aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2012-01-26 13:50:52 -0800
committerRichard Henderson <rth@gcc.gnu.org>2012-01-26 13:50:52 -0800
commite29137fe36371903cee894f8706c2f906bc2754f (patch)
tree790f5a7979968aad47dc67d280f066322d6fa976 /libstdc++-v3
parent57c5ab1ba6798741ed42da56111dee7b741108fa (diff)
downloadgcc-e29137fe36371903cee894f8706c2f906bc2754f.zip
gcc-e29137fe36371903cee894f8706c2f906bc2754f.tar.gz
gcc-e29137fe36371903cee894f8706c2f906bc2754f.tar.bz2
libstdc++: Use __GCC_ATOMIC_TEST_AND_SET in atomic_flag.
* include/bits/atomic_base.h (__atomic_flag_base): Define _M_i based on the value of __GCC_ATOMIC_TEST_AND_SET_TRUEVAL. (ATOMIC_FLAG_INIT): Initialize with 0, not false. (atomic_flag::atomic_flag): Use __GCC_ATOMIC_TEST_AND_SET_TRUEVAL. From-SVN: r183582
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/atomic_base.h11
2 files changed, 16 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index b9cca6a..67e5b89 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2012-01-27 Richard Henderson <rth@redhat.com>
+
+ * include/bits/atomic_base.h (__atomic_flag_base): Define _M_i
+ based on the value of __GCC_ATOMIC_TEST_AND_SET_TRUEVAL.
+ (ATOMIC_FLAG_INIT): Initialize with 0, not false.
+ (atomic_flag::atomic_flag): Use __GCC_ATOMIC_TEST_AND_SET_TRUEVAL.
+
2012-01-26 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/51985
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index ef17b7e..aa43bcc 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -227,12 +227,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct __atomic_flag_base
{
+ /* The target's "set" value for test-and-set may not be exactly 1. */
+#if __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1
bool _M_i;
+#else
+ unsigned char _M_i;
+#endif
};
_GLIBCXX_END_EXTERN_C
-#define ATOMIC_FLAG_INIT { false }
+#define ATOMIC_FLAG_INIT { 0 }
/// atomic_flag
struct atomic_flag : public __atomic_flag_base
@@ -244,7 +249,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
atomic_flag& operator=(const atomic_flag&) volatile = delete;
// Conversion to ATOMIC_FLAG_INIT.
- atomic_flag(bool __i) noexcept : __atomic_flag_base({ __i }) { }
+ constexpr atomic_flag(bool __i) noexcept
+ : __atomic_flag_base({ __i ? __GCC_ATOMIC_TEST_AND_SET_TRUEVAL : 0 })
+ { }
bool
test_and_set(memory_order __m = memory_order_seq_cst) noexcept