exception (get_terminate(), [...]): Declare.
* 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. From-SVN: r197380
This commit is contained in:
parent
b6fd8c8e88
commit
dca77a8a1b
18 changed files with 286 additions and 52 deletions
|
@ -1,3 +1,29 @@
|
||||||
|
2013-04-03 Jonathan Wakely <jwakely.gcc@gmail.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2013-04-02 Jonathan Wakely <jwakely.gcc@gmail.com>
|
2013-04-02 Jonathan Wakely <jwakely.gcc@gmail.com>
|
||||||
|
|
||||||
* doc/xml/manual/appendix_contributing.xml: Remove broken link and
|
* doc/xml/manual/appendix_contributing.xml: Remove broken link and
|
||||||
|
|
|
@ -3241,7 +3241,7 @@ changequote([,])dnl
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For libtool versioning info, format is CURRENT:REVISION:AGE
|
# For libtool versioning info, format is CURRENT:REVISION:AGE
|
||||||
libtool_VERSION=6:18:0
|
libtool_VERSION=6:19:0
|
||||||
|
|
||||||
# Everything parsed; figure out what files and settings to use.
|
# Everything parsed; figure out what files and settings to use.
|
||||||
case $enable_symvers in
|
case $enable_symvers in
|
||||||
|
|
|
@ -1344,6 +1344,19 @@ GLIBCXX_3.4.18 {
|
||||||
|
|
||||||
} GLIBCXX_3.4.17;
|
} GLIBCXX_3.4.17;
|
||||||
|
|
||||||
|
GLIBCXX_3.4.19 {
|
||||||
|
|
||||||
|
# std::get_new_handler()
|
||||||
|
_ZSt15get_new_handlerv;
|
||||||
|
|
||||||
|
# std::get_terminate()
|
||||||
|
_ZSt13get_terminatev;
|
||||||
|
|
||||||
|
# std::get_unexpected()
|
||||||
|
_ZSt14get_unexpectedv;
|
||||||
|
|
||||||
|
} GLIBCXX_3.4.18;
|
||||||
|
|
||||||
# Symbols in the support library (libsupc++) have their own tag.
|
# Symbols in the support library (libsupc++) have their own tag.
|
||||||
CXXABI_1.3 {
|
CXXABI_1.3 {
|
||||||
|
|
||||||
|
|
2
libstdc++-v3/configure
vendored
2
libstdc++-v3/configure
vendored
|
@ -71477,7 +71477,7 @@ $as_echo "$as_me: WARNING: === Symbol versioning will be disabled." >&2;}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For libtool versioning info, format is CURRENT:REVISION:AGE
|
# For libtool versioning info, format is CURRENT:REVISION:AGE
|
||||||
libtool_VERSION=6:18:0
|
libtool_VERSION=6:19:0
|
||||||
|
|
||||||
# Everything parsed; figure out what files and settings to use.
|
# Everything parsed; figure out what files and settings to use.
|
||||||
case $enable_symvers in
|
case $enable_symvers in
|
||||||
|
|
|
@ -154,13 +154,10 @@ particular release.
|
||||||
<entry>C library dependency for quick_exit, at_quick_exit</entry>
|
<entry>C library dependency for quick_exit, at_quick_exit</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<?dbhtml bgcolor="#B0B0B0" ?>
|
|
||||||
<entry>18.6</entry>
|
<entry>18.6</entry>
|
||||||
<entry>Dynamic memory management</entry>
|
<entry>Dynamic memory management</entry>
|
||||||
<entry>Partial</entry>
|
<entry>Y</entry>
|
||||||
<entry>Missing <code>get_new_handler</code>.
|
<entry/>
|
||||||
<code>set_new_handler</code> is not thread-safe.
|
|
||||||
</entry>
|
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry>18.7</entry>
|
<entry>18.7</entry>
|
||||||
|
@ -205,13 +202,10 @@ particular release.
|
||||||
<entry/>
|
<entry/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<?dbhtml bgcolor="#B0B0B0" ?>
|
|
||||||
<entry>18.8.3</entry>
|
<entry>18.8.3</entry>
|
||||||
<entry>Abnormal termination</entry>
|
<entry>Abnormal termination</entry>
|
||||||
<entry>Partial</entry>
|
<entry>Y</entry>
|
||||||
<entry>Missing <code>get_terminate</code>.
|
<entry/>
|
||||||
<code>set_terminate</code> is not thread-safe.
|
|
||||||
</entry>
|
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry>18.8.4</entry>
|
<entry>18.8.4</entry>
|
||||||
|
@ -2616,12 +2610,9 @@ particular release.
|
||||||
<entry/>
|
<entry/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<?dbhtml bgcolor="#B0B0B0" ?>
|
|
||||||
<entry>D.11</entry>
|
<entry>D.11</entry>
|
||||||
<entry>Violating exception-specifications</entry>
|
<entry>Violating exception-specifications</entry>
|
||||||
<entry>Partial</entry>
|
<entry/>
|
||||||
<entry>Missing <code>get_unexpected</code>.
|
|
||||||
<code>set_unexpected</code> is not thread-safe.
|
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
|
|
@ -106,31 +106,51 @@ cp-demangle.o: cp-demangle.c
|
||||||
$(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -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
|
eh_ptr.lo: eh_ptr.cc
|
||||||
$(LTCXXCOMPILE) -std=gnu++0x -c $<
|
$(LTCXXCOMPILE) -std=gnu++11 -c $<
|
||||||
eh_ptr.o: eh_ptr.cc
|
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
|
eh_throw.lo: eh_throw.cc
|
||||||
$(LTCXXCOMPILE) -std=gnu++0x -c $<
|
$(LTCXXCOMPILE) -std=gnu++11 -c $<
|
||||||
eh_throw.o: eh_throw.cc
|
eh_throw.o: eh_throw.cc
|
||||||
$(CXXCOMPILE) -std=gnu++0x -c $<
|
$(CXXCOMPILE) -std=gnu++11 -c $<
|
||||||
|
|
||||||
guard.lo: guard.cc
|
guard.lo: guard.cc
|
||||||
$(LTCXXCOMPILE) -std=gnu++0x -c $<
|
$(LTCXXCOMPILE) -std=gnu++11 -c $<
|
||||||
guard.o: guard.cc
|
guard.o: guard.cc
|
||||||
$(CXXCOMPILE) -std=gnu++0x -c $<
|
$(CXXCOMPILE) -std=gnu++11 -c $<
|
||||||
|
|
||||||
atexit_thread.lo: atexit_thread.cc
|
atexit_thread.lo: atexit_thread.cc
|
||||||
$(LTCXXCOMPILE) -std=gnu++0x -c $<
|
$(LTCXXCOMPILE) -std=gnu++11 -c $<
|
||||||
atexit_thread.o: atexit_thread.cc
|
atexit_thread.o: atexit_thread.cc
|
||||||
$(CXXCOMPILE) -std=gnu++0x -c $<
|
$(CXXCOMPILE) -std=gnu++11 -c $<
|
||||||
|
|
||||||
nested_exception.lo: nested_exception.cc
|
nested_exception.lo: nested_exception.cc
|
||||||
$(LTCXXCOMPILE) -std=gnu++0x -c $<
|
$(LTCXXCOMPILE) -std=gnu++11 -c $<
|
||||||
nested_exception.o: nested_exception.cc
|
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
|
# 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
|
# modified in a per-library or per-sub-library way. Need to manually
|
||||||
|
|
|
@ -787,31 +787,51 @@ cp-demangle.lo: cp-demangle.c
|
||||||
cp-demangle.o: cp-demangle.c
|
cp-demangle.o: cp-demangle.c
|
||||||
$(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -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
|
eh_ptr.lo: eh_ptr.cc
|
||||||
$(LTCXXCOMPILE) -std=gnu++0x -c $<
|
$(LTCXXCOMPILE) -std=gnu++11 -c $<
|
||||||
eh_ptr.o: eh_ptr.cc
|
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
|
eh_throw.lo: eh_throw.cc
|
||||||
$(LTCXXCOMPILE) -std=gnu++0x -c $<
|
$(LTCXXCOMPILE) -std=gnu++11 -c $<
|
||||||
eh_throw.o: eh_throw.cc
|
eh_throw.o: eh_throw.cc
|
||||||
$(CXXCOMPILE) -std=gnu++0x -c $<
|
$(CXXCOMPILE) -std=gnu++11 -c $<
|
||||||
|
|
||||||
guard.lo: guard.cc
|
guard.lo: guard.cc
|
||||||
$(LTCXXCOMPILE) -std=gnu++0x -c $<
|
$(LTCXXCOMPILE) -std=gnu++11 -c $<
|
||||||
guard.o: guard.cc
|
guard.o: guard.cc
|
||||||
$(CXXCOMPILE) -std=gnu++0x -c $<
|
$(CXXCOMPILE) -std=gnu++11 -c $<
|
||||||
|
|
||||||
atexit_thread.lo: atexit_thread.cc
|
atexit_thread.lo: atexit_thread.cc
|
||||||
$(LTCXXCOMPILE) -std=gnu++0x -c $<
|
$(LTCXXCOMPILE) -std=gnu++11 -c $<
|
||||||
atexit_thread.o: atexit_thread.cc
|
atexit_thread.o: atexit_thread.cc
|
||||||
$(CXXCOMPILE) -std=gnu++0x -c $<
|
$(CXXCOMPILE) -std=gnu++11 -c $<
|
||||||
|
|
||||||
nested_exception.lo: nested_exception.cc
|
nested_exception.lo: nested_exception.cc
|
||||||
$(LTCXXCOMPILE) -std=gnu++0x -c $<
|
$(LTCXXCOMPILE) -std=gnu++11 -c $<
|
||||||
nested_exception.o: nested_exception.cc
|
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)
|
install-stdHEADERS: $(std_HEADERS)
|
||||||
@$(NORMAL_INSTALL)
|
@$(NORMAL_INSTALL)
|
||||||
|
|
|
@ -45,7 +45,7 @@ __cxxabiv1::__terminate (std::terminate_handler handler) throw ()
|
||||||
void
|
void
|
||||||
std::terminate () throw()
|
std::terminate () throw()
|
||||||
{
|
{
|
||||||
__terminate (__terminate_handler);
|
__terminate (get_terminate ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -58,21 +58,37 @@ __cxxabiv1::__unexpected (std::unexpected_handler handler)
|
||||||
void
|
void
|
||||||
std::unexpected ()
|
std::unexpected ()
|
||||||
{
|
{
|
||||||
__unexpected (__unexpected_handler);
|
__unexpected (get_unexpected ());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::terminate_handler
|
std::terminate_handler
|
||||||
std::set_terminate (std::terminate_handler func) throw()
|
std::set_terminate (std::terminate_handler func) throw()
|
||||||
{
|
{
|
||||||
std::terminate_handler old = __terminate_handler;
|
std::terminate_handler old;
|
||||||
__terminate_handler = func;
|
__atomic_exchange (&__terminate_handler, &func, &old, __ATOMIC_ACQ_REL);
|
||||||
return old;
|
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::unexpected_handler
|
||||||
std::set_unexpected (std::unexpected_handler func) throw()
|
std::set_unexpected (std::unexpected_handler func) throw()
|
||||||
{
|
{
|
||||||
std::unexpected_handler old = __unexpected_handler;
|
std::unexpected_handler old;
|
||||||
__unexpected_handler = func;
|
__atomic_exchange (&__unexpected_handler, &func, &old, __ATOMIC_ACQ_REL);
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unexpected_handler
|
||||||
|
std::get_unexpected () noexcept
|
||||||
|
{
|
||||||
|
std::unexpected_handler func;
|
||||||
|
__atomic_load (&__unexpected_handler, &func, __ATOMIC_ACQUIRE);
|
||||||
|
return func;
|
||||||
|
}
|
||||||
|
|
|
@ -92,6 +92,11 @@ namespace std
|
||||||
/// Takes a new handler function as an argument, returns the old function.
|
/// Takes a new handler function as an argument, returns the old function.
|
||||||
terminate_handler set_terminate(terminate_handler) _GLIBCXX_USE_NOEXCEPT;
|
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
|
/** The runtime will call this function if %exception handling must be
|
||||||
* abandoned for any reason. It can also be called by the user. */
|
* abandoned for any reason. It can also be called by the user. */
|
||||||
void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__));
|
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.
|
/// Takes a new handler function as an argument, returns the old function.
|
||||||
unexpected_handler set_unexpected(unexpected_handler) _GLIBCXX_USE_NOEXCEPT;
|
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
|
/** The runtime will call this function if an %exception is thrown which
|
||||||
* violates the function's %exception specification. */
|
* violates the function's %exception specification. */
|
||||||
void unexpected() __attribute__ ((__noreturn__));
|
void unexpected() __attribute__ ((__noreturn__));
|
||||||
|
|
|
@ -75,6 +75,11 @@ namespace std
|
||||||
/// Takes a replacement handler as the argument, returns the
|
/// Takes a replacement handler as the argument, returns the
|
||||||
/// previous handler.
|
/// previous handler.
|
||||||
new_handler set_new_handler(new_handler) throw();
|
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
|
} // namespace std
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
|
|
|
@ -28,12 +28,24 @@
|
||||||
const std::nothrow_t std::nothrow = { };
|
const std::nothrow_t std::nothrow = { };
|
||||||
|
|
||||||
using std::new_handler;
|
using std::new_handler;
|
||||||
new_handler __new_handler;
|
namespace
|
||||||
|
{
|
||||||
|
new_handler __new_handler;
|
||||||
|
}
|
||||||
|
|
||||||
new_handler
|
new_handler
|
||||||
std::set_new_handler (new_handler handler) throw()
|
std::set_new_handler (new_handler handler) throw()
|
||||||
{
|
{
|
||||||
new_handler prev_handler = __new_handler;
|
new_handler prev_handler;
|
||||||
__new_handler = handler;
|
__atomic_exchange (&__new_handler, &handler, &prev_handler,
|
||||||
|
__ATOMIC_ACQ_REL);
|
||||||
return prev_handler;
|
return prev_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_handler
|
||||||
|
std::get_new_handler () noexcept
|
||||||
|
{
|
||||||
|
new_handler handler;
|
||||||
|
__atomic_load (&__new_handler, &handler, __ATOMIC_ACQUIRE);
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
|
|
@ -38,8 +38,6 @@ using std::malloc;
|
||||||
extern "C" void *malloc (std::size_t);
|
extern "C" void *malloc (std::size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern new_handler __new_handler;
|
|
||||||
|
|
||||||
_GLIBCXX_WEAK_DEFINITION void *
|
_GLIBCXX_WEAK_DEFINITION void *
|
||||||
operator new (std::size_t sz) _GLIBCXX_THROW (std::bad_alloc)
|
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);
|
p = (void *) malloc (sz);
|
||||||
while (p == 0)
|
while (p == 0)
|
||||||
{
|
{
|
||||||
new_handler handler = __new_handler;
|
new_handler handler = std::get_new_handler ();
|
||||||
if (! handler)
|
if (! handler)
|
||||||
_GLIBCXX_THROW_OR_ABORT(bad_alloc());
|
_GLIBCXX_THROW_OR_ABORT(bad_alloc());
|
||||||
handler ();
|
handler ();
|
||||||
|
|
|
@ -30,7 +30,6 @@ using std::new_handler;
|
||||||
using std::bad_alloc;
|
using std::bad_alloc;
|
||||||
|
|
||||||
extern "C" void *malloc (std::size_t);
|
extern "C" void *malloc (std::size_t);
|
||||||
extern new_handler __new_handler;
|
|
||||||
|
|
||||||
_GLIBCXX_WEAK_DEFINITION void *
|
_GLIBCXX_WEAK_DEFINITION void *
|
||||||
operator new (std::size_t sz, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
|
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);
|
p = (void *) malloc (sz);
|
||||||
while (p == 0)
|
while (p == 0)
|
||||||
{
|
{
|
||||||
new_handler handler = __new_handler;
|
new_handler handler = std::get_new_handler ();
|
||||||
if (! handler)
|
if (! handler)
|
||||||
return 0;
|
return 0;
|
||||||
__try
|
__try
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// { dg-do compile }
|
// { dg-do compile }
|
||||||
|
// { dg-options "-std=gnu++11" }
|
||||||
|
|
||||||
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
|
@ -25,10 +26,12 @@ namespace std {
|
||||||
|
|
||||||
typedef void (*unexpected_handler)();
|
typedef void (*unexpected_handler)();
|
||||||
unexpected_handler set_unexpected(unexpected_handler f ) throw();
|
unexpected_handler set_unexpected(unexpected_handler f ) throw();
|
||||||
|
unexpected_handler get_unexpected() noexcept;
|
||||||
void unexpected();
|
void unexpected();
|
||||||
|
|
||||||
typedef void (*terminate_handler)();
|
typedef void (*terminate_handler)();
|
||||||
terminate_handler set_terminate(terminate_handler f ) throw();
|
terminate_handler set_terminate(terminate_handler f ) throw();
|
||||||
|
terminate_handler get_terminate() noexcept;
|
||||||
void terminate() throw();
|
void terminate() throw();
|
||||||
|
|
||||||
bool uncaught_exception() throw();
|
bool uncaught_exception() throw();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// { dg-do compile }
|
// { dg-do compile }
|
||||||
|
// { dg-options "-std=gnu++11" }
|
||||||
|
|
||||||
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
|
@ -25,6 +26,7 @@ namespace std {
|
||||||
extern const nothrow_t nothrow;
|
extern const nothrow_t nothrow;
|
||||||
typedef void (*new_handler)();
|
typedef void (*new_handler)();
|
||||||
new_handler set_new_handler(new_handler new_p) throw();
|
new_handler set_new_handler(new_handler new_p) throw();
|
||||||
|
new_handler get_new_handler() noexcept;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* operator new(std::size_t size) throw(std::bad_alloc);
|
void* operator new(std::size_t size) throw(std::bad_alloc);
|
||||||
|
|
39
libstdc++-v3/testsuite/18_support/new_handler.cc
Normal file
39
libstdc++-v3/testsuite/18_support/new_handler.cc
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
// Copyright (C) 2013 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 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING3. If not see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// { dg-options "-std=gnu++11" }
|
||||||
|
|
||||||
|
// 18.6.2 Storage allocation errors
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
void handler() { throw std::bad_alloc(); }
|
||||||
|
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
auto prev = std::set_new_handler(handler);
|
||||||
|
VERIFY( prev == nullptr );
|
||||||
|
auto curr = std::get_new_handler();
|
||||||
|
VERIFY( curr == handler );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
40
libstdc++-v3/testsuite/18_support/terminate_handler.cc
Normal file
40
libstdc++-v3/testsuite/18_support/terminate_handler.cc
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
// Copyright (C) 2013 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 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING3. If not see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// { dg-options "-std=gnu++11" }
|
||||||
|
|
||||||
|
// 18.8.3 Abnormal termination
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
void handler() { std::abort(); }
|
||||||
|
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
auto prev = std::set_terminate(handler);
|
||||||
|
VERIFY( prev != handler );
|
||||||
|
auto curr = std::get_terminate();
|
||||||
|
VERIFY( curr == handler );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
40
libstdc++-v3/testsuite/18_support/unexpected_handler.cc
Normal file
40
libstdc++-v3/testsuite/18_support/unexpected_handler.cc
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
// Copyright (C) 2013 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 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING3. If not see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// { dg-options "-std=gnu++11" }
|
||||||
|
|
||||||
|
// D.11 Violating exception-specifications
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
void handler() { std::abort(); }
|
||||||
|
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
auto prev = std::set_unexpected(handler);
|
||||||
|
VERIFY( prev != handler );
|
||||||
|
auto curr = std::get_unexpected();
|
||||||
|
VERIFY( curr == handler );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue