atomic: Update to N3000.

2009-12-20  Benjamin Kosnik  <bkoz@redhat.com>

	* include/std/atomic: Update to N3000.
	* include/bits/atomic_0.h: Same.
	* include/bits/atomic_2.h: Same.
	* include/c_global/cstdatomic: Move...
	* include/bits/atomic_base.h: ...here.
	* include/c_compatibility/stdatomic.h: Just include atomic_base.h.
	* include/precompiled/stdc++.h: Adjust includes.
	* include/Makefile.am: Adjust files.
	* include/Makefile.in: Regenerate.
	* include/std/future: Adjust.
	* src/atomic.cc: Adjust, adjust exports for compatibility.
	* src/compatibility.cc: Move C++0x stuff...
	* src/compatibility-c++0x.cc: ...here.

	* doc/xml/manual/using.xml: Update.
	* doc/xml/manual/status_cxx200x.xml: Update.
	* doc/doxygen/user.cfg.in: Update.

	* testsuite/29_atomics/atomic_address/cons/assign_neg.cc: Same.
	* testsuite/29_atomics/atomic_address/cons/single_value.cc: Same.
	* testsuite/29_atomics/atomic_address/cons/copy_neg.cc: Same.
	* testsuite/29_atomics/atomic_address/cons/default.cc: Same.
	* testsuite/29_atomics/atomic_address/cons/aggregate.cc: Same.
	* testsuite/29_atomics/atomic_address/requirements/
	standard_layout.cc: Same.
	* testsuite/29_atomics/atomic_address/requirements/trivial.cc: Same.
	* testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: Same.
	* testsuite/29_atomics/atomic_integral/cons/single_value.cc: Same.
	* testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: Same.
	* testsuite/29_atomics/atomic_integral/cons/default.cc: Same.
	* testsuite/29_atomics/atomic_integral/cons/copy_list.cc: Same.
	* testsuite/29_atomics/atomic_integral/cons/direct_list.cc: Same.
	* testsuite/29_atomics/atomic_integral/requirements/
	standard_layout.cc: Same.
	* testsuite/29_atomics/atomic_integral/requirements/trivial.cc: Same.
	* testsuite/29_atomics/atomic_integral/operators/increment_neg.cc: Same.
	* testsuite/29_atomics/atomic_integral/operators/
	integral_assignment.cc: Same.
	* testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc: Same.
	* testsuite/29_atomics/atomic_integral/operators/decrement_neg.cc: Same.
	* testsuite/29_atomics/atomic_integral/operators/increment.cc: Same.
	* testsuite/29_atomics/atomic_integral/operators/bitwise.cc: Same.
	* testsuite/29_atomics/atomic_integral/operators/decrement.cc: Same.
	* testsuite/29_atomics/atomic_integral/operators/
	integral_conversion.cc: Same.
	* testsuite/29_atomics/atomic_flag/cons/assign_neg.cc: Same.
	* testsuite/29_atomics/atomic_flag/cons/copy_neg.cc: Same.
	* testsuite/29_atomics/atomic_flag/cons/default.cc: Same.
	* testsuite/29_atomics/atomic_flag/cons/aggregate.cc: Same.
	* testsuite/29_atomics/atomic_flag/requirements/
	standard_layout.cc: Same.
	* testsuite/29_atomics/atomic_flag/requirements/trivial.cc: Same.
	* testsuite/29_atomics/atomic_flag/clear/1.cc: Same.
	* testsuite/29_atomics/atomic_flag/test_and_set/explicit.c
	* testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc: Same.
	* testsuite/29_atomics/atomic_flag/test_and_set/implicit.c
	* testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc: Same.
	* testsuite/29_atomics/headers/stdatomic.h/functions.c
	* testsuite/29_atomics/atomic/cons/assign_neg.cc: Same.
	* testsuite/29_atomics/atomic/cons/single_value.cc: Same.
	* testsuite/29_atomics/atomic/cons/copy_neg.cc: Same.
	* testsuite/29_atomics/atomic/cons/default.cc: Same.
	* testsuite/29_atomics/atomic/cons/copy_list.cc: Same.
	* testsuite/29_atomics/atomic/cons/direct_list.cc: Same.
	* testsuite/29_atomics/atomic/requirements/explicit_instantiation/
	1.cc: Same.
	* testsuite/29_atomics/atomic/requirements/base_classes.cc: Same.
	* testsuite/29_atomics/atomic/operators/integral_assignment.cc: Same.
	* testsuite/29_atomics/atomic/operators/integral_conversion.cc: Same.
	* testsuite/util/testsuite_common_types.h: Adjust.

	* testsuite/29_atomics/headers/cstdatomic: Move and adjust...
	* testsuite/29_atomics/headers/atomic: ...here.
	* testsuite/29_atomics/headers/atomic/types_std_c++0x.cc: Same.
	* testsuite/29_atomics/headers/atomic/functions_std_c++0x.cc: Same.
	* testsuite/29_atomics/headers/atomic/std_c++0x_neg.cc: Same.
	* testsuite/29_atomics/headers/atomic/macros.cc: Same.

	* testsuite/29_atomics/headers/atomic/types_std_c++0x_neg.cc: Add.
	* testsuite/29_atomics/atomic/cons/user_pod.cc: Add.

From-SVN: r155377
This commit is contained in:
Benjamin Kosnik 2009-12-21 19:00:34 +00:00 committed by Benjamin Kosnik
parent dcc1e1fab4
commit afd88205d8
68 changed files with 1001 additions and 811 deletions

View file

@ -1,3 +1,86 @@
2009-12-20 Benjamin Kosnik <bkoz@redhat.com>
* include/std/atomic: Update to N3000.
* include/bits/atomic_0.h: Same.
* include/bits/atomic_2.h: Same.
* include/c_global/cstdatomic: Move...
* include/bits/atomic_base.h: ...here.
* include/c_compatibility/stdatomic.h: Just include atomic_base.h.
* include/precompiled/stdc++.h: Adjust includes.
* include/Makefile.am: Adjust files.
* include/Makefile.in: Regenerate.
* include/std/future: Adjust.
* src/atomic.cc: Adjust, adjust exports for compatibility.
* src/compatibility.cc: Move C++0x stuff...
* src/compatibility-c++0x.cc: ...here.
* doc/xml/manual/using.xml: Update.
* doc/xml/manual/status_cxx200x.xml: Update.
* doc/doxygen/user.cfg.in: Update.
* testsuite/29_atomics/atomic_address/cons/assign_neg.cc: Same.
* testsuite/29_atomics/atomic_address/cons/single_value.cc: Same.
* testsuite/29_atomics/atomic_address/cons/copy_neg.cc: Same.
* testsuite/29_atomics/atomic_address/cons/default.cc: Same.
* testsuite/29_atomics/atomic_address/cons/aggregate.cc: Same.
* testsuite/29_atomics/atomic_address/requirements/
standard_layout.cc: Same.
* testsuite/29_atomics/atomic_address/requirements/trivial.cc: Same.
* testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: Same.
* testsuite/29_atomics/atomic_integral/cons/single_value.cc: Same.
* testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: Same.
* testsuite/29_atomics/atomic_integral/cons/default.cc: Same.
* testsuite/29_atomics/atomic_integral/cons/copy_list.cc: Same.
* testsuite/29_atomics/atomic_integral/cons/direct_list.cc: Same.
* testsuite/29_atomics/atomic_integral/requirements/
standard_layout.cc: Same.
* testsuite/29_atomics/atomic_integral/requirements/trivial.cc: Same.
* testsuite/29_atomics/atomic_integral/operators/increment_neg.cc: Same.
* testsuite/29_atomics/atomic_integral/operators/
integral_assignment.cc: Same.
* testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc: Same.
* testsuite/29_atomics/atomic_integral/operators/decrement_neg.cc: Same.
* testsuite/29_atomics/atomic_integral/operators/increment.cc: Same.
* testsuite/29_atomics/atomic_integral/operators/bitwise.cc: Same.
* testsuite/29_atomics/atomic_integral/operators/decrement.cc: Same.
* testsuite/29_atomics/atomic_integral/operators/
integral_conversion.cc: Same.
* testsuite/29_atomics/atomic_flag/cons/assign_neg.cc: Same.
* testsuite/29_atomics/atomic_flag/cons/copy_neg.cc: Same.
* testsuite/29_atomics/atomic_flag/cons/default.cc: Same.
* testsuite/29_atomics/atomic_flag/cons/aggregate.cc: Same.
* testsuite/29_atomics/atomic_flag/requirements/
standard_layout.cc: Same.
* testsuite/29_atomics/atomic_flag/requirements/trivial.cc: Same.
* testsuite/29_atomics/atomic_flag/clear/1.cc: Same.
* testsuite/29_atomics/atomic_flag/test_and_set/explicit.c
* testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc: Same.
* testsuite/29_atomics/atomic_flag/test_and_set/implicit.c
* testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc: Same.
* testsuite/29_atomics/headers/stdatomic.h/functions.c
* testsuite/29_atomics/atomic/cons/assign_neg.cc: Same.
* testsuite/29_atomics/atomic/cons/single_value.cc: Same.
* testsuite/29_atomics/atomic/cons/copy_neg.cc: Same.
* testsuite/29_atomics/atomic/cons/default.cc: Same.
* testsuite/29_atomics/atomic/cons/copy_list.cc: Same.
* testsuite/29_atomics/atomic/cons/direct_list.cc: Same.
* testsuite/29_atomics/atomic/requirements/explicit_instantiation/
1.cc: Same.
* testsuite/29_atomics/atomic/requirements/base_classes.cc: Same.
* testsuite/29_atomics/atomic/operators/integral_assignment.cc: Same.
* testsuite/29_atomics/atomic/operators/integral_conversion.cc: Same.
* testsuite/util/testsuite_common_types.h: Adjust.
* testsuite/29_atomics/headers/cstdatomic: Move and adjust...
* testsuite/29_atomics/headers/atomic: ...here.
* testsuite/29_atomics/headers/atomic/types_std_c++0x.cc: Same.
* testsuite/29_atomics/headers/atomic/functions_std_c++0x.cc: Same.
* testsuite/29_atomics/headers/atomic/std_c++0x_neg.cc: Same.
* testsuite/29_atomics/headers/atomic/macros.cc: Same.
* testsuite/29_atomics/headers/atomic/types_std_c++0x_neg.cc: Add.
* testsuite/29_atomics/atomic/cons/user_pod.cc: Add.
2009-12-18 Jimmy Guo <jguo@yahoo-inc.com>
PR libstdc++/40088

