aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/mach/hurd
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2023-04-14 16:32:45 +0300
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-04-18 16:20:09 +0200
commit8895a99c10349e5b0bb57b64c229389169a312e0 (patch)
treed488af7f7b522eb2b578d32d81a94a574849fe65 /sysdeps/mach/hurd
parent589cccc8c92823f9d1d4abc448553bd80daf65f2 (diff)
downloadglibc-8895a99c10349e5b0bb57b64c229389169a312e0.tar
glibc-8895a99c10349e5b0bb57b64c229389169a312e0.tar.gz
glibc-8895a99c10349e5b0bb57b64c229389169a312e0.tar.bz2
glibc-8895a99c10349e5b0bb57b64c229389169a312e0.zip
hurd: Microoptimize sigreturn
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Diffstat (limited to 'sysdeps/mach/hurd')
-rw-r--r--sysdeps/mach/hurd/i386/sigreturn.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sysdeps/mach/hurd/i386/sigreturn.c b/sysdeps/mach/hurd/i386/sigreturn.c
index a0fc8891b7..1686734d3c 100644
--- a/sysdeps/mach/hurd/i386/sigreturn.c
+++ b/sysdeps/mach/hurd/i386/sigreturn.c
@@ -29,7 +29,12 @@ static void
__sigreturn2 (int *usp, struct sigcontext *scp)
{
mach_port_t reply_port;
- struct hurd_sigstate *ss = _hurd_self_sigstate ();
+ struct hurd_sigstate *ss;
+
+ /* We know the sigstate must be initialized by the call below, but the
+ compiler does not. Help it out a little bit by eliding the check that
+ _hurd_self_sigstate makes otherwise. */
+ ss = THREAD_GETMEM (THREAD_SELF, _hurd_sigstate);
_hurd_sigstate_unlock (ss);
/* Destroy the MiG reply port used by the signal handler, and restore the
@@ -44,7 +49,7 @@ __sigreturn2 (int *usp, struct sigcontext *scp)
do. */
reply_port = THREAD_GETMEM (THREAD_SELF, reply_port);
THREAD_SETMEM (THREAD_SELF, reply_port, MACH_PORT_DEAD);
- if (MACH_PORT_VALID (reply_port))
+ if (__glibc_likely (MACH_PORT_VALID (reply_port)))
(void) __mach_port_mod_refs (__mach_task_self (), reply_port,
MACH_PORT_RIGHT_RECEIVE, -1);
THREAD_SETMEM (THREAD_SELF, reply_port, scp->sc_reply_port);
@@ -69,6 +74,7 @@ __sigreturn2 (int *usp, struct sigcontext *scp)
/* Firewall. */
A (hlt);
#undef A
+ __builtin_unreachable ();
}
int
@@ -77,7 +83,7 @@ __sigreturn (struct sigcontext *scp)
struct hurd_sigstate *ss;
struct hurd_userlink *link = (void *) &scp[1];
- if (scp == NULL || (scp->sc_mask & _SIG_CANT_MASK))
+ if (__glibc_unlikely (scp == NULL || (scp->sc_mask & _SIG_CANT_MASK)))
{
errno = EINVAL;
return -1;