diff --git a/CHANGES.txt b/CHANGES.txt index 0c1287c018a..38bbcf79399 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -505,6 +505,9 @@ IMPROVEMENTS: ZOOKEEPER-1601. document changes for multi-threaded CommitProcessor and NIOServerCnxn (Thawan Kooburat via phunt) + ZOOKEEPER-1643. Windows: fetch_and_add not 64bit-compatible, may not be + correct (Erik Anderson via michim) + Release 3.4.0 - Non-backward compatible changes: diff --git a/src/c/src/mt_adaptor.c b/src/c/src/mt_adaptor.c index 833bead3da5..68c5eb3176a 100644 --- a/src/c/src/mt_adaptor.c +++ b/src/c/src/mt_adaptor.c @@ -484,25 +484,9 @@ int32_t inc_ref_counter(zhandle_t* zh,int i) 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; + return __sync_fetch_and_add(operand, incr); #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; + return InterlockedExchangeAdd(operand, incr); #endif }