about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-08-09 22:52:13 -0400
committerRich Felker <dalias@aerifal.cx>2012-08-09 22:52:13 -0400
commit2f437040e7911d9bef239588ea7ed6f4b9102922 (patch)
treecfb4950352818b7a3ed2f5be9d9425bbb0b7cd3a
parent83b42d94bd1009da6a95052d9ef0edeb1c73c8e4 (diff)
downloadmusl-2f437040e7911d9bef239588ea7ed6f4b9102922.tar.gz
musl-2f437040e7911d9bef239588ea7ed6f4b9102922.tar.xz
musl-2f437040e7911d9bef239588ea7ed6f4b9102922.zip
fix (hopefully) all hard-coded 8's for kernel sigset_t size
some minor changes to how hard-coded sets for thread-related purposes
are handled were also needed, since the old object sizes were not
necessarily sufficient. things have gotten a bit ugly in this area,
and i think a cleanup is in order at some point, but for now the goal
is just to get the code working on all supported archs including mips,
which was badly broken by linux rejecting syscalls with the wrong
sigset_t size.
-rw-r--r--src/internal/pthread_impl.h7
-rw-r--r--src/linux/epoll_pwait.c2
-rw-r--r--src/linux/signalfd.c2
-rw-r--r--src/select/pselect.c2
-rw-r--r--src/signal/raise.c5
-rw-r--r--src/signal/siglongjmp.c4
-rw-r--r--src/signal/sigpending.c2
-rw-r--r--src/signal/sigsuspend.c2
-rw-r--r--src/signal/sigtimedwait.c3
-rw-r--r--src/thread/pthread_create.c6
-rw-r--r--src/thread/pthread_self.c3
-rw-r--r--src/thread/pthread_sigmask.c4
-rw-r--r--src/thread/synccall.c6
-rw-r--r--src/time/timer_create.c3
14 files changed, 31 insertions, 20 deletions
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
index 46d8fdd2..56b92b22 100644
--- a/src/internal/pthread_impl.h
+++ b/src/internal/pthread_impl.h
@@ -90,9 +90,12 @@ struct __timer {
 #define SIGCANCEL 33
 #define SIGSYNCCALL 34
 
-#define SIGPT_SET ((sigset_t *)(unsigned long [1+(sizeof(long)==4)]){ \
+#define SIGALL_SET ((sigset_t *)(const unsigned long long [2]){ -1,-1 })
+#define SIGPT_SET \
+	((sigset_t *)(const unsigned long [__SYSCALL_SSLEN/sizeof(long)]){ \
 	[sizeof(long)==4] = 3UL<<(32*(sizeof(long)>4)) })
-#define SIGTIMER_SET ((sigset_t *)(unsigned long [1+(sizeof(long)==4)]){ \
+#define SIGTIMER_SET \
+	((sigset_t *)(const unsigned long [__SYSCALL_SSLEN/sizeof(long)]){ \
 	 0x80000000 })
 
 pthread_t __pthread_self_init(void);
diff --git a/src/linux/epoll_pwait.c b/src/linux/epoll_pwait.c
index 39ad5b77..3ecdbb59 100644
--- a/src/linux/epoll_pwait.c
+++ b/src/linux/epoll_pwait.c
@@ -3,5 +3,5 @@
 
 int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs)
 {
-	return syscall(SYS_epoll_pwait, fd, ev, cnt, to, sigs, 8);
+	return syscall(SYS_epoll_pwait, fd, ev, cnt, to, sigs, __SYSCALL_SSLEN);
 }
diff --git a/src/linux/signalfd.c b/src/linux/signalfd.c
index 99c35143..1a6c03c3 100644
--- a/src/linux/signalfd.c
+++ b/src/linux/signalfd.c
@@ -3,5 +3,5 @@
 
 int signalfd(int fd, const sigset_t *sigs, int flags)
 {
-	return syscall(SYS_signalfd, fd, sigs, 8);
+	return syscall(SYS_signalfd, fd, sigs, __SYSCALL_SSLEN);
 }
