about summary refs log tree commit diff
path: root/src/signal
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-07-11 02:44:14 -0400
committerRich Felker <dalias@aerifal.cx>2012-07-11 02:44:14 -0400
commitfcaec912ed406659832f452e71a6c965308362dd (patch)
tree3164466a2bc9e17b5e34b95fa61bb731692eb4c1 /src/signal
parente864a29090459c98d106f6f74a16b3558e18fdca (diff)
downloadmusl-fcaec912ed406659832f452e71a6c965308362dd.tar.gz
musl-fcaec912ed406659832f452e71a6c965308362dd.tar.xz
musl-fcaec912ed406659832f452e71a6c965308362dd.zip
changes to kernel sigaction struct handling in preparation for mips port
Diffstat (limited to 'src/signal')
-rw-r--r--src/signal/restore.c10
-rw-r--r--src/signal/sigaction.c21
2 files changed, 17 insertions, 14 deletions
diff --git a/src/signal/restore.c b/src/signal/restore.c
index e69de29b..873b867e 100644
--- a/src/signal/restore.c
+++ b/src/signal/restore.c
@@ -0,0 +1,10 @@
+/* These functions will not work, but suffice for targets where the
+ * kernel sigaction structure does not actually use sa_restorer. */
+
+void __restore()
+{
+}
+
+void __restore_rt()
+{
+}
diff --git a/src/signal/sigaction.c b/src/signal/sigaction.c
index 5bc9383b..089e9b80 100644
--- a/src/signal/sigaction.c
+++ b/src/signal/sigaction.c
@@ -4,6 +4,7 @@
 #include "syscall.h"
 #include "pthread_impl.h"
 #include "libc.h"
+#include "ksigaction.h"
 
 void __restore(), __restore_rt();
 
@@ -12,28 +13,20 @@ weak_alias(dummy, __pthread_self_def);
 
 int __libc_sigaction(int sig, const struct sigaction *sa, struct sigaction *old)
 {
-	struct {
-		void *handler;
-		unsigned long flags;
-		void (*restorer)(void);
-		sigset_t mask;
-	} ksa, kold;
-	long pksa=0, pkold=0;
+	struct k_sigaction ksa, *pksa=0;
 	if (sa) {
 		ksa.handler = sa->sa_handler;
 		ksa.flags = sa->sa_flags | SA_RESTORER;
 		ksa.restorer = (sa->sa_flags & SA_SIGINFO) ? __restore_rt : __restore;
-		ksa.mask = sa->sa_mask;
-		pksa = (long)&ksa;
+		memcpy(&ksa.mask, &sa->sa_mask, sizeof ksa.mask);
 	}
-	if (old) pkold = (long)&kold;
 	__pthread_self_def();
-	if (syscall(SYS_rt_sigaction, sig, pksa, pkold, 8))
+	if (syscall(SYS_rt_sigaction, sig, sa?&ksa:0, old?&ksa:0, sizeof ksa.mask))
 		return -1;
 	if (old) {
-		old->sa_handler = kold.handler;
-		old->sa_flags = kold.flags;
-		old->sa_mask = kold.mask;
+		old->sa_handler = ksa.handler;
+		old->sa_flags = ksa.flags;
+		memcpy(&old->sa_mask, &ksa.mask, sizeof ksa.mask);
 	}
 	return 0;
 }