Browse Source

Fixes for ARM build

rdb 8 years ago
parent
commit
3db8ce2562
2 changed files with 19 additions and 7 deletions
  1. 6 0
      panda/src/display/displayInformation.cxx
  2. 13 7
      panda/src/display/graphicsPipe.cxx

+ 6 - 0
panda/src/display/displayInformation.cxx

@@ -15,11 +15,13 @@
 #include "displayInformation.h"
 #include "displayInformation.h"
 
 
 // For __rdtsc
 // For __rdtsc
+#if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
 #ifdef _MSC_VER
 #ifdef _MSC_VER
 #include <intrin.h>
 #include <intrin.h>
 #elif defined(__GNUC__) && !defined(__clang__)
 #elif defined(__GNUC__) && !defined(__clang__)
 #include <x86intrin.h>
 #include <x86intrin.h>
 #endif
 #endif
+#endif
 
 
 /**
 /**
  * Returns true if these two DisplayModes are identical.
  * Returns true if these two DisplayModes are identical.
@@ -529,6 +531,7 @@ get_cpu_frequency() {
  */
  */
 uint64_t DisplayInformation::
 uint64_t DisplayInformation::
 get_cpu_time() {
 get_cpu_time() {
+#if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
 #if defined(_MSC_VER) || (defined(__GNUC__) && !defined(__clang__))
 #if defined(_MSC_VER) || (defined(__GNUC__) && !defined(__clang__))
   return __rdtsc();
   return __rdtsc();
 #else
 #else
@@ -536,6 +539,9 @@ get_cpu_time() {
   __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
   __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
   return ((uint64_t)hi << 32) | lo;
   return ((uint64_t)hi << 32) | lo;
 #endif
 #endif
+#else
+  return 0;
+#endif
 }
 }
 
 
 /**
 /**

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

@@ -28,6 +28,16 @@
 #include <unistd.h>
 #include <unistd.h>
 #endif
 #endif
 
 
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include <windows.h>
+#endif
+
+// 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__)
 #if defined(__GNUC__) && !defined(__APPLE__)
 // GCC and Clang offer a useful cpuid.h header.
 // GCC and Clang offer a useful cpuid.h header.
 #include <cpuid.h>
 #include <cpuid.h>
@@ -38,13 +48,6 @@
 #include <intrin.h>
 #include <intrin.h>
 #endif
 #endif
 
 
-#ifdef _WIN32
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN 1
-#endif
-#include <windows.h>
-#endif
-
 union cpuid_info {
 union cpuid_info {
   char str[16];
   char str[16];
   struct {
   struct {
@@ -85,6 +88,7 @@ static inline void get_cpuid(uint32_t leaf, cpuid_info &info) {
            : "0" (leaf));
            : "0" (leaf));
 #endif
 #endif
 }
 }
+#endif
 
 
 #ifdef IS_LINUX
 #ifdef IS_LINUX
 /**
 /**
@@ -123,6 +127,7 @@ GraphicsPipe() :
 
 
   _display_information = new DisplayInformation();
   _display_information = new DisplayInformation();
 
 
+#if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
   cpuid_info info;
   cpuid_info info;
   const uint32_t max_cpuid = get_cpuid_max(0);
   const uint32_t max_cpuid = get_cpuid_max(0);
   const uint32_t max_extended = get_cpuid_max(0x80000000);
   const uint32_t max_extended = get_cpuid_max(0x80000000);
@@ -148,6 +153,7 @@ GraphicsPipe() :
     brand[48] = 0;
     brand[48] = 0;
     _display_information->_cpu_brand_string = brand;
     _display_information->_cpu_brand_string = brand;
   }
   }
+#endif
 
 
 #if defined(IS_OSX)
 #if defined(IS_OSX)
   // macOS exposes a lot of useful information through sysctl.
   // macOS exposes a lot of useful information through sysctl.