cstdatomic: Update to N2798.

2008-12-11  Benjamin Kosnik  <bkoz@redhat.com>
	    Richard Henderson  <rth@redhat.com>

	* include/c_global/cstdatomic: Update to N2798.
	(atomic): Remove explicit constructors as per DR 845.
	* include/bits/atomic_0.h: New. Switchable implementation.
	* include/bits/atomic_2.h: New. Lock-free implementation.
	* include/c_compatibility/stdatomic.h: Use foward headers.
	* include/bits/atomicfwd_cxx.h: New.
	* include/bits/atomicfwd_c.h: New.
	* src/atomic.cc: Adjust.
	* acinclude.m4 (GLIBCXX_CHECK_STANDARD_LAYOUT): Remove,
	unconditionally use default/deleted syntax.
	(GLIBCXX_ENABLE_ATOMIC_BUILTINS): Check for 2, 8.
	* include/Makefile.am (bits_headers): Add atomicfwd_c.h,
	atomicfwd_cxx.h, atomic_0.h, atomic_2.h.
	* include/Makefile.in: Regenerate.
	* configure: Regenerate.
	* config.h.in: Regenerate.
	* config/abi/pre/gnu.ver: Adjust exports.

	* testsuite/27_io/ios_base/types/fmtflags/bitmask_operators.cc: Adjust.
	* testsuite/27_io/ios_base/types/openmode/bitmask_operators.cc: Same.
	* testsuite/27_io/ios_base/types/iostate/bitmask_operators.cc: Same.
	* testsuite/29_atomics/atomic_address/cons/assign_neg.cc: Same.
	* testsuite/29_atomics/atomic_address/cons/explicit_value.cc: Move to..
	* testsuite/29_atomics/atomic_address/cons/single_value.cc: ...this.
	* testsuite/29_atomics/atomic_address/cons/copy_neg.cc
	* testsuite/29_atomics/atomic_integral/cons/single_value.cc: New.
	* testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: New.
	* testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: New.
	* testsuite/29_atomics/atomic_integral/cons/default.cc: New.
	* testsuite/29_atomics/atomic_integral/cons/direct_list.cc: New.
	* testsuite/29_atomics/atomic_integral/cons/copy_list.cc: New.
	* testsuite/29_atomics/atomic_integral/requirements/
	standard_layout.cc: New.
	* testsuite/29_atomics/atomic_integral/operators/
	integral_assignment.cc: New.
	* testsuite/29_atomics/atomic_integral/operators/increment_neg.cc: New.
	* testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc: New.
	* testsuite/29_atomics/atomic_integral/operators/decrement_neg.cc: New.
	* testsuite/29_atomics/atomic_integral/operators/increment.cc: New.
	* testsuite/29_atomics/atomic_integral/operators/decrement.cc: New.
	* testsuite/29_atomics/atomic_integral/operators/bitwise.cc: New.
	* testsuite/29_atomics/atomic_integral/operators/
	integral_conversion.cc: New.
	* testsuite/29_atomics/atomic_flag/cons/assign_neg.cc: Adjust.
	* testsuite/29_atomics/atomic_flag/cons/copy_neg.cc: Same.
	* testsuite/29_atomics/atomic_flag/requirements/
	standard_layout.cc: Same.
	* testsuite/29_atomics/atomic_flag/
	atomic_global_fence_compatibility.cc: Kill.
	* testsuite/29_atomics/headers/cstdatomic/types_std_c++0x.cc: Adjust.
	* testsuite/29_atomics/headers/cstdatomic/functions_std_c++0x.cc: Same.
	* testsuite/29_atomics/headers/cstdatomic/macros.cc: Same.
	* testsuite/29_atomics/headers/stdatomic.h/macros.c: Same.
	* testsuite/29_atomics/headers/stdatomic.h/types.c: Same.
	* testsuite/29_atomics/atomic/cons/assign_neg.cc: Same.
	* testsuite/29_atomics/atomic/cons/explicit_value.cc: Move to...
	* testsuite/29_atomics/atomic/cons/single_value.cc: ...this.
	* testsuite/29_atomics/atomic/cons/copy_neg.cc
	* testsuite/29_atomics/atomic/cons/direct_list.cc: New.
	* testsuite/29_atomics/atomic/cons/copy_list.cc: New.
	* testsuite/29_atomics/atomic/requirements/standard_layout.cc: New.
	* testsuite/29_atomics/atomic/requirements/base_classes.cc: New.
	* testsuite/29_atomics/atomic/operators/integral_assignment.cc: New.
	* testsuite/29_atomics/atomic/operators/integral_conversion.cc: New.
	* testsuite/util/testsuite_hooks.h (bitmask_operators): Move...
	* testsuite/util/testsuite_common_types.h: ...here.
	(atomic_integrals_no_bool): New.
	(atomic_integrals): New.
	(has_increment_operators, has_decrement_operators)
	(direct_list_initializable, single_value_constructible)
	(standard_layout, has_bitwise_operators, integral_convertable)
	(integral_assignable): Add.


Co-Authored-By: Richard Henderson <rth@redhat.com>

From-SVN: r142714
This commit is contained in:
Benjamin Kosnik 2008-12-12 17:10:16 +00:00 committed by Benjamin Kosnik
parent 0f2dc4ccd7
commit 50ce8d3d78
54 changed files with 3388 additions and 4398 deletions

View File

@ -1,3 +1,79 @@
2008-12-11 Benjamin Kosnik <bkoz@redhat.com>
Richard Henderson <rth@redhat.com>
* include/c_global/cstdatomic: Update to N2798.
(atomic): Remove explicit constructors as per DR 845.
* include/bits/atomic_0.h: New. Switchable implementation.
* include/bits/atomic_2.h: New. Lock-free implementation.
* include/c_compatibility/stdatomic.h: Use foward headers.
* include/bits/atomicfwd_cxx.h: New.
* include/bits/atomicfwd_c.h: New.
* src/atomic.cc: Adjust.
* acinclude.m4 (GLIBCXX_CHECK_STANDARD_LAYOUT): Remove,
unconditionally use default/deleted syntax.
(GLIBCXX_ENABLE_ATOMIC_BUILTINS): Check for 2, 8.
* include/Makefile.am (bits_headers): Add atomicfwd_c.h,
atomicfwd_cxx.h, atomic_0.h, atomic_2.h.
* include/Makefile.in: Regenerate.
* configure: Regenerate.
* config.h.in: Regenerate.
* config/abi/pre/gnu.ver: Adjust exports.
* testsuite/27_io/ios_base/types/fmtflags/bitmask_operators.cc: Adjust.
* testsuite/27_io/ios_base/types/openmode/bitmask_operators.cc: Same.
* testsuite/27_io/ios_base/types/iostate/bitmask_operators.cc: Same.
* testsuite/29_atomics/atomic_address/cons/assign_neg.cc: Same.
* testsuite/29_atomics/atomic_address/cons/explicit_value.cc: Move to..
* testsuite/29_atomics/atomic_address/cons/single_value.cc: ...this.
* testsuite/29_atomics/atomic_address/cons/copy_neg.cc
* testsuite/29_atomics/atomic_integral/cons/single_value.cc: New.
* testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: New.
* testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: New.
* testsuite/29_atomics/atomic_integral/cons/default.cc: New.
* testsuite/29_atomics/atomic_integral/cons/direct_list.cc: New.
* testsuite/29_atomics/atomic_integral/cons/copy_list.cc: New.
* testsuite/29_atomics/atomic_integral/requirements/
standard_layout.cc: New.
* testsuite/29_atomics/atomic_integral/operators/
integral_assignment.cc: New.
* testsuite/29_atomics/atomic_integral/operators/increment_neg.cc: New.
* testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc: New.
* testsuite/29_atomics/atomic_integral/operators/decrement_neg.cc: New.
* testsuite/29_atomics/atomic_integral/operators/increment.cc: New.
* testsuite/29_atomics/atomic_integral/operators/decrement.cc: New.
* testsuite/29_atomics/atomic_integral/operators/bitwise.cc: New.
* testsuite/29_atomics/atomic_integral/operators/
integral_conversion.cc: New.
* testsuite/29_atomics/atomic_flag/cons/assign_neg.cc: Adjust.
* testsuite/29_atomics/atomic_flag/cons/copy_neg.cc: Same.
* testsuite/29_atomics/atomic_flag/requirements/
standard_layout.cc: Same.
* testsuite/29_atomics/atomic_flag/
atomic_global_fence_compatibility.cc: Kill.
* testsuite/29_atomics/headers/cstdatomic/types_std_c++0x.cc: Adjust.
* testsuite/29_atomics/headers/cstdatomic/functions_std_c++0x.cc: Same.
* testsuite/29_atomics/headers/cstdatomic/macros.cc: Same.
* testsuite/29_atomics/headers/stdatomic.h/macros.c: Same.
* testsuite/29_atomics/headers/stdatomic.h/types.c: Same.
* testsuite/29_atomics/atomic/cons/assign_neg.cc: Same.
* testsuite/29_atomics/atomic/cons/explicit_value.cc: Move to...
* testsuite/29_atomics/atomic/cons/single_value.cc: ...this.
* testsuite/29_atomics/atomic/cons/copy_neg.cc
* testsuite/29_atomics/atomic/cons/direct_list.cc: New.
* testsuite/29_atomics/atomic/cons/copy_list.cc: New.
* testsuite/29_atomics/atomic/requirements/standard_layout.cc: New.
* testsuite/29_atomics/atomic/requirements/base_classes.cc: New.
* testsuite/29_atomics/atomic/operators/integral_assignment.cc: New.
* testsuite/29_atomics/atomic/operators/integral_conversion.cc: New.
* testsuite/util/testsuite_hooks.h (bitmask_operators): Move...
* testsuite/util/testsuite_common_types.h: ...here.
(atomic_integrals_no_bool): New.
(atomic_integrals): New.
(has_increment_operators, has_decrement_operators)
(direct_list_initializable, single_value_constructible)
(standard_layout, has_bitwise_operators, integral_convertable)
(integral_assignable): Add.
2008-12-11 Jakub Jelinek <jakub@redhat.com> 2008-12-11 Jakub Jelinek <jakub@redhat.com>
PR c++/37582 PR c++/37582

View File

