>From a50f188c7928e3d01d1b4c59712c50c3a571bfd0 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 5 Oct 2018 21:53:24 +0200 Subject: [PATCH 3/5] raise: Make it possible to namespace the defined symbol. * lib/raise.c (raise): Undefine only after the replacement function has been defined. (raise): Renamed from rpl_raise. (raise_nothrow): Move to the end of the compilation unit. --- ChangeLog | 8 ++++++++ lib/raise.c | 48 +++++++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d2921d..8d4d249 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2018-10-05 Bruno Haible + raise: Make it possible to namespace the defined symbol. + * lib/raise.c (raise): Undefine only after the replacement function has + been defined. + (raise): Renamed from rpl_raise. + (raise_nothrow): Move to the end of the compilation unit. + +2018-10-05 Bruno Haible + memcmp: Make it possible to namespace the defined symbol. * lib/memcmp.c (memcmp): Don't undefine outside of glibc. diff --git a/lib/raise.c b/lib/raise.c index 3a29339..8a93bea 100644 --- a/lib/raise.c +++ b/lib/raise.c @@ -31,27 +31,9 @@ # include "msvc-inval.h" # endif -# undef raise - # if HAVE_MSVC_INVALID_PARAMETER_HANDLER -static int -raise_nothrow (int sig) -{ - int result; - - TRY_MSVC_INVAL - { - result = raise (sig); - } - CATCH_MSVC_INVAL - { - result = -1; - errno = EINVAL; - } - DONE_MSVC_INVAL; - - return result; -} +/* Forward declaration. */ +static int raise_nothrow (int sig); # else # define raise_nothrow raise # endif @@ -61,12 +43,11 @@ raise_nothrow (int sig) # include -# define rpl_raise raise - #endif int -rpl_raise (int sig) +raise (int sig) +#undef raise { #if GNULIB_defined_signal_blocking && GNULIB_defined_SIGPIPE if (sig == SIGPIPE) @@ -79,3 +60,24 @@ rpl_raise (int sig) return kill (getpid (), sig); #endif } + +#if HAVE_RAISE && HAVE_MSVC_INVALID_PARAMETER_HANDLER +static int +raise_nothrow (int sig) +{ + int result; + + TRY_MSVC_INVAL + { + result = raise (sig); + } + CATCH_MSVC_INVAL + { + result = -1; + errno = EINVAL; + } + DONE_MSVC_INVAL; + + return result; +} +#endif -- 2.7.4