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