1 Star 0 Fork 19

付善庆 / zookeeper

forked from src-openEuler / zookeeper 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
mt_adaptor.c.patch 922 Bytes
一键复制 编辑 原始数据 按行查看 历史
rocky 提交于 2023-08-11 09:34 . init
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
}
1
https://gitee.com/fu-shanqing/zookeeper.git
git@gitee.com:fu-shanqing/zookeeper.git
fu-shanqing
zookeeper
zookeeper
master

搜索帮助