View file

@ -580,6 +580,7 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \
@srcdir@/libsupc++/typeinfo \
include/algorithm \
include/array \
include/atomic \
include/bitset \
include/chrono \
include/complex \
@ -635,7 +636,6 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \
include/csetjmp \
include/csignal \
include/cstdarg \
include/cstdatomic \
include/cstdbool \
include/cstddef \
include/cstdint \

View file

@ -2200,7 +2200,7 @@ particular release.
</row>
<row>
<entry>29.2</entry>
<entry>Header <code>&lt;cstdatomic&gt;</code> synopsis</entry>
<entry>Header <code>&lt;atomic&gt;</code> synopsis</entry>
<entry>Y</entry>
<entry></entry>
</row>

View file

@ -329,24 +329,23 @@ mode, i.e. <literal>-std=c++0x</literal> or <literal>-std=gnu++0x</literal>.
<entry><filename class="headerfile">csetjmp</filename></entry>
<entry><filename class="headerfile">csignal</filename></entry>
<entry><filename class="headerfile">cstdarg</filename></entry>
<entry><filename class="headerfile">cstdatomic</filename></entry>
<entry><filename class="headerfile">cstdbool</filename></entry>
</row>
<row>
<entry><filename class="headerfile">cstdbool</filename></entry>
<entry><filename class="headerfile">cstddef</filename></entry>
<entry><filename class="headerfile">cstdint</filename></entry>
<entry><filename class="headerfile">cstdlib</filename></entry>
<entry><filename class="headerfile">cstdio</filename></entry>
<entry><filename class="headerfile">cstring</filename></entry>
</row>
<row>
<entry><filename class="headerfile">cstring</filename></entry>
<entry><filename class="headerfile">ctgmath</filename></entry>
<entry><filename class="headerfile">ctime</filename></entry>
<entry><filename class="headerfile">cuchar</filename></entry>
<entry><filename class="headerfile">cwchar</filename></entry>
<entry><filename class="headerfile">cwctype</filename></entry>
</row>
<row>
<entry><filename class="headerfile">cwctype</filename></entry>
<entry><filename class="headerfile">stdatomic.h</filename></entry>
</row>

View file

@ -29,6 +29,7 @@ std_builddir = .
std_headers = \
${std_srcdir}/algorithm \
${std_srcdir}/array \
${std_srcdir}/atomic \
${std_srcdir}/bitset \
${std_srcdir}/c++0x_warning.h \
${std_srcdir}/chrono \
@ -78,6 +79,7 @@ bits_builddir = ./bits
bits_headers = \
${bits_srcdir}/algorithmfwd.h \
${bits_srcdir}/allocator.h \
${bits_srcdir}/atomic_base.h \
${bits_srcdir}/atomicfwd_c.h \
${bits_srcdir}/atomicfwd_cxx.h \
${bits_srcdir}/atomic_0.h \
@ -641,7 +643,6 @@ c_base_headers = \
${c_base_srcdir}/csetjmp \
${c_base_srcdir}/csignal \
${c_base_srcdir}/cstdarg \
${c_base_srcdir}/cstdatomic \
${c_base_srcdir}/cstdbool \
${c_base_srcdir}/cstddef \
${c_base_srcdir}/cstdint \

View file

@ -271,6 +271,7 @@ std_builddir = .
std_headers = \
${std_srcdir}/algorithm \
${std_srcdir}/array \
${std_srcdir}/atomic \
${std_srcdir}/bitset \
${std_srcdir}/c++0x_warning.h \
${std_srcdir}/chrono \
@ -320,6 +321,7 @@ bits_builddir = ./bits
bits_headers = \
${bits_srcdir}/algorithmfwd.h \
${bits_srcdir}/allocator.h \
${bits_srcdir}/atomic_base.h \
${bits_srcdir}/atomicfwd_c.h \
${bits_srcdir}/atomicfwd_cxx.h \
${bits_srcdir}/atomic_0.h \
@ -881,7 +883,6 @@ c_base_headers = \
${c_base_srcdir}/csetjmp \
${c_base_srcdir}/csignal \
${c_base_srcdir}/cstdarg \
${c_base_srcdir}/cstdatomic \
${c_base_srcdir}/cstdbool \
${c_base_srcdir}/cstddef \
${c_base_srcdir}/cstdint \

View file

