summaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-10 20:26:45 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-10 20:26:45 +0000
commit857d9b7bdf139c12a8bf7483f712f59cf047c698 (patch)
treedc0bf9fb108791fffd3d1c8bee85cb81446f702c /libstdc++-v3/src
parent8965c2646dd063b1468e923de148bbcc90ae3a93 (diff)
downloadgcc-857d9b7bdf139c12a8bf7483f712f59cf047c698.tar.gz
2008-04-10 Benjamin Kosnik <bkoz@redhat.com>
* include/c_global/cstdatomic: C++ types only, format, doxygen markup. * include/c_compatibility/stdatomic.h: "C" only, format, doxygen markup. * src/atomic.c: Format, doxygen markup, edits. * include/Makefile.am (cstdatomic, stdatomic.h): Add. * src/Makefile.am (atomic.c): Add. * acinclude.m4 (GLIBCXX_CHECK_STANDARD_LAYOUT): New. * configure.ac: Call it. * include/Makefile.in: Regenerate. * src/Makefile.in: Same. * Makefile.in: Same. * doc/Makefile.in: Same. * po/Makefile.in: Same. * libmath/Makefile.in: Same. * include/Makefile.in: Same. * testsuite/Makefile.in: Same. * libsupc++/Makefile.in: Same. * config.h.in: Same. * configure: Same. * config/abi/pre/gnu.ver: Add atomics exports. * include/ext/typelist.h (apply_generator): New. * include/bits/c++config (_GLIBCXX_BEGIN_EXTERN_C): New. (_GLIBCXX_END_EXTERN_C): New. Deal with _GLIBCXX_BEGIN_NAMESPACE, _GLIBCXX_END_NAMESPACE when compiling as C. * testsuite/lib/libstdc++.exp (v3_target_compile_as_c): Add -L flag for libstdc++. * testsuite/util/testsuite_common_types.h (integral_types): New typelist. (atomics, atomics_tl): Same. (assignable, default_constructible, copy_constructible, explicit_value_constructible): New. * testsuite/17_intro/headers/c++200x/all.cc: Test new headers. * testsuite/29_atomics: New. * testsuite/29_atomics/atomic_address: Same. * testsuite/29_atomics/atomic_address/cons: Same. * testsuite/29_atomics/atomic_address/cons/explicit_value.cc: Same. * testsuite/29_atomics/atomic_address/cons/assign_neg.cc: Same. * testsuite/29_atomics/atomic_address/cons/copy_neg.cc: Same. * testsuite/29_atomics/atomic_address/cons/default.cc: Same. * testsuite/29_atomics/atomic_address/cons/aggregate.cc: Same. * testsuite/29_atomics/atomic_flag: Same. * testsuite/29_atomics/atomic_flag/cons: Same. * testsuite/29_atomics/atomic_flag/cons/assign_neg.cc: Same. * testsuite/29_atomics/atomic_flag/cons/copy_neg.cc: Same. * testsuite/29_atomics/atomic_flag/cons/default.cc: Same. * testsuite/29_atomics/atomic_flag/cons/aggregate.cc: Same. * testsuite/29_atomics/atomic_flag/requirements: Same. * testsuite/29_atomics/atomic_flag/requirements/standard_layout.cc: Same. * testsuite/29_atomics/atomic_flag/ atomic_global_fence_compatibility.cc: Same. * testsuite/29_atomics/atomic_flag/test_and_set: Same. * testsuite/29_atomics/atomic_flag/test_and_set/explicit.c: Same. * testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc: Same. * testsuite/29_atomics/atomic_flag/test_and_set/implicit.c: Same. * testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc: Same. * testsuite/29_atomics/headers: Same. * testsuite/29_atomics/headers/cstdatomic: Same. * testsuite/29_atomics/headers/cstdatomic/types_std_c++0x.cc: Same. * testsuite/29_atomics/headers/cstdatomic/functions_std_c++0x.cc: Same. * testsuite/29_atomics/headers/cstdatomic/std_c++0x_neg.cc: Same. * testsuite/29_atomics/headers/cstdatomic/macros.cc: Same. * testsuite/29_atomics/headers/stdatomic.h: Same. * testsuite/29_atomics/headers/stdatomic.h/macros.c: Same. * testsuite/29_atomics/headers/stdatomic.h/types.c: Same. * testsuite/29_atomics/headers/stdatomic.h/functions.c: Same. * testsuite/29_atomics/atomic: Same. * testsuite/29_atomics/atomic/cons: Same. * testsuite/29_atomics/atomic/cons/explicit_value.cc: Same. * testsuite/29_atomics/atomic/cons/assign_neg.cc: Same. * testsuite/29_atomics/atomic/cons/copy_neg.cc: Same. * testsuite/29_atomics/atomic/cons/default.cc: Same. * testsuite/29_atomics/atomic/requirements: Same. * testsuite/29_atomics/atomic/requirements/explicit_instantiation: Same. * testsuite/29_atomics/atomic/requirements/explicit_instantiation/ 1.cc: Same. 2008-04-10 Lawrence Crowl <crowl@google.com> * include/c_global/cstdatomic: New. * include/c_compatibility/stdatomic.h: New. * src/atomic.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134174 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/Makefile.am6
-rw-r--r--libstdc++-v3/src/Makefile.in57
-rw-r--r--libstdc++-v3/src/atomic.cc116
3 files changed, 154 insertions, 25 deletions
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index 7bd12aa1f60..e6c0aad184a 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -134,6 +134,7 @@ endif
# Sources present in the src directory.
sources = \
+ atomic.cc \
bitmap_allocator.cc \
pool_allocator.cc \
mt_allocator.cc \
@@ -248,6 +249,11 @@ date_time.lo: date_time.cc
date_time.o: date_time.cc
$(CXXCOMPILE) -std=gnu++0x -c $<
+atomic.lo: atomic.cc
+ $(LTCXXCOMPILE) -x c++ -std=gnu++0x -c $<
+atomic.o: atomic.cc
+ $(CXXCOMPILE) -x c++ -std=gnu++0x -c $<
+
if GLIBCXX_LDBL_COMPAT
# Use special rules for compatibility-ldbl.cc compilation, as we need to
# pass -mlong-double-64.
diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
index 450e97f9538..744833f75c2 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -50,6 +50,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/enable.m4 \
$(top_srcdir)/../config/lib-prefix.m4 \
$(top_srcdir)/../config/multi.m4 \
$(top_srcdir)/../config/no-executables.m4 \
+ $(top_srcdir)/../config/proginstall.m4 \
$(top_srcdir)/../config/unwind_ipinfo.m4 \
$(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \
$(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
@@ -69,18 +70,18 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(toolexeclibdir)"
toolexeclibLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
-am__libstdc___la_SOURCES_DIST = bitmap_allocator.cc pool_allocator.cc \
- mt_allocator.cc codecvt.cc compatibility.cc complex_io.cc \
- ctype.cc date_time.cc debug.cc functexcept.cc hash.cc \
- hash_c++0x.cc globals_io.cc hashtable.cc hashtable_c++0x.cc \
- ios.cc ios_failure.cc ios_init.cc ios_locale.cc limits.cc \
- list.cc debug_list.cc locale.cc locale_init.cc \
- locale_facets.cc localename.cc stdexcept.cc strstream.cc \
- system_error.cc tree.cc allocator-inst.cc concept-inst.cc \
- fstream-inst.cc ext-inst.cc ios-inst.cc iostream-inst.cc \
- istream-inst.cc istream.cc locale-inst.cc misc-inst.cc \
- ostream-inst.cc sstream-inst.cc streambuf-inst.cc streambuf.cc \
- string-inst.cc valarray-inst.cc wlocale-inst.cc \
+am__libstdc___la_SOURCES_DIST = atomic.cc bitmap_allocator.cc \
+ pool_allocator.cc mt_allocator.cc codecvt.cc compatibility.cc \
+ complex_io.cc ctype.cc date_time.cc debug.cc functexcept.cc \
+ hash.cc hash_c++0x.cc globals_io.cc hashtable.cc \
+ hashtable_c++0x.cc ios.cc ios_failure.cc ios_init.cc \
+ ios_locale.cc limits.cc list.cc debug_list.cc locale.cc \
+ locale_init.cc locale_facets.cc localename.cc stdexcept.cc \
+ strstream.cc system_error.cc tree.cc allocator-inst.cc \
+ concept-inst.cc fstream-inst.cc ext-inst.cc ios-inst.cc \
+ iostream-inst.cc istream-inst.cc istream.cc locale-inst.cc \
+ misc-inst.cc ostream-inst.cc sstream-inst.cc streambuf-inst.cc \
+ streambuf.cc string-inst.cc valarray-inst.cc wlocale-inst.cc \
wstring-inst.cc atomicity.cc codecvt_members.cc \
collate_members.cc ctype_members.cc messages_members.cc \
monetary_members.cc numeric_members.cc time_members.cc \
@@ -94,19 +95,19 @@ am__objects_1 = atomicity.lo codecvt_members.lo collate_members.lo \
@ENABLE_PARALLEL_TRUE@ parallel_settings.lo
am__objects_4 = basic_file.lo c++locale.lo $(am__objects_2) \
$(am__objects_3)
-am__objects_5 = bitmap_allocator.lo pool_allocator.lo mt_allocator.lo \
- codecvt.lo compatibility.lo complex_io.lo ctype.lo \
- date_time.lo debug.lo functexcept.lo hash.lo hash_c++0x.lo \
- globals_io.lo hashtable.lo hashtable_c++0x.lo ios.lo \
- ios_failure.lo ios_init.lo ios_locale.lo limits.lo list.lo \
- debug_list.lo locale.lo locale_init.lo locale_facets.lo \
- localename.lo stdexcept.lo strstream.lo system_error.lo \
- tree.lo allocator-inst.lo concept-inst.lo fstream-inst.lo \
- ext-inst.lo ios-inst.lo iostream-inst.lo istream-inst.lo \
- istream.lo locale-inst.lo misc-inst.lo ostream-inst.lo \
- sstream-inst.lo streambuf-inst.lo streambuf.lo string-inst.lo \
- valarray-inst.lo wlocale-inst.lo wstring-inst.lo \
- $(am__objects_1) $(am__objects_4)
+am__objects_5 = atomic.lo bitmap_allocator.lo pool_allocator.lo \
+ mt_allocator.lo codecvt.lo compatibility.lo complex_io.lo \
+ ctype.lo date_time.lo debug.lo functexcept.lo hash.lo \
+ hash_c++0x.lo globals_io.lo hashtable.lo hashtable_c++0x.lo \
+ ios.lo ios_failure.lo ios_init.lo ios_locale.lo limits.lo \
+ list.lo debug_list.lo locale.lo locale_init.lo \
+ locale_facets.lo localename.lo stdexcept.lo strstream.lo \
+ system_error.lo tree.lo allocator-inst.lo concept-inst.lo \
+ fstream-inst.lo ext-inst.lo ios-inst.lo iostream-inst.lo \
+ istream-inst.lo istream.lo locale-inst.lo misc-inst.lo \
+ ostream-inst.lo sstream-inst.lo streambuf-inst.lo streambuf.lo \
+ string-inst.lo valarray-inst.lo wlocale-inst.lo \
+ wstring-inst.lo $(am__objects_1) $(am__objects_4)
am_libstdc___la_OBJECTS = $(am__objects_5)
libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
@@ -367,6 +368,7 @@ host_sources_extra = \
# Sources present in the src directory.
sources = \
+ atomic.cc \
bitmap_allocator.cc \
pool_allocator.cc \
mt_allocator.cc \
@@ -839,6 +841,11 @@ date_time.lo: date_time.cc
date_time.o: date_time.cc
$(CXXCOMPILE) -std=gnu++0x -c $<
+atomic.lo: atomic.cc
+ $(LTCXXCOMPILE) -x c++ -std=gnu++0x -c $<
+atomic.o: atomic.cc
+ $(CXXCOMPILE) -x c++ -std=gnu++0x -c $<
+
# Use special rules for compatibility-ldbl.cc compilation, as we need to
# pass -mlong-double-64.
@GLIBCXX_LDBL_COMPAT_TRUE@compatibility-ldbl.lo: compatibility-ldbl.cc
diff --git a/libstdc++-v3/src/atomic.cc b/libstdc++-v3/src/atomic.cc
new file mode 100644
index 00000000000..e43733332db
--- /dev/null
+++ b/libstdc++-v3/src/atomic.cc
@@ -0,0 +1,116 @@
+// Support for atomic operations -*- C++ -*-
+
+// 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 <stdint.h>
+#include <cstdatomic>
+
+#define LOGSIZE 4
+
+namespace
+{
+ atomic_flag volatile __atomic_flag_anon_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,
+ };
+} // anonymous namespace
+
+namespace std
+{
+ extern "C" {
+
+ const atomic_flag atomic_global_fence_compatibility = ATOMIC_FLAG_INIT;
+
+ bool
+ atomic_flag_test_and_set_explicit(volatile atomic_flag* __a,
+ memory_order __x)
+ {
+#ifdef _GLIBCXX_ATOMIC_BUILTINS
+ if (__x >= memory_order_acq_rel)
+ __sync_synchronize();
+ return __sync_lock_test_and_set(&(__a->_M_base._M_b), 1);
+#else
+ bool result = __a->_M_base._M_b;
+ __a->_M_base._M_b = true;
+ return result;
+#endif
+ }
+
+ bool
+ 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)
+ {
+#ifdef _GLIBCXX_ATOMIC_BUILTINS
+ __sync_lock_release(&(__a->_M_base._M_b));
+ if (__x >= memory_order_acq_rel)
+ __sync_synchronize();
+#else
+ __a->_M_base._M_b = false;
+#endif
+ }
+
+ void
+ atomic_flag_clear(volatile atomic_flag* __a)
+ { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
+
+ void
+ atomic_flag_fence(const volatile atomic_flag*, memory_order)
+ {
+#ifdef _GLIBCXX_ATOMIC_BUILTINS
+ __sync_synchronize();
+#endif
+ }
+
+ void
+ __atomic_flag_wait_explicit(volatile atomic_flag* __a, memory_order __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;
+ }
+
+ } // extern "C"
+} // namespace std