Index: source/common/umutex.h |
diff --git a/source/common/umutex.h b/source/common/umutex.h |
index e0ad0d3c03654d61a023a082548563d8d4c03c61..0e4d118523c874f34098d4038c2167ced663fd8e 100644 |
--- a/source/common/umutex.h |
+++ b/source/common/umutex.h |
@@ -1,6 +1,6 @@ |
/* |
********************************************************************** |
-* Copyright (C) 1997-2014, International Business Machines |
+* Copyright (C) 1997-2015, International Business Machines |
* Corporation and others. All Rights Reserved. |
********************************************************************** |
* |
@@ -118,6 +118,33 @@ inline int32_t umtx_atomic_dec(u_atomic_int32_t *var) { |
U_NAMESPACE_END |
+#elif U_HAVE_CLANG_ATOMICS |
+/* |
+ * Clang __c11 atomic built-ins |
+ */ |
+ |
+U_NAMESPACE_BEGIN |
+typedef _Atomic(int32_t) u_atomic_int32_t; |
+#define ATOMIC_INT32_T_INITIALIZER(val) val |
+ |
+inline int32_t umtx_loadAcquire(u_atomic_int32_t &var) { |
+ return __c11_atomic_load(&var, __ATOMIC_ACQUIRE); |
+} |
+ |
+inline void umtx_storeRelease(u_atomic_int32_t &var, int32_t val) { |
+ return __c11_atomic_store(&var, val, __ATOMIC_RELEASE); |
+} |
+ |
+inline int32_t umtx_atomic_inc(u_atomic_int32_t *var) { |
+ return __c11_atomic_fetch_add(var, 1, __ATOMIC_SEQ_CST) + 1; |
+} |
+ |
+inline int32_t umtx_atomic_dec(u_atomic_int32_t *var) { |
+ return __c11_atomic_fetch_sub(var, 1, __ATOMIC_SEQ_CST) - 1; |
+} |
+U_NAMESPACE_END |
+ |
+ |
#elif U_HAVE_GCC_ATOMICS |
/* |
* gcc atomic ops. These are available on several other compilers as well. |