[klibc] [klibc:master] signal: Add compile-time check on signal types

klibc-bot for Ben Hutchings ben at decadent.org.uk
Wed Aug 26 19:54:08 PDT 2020


Commit-ID:  b0c39f5ac8913b841037f8a90d83e55402c0ac25
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=b0c39f5ac8913b841037f8a90d83e55402c0ac25
Author:     Ben Hutchings <ben at decadent.org.uk>
AuthorDate: Thu, 27 Aug 2020 02:07:32 +0100
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Thu, 27 Aug 2020 03:51:16 +0100

[klibc] signal: Add compile-time check on signal types

If we are going to use the RT signal API, we must have the right type
definitions.  Check for signs that we have the old API definitions:

* _NSIG less than 64
* sigset_t too small for _NSIG
* sa_mask not at the end of struct sigaction

Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 usr/klibc/sigaction.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/usr/klibc/sigaction.c b/usr/klibc/sigaction.c
index 19a8a54b..30ef39ef 100644
--- a/usr/klibc/sigaction.c
+++ b/usr/klibc/sigaction.c
@@ -3,6 +3,7 @@
  */
 
 #include <signal.h>
+#include <stddef.h>
 #include <sys/syscall.h>
 #include <klibc/sysconfig.h>
 
@@ -38,6 +39,13 @@ int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
 #endif
 
 #if _KLIBC_USE_RT_SIG
+	/* Check that we have the right signal API definitions */
+	(void)sizeof(char[_NSIG >= 64 ? 1 : -1]);
+	(void)sizeof(char[sizeof(sigset_t) * 8 >= _NSIG ? 1 : -1]);
+	(void)sizeof(char[offsetof(struct sigaction, sa_mask)
+			  + sizeof(sigset_t) == sizeof(struct sigaction)
+			  ? 1 : -1]);
+
 # ifdef __sparc__
 	{
 		void (*restorer)(void);


More information about the klibc mailing list