Mercurial > gnulib
changeset 39889:38e070a924c2
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 05 Oct 2018 21:53:24 +0200 |
parents | 281300b4ad17 |
children | 3b389d4449c2 |
files | ChangeLog lib/raise.c |
diffstat | 2 files changed, 38 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Oct 05 21:50:47 2018 +0200 +++ b/ChangeLog Fri Oct 05 21:53:24 2018 +0200 @@ -1,3 +1,11 @@ +2018-10-05 Bruno Haible <bruno@clisp.org> + + 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 <bruno@clisp.org> memcmp: Make it possible to namespace the defined symbol.
--- a/lib/raise.c Fri Oct 05 21:50:47 2018 +0200 +++ b/lib/raise.c Fri Oct 05 21:53:24 2018 +0200 @@ -31,9 +31,37 @@ # include "msvc-inval.h" # endif -# undef raise +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +/* Forward declaration. */ +static int raise_nothrow (int sig); +# else +# define raise_nothrow raise +# endif + +#else +/* An old Unix platform. */ + +# include <unistd.h> + +#endif -# if HAVE_MSVC_INVALID_PARAMETER_HANDLER +int +raise (int sig) +#undef raise +{ +#if GNULIB_defined_signal_blocking && GNULIB_defined_SIGPIPE + if (sig == SIGPIPE) + return _gl_raise_SIGPIPE (); +#endif + +#if HAVE_RAISE + return raise_nothrow (sig); +#else + return kill (getpid (), sig); +#endif +} + +#if HAVE_RAISE && HAVE_MSVC_INVALID_PARAMETER_HANDLER static int raise_nothrow (int sig) { @@ -52,30 +80,4 @@ return result; } -# else -# define raise_nothrow raise -# endif - -#else -/* An old Unix platform. */ - -# include <unistd.h> - -# define rpl_raise raise - #endif - -int -rpl_raise (int sig) -{ -#if GNULIB_defined_signal_blocking && GNULIB_defined_SIGPIPE - if (sig == SIGPIPE) - return _gl_raise_SIGPIPE (); -#endif - -#if HAVE_RAISE - return raise_nothrow (sig); -#else - return kill (getpid (), sig); -#endif -}