cpusupport_x86_shani.c 836 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "cpusupport.h"
  2. #ifdef CPUSUPPORT_X86_CPUID_COUNT
  3. #include <cpuid.h>
  4. #define CPUID_SHANI_BIT (1 << 29)
  5. #endif
  6. CPUSUPPORT_FEATURE_DECL(x86, shani)
  7. {
  8. #ifdef CPUSUPPORT_X86_CPUID_COUNT
  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 < 7)
  14. goto unsupported;
  15. /*
  16. * Ask about extended CPU features. Note that this macro violates
  17. * the principle of being "function-like" by taking the variables
  18. * used for holding output registers as named parameters rather than
  19. * as pointers (which would be necessary if __cpuid_count were a
  20. * function).
  21. */
  22. __cpuid_count(7, 0, eax, ebx, ecx, edx);
  23. /* Return the relevant feature bit. */
  24. return ((ebx & CPUID_SHANI_BIT) ? 1 : 0);
  25. unsupported:
  26. #endif
  27. return (0);
  28. }