aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2020-08-28 19:37:19 +0100
committerBen Hutchings <ben@decadent.org.uk>2020-08-29 17:22:38 +0100
commit755b07d826618779a2232199cb53e2a44809ad89 (patch)
tree2096a0490cf132b9419ebec63ed9102ba767396e
parent77c7ccc993d605eb7f6bef511017d28c1bb2d7e7 (diff)
downloadklibc-755b07d826618779a2232199cb53e2a44809ad89.tar.gz
[klibc] signal: Add config flag for additional sigaction fixup
On ia64, sigaction() needs to make further changes to the given struct sigaction. Add a config flag for this, that forces copying of struct sigaction. Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--usr/include/klibc/sysconfig.h11
-rw-r--r--usr/klibc/sigaction.c20
2 files changed, 25 insertions, 6 deletions
diff --git a/usr/include/klibc/sysconfig.h b/usr/include/klibc/sysconfig.h
index 5722e04f8c57b..d658ad308714c 100644
--- a/usr/include/klibc/sysconfig.h
+++ b/usr/include/klibc/sysconfig.h
@@ -177,6 +177,17 @@
/*
+ * _KLIBC_NEEDS_SIGACTION_FIXUP
+ *
+ * On some architectures, struct sigaction needs additional
+ * changes before passing to the kernel.
+ */
+#ifndef _KLIBC_NEEDS_SIGACTION_FIXUP
+# define _KLIBC_NEEDS_SIGACTION_FIXUP 0
+#endif
+
+
+/*
* _KLIBC_STATFS_F_TYPE_64:
*
* This indicates that the f_type, f_bsize, f_namelen,
diff --git a/usr/klibc/sigaction.c b/usr/klibc/sigaction.c
index d2223843654af..a8181a4102d10 100644
--- a/usr/klibc/sigaction.c
+++ b/usr/klibc/sigaction.c
@@ -8,11 +8,17 @@
#include <klibc/sysconfig.h>
__extern void __sigreturn(void);
+
+#if _KLIBC_NEEDS_SIGACTION_FIXUP
+typedef struct sigaction *act_type;
+#else
+typedef const struct sigaction *act_type;
+#endif
+
#if _KLIBC_USE_RT_SIG
-__extern int __rt_sigaction(int, const struct sigaction *, struct sigaction *,
- size_t);
+__extern int __rt_sigaction(int, act_type, struct sigaction *, size_t);
#else
-__extern int __sigaction(int, const struct sigaction *, struct sigaction *);
+__extern int __sigaction(int, act_type, struct sigaction *);
#endif
int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
@@ -28,7 +34,9 @@ int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
struct sigaction sa;
int rv;
- if (act && (act->sa_flags & needed_flags) != needed_flags) {
+ if (act &&
+ ((act->sa_flags & needed_flags) != needed_flags ||
+ _KLIBC_NEEDS_SIGACTION_FIXUP)) {
sa = *act;
sa.sa_flags |= needed_flags;
#if _KLIBC_NEEDS_SA_RESTORER
@@ -46,9 +54,9 @@ int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
+ sizeof(sigset_t) == sizeof(struct sigaction)
? 1 : -1]);
- rv = __rt_sigaction(sig, act, oact, sizeof(sigset_t));
+ rv = __rt_sigaction(sig, (act_type)act, oact, sizeof(sigset_t));
#else
- rv = __sigaction(sig, act, oact);
+ rv = __sigaction(sig, (act_type)act, oact);
#endif
#if _KLIBC_NEEDS_SA_RESTORER