OpenImageIO/oiio-ppc.patch
Richard M. Shaw d9e76f50bd Update to lastest bugfix release.
- Upstream patch makes native spinlocks faster than TBB. TBB no longer needed.
2013-07-01 10:59:06 -05:00

64 lines
2.2 KiB
Diff

diff -up oiio-Release-1.1.10/src/include/thread.h.ppc oiio-Release-1.1.10/src/include/thread.h
--- oiio-Release-1.1.10/src/include/thread.h.ppc 2013-05-27 16:16:38.902025786 +0200
+++ oiio-Release-1.1.10/src/include/thread.h 2013-05-27 17:00:19.856167856 +0200
@@ -112,7 +112,7 @@ InterlockedExchangeAdd64 (volatile long
#endif
#if defined(__GNUC__) && (defined(_GLIBCXX_ATOMIC_BUILTINS) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 401))
-#if !defined(__FreeBSD__) || defined(__x86_64__)
+#if !defined(__FreeBSD__) && !defined(__powerpc__) || defined(__x86_64__)
#define USE_GCC_ATOMICS
#endif
#endif
@@ -235,6 +235,11 @@ atomic_exchange_and_add (volatile int *a
#elif defined(_MSC_VER)
// Windows
return _InterlockedExchangeAdd ((volatile LONG *)at, x);
+#elif defined (__powerpc__)
+ long long r;
+ r = *at;
+ *at += x;
+ return r;
#else
# error No atomics on this platform.
#endif
@@ -257,6 +262,11 @@ atomic_exchange_and_add (volatile long l
# else
return InterlockedExchangeAdd64 ((volatile LONGLONG *)at, x);
# endif
+#elif defined (__powerpc__)
+ long long r;
+ r = *at;
+ *at += x;
+ return r;
#else
# error No atomics on this platform.
#endif
@@ -280,6 +290,8 @@ atomic_compare_and_exchange (volatile in
return a->compare_and_swap (newval, compareval) == newval;
#elif defined(_MSC_VER)
return (_InterlockedCompareExchange ((volatile LONG *)at, newval, compareval) == compareval);
+#elif defined(__powerpc__)
+ return ((*at == compareval) ? (*at = newval), 1 : 0);
#else
# error No atomics on this platform.
#endif
@@ -297,6 +309,8 @@ atomic_compare_and_exchange (volatile lo
return a->compare_and_swap (newval, compareval) == newval;
#elif defined(_MSC_VER)
return (_InterlockedCompareExchange64 ((volatile LONGLONG *)at, newval, compareval) == compareval);
+#elif defined(__PPC__)
+ return ((*at == compareval) ? (*at = newval), 1 : 0);
#else
# error No atomics on this platform.
#endif
@@ -326,7 +340,7 @@ pause (int delay)
{
#if defined(__GNUC__)
for (int i = 0; i < delay; ++i) {
-#if defined __arm__ || defined __s390__
+#if defined __arm__ || defined __s390__ || defined __powerpc__
__asm__ __volatile__("NOP;");
#else
__asm__ __volatile__("pause;");