#endif
+#ifdef LISP_FEATURE_SB_THREAD
+void
+arch_os_load_ldt(struct thread *thread)
+{
+ sel_t sel;
+
+ sel.index = thread->tls_cookie;
+ sel.rpl = USER_PRIV;
+ sel.ti = SEL_LDT;
+
+ __asm__ __volatile__ ("mov %0, %%fs" : : "r"(sel));
+}
+#endif
+
int arch_os_thread_init(struct thread *thread) {
#ifdef LISP_FEATURE_SB_THREAD
int n;
- sel_t sel;
data_desc_t ldt_entry = { 0, 0, 0, DESC_DATA_WRITE,
3, 1, 0, DESC_DATA_32B, DESC_GRAN_BYTE, 0 };
thread_mutex_unlock(&modify_ldt_lock);
FSHOW_SIGNAL((stderr, "/ TLS: Allocated LDT %x\n", n));
- sel.index = n;
- sel.rpl = USER_PRIV;
- sel.ti = SEL_LDT;
-
- __asm__ __volatile__ ("mov %0, %%fs" : : "r"(sel));
-
thread->tls_cookie=n;
+ arch_os_load_ldt(thread);
+
pthread_setspecific(specials,thread);
#endif
#ifdef LISP_FEATURE_MACH_EXCEPTION_HANDLER
call_handler_on_thread(thread, &thread_state, signal, &siginfo, handler);
}
+ if (current_mach_task == MACH_PORT_NULL)
+ current_mach_task = mach_task_self();
+
dealloc_ret = mach_port_deallocate (current_mach_task, thread);
if (dealloc_ret) {
lose("mach_port_deallocate (thread) failed with return_code %d\n", dealloc_ret);