summaryrefslogtreecommitdiff
path: root/hurd
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2013-10-20 18:13:31 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2013-10-20 18:13:31 +0200
commitc85d2864b23774e723c8e4610ac0cd737dfa40a4 (patch)
tree37718e06b5b0b1452d02e9353d162344ab45b3ff /hurd
parent1b8fb80cd64c4250c7ba7d50941699c96e2c8741 (diff)
Convert sigstate to TLS
Diffstat (limited to 'hurd')
-rw-r--r--hurd/hurd/signal.h23
-rw-r--r--hurd/hurdsig.c3
2 files changed, 17 insertions, 9 deletions
diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h
index d4079efe00..1efa4a29be 100644
--- a/hurd/hurd/signal.h
+++ b/hurd/hurd/signal.h
@@ -129,14 +129,13 @@ extern struct hurd_sigstate *_hurd_self_sigstate (void)
#define _HURD_SIGNAL_H_EXTERN_INLINE __extern_inline
#endif
+extern __thread struct hurd_sigstate *_hurd_sigstate;
_HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate *
_hurd_self_sigstate (void)
{
- struct hurd_sigstate **location =
- (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE);
- if (*location == NULL)
- *location = _hurd_thread_sigstate (__mach_thread_self ());
- return *location;
+ if (_hurd_sigstate == NULL)
+ _hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ());
+ return _hurd_sigstate;
}
/* Thread listening on our message port; also called the "signal thread". */
@@ -167,16 +166,22 @@ extern int _hurd_core_limit;
_HURD_SIGNAL_H_EXTERN_INLINE void *
_hurd_critical_section_lock (void)
{
- struct hurd_sigstate **location =
- (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 = _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; this locks the sigstate lock. */
- ss = *location = _hurd_thread_sigstate (__mach_thread_self ());
+ ss = _hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ());
__spin_unlock (&ss->lock);
}
diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c
index e38a4b2577..ee4227a294 100644
--- a/hurd/hurdsig.c
+++ b/hurd/hurdsig.c
@@ -50,6 +50,9 @@ unsigned long int __hurd_sigthread_stack_base;
unsigned long int __hurd_sigthread_stack_end;
unsigned long int *__hurd_sigthread_variables;
+/* Per-thread signal state. */
+__thread struct hurd_sigstate *_hurd_sigstate;
+
/* Linked-list of per-thread signal state. */
struct hurd_sigstate *_hurd_sigstates;