[cfe-commits] [libcxx] r115614 - /libcxx/trunk/include/atomic

Howard Hinnant hhinnant at apple.com
Tue Oct 5 07:02:23 PDT 2010


Author: hhinnant
Date: Tue Oct  5 09:02:23 2010
New Revision: 115614

URL: http://llvm.org/viewvc/llvm-project?rev=115614&view=rev
Log:
Make flag type configurable by the compiler

Modified:
    libcxx/trunk/include/atomic

Modified: libcxx/trunk/include/atomic
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?rev=115614&r1=115613&r2=115614&view=diff
==============================================================================
--- libcxx/trunk/include/atomic (original)
+++ libcxx/trunk/include/atomic Tue Oct  5 09:02:23 2010
@@ -12376,6 +12376,10 @@
 
 // flag type and operations
 
+#if !__has_feature(__atomic_flag)
+    typedef bool __atomic_flag__;
+#endif
+
 struct atomic_flag;
 
 bool atomic_flag_test_and_set(volatile atomic_flag*);
@@ -12389,7 +12393,7 @@
 
 typedef struct _LIBCPP_VISIBLE atomic_flag
 {
-    bool __flg_;
+    __atomic_flag__ __flg_;
 
     _LIBCPP_INLINE_VISIBILITY
     bool test_and_set() volatile
@@ -12441,7 +12445,8 @@
 bool
 atomic_flag_test_and_set(volatile atomic_flag* __f)
 {
-    return __choose_exchange_seq_cst(&__f->__flg_, true);
+    return __choose_exchange_seq_cst(&__f->__flg_, __atomic_flag__(true))
+            == __atomic_flag__(true);
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -12458,17 +12463,23 @@
     switch (__o)
     {
     case memory_order_relaxed:
-        return __choose_exchange_relaxed(&__f->__flg_, true);
+        return __choose_exchange_relaxed(&__f->__flg_, __atomic_flag__(true))
+            == __atomic_flag__(true);
     case memory_order_consume:
-        return __choose_exchange_consume(&__f->__flg_, true);
+        return __choose_exchange_consume(&__f->__flg_, __atomic_flag__(true))
+            == __atomic_flag__(true);
     case memory_order_acquire:
-        return __choose_exchange_acquire(&__f->__flg_, true);
+        return __choose_exchange_acquire(&__f->__flg_, __atomic_flag__(true))
+            == __atomic_flag__(true);
     case memory_order_release:
-        return __choose_exchange_release(&__f->__flg_, true);
+        return __choose_exchange_release(&__f->__flg_, __atomic_flag__(true))
+            == __atomic_flag__(true);
     case memory_order_acq_rel:
-        return __choose_exchange_acq_rel(&__f->__flg_, true);
+        return __choose_exchange_acq_rel(&__f->__flg_, __atomic_flag__(true))
+            == __atomic_flag__(true);
     case memory_order_seq_cst:
-        return __choose_exchange_seq_cst(&__f->__flg_, true);
+        return __choose_exchange_seq_cst(&__f->__flg_, __atomic_flag__(true))
+            == __atomic_flag__(true);
     }
 }
 
@@ -12484,7 +12495,7 @@
 void
 atomic_flag_clear(volatile atomic_flag* __f)
 {
-    return __choose_store_seq_cst(&__f->__flg_, false);
+    __choose_store_seq_cst(&__f->__flg_, __atomic_flag__(false));
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -12501,13 +12512,13 @@
     switch (__o)
     {
     case memory_order_relaxed:
-        __choose_store_relaxed(&__f->__flg_, false);
+        __choose_store_relaxed(&__f->__flg_, __atomic_flag__(false));
         break;
     case memory_order_release:
-        __choose_store_release(&__f->__flg_, false);
+        __choose_store_release(&__f->__flg_, __atomic_flag__(false));
         break;
     case memory_order_seq_cst:
-        __choose_store_seq_cst(&__f->__flg_, false);
+        __choose_store_seq_cst(&__f->__flg_, __atomic_flag__(false));
         break;
     }
 }





More information about the cfe-commits mailing list