From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1792) id D8E453858C50; Sat, 29 Apr 2023 14:50:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D8E453858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682779831; bh=Lu/15H2NNyKTZuc6u/VLWMDCN7+SbX7XMa9SRt53MlA=; h=From:To:Subject:Date:From; b=qWO6LNfR0hDhUS0l+uPgOzdTlPuwXR3lzViVjiCNxGZUG4YzFaZ6kkTqhjB2N8mLL SXyEv2jGqiEMjnZ6y0DXqYxStGQ0Cm9pb5iB3mCLKQxZU0jYrVHz95doCZF/dfiMAj BfYUEHXrh3ODAbRCtGykLJLRF7vd9nafukLWVN2M= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Samuel Thibault To: glibc-cvs@sourceware.org Subject: [glibc] hurd: Simplify _hurd_critical_section_lock a bit X-Act-Checkin: glibc X-Git-Author: Sergey Bugaev X-Git-Refname: refs/heads/master X-Git-Oldrev: a443bd3fb233186038b8b483959ecb7978d1abea X-Git-Newrev: c287ecd99133cd82413ad99f2f167628b2df670c Message-Id: <20230429145031.D8E453858C50@sourceware.org> Date: Sat, 29 Apr 2023 14:50:31 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c287ecd99133cd82413ad99f2f167628b2df670c commit c287ecd99133cd82413ad99f2f167628b2df670c Author: Sergey Bugaev Date: Sat Apr 29 16:13:48 2023 +0300 hurd: Simplify _hurd_critical_section_lock a bit This block of code was doing exactly what _hurd_self_sigstate does; so just call that and let it do its job. Signed-off-by: Sergey Bugaev Message-Id: <20230429131354.2507443-1-bugaevc@gmail.com> Diff: --- hurd/hurd/signal.h | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h index 662e955e94..b8af6f289a 100644 --- a/hurd/hurd/signal.h +++ b/hurd/hurd/signal.h @@ -170,6 +170,11 @@ _hurd_self_sigstate (void) if (__glibc_unlikely (ss == NULL)) { thread_t self = __mach_thread_self (); + + /* The thread variable is unset; this must be the first time we've + asked for it. In this case, the critical section flag cannot + possible already be set. Look up our sigstate structure the slow + way. */ ss = _hurd_thread_sigstate (self); THREAD_SETMEM (THREAD_SELF, _hurd_sigstate, ss); __mach_port_deallocate (__mach_task_self (), self); @@ -218,19 +223,7 @@ _hurd_critical_section_lock (void) return NULL; #endif - ss = THREAD_GETMEM (THREAD_SELF, _hurd_sigstate); - if (ss == NULL) - { - thread_t self = __mach_thread_self (); - - /* The thread variable is unset; this must be the first time we've - asked for it. In this case, the critical section flag cannot - possible already be set. Look up our sigstate structure the slow - way. */ - ss = _hurd_thread_sigstate (self); - THREAD_SETMEM (THREAD_SELF, _hurd_sigstate, ss); - __mach_port_deallocate (__mach_task_self (), self); - } + ss = _hurd_self_sigstate (); if (! __spin_try_lock (&ss->critical_section_lock)) /* We are already in a critical section, so do nothing. */