> Authentication-Results: xs4all.nl; spf=pass smtp.mailfrom=openbsd.org;
> dkim=pass header.d=gmail.com; dmarc=pass header.from=gmail.com
> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
> d=gmail.com; s=20120113;
> h=date:from:to:subject:message-id:user-agent:mime-version;
> bh=wHI+HGvmVGdQXRWGopuROd9A3G8cQCYiUyi2sLrp+YM=;
> b=JiVNqPKe+7ZynDMg4qS9phlxzK7tYFbvc1h6987UtaHclHKbbucd7EO4hFXrfD0i57
> +tk8sg6JohkfSGkdin55DrAWFNY/hWEbiLlZuTGvp63ijxLZLtHS1FNB4kuwwYJWmAU5
> d/Kc+H4IMWq68pnfUzTuPkzvG2CptRgQduBa1ofBHWhCdM+3F6AVZFeWaKprUdFkuO/Z
> i85AMmekwCGnFWZjqSIU/PJoHQQxokHfeRPneM1kldw6A0pTNf9ltzVIyNvfsxmk7P20
> pEHP5jTiTz1mPRHUhGnSgkMHKUDAWw+/9s5PYFQGrgHoekUc2DZ0P3w/Dg1wITZHWYim
> /b+A==
> X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
> d=1e100.net; s=20130820;
> h=x-gm-message-state:date:from:to:subject:message-id:user-agent
> :mime-version;
> bh=wHI+HGvmVGdQXRWGopuROd9A3G8cQCYiUyi2sLrp+YM=;
> b=UzqadVZQO8CG6J2AH3DEKNBNoOjCAeqcaZDEhaIyN19jcdwumGmCiHFojMktvZMiEA
> 33rNpiYNTOfkPbMQRVjtWbh/1qiSvFGGGXHJnzuhj4MnLyAse30ejwWsXKBDCmjiY77p
> 8XOyvmrbTZULKD5hw7xPhufLn1/8d6MMmx0VZ4lLJdnvinvpwQ55teSoraRUCGyEZ7Xn
> 0bykIJQ+sLMNghJnefa3FLdqczSI4FX5ydZeqonUa84sxmrm6Mo5M9148CiKpQKChZ5c
> n9zzzBK0y5vTdtfbuOc5xi/Rv7Q0GdW4RbAb3+4dHY+jtfai6LCBcmYxmtteUU5Sdapu
> 3L1w==
> X-Gm-Message-State:
> AD7BkJL5G3+QB5yM+yzySAzHqSe1KyaC3slZ4b6IRR7ZIZsiE8FP8RHnGWL5xTokVGhq8g==
> X-Received: by 10.98.86.28 with SMTP id k28mr3937255pfb.43.1459576045404;
> Fri, 01 Apr 2016 22:47:25 -0700 (PDT)
> Date: Fri, 1 Apr 2016 22:47:13 -0700
> From: Philip Guenther <[email protected]>
> X-X-Sender: [email protected]
> List-Owner: <mailto:[email protected]>
> X-Loop: [email protected]
> Sender: [email protected]
> X-XS4ALL-DNSBL-Checked: mxdrop303.xs4all.net checked 192.43.244.163 against
> DNS blacklists
> X-CNFS-Analysis: v=2.1 cv=Q6IvmNCa c=1 sm=0 tr=0
> a=A3duGc4wJ8K8BtNzzvyz4A==:117 a=A3duGc4wJ8K8BtNzzvyz4A==:17
> a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10
> a=kj9zAlcOel0A:10 a=kziv93cY1bsA:10 a=mkKYH3Xk5Cu4iesHknEA:9
> a=CjuIK1q_8ugA:10
> X-Virus-Scanned: by XS4ALL Virus Scanner
> X-XS4ALL-Spam-Score: -0.1 () DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU,
> FREEMAIL_FROM, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD
> X-XS4ALL-Spam: NO
> Envelope-To: [email protected]
>
>
> This diff eliminates the need to _invoke_ syscalls via their aliases with
> the '_thread_sys_' prefix, and uses that for a few syscalls that didn't
> but should have.
>
> This is done via the REDIRECT_SYSCALL() macro which builds on the same gcc
> extensions that the libc cleanup this fall did. Applying that to
> sigaction(), sigprocmask(), and thrkill() makes the code easier to read
> without changing the resulting generated objects.
>
> After that, applying it to getthrid(), sysctl(), and isssetugid() keeps
> libpthread from depending on names that are in the reserved namespace.
>
> The sched_yield() declaration in rthread.h is actually unnecessary:
> <pthread.h> pulls in <sched.h> which has the official declaration for it,
> so delete it.
>
> check_sym report:
> No dynamic export changes
> External reference changes:
> added:
> _thread_sys_getthrid
> _thread_sys_issetugid
> _thread_sys_sysctl
>
> removed:
> getthrid
> issetugid
> sysctl
>
> ok?
ok kettenis@
> Index: rthread.h
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/librthread/rthread.h,v
> retrieving revision 1.55
> diff -u -p -r1.55 rthread.h
> --- rthread.h 27 Jan 2016 08:40:05 -0000 1.55
> +++ rthread.h 2 Apr 2016 05:34:27 -0000
> @@ -233,15 +233,10 @@ void _leave_delayed_cancel(pthread_t, in
>
> 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);
> -
> Index: rthread.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/librthread/rthread.c,v
> retrieving revision 1.88
> diff -u -p -r1.88 rthread.c
> --- rthread.c 20 Mar 2016 02:30:28 -0000 1.88
> +++ rthread.c 2 Apr 2016 05:35:17 -0000
> @@ -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);
> }
> }
> Index: rthread_debug.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/librthread/rthread_debug.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 rthread_debug.c
> --- rthread_debug.c 13 Mar 2012 05:51:30 -0000 1.3
> +++ rthread_debug.c 31 Mar 2016 23:23:42 -0000
> @@ -11,6 +11,8 @@
>
> #include "rthread.h"
>
> +REDIRECT_SYSCALL(issetugid);
> +
> int _rthread_debug_level;
>
> /*
> Index: rthread_fork.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/librthread/rthread_fork.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 rthread_fork.c
> --- rthread_fork.c 27 Jan 2016 08:40:05 -0000 1.15
> +++ rthread_fork.c 2 Apr 2016 05:35:50 -0000
> @@ -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);
> Index: rthread_np.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/librthread/rthread_np.c,v
> retrieving revision 1.17
> diff -u -p -r1.17 rthread_np.c
> --- rthread_np.c 24 Jan 2015 10:35:33 -0000 1.17
> +++ rthread_np.c 31 Mar 2016 23:00:23 -0000
> @@ -36,6 +36,8 @@
>
> #include "rthread.h"
>
> +REDIRECT_SYSCALL(sysctl);
> +
> void
> pthread_set_name_np(pthread_t thread, const char *name)
> {
>
>