summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/skalibs/nsig.h20
-rw-r--r--src/include/skalibs/skalibs.h2
-rw-r--r--src/libstddjb/selfpipe_trapset.c1
-rw-r--r--src/libstddjb/sig_catch.c10
4 files changed, 16 insertions, 17 deletions
diff --git a/src/include/skalibs/nsig.h b/src/include/skalibs/nsig.h
index 6dbddea..f6d0ee5 100644
--- a/src/include/skalibs/nsig.h
+++ b/src/include/skalibs/nsig.h
@@ -1,9 +1,8 @@
/* ISC license. */
/*
- This header MUST be paired with skalibs/nonposix.h AND
- skalibs/bsdsnowflake.h, both of which must be included
- before system headers.
+ This header MUST be paired with skalibs/nonposix.h,
+ which must be included before system headers.
*/
#ifndef SKALIBS_NSIG_H
@@ -18,17 +17,22 @@
# define NSIG (SIGMAX + 1)
# elif defined(_SIGMAX)
# define NSIG(_SIGMAX + 1)
-# elif defined(SKALIBS_BSD_SUCKS)
-# define NSIG 64
# else
# define NSIG 65
# endif
#endif
-#ifdef SKALIBS_BSD_SUCKS
-# define SKALIBS_NSIG (NSIG+1)
-#else
+/*
+ Some systems (FreeBSD, Darwin) incorrectly define NSIG as 32
+ (their highest signal number) when it should be 33 (highest plus one).
+ OpenBSD gets this right so we can't use SKALIBS_BSD_SUCKS.
+ The heuristic we use is: if NSIG is a power of two, it's wrong.
+*/
+
+#if NSIG & (NSIG - 1)
# define SKALIBS_NSIG NSIG
+#else
+# define SKALIBS_NSIG (NSIG+1)
#endif
#endif
diff --git a/src/include/skalibs/skalibs.h b/src/include/skalibs/skalibs.h
index 5e24fe2..c1eaf81 100644
--- a/src/include/skalibs/skalibs.h
+++ b/src/include/skalibs/skalibs.h
@@ -9,7 +9,7 @@
- skalibs/sysdeps.h: system-dependent feature test macros
- skalibs/nonposix.h: pre-system headers definitions for POSIX extensions
- skalibs/bsdsnowflake.h: pre-system headers BSD-specific workarounds
- - skalibs/nsig.h: SKALIBS_NSIG definition, requires nonposix+bsdsnowflake
+ - skalibs/nsig.h: SKALIBS_NSIG definition, requires nonposix
- skalibs/posixishard.h: post-system headers workarounds for conformance failures
*/
diff --git a/src/libstddjb/selfpipe_trapset.c b/src/libstddjb/selfpipe_trapset.c
index 9559c07..3bb64d4 100644
--- a/src/libstddjb/selfpipe_trapset.c
+++ b/src/libstddjb/selfpipe_trapset.c
@@ -30,7 +30,6 @@ int selfpipe_trapset (sigset_t const *set)
#else
#include <skalibs/nonposix.h>
-#include <skalibs/bsdsnowflake.h>
#include <errno.h>
#include <signal.h>
diff --git a/src/libstddjb/sig_catch.c b/src/libstddjb/sig_catch.c
index a11e317..1c106a0 100644
--- a/src/libstddjb/sig_catch.c
+++ b/src/libstddjb/sig_catch.c
@@ -3,7 +3,6 @@
/* MT-unsafe */
#include <skalibs/nonposix.h>
-#include <skalibs/bsdsnowflake.h>
#include <signal.h>
#include <errno.h>
@@ -13,8 +12,8 @@
#include <skalibs/nsig.h>
/*
- BSD fails sigaction() with EINVAL on non-catchable signals, whereas
- every reasonable OS succeeds and simply ignores the signal handler.
+ We don't want to fail on non-catchable signals,
+ even if sigaction() does.
*/
int sig_catch (int sig, sig_func_ref f)
@@ -22,8 +21,5 @@ int sig_catch (int sig, sig_func_ref f)
struct sigaction action = { .sa_handler = f, .sa_flags = SA_RESTART | SA_NOCLDSTOP } ;
sigfillset(&action.sa_mask) ;
return sigaction(sig, &action, 0) >= 0
-#ifdef SKALIBS_BSD_SUCKS
- || (errno == EINVAL && sig >= 1 && sig <= NSIG)
-#endif
- ;
+ || (errno == EINVAL && sig >= 1 && sig < SKALIBS_NSIG) ;
}