Blame SOURCES/nspr-gcc-atomics.patch

f14557
diff --git a/pr/include/md/_linux.h b/pr/include/md/_linux.h
f14557
--- a/pr/include/md/_linux.h
f14557
+++ b/pr/include/md/_linux.h
f14557
@@ -82,53 +82,73 @@
f14557
 #define NO_DLOPEN_NULL
f14557
 #endif
f14557
 
f14557
 #if defined(__FreeBSD_kernel__) || defined(__GNU__)
f14557
 #define _PR_HAVE_SOCKADDR_LEN
f14557
 #endif
f14557
 
f14557
 #if defined(__i386__)
f14557
+#if defined(__GNUC__)
f14557
+/* Use GCC built-in functions */
f14557
+#define _PR_HAVE_ATOMIC_OPS
f14557
+#define _MD_INIT_ATOMIC()
f14557
+#define _MD_ATOMIC_INCREMENT(ptr) __sync_add_and_fetch(ptr, 1)
f14557
+#define _MD_ATOMIC_DECREMENT(ptr) __sync_sub_and_fetch(ptr, 1)
f14557
+#define _MD_ATOMIC_ADD(ptr, i) __sync_add_and_fetch(ptr, i)
f14557
+#define _MD_ATOMIC_SET(ptr, nv) __sync_lock_test_and_set(ptr, nv)
f14557
+#else
f14557
 #define _PR_HAVE_ATOMIC_OPS
f14557
 #define _MD_INIT_ATOMIC()
f14557
 extern PRInt32 _PR_x86_AtomicIncrement(PRInt32 *val);
f14557
 #define _MD_ATOMIC_INCREMENT          _PR_x86_AtomicIncrement
f14557
 extern PRInt32 _PR_x86_AtomicDecrement(PRInt32 *val);
f14557
 #define _MD_ATOMIC_DECREMENT          _PR_x86_AtomicDecrement
f14557
 extern PRInt32 _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val);
f14557
 #define _MD_ATOMIC_ADD                _PR_x86_AtomicAdd
f14557
 extern PRInt32 _PR_x86_AtomicSet(PRInt32 *val, PRInt32 newval);
f14557
 #define _MD_ATOMIC_SET                _PR_x86_AtomicSet
f14557
 #endif
f14557
+#endif
f14557
 
f14557
 #if defined(__ia64__)
f14557
 #define _PR_HAVE_ATOMIC_OPS
f14557
 #define _MD_INIT_ATOMIC()
f14557
 extern PRInt32 _PR_ia64_AtomicIncrement(PRInt32 *val);
f14557
 #define _MD_ATOMIC_INCREMENT          _PR_ia64_AtomicIncrement
f14557
 extern PRInt32 _PR_ia64_AtomicDecrement(PRInt32 *val);
f14557
 #define _MD_ATOMIC_DECREMENT          _PR_ia64_AtomicDecrement
f14557
 extern PRInt32 _PR_ia64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
f14557
 #define _MD_ATOMIC_ADD                _PR_ia64_AtomicAdd
f14557
 extern PRInt32 _PR_ia64_AtomicSet(PRInt32 *val, PRInt32 newval);
f14557
 #define _MD_ATOMIC_SET                _PR_ia64_AtomicSet
f14557
 #endif
f14557
 
f14557
 #if defined(__x86_64__)
f14557
+#if defined(__GNUC__)
f14557
+/* Use GCC built-in functions */
f14557
+#define _PR_HAVE_ATOMIC_OPS
f14557
+#define _MD_INIT_ATOMIC()
f14557
+#define _MD_ATOMIC_INCREMENT(ptr) __sync_add_and_fetch(ptr, 1)
f14557
+#define _MD_ATOMIC_DECREMENT(ptr) __sync_sub_and_fetch(ptr, 1)
f14557
+#define _MD_ATOMIC_ADD(ptr, i) __sync_add_and_fetch(ptr, i)
f14557
+#define _MD_ATOMIC_SET(ptr, nv) __sync_lock_test_and_set(ptr, nv)
f14557
+#else
f14557
 #define _PR_HAVE_ATOMIC_OPS
f14557
 #define _MD_INIT_ATOMIC()
f14557
 extern PRInt32 _PR_x86_64_AtomicIncrement(PRInt32 *val);
f14557
 #define _MD_ATOMIC_INCREMENT          _PR_x86_64_AtomicIncrement
f14557
 extern PRInt32 _PR_x86_64_AtomicDecrement(PRInt32 *val);
f14557
 #define _MD_ATOMIC_DECREMENT          _PR_x86_64_AtomicDecrement
f14557
 extern PRInt32 _PR_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
f14557
 #define _MD_ATOMIC_ADD                _PR_x86_64_AtomicAdd
f14557
 extern PRInt32 _PR_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);
f14557
 #define _MD_ATOMIC_SET                _PR_x86_64_AtomicSet
f14557
 #endif
f14557
+#endif
f14557
 
f14557
 #if defined(__or1k__)
f14557
 #if defined(__GNUC__)
f14557
 /* Use GCC built-in functions */
f14557
 #define _PR_HAVE_ATOMIC_OPS
f14557
 #define _MD_INIT_ATOMIC()
f14557
 #define _MD_ATOMIC_INCREMENT(ptr) __sync_add_and_fetch(ptr, 1)
f14557
 #define _MD_ATOMIC_DECREMENT(ptr) __sync_sub_and_fetch(ptr, 1)