summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2016-04-02 19:00:52 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2016-04-02 19:00:52 +0000
commitfdde865858c3237682a6b0ab261839d3b408b949 (patch)
tree710ac701b38f8dc6bb162ed86c61bc5c1944aa79 /lib
parent41ae94909625acb9bfbab33ce23bd8a71df68dcf (diff)
Eliminate the need to explicitly invoke syscalls via their _thread_sys_*
aliases by using a macro REDIRECT_SYSCALL() to map the symbols. Apply that to getthrid(), sysctl(), and issetugid() as well. ok mpi@ beck@
Diffstat (limited to 'lib')
-rw-r--r--lib/librthread/rthread.c25
-rw-r--r--lib/librthread/rthread.h11
-rw-r--r--lib/librthread/rthread_debug.c4
-rw-r--r--lib/librthread/rthread_fork.c4
-rw-r--r--lib/librthread/rthread_np.c4
5 files changed, 32 insertions, 16 deletions
diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c
index 4d7254912d2..1a70da97a0c 100644
--- a/lib/librthread/rthread.c
+++ b/lib/librthread/rthread.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread.c,v 1.88 2016/03/20 02:30:28 guenther Exp $ */
+/* $OpenBSD: rthread.c,v 1.89 2016/04/02 19:00:51 guenther Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -47,6 +47,21 @@
#include "rthread.h"
#include "tcb.h"
+/*
+ * Call nonstandard functions via names in the reserved namespace:
+ * NOT YET dlctl() -> _dlctl()
+ * getthrid -> _thread_sys_getthrid
+ */
+REDIRECT_SYSCALL(getthrid);
+
+/*
+ * libc's signal wrappers hide SIGTHR; we need to call the real syscall
+ * stubs _thread_sys_* directly.
+ */
+REDIRECT_SYSCALL(sigaction);
+REDIRECT_SYSCALL(sigprocmask);
+REDIRECT_SYSCALL(thrkill);
+
static int concurrency_level; /* not used */
struct _spinlock _SPINLOCK_UNLOCKED_ASSIGN = _SPINLOCK_UNLOCKED;
@@ -207,9 +222,9 @@ _rthread_init(void)
memset(&sa, 0, sizeof(sa));
sigemptyset(&sa.sa_mask);
sa.sa_handler = sigthr_handler;
- _thread_sys_sigaction(SIGTHR, &sa, NULL);
+ sigaction(SIGTHR, &sa, NULL);
sigaddset(&sa.sa_mask, SIGTHR);
- _thread_sys_sigprocmask(SIG_UNBLOCK, &sa.sa_mask, NULL);
+ sigprocmask(SIG_UNBLOCK, &sa.sa_mask, NULL);
return (0);
}
@@ -463,7 +478,7 @@ pthread_kill(pthread_t thread, int sig)
{
if (sig == SIGTHR)
return (EINVAL);
- if (_thread_sys_thrkill(thread->tid, sig, thread->tcb))
+ if (thrkill(thread->tid, sig, thread->tcb))
return (errno);
return (0);
}
@@ -487,7 +502,7 @@ pthread_cancel(pthread_t thread)
if (thread->flags & THREAD_CANCEL_ENABLE) {
_spinunlock(&thread->flags_lock);
- _thread_sys_thrkill(tid, SIGTHR, thread->tcb);
+ thrkill(tid, SIGTHR, thread->tcb);
return (0);
}
}
diff --git a/lib/librthread/rthread.h b/lib/librthread/rthread.h
index 0b699b525cb..284356fb857 100644
--- a/lib/librthread/rthread.h
+++ b/lib/librthread/rthread.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread.h,v 1.55 2016/01/27 08:40:05 kettenis Exp $ */
+/* $OpenBSD: rthread.h,v 1.56 2016/04/02 19:00:51 guenther Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -233,15 +233,10 @@ void _leave_delayed_cancel(pthread_t, int);
void _thread_dump_info(void);
-/* syscalls */
+/* syscalls not declared in system headers */
+#define REDIRECT_SYSCALL(x) typeof(x) x asm("_thread_sys_"#x)
void __threxit(pid_t *);
int __thrsleep(const volatile void *, clockid_t, const struct timespec *,
volatile void *, const int *);
int __thrwakeup(const volatile void *, int n);
int __thrsigdivert(sigset_t, siginfo_t *, const struct timespec *);
-int sched_yield(void);
-int _thread_sys_sigaction(int, const struct sigaction *,
- struct sigaction *);
-int _thread_sys_sigprocmask(int, const sigset_t *, sigset_t *);
-int _thread_sys_thrkill(pid_t _tid, int _signum, void *_tcb);
-
diff --git a/lib/librthread/rthread_debug.c b/lib/librthread/rthread_debug.c
index bca185afbaf..b2c73a1a0f8 100644
--- a/lib/librthread/rthread_debug.c
+++ b/lib/librthread/rthread_debug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_debug.c,v 1.3 2012/03/13 05:51:30 guenther Exp $ */
+/* $OpenBSD: rthread_debug.c,v 1.4 2016/04/02 19:00:51 guenther Exp $ */
/* $snafu: rthread_debug.c,v 1.2 2004/12/09 18:41:44 marc Exp $ */
/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
@@ -11,6 +11,8 @@
#include "rthread.h"
+REDIRECT_SYSCALL(issetugid);
+
int _rthread_debug_level;
/*
diff --git a/lib/librthread/rthread_fork.c b/lib/librthread/rthread_fork.c
index e6d632f90bf..3f7a5faa32c 100644
--- a/lib/librthread/rthread_fork.c
+++ b/lib/librthread/rthread_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_fork.c,v 1.15 2016/01/27 08:40:05 kettenis Exp $ */
+/* $OpenBSD: rthread_fork.c,v 1.16 2016/04/02 19:00:51 guenther Exp $ */
/*
* Copyright (c) 2008 Kurt Miller <kurt@openbsd.org>
@@ -45,6 +45,8 @@
#include "rthread.h"
+REDIRECT_SYSCALL(getthrid);
+
pid_t _thread_sys_fork(void);
pid_t _thread_sys_vfork(void);
pid_t _dofork(int);
diff --git a/lib/librthread/rthread_np.c b/lib/librthread/rthread_np.c
index 656db4fdb0b..ed866820c27 100644
--- a/lib/librthread/rthread_np.c
+++ b/lib/librthread/rthread_np.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_np.c,v 1.17 2015/01/24 10:35:33 kettenis Exp $ */
+/* $OpenBSD: rthread_np.c,v 1.18 2016/04/02 19:00:51 guenther Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* Copyright (c) 2005 Otto Moerbeek <otto@openbsd.org>
@@ -36,6 +36,8 @@
#include "rthread.h"
+REDIRECT_SYSCALL(sysctl);
+
void
pthread_set_name_np(pthread_t thread, const char *name)
{