cpusupport_x86_sse2.c 581 B

12345678910111213141516171819202122232425262728293031
  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. return (0);
  23. }