summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2005-04-23 03:31:59 +0000
committerdavidxu <davidxu@FreeBSD.org>2005-04-23 03:31:59 +0000
commit8d38949442f74e86e45e2a15f3027e9e3428b42b (patch)
tree9decab66488d26669226da094c12c49473a57b19 /lib/libthr
parenta0a25ee25d1bd296e898cd72e97a736762e337fb (diff)
downloadFreeBSD-src-8d38949442f74e86e45e2a15f3027e9e3428b42b.zip
FreeBSD-src-8d38949442f74e86e45e2a15f3027e9e3428b42b.tar.gz
Now libthr only uses GDT based tls on i386. using LDT can only increase
clock cycles and has 8191 threads limitation.
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/arch/i386/i386/pthread_md.c46
-rw-r--r--lib/libthr/arch/i386/include/pthread_md.h10
2 files changed, 3 insertions, 53 deletions
diff --git a/lib/libthr/arch/i386/i386/pthread_md.c b/lib/libthr/arch/i386/i386/pthread_md.c
index b410acc..82074b6 100644
--- a/lib/libthr/arch/i386/i386/pthread_md.c
+++ b/lib/libthr/arch/i386/i386/pthread_md.c
@@ -35,15 +35,9 @@
#include "pthread_md.h"
-int _thr_using_setbase;
-
struct tcb *
_tcb_ctor(struct pthread *thread, int initial)
{
-#ifndef COMPAT_32BIT
- union descriptor ldt;
- void *base;
-#endif
struct tcb *tcb;
void *oldtls;
int error;
@@ -54,51 +48,15 @@ _tcb_ctor(struct pthread *thread, int initial)
oldtls = NULL;
tcb = _rtld_allocate_tls(oldtls, sizeof(struct tcb), 16);
- if (tcb) {
+ if (tcb)
tcb->tcb_thread = thread;
-#ifndef COMPAT_32BIT
- tcb->tcb_ldt = -1;
- switch (_thr_using_setbase) {
- case 1: /* use i386_set_gsbase() in _kcb_set */
- break;
- case 0: /* Untested, try the get/set_gsbase routines once */
- error = i386_get_gsbase(&base);
- if (error == 0) {
- _thr_using_setbase = 1;
- break;
- }
- /* fall through */
- case 2: /* Use the user_ldt code, we must have an old kernel */
- _thr_using_setbase = 2;
- ldt.sd.sd_hibase = (unsigned int)tcb >> 24;
- ldt.sd.sd_lobase = (unsigned int)tcb & 0xFFFFFF;
- ldt.sd.sd_hilimit = (sizeof(struct tcb) >> 16) & 0xF;
- ldt.sd.sd_lolimit = sizeof(struct tcb) & 0xFFFF;
- ldt.sd.sd_type = SDT_MEMRWA;
- ldt.sd.sd_dpl = SEL_UPL;
- ldt.sd.sd_p = 1;
- ldt.sd.sd_xx = 0;
- ldt.sd.sd_def32 = 1;
- ldt.sd.sd_gran = 0; /* no more than 1M */
- tcb->tcb_ldt = i386_set_ldt(LDT_AUTO_ALLOC, &ldt, 1);
- if (tcb->tcb_ldt < 0) {
- _rtld_free_tls(tcb, sizeof(struct tcb), 16);
- tcb = NULL;
- }
- break;
- }
-#endif
- }
return (tcb);
}
void
_tcb_dtor(struct tcb *tcb)
{
-#ifndef COMPAT_32BIT
- if (tcb->tcb_ldt >= 0)
- i386_set_ldt(tcb->tcb_ldt, NULL, 1);
-#endif
+
_rtld_free_tls(tcb, sizeof(struct tcb), 16);
}
diff --git a/lib/libthr/arch/i386/include/pthread_md.h b/lib/libthr/arch/i386/include/pthread_md.h
index ac3cc9c..46ab5b6 100644
--- a/lib/libthr/arch/i386/include/pthread_md.h
+++ b/lib/libthr/arch/i386/include/pthread_md.h
@@ -49,7 +49,6 @@ struct tcb {
struct tcb *tcb_self; /* required by rtld */
void *tcb_dtv; /* required by rtld */
struct pthread *tcb_thread;
- int tcb_ldt;
};
/*
@@ -88,14 +87,7 @@ static __inline void
_tcb_set(struct tcb *tcb)
{
#ifndef COMPAT_32BIT
- int val;
-
- if (_thr_using_setbase == 1) {
- i386_set_gsbase(tcb);
- } else {
- val = (tcb->tcb_ldt << 3) | 7;
- __asm __volatile("movl %0, %%gs" : : "r" (val));
- }
+ i386_set_gsbase(tcb);
#else
_amd64_set_gsbase(tcb);
#endif
OpenPOWER on IntegriCloud