diff options
author | davidxu <davidxu@FreeBSD.org> | 2004-08-19 23:49:04 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2004-08-19 23:49:04 +0000 |
commit | 1d227ebfe244c308f779bc951b98515f9271c2dd (patch) | |
tree | c2cbf5cdc79daabfc870a497148f30881083b1aa /lib/libthr/arch | |
parent | be1d6f4eb1c9af043ddd260b2c562df680609aad (diff) | |
download | FreeBSD-src-1d227ebfe244c308f779bc951b98515f9271c2dd.zip FreeBSD-src-1d227ebfe244c308f779bc951b98515f9271c2dd.tar.gz |
Adjust code to support AMD64, on AMD64, thread needs to set fsbase by
itself before it can execute any other code, so new thread should be
created with all signals are masked until after fsbase is set.
Diffstat (limited to 'lib/libthr/arch')
-rw-r--r-- | lib/libthr/arch/i386/i386/_setcurthread.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libthr/arch/i386/i386/_setcurthread.c b/lib/libthr/arch/i386/i386/_setcurthread.c index 0ff4ff6..4e07579 100644 --- a/lib/libthr/arch/i386/i386/_setcurthread.c +++ b/lib/libthr/arch/i386/i386/_setcurthread.c @@ -47,13 +47,16 @@ struct tcb { struct tcb *tcb_self; /* required by rtld */ void *tcb_dtv; /* required by rtld */ struct pthread *tcb_thread; + int tcb_ldt; }; void _retire_thread(void *entry) { - _rtld_free_tls(entry, sizeof(struct tcb), 16); - /* XXX free ldt descriptor here */ + struct tcb *tcb = (struct tcb *)entry; + + i386_set_ldt(tcb->tcb_ldt, NULL, 1); + _rtld_free_tls(tcb, sizeof(struct tcb), 16); } void * @@ -66,6 +69,10 @@ _set_curthread(ucontext_t *uc, struct pthread *thr, int *err) *err = 0; + if (uc == NULL && thr->arch_id != NULL) { + return (thr->arch_id); + } + if (uc == NULL) { __asm __volatile("movl %%gs:0, %0" : "=r" (oldtls)); } else { @@ -104,7 +111,7 @@ _set_curthread(ucontext_t *uc, struct pthread *thr, int *err) ldt_index = i386_set_ldt(LDT_AUTO_ALLOC, &desc, 1); if (ldt_index == -1) abort(); - + tcb->tcb_ldt = ldt_index; /* * Set up our gs with the index into the ldt for this entry. */ |