diff options
Diffstat (limited to 'hurd/hurd/signal.h')
-rw-r--r-- | hurd/hurd/signal.h | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h index 0e3315a6fe..eb9b0ca423 100644 --- a/hurd/hurd/signal.h +++ b/hurd/hurd/signal.h @@ -40,7 +40,6 @@ #include <cthreads.h> /* For `struct mutex'. */ #include <setjmp.h> /* For `jmp_buf'. */ #include <spin-lock.h> -#include <hurd/threadvar.h> /* We cache sigstate in a threadvar. */ struct hurd_signal_preemptor; /* <hurd/sigpreempt.h> */ #if defined __USE_EXTERN_INLINES && defined _LIBC # if IS_IN (libc) || IS_IN (libpthread) @@ -139,11 +138,9 @@ extern struct hurd_sigstate *_hurd_self_sigstate (void) _HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate * _hurd_self_sigstate (void) { - struct hurd_sigstate **location = (struct hurd_sigstate **) - (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE); - if (*location == NULL) - *location = _hurd_thread_sigstate (__mach_thread_self ()); - return *location; + if (THREAD_SELF->_hurd_sigstate == NULL) + THREAD_SELF->_hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ()); + return THREAD_SELF->_hurd_sigstate; } # endif #endif @@ -180,16 +177,22 @@ extern void *_hurd_critical_section_lock (void); _HURD_SIGNAL_H_EXTERN_INLINE void * _hurd_critical_section_lock (void) { - struct hurd_sigstate **location = (struct hurd_sigstate **) - (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE); - struct hurd_sigstate *ss = *location; + struct hurd_sigstate *ss; + +#ifdef __LIBC_NO_TLS + if (__LIBC_NO_TLS()) + /* TLS is currently initializing, no need to enter critical section. */ + return NULL; +#endif + + ss = THREAD_SELF->_hurd_sigstate; if (ss == NULL) { /* 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 = *location = _hurd_thread_sigstate (__mach_thread_self ()); + ss = THREAD_SELF->_hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ()); } if (! __spin_try_lock (&ss->critical_section_lock)) |