mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 04:51:52 +00:00
Fixed: #874 commented the old asm g++ code and use the builtin function. patch by rti
This commit is contained in:
parent
632eaaaea6
commit
0347a1839d
1 changed files with 9 additions and 2 deletions
|
@ -109,6 +109,7 @@ private:
|
||||||
// - () instead of [],
|
// - () instead of [],
|
||||||
// - immediate values prefixed by $
|
// - immediate values prefixed by $
|
||||||
|
|
||||||
|
/*
|
||||||
// Tested: works on multi-processor
|
// Tested: works on multi-processor
|
||||||
#ifdef HAVE_X86_64
|
#ifdef HAVE_X86_64
|
||||||
# define ASM_ASWAP_FOR_GCC_XCHG __asm__ volatile( \
|
# define ASM_ASWAP_FOR_GCC_XCHG __asm__ volatile( \
|
||||||
|
@ -129,7 +130,9 @@ private:
|
||||||
: "m" (lockPtr) \
|
: "m" (lockPtr) \
|
||||||
: "eax", "ecx", "memory" ); // force to use registers and memory
|
: "eax", "ecx", "memory" ); // force to use registers and memory
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
// Tested: does not work (at least on multi-processor)! (with or without 'lock' prefix)
|
// Tested: does not work (at least on multi-processor)! (with or without 'lock' prefix)
|
||||||
#define ASM_ASWAP_FOR_GCC_CMPXCHG __asm__ volatile( \
|
#define ASM_ASWAP_FOR_GCC_CMPXCHG __asm__ volatile( \
|
||||||
"mov $1, %%edx;" \
|
"mov $1, %%edx;" \
|
||||||
|
@ -142,7 +145,7 @@ private:
|
||||||
: "=m" (result) \
|
: "=m" (result) \
|
||||||
: "m" (lockPtr) \
|
: "m" (lockPtr) \
|
||||||
: "eax", "ecx", "edx", "memory" ); // force to use registers and memory
|
: "eax", "ecx", "edx", "memory" ); // force to use registers and memory
|
||||||
|
*/
|
||||||
|
|
||||||
// Tested: does not work on hyper-threading processors!
|
// Tested: does not work on hyper-threading processors!
|
||||||
/*ASM_ASWAP_FOR_MSVC_CMPXCHG
|
/*ASM_ASWAP_FOR_MSVC_CMPXCHG
|
||||||
|
@ -237,7 +240,11 @@ public:
|
||||||
# endif // NL_DEBUG
|
# endif // NL_DEBUG
|
||||||
# endif // NL_NO_ASM
|
# endif // NL_NO_ASM
|
||||||
#else
|
#else
|
||||||
ASM_ASWAP_FOR_GCC_XCHG
|
// GCC implements the same functionality using a builtin function
|
||||||
|
// http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html
|
||||||
|
// the macro below crashed on Mac OS X 10.6 in a 64bit build
|
||||||
|
//ASM_ASWAP_FOR_GCC_XCHG
|
||||||
|
result = __sync_bool_compare_and_swap(lockPtr, 0, 1);
|
||||||
#endif // NL_OS_WINDOWS
|
#endif // NL_OS_WINDOWS
|
||||||
return result != 0;
|
return result != 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue