zookeeper (3.3.5+dfsg1-2) fixes/ZOOKEEPER-1374

Summary

 src/c/tests/ThreadingUtil.cc |    8 ++++++++
 1 file changed, 8 insertions(+)

    
download this patch

Patch contents

Description: Use __sync primitives for better cross platform support when 
 compiling with gcc.
Origin: https://issues.apache.org/jira/browse/ZOOKEEPER-1374

Index: zookeeper/src/c/tests/ThreadingUtil.cc
===================================================================
--- zookeeper.orig/src/c/tests/ThreadingUtil.cc	2012-01-27 22:36:14.696423169 +0000
+++ zookeeper/src/c/tests/ThreadingUtil.cc	2012-01-27 22:36:46.460422374 +0000
@@ -47,6 +47,9 @@
 // Atomics
 int32_t atomic_post_incr(volatile int32_t* operand, int32_t incr)
 {
+#if defined(__GNUC__)
+    return __sync_fetch_and_add(operand,incr);
+#else
     int32_t result;
     __asm__ __volatile__(
          "lock xaddl %0,%1\n"
@@ -54,15 +57,20 @@
          : "0"(incr)
          : "memory");
    return result;
+#endif
 }
 int32_t atomic_fetch_store(volatile int32_t *ptr, int32_t value)
 {
+#if defined(__GNUC__)
+    return __sync_lock_test_and_set(ptr,value);
+#else
     int32_t result;
     __asm__ __volatile__("lock xchgl %0,%1\n"
                           : "=r"(result), "=m"(*ptr)
                           : "0"(value)
                           : "memory");
    return result; 
+#endif
 }
 #else
 int32_t atomic_post_incr(volatile int32_t* operand, int32_t incr){