diff --git a/src/select/pselect.c b/src/select/pselect.c
index f28887ff..48fcefed 100644
--- a/src/select/pselect.c
+++ b/src/select/pselect.c
@@ -4,7 +4,7 @@
 
 int pselect(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, const struct timespec *ts, const sigset_t *mask)
 {
-	long data[2] = { (long)mask, 8 };
+	long data[2] = { (long)mask, __SYSCALL_SSLEN };
 	struct timespec ts_tmp;
 	if (ts) ts_tmp = *ts;
 	return syscall_cp(SYS_pselect6, n, rfds, wfds, efds, ts ? &ts_tmp : 0, data);
diff --git a/src/signal/raise.c b/src/signal/raise.c
index 71e0505b..c0814fad 100644
--- a/src/signal/raise.c
+++ b/src/signal/raise.c
@@ -2,15 +2,16 @@
 #include <errno.h>
 #include <stdint.h>
 #include "syscall.h"
+#include "pthread_impl.h"
 
 int raise(int sig)
 {
 	int pid, tid, ret;
 	sigset_t set;
-	__syscall(SYS_rt_sigprocmask, SIG_BLOCK, (uint64_t[]){-1}, &set, 8);
+	__syscall(SYS_rt_sigprocmask, SIG_BLOCK, SIGALL_SET, &set, __SYSCALL_SSLEN);
 	tid = syscall(SYS_gettid);
 	pid = syscall(SYS_getpid);
 	ret = syscall(SYS_tgkill, pid, tid, sig);
-	__syscall(SYS_rt_sigprocmask, SIG_SETMASK, &set, 0, 8);
+	__syscall(SYS_rt_sigprocmask, SIG_SETMASK, &set, 0, __SYSCALL_SSLEN);
 	return ret;
 }
diff --git a/src/signal/siglongjmp.c b/src/signal/siglongjmp.c
index 9b4a5398..e9a61314 100644
--- a/src/signal/siglongjmp.c
+++ b/src/signal/siglongjmp.c
@@ -5,7 +5,7 @@
 
 void siglongjmp(sigjmp_buf buf, int ret)
 {
-	if (buf->__fl)
-		__syscall(SYS_rt_sigprocmask, SIG_SETMASK, buf->__ss, 0, 8);
+	if (buf->__fl) __syscall(SYS_rt_sigprocmask, SIG_SETMASK,
+		buf->__ss, 0, __SYSCALL_SSLEN);
 	longjmp(buf->__jb, ret);
 }
diff --git a/src/signal/sigpending.c b/src/signal/sigpending.c
index f6b8972e..46ce3036 100644
--- a/src/signal/sigpending.c
+++ b/src/signal/sigpending.c
@@ -3,5 +3,5 @@
 
 int sigpending(sigset_t *set)
 {
-	return syscall(SYS_rt_sigpending, set, 8);
+	return syscall(SYS_rt_sigpending, set, __SYSCALL_SSLEN);
 }
diff --git a/src/signal/sigsuspend.c b/src/signal/sigsuspend.c
index cd3a7b59..bdfaeee0 100644
--- a/src/signal/sigsuspend.c
+++ b/src/signal/sigsuspend.c
@@ -4,5 +4,5 @@
 
 int sigsuspend(const sigset_t *mask)
 {
-	return syscall_cp(SYS_rt_sigsuspend, mask, 8);
+	return syscall_cp(SYS_rt_sigsuspend, mask, __SYSCALL_SSLEN);
 }
diff --git a/src/signal/sigtimedwait.c b/src/signal/sigtimedwait.c
index 7eea58ab..f62db2f3 100644
--- a/src/signal/sigtimedwait.c
+++ b/src/signal/sigtimedwait.c
@@ -6,7 +6,8 @@
 int sigtimedwait(const sigset_t *mask, siginfo_t *si, const struct timespec *timeout)
 {
 	int ret;
-	do ret = syscall_cp(SYS_rt_sigtimedwait, mask, si, timeout, 8);
+	do ret = syscall_cp(SYS_rt_sigtimedwait, mask,
+		si, timeout, __SYSCALL_SSLEN);
 	while (ret<0 && errno==EINTR);
 	return ret;
 }
diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
index 94dc308d..52b48d6f 100644
--- a/src/thread/pthread_create.c
+++ b/src/thread/pthread_create.c
@@ -38,7 +38,8 @@ void pthread_exit(void *result)
 	if (self->detached && self->map_base) {
 		if (self->detached == 2)
 			__syscall(SYS_set_tid_address, 0);
-		__syscall(SYS_rt_sigprocmask, SIG_BLOCK, (uint64_t[]){-1},0,8);
+		__syscall(SYS_rt_sigprocmask, SIG_BLOCK,
+			SIGALL_SET, 0, __SYSCALL_SSLEN);
 		__unmapself(self->map_base, self->map_size);
 	}
 
@@ -61,7 +62,8 @@ static int start(void *p)
 {
 	pthread_t self = p;
 	if (self->unblock_cancel)
-		__syscall(SYS_rt_sigprocmask, SIG_UNBLOCK, SIGPT_SET, 0, 8);
+		__syscall(SYS_rt_sigprocmask, SIG_UNBLOCK,
+			SIGPT_SET, 0, __SYSCALL_SSLEN);
 	pthread_exit(self->start(self->start_arg));
 	return 0;
 }
diff --git a/src/thread/pthread_self.c b/src/thread/pthread_self.c
index f68896f7..a8cc80b5 100644
--- a/src/thread/pthread_self.c
+++ b/src/thread/pthread_self.c
@@ -8,7 +8,8 @@ weak_alias(dummy, __pthread_tsd_main);
 
 static int init_main_thread()
 {
-	__syscall(SYS_rt_sigprocmask, SIG_UNBLOCK, SIGPT_SET, 0, 8);
+	__syscall(SYS_rt_sigprocmask, SIG_UNBLOCK,
+		SIGPT_SET, 0, __SYSCALL_SSLEN);
 	if (__set_thread_area(&main_thread) < 0) return -1;
 	main_thread.canceldisable = libc.canceldisable;
 	main_thread.tsd = (void **)__pthread_tsd_main;
diff --git a/src/thread/pthread_sigmask.c b/src/thread/pthread_sigmask.c
index decc38f8..cddc2bca 100644
--- a/src/thread/pthread_sigmask.c
+++ b/src/thread/pthread_sigmask.c
@@ -6,8 +6,8 @@
 int pthread_sigmask(int how, const sigset_t *set, sigset_t *old)
 {
 	int ret;
-	if (how > 2U) return EINVAL;
-	ret = -__syscall(SYS_rt_sigprocmask, how, set, old, 8);
+	if ((unsigned)how - SIG_BLOCK > 2U) return EINVAL;
+	ret = -__syscall(SYS_rt_sigprocmask, how, set, old, __SYSCALL_SSLEN);
 	if (!ret && old) {
 		if (sizeof old->__bits[0] == 8) {
 			old->__bits[0] &= ~0x380000000ULL;
diff --git a/src/thread/synccall.c b/src/thread/synccall.c
index 1520b3b4..fd377cb3 100644
--- a/src/thread/synccall.c
+++ b/src/thread/synccall.c
@@ -61,7 +61,8 @@ void __synccall(void (*func)(void *), void *ctx)
 
 	pthread_rwlock_wrlock(&lock);
 
-	__syscall(SYS_rt_sigprocmask, SIG_BLOCK, (uint64_t[]){-1}, &oldmask, 8);
+	__syscall(SYS_rt_sigprocmask, SIG_BLOCK, SIGALL_SET,
+		&oldmask, __SYSCALL_SSLEN);
 
 	sem_init(&chaindone, 0, 0);
 	sem_init(&chainlock, 0, 1);
@@ -93,7 +94,8 @@ void __synccall(void (*func)(void *), void *ctx)
 	sa.sa_handler = SIG_IGN;
 	__libc_sigaction(SIGSYNCCALL, &sa, 0);
 
-	__syscall(SYS_rt_sigprocmask, SIG_SETMASK, &oldmask, 0, 8);
+	__syscall(SYS_rt_sigprocmask, SIG_SETMASK,
+		&oldmask, 0, __SYSCALL_SSLEN);
 
 	pthread_rwlock_unlock(&lock);
 }
diff --git a/src/time/timer_create.c b/src/time/timer_create.c
index 6cff16fb..813678a1 100644
--- a/src/time/timer_create.c
+++ b/src/time/timer_create.c
@@ -51,7 +51,8 @@ static void install_handler()
 		.sa_flags = SA_SIGINFO | SA_RESTART
 	};
 	__libc_sigaction(SIGTIMER, &sa, 0);
-	__syscall(SYS_rt_sigprocmask, SIG_UNBLOCK, SIGTIMER_SET, 0, 8);
+	__syscall(SYS_rt_sigprocmask, SIG_UNBLOCK,
+		SIGTIMER_SET, 0, __SYSCALL_SSLEN);
 }
 
 static void *start(void *arg)