1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include "cpusupport.h"
#ifdef CPUSUPPORT_X86_CPUID
#include <cpuid.h>
#define CPUID_SSE2_BIT (1 << 26)
#endif
CPUSUPPORT_FEATURE_DECL(x86, sse2)
{
#ifdef CPUSUPPORT_X86_CPUID
unsigned int eax, ebx, ecx, edx;
/* Check if CPUID supports the level we need. */
if (!__get_cpuid(0, &eax, &ebx, &ecx, &edx))
goto unsupported;
if (eax < 1)
goto unsupported;
/* Ask about CPU features. */
if (!__get_cpuid(1, &eax, &ebx, &ecx, &edx))
goto unsupported;
/* Return the relevant feature bit. */
return ((edx & CPUID_SSE2_BIT) ? 1 : 0);
unsupported:
#endif
return (0);
}
|