skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit b15c4329b10e422d85673e1708ce20bb0116598e
parent 94caf2cee5c03e037c465648eac8cb1dd32c7c73
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Fri, 28 Apr 2017 12:12:06 +0000

 Change SKALIBS_NSIG to SKALIBS_DEFAULT_NSIG and NSIG to SKALIBS_NSIG to accommodate OpenBSD snowflakiness

Diffstat:
Msrc/include/skalibs/nsig.h | 13+++++++++++--
Msrc/libstddjb/selfpipe_finish.c | 2+-
Msrc/libstddjb/selfpipe_trapset.c | 4++--
Msrc/libstddjb/sig_stack.c | 8++++----
4 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/include/skalibs/nsig.h b/src/include/skalibs/nsig.h @@ -9,10 +9,19 @@ #include <signal.h> -#define SKALIBS_NSIG 65 +#define SKALIBS_DEFAULT_NSIG 65 #ifndef NSIG -# define NSIG SKALIBS_NSIG +# define NSIG SKALIBS_DEFAULT_NSIG +#endif + + + /* OpenBSD is a fucking snowflake */ + +#ifdef __OpenBSD__ +#define SKALIBS_NSIG (NSIG-1) +#else +#define SKALIBS_NSIG NSIG #endif #endif diff --git a/src/libstddjb/selfpipe_finish.c b/src/libstddjb/selfpipe_finish.c @@ -31,7 +31,7 @@ void selfpipe_finish (void) void selfpipe_finish (void) { - sig_restoreto(&selfpipe_caught, NSIG-1) ; + sig_restoreto(&selfpipe_caught, SKALIBS_NSIG-1) ; sigemptyset(&selfpipe_caught) ; fd_close(selfpipe[1]) ; fd_close(selfpipe[0]) ; diff --git a/src/libstddjb/selfpipe_trapset.c b/src/libstddjb/selfpipe_trapset.c @@ -40,7 +40,7 @@ int selfpipe_trapset (sigset_t const *set) { unsigned int i = 1 ; if (selfpipe_fd < 0) return (errno = EBADF, -1) ; - for (; i < NSIG ; i++) + for (; i < SKALIBS_NSIG ; i++) { int h = sigismember(set, i) ; if (h < 0) continue ; @@ -53,7 +53,7 @@ int selfpipe_trapset (sigset_t const *set) if (sig_restore(i) < 0) break ; } } - if (i < NSIG) + if (i < SKALIBS_NSIG) { int e = errno ; sig_restoreto(set, i) ; diff --git a/src/libstddjb/sig_stack.c b/src/libstddjb/sig_stack.c @@ -6,12 +6,12 @@ #include <skalibs/sig.h> #include <skalibs/nsig.h> -static struct skasigaction skasigstack[NSIG-1][SIGSTACKSIZE] ; -static unsigned int sigsp[NSIG-1] ; +static struct skasigaction skasigstack[SKALIBS_NSIG-1][SIGSTACKSIZE] ; +static unsigned int sigsp[SKALIBS_NSIG-1] ; int sig_pusha (int sig, struct skasigaction const *ssa) { - if ((sig <= 0) || (sig >= NSIG)) return (errno = EINVAL, -1) ; + if ((sig <= 0) || (sig >= SKALIBS_NSIG)) return (errno = EINVAL, -1) ; if (sigsp[sig-1] >= SIGSTACKSIZE) return (errno = ENOBUFS, -1) ; if (skasigaction(sig, ssa, &skasigstack[sig-1][sigsp[sig-1]]) == -1) return -1 ; @@ -20,7 +20,7 @@ int sig_pusha (int sig, struct skasigaction const *ssa) int sig_pop (int sig) { - if ((sig <= 0) || (sig >= NSIG)) return (errno = EINVAL, -1) ; + if ((sig <= 0) || (sig >= SKALIBS_NSIG)) return (errno = EINVAL, -1) ; if (!sigsp[sig-1]) return (errno = EFAULT, -1); if (skasigaction(sig, &skasigstack[sig-1][sigsp[sig-1]-1], 0) == -1) return -1 ;