[1/7] hurd: Simplify _hurd_critical_section_lock a bit

Message ID 20230429131354.2507443-1-bugaevc@gmail.com
State Committed, archived
Headers
Series [1/7] hurd: Simplify _hurd_critical_section_lock a bit |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Sergey Bugaev April 29, 2023, 1:13 p.m. UTC
  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 <bugaevc@gmail.com>
---
 hurd/hurd/signal.h | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
  

Comments

Samuel Thibault April 29, 2023, 2:50 p.m. UTC | #1
Applied, thanks!

Sergey Bugaev, le sam. 29 avril 2023 16:13:48 +0300, a ecrit:
> 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 <bugaevc@gmail.com>
> ---
>  hurd/hurd/signal.h | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
> 
> diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h
> index 662e955e..302ca25e 100644
> --- a/hurd/hurd/signal.h
> +++ b/hurd/hurd/signal.h
> @@ -218,19 +218,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.  */
> -- 
> 2.40.1
>
  

Patch

diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h
index 662e955e..302ca25e 100644
--- a/hurd/hurd/signal.h
+++ b/hurd/hurd/signal.h
@@ -218,19 +218,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.  */