Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2014
577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.60 KB | None | 0 0
  1. diff --git a/dep/include/g3dlite/G3D/AtomicInt32.h b/dep/include/g3dlite/G3D/AtomicInt32.h
  2. index 2d63f99..9a5722d 100644
  3. --- a/dep/include/g3dlite/G3D/AtomicInt32.h
  4. +++ b/dep/include/g3dlite/G3D/AtomicInt32.h
  5. @@ -76,13 +76,8 @@ public:
  6.  
  7.  #       elif defined(G3D_LINUX) || defined(G3D_FREEBSD)
  8.  
  9. -            int32 old;
  10. -            asm volatile ("lock; xaddl %0,%1"
  11. -                  : "=r"(old), "=m"(m_value) /* outputs */
  12. -                  : "0"(x), "m"(m_value)   /* inputs */
  13. -                  : "memory", "cc");
  14. -            return old;
  15. -            
  16. +            return __sync_fetch_and_add(&m_value, 1);
  17. +
  18.  #       elif defined(G3D_OSX)
  19.  
  20.              int32 old = m_value;
  21. @@ -115,14 +110,7 @@ public:
  22.              // Note: returns the newly decremented value
  23.              return InterlockedDecrement(&m_value);
  24.  #       elif defined(G3D_LINUX)  || defined(G3D_FREEBSD)
  25. -            unsigned char nz;
  26. -
  27. -            asm volatile ("lock; decl %1;\n\t"
  28. -                          "setnz %%al"
  29. -                          : "=a" (nz)
  30. -                          : "m" (m_value)
  31. -                          : "memory", "cc");
  32. -            return nz;
  33. +           return __sync_sub_and_fetch(&m_value, 1);
  34.  #       elif defined(G3D_OSX)
  35.              // Note: returns the newly decremented value
  36.              return OSAtomicDecrement32(&m_value);
  37. @@ -142,7 +130,9 @@ public:
  38.      int32 compareAndSet(const int32 comperand, const int32 exchange) {
  39.  #       if defined(G3D_WIN32)
  40.              return InterlockedCompareExchange(&m_value, exchange, comperand);
  41. -#       elif defined(G3D_LINUX) || defined(G3D_FREEBSD) || defined(G3D_OSX)
  42. +#       elif defined(G3D_LINUX) || defined(G3D_FREEBSD)
  43. +       return __sync_val_compare_and_swap(&m_value, comperand, exchange);
  44. +# elif defined(G3D_OSX)
  45.              // Based on Apache Portable Runtime
  46.              // http://koders.com/c/fid3B6631EE94542CDBAA03E822CA780CBA1B024822.aspx
  47.              int32 ret;
  48. diff --git a/dep/include/g3dlite/G3D/platform.h b/dep/include/g3dlite/G3D/platform.h
  49. index c6018bb..985301a 100644
  50. --- a/dep/include/g3dlite/G3D/platform.h
  51. +++ b/dep/include/g3dlite/G3D/platform.h
  52. @@ -270,8 +270,13 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) {\
  53.  #       ifndef __stdcall
  54.  #           define __stdcall
  55.  #       endif
  56. +# elif defined(__arm__)
  57. +
  58. + // CDECL does not apply to arm.
  59. +# define __cdecl
  60.  #   endif // calling conventions
  61.  
  62. +
  63.  /** @def G3D_CHECK_PRINTF_METHOD_ARGS()
  64.      Enables printf parameter validation on gcc. */
  65.  #   define G3D_CHECK_PRINTF_METHOD_ARGS   __attribute__((__format__(__printf__, 2, 3)))
  66. diff --git a/dep/src/g3dlite/System.cpp b/dep/src/g3dlite/System.cpp
  67. index ce190d0..a4cfab2 100644
  68. --- a/dep/src/g3dlite/System.cpp
  69. +++ b/dep/src/g3dlite/System.cpp
  70. @@ -524,8 +524,11 @@ static bool checkForCPUID() {
  71.      // all known supported architectures have cpuid
  72.      // add cases for incompatible architectures if they are added
  73.      // e.g., if we ever support __powerpc__ being defined again
  74. -
  75. +#if defined(__arm__)
  76. +    return false;
  77. +#else
  78.      return true;
  79. +#endif
  80.  }
  81.  
  82.  
  83. @@ -1730,6 +1733,14 @@ void System::cpuid(CPUIDFunction func, uint32& eax, uint32& ebx, uint32& ecx, ui
  84.      edx = 0;
  85.  }
  86.  
  87. +#elif defined(G3D_LINUX) && defined(__arm__)
  88. +// non-x86 CPU; no CPUID, at least in userspace
  89. +void System::cpuid(CPUIDFunction func, uint32& eax, uint32& ebx, uint32& ecx, uint32& edx) {
  90. +    eax = 0;
  91. +    ebx = 0;
  92. +    ecx = 0;
  93. +    edx = 0;
  94. +}
  95.  #else
  96.  
  97.  // See http://sam.zoy.org/blog/2007-04-13-shlib-with-non-pic-code-have-inline-assembly-and-pic-mix-well
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement