summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2022-09-05 06:59:43 +0000
committerLaurent Bercot <ska@appnovation.com>2022-09-05 06:59:43 +0000
commit61b4199fe43e94d6753290a62eb45363503e0deb (patch)
treed21b093b2e9aa4530e68b845d8368a43e9895034 /src/include
parent61e06f3b12afe464c3b4fcd23d4a3a07251c50ac (diff)
downloadskalibs-61b4199fe43e94d6753290a62eb45363503e0deb.tar.xz
Better NSIG detection and fix
Incredibly enough, OpenBSD defines NSIG correctly, so our workaround was not accurate. Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/skalibs/nsig.h20
-rw-r--r--src/include/skalibs/skalibs.h2
2 files changed, 13 insertions, 9 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
*/