cpusupport_x86_sse2.c 604 B

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