@ -42,26 +42,26 @@ namespace __atomic0
// Implementation specific defines.
#define _ATOMIC_LOAD_(__a, __x) \
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
volatile __atomic_flag_base* __g = __atomic_flag_for_address(__p); \
({__typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
__atomic_flag_base* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \
__typeof__ _ATOMIC_MEMBER_ __r = *__p; \
atomic_flag_clear_explicit(__g, __x); \
__r; })
#define _ATOMIC_STORE_(__a, __m, __x) \
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
({__typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
__typeof__(__m) __v = (__m); \
volatile __atomic_flag_base* __g = __atomic_flag_for_address(__p); \
__atomic_flag_base* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \
*__p = __v; \
atomic_flag_clear_explicit(__g, __x); \
__v; })
#define _ATOMIC_MODIFY_(__a, __o, __m, __x) \
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
({__typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
__typeof__(__m) __v = (__m); \
volatile __atomic_flag_base* __g = __atomic_flag_for_address(__p); \
__atomic_flag_base* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \
__typeof__ _ATOMIC_MEMBER_ __r = *__p; \
*__p __o __v; \
@ -69,11 +69,11 @@ namespace __atomic0
__r; })
#define _ATOMIC_CMPEXCHNG_(__a, __e, __m, __x) \
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
({__typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
__typeof__(__e) __q = (__e); \
__typeof__(__m) __v = (__m); \
bool __r; \
volatile __atomic_flag_base* __g = __atomic_flag_for_address(__p); \
__atomic_flag_base* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \
__typeof__ _ATOMIC_MEMBER_ __t__ = *__p; \
if (__t__ == *__q) { *__p = __v; __r = true; } \
@ -87,16 +87,16 @@ namespace __atomic0
atomic_flag() = default;
~atomic_flag() = default;
atomic_flag(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) volatile = delete;
// Conversion to ATOMIC_FLAG_INIT.
atomic_flag(bool __i): __atomic_flag_base({ __i }) { }
bool
test_and_set(memory_order __m = memory_order_seq_cst) volatile;
test_and_set(memory_order __m = memory_order_seq_cst);
void
clear(memory_order __m = memory_order_seq_cst) volatile;
clear(memory_order __m = memory_order_seq_cst);
};
/// 29.4.2, address types
@ -109,16 +109,16 @@ namespace __atomic0
atomic_address() = default;
~atomic_address() = default;
atomic_address(const atomic_address&) = delete;
atomic_address& operator=(const atomic_address&) = delete;
atomic_address& operator=(const atomic_address&) volatile = delete;
atomic_address(void* __v) { _M_i = __v; }
bool
is_lock_free() const volatile
is_lock_free() const
{ return false; }
void
store(void* __v, memory_order __m = memory_order_seq_cst) volatile
store(void* __v, memory_order __m = memory_order_seq_cst)
{
__glibcxx_assert(__m != memory_order_acquire);
__glibcxx_assert(__m != memory_order_acq_rel);
@ -127,7 +127,7 @@ namespace __atomic0
}
void*
load(memory_order __m = memory_order_seq_cst) const volatile
load(memory_order __m = memory_order_seq_cst) const
{
__glibcxx_assert(__m != memory_order_release);
__glibcxx_assert(__m != memory_order_acq_rel);
@ -135,12 +135,12 @@ namespace __atomic0
}
void*
exchange(void* __v, memory_order __m = memory_order_seq_cst) volatile
exchange(void* __v, memory_order __m = memory_order_seq_cst)
{ return _ATOMIC_MODIFY_(this, =, __v, __m); }
bool
compare_exchange_weak(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
memory_order __m2)
{
__glibcxx_assert(__m2 != memory_order_release);
__glibcxx_assert(__m2 != memory_order_acq_rel);
@ -150,7 +150,7 @@ namespace __atomic0
bool
compare_exchange_weak(void*& __v1, void* __v2,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{
return compare_exchange_weak(__v1, __v2, __m,
__calculate_memory_order(__m));
@ -158,7 +158,7 @@ namespace __atomic0
bool
compare_exchange_strong(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
memory_order __m2)
{
__glibcxx_assert(__m2 != memory_order_release);
__glibcxx_assert(__m2 != memory_order_acq_rel);
@ -168,17 +168,17 @@ namespace __atomic0
bool
compare_exchange_strong(void*& __v1, void* __v2,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{
return compare_exchange_strong(__v1, __v2, __m,
__calculate_memory_order(__m));
}
void*
fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile
fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst)
{
void* volatile* __p = &(_M_i);
volatile __atomic_flag_base* __g = __atomic_flag_for_address(__p);
void** __p = &(_M_i);
__atomic_flag_base* __g = __atomic_flag_for_address(__p);
__atomic_flag_wait_explicit(__g, __m);
void* __r = *__p;
*__p = (void*)((char*)(*__p) + __d);
@ -187,10 +187,10 @@ namespace __atomic0
}
void*
fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile
fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst)
{
void* volatile* __p = &(_M_i);
volatile __atomic_flag_base* __g = __atomic_flag_for_address(__p);
void** __p = &(_M_i);
__atomic_flag_base* __g = __atomic_flag_for_address(__p);
__atomic_flag_wait_explicit(__g, __m);
void* __r = *__p;
*__p = (void*)((char*)(*__p) - __d);
@ -198,22 +198,22 @@ namespace __atomic0
return __r;
}
operator void*() const volatile
operator void*() const
{ return load(); }
void*
operator=(void* __v) // XXX volatile
operator=(void* __v)
{
store(__v);
return __v;
}
void*
operator+=(ptrdiff_t __d) volatile
operator+=(ptrdiff_t __d)
{ return fetch_add(__d) + __d; }
void*
operator-=(ptrdiff_t __d) volatile
operator-=(ptrdiff_t __d)
{ return fetch_sub(__d) - __d; }
};
@ -252,64 +252,63 @@ namespace __atomic0
__atomic_base() = default;
~__atomic_base() = default;
__atomic_base(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) volatile = delete;
// Requires __integral_type convertible to _M_base._M_i.
__atomic_base(__integral_type __i) { _M_i = __i; }
operator __integral_type() const volatile
operator __integral_type() const
{ return load(); }
__integral_type
operator=(__integral_type __i) // XXX volatile
operator=(__integral_type __i)
{
store(__i);
return __i;
}
__integral_type
operator++(int) volatile
operator++(int)
{ return fetch_add(1); }
__integral_type
operator--(int) volatile
operator--(int)
{ return fetch_sub(1); }
__integral_type
operator++() volatile
operator++()
{ return fetch_add(1) + 1; }
__integral_type
operator--() volatile
operator--()
{ return fetch_sub(1) - 1; }
__integral_type
operator+=(__integral_type __i) volatile
operator+=(__integral_type __i)
{ return fetch_add(__i) + __i; }
__integral_type
operator-=(__integral_type __i) volatile
operator-=(__integral_type __i)
{ return fetch_sub(__i) - __i; }
__integral_type
operator&=(__integral_type __i) volatile
operator&=(__integral_type __i)
{ return fetch_and(__i) & __i; }
__integral_type
operator|=(__integral_type __i) volatile
operator|=(__integral_type __i)
{ return fetch_or(__i) | __i; }
__integral_type
operator^=(__integral_type __i) volatile
operator^=(__integral_type __i)
{ return fetch_xor(__i) ^ __i; }
bool
is_lock_free() const volatile
is_lock_free() const
{ return false; }
void
store(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
store(__integral_type __i, memory_order __m = memory_order_seq_cst)
{
__glibcxx_assert(__m != memory_order_acquire);
__glibcxx_assert(__m != memory_order_acq_rel);
@ -318,7 +317,7 @@ namespace __atomic0
}
__integral_type
load(memory_order __m = memory_order_seq_cst) const volatile
load(memory_order __m = memory_order_seq_cst) const
{
__glibcxx_assert(__m != memory_order_release);
__glibcxx_assert(__m != memory_order_acq_rel);
@ -326,13 +325,12 @@ namespace __atomic0
}
__integral_type
exchange(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
exchange(__integral_type __i, memory_order __m = memory_order_seq_cst)
{ return _ATOMIC_MODIFY_(this, =, __i, __m); }
bool
compare_exchange_weak(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
memory_order __m1, memory_order __m2)
{
__glibcxx_assert(__m2 != memory_order_release);
__glibcxx_assert(__m2 != memory_order_acq_rel);
@ -342,7 +340,7 @@ namespace __atomic0
bool
compare_exchange_weak(__integral_type& __i1, __integral_type __i2,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{
return compare_exchange_weak(__i1, __i2, __m,
__calculate_memory_order(__m));
@ -350,7 +348,7 @@ namespace __atomic0
bool
compare_exchange_strong(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
memory_order __m1, memory_order __m2)
{
__glibcxx_assert(__m2 != memory_order_release);
__glibcxx_assert(__m2 != memory_order_acq_rel);
@ -360,35 +358,30 @@ namespace __atomic0
bool
compare_exchange_strong(__integral_type& __i1, __integral_type __i2,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{
return compare_exchange_strong(__i1, __i2, __m,
__calculate_memory_order(__m));
}
__integral_type
fetch_add(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
fetch_add(__integral_type __i, memory_order __m = memory_order_seq_cst)
{ return _ATOMIC_MODIFY_(this, +=, __i, __m); }
__integral_type
fetch_sub(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
fetch_sub(__integral_type __i, memory_order __m = memory_order_seq_cst)
{ return _ATOMIC_MODIFY_(this, -=, __i, __m); }
__integral_type
fetch_and(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
fetch_and(__integral_type __i, memory_order __m = memory_order_seq_cst)
{ return _ATOMIC_MODIFY_(this, &=, __i, __m); }
__integral_type
fetch_or(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
fetch_or(__integral_type __i, memory_order __m = memory_order_seq_cst)
{ return _ATOMIC_MODIFY_(this, |=, __i, __m); }
__integral_type
fetch_xor(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
fetch_xor(__integral_type __i, memory_order __m = memory_order_seq_cst)
{ return _ATOMIC_MODIFY_(this, ^=, __i, __m); }
};
@ -404,52 +397,52 @@ namespace __atomic0
atomic_bool() = default;
~atomic_bool() = default;
atomic_bool(const atomic_bool&) = delete;
atomic_bool& operator=(const atomic_bool&) = delete;
atomic_bool& operator=(const atomic_bool&) volatile = delete;
atomic_bool(bool __i) : _M_base(__i) { }
bool
operator=(bool __i) // XXX volatile
operator=(bool __i)
{ return _M_base.operator=(__i); }
operator bool() const volatile
operator bool() const
{ return _M_base.load(); }
bool
is_lock_free() const volatile
is_lock_free() const
{ return _M_base.is_lock_free(); }
void
store(bool __i, memory_order __m = memory_order_seq_cst) volatile
store(bool __i, memory_order __m = memory_order_seq_cst)
{ _M_base.store(__i, __m); }
bool
load(memory_order __m = memory_order_seq_cst) const volatile
load(memory_order __m = memory_order_seq_cst) const
{ return _M_base.load(__m); }
bool
exchange(bool __i, memory_order __m = memory_order_seq_cst) volatile
exchange(bool __i, memory_order __m = memory_order_seq_cst)
{ return _M_base.exchange(__i, __m); }
bool
compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1,
memory_order __m2) volatile
memory_order __m2)
{ return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
bool
compare_exchange_weak(bool& __i1, bool __i2,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{ return _M_base.compare_exchange_weak(__i1, __i2, __m); }
bool
compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1,
memory_order __m2) volatile
memory_order __m2)
{ return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
bool
compare_exchange_strong(bool& __i1, bool __i2,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{ return _M_base.compare_exchange_strong(__i1, __i2, __m); }
};

View file

@ -49,13 +49,13 @@ namespace __atomic2
atomic_flag() = default;
~atomic_flag() = default;
atomic_flag(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) volatile = delete;
// Conversion to ATOMIC_FLAG_INIT.
atomic_flag(bool __i): __atomic_flag_base({ __i }) { }
bool
test_and_set(memory_order __m = memory_order_seq_cst) volatile
test_and_set(memory_order __m = memory_order_seq_cst)
{
// Redundant synchronize if built-in for lock is a full barrier.
if (__m != memory_order_acquire && __m != memory_order_acq_rel)
@ -64,7 +64,7 @@ namespace __atomic2
}
void
clear(memory_order __m = memory_order_seq_cst) volatile
clear(memory_order __m = memory_order_seq_cst)
{
__glibcxx_assert(__m != memory_order_consume);
__glibcxx_assert(__m != memory_order_acquire);
@ -87,16 +87,16 @@ namespace __atomic2
atomic_address() = default;
~atomic_address() = default;
atomic_address(const atomic_address&) = delete;
atomic_address& operator=(const atomic_address&) = delete;
atomic_address& operator=(const atomic_address&) volatile = delete;
atomic_address(void* __v) { _M_i = __v; }
bool
is_lock_free() const volatile
is_lock_free() const
{ return true; }
void
store(void* __v, memory_order __m = memory_order_seq_cst) volatile
store(void* __v, memory_order __m = memory_order_seq_cst)
{
__glibcxx_assert(__m != memory_order_acquire);
__glibcxx_assert(__m != memory_order_acq_rel);
@ -114,7 +114,7 @@ namespace __atomic2
}
void*
load(memory_order __m = memory_order_seq_cst) const volatile
load(memory_order __m = memory_order_seq_cst) const
{
__glibcxx_assert(__m != memory_order_release);
__glibcxx_assert(__m != memory_order_acq_rel);
@ -126,7 +126,7 @@ namespace __atomic2
}
void*
exchange(void* __v, memory_order __m = memory_order_seq_cst) volatile
exchange(void* __v, memory_order __m = memory_order_seq_cst)
{
// XXX built-in assumes memory_order_acquire.
return __sync_lock_test_and_set(&_M_i, __v);
@ -134,12 +134,12 @@ namespace __atomic2
bool
compare_exchange_weak(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
memory_order __m2)
{ return compare_exchange_strong(__v1, __v2, __m1, __m2); }
bool
compare_exchange_weak(void*& __v1, void* __v2,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{
return compare_exchange_weak(__v1, __v2, __m,
__calculate_memory_order(__m));
@ -147,7 +147,7 @@ namespace __atomic2
bool
compare_exchange_strong(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
memory_order __m2)
{
__glibcxx_assert(__m2 != memory_order_release);
__glibcxx_assert(__m2 != memory_order_acq_rel);
@ -163,36 +163,36 @@ namespace __atomic2
bool
compare_exchange_strong(void*& __v1, void* __v2,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{
return compare_exchange_strong(__v1, __v2, __m,
__calculate_memory_order(__m));
}
void*
fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile
fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst)
{ return __sync_fetch_and_add(&_M_i, __d); }
void*
fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile
fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst)
{ return __sync_fetch_and_sub(&_M_i, __d); }
operator void*() const volatile
operator void*() const
{ return load(); }
void*
operator=(void* __v) // XXX volatile
operator=(void* __v)
{
store(__v);
return __v;
}
void*
operator+=(ptrdiff_t __d) volatile
operator+=(ptrdiff_t __d)
{ return __sync_add_and_fetch(&_M_i, __d); }
void*
operator-=(ptrdiff_t __d) volatile
operator-=(ptrdiff_t __d)
{ return __sync_sub_and_fetch(&_M_i, __d); }
};
@ -230,64 +230,63 @@ namespace __atomic2
__atomic_base() = default;
~__atomic_base() = default;
__atomic_base(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) volatile = delete;
// Requires __integral_type convertible to _M_base._M_i.
__atomic_base(__integral_type __i) { _M_i = __i; }
operator __integral_type() const volatile
operator __integral_type() const
{ return load(); }
__integral_type
operator=(__integral_type __i) // XXX volatile
operator=(__integral_type __i)
{
store(__i);
return __i;
}
__integral_type
operator++(int) volatile
operator++(int)
{ return fetch_add(1); }
__integral_type
operator--(int) volatile
operator--(int)
{ return fetch_sub(1); }
__integral_type
operator++() volatile
operator++()
{ return __sync_add_and_fetch(&_M_i, 1); }
__integral_type
operator--() volatile
operator--()
{ return __sync_sub_and_fetch(&_M_i, 1); }
__integral_type
operator+=(__integral_type __i) volatile
operator+=(__integral_type __i)
{ return __sync_add_and_fetch(&_M_i, __i); }
__integral_type
operator-=(__integral_type __i) volatile
operator-=(__integral_type __i)
{ return __sync_sub_and_fetch(&_M_i, __i); }
__integral_type
operator&=(__integral_type __i) volatile
operator&=(__integral_type __i)
{ return __sync_and_and_fetch(&_M_i, __i); }
__integral_type
operator|=(__integral_type __i) volatile
operator|=(__integral_type __i)
{ return __sync_or_and_fetch(&_M_i, __i); }
__integral_type
operator^=(__integral_type __i) volatile
operator^=(__integral_type __i)
{ return __sync_xor_and_fetch(&_M_i, __i); }
bool
is_lock_free() const volatile
is_lock_free() const
{ return true; }
void
store(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
store(__integral_type __i, memory_order __m = memory_order_seq_cst)
{
__glibcxx_assert(__m != memory_order_acquire);
__glibcxx_assert(__m != memory_order_acq_rel);
@ -305,7 +304,7 @@ namespace __atomic2
}
__integral_type
load(memory_order __m = memory_order_seq_cst) const volatile
load(memory_order __m = memory_order_seq_cst) const
{
__glibcxx_assert(__m != memory_order_release);
__glibcxx_assert(__m != memory_order_acq_rel);
@ -317,8 +316,7 @@ namespace __atomic2
}
__integral_type
exchange(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
exchange(__integral_type __i, memory_order __m = memory_order_seq_cst)
{
// XXX built-in assumes memory_order_acquire.
return __sync_lock_test_and_set(&_M_i, __i);
@ -326,12 +324,12 @@ namespace __atomic2
bool
compare_exchange_weak(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
memory_order __m1, memory_order __m2)
{ return compare_exchange_strong(__i1, __i2, __m1, __m2); }
bool
compare_exchange_weak(__integral_type& __i1, __integral_type __i2,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{
return compare_exchange_weak(__i1, __i2, __m,
__calculate_memory_order(__m));
@ -339,7 +337,7 @@ namespace __atomic2
bool
compare_exchange_strong(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
memory_order __m1, memory_order __m2)
{
__glibcxx_assert(__m2 != memory_order_release);
__glibcxx_assert(__m2 != memory_order_acq_rel);
@ -355,7 +353,7 @@ namespace __atomic2
bool
compare_exchange_strong(__integral_type& __i1, __integral_type __i2,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{
return compare_exchange_strong(__i1, __i2, __m,
__calculate_memory_order(__m));
@ -363,27 +361,27 @@ namespace __atomic2
__integral_type
fetch_add(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{ return __sync_fetch_and_add(&_M_i, __i); }
__integral_type
fetch_sub(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{ return __sync_fetch_and_sub(&_M_i, __i); }
__integral_type
fetch_and(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{ return __sync_fetch_and_and(&_M_i, __i); }
__integral_type
fetch_or(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{ return __sync_fetch_and_or(&_M_i, __i); }
__integral_type
fetch_xor(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{ return __sync_fetch_and_xor(&_M_i, __i); }
};
@ -399,52 +397,52 @@ namespace __atomic2
atomic_bool() = default;
~atomic_bool() = default;
atomic_bool(const atomic_bool&) = delete;
atomic_bool& operator=(const atomic_bool&) = delete;
atomic_bool& operator=(const atomic_bool&) volatile = delete;
atomic_bool(bool __i) : _M_base(__i) { }
bool
operator=(bool __i) // XXX volatile
operator=(bool __i)
{ return _M_base.operator=(__i); }
operator bool() const volatile
operator bool() const
{ return _M_base.load(); }
bool
is_lock_free() const volatile
is_lock_free() const
{ return _M_base.is_lock_free(); }
void
store(bool __i, memory_order __m = memory_order_seq_cst) volatile
store(bool __i, memory_order __m = memory_order_seq_cst)
{ _M_base.store(__i, __m); }
bool
load(memory_order __m = memory_order_seq_cst) const volatile
load(memory_order __m = memory_order_seq_cst) const
{ return _M_base.load(__m); }
bool
exchange(bool __i, memory_order __m = memory_order_seq_cst) volatile
exchange(bool __i, memory_order __m = memory_order_seq_cst)
{ return _M_base.exchange(__i, __m); }
bool
compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1,
memory_order __m2) volatile
memory_order __m2)
{ return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
bool
compare_exchange_weak(bool& __i1, bool __i2,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{ return _M_base.compare_exchange_weak(__i1, __i2, __m); }
bool
compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1,
memory_order __m2) volatile
memory_order __m2)
{ return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
bool
compare_exchange_strong(bool& __i1, bool __i2,
memory_order __m = memory_order_seq_cst) volatile
memory_order __m = memory_order_seq_cst)
{ return _M_base.compare_exchange_strong(__i1, __i2, __m); }
};
} // namespace __atomic2

View file

@ -0,0 +1,224 @@
// -*- C++ -*- compatibility header.
// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/atomic_base.h
* This is a Standard C++ Library header.
*/
#include <bits/c++config.h>
#include <stddef.h>
#include <stdbool.h> // XXX need to define bool w/o stdbool.h in tr1/cstdbool
#ifndef _GLIBCXX_ATOMIC_BASE_H
#define _GLIBCXX_ATOMIC_BASE_H 1
_GLIBCXX_BEGIN_NAMESPACE(std)
_GLIBCXX_BEGIN_EXTERN_C
/**
* @defgroup atomics Atomics
*
* Components for performing atomic operations.
* @{
*/
/// Enumeration for memory_order
typedef enum memory_order
{
memory_order_relaxed,
memory_order_consume,
memory_order_acquire,
memory_order_release,
memory_order_acq_rel,
memory_order_seq_cst
} memory_order;
// Base for atomic_flag.
typedef struct __atomic_flag_base
{
bool _M_i;
} __atomic_flag_base;
#define ATOMIC_FLAG_INIT { false }
/// 29.2 Lock-free Property
#if defined(_GLIBCXX_ATOMIC_BUILTINS_1) && defined(_GLIBCXX_ATOMIC_BUILTINS_2) \
&& defined(_GLIBCXX_ATOMIC_BUILTINS_4) && defined(_GLIBCXX_ATOMIC_BUILTINS_8)
# define _GLIBCXX_ATOMIC_PROPERTY 2
# define _GLIBCXX_ATOMIC_NAMESPACE __atomic2
#elif defined(_GLIBCXX_ATOMIC_BUILTINS_1)
# define _GLIBCXX_ATOMIC_PROPERTY 1
# define _GLIBCXX_ATOMIC_NAMESPACE __atomic1
#else
# define _GLIBCXX_ATOMIC_PROPERTY 0
# define _GLIBCXX_ATOMIC_NAMESPACE __atomic0
#endif
#define ATOMIC_INTEGRAL_LOCK_FREE _GLIBCXX_ATOMIC_PROPERTY
#define ATOMIC_ADDRESS_LOCK_FREE _GLIBCXX_ATOMIC_PROPERTY
// Switch atomic integral base types based on C or C++. In
// addition, for "C" only provide type-generic macros for atomic
// operations. (As C++ accomplishes the same thing with sets of
// overloaded functions.
#ifdef __cplusplus
inline namespace _GLIBCXX_ATOMIC_NAMESPACE { }
# include <bits/atomicfwd_cxx.h>
#else
# include <bits/atomicfwd_c.h>
#endif
// Typedefs for other atomic integral types.
typedef atomic_schar atomic_int_least8_t;
typedef atomic_uchar atomic_uint_least8_t;
typedef atomic_short atomic_int_least16_t;
typedef atomic_ushort atomic_uint_least16_t;
typedef atomic_int atomic_int_least32_t;
typedef atomic_uint atomic_uint_least32_t;
typedef atomic_llong atomic_int_least64_t;
typedef atomic_ullong atomic_uint_least64_t;
typedef atomic_schar atomic_int_fast8_t;
typedef atomic_uchar atomic_uint_fast8_t;
typedef atomic_short atomic_int_fast16_t;
typedef atomic_ushort atomic_uint_fast16_t;
typedef atomic_int atomic_int_fast32_t;
typedef atomic_uint atomic_uint_fast32_t;
typedef atomic_llong atomic_int_fast64_t;
typedef atomic_ullong atomic_uint_fast64_t;
typedef atomic_long atomic_intptr_t;
typedef atomic_ulong atomic_uintptr_t;
typedef atomic_long atomic_ssize_t;
typedef atomic_ulong atomic_size_t;
typedef atomic_llong atomic_intmax_t;
typedef atomic_ullong atomic_uintmax_t;
typedef atomic_long atomic_ptrdiff_t;
// Accessor functions for base atomic_flag type.
bool
atomic_flag_test_and_set_explicit(__atomic_flag_base*, memory_order)
_GLIBCXX_NOTHROW;
inline bool
atomic_flag_test_and_set(__atomic_flag_base* __a)
{ return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
void
atomic_flag_clear_explicit(__atomic_flag_base*, memory_order)
_GLIBCXX_NOTHROW;
inline void
atomic_flag_clear(__atomic_flag_base* __a)
{ atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
void
__atomic_flag_wait_explicit(__atomic_flag_base*, memory_order)
_GLIBCXX_NOTHROW;
_GLIBCXX_CONST __atomic_flag_base*
__atomic_flag_for_address(const void* __z) _GLIBCXX_NOTHROW;
// Implementation specific defines.
#define _ATOMIC_LOAD_(__a, __x) \
({__typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
atomic_flag* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \
__typeof__ _ATOMIC_MEMBER_ __r = *__p; \
atomic_flag_clear_explicit(__g, __x); \
__r; })
#define _ATOMIC_STORE_(__a, __m, __x) \
({__typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
__typeof__(__m) __v = (__m); \
atomic_flag* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \
*__p = __v; \
atomic_flag_clear_explicit(__g, __x); \
__v; })
#define _ATOMIC_MODIFY_(__a, __o, __m, __x) \
({__typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
__typeof__(__m) __v = (__m); \
atomic_flag* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \
__typeof__ _ATOMIC_MEMBER_ __r = *__p; \
*__p __o __v; \
atomic_flag_clear_explicit(__g, __x); \
__r; })
#define _ATOMIC_CMPEXCHNG_(__a, __e, __m, __x) \
({__typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
__typeof__(__e) __q = (__e); \
__typeof__(__m) __v = (__m); \
bool __r; \
atomic_flag* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \
__typeof__ _ATOMIC_MEMBER_ __t__ = *__p; \
if (__t__ == *__q) { *__p = __v; __r = true; } \
else { *__q = __t__; __r = false; } \
atomic_flag_clear_explicit(__g, __x); \
__r; })
// @} group atomics
_GLIBCXX_END_EXTERN_C
_GLIBCXX_END_NAMESPACE
// Inject into global namespace.
#ifdef __cplusplus
#include <atomic>
using std::memory_order;
using std::memory_order_relaxed;
using std::memory_order_consume;
using std::memory_order_acquire;
using std::memory_order_release;
using std::memory_order_acq_rel;
using std::memory_order_seq_cst;
using std::atomic_flag;
using std::atomic_bool;
using std::atomic_char;
using std::atomic_schar;
using std::atomic_uchar;
using std::atomic_short;
using std::atomic_ushort;
using std::atomic_int;
using std::atomic_uint;
using std::atomic_long;
using std::atomic_ulong;
using std::atomic_llong;
using std::atomic_ullong;
using std::atomic_wchar_t;
using std::atomic_char16_t;
using std::atomic_char32_t;
using std::atomic_address;
using std::atomic;
#endif
#endif

View file

@ -26,196 +26,12 @@
* This is a Standard C++ Library header.
*/
#include <bits/c++config.h>
#include <stddef.h>
#include <stdbool.h> // XXX need to define bool w/o stdbool.h in tr1/cstdbool
#include <bits/atomic_base.h>
#ifndef _GLIBCXX_STDATOMIC_H
#define _GLIBCXX_STDATOMIC_H 1
_GLIBCXX_BEGIN_NAMESPACE(std)
_GLIBCXX_BEGIN_EXTERN_C
/**
* @defgroup atomics Atomics
*
* Components for performing atomic operations.
* @{
*/
/// Enumeration for memory_order
typedef enum memory_order
{
memory_order_relaxed,
memory_order_consume,
memory_order_acquire,
memory_order_release,
memory_order_acq_rel,
memory_order_seq_cst
} memory_order;
// Base for atomic_flag.
typedef struct __atomic_flag_base
{
bool _M_i;
} __atomic_flag_base;
#define ATOMIC_FLAG_INIT { false }
/// 29.2 Lock-free Property
#if defined(_GLIBCXX_ATOMIC_BUILTINS_1) && defined(_GLIBCXX_ATOMIC_BUILTINS_2) \
&& defined(_GLIBCXX_ATOMIC_BUILTINS_4) && defined(_GLIBCXX_ATOMIC_BUILTINS_8)
# define _GLIBCXX_ATOMIC_PROPERTY 2
# define _GLIBCXX_ATOMIC_NAMESPACE __atomic2
#elif defined(_GLIBCXX_ATOMIC_BUILTINS_1)
# define _GLIBCXX_ATOMIC_PROPERTY 1
# define _GLIBCXX_ATOMIC_NAMESPACE __atomic1
#else
# define _GLIBCXX_ATOMIC_PROPERTY 0
# define _GLIBCXX_ATOMIC_NAMESPACE __atomic0
#endif
#define ATOMIC_INTEGRAL_LOCK_FREE _GLIBCXX_ATOMIC_PROPERTY
#define ATOMIC_ADDRESS_LOCK_FREE _GLIBCXX_ATOMIC_PROPERTY
// Switch atomic integral base types based on C or C++. In
// addition, for "C" only provide type-generic macros for atomic
// operations. (As C++ accomplishes the same thing with sets of
// overloaded functions.
#ifdef __cplusplus
inline namespace _GLIBCXX_ATOMIC_NAMESPACE { }
# include <bits/atomicfwd_cxx.h>
#else
# include <bits/atomicfwd_c.h>
#endif
// Typedefs for other atomic integral types.
typedef atomic_schar atomic_int_least8_t;
typedef atomic_uchar atomic_uint_least8_t;
typedef atomic_short atomic_int_least16_t;
typedef atomic_ushort atomic_uint_least16_t;
typedef atomic_int atomic_int_least32_t;
typedef atomic_uint atomic_uint_least32_t;
typedef atomic_llong atomic_int_least64_t;
typedef atomic_ullong atomic_uint_least64_t;
typedef atomic_schar atomic_int_fast8_t;
typedef atomic_uchar atomic_uint_fast8_t;
typedef atomic_short atomic_int_fast16_t;
typedef atomic_ushort atomic_uint_fast16_t;
typedef atomic_int atomic_int_fast32_t;
typedef atomic_uint atomic_uint_fast32_t;
typedef atomic_llong atomic_int_fast64_t;
typedef atomic_ullong atomic_uint_fast64_t;
typedef atomic_long atomic_intptr_t;
typedef atomic_ulong atomic_uintptr_t;
typedef atomic_long atomic_ssize_t;
typedef atomic_ulong atomic_size_t;
typedef atomic_llong atomic_intmax_t;
typedef atomic_ullong atomic_uintmax_t;
typedef atomic_long atomic_ptrdiff_t;
// Accessor functions for base atomic_flag type.
bool
atomic_flag_test_and_set_explicit(volatile __atomic_flag_base*, memory_order) _GLIBCXX_NOTHROW;
inline bool
atomic_flag_test_and_set(volatile __atomic_flag_base* __a)
{ return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
void
atomic_flag_clear_explicit(volatile __atomic_flag_base*, memory_order) _GLIBCXX_NOTHROW;
inline void
atomic_flag_clear(volatile __atomic_flag_base* __a)
{ atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
void
__atomic_flag_wait_explicit(volatile __atomic_flag_base*, memory_order) _GLIBCXX_NOTHROW;
_GLIBCXX_CONST volatile __atomic_flag_base*
__atomic_flag_for_address(const volatile void* __z) _GLIBCXX_NOTHROW;
// Implementation specific defines.
#define _ATOMIC_LOAD_(__a, __x) \
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
volatile atomic_flag* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \
__typeof__ _ATOMIC_MEMBER_ __r = *__p; \
atomic_flag_clear_explicit(__g, __x); \
__r; })
#define _ATOMIC_STORE_(__a, __m, __x) \
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
__typeof__(__m) __v = (__m); \
volatile atomic_flag* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \
*__p = __v; \
atomic_flag_clear_explicit(__g, __x); \
__v; })
#define _ATOMIC_MODIFY_(__a, __o, __m, __x) \
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
__typeof__(__m) __v = (__m); \
volatile atomic_flag* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \
__typeof__ _ATOMIC_MEMBER_ __r = *__p; \
*__p __o __v; \
atomic_flag_clear_explicit(__g, __x); \
__r; })
#define _ATOMIC_CMPEXCHNG_(__a, __e, __m, __x) \
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
__typeof__(__e) __q = (__e); \
__typeof__(__m) __v = (__m); \
bool __r; \
volatile atomic_flag* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \
__typeof__ _ATOMIC_MEMBER_ __t__ = *__p; \
if (__t__ == *__q) { *__p = __v; __r = true; } \
else { *__q = __t__; __r = false; } \
atomic_flag_clear_explicit(__g, __x); \
__r; })
// @} group atomics
_GLIBCXX_END_EXTERN_C
_GLIBCXX_END_NAMESPACE
// Inject into global namespace.
#ifdef __cplusplus
#include <cstdatomic>
using std::memory_order;
using std::memory_order_relaxed;
using std::memory_order_consume;
using std::memory_order_acquire;
using std::memory_order_release;
using std::memory_order_acq_rel;
using std::memory_order_seq_cst;
using std::atomic_flag;
using std::atomic_bool;
using std::atomic_char;
using std::atomic_schar;
using std::atomic_uchar;
using std::atomic_short;
using std::atomic_ushort;
using std::atomic_int;
using std::atomic_uint;
using std::atomic_long;
using std::atomic_ulong;
using std::atomic_llong;
using std::atomic_ullong;
using std::atomic_wchar_t;
using std::atomic_char16_t;
using std::atomic_char32_t;
using std::atomic_address;
using std::atomic;
#ifdef _GLIBCXX_NAMESPACE_C
#endif
#endif

View file

@ -53,7 +53,6 @@
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdatomic>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
@ -97,6 +96,7 @@
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>

View file

@ -23,21 +23,15 @@
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file cstdatomic
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the "*.h" implementation files.
*
* This is the C++ version of the Standard C Library header @c stdatomic.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
/** @file atomic
* This is a Standard C++ Library header.
*/
// Based on "C++ Atomic Types and Operations" by Hans Boehm and Lawrence Crowl.
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html
#ifndef _GLIBCXX_STDATOMIC
#define _GLIBCXX_STDATOMIC 1
#ifndef _GLIBCXX_ATOMIC
#define _GLIBCXX_ATOMIC 1
#pragma GCC system_header
@ -45,7 +39,7 @@
# include <c++0x_warning.h>
#endif
#include <stdatomic.h>
#include <bits/atomic_base.h>
#include <cstddef>
_GLIBCXX_BEGIN_NAMESPACE(std)
@ -79,7 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
//
// The nested namespace inlined into std:: is determined by the value
// of the _GLIBCXX_ATOMIC_PROPERTY macro and the resulting
// ATOMIC_*_LOCK_FREE macros. See file stdatomic.h.
// ATOMIC_*_LOCK_FREE macros. See file atomic_base.h.
//
// 0 == __atomic0 == Never lock-free
// 1 == __atomic1 == Best available, sometimes lock-free
@ -99,14 +93,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(_Tp __i) : _M_i(__i) { }
operator _Tp() const volatile;
operator _Tp() const;
_Tp
operator=(_Tp __i) volatile { store(__i); return __i; }
operator=(_Tp __i) { store(__i); return __i; }
bool
is_lock_free() const volatile;
@ -143,67 +137,65 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(_Tp* __v) : atomic_address(__v) { }
void
store(_Tp*, memory_order = memory_order_seq_cst) volatile;
store(_Tp*, memory_order = memory_order_seq_cst);
_Tp*
load(memory_order = memory_order_seq_cst) const volatile;
load(memory_order = memory_order_seq_cst) const;
_Tp*
exchange(_Tp*, memory_order = memory_order_seq_cst) volatile;
exchange(_Tp*, memory_order = memory_order_seq_cst);
bool
compare_exchange_weak(_Tp*&, _Tp*, memory_order, memory_order) volatile;
compare_exchange_weak(_Tp*&, _Tp*, memory_order, memory_order);
bool
compare_exchange_strong(_Tp*&, _Tp*, memory_order, memory_order) volatile;
compare_exchange_strong(_Tp*&, _Tp*, memory_order, memory_order);
bool
compare_exchange_weak(_Tp*&, _Tp*,
memory_order = memory_order_seq_cst) volatile;
compare_exchange_weak(_Tp*&, _Tp*, memory_order = memory_order_seq_cst);
bool
compare_exchange_strong(_Tp*&, _Tp*,
memory_order = memory_order_seq_cst) volatile;
compare_exchange_strong(_Tp*&, _Tp*, memory_order = memory_order_seq_cst);
_Tp*
fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst) volatile;
fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst);
_Tp*
fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst) volatile;
fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst);
operator _Tp*() const volatile
operator _Tp*() const
{ return load(); }
_Tp*
operator=(_Tp* __v) volatile
operator=(_Tp* __v)
{
store(__v);
return __v;
}
_Tp*
operator++(int) volatile { return fetch_add(1); }
operator++(int) { return fetch_add(1); }
_Tp*
operator--(int) volatile { return fetch_sub(1); }
operator--(int) { return fetch_sub(1); }
_Tp*
operator++() volatile { return fetch_add(1) + 1; }
operator++() { return fetch_add(1) + 1; }
_Tp*
operator--() volatile { return fetch_sub(1) - 1; }
operator--() { return fetch_sub(1) - 1; }
_Tp*
operator+=(ptrdiff_t __d) volatile
operator+=(ptrdiff_t __d)
{ return fetch_add(__d) + __d; }
_Tp*
operator-=(ptrdiff_t __d) volatile
operator-=(ptrdiff_t __d)
{ return fetch_sub(__d) - __d; }
};
@ -218,7 +210,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -236,7 +228,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -254,7 +246,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -272,7 +264,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -290,7 +282,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -308,7 +300,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -326,7 +318,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -344,7 +336,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -362,7 +354,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -380,7 +372,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -398,7 +390,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -416,7 +408,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -434,7 +426,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -452,7 +444,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -470,7 +462,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -488,7 +480,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
atomic() = default;
~atomic() = default;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
atomic(__integral_type __i) : __base_type(__i) { }
@ -499,18 +491,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp>
_Tp*
atomic<_Tp*>::load(memory_order __m) const volatile
atomic<_Tp*>::load(memory_order __m) const
{ return static_cast<_Tp*>(atomic_address::load(__m)); }
template<typename _Tp>
_Tp*
atomic<_Tp*>::exchange(_Tp* __v, memory_order __m) volatile
atomic<_Tp*>::exchange(_Tp* __v, memory_order __m)
{ return static_cast<_Tp*>(atomic_address::exchange(__v, __m)); }
template<typename _Tp>
bool
atomic<_Tp*>::compare_exchange_weak(_Tp*& __r, _Tp* __v, memory_order __m1,
memory_order __m2) volatile
memory_order __m2)
{
void** __vr = reinterpret_cast<void**>(&__r);
void* __vv = static_cast<void*>(__v);
@ -521,7 +513,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
bool
atomic<_Tp*>::compare_exchange_strong(_Tp*& __r, _Tp* __v,
memory_order __m1,
memory_order __m2) volatile
memory_order __m2)
{
void** __vr = reinterpret_cast<void**>(&__r);
void* __vv = static_cast<void*>(__v);
@ -531,7 +523,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp>
bool
atomic<_Tp*>::compare_exchange_weak(_Tp*& __r, _Tp* __v,
memory_order __m) volatile
memory_order __m)
{
return compare_exchange_weak(__r, __v, __m,
__calculate_memory_order(__m));
@ -540,7 +532,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp>
bool
atomic<_Tp*>::compare_exchange_strong(_Tp*& __r, _Tp* __v,
memory_order __m) volatile
memory_order __m)
{
return compare_exchange_strong(__r, __v, __m,
__calculate_memory_order(__m));
@ -548,7 +540,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp>
_Tp*
atomic<_Tp*>::fetch_add(ptrdiff_t __d, memory_order __m) volatile
atomic<_Tp*>::fetch_add(ptrdiff_t __d, memory_order __m)
{
void* __p = atomic_fetch_add_explicit(this, sizeof(_Tp) * __d, __m);
return static_cast<_Tp*>(__p);
@ -556,7 +548,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp>
_Tp*
atomic<_Tp*>::fetch_sub(ptrdiff_t __d, memory_order __m) volatile
atomic<_Tp*>::fetch_sub(ptrdiff_t __d, memory_order __m)
{
void* __p = atomic_fetch_sub_explicit(this, sizeof(_Tp) * __d, __m);
return static_cast<_Tp*>(__p);
@ -564,55 +556,52 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// Convenience function definitions, atomic_flag.
inline bool
atomic_flag_test_and_set_explicit(volatile atomic_flag* __a, memory_order __m)
atomic_flag_test_and_set_explicit(atomic_flag* __a, memory_order __m)
{ return __a->test_and_set(__m); }
inline void
atomic_flag_clear_explicit(volatile atomic_flag* __a, memory_order __m)
atomic_flag_clear_explicit(atomic_flag* __a, memory_order __m)
{ return __a->clear(__m); }
// Convenience function definitions, atomic_address.
inline bool
atomic_is_lock_free(const volatile atomic_address* __a)
atomic_is_lock_free(const atomic_address* __a)
{ return __a->is_lock_free(); }
inline void
atomic_store(volatile atomic_address* __a, void* __v)
atomic_store(atomic_address* __a, void* __v)
{ __a->store(__v); }
inline void
atomic_store_explicit(volatile atomic_address* __a, void* __v,
memory_order __m)
atomic_store_explicit(atomic_address* __a, void* __v, memory_order __m)
{ __a->store(__v, __m); }
inline void*
atomic_load(const volatile atomic_address* __a)
atomic_load(const atomic_address* __a)
{ return __a->load(); }
inline void*
atomic_load_explicit(const volatile atomic_address* __a, memory_order __m)
atomic_load_explicit(const atomic_address* __a, memory_order __m)
{ return __a->load(__m); }
inline void*
atomic_exchange(volatile atomic_address* __a, void* __v)
atomic_exchange(atomic_address* __a, void* __v)
{ return __a->exchange(__v); }
inline void*
atomic_exchange_explicit(volatile atomic_address* __a, void* __v,
memory_order __m)
atomic_exchange_explicit(atomic_address* __a, void* __v, memory_order __m)
{ return __a->exchange(__v, __m); }
inline bool
atomic_compare_exchange_weak(volatile atomic_address* __a,
void** __v1, void* __v2)
atomic_compare_exchange_weak(atomic_address* __a, void** __v1, void* __v2)
{
return __a->compare_exchange_weak(*__v1, __v2, memory_order_seq_cst,
memory_order_seq_cst);
}
inline bool
atomic_compare_exchange_strong(volatile atomic_address* __a,
atomic_compare_exchange_strong(atomic_address* __a,
void** __v1, void* __v2)
{
return __a->compare_exchange_strong(*__v1, __v2, memory_order_seq_cst,
@ -620,89 +609,87 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
}
inline bool
atomic_compare_exchange_weak_explicit(volatile atomic_address* __a,
atomic_compare_exchange_weak_explicit(atomic_address* __a,
void** __v1, void* __v2,
memory_order __m1, memory_order __m2)
{ return __a->compare_exchange_weak(*__v1, __v2, __m1, __m2); }
inline bool
atomic_compare_exchange_strong_explicit(volatile atomic_address* __a,
atomic_compare_exchange_strong_explicit(atomic_address* __a,
void** __v1, void* __v2,
memory_order __m1, memory_order __m2)
{ return __a->compare_exchange_strong(*__v1, __v2, __m1, __m2); }
inline void*
atomic_fetch_add_explicit(volatile atomic_address* __a, ptrdiff_t __d,
atomic_fetch_add_explicit(atomic_address* __a, ptrdiff_t __d,
memory_order __m)
{ return __a->fetch_add(__d, __m); }
inline void*
atomic_fetch_add(volatile atomic_address* __a, ptrdiff_t __d)
atomic_fetch_add(atomic_address* __a, ptrdiff_t __d)
{ return __a->fetch_add(__d); }
inline void*
atomic_fetch_sub_explicit(volatile atomic_address* __a, ptrdiff_t __d,
atomic_fetch_sub_explicit(atomic_address* __a, ptrdiff_t __d,
memory_order __m)
{ return __a->fetch_sub(__d, __m); }
inline void*
atomic_fetch_sub(volatile atomic_address* __a, ptrdiff_t __d)
atomic_fetch_sub(atomic_address* __a, ptrdiff_t __d)
{ return __a->fetch_sub(__d); }
// Convenience function definitions, atomic_bool.
inline bool
atomic_is_lock_free(const volatile atomic_bool* __a)
atomic_is_lock_free(const atomic_bool* __a)
{ return __a->is_lock_free(); }
inline void
atomic_store(volatile atomic_bool* __a, bool __i)
atomic_store(atomic_bool* __a, bool __i)
{ __a->store(__i); }
inline void
atomic_store_explicit(volatile atomic_bool* __a, bool __i, memory_order __m)
atomic_store_explicit(atomic_bool* __a, bool __i, memory_order __m)
{ __a->store(__i, __m); }
inline bool
atomic_load(const volatile atomic_bool* __a)
atomic_load(const atomic_bool* __a)
{ return __a->load(); }
inline bool
atomic_load_explicit(const volatile atomic_bool* __a, memory_order __m)
atomic_load_explicit(const atomic_bool* __a, memory_order __m)
{ return __a->load(__m); }
inline bool
atomic_exchange(volatile atomic_bool* __a, bool __i)
atomic_exchange(atomic_bool* __a, bool __i)
{ return __a->exchange(__i); }
inline bool
atomic_exchange_explicit(volatile atomic_bool* __a, bool __i,
memory_order __m)
atomic_exchange_explicit(atomic_bool* __a, bool __i, memory_order __m)
{ return __a->exchange(__i, __m); }
inline bool
atomic_compare_exchange_weak(volatile atomic_bool* __a, bool* __i1, bool __i2)
atomic_compare_exchange_weak(atomic_bool* __a, bool* __i1, bool __i2)
{
return __a->compare_exchange_weak(*__i1, __i2, memory_order_seq_cst,
memory_order_seq_cst);
}
inline bool
atomic_compare_exchange_strong(volatile atomic_bool* __a,
bool* __i1, bool __i2)
atomic_compare_exchange_strong(atomic_bool* __a, bool* __i1, bool __i2)
{
return __a->compare_exchange_strong(*__i1, __i2, memory_order_seq_cst,
memory_order_seq_cst);
}
inline bool
atomic_compare_exchange_weak_explicit(volatile atomic_bool* __a, bool* __i1,
atomic_compare_exchange_weak_explicit(atomic_bool* __a, bool* __i1,
bool __i2, memory_order __m1,
memory_order __m2)
{ return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
inline bool
atomic_compare_exchange_strong_explicit(volatile atomic_bool* __a,
atomic_compare_exchange_strong_explicit(atomic_bool* __a,
bool* __i1, bool __i2,
memory_order __m1, memory_order __m2)
{ return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
@ -713,32 +700,30 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// to intergral types as specified in the standard.
template<typename _ITp>
inline void
atomic_store_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
memory_order __m)
atomic_store_explicit(__atomic_base<_ITp>* __a, _ITp __i, memory_order __m)
{ __a->store(__i, __m); }
template<typename _ITp>
inline _ITp
atomic_load_explicit(const volatile __atomic_base<_ITp>* __a,
memory_order __m)
atomic_load_explicit(const __atomic_base<_ITp>* __a, memory_order __m)
{ return __a->load(__m); }
template<typename _ITp>
inline _ITp
atomic_exchange_explicit(volatile __atomic_base<_ITp>* __a,
_ITp __i, memory_order __m)
atomic_exchange_explicit(__atomic_base<_ITp>* __a, _ITp __i,
memory_order __m)
{ return __a->exchange(__i, __m); }
template<typename _ITp>
inline bool
atomic_compare_exchange_weak_explicit(volatile __atomic_base<_ITp>* __a,
atomic_compare_exchange_weak_explicit(__atomic_base<_ITp>* __a,
_ITp* __i1, _ITp __i2,
memory_order __m1, memory_order __m2)
{ return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
template<typename _ITp>
inline bool
atomic_compare_exchange_strong_explicit(volatile __atomic_base<_ITp>* __a,
atomic_compare_exchange_strong_explicit(__atomic_base<_ITp>* __a,
_ITp* __i1, _ITp __i2,
memory_order __m1,
memory_order __m2)
@ -746,57 +731,57 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _ITp>
inline _ITp
atomic_fetch_add_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
atomic_fetch_add_explicit(__atomic_base<_ITp>* __a, _ITp __i,
memory_order __m)
{ return __a->fetch_add(__i, __m); }
template<typename _ITp>
inline _ITp
atomic_fetch_sub_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
atomic_fetch_sub_explicit(__atomic_base<_ITp>* __a, _ITp __i,
memory_order __m)
{ return __a->fetch_sub(__i, __m); }
template<typename _ITp>
inline _ITp
atomic_fetch_and_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
atomic_fetch_and_explicit(__atomic_base<_ITp>* __a, _ITp __i,
memory_order __m)
{ return __a->fetch_and(__i, __m); }
template<typename _ITp>
inline _ITp
atomic_fetch_or_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
atomic_fetch_or_explicit(__atomic_base<_ITp>* __a, _ITp __i,
memory_order __m)
{ return __a->fetch_or(__i, __m); }
template<typename _ITp>
inline _ITp
atomic_fetch_xor_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
atomic_fetch_xor_explicit(__atomic_base<_ITp>* __a, _ITp __i,
memory_order __m)
{ return __a->fetch_xor(__i, __m); }
template<typename _ITp>
inline bool
atomic_is_lock_free(const volatile __atomic_base<_ITp>* __a)
atomic_is_lock_free(const __atomic_base<_ITp>* __a)
{ return __a->is_lock_free(); }
template<typename _ITp>
inline void
atomic_store(volatile __atomic_base<_ITp>* __a, _ITp __i)
atomic_store(__atomic_base<_ITp>* __a, _ITp __i)
{ atomic_store_explicit(__a, __i, memory_order_seq_cst); }
template<typename _ITp>
inline _ITp
atomic_load(const volatile __atomic_base<_ITp>* __a)
atomic_load(const __atomic_base<_ITp>* __a)
{ return atomic_load_explicit(__a, memory_order_seq_cst); }
template<typename _ITp>
inline _ITp
atomic_exchange(volatile __atomic_base<_ITp>* __a, _ITp __i)
atomic_exchange(__atomic_base<_ITp>* __a, _ITp __i)
{ return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
template<typename _ITp>
inline bool
atomic_compare_exchange_weak(volatile __atomic_base<_ITp>* __a,
atomic_compare_exchange_weak(__atomic_base<_ITp>* __a,
_ITp* __i1, _ITp __i2)
{
return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
@ -806,7 +791,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _ITp>
inline bool
atomic_compare_exchange_strong(volatile __atomic_base<_ITp>* __a,
atomic_compare_exchange_strong(__atomic_base<_ITp>* __a,
_ITp* __i1, _ITp __i2)
{
return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
@ -816,27 +801,27 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _ITp>
inline _ITp
atomic_fetch_add(volatile __atomic_base<_ITp>* __a, _ITp __i)
atomic_fetch_add(__atomic_base<_ITp>* __a, _ITp __i)
{ return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
template<typename _ITp>
inline _ITp
atomic_fetch_sub(volatile __atomic_base<_ITp>* __a, _ITp __i)
atomic_fetch_sub(__atomic_base<_ITp>* __a, _ITp __i)
{ return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
template<typename _ITp>
inline _ITp
atomic_fetch_and(volatile __atomic_base<_ITp>* __a, _ITp __i)
atomic_fetch_and(__atomic_base<_ITp>* __a, _ITp __i)
{ return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
template<typename _ITp>
inline _ITp
atomic_fetch_or(volatile __atomic_base<_ITp>* __a, _ITp __i)
atomic_fetch_or(__atomic_base<_ITp>* __a, _ITp __i)
{ return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
template<typename _ITp>
inline _ITp
atomic_fetch_xor(volatile __atomic_base<_ITp>* __a, _ITp __i)
atomic_fetch_xor(__atomic_base<_ITp>* __a, _ITp __i)
{ return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
// @} group atomics
@ -844,5 +829,3 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_GLIBCXX_END_NAMESPACE
#endif

View file

@ -41,7 +41,7 @@
#include <condition_variable>
#include <system_error>
#include <exception>
#include <cstdatomic>
#include <atomic>
#include <bits/functexcept.h>
namespace std

View file

@ -24,7 +24,7 @@
// <http://www.gnu.org/licenses/>.
#include "gstdint.h"
#include <cstdatomic>
#include <atomic>
#include <mutex>
#define LOGSIZE 4
@ -40,7 +40,7 @@ namespace
}
#endif
std::__atomic_flag_base volatile flag_table[ 1 << LOGSIZE ] =
std::__atomic_flag_base flag_table[ 1 << LOGSIZE ] =
{
ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT,
ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT,
@ -54,7 +54,7 @@ namespace std
namespace __atomic0
{
bool
atomic_flag::test_and_set(memory_order) volatile
atomic_flag::test_and_set(memory_order)
{
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
lock_guard<mutex> __lock(get_atomic_mutex());
@ -65,7 +65,7 @@ namespace std
}
void
atomic_flag::clear(memory_order) volatile
atomic_flag::clear(memory_order)
{
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
lock_guard<mutex> __lock(get_atomic_mutex());
@ -77,31 +77,31 @@ namespace std
extern "C"
{
bool
atomic_flag_test_and_set_explicit(volatile __atomic_flag_base* __a,
atomic_flag_test_and_set_explicit(__atomic_flag_base* __a,
memory_order __m) throw ()
{
volatile atomic_flag* d = static_cast<volatile atomic_flag*>(__a);
atomic_flag* d = static_cast<volatile atomic_flag*>(__a);
return d->test_and_set(__m);
}
void
atomic_flag_clear_explicit(volatile __atomic_flag_base* __a,
atomic_flag_clear_explicit(__atomic_flag_base* __a,
memory_order __m) throw ()
{
volatile atomic_flag* d = static_cast<volatile atomic_flag*>(__a);
atomic_flag* d = static_cast<volatile atomic_flag*>(__a);
return d->clear(__m);
}
void
__atomic_flag_wait_explicit(volatile __atomic_flag_base* __a,
__atomic_flag_wait_explicit(__atomic_flag_base* __a,
memory_order __x) throw ()
{
while (atomic_flag_test_and_set_explicit(__a, __x))
{ };
}
volatile __atomic_flag_base*
__atomic_flag_for_address(const volatile void* __z) throw ()
__atomic_flag_base*
__atomic_flag_for_address(const void* __z) throw ()
{
uintptr_t __u = reinterpret_cast<uintptr_t>(__z);
__u += (__u >> 2) + (__u << 4);
@ -114,3 +114,24 @@ namespace std
}
} // extern "C"
} // namespace std
// XXX GLIBCXX_ABI Deprecated
// gcc-4.5.0
// <atomic> signature changes
// The rename syntax for default exported names is
// asm (".symver name1,exportedname@GLIBCXX_3.4")
// asm (".symver name2,exportedname@@GLIBCXX_3.4.5")
// In the future, GLIBCXX_ABI > 6 should remove all uses of
// _GLIBCXX_*_SYMVER macros in this file.
#define _GLIBCXX_ASM_SYMVER(cur, old, version) \
asm (".symver " #cur "," #old "@@" #version);
#if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC) \
&& defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE)
_GLIBCXX_ASM_SYMVER(_ZNSt9__atomic011atomic_flag5clearESt12memory_order, _ZNVSt9__atomic011atomic_flag5clearESt12memory_order, GLIBCXX_3.4.11)
_GLIBCXX_ASM_SYMVER(_ZNSt9__atomic011atomic_flag12test_and_setESt12memory_order, _ZNVSt9__atomic011atomic_flag12test_and_setESt12memory_order, GLIBCXX_3.4.11)
#endif

View file

@ -33,9 +33,23 @@
namespace std
{
// gcc-4.4.0
// <mutex> exported std::lock_error
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
class lock_error : public exception
{
public:
virtual const char*
_GLIBCXX_CONST what() const throw();
};
const char*
lock_error::what() const throw()
{ return "std::lock_error"; }
#endif
// We need these due to the symbols exported since GLIBCXX_3.4.10.
// See libstdc++/41662 for details.
template<typename _Tp>
struct hash : public std::unary_function<_Tp, size_t>
{

View file

@ -513,25 +513,6 @@ extern __attribute__((used, weak)) const void * const _ZTIPKe[4]
(void *) _ZTSPKe, (void *) 1L, (void *) _ZTIe };
#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
// gcc-4.4.0
// <mutex> exported std::lock_error
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
namespace std
{
class lock_error : public exception
{
public:
virtual const char*
_GLIBCXX_CONST what() const throw();
};
const char*
lock_error::what() const throw()
{ return "std::lock_error"; }
}
#endif
#ifdef _GLIBCXX_SYMVER_DARWIN
#if (defined(__ppc__) || defined(__ppc64__)) && defined(PIC)
/* __eprintf shouldn't have been made visible from libstdc++, or

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()
@ -30,19 +29,19 @@ int main()
}
// { dg-error "used here" "" { target *-*-* } 521 }
// { dg-error "deleted function" "" { target *-*-* } 239 }
// { dg-error "deleted function" "" { target *-*-* } 257 }
// { dg-error "deleted function" "" { target *-*-* } 275 }
// { dg-error "deleted function" "" { target *-*-* } 293 }
// { dg-error "deleted function" "" { target *-*-* } 311 }
// { dg-error "deleted function" "" { target *-*-* } 329 }
// { dg-error "deleted function" "" { target *-*-* } 347 }
// { dg-error "deleted function" "" { target *-*-* } 365 }
// { dg-error "deleted function" "" { target *-*-* } 383 }
// { dg-error "deleted function" "" { target *-*-* } 401 }
// { dg-error "deleted function" "" { target *-*-* } 419 }
// { dg-error "deleted function" "" { target *-*-* } 437 }
// { dg-error "deleted function" "" { target *-*-* } 455 }
// { dg-error "deleted function" "" { target *-*-* } 473 }
// { dg-error "deleted function" "" { target *-*-* } 491 }
// { dg-error "deleted function" "" { target *-*-* } 231 }
// { dg-error "deleted function" "" { target *-*-* } 249 }
// { dg-error "deleted function" "" { target *-*-* } 267 }
// { dg-error "deleted function" "" { target *-*-* } 285 }
// { dg-error "deleted function" "" { target *-*-* } 303 }
// { dg-error "deleted function" "" { target *-*-* } 321 }
// { dg-error "deleted function" "" { target *-*-* } 339 }
// { dg-error "deleted function" "" { target *-*-* } 357 }
// { dg-error "deleted function" "" { target *-*-* } 375 }
// { dg-error "deleted function" "" { target *-*-* } 393 }
// { dg-error "deleted function" "" { target *-*-* } 411 }
// { dg-error "deleted function" "" { target *-*-* } 429 }
// { dg-error "deleted function" "" { target *-*-* } 447 }
// { dg-error "deleted function" "" { target *-*-* } 465 }
// { dg-error "deleted function" "" { target *-*-* } 483 }
// { dg-excess-errors "In member function" }

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()
@ -30,19 +29,19 @@ int main()
}
// { dg-error "used here" "" { target *-*-* } 560 }
// { dg-error "deleted function" "" { target *-*-* } 238 }
// { dg-error "deleted function" "" { target *-*-* } 256 }
// { dg-error "deleted function" "" { target *-*-* } 274 }
// { dg-error "deleted function" "" { target *-*-* } 292 }
// { dg-error "deleted function" "" { target *-*-* } 310 }
// { dg-error "deleted function" "" { target *-*-* } 328 }
// { dg-error "deleted function" "" { target *-*-* } 346 }
// { dg-error "deleted function" "" { target *-*-* } 364 }
// { dg-error "deleted function" "" { target *-*-* } 382 }
// { dg-error "deleted function" "" { target *-*-* } 400 }
// { dg-error "deleted function" "" { target *-*-* } 418 }
// { dg-error "deleted function" "" { target *-*-* } 436 }
// { dg-error "deleted function" "" { target *-*-* } 454 }
// { dg-error "deleted function" "" { target *-*-* } 472 }
// { dg-error "deleted function" "" { target *-*-* } 490 }
// { dg-error "deleted function" "" { target *-*-* } 248 }
// { dg-error "deleted function" "" { target *-*-* } 266 }
// { dg-error "deleted function" "" { target *-*-* } 284 }
// { dg-error "deleted function" "" { target *-*-* } 302 }
// { dg-error "deleted function" "" { target *-*-* } 320 }
// { dg-error "deleted function" "" { target *-*-* } 338 }
// { dg-error "deleted function" "" { target *-*-* } 356 }
// { dg-error "deleted function" "" { target *-*-* } 374 }
// { dg-error "deleted function" "" { target *-*-* } 230 }
// { dg-error "deleted function" "" { target *-*-* } 410 }
// { dg-error "deleted function" "" { target *-*-* } 428 }
// { dg-error "deleted function" "" { target *-*-* } 446 }
// { dg-error "deleted function" "" { target *-*-* } 464 }
// { dg-error "deleted function" "" { target *-*-* } 482 }
// { dg-error "deleted function" "" { target *-*-* } 392 }
// { dg-excess-errors "In member function" }

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -0,0 +1,39 @@
// { dg-options "-std=gnu++0x" }
// { dg-do link { xfail *-*-* } }
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <atomic>
struct dwordp
{
int* p1;
int* p2;
};
void atomics()
{
std::atomic<dwordp> a;
bool b = a.is_lock_free(); // { dg-excess-errors "undefined reference to" }
}
int main()
{
atomics();
return 0;
}

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_hooks.h>
#include <testsuite_common_types.h>

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_hooks.h>
#include <testsuite_common_types.h>

View file

@ -18,7 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
void test01()

View file

@ -18,10 +18,9 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of basic_string
#include <cstdatomic>
#include <atomic>
#include <testsuite_character.h>
template class std::atomic<__gnu_test::pod_char>;

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
int main()
{

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
void test01()
{
@ -29,5 +28,5 @@ void test01()
test_type t2;
t1 = t2;
}
// { dg-error "used here" "" { target *-*-* } 30 }
// { dg-error "used here" "" { target *-*-* } 29 }
// { dg-excess-errors "deleted function" }

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
void test01()
{
@ -28,5 +27,5 @@ void test01()
test_type t1;
test_type t2(t1);
}
// { dg-error "used here" "" { target *-*-* } 29 }
// { dg-error "used here" "" { target *-*-* } 28 }
// { dg-excess-errors "deleted function" }

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
int main()
{

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
int main()
{

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
void test01()

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
void test01()

View file

@ -17,7 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_hooks.h>
int main()

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
int main()
{

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
void test01()
{
@ -29,5 +28,5 @@ void test01()
test_type t2;
t1 = t2;
}
// { dg-error "used here" "" { target *-*-* } 30 }
// { dg-error "used here" "" { target *-*-* } 29 }
// { dg-excess-errors "deleted function" }

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
void test01()
{
@ -28,5 +27,5 @@ void test01()
test_type t1;
test_type t2(t1);
}
// { dg-error "used here" "" { target *-*-* } 29 }
// { dg-error "used here" "" { target *-*-* } 28 }
// { dg-excess-errors "deleted function" }

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
int main()
{

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
void test01()

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
void test01()

View file

@ -17,7 +17,6 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <stdatomic.h>
int main()

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
int main()
{

View file

@ -17,7 +17,6 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <stdatomic.h>
int main()

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
int main()
{

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()
@ -33,7 +32,7 @@ int main()
// { dg-error "used here" "" { target *-*-* } 521 }
// { dg-excess-errors "deleted function" }
// { dg-excess-errors "deleted function" }
// { dg-error "instantiated from" "" { target *-*-* } 29 }
// { dg-error "instantiated from" "" { target *-*-* } 28 }
// { dg-error "instantiated from" "" { target *-*-* } 528 }
// { dg-error "instantiated from" "" { target *-*-* } 170 }
// { dg-error "instantiated from" "" { target *-*-* } 399 }

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()
@ -33,7 +32,7 @@ int main()
// { dg-error "used here" "" { target *-*-* } 560 }
// { dg-excess-errors "deleted function" }
// { dg-excess-errors "deleted function" }
// { dg-error "instantiated from" "" { target *-*-* } 29 }
// { dg-error "instantiated from" "" { target *-*-* } 28 }
// { dg-error "instantiated from" "" { target *-*-* } 566 }
// { dg-error "instantiated from" "" { target *-*-* } 170 }
// { dg-error "instantiated from" "" { target *-*-* } 399 }

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -18,8 +18,7 @@
// along with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -18,8 +18,7 @@
// along with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -18,8 +18,7 @@
// along with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -18,8 +18,7 @@
// along with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -18,8 +18,7 @@
// along with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -18,8 +18,7 @@
// along with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
int main()

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_hooks.h>
#include <testsuite_common_types.h>

View file

@ -17,8 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_hooks.h>
#include <testsuite_common_types.h>

View file

@ -19,7 +19,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
void test01()

View file

@ -18,8 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
#include <testsuite_common_types.h>
void test01()

View file

@ -18,7 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
namespace gnu
{

View file

@ -18,7 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
namespace gnu
{

View file

@ -18,7 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic> // { dg-excess-errors "In file included from" }
#include <atomic> // { dg-excess-errors "In file included from" }
// { dg-error "upcoming ISO" "" { target *-*-* } 31 }

View file

@ -18,7 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdatomic>
#include <atomic>
void test01()
{

View file

@ -0,0 +1,78 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <atomic>
void test01()
{
// Not global scoped, only namespace std.
using memory_order;
using memory_order_relaxed;
using memory_order_consume;
using memory_order_acquire;
using memory_order_release;
using memory_order_acq_rel;
using memory_order_seq_cst;
using atomic_flag;
using atomic_bool;
using atomic_char;
using atomic_schar;
using atomic_uchar;
using atomic_short;
using atomic_ushort;
using atomic_int;
using atomic_uint;
using atomic_long;
using atomic_ulong;
using atomic_llong;
using atomic_ullong;
using atomic_wchar_t;
using atomic_char16_t;
using atomic_char32_t;
using atomic_address;
}
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 26 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 27 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 28 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 29 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 30 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 31 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 32 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 34 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 36 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 37 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 38 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 39 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 40 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 41 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 42 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 43 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 44 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 45 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 46 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 47 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 48 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 49 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 50 }
// { dg-error "expected nested-name-specifier" "" { target *-*-* } 52 }

View file

@ -22,8 +22,8 @@
int main()
{
volatile atomic_flag f;
volatile atomic_flag* p = &f;
atomic_flag f;
atomic_flag* p = &f;
memory_order m = memory_order_relaxed;
// For position only.

View file

@ -44,7 +44,7 @@
#include <tr1/unordered_set>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdatomic>
#include <atomic>
#include <type_traits>
#endif