summaryrefslogtreecommitdiff
path: root/libstdc++-v3/libsupc++
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2013-04-03 00:08:54 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2013-04-03 00:08:54 +0000
commita366a1d39800dd1c8d89eaf8b1247866b90b59f1 (patch)
tree41b23a61903b4ffa760fefd1e9f216e33e089932 /libstdc++-v3/libsupc++
parent3ca21885bf62d811e364fc478a44da09652a3bc7 (diff)
downloadgcc-a366a1d39800dd1c8d89eaf8b1247866b90b59f1.tar.gz
* libsupc++/exception (get_terminate(), get_unexpected()): Declare.
* libsupc++/eh_terminate.cc (get_terminate() , set_unexpected()): Define. (set_terminate(terminate_handler)): Set atomically. (set_unexpected(terminate_handler)): Likewise. * libsupc++/new (get_new_handler()): Declare. * libsupc++/new_handler.cc (get_new_handler()): Define. (set_new_handler(new_handler)): Set atomically. (__new_handler): Use internal linkage. * libsupc++/new_op.cc (operator new): Use get_new_handler(). * libsupc++/new_opnt.cc (operator new): Likewise. * acinclude.m4: Bump libtool_VERSION to 6:19:0. * configure: Regenerate. * libsupc++/Makefile.am: Compile above files with -std=gnu++11. * libsupc++/Makefile.in: Regenerate. * config/abi/pre/gnu.ver: Add new exports. * doc/xml/manual/status_cxx2011.xml: Update. * testsuite/18_support/headers/exception/synopsis.cc: Check accessors for handlers. * testsuite/18_support/headers/new/synopsis.cc: Likewise. * testsuite/18_support/new_handler.cc: New. * testsuite/18_support/terminate_handler.cc: New. * testsuite/18_support/unexpected_handler.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@197380 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/libsupc++')
-rw-r--r--libstdc++-v3/libsupc++/Makefile.am42
-rw-r--r--libstdc++-v3/libsupc++/Makefile.in42
-rw-r--r--libstdc++-v3/libsupc++/eh_terminate.cc28
-rw-r--r--libstdc++-v3/libsupc++/exception10
-rw-r--r--libstdc++-v3/libsupc++/new5
-rw-r--r--libstdc++-v3/libsupc++/new_handler.cc18
-rw-r--r--libstdc++-v3/libsupc++/new_op.cc4
-rw-r--r--libstdc++-v3/libsupc++/new_opnt.cc3
8 files changed, 116 insertions, 36 deletions
diff --git a/libstdc++-v3/libsupc++/Makefile.am b/libstdc++-v3/libsupc++/Makefile.am
index f276eda0854..25c58fb8b0d 100644
--- a/libstdc++-v3/libsupc++/Makefile.am
+++ b/libstdc++-v3/libsupc++/Makefile.am
@@ -106,31 +106,51 @@ cp-demangle.o: cp-demangle.c
$(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
-# Use special rules for the C++0x sources so that the proper flags are passed.
+# Use special rules for the C++11 sources so that the proper flags are passed.
eh_ptr.lo: eh_ptr.cc
- $(LTCXXCOMPILE) -std=gnu++0x -c $<
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
eh_ptr.o: eh_ptr.cc
- $(CXXCOMPILE) -std=gnu++0x -c $<
+ $(CXXCOMPILE) -std=gnu++11 -c $<
+
+eh_terminate.lo: eh_terminate.cc
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
+eh_terminate.o: eh_terminate.cc
+ $(CXXCOMPILE) -std=gnu++11 -c $<
eh_throw.lo: eh_throw.cc
- $(LTCXXCOMPILE) -std=gnu++0x -c $<
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
eh_throw.o: eh_throw.cc
- $(CXXCOMPILE) -std=gnu++0x -c $<
+ $(CXXCOMPILE) -std=gnu++11 -c $<
guard.lo: guard.cc
- $(LTCXXCOMPILE) -std=gnu++0x -c $<
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
guard.o: guard.cc
- $(CXXCOMPILE) -std=gnu++0x -c $<
+ $(CXXCOMPILE) -std=gnu++11 -c $<
atexit_thread.lo: atexit_thread.cc
- $(LTCXXCOMPILE) -std=gnu++0x -c $<
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
atexit_thread.o: atexit_thread.cc
- $(CXXCOMPILE) -std=gnu++0x -c $<
+ $(CXXCOMPILE) -std=gnu++11 -c $<
nested_exception.lo: nested_exception.cc
- $(LTCXXCOMPILE) -std=gnu++0x -c $<
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
nested_exception.o: nested_exception.cc
- $(CXXCOMPILE) -std=gnu++0x -c $<
+ $(CXXCOMPILE) -std=gnu++11 -c $<
+
+new_handler.lo: new_handler.cc
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
+new_handler.o: new_handler.cc
+ $(CXXCOMPILE) -std=gnu++11 -c $<
+
+new_op.lo: new_op.cc
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
+new_op.o: new_op.cc
+ $(CXXCOMPILE) -std=gnu++11 -c $<
+
+new_opnt.lo: new_opnt.cc
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
+new_opnt.o: new_opnt.cc
+ $(CXXCOMPILE) -std=gnu++11 -c $<
# AM_CXXFLAGS needs to be in each subdirectory so that it can be
# modified in a per-library or per-sub-library way. Need to manually
diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in
index 8bf86f35af6..eb13f1ea9ef 100644
--- a/libstdc++-v3/libsupc++/Makefile.in
+++ b/libstdc++-v3/libsupc++/Makefile.in
@@ -787,31 +787,51 @@ cp-demangle.lo: cp-demangle.c
cp-demangle.o: cp-demangle.c
$(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
-# Use special rules for the C++0x sources so that the proper flags are passed.
+# Use special rules for the C++11 sources so that the proper flags are passed.
eh_ptr.lo: eh_ptr.cc
- $(LTCXXCOMPILE) -std=gnu++0x -c $<
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
eh_ptr.o: eh_ptr.cc
- $(CXXCOMPILE) -std=gnu++0x -c $<
+ $(CXXCOMPILE) -std=gnu++11 -c $<
+
+eh_terminate.lo: eh_terminate.cc
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
+eh_terminate.o: eh_terminate.cc
+ $(CXXCOMPILE) -std=gnu++11 -c $<
eh_throw.lo: eh_throw.cc
- $(LTCXXCOMPILE) -std=gnu++0x -c $<
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
eh_throw.o: eh_throw.cc
- $(CXXCOMPILE) -std=gnu++0x -c $<
+ $(CXXCOMPILE) -std=gnu++11 -c $<
guard.lo: guard.cc
- $(LTCXXCOMPILE) -std=gnu++0x -c $<
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
guard.o: guard.cc
- $(CXXCOMPILE) -std=gnu++0x -c $<
+ $(CXXCOMPILE) -std=gnu++11 -c $<
atexit_thread.lo: atexit_thread.cc
- $(LTCXXCOMPILE) -std=gnu++0x -c $<
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
atexit_thread.o: atexit_thread.cc
- $(CXXCOMPILE) -std=gnu++0x -c $<
+ $(CXXCOMPILE) -std=gnu++11 -c $<
nested_exception.lo: nested_exception.cc
- $(LTCXXCOMPILE) -std=gnu++0x -c $<
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
nested_exception.o: nested_exception.cc
- $(CXXCOMPILE) -std=gnu++0x -c $<
+ $(CXXCOMPILE) -std=gnu++11 -c $<
+
+new_handler.lo: new_handler.cc
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
+new_handler.o: new_handler.cc
+ $(CXXCOMPILE) -std=gnu++11 -c $<
+
+new_op.lo: new_op.cc
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
+new_op.o: new_op.cc
+ $(CXXCOMPILE) -std=gnu++11 -c $<
+
+new_opnt.lo: new_opnt.cc
+ $(LTCXXCOMPILE) -std=gnu++11 -c $<
+new_opnt.o: new_opnt.cc
+ $(CXXCOMPILE) -std=gnu++11 -c $<
install-stdHEADERS: $(std_HEADERS)
@$(NORMAL_INSTALL)
diff --git a/libstdc++-v3/libsupc++/eh_terminate.cc b/libstdc++-v3/libsupc++/eh_terminate.cc
index b54c8598401..bc38e1d201d 100644
--- a/libstdc++-v3/libsupc++/eh_terminate.cc
+++ b/libstdc++-v3/libsupc++/eh_terminate.cc
@@ -45,7 +45,7 @@ __cxxabiv1::__terminate (std::terminate_handler handler) throw ()
void
std::terminate () throw()
{
- __terminate (__terminate_handler);
+ __terminate (get_terminate ());
}
void
@@ -58,21 +58,37 @@ __cxxabiv1::__unexpected (std::unexpected_handler handler)
void
std::unexpected ()
{
- __unexpected (__unexpected_handler);
+ __unexpected (get_unexpected ());
}
std::terminate_handler
std::set_terminate (std::terminate_handler func) throw()
{
- std::terminate_handler old = __terminate_handler;
- __terminate_handler = func;
+ std::terminate_handler old;
+ __atomic_exchange (&__terminate_handler, &func, &old, __ATOMIC_ACQ_REL);
return old;
}
+std::terminate_handler
+std::get_terminate () noexcept
+{
+ std::terminate_handler func;
+ __atomic_load (&__terminate_handler, &func, __ATOMIC_ACQUIRE);
+ return func;
+}
+
std::unexpected_handler
std::set_unexpected (std::unexpected_handler func) throw()
{
- std::unexpected_handler old = __unexpected_handler;
- __unexpected_handler = func;
+ std::unexpected_handler old;
+ __atomic_exchange (&__unexpected_handler, &func, &old, __ATOMIC_ACQ_REL);
return old;
}
+
+std::unexpected_handler
+std::get_unexpected () noexcept
+{
+ std::unexpected_handler func;
+ __atomic_load (&__unexpected_handler, &func, __ATOMIC_ACQUIRE);
+ return func;
+}
diff --git a/libstdc++-v3/libsupc++/exception b/libstdc++-v3/libsupc++/exception
index f30cda99f7c..6bd97706a83 100644
--- a/libstdc++-v3/libsupc++/exception
+++ b/libstdc++-v3/libsupc++/exception
@@ -92,6 +92,11 @@ namespace std
/// Takes a new handler function as an argument, returns the old function.
terminate_handler set_terminate(terminate_handler) _GLIBCXX_USE_NOEXCEPT;
+#if __cplusplus >= 201103L
+ /// Return the current terminate handler.
+ terminate_handler get_terminate() noexcept;
+#endif
+
/** The runtime will call this function if %exception handling must be
* abandoned for any reason. It can also be called by the user. */
void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__));
@@ -99,6 +104,11 @@ namespace std
/// Takes a new handler function as an argument, returns the old function.
unexpected_handler set_unexpected(unexpected_handler) _GLIBCXX_USE_NOEXCEPT;
+#if __cplusplus >= 201103L
+ /// Return the current unexpected handler.
+ unexpected_handler get_unexpected() noexcept;
+#endif
+
/** The runtime will call this function if an %exception is thrown which
* violates the function's %exception specification. */
void unexpected() __attribute__ ((__noreturn__));
diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new
index 2a926037cf2..e3f0f7796f8 100644
--- a/libstdc++-v3/libsupc++/new
+++ b/libstdc++-v3/libsupc++/new
@@ -75,6 +75,11 @@ namespace std
/// Takes a replacement handler as the argument, returns the
/// previous handler.
new_handler set_new_handler(new_handler) throw();
+
+#if __cplusplus >= 201103L
+ /// Return the current new handler.
+ new_handler get_new_handler() noexcept;
+#endif
} // namespace std
//@{
diff --git a/libstdc++-v3/libsupc++/new_handler.cc b/libstdc++-v3/libsupc++/new_handler.cc
index bbce0bdfa30..2f6bb5e46c1 100644
--- a/libstdc++-v3/libsupc++/new_handler.cc
+++ b/libstdc++-v3/libsupc++/new_handler.cc
@@ -28,12 +28,24 @@
const std::nothrow_t std::nothrow = { };
using std::new_handler;
-new_handler __new_handler;
+namespace
+{
+ new_handler __new_handler;
+}
new_handler
std::set_new_handler (new_handler handler) throw()
{
- new_handler prev_handler = __new_handler;
- __new_handler = handler;
+ new_handler prev_handler;
+ __atomic_exchange (&__new_handler, &handler, &prev_handler,
+ __ATOMIC_ACQ_REL);
return prev_handler;
}
+
+new_handler
+std::get_new_handler () noexcept
+{
+ new_handler handler;
+ __atomic_load (&__new_handler, &handler, __ATOMIC_ACQUIRE);
+ return handler;
+}
diff --git a/libstdc++-v3/libsupc++/new_op.cc b/libstdc++-v3/libsupc++/new_op.cc
index 97815962889..903b347045c 100644
--- a/libstdc++-v3/libsupc++/new_op.cc
+++ b/libstdc++-v3/libsupc++/new_op.cc
@@ -38,8 +38,6 @@ using std::malloc;
extern "C" void *malloc (std::size_t);
#endif
-extern new_handler __new_handler;
-
_GLIBCXX_WEAK_DEFINITION void *
operator new (std::size_t sz) _GLIBCXX_THROW (std::bad_alloc)
{
@@ -51,7 +49,7 @@ operator new (std::size_t sz) _GLIBCXX_THROW (std::bad_alloc)
p = (void *) malloc (sz);
while (p == 0)
{
- new_handler handler = __new_handler;
+ new_handler handler = std::get_new_handler ();
if (! handler)
_GLIBCXX_THROW_OR_ABORT(bad_alloc());
handler ();
diff --git a/libstdc++-v3/libsupc++/new_opnt.cc b/libstdc++-v3/libsupc++/new_opnt.cc
index 3e226248670..d72feffa213 100644
--- a/libstdc++-v3/libsupc++/new_opnt.cc
+++ b/libstdc++-v3/libsupc++/new_opnt.cc
@@ -30,7 +30,6 @@ using std::new_handler;
using std::bad_alloc;
extern "C" void *malloc (std::size_t);
-extern new_handler __new_handler;
_GLIBCXX_WEAK_DEFINITION void *
operator new (std::size_t sz, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
@@ -43,7 +42,7 @@ operator new (std::size_t sz, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
p = (void *) malloc (sz);
while (p == 0)
{
- new_handler handler = __new_handler;
+ new_handler handler = std::get_new_handler ();
if (! handler)
return 0;
__try