Blame zookeeper-3.4.5-atomic.patch
|
|
ebc3b4d |
diff -up zookeeper-3.4.5/src/c/src/mt_adaptor.c.atomic zookeeper-3.4.5/src/c/src/mt_adaptor.c
|
|
|
ebc3b4d |
--- zookeeper-3.4.5/src/c/src/mt_adaptor.c.atomic 2013-06-14 09:58:27.000000000 +0200
|
|
|
ebc3b4d |
+++ zookeeper-3.4.5/src/c/src/mt_adaptor.c 2013-06-14 10:00:09.000000000 +0200
|
|
|
ebc3b4d |
@@ -482,27 +482,7 @@ int32_t inc_ref_counter(zhandle_t* zh,in
|
|
|
ebc3b4d |
|
|
|
ebc3b4d |
int32_t fetch_and_add(volatile int32_t* operand, int incr)
|
|
|
ebc3b4d |
{
|
|
|
ebc3b4d |
-#ifndef WIN32
|
|
|
ebc3b4d |
- int32_t result;
|
|
|
ebc3b4d |
- asm __volatile__(
|
|
|
ebc3b4d |
- "lock xaddl %0,%1\n"
|
|
|
ebc3b4d |
- : "=r"(result), "=m"(*(int *)operand)
|
|
|
ebc3b4d |
- : "0"(incr)
|
|
|
ebc3b4d |
- : "memory");
|
|
|
ebc3b4d |
- return result;
|
|
|
ebc3b4d |
-#else
|
|
|
ebc3b4d |
- volatile int32_t result;
|
|
|
ebc3b4d |
- _asm
|
|
|
ebc3b4d |
- {
|
|
|
ebc3b4d |
- mov eax, operand; //eax = v;
|
|
|
ebc3b4d |
- mov ebx, incr; // ebx = i;
|
|
|
ebc3b4d |
- mov ecx, 0x0; // ecx = 0;
|
|
|
ebc3b4d |
- lock xadd dword ptr [eax], ecx;
|
|
|
ebc3b4d |
- lock xadd dword ptr [eax], ebx;
|
|
|
ebc3b4d |
- mov result, ecx; // result = ebx;
|
|
|
ebc3b4d |
- }
|
|
|
ebc3b4d |
- return result;
|
|
|
ebc3b4d |
-#endif
|
|
|
ebc3b4d |
+ return __atomic_add_fetch(operand, incr, __ATOMIC_SEQ_CST);
|
|
|
ebc3b4d |
}
|
|
|
ebc3b4d |
|
|
|
ebc3b4d |
// make sure the static xid is initialized before any threads started
|