www.pudn.com > mediator15src.zip > mmxcheck.cpp


/* 
 * mmxcheck.cpp 
 * Copyright (C) 2001-2002 Arno Hornberger  
 * 
 * This file is part of MPEG Mediator, a free MPEG stream converter. 
 * 
 * MPEG Mediator is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * MPEG Mediator is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 */ 
 
#include  
 
#define _MMX_FEATURE_BIT        0x00800000 
 
static bool hasCPUID() 
{ 
	__try { 
		_asm 
    { 
			xor eax, eax 
      cpuid 
    } 
  } 
	__except (EXCEPTION_EXECUTE_HANDLER) { 
		return false; 
  } 
  return true; 
} 
 
bool mmx_available(void) 
{ 
  DWORD dwFeature = 0; 
 
  if (!hasCPUID()) 
		return false; 
 
  _asm 
  { 
    push ebx 
    push ecx 
    push edx 
 
    // get the Standard bits 
    mov eax,1 
    cpuid 
    mov dwFeature,edx 
 
    pop ecx 
    pop ebx 
    pop edx 
  } 
 
  if (dwFeature & _MMX_FEATURE_BIT) 
		return true; 
	else 
		return false; 
}