Last active
August 29, 2015 14:08
-
-
Save euskadi31/2e5a2f9e9d7e94a621e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- src/c/src/mt_adaptor.c 2014-10-30 13:40:02.000000000 +0100 | |
+++ src/c/src/mt_adaptor.c 2014-10-30 13:40:58.000000000 +0100 | |
@@ -483,25 +483,9 @@ | |
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 | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment