[klibc] [klibc:ia64-signal-fix] signal: Move rt_sigaction() argument mangling to arch directories

klibc-bot for Ben Hutchings ben at decadent.org.uk
Fri Aug 28 12:36:04 PDT 2020


Commit-ID:  77c7ccc993d605eb7f6bef511017d28c1bb2d7e7
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=77c7ccc993d605eb7f6bef511017d28c1bb2d7e7
Author:     Ben Hutchings <ben at decadent.org.uk>
AuthorDate: Fri, 28 Aug 2020 19:21:47 +0100
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Fri, 28 Aug 2020 19:52:24 +0100

[klibc] signal: Move rt_sigaction() argument mangling to arch directories

On alpha, sparc, and sparc64, the rt_sigaction() system call takes an
additional parameter.  Define another wrapper function on those
architectures to handle this, instead of doing it directly in
sigaction().

This is preparation for fixing signal handling on ia64, which needs
a more complex wrapper.

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

---
 usr/klibc/SYSCALLS.def             |  4 ++--
 usr/klibc/arch/alpha/Kbuild        |  2 +-
 usr/klibc/arch/alpha/sigaction.c   | 16 ++++++++++++++++
 usr/klibc/arch/sparc/Kbuild        |  2 +-
 usr/klibc/arch/sparc/sigaction.c   | 21 +++++++++++++++++++++
 usr/klibc/arch/sparc64/Kbuild      |  2 +-
 usr/klibc/arch/sparc64/sigaction.c | 21 +++++++++++++++++++++
 usr/klibc/sigaction.c              | 23 +++--------------------
 8 files changed, 66 insertions(+), 25 deletions(-)

diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def
index b639fceb..16ad3830 100644
--- a/usr/klibc/SYSCALLS.def
+++ b/usr/klibc/SYSCALLS.def
@@ -207,8 +207,8 @@ ssize_t sendfile64,sendfile::sendfile(int, int, off_t *, size_t, off_t);
  */
 #if _KLIBC_USE_RT_SIG
 <!sparc,sparc64,alpha> int rt_sigaction::__rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t);
-<sparc,sparc64> int rt_sigaction::__rt_sigaction(int, const struct sigaction *, struct sigaction *, void *, size_t);
-<alpha> int rt_sigaction::__rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t, void *);
+<sparc,sparc64> int rt_sigaction::____rt_sigaction(int, const struct sigaction *, struct sigaction *, void *, size_t);
+<alpha> int rt_sigaction::____rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t, void *);
 int rt_sigsuspend::__rt_sigsuspend(const sigset_t *, size_t);
 int rt_sigpending::__rt_sigpending(sigset_t *, size_t);
 int rt_sigprocmask::__rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t);
diff --git a/usr/klibc/arch/alpha/Kbuild b/usr/klibc/arch/alpha/Kbuild
index 89386aea..715a430c 100644
--- a/usr/klibc/arch/alpha/Kbuild
+++ b/usr/klibc/arch/alpha/Kbuild
@@ -9,7 +9,7 @@
 
 always  := crt0.o
 targets := crt0.o
-klib-y := pipe.o setjmp.o sigreturn.o syscall.o sysdual.o
+klib-y := pipe.o sigaction.o setjmp.o sigreturn.o syscall.o sysdual.o
 
 # Special CFLAGS for the divide code
 DIVCFLAGS = $(KLIBCREQFLAGS) $(KLIBCARCHREQFLAGS) \
diff --git a/usr/klibc/arch/alpha/sigaction.c b/usr/klibc/arch/alpha/sigaction.c
new file mode 100644
index 00000000..53e830b5
--- /dev/null
+++ b/usr/klibc/arch/alpha/sigaction.c
@@ -0,0 +1,16 @@
+/*
+ * sigaction.c
+ */
+
+#include <signal.h>
+#include <sys/syscall.h>
+
+__extern void __sigreturn(void);
+__extern int ____rt_sigaction(int, const struct sigaction *, struct sigaction *,
+			      size_t, void (*)(void));
+
+int __rt_sigaction(int sig, const struct sigaction *act,
+		   struct sigaction *oact, size_t size)
+{
+	return ____rt_sigaction(sig, act, oact, size, &__sigreturn);
+}
diff --git a/usr/klibc/arch/sparc/Kbuild b/usr/klibc/arch/sparc/Kbuild
index d013f5d4..d92bbb0f 100644
--- a/usr/klibc/arch/sparc/Kbuild
+++ b/usr/klibc/arch/sparc/Kbuild
@@ -8,7 +8,7 @@ targets := crt0.o
 m4-targets := sdiv.o srem.o udiv.o urem.o
 
 klib-y := $(m4-targets) smul.o umul.o __muldi3.o
