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.
14 files changed:
#define SIGCANCEL 33
#define SIGSYNCCALL 34
#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)) })
[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);
0x80000000 })
pthread_t __pthread_self_init(void);
int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs)
{
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);
int signalfd(int fd, const sigset_t *sigs, int flags)
{
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);
int pselect(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, const struct timespec *ts, const sigset_t *mask)
{
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);
struct timespec ts_tmp;
if (ts) ts_tmp = *ts;
return syscall_cp(SYS_pselect6, n, rfds, wfds, efds, ts ? &ts_tmp : 0, data);
#include <errno.h>
#include <stdint.h>
#include "syscall.h"
#include <errno.h>
#include <stdint.h>
#include "syscall.h"
+#include "pthread_impl.h"
int raise(int sig)
{
int pid, tid, ret;
sigset_t set;
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);
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);
void siglongjmp(sigjmp_buf buf, int ret)
{
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);
}
longjmp(buf->__jb, ret);
}
int sigpending(sigset_t *set)
{
int sigpending(sigset_t *set)
{
- return syscall(SYS_rt_sigpending, set, 8);
+ return syscall(SYS_rt_sigpending, set, __SYSCALL_SSLEN);
int sigsuspend(const sigset_t *mask)
{
int sigsuspend(const sigset_t *mask)
{
- return syscall_cp(SYS_rt_sigsuspend, mask, 8);
+ return syscall_cp(SYS_rt_sigsuspend, mask, __SYSCALL_SSLEN);
int sigtimedwait(const sigset_t *mask, siginfo_t *si, const struct timespec *timeout)
{
int ret;
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;
}
while (ret<0 && errno==EINTR);
return ret;
}
if (self->detached && self->map_base) {
if (self->detached == 2)
__syscall(SYS_set_tid_address, 0);
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);
}
__unmapself(self->map_base, self->map_size);
}
{
pthread_t self = p;
if (self->unblock_cancel)
{
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;
}
pthread_exit(self->start(self->start_arg));
return 0;
}
static int init_main_thread()
{
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;
if (__set_thread_area(&main_thread) < 0) return -1;
main_thread.canceldisable = libc.canceldisable;
main_thread.tsd = (void **)__pthread_tsd_main;
int pthread_sigmask(int how, const sigset_t *set, sigset_t *old)
{
int ret;
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;
if (!ret && old) {
if (sizeof old->__bits[0] == 8) {
old->__bits[0] &= ~0x380000000ULL;
pthread_rwlock_wrlock(&lock);
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);
sem_init(&chaindone, 0, 0);
sem_init(&chainlock, 0, 1);
sa.sa_handler = SIG_IGN;
__libc_sigaction(SIGSYNCCALL, &sa, 0);
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);
}
pthread_rwlock_unlock(&lock);
}
.sa_flags = SA_SIGINFO | SA_RESTART
};
__libc_sigaction(SIGTIMER, &sa, 0);
.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)
}
static void *start(void *arg)