[patch] C++11: Observers for the three 'handler functions'

Jonathan Wakely jwakely.gcc@gmail.com
Fri Apr 5 15:05:00 GMT 2013


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
>         available.
>         * 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
correctness.

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.



More information about the Gcc-patches mailing list