@ -1676,41 +1676,6 @@ m4_popdef([SYSERR])dnl
m4_popdef([n_syserr])dnl m4_popdef([n_syserr])dnl
]) ])
dnl
dnl Check whether C++200x's standard layout types are supported.
dnl
AC_DEFUN([GLIBCXX_CHECK_STANDARD_LAYOUT], [
AC_MSG_CHECKING([for ISO C++200x standard layout type support])
AC_CACHE_VAL(ac_standard_layout, [
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_test_CXXFLAGS="${CXXFLAGS+set}"
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS='-std=gnu++0x'
AC_TRY_COMPILE([struct b
{
bool t;
// Need standard layout relaxation from POD
private:
b& operator=(const b&);
b(const b&);
};],
[b tst1 = { false };],
[ac_standard_layout=yes], [ac_standard_layout=no])
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
AC_MSG_RESULT($ac_standard_layout)
if test x"$ac_standard_layout" = x"yes"; then
AC_DEFINE(_GLIBCXX_USE_STANDARD_LAYOUT, 1,
[Define if standard layout types are supported in C++200x.])
fi
])
dnl dnl
dnl Check for what type of C headers to use. dnl Check for what type of C headers to use.
dnl dnl
@ -2456,7 +2421,9 @@ dnl see: CHECK_SYNC_FETCH_AND_ADD
dnl dnl
dnl Defines: dnl Defines:
dnl _GLIBCXX_ATOMIC_BUILTINS_1 dnl _GLIBCXX_ATOMIC_BUILTINS_1
dnl _GLIBCXX_ATOMIC_BUILTINS_2
dnl _GLIBCXX_ATOMIC_BUILTINS_4 dnl _GLIBCXX_ATOMIC_BUILTINS_4
dnl _GLIBCXX_ATOMIC_BUILTINS_8
dnl dnl
AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [ AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
AC_LANG_SAVE AC_LANG_SAVE
@ -2472,6 +2439,66 @@ AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
cat > conftest.$ac_ext << EOF cat > conftest.$ac_ext << EOF
[#]line __oline__ "configure" [#]line __oline__ "configure"
int main() int main()
{
typedef bool atomic_type;
atomic_type c1;
atomic_type c2;
const atomic_type c3(0);
__sync_fetch_and_add(&c1, c2);
__sync_val_compare_and_swap(&c1, c3, c2);
__sync_lock_test_and_set(&c1, c3);
__sync_lock_release(&c1);
__sync_synchronize();
return 0;
}
EOF
AC_MSG_CHECKING([for atomic builtins for bool])
if AC_TRY_EVAL(ac_compile); then
if grep __sync_ conftest.s >/dev/null 2>&1 ; then
enable_atomic_builtinsb=no
else
AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1,
[Define if builtin atomic operations for bool are supported on this host.])
enable_atomic_builtinsb=yes
fi
fi
AC_MSG_RESULT($enable_atomic_builtinsb)
rm -f conftest*
cat > conftest.$ac_ext << EOF
[#]line __oline__ "configure"
int main()
{
typedef short atomic_type;
atomic_type c1;
atomic_type c2;
const atomic_type c3(0);
__sync_fetch_and_add(&c1, c2);
__sync_val_compare_and_swap(&c1, c3, c2);
__sync_lock_test_and_set(&c1, c3);
__sync_lock_release(&c1);
__sync_synchronize();
return 0;
}
EOF
AC_MSG_CHECKING([for atomic builtins for short])
if AC_TRY_EVAL(ac_compile); then
if grep __sync_ conftest.s >/dev/null 2>&1 ; then
enable_atomic_builtinss=no
else
AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1,
[Define if builtin atomic operations for short are supported on this host.])
enable_atomic_builtinss=yes
fi
fi
AC_MSG_RESULT($enable_atomic_builtinss)
rm -f conftest*
cat > conftest.$ac_ext << EOF
[#]line __oline__ "configure"
int main()
{ {
// NB: _Atomic_word not necessarily int. // NB: _Atomic_word not necessarily int.
typedef int atomic_type; typedef int atomic_type;
@ -2504,7 +2531,7 @@ EOF
[#]line __oline__ "configure" [#]line __oline__ "configure"
int main() int main()
{ {
typedef bool atomic_type; typedef long long atomic_type;
atomic_type c1; atomic_type c1;
atomic_type c2; atomic_type c2;
const atomic_type c3(0); const atomic_type c3(0);
@ -2517,19 +2544,20 @@ int main()
} }
EOF EOF
AC_MSG_CHECKING([for atomic builtins for bool]) AC_MSG_CHECKING([for atomic builtins for long long])
if AC_TRY_EVAL(ac_compile); then if AC_TRY_EVAL(ac_compile); then
if grep __sync_ conftest.s >/dev/null 2>&1 ; then if grep __sync_ conftest.s >/dev/null 2>&1 ; then
enable_atomic_builtinsb=no enable_atomic_builtinsll=no
else else
AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1, AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1,
[Define if builtin atomic operations for bool are supported on this host.]) [Define if builtin atomic operations for long long are supported on this host.])
enable_atomic_builtinsb=yes enable_atomic_builtinsll=yes
fi fi
fi fi
AC_MSG_RESULT($enable_atomic_builtinsb) AC_MSG_RESULT($enable_atomic_builtinsll)
rm -f conftest* rm -f conftest*
CXXFLAGS="$old_CXXFLAGS" CXXFLAGS="$old_CXXFLAGS"
AC_LANG_RESTORE AC_LANG_RESTORE

View File

@ -692,9 +692,17 @@
/* Define if builtin atomic operations for bool are supported on this host. */ /* Define if builtin atomic operations for bool are supported on this host. */
#undef _GLIBCXX_ATOMIC_BUILTINS_1 #undef _GLIBCXX_ATOMIC_BUILTINS_1
/* Define if builtin atomic operations for short are supported on this host.
*/
#undef _GLIBCXX_ATOMIC_BUILTINS_2
/* Define if builtin atomic operations for int are supported on this host. */ /* Define if builtin atomic operations for int are supported on this host. */
#undef _GLIBCXX_ATOMIC_BUILTINS_4 #undef _GLIBCXX_ATOMIC_BUILTINS_4
/* Define if builtin atomic operations for long long are supported on this
host. */
#undef _GLIBCXX_ATOMIC_BUILTINS_8
/* Define to use concept checking code from the boost libraries. */ /* Define to use concept checking code from the boost libraries. */
#undef _GLIBCXX_CONCEPT_CHECKS #undef _GLIBCXX_CONCEPT_CHECKS
@ -804,9 +812,6 @@
of TR1 (Chapter 5.1). */ of TR1 (Chapter 5.1). */
#undef _GLIBCXX_USE_RANDOM_TR1 #undef _GLIBCXX_USE_RANDOM_TR1
/* Define if standard layout types are supported in C++200x. */
#undef _GLIBCXX_USE_STANDARD_LAYOUT
/* Define if code specialized for wchar_t should be used. */ /* Define if code specialized for wchar_t should be used. */
#undef _GLIBCXX_USE_WCHAR_T #undef _GLIBCXX_USE_WCHAR_T

View File

@ -866,13 +866,11 @@ GLIBCXX_3.4.11 {
# atomic # atomic
__atomic_flag_for_address; __atomic_flag_for_address;
__atomic_flag_wait_explicit; __atomic_flag_wait_explicit;
atomic_flag_clear;
atomic_flag_clear_explicit; atomic_flag_clear_explicit;
atomic_flag_fence;
atomic_flag_test_and_set;
atomic_flag_test_and_set_explicit; atomic_flag_test_and_set_explicit;
atomic_global_fence_compatibility; _ZNVSt9__atomic011atomic_flag12test_and_setESt12memory_order;
_ZNVSt9__atomic011atomic_flag5clearESt12memory_order;
# mutex # mutex
_ZSt10adopt_lock; _ZSt10adopt_lock;
_ZSt10defer_lock; _ZSt10defer_lock;

192
libstdc++-v3/configure vendored
View File

@ -14711,6 +14711,84 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat > conftest.$ac_ext << EOF cat > conftest.$ac_ext << EOF
#line 14712 "configure" #line 14712 "configure"
int main() int main()
{
typedef bool atomic_type;
atomic_type c1;
atomic_type c2;
const atomic_type c3(0);
__sync_fetch_and_add(&c1, c2);
__sync_val_compare_and_swap(&c1, c3, c2);
__sync_lock_test_and_set(&c1, c3);
__sync_lock_release(&c1);
__sync_synchronize();
return 0;
}
EOF
echo "$as_me:$LINENO: checking for atomic builtins for bool" >&5
echo $ECHO_N "checking for atomic builtins for bool... $ECHO_C" >&6
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
if grep __sync_ conftest.s >/dev/null 2>&1 ; then
enable_atomic_builtinsb=no
else
cat >>confdefs.h <<\_ACEOF
#define _GLIBCXX_ATOMIC_BUILTINS_1 1
_ACEOF
enable_atomic_builtinsb=yes
fi
fi
echo "$as_me:$LINENO: result: $enable_atomic_builtinsb" >&5
echo "${ECHO_T}$enable_atomic_builtinsb" >&6
rm -f conftest*
cat > conftest.$ac_ext << EOF
#line 14751 "configure"
int main()
{
typedef short atomic_type;
atomic_type c1;
atomic_type c2;
const atomic_type c3(0);
__sync_fetch_and_add(&c1, c2);
__sync_val_compare_and_swap(&c1, c3, c2);
__sync_lock_test_and_set(&c1, c3);
__sync_lock_release(&c1);
__sync_synchronize();
return 0;
}
EOF
echo "$as_me:$LINENO: checking for atomic builtins for short" >&5
echo $ECHO_N "checking for atomic builtins for short... $ECHO_C" >&6
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
if grep __sync_ conftest.s >/dev/null 2>&1 ; then
enable_atomic_builtinss=no
else
cat >>confdefs.h <<\_ACEOF
#define _GLIBCXX_ATOMIC_BUILTINS_2 1
_ACEOF
enable_atomic_builtinss=yes
fi
fi
echo "$as_me:$LINENO: result: $enable_atomic_builtinss" >&5
echo "${ECHO_T}$enable_atomic_builtinss" >&6
rm -f conftest*
cat > conftest.$ac_ext << EOF
#line 14790 "configure"
int main()
{ {
// NB: _Atomic_word not necessarily int. // NB: _Atomic_word not necessarily int.
typedef int atomic_type; typedef int atomic_type;
@ -14749,10 +14827,10 @@ echo "${ECHO_T}$enable_atomic_builtinsi" >&6
rm -f conftest* rm -f conftest*
cat > conftest.$ac_ext << EOF cat > conftest.$ac_ext << EOF
#line 14752 "configure" #line 14830 "configure"
int main() int main()
{ {
typedef bool atomic_type; typedef long long atomic_type;
atomic_type c1; atomic_type c1;
atomic_type c2; atomic_type c2;
const atomic_type c3(0); const atomic_type c3(0);
@ -14765,28 +14843,29 @@ int main()
} }
EOF EOF
echo "$as_me:$LINENO: checking for atomic builtins for bool" >&5 echo "$as_me:$LINENO: checking for atomic builtins for long long" >&5
echo $ECHO_N "checking for atomic builtins for bool... $ECHO_C" >&6 echo $ECHO_N "checking for atomic builtins for long long... $ECHO_C" >&6
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5 (eval $ac_compile) 2>&5
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then (exit $ac_status); }; then
if grep __sync_ conftest.s >/dev/null 2>&1 ; then if grep __sync_ conftest.s >/dev/null 2>&1 ; then
enable_atomic_builtinsb=no enable_atomic_builtinsll=no
else else
cat >>confdefs.h <<\_ACEOF cat >>confdefs.h <<\_ACEOF
#define _GLIBCXX_ATOMIC_BUILTINS_1 1 #define _GLIBCXX_ATOMIC_BUILTINS_8 1
_ACEOF _ACEOF
enable_atomic_builtinsb=yes enable_atomic_builtinsll=yes
fi fi
fi fi
echo "$as_me:$LINENO: result: $enable_atomic_builtinsb" >&5 echo "$as_me:$LINENO: result: $enable_atomic_builtinsll" >&5
echo "${ECHO_T}$enable_atomic_builtinsb" >&6 echo "${ECHO_T}$enable_atomic_builtinsll" >&6
rm -f conftest* rm -f conftest*
CXXFLAGS="$old_CXXFLAGS" CXXFLAGS="$old_CXXFLAGS"
ac_ext=c ac_ext=c
ac_cpp='$CPP $CPPFLAGS' ac_cpp='$CPP $CPPFLAGS'
@ -14939,100 +15018,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
GLIBCXX_CHECK_STANDARD_LAYOUT
echo "$as_me:$LINENO: checking for ISO C++200x standard layout type support" >&5
echo $ECHO_N "checking for ISO C++200x standard layout type support... $ECHO_C" >&6
if test "${ac_standard_layout+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_ext=cc
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
ac_test_CXXFLAGS="${CXXFLAGS+set}"
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS='-std=gnu++0x'
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
struct b
{
bool t;
// Need standard layout relaxation from POD
private:
b& operator=(const b&);
b(const b&);
};
int
main ()
{
b tst1 = { false };
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_cxx_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_standard_layout=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_standard_layout=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
CXXFLAGS="$ac_save_CXXFLAGS"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
fi
echo "$as_me:$LINENO: result: $ac_standard_layout" >&5
echo "${ECHO_T}$ac_standard_layout" >&6
if test x"$ac_standard_layout" = x"yes"; then
cat >>confdefs.h <<\_ACEOF
#define _GLIBCXX_USE_STANDARD_LAYOUT 1
_ACEOF
fi
# Enable all the variable C++ runtime options that don't require linking. # Enable all the variable C++ runtime options that don't require linking.

View File

@ -78,6 +78,10 @@ bits_builddir = ./bits
bits_headers = \ bits_headers = \
${bits_srcdir}/algorithmfwd.h \ ${bits_srcdir}/algorithmfwd.h \
${bits_srcdir}/allocator.h \ ${bits_srcdir}/allocator.h \
${bits_srcdir}/atomicfwd_c.h \
${bits_srcdir}/atomicfwd_cxx.h \
${bits_srcdir}/atomic_0.h \
${bits_srcdir}/atomic_2.h \
${bits_srcdir}/basic_ios.h \ ${bits_srcdir}/basic_ios.h \
${bits_srcdir}/basic_ios.tcc \ ${bits_srcdir}/basic_ios.tcc \
${bits_srcdir}/basic_string.h \ ${bits_srcdir}/basic_string.h \

View File

@ -344,6 +344,10 @@ bits_builddir = ./bits
bits_headers = \ bits_headers = \
${bits_srcdir}/algorithmfwd.h \ ${bits_srcdir}/algorithmfwd.h \
${bits_srcdir}/allocator.h \ ${bits_srcdir}/allocator.h \
${bits_srcdir}/atomicfwd_c.h \
${bits_srcdir}/atomicfwd_cxx.h \
${bits_srcdir}/atomic_0.h \
${bits_srcdir}/atomic_2.h \
${bits_srcdir}/basic_ios.h \ ${bits_srcdir}/basic_ios.h \
${bits_srcdir}/basic_ios.tcc \ ${bits_srcdir}/basic_ios.tcc \
${bits_srcdir}/basic_string.h \ ${bits_srcdir}/basic_string.h \

View File

@ -0,0 +1,471 @@
// -*- C++ -*- header.
// Copyright (C) 2008
// 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 2, 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 COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/** @file bits/atomic_0.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
#ifndef _GLIBCXX_ATOMIC_0_H
#define _GLIBCXX_ATOMIC_0_H 1
#pragma GCC system_header
// _GLIBCXX_BEGIN_NAMESPACE(std)
// 0 == __atomic0 == Never lock-free
namespace __atomic0
{
struct atomic_flag;
// 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); \
__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_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__(__m) __v = (__m); \
volatile __atomic_flag_base* __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_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; } \
else { *__q = __t__; __r = false; } \
atomic_flag_clear_explicit(__g, __x); \
__r; })
/// atomic_flag
struct atomic_flag : private __atomic_flag_base
{
atomic_flag() = default;
~atomic_flag() = default;
atomic_flag(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) = delete;
atomic_flag(bool __i) { _M_i = __i; } // XXX deleted copy ctor != agg
bool
test_and_set(memory_order __m = memory_order_seq_cst) volatile;
void
clear(memory_order __m = memory_order_seq_cst) volatile;
};
/// 29.4.2, address types
struct atomic_address
{
private:
void* _M_i;
public:
atomic_address() = default;
~atomic_address() = default;
atomic_address(const atomic_address&) = delete;
atomic_address& operator=(const atomic_address&) = delete;
atomic_address(void* __v) { _M_i = __v; }
bool
is_lock_free() const volatile
{ return false; }
void
store(void* __v, memory_order __m = memory_order_seq_cst) volatile
{
// XXX
//if (__m != memory_order_acquire && __m != memory_order_acq_rel
// && __m != memory_order_consume)
_ATOMIC_STORE_(this, __v, __m);
}
void*
load(memory_order __m = memory_order_seq_cst) const volatile
{
// XXX
//if (__m != memory_order_release && __m != memory_order_acq_rel)
return _ATOMIC_LOAD_(this, __m);
}
void*
exchange(void* __v, memory_order __m = memory_order_seq_cst) volatile
{ return _ATOMIC_MODIFY_(this, =, __v, __m); }
bool
compare_exchange_weak(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
{
bool __ret = false;
if (__m2 != memory_order_release && __m2 != memory_order_acq_rel
&& __m2 <= __m1)
__ret = _ATOMIC_CMPEXCHNG_(this, &__v1, __v2, __m1);
return __ret;
}
bool
compare_exchange_weak(void*& __v1, void* __v2,
memory_order __m = memory_order_seq_cst) volatile
{
return compare_exchange_weak(__v1, __v2, __m,
__calculate_memory_order(__m));
}
bool
compare_exchange_strong(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
{
bool __ret = false;
if (__m2 != memory_order_release && __m2 != memory_order_acq_rel
&& __m2 <= __m1)
__ret = _ATOMIC_CMPEXCHNG_(this, &__v1, __v2, __m1);
return __ret;
}
bool
compare_exchange_strong(void*& __v1, void* __v2,
memory_order __m = memory_order_seq_cst) volatile
{
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
{
void* volatile* __p = &(_M_i);
volatile __atomic_flag_base* __g = __atomic_flag_for_address(__p);
__atomic_flag_wait_explicit(__g, __m);
void* __r = *__p;
*__p = (void*)((char*)(*__p) + __d);
atomic_flag_clear_explicit(__g, __m);
return __r;
}
void*
fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile
{
void* volatile* __p = &(_M_i);
volatile __atomic_flag_base* __g = __atomic_flag_for_address(__p);
__atomic_flag_wait_explicit(__g, __m);
void* __r = *__p;
*__p = (void*)((char*)(*__p) - __d);
atomic_flag_clear_explicit(__g, __m);
return __r;
}
operator void*() const volatile
{ return load(); }
void*
operator=(void* __v) // XXX volatile
{
store(__v);
return __v;
}
void*
operator+=(ptrdiff_t __d) volatile
{ return fetch_add(__d) + __d; }
void*
operator-=(ptrdiff_t __d) volatile
{ return fetch_sub(__d) - __d; }
};
// 29.3.1 atomic integral types
// For each of the integral types, define atomic_[integral type] struct
//
// atomic_bool bool
// atomic_char char
// atomic_schar signed char
// atomic_uchar unsigned char
// atomic_short short
// atomic_ushort unsigned short
// atomic_int int
// atomic_uint unsigned int
// atomic_long long
// atomic_ulong unsigned long
// atomic_llong long long
// atomic_ullong unsigned long long
// atomic_char16_t char16_t
// atomic_char32_t char32_t
// atomic_wchar_t wchar_t
// Base type.
// NB: Assuming _ITp is an integral scalar type that is 1, 2, 4, or 8 bytes,
// since that is what GCC built-in functions for atomic memory access work on.
template<typename _ITp>
struct __atomic_base
{
private:
typedef _ITp __integral_type;
__integral_type _M_i;
public:
__atomic_base() = default;
~__atomic_base() = default;
__atomic_base(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) = delete;
// Requires __integral_type convertible to _M_base._M_i.
__atomic_base(__integral_type __i) { _M_i = __i; }
operator __integral_type() const volatile
{ return load(); }
__integral_type
operator=(__integral_type __i) // XXX volatile
{
store(__i);
return __i;
}
__integral_type
operator++(int) volatile
{ return fetch_add(1); }
__integral_type
operator--(int) volatile
{ return fetch_sub(1); }
__integral_type
operator++() volatile
{ return fetch_add(1) + 1; }
__integral_type
operator--() volatile
{ return fetch_sub(1) - 1; }
__integral_type
operator+=(__integral_type __i) volatile
{ return fetch_add(__i) + __i; }
__integral_type
operator-=(__integral_type __i) volatile
{ return fetch_sub(__i) - __i; }
__integral_type
operator&=(__integral_type __i) volatile
{ return fetch_and(__i) & __i; }
__integral_type
operator|=(__integral_type __i) volatile
{ return fetch_or(__i) | __i; }
__integral_type
operator^=(__integral_type __i) volatile
{ return fetch_xor(__i) ^ __i; }
bool
is_lock_free() const volatile
{ return false; }
void
store(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{
// XXX
//if (__m != memory_order_acquire && __m != memory_order_acq_rel
// && __m != memory_order_consume)
_ATOMIC_STORE_(this, __i, __m);
}
__integral_type
load(memory_order __m = memory_order_seq_cst) const volatile
{
// if (__m != memory_order_release && __m != memory_order_acq_rel)
return _ATOMIC_LOAD_(this, __m);
}
__integral_type
exchange(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{ return _ATOMIC_MODIFY_(this, =, __i, __m); }
bool
compare_exchange_weak(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
{
bool __ret = false;
if (__m2 != memory_order_release && __m2 != memory_order_acq_rel
&& __m2 <= __m1)
__ret = _ATOMIC_CMPEXCHNG_(this, &__i1, __i2, __m1);
return __ret;
}
bool
compare_exchange_weak(__integral_type& __i1, __integral_type __i2,
memory_order __m = memory_order_seq_cst) volatile
{
return compare_exchange_weak(__i1, __i2, __m,
__calculate_memory_order(__m));
}
bool
compare_exchange_strong(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
{
bool __ret = false;
if (__m2 != memory_order_release && __m2 != memory_order_acq_rel
&& __m2 <= __m1)
__ret = _ATOMIC_CMPEXCHNG_(this, &__i1, __i2, __m1);
return __ret;
}
bool
compare_exchange_strong(__integral_type& __i1, __integral_type __i2,
memory_order __m = memory_order_seq_cst) volatile
{
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
{ return _ATOMIC_MODIFY_(this, +=, __i, __m); }
__integral_type
fetch_sub(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{ return _ATOMIC_MODIFY_(this, -=, __i, __m); }
__integral_type
fetch_and(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{ return _ATOMIC_MODIFY_(this, &=, __i, __m); }
__integral_type
fetch_or(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{ return _ATOMIC_MODIFY_(this, |=, __i, __m); }
__integral_type
fetch_xor(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{ return _ATOMIC_MODIFY_(this, ^=, __i, __m); }
};
/// atomic_bool
// NB: No operators or fetch-operations for this type.
struct atomic_bool
{
private:
__atomic_base<bool> _M_base;
public:
atomic_bool() = default;
~atomic_bool() = default;
atomic_bool(const atomic_bool&) = delete;
atomic_bool& operator=(const atomic_bool&) = delete;
atomic_bool(bool __i) : _M_base(__i) { }
bool
operator=(bool __i) // XXX volatile
{ return _M_base.operator=(__i); }
operator bool() const volatile
{ return _M_base.load(); }
bool
is_lock_free() const volatile
{ return _M_base.is_lock_free(); }
void
store(bool __i, memory_order __m = memory_order_seq_cst) volatile
{ _M_base.store(__i, __m); }
bool
load(memory_order __m = memory_order_seq_cst) const volatile
{ return _M_base.load(__m); }
bool
exchange(bool __i, memory_order __m = memory_order_seq_cst) volatile
{ return _M_base.exchange(__i, __m); }
bool
compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1,
memory_order __m2) volatile
{ 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
{ return _M_base.compare_exchange_weak(__i1, __i2, __m); }
bool
compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1,
memory_order __m2) volatile
{ 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
{ return _M_base.compare_exchange_strong(__i1, __i2, __m); }
};
#undef _ATOMIC_LOAD_
#undef _ATOMIC_STORE_
#undef _ATOMIC_MODIFY_
#undef _ATOMIC_CMPEXCHNG_
} // namespace __atomic0
// _GLIBCXX_END_NAMESPACE
#endif

View File

@ -0,0 +1,456 @@
// -*- C++ -*- header.
// Copyright (C) 2008
// 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 2, 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 COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/** @file bits/atomic_2.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
#ifndef _GLIBCXX_ATOMIC_2_H
#define _GLIBCXX_ATOMIC_2_H 1
#pragma GCC system_header
#include <cassert> // XXX static_assert vs. constant-expression PR38502
// _GLIBCXX_BEGIN_NAMESPACE(std)
// 2 == __atomic2 == Always lock-free
// Assumed:
// _GLIBCXX_ATOMIC_BUILTINS_1
// _GLIBCXX_ATOMIC_BUILTINS_2
// _GLIBCXX_ATOMIC_BUILTINS_4
// _GLIBCXX_ATOMIC_BUILTINS_8
namespace __atomic2
{
/// atomic_flag
struct atomic_flag : private __atomic_flag_base
{
atomic_flag() = default;
~atomic_flag() = default;
atomic_flag(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) = delete;
atomic_flag(bool __i) { _M_i = __i; } // XXX deleted copy ctor != agg
bool
test_and_set(memory_order __m = memory_order_seq_cst) volatile
{
// Redundant synchronize if built-in for lock is a full barrier.
if (__m != memory_order_acquire && __m != memory_order_acq_rel)
__sync_synchronize();
return __sync_lock_test_and_set(&_M_i, 1);
}
void
clear(memory_order __m = memory_order_seq_cst) volatile
{
__sync_lock_release(&_M_i);
if (__m != memory_order_acquire && __m != memory_order_acq_rel)
__sync_synchronize();
}
};
/// 29.4.2, address types
struct atomic_address
{
private:
void* _M_i;
public:
atomic_address() = default;
~atomic_address() = default;
atomic_address(const atomic_address&) = delete;
atomic_address& operator=(const atomic_address&) = delete;
atomic_address(void* __v) { _M_i = __v; }
bool
is_lock_free() const volatile
{ return true; }
void
store(void* __v, memory_order __m = memory_order_seq_cst) volatile
{
assert(__m == memory_order_acquire);
assert(__m == memory_order_acq_rel);
assert(__m == memory_order_consume);
if (__m == memory_order_relaxed)
_M_i = __v;
else
{
// write_mem_barrier();
_M_i = __v;
if (__m = memory_order_seq_cst)
__sync_synchronize();
}
}
void*
load(memory_order __m = memory_order_seq_cst) const volatile
{
assert(__m == memory_order_release);
assert(__m == memory_order_acq_rel);
__sync_synchronize();
void* __ret = _M_i;
__sync_synchronize();
return __ret;
}
void*
exchange(void* __v, memory_order __m = memory_order_seq_cst) volatile
{
// XXX built-in assumes memory_order_acquire.
return __sync_lock_test_and_set(&_M_i, __v);
}
bool
compare_exchange_weak(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
{ return compare_exchange_strong(__v1, __v2, __m1, __m2); }
bool
compare_exchange_weak(void*& __v1, void* __v2,
memory_order __m = memory_order_seq_cst) volatile
{
return compare_exchange_weak(__v1, __v2, __m,
__calculate_memory_order(__m));
}
bool
compare_exchange_strong(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
{
assert(__m2 == memory_order_release);
assert(__m2 == memory_order_acq_rel);
assert(__m2 <= __m1);
void* __v1o = __v1;
void* __v1n = __sync_val_compare_and_swap(&_M_i, __v1o, __v2);
// Assume extra stores (of same value) allowed in true case.
__v1 = __v1n;
return __v1o == __v1n;
}
bool
compare_exchange_strong(void*& __v1, void* __v2,
memory_order __m = memory_order_seq_cst) volatile
{
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
{ return __sync_fetch_and_add(&_M_i, __d); }
void*
fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile
{ return __sync_fetch_and_sub(&_M_i, __d); }
operator void*() const volatile
{ return load(); }
void*
operator=(void* __v) // XXX volatile
{
store(__v);
return __v;
}
void*
operator+=(ptrdiff_t __d) volatile
{ return __sync_add_and_fetch(&_M_i, __d); }
void*
operator-=(ptrdiff_t __d) volatile
{ return __sync_sub_and_fetch(&_M_i, __d); }
};
// 29.3.1 atomic integral types
// For each of the integral types, define atomic_[integral type] struct
//
// atomic_bool bool
// atomic_char char
// atomic_schar signed char
// atomic_uchar unsigned char
// atomic_short short
// atomic_ushort unsigned short
// atomic_int int
// atomic_uint unsigned int
// atomic_long long
// atomic_ulong unsigned long
// atomic_llong long long
// atomic_ullong unsigned long long
// atomic_char16_t char16_t
// atomic_char32_t char32_t
// atomic_wchar_t wchar_t
// Base type.
// NB: Assuming _ITp is an integral scalar type that is 1, 2, 4, or 8 bytes,
// since that is what GCC built-in functions for atomic memory access work on.
template<typename _ITp>
struct __atomic_base
{
private:
typedef _ITp __integral_type;
__integral_type _M_i;
public:
__atomic_base() = default;
~__atomic_base() = default;
__atomic_base(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) = delete;
// Requires __integral_type convertible to _M_base._M_i.
__atomic_base(__integral_type __i) { _M_i = __i; }
operator __integral_type() const volatile
{ return load(); }
__integral_type
operator=(__integral_type __i) // XXX volatile
{
store(__i);
return __i;
}
__integral_type
operator++(int) volatile
{ return fetch_add(1); }
__integral_type
operator--(int) volatile
{ return fetch_sub(1); }
__integral_type
operator++() volatile
{ return __sync_add_and_fetch(&_M_i, 1); }
__integral_type
operator--() volatile
{ return __sync_sub_and_fetch(&_M_i, 1); }
__integral_type
operator+=(__integral_type __i) volatile
{ return __sync_add_and_fetch(&_M_i, __i); }
__integral_type
operator-=(__integral_type __i) volatile
{ return __sync_sub_and_fetch(&_M_i, __i); }
__integral_type
operator&=(__integral_type __i) volatile
{ return __sync_and_and_fetch(&_M_i, __i); }
__integral_type
operator|=(__integral_type __i) volatile
{ return __sync_or_and_fetch(&_M_i, __i); }
__integral_type
operator^=(__integral_type __i) volatile
{ return __sync_xor_and_fetch(&_M_i, __i); }
bool
is_lock_free() const volatile
{ return true; }
void
store(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{
assert(__m == memory_order_acquire);
assert(__m == memory_order_acq_rel);
assert(__m == memory_order_consume);
if (__m == memory_order_relaxed)
_M_i = __i;
else
{
// write_mem_barrier();
_M_i = __i;
if (__m = memory_order_seq_cst)
__sync_synchronize();
}
}
__integral_type
load(memory_order __m = memory_order_seq_cst) const volatile
{
assert(__m == memory_order_release);
assert(__m == memory_order_acq_rel);
__sync_synchronize();
__integral_type __ret = _M_i;
__sync_synchronize();
return __ret;
}
__integral_type
exchange(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{
// XXX built-in assumes memory_order_acquire.
return __sync_lock_test_and_set(&_M_i, __i);
}
bool
compare_exchange_weak(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
{ 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
{
return compare_exchange_weak(__i1, __i2, __m,
__calculate_memory_order(__m));
}
bool
compare_exchange_strong(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
{
assert(__m2 == memory_order_release);
assert(__m2 == memory_order_acq_rel);
assert(__m2 <= __m1);
__integral_type __i1o = __i1;
__integral_type __i1n = __sync_val_compare_and_swap(&_M_i, __i1o, __i2);
// Assume extra stores (of same value) allowed in true case.
__i1 = __i1n;
return __i1o == __i1n;
}
bool
compare_exchange_strong(__integral_type& __i1, __integral_type __i2,
memory_order __m = memory_order_seq_cst) volatile
{
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
{ return __sync_fetch_and_add(&_M_i, __i); }
__integral_type
fetch_sub(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{ return __sync_fetch_and_sub(&_M_i, __i); }
__integral_type
fetch_and(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{ return __sync_fetch_and_and(&_M_i, __i); }
__integral_type
fetch_or(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{ return __sync_fetch_and_or(&_M_i, __i); }
__integral_type
fetch_xor(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{ return __sync_fetch_and_xor(&_M_i, __i); }
};
/// atomic_bool
// NB: No operators or fetch-operations for this type.
struct atomic_bool
{
private:
__atomic_base<bool> _M_base;
public:
atomic_bool() = default;
~atomic_bool() = default;
atomic_bool(const atomic_bool&) = delete;
atomic_bool& operator=(const atomic_bool&) = delete;
atomic_bool(bool __i) : _M_base(__i) { }
bool
operator=(bool __i) // XXX volatile
{ return _M_base.operator=(__i); }
operator bool() const volatile
{ return _M_base.load(); }
bool
is_lock_free() const volatile
{ return _M_base.is_lock_free(); }
void
store(bool __i, memory_order __m = memory_order_seq_cst) volatile
{ _M_base.store(__i, __m); }
bool
load(memory_order __m = memory_order_seq_cst) const volatile
{ return _M_base.load(__m); }
bool
exchange(bool __i, memory_order __m = memory_order_seq_cst) volatile
{ return _M_base.exchange(__i, __m); }
bool
compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1,
memory_order __m2) volatile
{ 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
{ return _M_base.compare_exchange_weak(__i1, __i2, __m); }
bool
compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1,
memory_order __m2) volatile
{ 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
{ return _M_base.compare_exchange_strong(__i1, __i2, __m); }
};
} // namespace __atomic2
// _GLIBCXX_END_NAMESPACE
#endif

View File

@ -0,0 +1,179 @@
// -*- C++ -*- header.
// Copyright (C) 2008
// 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 2, 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 COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/** @file bits/atomicfwd_c.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
// "C" only bits.
#define _ATOMIC_MEMBER_ ((__a)->_M_i)
// POD base classes for atomic intgral types.
struct __atomic_bool_base
{
bool _M_i;
};
struct __atomic_char_base
{
char _M_i;
};
struct __atomic_schar_base
{
signed char _M_i;
};
struct __atomic_uchar_base
{
unsigned char _M_i;
};
struct __atomic_short_base
{
short _M_i;
};
struct __atomic_ushort_base
{
unsigned short _M_i;
};
struct __atomic_int_base
{
int _M_i;
};
struct __atomic_uint_base
{
unsigned int _M_i;
};
struct __atomic_long_base
{
long _M_i;
};
struct __atomic_ulong_base
{
unsigned long _M_i;
};
struct __atomic_llong_base
{
long long _M_i;
};
struct __atomic_ullong_base
{
unsigned long long _M_i;
};
struct __atomic_wchar_t_base
{
wchar_t _M_i;
};
typedef struct __atomic_flag_base atomic_flag;
typedef struct __atomic_address_base atomic_address;
typedef struct __atomic_bool_base atomic_bool;
typedef struct __atomic_char_base atomic_char;
typedef struct __atomic_schar_base atomic_schar;
typedef struct __atomic_uchar_base atomic_uchar;
typedef struct __atomic_short_base atomic_short;
typedef struct __atomic_ushort_base atomic_ushort;
typedef struct __atomic_int_base atomic_int;
typedef struct __atomic_uint_base atomic_uint;
typedef struct __atomic_long_base atomic_long;
typedef struct __atomic_ulong_base atomic_ulong;
typedef struct __atomic_llong_base atomic_llong;
typedef struct __atomic_ullong_base atomic_ullong;
typedef struct __atomic_wchar_t_base atomic_wchar_t;
typedef struct __atomic_short_base atomic_char16_t;
typedef struct __atomic_int_base atomic_char32_t;
#define atomic_is_lock_free(__a) \
false
#define atomic_load_explicit(__a, __x) \
_ATOMIC_LOAD_(__a, __x)
#define atomic_load(__a) \
atomic_load_explicit(__a, memory_order_seq_cst)
#define atomic_store_explicit(__a, __m, __x) \
_ATOMIC_STORE_(__a, __m, __x)
#define atomic_store(__a, __m) \
atomic_store_explicit(__a, __m, memory_order_seq_cst)
#define atomic_exchange_explicit(__a, __m, __x) \
_ATOMIC_MODIFY_(__a, =, __m, __x)
#define atomic_exchange(__a, __m) \
atomic_exchange_explicit(__a, __m, memory_order_seq_cst)
#define atomic_compare_exchange_explicit(__a, __e, __m, __x, __y) \
_ATOMIC_CMPEXCHNG_(__a, __e, __m, __x)
#define atomic_compare_exchange(__a, __e, __m) \
_ATOMIC_CMPEXCHNG_(__a, __e, __m, memory_order_seq_cst)
#define atomic_fetch_add_explicit(__a, __m, __x) \
_ATOMIC_MODIFY_(__a, +=, __m, __x)
#define atomic_fetch_add(__a, __m) \
atomic_fetch_add_explicit(__a, __m, memory_order_seq_cst)
#define atomic_fetch_sub_explicit(__a, __m, __x) \
_ATOMIC_MODIFY_(__a, -=, __m, __x)
#define atomic_fetch_sub(__a, __m) \
atomic_fetch_sub_explicit(__a, __m, memory_order_seq_cst)
#define atomic_fetch_and_explicit(__a, __m, __x) \
_ATOMIC_MODIFY_(__a, &=, __m, __x)
#define atomic_fetch_and(__a, __m) \
atomic_fetch_and_explicit(__a, __m, memory_order_seq_cst)
#define atomic_fetch_or_explicit(__a, __m, __x) \
_ATOMIC_MODIFY_(__a, |=, __m, __x)
#define atomic_fetch_or(__a, __m) \
atomic_fetch_or_explicit(__a, __m, memory_order_seq_cst)
#define atomic_fetch_xor_explicit(__a, __m, __x) \
_ATOMIC_MODIFY_(__a, ^=, __m, __x)
#define atomic_fetch_xor(__a, __m) \
atomic_fetch_xor_explicit(__a, __m, memory_order_seq_cst)

View File

@ -0,0 +1,114 @@
// -*- C++ -*- header.
// Copyright (C) 2008
// 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 2, 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 COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301, USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/** @file bits/atomicfwd_cxx.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
// "C++" only bits.
#define _ATOMIC_MEMBER_ _M_i
_GLIBCXX_END_EXTERN_C
namespace __atomic0
{
template<typename _IntTp>
struct __atomic_base;
struct atomic_flag;
struct atomic_address;
struct atomic_bool;
}
namespace __atomic2
{
template<typename _IntTp>
struct __atomic_base;
struct atomic_flag;
struct atomic_address;
struct atomic_bool;
}
namespace __atomic1
{
using __atomic2::atomic_flag;
using __atomic2::atomic_bool;
using __atomic0::atomic_address;
using __atomic0::__atomic_base;
}
/// atomic_char
typedef __atomic_base<char> atomic_char;
/// atomic_schar
typedef __atomic_base<signed char> atomic_schar;
/// atomic_uchar
typedef __atomic_base<unsigned char> atomic_uchar;
/// atomic_short
typedef __atomic_base<short> atomic_short;
/// atomic_ushort
typedef __atomic_base<unsigned short> atomic_ushort;
/// atomic_int
typedef __atomic_base<int> atomic_int;
/// atomic_uint
typedef __atomic_base<unsigned int> atomic_uint;
/// atomic_long
typedef __atomic_base<long> atomic_long;
/// atomic_ulong
typedef __atomic_base<unsigned long> atomic_ulong;
/// atomic_llong
typedef __atomic_base<long long> atomic_llong;
/// atomic_ullong
typedef __atomic_base<unsigned long long> atomic_ullong;
/// atomic_wchar_t
typedef __atomic_base<wchar_t> atomic_wchar_t;
/// atomic_char16_t
typedef __atomic_base<char16_t> atomic_char16_t;
/// atomic_char32_t
typedef __atomic_base<char32_t> atomic_char32_t;
template<typename _Tp>
struct atomic;
_GLIBCXX_BEGIN_EXTERN_C

View File

@ -45,201 +45,46 @@ _GLIBCXX_BEGIN_EXTERN_C
typedef enum memory_order typedef enum memory_order
{ {
memory_order_relaxed, memory_order_relaxed,
memory_order_consume,
memory_order_acquire, memory_order_acquire,
memory_order_release, memory_order_release,
memory_order_acq_rel, memory_order_acq_rel,
memory_order_seq_cst memory_order_seq_cst
} memory_order; } memory_order;
// Base for atomic_flag. // Base for atomic_flag.
struct __atomic_flag_base typedef struct __atomic_flag_base
{
bool _M_b;
};
// Base for atomic_address
struct __atomic_address_base
{
void* _M_i;
};
// POD base classes for atomic intgral types.
struct __atomic_bool_base
{ {
bool _M_i; bool _M_i;
}; } __atomic_flag_base;
struct __atomic_char_base #define ATOMIC_FLAG_INIT { false }
{
char _M_i;
};
struct __atomic_schar_base /// 29.2 Lock-free Property
{ #if defined(_GLIBCXX_ATOMIC_BUILTINS_1) && defined(_GLIBCXX_ATOMIC_BUILTINS_2) \
signed char _M_i; && 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
struct __atomic_uchar_base #define ATOMIC_INTEGRAL_LOCK_FREE _GLIBCXX_ATOMIC_PROPERTY
{ #define ATOMIC_ADDRESS_LOCK_FREE _GLIBCXX_ATOMIC_PROPERTY
unsigned char _M_i;
};
struct __atomic_short_base
{
short _M_i;
};
struct __atomic_ushort_base
{
unsigned short _M_i;
};
struct __atomic_int_base
{
int _M_i;
};
struct __atomic_uint_base
{
unsigned int _M_i;
};
struct __atomic_long_base
{
long _M_i;
};
struct __atomic_ulong_base
{
unsigned long _M_i;
};
struct __atomic_llong_base
{
long long _M_i;
};
struct __atomic_ullong_base
{
unsigned long long _M_i;
};
struct __atomic_wchar_t_base
{
wchar_t _M_i;
};
// Switch atomic integral base types based on C or C++. In // Switch atomic integral base types based on C or C++. In
// addition, for "C" only provide type-generic macros for atomic // addition, for "C" only provide type-generic macros for atomic
// operations. (As C++ accomplishes the same thing with sets of // operations. (As C++ accomplishes the same thing with sets of
// overloaded functions. // overloaded functions.
#ifdef __cplusplus #ifdef __cplusplus
inline namespace _GLIBCXX_ATOMIC_NAMESPACE { }
#define ATOMIC_FLAG_INIT { { false } } # include <bits/atomicfwd_cxx.h>
#define _ATOMIC_MEMBER_ ((__a)->_M_base._M_i)
extern "C++"
{
struct atomic_flag;
struct atomic_address;
struct atomic_bool;
struct atomic_char;
struct atomic_schar;
struct atomic_uchar;
struct atomic_short;
struct atomic_ushort;
struct atomic_int;
struct atomic_uint;
struct atomic_long;
struct atomic_ulong;
struct atomic_llong;
struct atomic_ullong;
struct atomic_wchar_t;
template<typename _Tp>
struct atomic;
}
#else #else
# include <bits/atomicfwd_c.h>
#define ATOMIC_FLAG_INIT { false }
#define _ATOMIC_MEMBER_ ((__a)->_M_i)
typedef struct __atomic_flag_base atomic_flag;
typedef struct __atomic_address_base atomic_address;
typedef struct __atomic_bool_base atomic_bool;
typedef struct __atomic_char_base atomic_char;
typedef struct __atomic_schar_base atomic_schar;
typedef struct __atomic_uchar_base atomic_uchar;
typedef struct __atomic_short_base atomic_short;
typedef struct __atomic_ushort_base atomic_ushort;
typedef struct __atomic_int_base atomic_int;
typedef struct __atomic_uint_base atomic_uint;
typedef struct __atomic_long_base atomic_long;
typedef struct __atomic_ulong_base atomic_ulong;
typedef struct __atomic_llong_base atomic_llong;
typedef struct __atomic_ullong_base atomic_ullong;
typedef struct __atomic_wchar_t_base atomic_wchar_t;
#define atomic_is_lock_free(__a) \
false
#define atomic_load(__a) \
_ATOMIC_LOAD_(__a, memory_order_seq_cst)
#define atomic_load_explicit(__a, __x) \
_ATOMIC_LOAD_(__a, __x)
#define atomic_store(__a, __m) \
_ATOMIC_STORE_(__a, __m, memory_order_seq_cst)
#define atomic_store_explicit(__a, __m, __x) \
_ATOMIC_STORE_(__a, __m, __x)
#define atomic_swap(__a, __m) \
_ATOMIC_MODIFY_(__a, =, __m, memory_order_seq_cst)
#define atomic_swap_explicit(__a, __m, __x) \
_ATOMIC_MODIFY_(__a, =, __m, __x)
#define atomic_compare_swap(__a, __e, __m) \
_ATOMIC_CMPSWP_(__a, __e, __m, memory_order_seq_cst)
#define atomic_compare_swap_explicit(__a, __e, __m, __x, __y) \
_ATOMIC_CMPSWP_(__a, __e, __m, __x)
#define atomic_fence(__a, __x) \
({ _ATOMIC_FENCE_(__a, __x); })
#define atomic_fetch_add_explicit(__a, __m, __x) \
_ATOMIC_MODIFY_(__a, +=, __m, __x)
#define atomic_fetch_add(__a, __m) \
_ATOMIC_MODIFY_(__a, +=, __m, memory_order_seq_cst)
#define atomic_fetch_sub_explicit(__a, __m, __x) \
_ATOMIC_MODIFY_(__a, -=, __m, __x)
#define atomic_fetch_sub(__a, __m) \
_ATOMIC_MODIFY_(__a, -=, __m, memory_order_seq_cst)
#define atomic_fetch_and_explicit(__a, __m, __x) \
_ATOMIC_MODIFY_(__a, &=, __m, __x)
#define atomic_fetch_and(__a, __m) \
_ATOMIC_MODIFY_(__a, &=, __m, memory_order_seq_cst)
#define atomic_fetch_or_explicit(__a, __m, __x) \
_ATOMIC_MODIFY_(__a, |=, __m, __x)
#define atomic_fetch_or(__a, __m) \
_ATOMIC_MODIFY_(__a, |=, __m, memory_order_seq_cst)
#define atomic_fetch_xor_explicit(__a, __m, __x) \
_ATOMIC_MODIFY_(__a, ^=, __m, __x)
#define atomic_fetch_xor(__a, __m) \
_ATOMIC_MODIFY_(__a, ^=, __m, memory_order_seq_cst)
#endif #endif
// Typedefs for other atomic integral types. // Typedefs for other atomic integral types.
@ -272,42 +117,31 @@ extern "C++"
typedef atomic_long atomic_ptrdiff_t; typedef atomic_long atomic_ptrdiff_t;
typedef atomic_int_least16_t atomic_char16_t; // Accessor functions for base atomic_flag type.
typedef atomic_int_least32_t atomic_char32_t; bool
atomic_flag_test_and_set_explicit(volatile __atomic_flag_base*, memory_order);
// Accessor functions for atomic_flag. inline bool
extern bool atomic_flag_test_and_set(volatile __atomic_flag_base* __a)
atomic_flag_test_and_set(volatile atomic_flag*); { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
extern bool void
atomic_flag_test_and_set_explicit(volatile atomic_flag*, memory_order); atomic_flag_clear_explicit(volatile __atomic_flag_base*, memory_order);
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);
extern void volatile __atomic_flag_base*
atomic_flag_clear(volatile atomic_flag*);
extern void
atomic_flag_clear_explicit(volatile atomic_flag*, memory_order);
extern void
atomic_flag_fence(const volatile atomic_flag*, memory_order);
extern void
__atomic_flag_wait_explicit(volatile atomic_flag*, memory_order);
extern volatile atomic_flag*
__atomic_flag_for_address(const volatile void* __z) __attribute__((const)); __atomic_flag_for_address(const volatile void* __z) __attribute__((const));
// External object.
extern const atomic_flag atomic_global_fence_compatibility;
/// 29.2 Lock-free Property
#define ATOMIC_INTEGRAL_LOCK_FREE 0
#define ATOMIC_ADDRESS_LOCK_FREE 0
// Implementation specific defines. // Implementation specific defines.
#define _ATOMIC_LOAD_(__a, __x) \ #define _ATOMIC_LOAD_(__a, __x) \
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \ ({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
volatile atomic_flag* __g = __atomic_flag_for_address(__p); \ volatile atomic_flag* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \ __atomic_flag_wait_explicit(__g, __x); \
__typeof__ _ATOMIC_MEMBER_ __r = *__p; \ __typeof__ _ATOMIC_MEMBER_ __r = *__p; \
atomic_flag_clear_explicit(__g, __x); \ atomic_flag_clear_explicit(__g, __x); \
@ -332,7 +166,7 @@ extern "C++"
atomic_flag_clear_explicit(__g, __x); \ atomic_flag_clear_explicit(__g, __x); \
__r; }) __r; })
#define _ATOMIC_CMPSWP_(__a, __e, __m, __x) \ #define _ATOMIC_CMPEXCHNG_(__a, __e, __m, __x) \
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \ ({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
__typeof__(__e) __q = (__e); \ __typeof__(__e) __q = (__e); \
__typeof__(__m) __v = (__m); \ __typeof__(__m) __v = (__m); \
@ -345,26 +179,19 @@ extern "C++"
atomic_flag_clear_explicit(__g, __x); \ atomic_flag_clear_explicit(__g, __x); \
__r; }) __r; })
#define _ATOMIC_FENCE_(__a, __x) \
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
volatile atomic_flag* __g = __atomic_flag_for_address(__p); \
atomic_flag_fence(__g, __x); \
})
_GLIBCXX_END_EXTERN_C _GLIBCXX_END_EXTERN_C
_GLIBCXX_END_NAMESPACE _GLIBCXX_END_NAMESPACE
#ifdef __cplusplus // Inject into global namespace. XXX
// Inject into global namespace iff C++. #if defined(__cplusplus) && !defined(_GLIBCXX_STDATOMIC)
using std::memory_order; using std::memory_order;
using std::memory_order_relaxed; using std::memory_order_relaxed;
using std::memory_order_consume;
using std::memory_order_acquire; using std::memory_order_acquire;
using std::memory_order_release; using std::memory_order_release;
using std::memory_order_acq_rel; using std::memory_order_acq_rel;
using std::memory_order_seq_cst; using std::memory_order_seq_cst;
using std::atomic_flag; using std::atomic_flag;
using std::atomic_bool; using std::atomic_bool;
using std::atomic_char; using std::atomic_char;
using std::atomic_schar; using std::atomic_schar;
@ -378,10 +205,10 @@ using std::atomic_ulong;
using std::atomic_llong; using std::atomic_llong;
using std::atomic_ullong; using std::atomic_ullong;
using std::atomic_wchar_t; using std::atomic_wchar_t;
using std::atomic_char16_t;
using std::atomic_char32_t;
using std::atomic_address; using std::atomic_address;
using std::atomic; using std::atomic;
#endif #endif
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -30,12 +30,17 @@
#include "gstdint.h" #include "gstdint.h"
#include <cstdatomic> #include <cstdatomic>
#include <mutex>
#define LOGSIZE 4 #define LOGSIZE 4
namespace namespace
{ {
atomic_flag volatile __atomic_flag_anon_table__[ 1 << LOGSIZE ] = #ifdef _GLIBCXX_HAS_GTHREADS
std::mutex atomic_mutex;
#endif
std::__atomic_flag_base volatile 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,
ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT,
@ -46,73 +51,66 @@ namespace
namespace std namespace std
{ {
extern "C" { namespace __atomic0
const atomic_flag atomic_global_fence_compatibility = ATOMIC_FLAG_INIT;
bool
atomic_flag_test_and_set_explicit(volatile atomic_flag* __a,
memory_order __x
__attribute__ ((__unused__)))
{ {
#ifdef _GLIBCXX_ATOMIC_BUILTINS_1 bool
if (__x >= memory_order_acq_rel) atomic_flag::test_and_set(memory_order) volatile
__sync_synchronize(); {
return __sync_lock_test_and_set(&(__a->_M_base._M_b), 1); #ifdef _GLIBCXX_HAS_GTHREADS
#else lock_guard<mutex> __lock(atomic_mutex);
bool result = __a->_M_base._M_b;
__a->_M_base._M_b = true;
return result;
#endif #endif
bool result = _M_i;
_M_i = true;
return result;
}
void
atomic_flag::clear(memory_order) volatile
{
#ifdef _GLIBCXX_HAS_GTHREADS
lock_guard<mutex> __lock(atomic_mutex);
#endif
_M_i = false;
}
} }
bool extern "C"
atomic_flag_test_and_set(volatile atomic_flag* __a)
{ return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
void
atomic_flag_clear_explicit(volatile atomic_flag* __a,
memory_order __x __attribute__ ((__unused__)))
{ {
#ifdef _GLIBCXX_ATOMIC_BUILTINS_1 bool
__sync_lock_release(&(__a->_M_base._M_b)); atomic_flag_test_and_set_explicit(volatile __atomic_flag_base* __a,
if (__x >= memory_order_acq_rel) memory_order __m)
__sync_synchronize(); {
#else volatile atomic_flag d(__a->_M_i);
__a->_M_base._M_b = false; return d.test_and_set(__m);
#endif }
}
void void
atomic_flag_clear(volatile atomic_flag* __a) atomic_flag_clear_explicit(volatile __atomic_flag_base* __a,
{ atomic_flag_clear_explicit(__a, memory_order_seq_cst); } memory_order __m)
{
void volatile atomic_flag d(__a->_M_i);
atomic_flag_fence(const volatile atomic_flag*, memory_order) return d.clear(__m);
{ }
#ifdef _GLIBCXX_ATOMIC_BUILTINS_1
__sync_synchronize();
#endif
}
void void
__atomic_flag_wait_explicit(volatile atomic_flag* __a, memory_order __x) __atomic_flag_wait_explicit(volatile __atomic_flag_base* __a,
{ memory_order __x)
while (atomic_flag_test_and_set_explicit(__a, __x)) {
{ }; while (atomic_flag_test_and_set_explicit(__a, __x))
} { };
}
volatile atomic_flag*
__atomic_flag_for_address(const volatile void* __z)
{
uintptr_t __u = reinterpret_cast<uintptr_t>(__z);
__u += (__u >> 2) + (__u << 4);
__u += (__u >> 7) + (__u << 5);
__u += (__u >> 17) + (__u << 13);
if (sizeof(uintptr_t) > 4) __u += (__u >> 31);
__u &= ~((~uintptr_t(0)) << LOGSIZE);
return __atomic_flag_anon_table__ + __u;
}
volatile __atomic_flag_base*
__atomic_flag_for_address(const volatile void* __z)
{
uintptr_t __u = reinterpret_cast<uintptr_t>(__z);
__u += (__u >> 2) + (__u << 4);
__u += (__u >> 7) + (__u << 5);
__u += (__u >> 17) + (__u << 13);
if (sizeof(uintptr_t) > 4)
__u += (__u >> 31);
__u &= ~((~uintptr_t(0)) << LOGSIZE);
return flag_table + __u;
}
} // extern "C" } // extern "C"
} // namespace std } // namespace std

View File

@ -1,7 +1,7 @@
// { dg-do compile } // { dg-do compile }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2004 Free Software Foundation, Inc. // Copyright (C) 2004, 2008 Free Software Foundation, Inc.
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
@ -31,7 +31,7 @@
// Benjamin Kosnik <bkoz@redhat.com> // Benjamin Kosnik <bkoz@redhat.com>
#include <ios> #include <ios>
#include <testsuite_hooks.h> #include <testsuite_common_types.h>
int main() int main()
{ {

View File

@ -1,7 +1,7 @@
// { dg-do compile } // { dg-do compile }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2004 Free Software Foundation, Inc. // Copyright (C) 2004, 2008 Free Software Foundation, Inc.
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
@ -31,7 +31,7 @@
// Benjamin Kosnik <bkoz@redhat.com> // Benjamin Kosnik <bkoz@redhat.com>
#include <ios> #include <ios>
#include <testsuite_hooks.h> #include <testsuite_common_types.h>
int main() int main()
{ {

View File

@ -1,7 +1,7 @@
// { dg-do compile } // { dg-do compile }
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2004 Free Software Foundation, Inc. // Copyright (C) 2004, 2008 Free Software Foundation, Inc.
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
@ -31,7 +31,7 @@
// Benjamin Kosnik <bkoz@redhat.com> // Benjamin Kosnik <bkoz@redhat.com>
#include <ios> #include <ios>
#include <testsuite_hooks.h> #include <testsuite_common_types.h>
int main() int main()
{ {

View File

@ -38,18 +38,20 @@ int main()
return 0; return 0;
} }
// { dg-error "within this context" "" { target *-*-* } 310 } // { dg-error "used here" "" { target *-*-* } 510 }
// { dg-error "is private" "" { target *-*-* } 1750 } // { dg-error "deleted function" "" { target *-*-* } 257 }
// { dg-error "is private" "" { target *-*-* } 1782 } // { dg-error "deleted function" "" { target *-*-* } 275 }
// { dg-error "is private" "" { target *-*-* } 1799 } // { dg-error "deleted function" "" { target *-*-* } 293 }
// { dg-error "is private" "" { target *-*-* } 1816 } // { dg-error "deleted function" "" { target *-*-* } 311 }
// { dg-error "is private" "" { target *-*-* } 1832 } // { dg-error "deleted function" "" { target *-*-* } 329 }
// { dg-error "is private" "" { target *-*-* } 1848 } // { dg-error "deleted function" "" { target *-*-* } 347 }
// { dg-error "is private" "" { target *-*-* } 1864 } // { dg-error "deleted function" "" { target *-*-* } 365 }
// { dg-error "is private" "" { target *-*-* } 1880 } // { dg-error "deleted function" "" { target *-*-* } 383 }
// { dg-error "is private" "" { target *-*-* } 1896 } // { dg-error "deleted function" "" { target *-*-* } 401 }
// { dg-error "is private" "" { target *-*-* } 1913 } // { dg-error "deleted function" "" { target *-*-* } 419 }
// { dg-error "is private" "" { target *-*-* } 1929 } // { dg-error "deleted function" "" { target *-*-* } 437 }
// { dg-error "is private" "" { target *-*-* } 1945 } // { dg-error "deleted function" "" { target *-*-* } 455 }
// { dg-error "is private" "" { target *-*-* } 1961 } // { dg-error "deleted function" "" { target *-*-* } 473 }
// { dg-error "deleted function" "" { target *-*-* } 491 }
// { dg-error "deleted function" "" { target *-*-* } 239 }
// { dg-excess-errors "In member function" } // { dg-excess-errors "In member function" }

View File

@ -32,7 +32,7 @@
int main() int main()
{ {
__gnu_test::explicit_value_constructible test; __gnu_test::copy_list_initializable test;
__gnu_cxx::typelist::apply_generator(test, __gnu_test::atomics_tl(), __gnu_cxx::typelist::apply_generator(test, __gnu_test::atomics_tl(),
__gnu_test::integral_types::type()); __gnu_test::integral_types::type());
return 0; return 0;

View File

@ -38,18 +38,20 @@ int main()
return 0; return 0;
} }
// { dg-error "within this context" "" { target *-*-* } 349 } // { dg-error "used here" "" { target *-*-* } 549 }
// { dg-error "is private" "" { target *-*-* } 1749 } // { dg-error "deleted function" "" { target *-*-* } 238 }
// { dg-error "is private" "" { target *-*-* } 1781 } // { dg-error "deleted function" "" { target *-*-* } 256 }
// { dg-error "is private" "" { target *-*-* } 1798 } // { dg-error "deleted function" "" { target *-*-* } 274 }
// { dg-error "is private" "" { target *-*-* } 1814 } // { dg-error "deleted function" "" { target *-*-* } 292 }
// { dg-error "is private" "" { target *-*-* } 1831 } // { dg-error "deleted function" "" { target *-*-* } 310 }
// { dg-error "is private" "" { target *-*-* } 1847 } // { dg-error "deleted function" "" { target *-*-* } 328 }
// { dg-error "is private" "" { target *-*-* } 1863 } // { dg-error "deleted function" "" { target *-*-* } 346 }
// { dg-error "is private" "" { target *-*-* } 1879 } // { dg-error "deleted function" "" { target *-*-* } 364 }
// { dg-error "is private" "" { target *-*-* } 1895 } // { dg-error "deleted function" "" { target *-*-* } 382 }
// { dg-error "is private" "" { target *-*-* } 1912 } // { dg-error "deleted function" "" { target *-*-* } 400 }
// { dg-error "is private" "" { target *-*-* } 1928 } // { dg-error "deleted function" "" { target *-*-* } 418 }
// { dg-error "is private" "" { target *-*-* } 1944 } // { dg-error "deleted function" "" { target *-*-* } 436 }
// { dg-error "is private" "" { target *-*-* } 1960 } // { dg-error "deleted function" "" { target *-*-* } 454 }
// { dg-error "deleted function" "" { target *-*-* } 472 }
// { dg-error "deleted function" "" { target *-*-* } 490 }
// { dg-excess-errors "In member function" } // { dg-excess-errors "In member function" }

View File

@ -0,0 +1,39 @@
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::direct_list_initializable test;
__gnu_cxx::typelist::apply_generator(test, __gnu_test::atomics_tl(),
__gnu_test::integral_types::type());
return 0;
}

View File

@ -0,0 +1,39 @@
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::single_value_constructible test;
__gnu_cxx::typelist::apply_generator(test, __gnu_test::atomics_tl(),
__gnu_test::integral_types::type());
return 0;
}

View File

@ -0,0 +1,40 @@
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <cstdatomic>
#include <testsuite_hooks.h>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::integral_assignable test;
__gnu_cxx::typelist::apply_generator(test, __gnu_test::atomics_tl(),
__gnu_test::integral_types::type());
return 0;
}

View File

@ -0,0 +1,40 @@
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <cstdatomic>
#include <testsuite_hooks.h>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::integral_convertable test;
__gnu_cxx::typelist::apply_generator(test, __gnu_test::atomics_tl(),
__gnu_test::integral_types::type());
return 0;
}

View File

@ -0,0 +1,32 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// Copyright (C) 2008 Free Software Foundation
//
// 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <cstdatomic>
#include <testsuite_common_types.h>
void test01()
{
// Check for required base class.
__gnu_test::has_required_base_class test;
__gnu_cxx::typelist::apply_generator(test,
__gnu_test::atomic_integrals::type(),
__gnu_test::atomics_tl());
}

View File

@ -0,0 +1,31 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2008-10-22 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <cstdatomic>
#include <testsuite_common_types.h>
void test01()
{
// Check for standard layout requirements
__gnu_test::standard_layout test;
__gnu_cxx::typelist::apply_generator(test, __gnu_test::atomics_tl());
}

View File

@ -38,5 +38,5 @@ void test01()
test_type t2; test_type t2;
t1 = t2; t1 = t2;
} }
// { dg-error "within this context" "" { target *-*-* } 39 } // { dg-error "used here" "" { target *-*-* } 39 }
// { dg-error "is private" "" { target *-*-* } 167 } // { dg-excess-errors "deleted function" }

View File

@ -37,5 +37,5 @@ void test01()
test_type t1; test_type t1;
test_type t2(t1); test_type t2(t1);
} }
// { dg-error "within this context" "" { target *-*-* } 38 } // { dg-error "used here" "" { target *-*-* } 38 }
// { dg-error "is private" "" { target *-*-* } 166 } // { dg-excess-errors "deleted function" }

View File

@ -31,7 +31,7 @@
int main() int main()
{ {
// Explicit value constructor. // Single value constructor.
void* v = NULL; void* v = NULL;
std::atomic_address a(v); std::atomic_address a(v);
return 0; return 0;

View File

@ -38,5 +38,5 @@ void test01()
test_type t2; test_type t2;
t1 = t2; t1 = t2;
} }
// { dg-error "within this context" "" { xfail *-*-* } 39 } // { dg-error "used here" "" { target *-*-* } 39 }
// { dg-error "is private" "" { xfail *-*-* } 89 } // { dg-excess-errors "deleted function" }

View File

@ -37,5 +37,5 @@ void test01()
test_type t1; test_type t1;
test_type t2(t1); test_type t2(t1);
} }
// { dg-error "within this context" "" { xfail *-*-* } 38 } // { dg-error "used here" "" { target *-*-* } 38 }
// { dg-error "is private" "" { xfail *-*-* } 88 } // { dg-excess-errors "deleted function" }

View File

@ -36,6 +36,10 @@ int main()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
typedef std::atomic_flag test_type; typedef std::atomic_flag test_type;
// libstdc++/37907
// VERIFY( std::is_standard_layout<test_type>::value );
VERIFY( std::has_trivial_default_constructor<test_type>::value ); VERIFY( std::has_trivial_default_constructor<test_type>::value );
VERIFY( std::has_trivial_destructor<test_type>::value ); VERIFY( std::has_trivial_destructor<test_type>::value );

View File

@ -0,0 +1,50 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::assignable test;
__gnu_cxx::typelist::apply_generator(test,
__gnu_test::atomic_integrals::type());
return 0;
}
// { dg-error "used here" "" { target *-*-* } 510 }
// { dg-excess-errors "deleted function" }
// { dg-excess-errors "deleted function" }
// { dg-error "instantiated from" "" { target *-*-* } 38 }
// { dg-error "instantiated from" "" { target *-*-* } 517 }
// { dg-error "instantiated from" "" { target *-*-* } 173 }
// { dg-error "instantiated from" "" { target *-*-* } 404 }
// { dg-error "instantiated from" "" { target *-*-* } 175 }
// { dg-excess-errors "In member function" }

View File

@ -0,0 +1,40 @@
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::copy_list_initializable test;
__gnu_cxx::typelist::apply_generator(test,
__gnu_test::atomic_integrals::type(),
__gnu_test::integral_types::type());
return 0;
}

View File

@ -0,0 +1,50 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::copy_constructible test;
__gnu_cxx::typelist::apply_generator(test,
__gnu_test::atomic_integrals::type());
return 0;
}
// { dg-error "used here" "" { target *-*-* } 549 }
// { dg-excess-errors "deleted function" }
// { dg-excess-errors "deleted function" }
// { dg-error "instantiated from" "" { target *-*-* } 38 }
// { dg-error "instantiated from" "" { target *-*-* } 555 }
// { dg-error "instantiated from" "" { target *-*-* } 173 }
// { dg-error "instantiated from" "" { target *-*-* } 404 }
// { dg-error "instantiated from" "" { target *-*-* } 175 }
// { dg-excess-errors "In member function" }

View File

@ -28,12 +28,12 @@
// the GNU General Public License. // the GNU General Public License.
#include <cstdatomic> #include <cstdatomic>
#include <testsuite_common_types.h>
int main() int main()
{ {
using namespace std; __gnu_test::default_constructible test;
atomic_flag_fence(&atomic_global_fence_compatibility, memory_order_acquire); __gnu_cxx::typelist::apply_generator(test,
atomic_global_fence_compatibility.fence(memory_order_release); __gnu_test::atomic_integrals::type());
return 0; return 0;
} }

View File

@ -0,0 +1,40 @@
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::direct_list_initializable test;
__gnu_cxx::typelist::apply_generator(test,
__gnu_test::atomic_integrals::type(),
__gnu_test::integral_types::type());
return 0;
}

View File

@ -0,0 +1,40 @@
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::single_value_constructible test;
__gnu_cxx::typelist::apply_generator(test,
__gnu_test::atomic_integrals::type(),
__gnu_test::integral_types::type());
return 0;
}

View File

@ -0,0 +1,40 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// -*- C++ -*-
// Copyright (C) 2008 Free Software Foundation, Inc.
// 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 2, 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 COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::has_bitwise_operators test;
using __gnu_test::atomic_integrals_no_bool;
__gnu_cxx::typelist::apply_generator(test, atomic_integrals_no_bool::type());
};

View File

@ -0,0 +1,44 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// -*- C++ -*-
// Copyright (C) 2008 Free Software Foundation, Inc.
// 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 2, 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 COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::bitwise_assignment_operators<std::atomic_bool>();
return 0;
}
// { dg-error "operator" "" { target *-*-* } 413 }
// { dg-error "operator" "" { target *-*-* } 414 }
// { dg-error "operator" "" { target *-*-* } 415 }
// { dg-excess-errors "In file included from" }

View File

@ -0,0 +1,40 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// -*- C++ -*-
// Copyright (C) 2008 Free Software Foundation, Inc.
// 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 2, 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 COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::has_decrement_operators test;
using __gnu_test::atomic_integrals_no_bool;
__gnu_cxx::typelist::apply_generator(test, atomic_integrals_no_bool::type());
};

View File

@ -0,0 +1,45 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// -*- C++ -*-
// Copyright (C) 2008 Free Software Foundation, Inc.
// 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 2, 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 COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::has_decrement_operators test;
test.operator()<std::atomic_bool>();
return 0;
}
// { dg-error "operator" "" { target *-*-* } 384 }
// { dg-error "operator" "" { target *-*-* } 385 }
// { dg-error "operator" "" { target *-*-* } 386 }
// { dg-excess-errors "In file included from" }

View File

@ -0,0 +1,40 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// -*- C++ -*-
// Copyright (C) 2008 Free Software Foundation, Inc.
// 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 2, 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 COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::has_increment_operators test;
using __gnu_test::atomic_integrals_no_bool;
__gnu_cxx::typelist::apply_generator(test, atomic_integrals_no_bool::type());
};

View File

@ -0,0 +1,45 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// -*- C++ -*-
// Copyright (C) 2008 Free Software Foundation, Inc.
// 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 2, 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 COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#include <cstdatomic>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::has_increment_operators test;
test.operator()<std::atomic_bool>();
return 0;
}
// { dg-error "operator" "" { target *-*-* } 362 }
// { dg-error "operator" "" { target *-*-* } 363 }
// { dg-error "operator" "" { target *-*-* } 364 }
// { dg-excess-errors "In file included from" }

View File

@ -0,0 +1,41 @@
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <cstdatomic>
#include <testsuite_hooks.h>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::integral_assignable test;
__gnu_cxx::typelist::apply_generator(test,
__gnu_test::atomic_integrals::type(),
__gnu_test::integral_types::type());
return 0;
}

View File

@ -0,0 +1,41 @@
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <cstdatomic>
#include <testsuite_hooks.h>
#include <testsuite_common_types.h>
int main()
{
__gnu_test::integral_convertable test;
__gnu_cxx::typelist::apply_generator(test,
__gnu_test::atomic_integrals::type(),
__gnu_test::integral_types::type());
return 0;
}

View File

@ -0,0 +1,32 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2008-10-22 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <cstdatomic>
#include <testsuite_common_types.h>
void test01()
{
// Check for standard layout requirements
__gnu_test::standard_layout test;
__gnu_cxx::typelist::apply_generator(test,
__gnu_test::atomic_integrals::type());
}

View File

@ -27,9 +27,8 @@ namespace gnu
using std::atomic_flag_test_and_set_explicit; using std::atomic_flag_test_and_set_explicit;
using std::atomic_flag_clear; using std::atomic_flag_clear;
using std::atomic_flag_clear_explicit; using std::atomic_flag_clear_explicit;
using std::atomic_flag_fence;
using std::atomic_global_fence_compatibility; using std::kill_dependency;
// Sloppy testing for integral types (en masse). // Sloppy testing for integral types (en masse).
using std::atomic_is_lock_free; using std::atomic_is_lock_free;
@ -37,11 +36,12 @@ namespace gnu
using std::atomic_store_explicit; using std::atomic_store_explicit;
using std::atomic_load; using std::atomic_load;
using std::atomic_load_explicit; using std::atomic_load_explicit;
using std::atomic_swap; using std::atomic_exchange;
using std::atomic_swap_explicit; using std::atomic_exchange_explicit;
using std::atomic_compare_swap; using std::atomic_compare_exchange_weak;
using std::atomic_compare_swap_explicit; using std::atomic_compare_exchange_strong;
using std::atomic_fence; using std::atomic_compare_exchange_weak_explicit;
using std::atomic_compare_exchange_strong_explicit;
using std::atomic_fetch_add; using std::atomic_fetch_add;
using std::atomic_fetch_add_explicit; using std::atomic_fetch_add_explicit;

View File

@ -24,11 +24,20 @@
namespace gnu namespace gnu
{ {
#ifndef ATOMIC_INTEGRAL_LOCK_FREE #ifndef ATOMIC_INTEGRAL_LOCK_FREE
#error "ATOMIC_INTEGRAL_LOCK_FREE_must_be_a_macro" # error "ATOMIC_INTEGRAL_LOCK_FREE must be a macro"
#else
# if ATOMIC_INTEGRAL_LOCK_FREE != 0 \
&& ATOMIC_INTEGRAL_LOCK_FREE != 1 && ATOMIC_INTEGRAL_LOCK_FREE != 2
# error "ATOMIC_INTEGRAL_LOCK_FREE must be 0, 1, or 2"
# endif
#endif #endif
#ifndef ATOMIC_ADDRESS_LOCK_FREE #ifndef ATOMIC_ADDRESS_LOCK_FREE
#error "ATOMIC_ADDRESS_LOCK_FREE_must_be_a_macro" # error "ATOMIC_ADDRESS_LOCK_FREE must be a macro"
# if ATOMIC_INTEGRAL_LOCK_FREE != 0 \
&& ATOMIC_INTEGRAL_LOCK_FREE != 1 && ATOMIC_INTEGRAL_LOCK_FREE != 2
# error "ATOMIC_INTEGRAL_LOCK_FREE must be 0, 1, or 2"
# endif
#endif #endif
#ifndef ATOMIC_FLAG_INIT #ifndef ATOMIC_FLAG_INIT

View File

@ -25,6 +25,7 @@ void test01()
{ {
using std::memory_order; using std::memory_order;
using std::memory_order_relaxed; using std::memory_order_relaxed;
using std::memory_order_consume;
using std::memory_order_acquire; using std::memory_order_acquire;
using std::memory_order_release; using std::memory_order_release;
using std::memory_order_acq_rel; using std::memory_order_acq_rel;
@ -75,7 +76,4 @@ void test01()
using std::atomic_uintmax_t; using std::atomic_uintmax_t;
using std::atomic_address; using std::atomic_address;
const std::atomic_flag* p __attribute__((unused))
= &std::atomic_global_fence_compatibility;
} }

View File

@ -55,24 +55,20 @@ int main()
#error "atomic_store_must_be_a_macro" #error "atomic_store_must_be_a_macro"
#endif #endif
#ifndef atomic_swap_explicit #ifndef atomic_exchange_explicit
#error "atomic_swap_explicit_must_be_a_macro" #error "atomic_exchange_explicit_must_be_a_macro"
#endif #endif
#ifndef atomic_swap #ifndef atomic_exchange
#error "atomic_swap_must_be_a_macro" #error "atomic_exchange_must_be_a_macro"
#endif #endif
#ifndef atomic_compare_swap #ifndef atomic_compare_exchange
#error "atomic_compare_swap_must_be_a_macro" #error "atomic_compare_exchange_must_be_a_macro"
#endif #endif
#ifndef atomic_compare_swap_explicit #ifndef atomic_compare_exchange_explicit
#error "atomic_compare_swap_explicit_must_be_a_macro" #error "atomic_compare_exchange_explicit_must_be_a_macro"
#endif
#ifndef atomic_fence
#error "atomic_fence_must_be_a_macro"
#endif #endif
#ifndef atomic_fetch_add_explicit #ifndef atomic_fetch_add_explicit

View File

@ -75,7 +75,4 @@ void test01()
typedef atomic_uintmax_t t_45; typedef atomic_uintmax_t t_45;
typedef atomic_address t_46; typedef atomic_address t_46;
const atomic_flag* p __attribute__((unused))
= &atomic_global_fence_compatibility;
} }

View File

@ -54,6 +54,7 @@
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdatomic> #include <cstdatomic>
#include <type_traits>
#endif #endif
namespace __gnu_test namespace __gnu_test
@ -279,14 +280,63 @@ namespace __gnu_test
typedef long long a11; typedef long long a11;
typedef unsigned long long a12; typedef unsigned long long a12;
typedef wchar_t a13; typedef wchar_t a13;
// typedef char16_t a14; #ifdef __GXX_EXPERIMENTAL_CXX0X__
// typedef char16_t a15; typedef char16_t a14;
typedef char32_t a15;
typedef node<_GLIBCXX_TYPELIST_CHAIN15(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)> type;
#else
typedef node<_GLIBCXX_TYPELIST_CHAIN13(a1, a2, a3, a4, a5, a6, a7, a8, a9, typedef node<_GLIBCXX_TYPELIST_CHAIN13(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13)> type; a10, a11, a12, a13)> type;
#endif
}; };
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
struct atomic_integrals_no_bool
{
typedef std::atomic_char a2;
typedef std::atomic_schar a3;
typedef std::atomic_uchar a4;
typedef std::atomic_short a5;
typedef std::atomic_ushort a6;
typedef std::atomic_int a7;
typedef std::atomic_uint a8;
typedef std::atomic_long a9;
typedef std::atomic_ulong a10;
typedef std::atomic_llong a11;
typedef std::atomic_ullong a12;
typedef std::atomic_wchar_t a13;
typedef std::atomic_char16_t a14;
typedef std::atomic_char32_t a15;
typedef node<_GLIBCXX_TYPELIST_CHAIN14(a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)> type;
};
struct atomic_integrals
{
typedef std::atomic_bool a1;
typedef std::atomic_char a2;
typedef std::atomic_schar a3;
typedef std::atomic_uchar a4;
typedef std::atomic_short a5;
typedef std::atomic_ushort a6;
typedef std::atomic_int a7;
typedef std::atomic_uint a8;
typedef std::atomic_long a9;
typedef std::atomic_ulong a10;
typedef std::atomic_llong a11;
typedef std::atomic_ullong a12;
typedef std::atomic_wchar_t a13;
typedef std::atomic_char16_t a14;
typedef std::atomic_char32_t a15;
typedef node<_GLIBCXX_TYPELIST_CHAIN15(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)> type;
};
template<typename Tp> template<typename Tp>
struct atomics struct atomics
{ {
@ -297,6 +347,156 @@ namespace __gnu_test
typedef transform<integral_types::type, atomics>::type atomics_tl; typedef transform<integral_types::type, atomics>::type atomics_tl;
#endif #endif
struct has_increment_operators
{
template<typename _Tp>
void
operator()()
{
struct _Concept
{
void __constraint()
{
_Tp a;
++a; // prefix
a++; // postfix
a += a;
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
struct has_decrement_operators
{
template<typename _Tp>
void
operator()()
{
struct _Concept
{
void __constraint()
{
_Tp a;
--a; // prefix
a--; // postfix
a -= a;
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
template<typename _Tp>
void
bitwise_operators()
{
_Tp a;
_Tp b;
a | b;
a & b;
a ^ b;
~b;
}
template<typename _Tp>
void
bitwise_assignment_operators()
{
_Tp a;
_Tp b;
a |= b; // set
a &= ~b; // clear
a ^= b;
}
// 17.3.2.1.2 - Bitmask types [lib.bitmask.types]
// bitmask_operators
template<typename _BitmTp>
void
bitmask_operators()
{
bitwise_operators<_BitmTp>();
bitwise_assignment_operators<_BitmTp>();
}
struct has_bitwise_operators
{
template<typename _Tp>
void
operator()()
{
struct _Concept
{
void __constraint()
{
bitwise_assignment_operators<_Tp>();
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
// Generator to test standard layout
#ifdef __GXX_EXPERIMENTAL_CXX0X__
struct standard_layout
{
template<typename _Tp>
void
operator()()
{
struct _Concept
{
void __constraint()
{
// libstdc++/37907
// typedef std::is_standard_layout<_Tp> standard_layout_p;
// static_assert(standard_layout_p::value, "not standard_layout");
typedef std::has_trivial_default_constructor<_Tp> ctor_p;
static_assert(ctor_p::value, "default ctor not trivial");
typedef std::has_trivial_destructor<_Tp> dtor_p;
static_assert(dtor_p::value, "dtor not trivial");
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
#endif
// Generator to test base class
struct has_required_base_class
{
template<typename _TBase, typename _TDerived>
void
operator()()
{
struct _Concept
{
void __constraint()
{
const _TDerived& obj = __a;
const _TBase* base __attribute__((unused)) = &obj;
}
_TDerived __a;
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
// Generator to test assignment operator. // Generator to test assignment operator.
struct assignable struct assignable
{ {
@ -356,8 +556,8 @@ namespace __gnu_test
} }
}; };
// Generator to test explicit value constructor. // Generator to test direct initialization, single value constructor.
struct explicit_value_constructible struct single_value_constructible
{ {
template<typename _Ttype, typename _Tvalue> template<typename _Ttype, typename _Tvalue>
void void
@ -376,5 +576,102 @@ namespace __gnu_test
} }
}; };
// Generator to test direct list initialization
#ifdef __GXX_EXPERIMENTAL_CXX0X__
struct direct_list_initializable
{
template<typename _Ttype, typename _Tvalue>
void
operator()()
{
struct _Concept
{
void __constraint()
{
_Ttype __v1 { }; // default ctor
_Ttype __v2 { __a }; // single-argument ctor
}
_Tvalue __a;
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
#endif
// Generator to test copy list initialization, aggregate initialization
struct copy_list_initializable
{
template<typename _Ttype, typename _Tvalue>
void
operator()()
{
struct _Concept
{
void __constraint()
{ _Ttype __v = {__a}; }
_Tvalue __a;
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
// Generator to test integral conversion operator
struct integral_convertable
{
template<typename _Ttype, typename _Tvalue>
void
operator()()
{
struct _Concept
{
void __constraint()
{
_Tvalue __v0(0);
_Tvalue __v1(1);
_Ttype __a(__v1);
__v0 = __a;
bool test __attribute__((unused)) = true;
VERIFY( __v1 == __v0 );
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
// Generator to test integral assignment operator
struct integral_assignable
{
template<typename _Ttype, typename _Tvalue>
void
operator()()
{
struct _Concept
{
void __constraint()
{
_Tvalue __v0(0);
_Tvalue __v1(1);
_Ttype __a(__v0);
__a = __v1;
_Tvalue __vr = __a;
bool test __attribute__((unused)) = true;
VERIFY( __v1 == __vr );
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
} // namespace __gnu_test } // namespace __gnu_test
#endif #endif

View File

@ -1,7 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// Utility subroutines for the C++ library testsuite. // Utility subroutines for the C++ library testsuite.
// //
// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
@ -100,22 +100,6 @@ namespace __gnu_test
void void
verify_demangle(const char* mangled, const char* wanted); verify_demangle(const char* mangled, const char* wanted);
// 17.3.2.1.2 - Bitmask types [lib.bitmask.types]
// bitmask_operators
template<typename bitmask_type>
void
bitmask_operators(bitmask_type a = bitmask_type(),
bitmask_type b = bitmask_type())
{
a | b;
a & b;
a ^ b;
~b;
a |= b; // set
a &= ~b; // clear
a ^= b;
}
// Simple callback structure for variable numbers of tests (all with // Simple callback structure for variable numbers of tests (all with
// same signature). Assume all unit tests are of the signature // same signature). Assume all unit tests are of the signature
// void test01(); // void test01();