-klib-y += setjmp.o pipe.o syscall.o sysfork.o
+klib-y += setjmp.o pipe.o sigaction.o syscall.o sysfork.o
 
 klib-y += ../../libgcc/__ashldi3.o ../../libgcc/__ashrdi3.o
 klib-y += ../../libgcc/__lshrdi3.o ../../libgcc/__divdi3.o
diff --git a/usr/klibc/arch/sparc/sigaction.c b/usr/klibc/arch/sparc/sigaction.c
new file mode 100644
index 00000000..5c31a52b
--- /dev/null
+++ b/usr/klibc/arch/sparc/sigaction.c
@@ -0,0 +1,21 @@
+/*
+ * sigaction.c
+ */
+
+#include <signal.h>
+#include <sys/syscall.h>
+
+__extern void __sigreturn(void);
+__extern int ____rt_sigaction(int, const struct sigaction *, struct sigaction *,
+			      void (*)(void), size_t);
+
+int __rt_sigaction(int sig, const struct sigaction *act,
+		   struct sigaction *oact, size_t size)
+{
+	void (*restorer)(void);
+
+	restorer = (act && act->sa_flags & SA_RESTORER)
+		? (void (*)(void))((uintptr_t)act->sa_restorer - 8)
+		: NULL;
+	return ____rt_sigaction(sig, act, oact, restorer, size);
+}
diff --git a/usr/klibc/arch/sparc64/Kbuild b/usr/klibc/arch/sparc64/Kbuild
index 2854f698..dbc6c653 100644
--- a/usr/klibc/arch/sparc64/Kbuild
+++ b/usr/klibc/arch/sparc64/Kbuild
@@ -2,7 +2,7 @@
 # klibc files for sparc64
 #
 
-klib-y := pipe.o setjmp.o syscall.o sysfork.o
+klib-y := pipe.o setjmp.o sigaction.o syscall.o sysfork.o
 
 always  := crt0.o
 targets := crt0.o
diff --git a/usr/klibc/arch/sparc64/sigaction.c b/usr/klibc/arch/sparc64/sigaction.c
new file mode 100644
index 00000000..5c31a52b
--- /dev/null
+++ b/usr/klibc/arch/sparc64/sigaction.c
@@ -0,0 +1,21 @@
+/*
+ * sigaction.c
+ */
+
+#include <signal.h>
+#include <sys/syscall.h>
+
+__extern void __sigreturn(void);
+__extern int ____rt_sigaction(int, const struct sigaction *, struct sigaction *,
+			      void (*)(void), size_t);
+
+int __rt_sigaction(int sig, const struct sigaction *act,
+		   struct sigaction *oact, size_t size)
+{
+	void (*restorer)(void);
+
+	restorer = (act && act->sa_flags & SA_RESTORER)
+		? (void (*)(void))((uintptr_t)act->sa_restorer - 8)
+		: NULL;
+	return ____rt_sigaction(sig, act, oact, restorer, size);
+}
diff --git a/usr/klibc/sigaction.c b/usr/klibc/sigaction.c
index 789494db..d2223843 100644
--- a/usr/klibc/sigaction.c
+++ b/usr/klibc/sigaction.c
@@ -8,16 +8,11 @@
 #include <klibc/sysconfig.h>
 
 __extern void __sigreturn(void);
-__extern int __sigaction(int, const struct sigaction *, struct sigaction *);
-#ifdef __sparc__
-__extern int __rt_sigaction(int, const struct sigaction *, struct sigaction *,
-			    void (*)(void), size_t);
-#elif defined(__alpha__)
-__extern int __rt_sigaction(int, const struct sigaction *, struct sigaction *,
-			    size_t, void (*)(void));
-#else
+#if _KLIBC_USE_RT_SIG
 __extern int __rt_sigaction(int, const struct sigaction *, struct sigaction *,
 			    size_t);
+#else
+__extern int __sigaction(int, const struct sigaction *, struct sigaction *);
 #endif
 
 int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
@@ -51,19 +46,7 @@ int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
 			  + sizeof(sigset_t) == sizeof(struct sigaction)
 			  ? 1 : -1]);
 
-# ifdef __sparc__
-	{
-		void (*restorer)(void);
-		restorer = (act && act->sa_flags & SA_RESTORER)
-			? (void (*)(void))((uintptr_t)act->sa_restorer - 8)
-			: NULL;
-		rv = __rt_sigaction(sig, act, oact, restorer, sizeof(sigset_t));
-	}
-# elif defined(__alpha__)
-	rv = __rt_sigaction(sig, act, oact, sizeof(sigset_t), &__sigreturn);
-# else
 	rv = __rt_sigaction(sig, act, oact, sizeof(sigset_t));
-# endif
 #else
 	rv = __sigaction(sig, act, oact);
 #endif


More information about the klibc mailing list