summaryrefslogtreecommitdiff
path: root/hurd
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2013-10-14 03:39:11 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2013-10-14 03:39:11 +0200
commitc8086a22140200e47d54d90607883653e868af77 (patch)
treec1540d357980131067b0da53be72e886977cfca5 /hurd
parent53b14ade01ba05eebc2bb0e71ceb4c19a1cf228c (diff)
parentf1cc02b3342389c782cadfc94a047ba6200b0eb8 (diff)
Merge branch 't/tls-threadvar' into refs/top-bases/tschwinge/Roger_Whittaker
Diffstat (limited to 'hurd')
-rw-r--r--hurd/hurd/threadvar.h3
-rw-r--r--hurd/hurdsig.c15
-rw-r--r--hurd/sigunwind.c3
3 files changed, 13 insertions, 8 deletions
diff --git a/hurd/hurd/threadvar.h b/hurd/hurd/threadvar.h
index ebfce35b51..4fd498965e 100644
--- a/hurd/hurd/threadvar.h
+++ b/hurd/hurd/threadvar.h
@@ -20,6 +20,7 @@
#define _HURD_THREADVAR_H
#include <features.h>
+#include <tls.h>
/* The per-thread variables are found by ANDing this mask
with the value of the stack pointer and then adding this offset.
@@ -117,5 +118,7 @@ __hurd_threadvar_location (enum __hurd_threadvar_index __index)
}
#endif
+extern mach_port_t __hurd_reply_port0;
+#define __hurd_local_reply_port (*(__libc_no_tls() ? &__hurd_reply_port0 : &THREAD_SELF->reply_port))
#endif /* hurd/threadvar.h */
diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c
index 12ea82955b..e93f26bb53 100644
--- a/hurd/hurdsig.c
+++ b/hurd/hurdsig.c
@@ -334,11 +334,11 @@ abort_thread (struct hurd_sigstate *ss, struct machine_thread_all_state *state,
that this location can be set without faulting, or else return NULL. */
static mach_port_t *
-interrupted_reply_port_location (struct machine_thread_all_state *thread_state,
+interrupted_reply_port_location (thread_t thread,
+ struct machine_thread_all_state *thread_state,
int sigthread)
{
- mach_port_t *portloc = (mach_port_t *) __hurd_threadvar_location_from_sp
- (_HURD_THREADVAR_MIG_REPLY, (void *) thread_state->basic.SP);
+ mach_port_t *portloc = &THREAD_TCB(thread, thread_state)->reply_port;
if (sigthread && _hurdsig_catch_memory_fault (portloc))
/* Faulted trying to read the stack. */
@@ -423,7 +423,8 @@ _hurdsig_abort_rpcs (struct hurd_sigstate *ss, int signo, int sigthread,
our nonzero return tells the trampoline code to finish the message
receive operation before running the handler. */
- mach_port_t *reply = interrupted_reply_port_location (state,
+ mach_port_t *reply = interrupted_reply_port_location (ss->thread,
+ state,
sigthread);
error_t err = __interrupt_operation (intr_port, _hurdsig_interrupt_timeout);
@@ -980,7 +981,8 @@ post_signal (struct hurd_sigstate *ss,
if (! machine_get_basic_state (ss->thread, &thread_state))
goto sigbomb;
- loc = interrupted_reply_port_location (&thread_state, 1);
+ loc = interrupted_reply_port_location (ss->thread,
+ &thread_state, 1);
if (loc && *loc != MACH_PORT_NULL)
/* This is the reply port for the context which called
sigreturn. Since we are abandoning that context entirely
@@ -1046,7 +1048,8 @@ post_signal (struct hurd_sigstate *ss,
{
/* Fetch the thread variable for the MiG reply port,
and set it to MACH_PORT_NULL. */
- mach_port_t *loc = interrupted_reply_port_location (&thread_state,
+ mach_port_t *loc = interrupted_reply_port_location (ss->thread,
+ &thread_state,
1);
if (loc)
{
diff --git a/hurd/sigunwind.c b/hurd/sigunwind.c
index de966aa09b..40af749479 100644
--- a/hurd/sigunwind.c
+++ b/hurd/sigunwind.c
@@ -38,8 +38,7 @@ _hurdsig_longjmp_from_handler (void *data, jmp_buf env, int val)
{
/* Destroy the MiG reply port used by the signal handler, and restore
the reply port in use by the thread when interrupted. */
- mach_port_t *reply_port =
- (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY);
+ mach_port_t *reply_port = &__hurd_local_reply_port;
if (*reply_port)
{
mach_port_t port = *reply_port;