summaryrefslogtreecommitdiff
path: root/mach
diff options
context:
space:
mode:
authorThomas Schwinge <tschwinge@gnu.org>2008-11-23 21:17:41 +0100
committerThomas Schwinge <thomas@schwinge.name>2010-01-25 21:40:49 +0100
commitc1c2b810c848f6ef082fa8cfb2bf501b850f0797 (patch)
treed829fab378ba5959b4e249033fb1f910de8be57a /mach
parent9bd608be06fc824cffd42ab8a81b210d4ef52a91 (diff)
glibc-2.8/debian/patches/hurd-i386/local-tls-support.diff 3151
Diffstat (limited to 'mach')
-rw-r--r--mach/mach.h3
-rw-r--r--mach/setup-thread.c30
2 files changed, 32 insertions, 1 deletions
diff --git a/mach/mach.h b/mach/mach.h
index f8fd44bb00..502db5ab29 100644
--- a/mach/mach.h
+++ b/mach/mach.h
@@ -101,5 +101,8 @@ kern_return_t mach_setup_thread (task_t task, thread_t thread, void *pc,
vm_address_t *stack_base,
vm_size_t *stack_size);
+/* Give THREAD a TLS area. */
+kern_return_t __mach_setup_tls (thread_t thread);
+kern_return_t mach_setup_tls (thread_t thread);
#endif /* mach.h */
diff --git a/mach/setup-thread.c b/mach/setup-thread.c
index fecffd9f06..bf0bfa9e94 100644
--- a/mach/setup-thread.c
+++ b/mach/setup-thread.c
@@ -20,6 +20,7 @@
#include <thread_state.h>
#include <string.h>
#include <mach/machine/vm_param.h>
+#include <ldsodefs.h>
#include "sysdep.h" /* Defines stack direction. */
#define STACK_SIZE (16 * 1024 * 1024) /* 16MB, arbitrary. */
@@ -73,8 +74,35 @@ __mach_setup_thread (task_t task, thread_t thread, void *pc,
if (error = __vm_protect (task, stack, __vm_page_size, 0, VM_PROT_NONE))
return error;
- return __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+ return __thread_set_state (thread, MACHINE_NEW_THREAD_STATE_FLAVOR,
(natural_t *) &ts, tssize);
}
weak_alias (__mach_setup_thread, mach_setup_thread)
+
+/* Give THREAD a TLS area. */
+kern_return_t
+__mach_setup_tls (thread_t thread)
+{
+ kern_return_t error;
+ struct machine_thread_state ts;
+ mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT;
+ tcbhead_t *tcb;
+
+ if (error = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+ (natural_t *) &ts, &tssize))
+ return error;
+ assert (tssize == MACHINE_THREAD_STATE_COUNT);
+
+ tcb = _dl_allocate_tls(NULL);
+ if (!tcb)
+ return KERN_RESOURCE_SHORTAGE;
+
+ _hurd_tls_new(thread, &ts, tcb);
+
+ error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+ (natural_t *) &ts, tssize);
+ return error;
+}
+
+weak_alias (__mach_setup_tls, mach_setup_tls)