zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject zookeeper git commit: ZOOKEEPER-1643. Windows: fetch_and_add not 64bit-compatible, may not be correct (Erik Anderson via michim)
Date Tue, 01 Aug 2017 15:41:20 GMT
Repository: zookeeper
Updated Branches:
  refs/heads/branch-3.4 76553b0ca -> 7956f138a


ZOOKEEPER-1643. Windows: fetch_and_add not 64bit-compatible, may not be correct (Erik Anderson
via michim)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1448007 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/7956f138
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/7956f138
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/7956f138

Branch: refs/heads/branch-3.4
Commit: 7956f138a781b2b4bd166c50e49bbad83d40c2a8
Parents: 76553b0
Author: Michi Mutsuzaki <michim@apache.org>
Authored: Wed Feb 20 05:24:31 2013 +0000
Committer: Michael Han <hanm@apache.org>
Committed: Tue Aug 1 08:41:10 2017 -0700

----------------------------------------------------------------------
 src/c/src/mt_adaptor.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zookeeper/blob/7956f138/src/c/src/mt_adaptor.c
----------------------------------------------------------------------
diff --git a/src/c/src/mt_adaptor.c b/src/c/src/mt_adaptor.c
index 7dc7878..1b18ac6 100644
--- a/src/c/src/mt_adaptor.c
+++ b/src/c/src/mt_adaptor.c
@@ -483,25 +483,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
 }
 


Mime
View raw message