Index: lib/builtins/atomic.c =================================================================== --- lib/builtins/atomic.c +++ lib/builtins/atomic.c @@ -30,12 +30,17 @@ #include "assembly.h" +#ifdef __clang__ // Clang objects if you redefine a builtin. This little hack allows us to // define a function with the same name as an intrinsic. -#pragma redefine_extname __atomic_load_c SYMBOL_NAME(__atomic_load) -#pragma redefine_extname __atomic_store_c SYMBOL_NAME(__atomic_store) -#pragma redefine_extname __atomic_exchange_c SYMBOL_NAME(__atomic_exchange) -#pragma redefine_extname __atomic_compare_exchange_c SYMBOL_NAME(__atomic_compare_exchange) +#define ATOMIC_IMPL_SYMBOL(x) x##_c +#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_load) SYMBOL_NAME(__atomic_load) +#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_store) SYMBOL_NAME(__atomic_store) +#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_exchange) SYMBOL_NAME(__atomic_exchange) +#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_compare_exchange) SYMBOL_NAME(__atomic_compare_exchange) +#else +#define ATOMIC_IMPL_SYMBOL(x) SYMBOL_NAME(x) +#endif /// Number of locks. This allocates one page on 32-bit platforms, two on /// 64-bit. This can be specified externally if a different trade between @@ -159,7 +164,7 @@ /// An atomic load operation. This is atomic with respect to the source /// pointer only. -void __atomic_load_c(int size, void *src, void *dest, int model) { +void ATOMIC_IMPL_SYMBOL(__atomic_load)(int size, void *src, void *dest, int model) { #define LOCK_FREE_ACTION(type) \ *((type*)dest) = __c11_atomic_load((_Atomic(type)*)src, model);\ return; @@ -173,7 +178,7 @@ /// An atomic store operation. This is atomic with respect to the destination /// pointer only. -void __atomic_store_c(int size, void *dest, void *src, int model) { +void ATOMIC_IMPL_SYMBOL(__atomic_store)(int size, void *dest, void *src, int model) { #define LOCK_FREE_ACTION(type) \ __c11_atomic_store((_Atomic(type)*)dest, *(type*)dest, model);\ return; @@ -190,7 +195,7 @@ /// they are not, then this stores the current value from *ptr in *expected. /// /// This function returns 1 if the exchange takes place or 0 if it fails. -int __atomic_compare_exchange_c(int size, void *ptr, void *expected, +int ATOMIC_IMPL_SYMBOL(__atomic_compare_exchange)(int size, void *ptr, void *expected, void *desired, int success, int failure) { #define LOCK_FREE_ACTION(type) \ return __c11_atomic_compare_exchange_strong((_Atomic(type)*)ptr, (type*)expected,\ @@ -211,7 +216,7 @@ /// Performs an atomic exchange operation between two pointers. This is atomic /// with respect to the target address. -void __atomic_exchange_c(int size, void *ptr, void *val, void *old, int model) { +void ATOMIC_IMPL_SYMBOL(__atomic_exchange)(int size, void *ptr, void *val, void *old, int model) { #define LOCK_FREE_ACTION(type) \ *(type*)old = __c11_atomic_exchange((_Atomic(type)*)ptr, *(type*)val,\ model);\