Fixed: #874 commented the old asm g++ code and use the builtin function. patch by rti

hg/feature/sound
vl 15 years ago
parent 94cb8e9c26
commit c29d30f319

@ -109,6 +109,7 @@ private:
// - () instead of [],
// - immediate values prefixed by $
/*
// Tested: works on multi-processor
#ifdef HAVE_X86_64
# define ASM_ASWAP_FOR_GCC_XCHG __asm__ volatile( \
@ -129,7 +130,9 @@ private:
: "m" (lockPtr) \
: "eax", "ecx", "memory" ); // force to use registers and memory
#endif
*/
/*
// Tested: does not work (at least on multi-processor)! (with or without 'lock' prefix)
#define ASM_ASWAP_FOR_GCC_CMPXCHG __asm__ volatile( \
"mov $1, %%edx;" \
@ -142,7 +145,7 @@ private:
: "=m" (result) \
: "m" (lockPtr) \
: "eax", "ecx", "edx", "memory" ); // force to use registers and memory
*/
// Tested: does not work on hyper-threading processors!
/*ASM_ASWAP_FOR_MSVC_CMPXCHG
@ -237,7 +240,11 @@ public:
# endif // NL_DEBUG
# endif // NL_NO_ASM
#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
return result != 0;
}

Loading…
Cancel
Save