Blame SOURCES/nspr-gcc-atomics.patch

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