This is the mail archive of the
mailing list for the GCC project.
Re: [patch] C++11: Observers for the three 'handler functions'
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 5 Apr 2013 12:59:45 +0100
- Subject: Re: [patch] C++11: Observers for the three 'handler functions'
- References: <CAH6eHdTS2xLDPughh7obu67ishe0Dpw3jvodUtFrF1jNKPrT8Q at mail dot gmail dot com> <515C164F dot 6030505 at oracle dot com> <CAH6eHdTtxSe6LJwP4M3Hqig4ahj_RixjRRYLhUw0RHjj3F4GZg at mail dot gmail dot com> <515C19A9 dot 1060800 at oracle dot com> <CAH6eHdSUGA6BFuZ8z9Bsu4P7GbUjBsqXtaDyj03onrCZr5x_6Q at mail dot gmail dot com> <CAH6eHdQNz+tOsC=ARXxX48rkm_ORBMjembFJ7Kub9WJza6eAbA at mail dot gmail dot com>
On 5 April 2013 11:13, Jonathan Wakely wrote:
> This should fix the handlers for platforms without __atomic_exchange
> for pointers by using a mutex. I used the old __mutex type not
> std::mutex because it's available on more platforms and works for the
> 'single' thread model too. I didn't try to optimise away the atomic
> ops for accessing the handlers because throwing exceptions and
> getting/setting these handlers should not be on the fast path of
> performance sensitive code.
> PR libstdc++/56841
> * libsupc++/eh_ptr.cc (rethrow_exception): Use get_unexpected() and
> get_terminate() accessors.
> * libsupc++/eh_throw.cc (__cxa_throw): Likewise.
> * libsupc++/eh_terminate.cc: Use mutex when atomic builtins not
> * libsupc++/new_handler.cc: Likewise.
> Tested x86_64-linux and hppa2.0-linux, committed to trunk.
I did think about adding a new accessor for internal use:
std::pair<unexpected_handler, terminate_handler> __get_handlers();
which could be used in eh_throw.cc and eh_ptr.cc to avoid doing two
separate PIC calls to get_unexpected() and get_terminate(), and so
that platforms using a mutex would only lock it once. We can
reconsider doing that later, it's only an optimisation not needed for
I think we could also remove the extern declarations of
__unexpected_handler and __terminate_handler and make them internal to
eh_terminate.cc, as I already did for __new_handler. Although those
names were visible to users they should not be used, are not part of
the IA-64 ABI, and are not exported from the shared lib.