llvm.org GIT mirror llvm / 986f29c
XLC supports the same atomic functions as GCC, use them. Patch by Kai. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167309 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
1 changed file(s) with 9 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
2020 #undef MemoryFence
2121 #endif
2222
23 #if defined(__GNUC__) || (defined(__IBMCPP__) && __IBMCPP__ >= 1210)
24 #define GNU_ATOMICS
25 #endif
26
2327 void sys::MemoryFence() {
2428 #if LLVM_HAS_ATOMICS == 0
2529 return;
2630 #else
27 # if defined(__GNUC__)
31 # if defined(GNU_ATOMICS)
2832 __sync_synchronize();
2933 # elif defined(_MSC_VER)
3034 MemoryBarrier();
4246 if (result == old_value)
4347 *ptr = new_value;
4448 return result;
45 #elif defined(__GNUC__)
49 #elif defined(GNU_ATOMICS)
4650 return __sync_val_compare_and_swap(ptr, old_value, new_value);
4751 #elif defined(_MSC_VER)
4852 return InterlockedCompareExchange(ptr, new_value, old_value);
5559 #if LLVM_HAS_ATOMICS == 0
5660 ++(*ptr);
5761 return *ptr;
58 #elif defined(__GNUC__)
62 #elif defined(GNU_ATOMICS)
5963 return __sync_add_and_fetch(ptr, 1);
6064 #elif defined(_MSC_VER)
6165 return InterlockedIncrement(ptr);
6872 #if LLVM_HAS_ATOMICS == 0
6973 --(*ptr);
7074 return *ptr;
71 #elif defined(__GNUC__)
75 #elif defined(GNU_ATOMICS)
7276 return __sync_sub_and_fetch(ptr, 1);
7377 #elif defined(_MSC_VER)
7478 return InterlockedDecrement(ptr);
8185 #if LLVM_HAS_ATOMICS == 0
8286 *ptr += val;
8387 return *ptr;
84 #elif defined(__GNUC__)
88 #elif defined(GNU_ATOMICS)
8589 return __sync_add_and_fetch(ptr, val);
8690 #elif defined(_MSC_VER)
8791 return InterlockedExchangeAdd(ptr, val) + val;