work around missing atomic operations on PPC(64)

This commit is contained in:
Karsten Hopp 2012-04-25 15:37:04 +02:00
parent 7d30ff8a52
commit b4a6f6c67c
2 changed files with 87 additions and 1 deletions

81
OpenImageIO-ppc.patch Normal file
View File

@ -0,0 +1,81 @@
diff -up OpenImageIO-oiio-1fa4a20/src/include/thread.h.ppckh OpenImageIO-oiio-1fa4a20/src/include/thread.h
--- OpenImageIO-oiio-1fa4a20/src/include/thread.h.ppckh 2012-04-25 15:29:32.530321567 +0200
+++ OpenImageIO-oiio-1fa4a20/src/include/thread.h 2012-04-25 15:29:42.490320642 +0200
@@ -256,7 +256,7 @@ private:
inline int
atomic_exchange_and_add (volatile int *at, int x)
{
-#if defined(__GNUC__) && (defined(_GLIBCXX_ATOMIC_BUILTINS) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 401))
+#if defined(__GNUC__) && (defined(_GLIBCXX_ATOMIC_BUILTINS) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 401)) && ! defined(__PPC__)
return __sync_fetch_and_add ((int *)at, x);
#elif USE_TBB
atomic<int> *a = (atomic<int> *)at;
@@ -267,6 +267,11 @@ atomic_exchange_and_add (volatile int *a
#elif defined(_WIN32)
// Windows
return _InterlockedExchangeAdd ((volatile LONG *)at, x);
+#elif defined (__PPC__)
+ long long r;
+ r = *at;
+ *at += x;
+ return r;
#else
# error No atomics on this platform.
#endif
@@ -277,7 +282,7 @@ atomic_exchange_and_add (volatile int *a
inline long long
atomic_exchange_and_add (volatile long long *at, long long x)
{
-#if defined(__GNUC__) && (defined(_GLIBCXX_ATOMIC_BUILTINS) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 401))
+#if defined(__GNUC__) && (defined(_GLIBCXX_ATOMIC_BUILTINS) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 401)) && ! defined(__PPC__)
return __sync_fetch_and_add (at, x);
#elif USE_TBB
atomic<long long> *a = (atomic<long long> *)at;
@@ -292,6 +297,11 @@ atomic_exchange_and_add (volatile long l
# else
return InterlockedExchangeAdd64 ((volatile LONGLONG *)at, x);
# endif
+#elif defined (__PPC__)
+ long long r;
+ r = *at;
+ *at += x;
+ return r;
#else
# error No atomics on this platform.
#endif
@@ -308,7 +318,7 @@ atomic_exchange_and_add (volatile long l
inline bool
atomic_compare_and_exchange (volatile int *at, int compareval, int newval)
{
-#if defined(__GNUC__) && (defined(_GLIBCXX_ATOMIC_BUILTINS) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 401))
+#if defined(__GNUC__) && (defined(_GLIBCXX_ATOMIC_BUILTINS) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 401)) && ! defined (__PPC__)
return __sync_bool_compare_and_swap (at, compareval, newval);
#elif USE_TBB
atomic<int> *a = (atomic<int> *)at;
@@ -317,6 +327,8 @@ atomic_compare_and_exchange (volatile in
return OSAtomicCompareAndSwap32Barrier (compareval, newval, at);
#elif defined(_WIN32)
return (_InterlockedCompareExchange ((volatile LONG *)at, newval, compareval) == compareval);
+#elif defined(__PPC__)
+ return ((*at == compareval) ? (*at = newval), 1 : 0);
#else
# error No atomics on this platform.
#endif
@@ -327,7 +339,7 @@ atomic_compare_and_exchange (volatile in
inline bool
atomic_compare_and_exchange (volatile long long *at, long long compareval, long long newval)
{
-#if defined(__GNUC__) && (defined(_GLIBCXX_ATOMIC_BUILTINS) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 401))
+#if defined(__GNUC__) && (defined(_GLIBCXX_ATOMIC_BUILTINS) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 401)) && ! defined (__PPC__)
return __sync_bool_compare_and_swap (at, compareval, newval);
#elif USE_TBB
atomic<long long> *a = (atomic<long long> *)at;
@@ -336,6 +348,8 @@ atomic_compare_and_exchange (volatile lo
return OSAtomicCompareAndSwap64Barrier (compareval, newval, at);
#elif defined(_WIN32)
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

View File

@ -3,7 +3,7 @@
Name: OpenImageIO
Version: 0.10.8
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Library for reading and writing images
Group: Development/Libraries
@ -18,6 +18,7 @@ Patch1: OpenImageIO-0.10.0-atomic_test_fix.patch
Patch2: OpenImageIO-0.10.3-use_external_tbb.patch
Patch3: OpenImageIO-0.10.2-Z_BEST_COMPRESSION.patch
Patch4: OpenImageIO-0.10.4-no_tbb.patch
Patch5: OpenImageIO-ppc.patch
BuildRequires: boost-devel glew-devel qt-devel OpenEXR-devel ilmbase-devel
BuildRequires: python2-devel txt2man
@ -66,6 +67,7 @@ Development files for package %{name}
%patch2 -p1 -b .tbb
%patch3 -p1 -b .zlib
%patch4 -p1 -b .no-tbb
%patch5 -p1 -b .ppckh
# Remove bundled pugixml
rm -f src/include/pugixml.hpp \
@ -130,6 +132,9 @@ cp -a doc/*.1 %{buildroot}%{_mandir}/man1
%changelog
* Wed Apr 25 2012 Karsten Hopp <karsten@redhat.com> 0.10.8-2
- work around missing atomic operations on PPC(64)
* Thu Apr 19 2012 Richard Shaw <hobbes1069@gmail.com> - 0.10.8-1
- Update to latest upstream release.