diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/nsig.h | 13 | ||||
-rw-r--r-- | src/libstddjb/selfpipe_finish.c | 2 | ||||
-rw-r--r-- | src/libstddjb/selfpipe_trapset.c | 4 | ||||
-rw-r--r-- | src/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 index 040be2c..3b3fb32 100644 --- 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 index fd9f6c2..60899eb 100644 --- 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 index 519e37b..ad5ba10 100644 --- 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 index f682971..88c78ec 100644 --- 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 ; |