Explorar el Código

ZOOKEEPER-1374. C client multi-threaded test suite fails to compile on ARM architectures. (James Page via mahadev)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1240952 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar hace 13 años
padre
commit
da05446a9f
Se han modificado 2 ficheros con 11 adiciones y 0 borrados
  1. 3 0
      CHANGES.txt
  2. 8 0
      src/c/tests/ThreadingUtil.cc

+ 3 - 0
CHANGES.txt

@@ -124,6 +124,9 @@ BUGFIXES:
 
 
   ZOOKEEPER-1340. multi problem - typical user operations are generating ERROR level 
   ZOOKEEPER-1340. multi problem - typical user operations are generating ERROR level 
   messages in the server (phunt via mahadev)
   messages in the server (phunt via mahadev)
+
+  ZOOKEEPER-1374. C client multi-threaded test suite fails to compile 
+  on ARM architectures. (James Page via mahadev)
  
  
 IMPROVEMENTS:
 IMPROVEMENTS:
 
 

+ 8 - 0
src/c/tests/ThreadingUtil.cc

@@ -47,6 +47,9 @@ void Mutex::release() {
 // Atomics
 // Atomics
 int32_t atomic_post_incr(volatile int32_t* operand, int32_t incr)
 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;
     int32_t result;
     __asm__ __volatile__(
     __asm__ __volatile__(
          "lock xaddl %0,%1\n"
          "lock xaddl %0,%1\n"
@@ -54,15 +57,20 @@ int32_t atomic_post_incr(volatile int32_t* operand, int32_t incr)
          : "0"(incr)
          : "0"(incr)
          : "memory");
          : "memory");
    return result;
    return result;
+#endif
 }
 }
 int32_t atomic_fetch_store(volatile int32_t *ptr, int32_t value)
 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;
     int32_t result;
     __asm__ __volatile__("lock xchgl %0,%1\n"
     __asm__ __volatile__("lock xchgl %0,%1\n"
                           : "=r"(result), "=m"(*ptr)
                           : "=r"(result), "=m"(*ptr)
                           : "0"(value)
                           : "0"(value)
                           : "memory");
                           : "memory");
    return result; 
    return result; 
+#endif
 }
 }
 #else
 #else
 int32_t atomic_post_incr(volatile int32_t* operand, int32_t incr){
 int32_t atomic_post_incr(volatile int32_t* operand, int32_t incr){