OpenImageIO/oiio-ppc.patch

64 lines
2.2 KiB
Diff
Raw Normal View History

2013-05-27 15:21:41 +00:00
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__)
2013-05-27 15:21:41 +00:00
+#if !defined(__FreeBSD__) && !defined(__powerpc__) || defined(__x86_64__)
#define USE_GCC_ATOMICS
#endif
#endif
2013-05-27 15:21:41 +00:00
@@ -235,6 +235,11 @@ atomic_exchange_and_add (volatile int *a
2013-01-28 13:34:02 +00:00
#elif defined(_MSC_VER)
2012-06-12 19:03:59 +00:00
// Windows
return _InterlockedExchangeAdd ((volatile LONG *)at, x);
2013-05-27 15:21:41 +00:00
+#elif defined (__powerpc__)
2013-01-28 13:34:02 +00:00
+ long long r;
+ r = *at;
+ *at += x;
+ return r;
2012-06-12 19:03:59 +00:00
#else
# error No atomics on this platform.
#endif
2013-05-27 15:21:41 +00:00
@@ -257,6 +262,11 @@ atomic_exchange_and_add (volatile long l
2012-06-12 19:03:59 +00:00
# else
return InterlockedExchangeAdd64 ((volatile LONGLONG *)at, x);
# endif
2013-05-27 15:21:41 +00:00
+#elif defined (__powerpc__)
2012-06-12 19:03:59 +00:00
+ long long r;
+ r = *at;
+ *at += x;
+ return r;
#else
# error No atomics on this platform.
#endif
2013-05-27 15:21:41 +00:00
@@ -280,6 +290,8 @@ atomic_compare_and_exchange (volatile in
return a->compare_and_swap (newval, compareval) == newval;
2013-01-28 13:34:02 +00:00
#elif defined(_MSC_VER)
2012-06-12 19:03:59 +00:00
return (_InterlockedCompareExchange ((volatile LONG *)at, newval, compareval) == compareval);
2013-05-27 15:21:41 +00:00
+#elif defined(__powerpc__)
2012-06-12 19:03:59 +00:00
+ return ((*at == compareval) ? (*at = newval), 1 : 0);
#else
# error No atomics on this platform.
#endif
2013-05-27 15:21:41 +00:00
@@ -297,6 +309,8 @@ atomic_compare_and_exchange (volatile lo
return a->compare_and_swap (newval, compareval) == newval;
2013-01-28 13:34:02 +00:00
#elif defined(_MSC_VER)
2012-06-12 19:03:59 +00:00
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
2013-05-27 15:21:41 +00:00
@@ -326,7 +340,7 @@ pause (int delay)
2013-01-28 15:52:46 +00:00
{
2013-05-27 15:21:41 +00:00
#if defined(__GNUC__)
2013-01-28 15:52:46 +00:00
for (int i = 0; i < delay; ++i) {
2013-05-27 15:21:41 +00:00
-#if defined __arm__ || defined __s390__
+#if defined __arm__ || defined __s390__ || defined __powerpc__
__asm__ __volatile__("NOP;");
#else
2013-01-28 15:52:46 +00:00
__asm__ __volatile__("pause;");