From Piotr Domagalski, "Currently, code using OpenSceneGraph doesn't build with clang due to the way __sync_bool_compare_and_swap() is used in OpenThreads/Atomic header file.

I tested it with clang 3.1 and it seems that clang is enforcing the use of the same type for all parameters in this builtin. Looking at the function declaration [1]

bool __sync_bool_compare_and_swap (type *ptr, type oldval type newval, ...)

it seems to be doing the right thing: here the same type is used for *ptr, oldval and newval.

[1] http://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html#g_t_005f_005fsync-Builtins
"
This commit is contained in:
Robert Osfield 2012-09-06 10:52:28 +00:00
parent 5a99e4672e
commit 3b8802c5aa

View File

@ -241,7 +241,7 @@ _OPENTHREADS_ATOMIC_INLINE bool
AtomicPtr::assign(void* ptrNew, const void* const ptrOld) AtomicPtr::assign(void* ptrNew, const void* const ptrOld)
{ {
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS) #if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
return __sync_bool_compare_and_swap(&_ptr, ptrOld, ptrNew); return __sync_bool_compare_and_swap(&_ptr, (void *)ptrOld, ptrNew);
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS) #elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
return __compare_and_swap((unsigned long*)&_ptr, (unsigned long)ptrOld, (unsigned long)ptrNew); return __compare_and_swap((unsigned long*)&_ptr, (unsigned long)ptrOld, (unsigned long)ptrNew);
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN) #elif defined(_OPENTHREADS_ATOMIC_USE_SUN)