Browse Source

display: remove CPUID ASM, use __get_cpuid(_max) (on macOS too)

I think this requires at least XCode 5.
rdb 6 years ago
parent
commit
651cf189fc
1 changed files with 5 additions and 7 deletions
  1. 5 7
      panda/src/display/graphicsPipe.cxx

+ 5 - 7
panda/src/display/graphicsPipe.cxx

@@ -38,7 +38,7 @@
 // CPUID is only available on i386 and x86-64 architectures.
 #if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
 
-#if defined(__GNUC__) && !defined(__APPLE__)
+#ifdef __GNUC__
 // GCC and Clang offer a useful cpuid.h header.
 #include <cpuid.h>
 #endif
@@ -59,14 +59,12 @@ union cpuid_info {
  * Gets cpuid info for the given leaf.
  */
 static inline void get_cpuid(uint32_t leaf, cpuid_info &info) {
-#if defined(__GNUC__) && !defined(__APPLE__)
-  __cpuid(leaf, info.eax, info.ebx, info.ecx, info.edx);
+#if defined(__GNUC__)
+  __get_cpuid(leaf, &info.eax, &info.ebx, &info.ecx, &info.edx);
 #elif defined(_MSC_VER)
   __cpuid((int *)info.str, leaf);
 #else
-  __asm__ ("cpuid\n\t"
-           : "=a" (info.eax), "=b" (info.ebx), "=c" (info.ecx), "=d" (info.edx)
-           : "0" (leaf));
+#  error No CPUID intrinsic is known for this compiler!
 #endif
 }
 
@@ -74,7 +72,7 @@ static inline void get_cpuid(uint32_t leaf, cpuid_info &info) {
  * Returns the highest cpuid leaf that is supported by the CPU.
  */
 static inline uint32_t get_cpuid_max(uint32_t leaf) {
-#if defined(__GNUC__) && !defined(__APPLE__)
+#if defined(__GNUC__)
   return __get_cpuid_max(leaf, nullptr);
 #else
   cpuid_info info;