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