Mercurial > hg > octave-lyh > gnulib-hg
changeset 10689:5fbf24129e48
Take into account the role of SIGABRT_COMPAT on Windows 2008.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 21 Oct 2008 01:12:33 +0200 |
parents | 989b49566cae |
children | 01f3623813da |
files | ChangeLog lib/sigaction.c lib/sigprocmask.c |
diffstat | 3 files changed, 61 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-10-20 Bruno Haible <bruno@clisp.org> + + Take into account the role of SIGABRT_COMPAT on Windows 2008. + * lib/sigprocmask.c (SIGABRT_COMPAT, SIGABRT_COMPAT_MASK): New macros. + (sigismember, sigaddset, sigdelset, sigfillset, rpl_signal): Handle it + as an alias for SIGABRT. + * lib/sigaction.c (SIGABRT_COMPAT): New macro. + (sigaction): Map it to SIGABRT. + Reported by Ramiro Polla <ramiro.polla@gmail.com> via Eric Blake. + 2008-10-20 Bruno Haible <bruno@clisp.org> * lib/fts.c: Don't include lstat.h.
--- a/lib/sigaction.c +++ b/lib/sigaction.c @@ -64,6 +64,14 @@ # define SIGSTOP (-1) #endif +/* On native Windows, as of 2008, the signal SIGABRT_COMPAT is an alias + for the signal SIGABRT. Only one signal handler is stored for both + SIGABRT and SIGABRT_COMPAT. SIGABRT_COMPAT is not a signal of its own. */ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# undef SIGABRT_COMPAT +# define SIGABRT_COMPAT 6 +#endif + /* A signal handler. */ typedef void (*handler_t) (int signal); @@ -134,6 +142,11 @@ return -1; } + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + /* POSIX requires sigaction() to be async-signal-safe. In other words, if an asynchronous signal can occur while we are anywhere inside this function, the user's handler could then call
--- a/lib/sigprocmask.c +++ b/lib/sigprocmask.c @@ -43,6 +43,19 @@ # define SIGSTOP (-1) #endif +/* On native Windows, as of 2008, the signal SIGABRT_COMPAT is an alias + for the signal SIGABRT. Only one signal handler is stored for both + SIGABRT and SIGABRT_COMPAT. SIGABRT_COMPAT is not a signal of its own. */ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# undef SIGABRT_COMPAT +# define SIGABRT_COMPAT 6 +#endif +#ifdef SIGABRT_COMPAT +# define SIGABRT_COMPAT_MASK (1U << SIGABRT_COMPAT) +#else +# define SIGABRT_COMPAT_MASK 0 +#endif + typedef void (*handler_t) (int); /* Handling of gnulib defined signals. */ @@ -74,7 +87,14 @@ sigismember (const sigset_t *set, int sig) { if (sig >= 0 && sig < NSIG) - return (*set >> sig) & 1; + { + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + + return (*set >> sig) & 1; + } else return 0; } @@ -91,6 +111,11 @@ { if (sig >= 0 && sig < NSIG) { + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + *set |= 1U << sig; return 0; } @@ -106,6 +131,11 @@ { if (sig >= 0 && sig < NSIG) { + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + *set &= ~(1U << sig); return 0; } @@ -116,10 +146,11 @@ } } + int sigfillset (sigset_t *set) { - *set = (2U << (NSIG - 1)) - 1; + *set = ((2U << (NSIG - 1)) - 1) & ~ SIGABRT_COMPAT_MASK; return 0; } @@ -241,6 +272,11 @@ if (sig >= 0 && sig < NSIG && sig != SIGKILL && sig != SIGSTOP && handler != SIG_ERR) { + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + if (blocked_set & (1U << sig)) { /* POSIX states that sigprocmask and signal are both