From ec54703bce74ac79735fd06599646267a98aaf22 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Thu, 28 Apr 2005 18:22:13 +0000 Subject: [PATCH] For the initial thread, rtld has already created the TCB and TLS storage. Use this. For all other threads allocate it. The TCB itself must not be NULL, so we don't have to check for it. --- .../arch/amd64/amd64/pthread_md.c | 19 ++++++------------- lib/libthread_xu/arch/i386/i386/pthread_md.c | 19 ++++++------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/lib/libthread_xu/arch/amd64/amd64/pthread_md.c b/lib/libthread_xu/arch/amd64/amd64/pthread_md.c index ba6be9385a..c763648b32 100644 --- a/lib/libthread_xu/arch/amd64/amd64/pthread_md.c +++ b/lib/libthread_xu/arch/amd64/amd64/pthread_md.c @@ -24,7 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/lib/libpthread/arch/amd64/amd64/pthread_md.c,v 1.4 2004/11/06 03:33:19 peter Exp $ - * $DragonFly: src/lib/libthread_xu/arch/amd64/amd64/pthread_md.c,v 1.4 2005/03/29 23:04:36 joerg Exp $ + * $DragonFly: src/lib/libthread_xu/arch/amd64/amd64/pthread_md.c,v 1.5 2005/04/28 18:22:13 joerg Exp $ */ #include @@ -44,18 +44,11 @@ _tcb_ctor(struct pthread *thread, int initial) old_tcb = NULL; flags = 0; - if (initial) { - /* - * We may have to replace a TLS already created by the low - * level libc startup code - */ - struct tls_info info; - if (sys_get_tls_area(0, &info, sizeof(info)) == 0) - old_tcb = info.base; - } - tcb = _rtld_allocate_tls(old_tcb); - if (tcb) - tcb->tcb_pthread = thread; + if (initial) + tcb = tls_get_tcb(); + else + tcb = _rtld_allocate_tls(old_tcb); + tcb->tcb_pthread = thread; return (tcb); } diff --git a/lib/libthread_xu/arch/i386/i386/pthread_md.c b/lib/libthread_xu/arch/i386/i386/pthread_md.c index 15e318cf47..1a79852e92 100644 --- a/lib/libthread_xu/arch/i386/i386/pthread_md.c +++ b/lib/libthread_xu/arch/i386/i386/pthread_md.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/arch/i386/i386/pthread_md.c,v 1.7 2005/03/29 23:04:36 joerg Exp $ + * $DragonFly: src/lib/libthread_xu/arch/i386/i386/pthread_md.c,v 1.8 2005/04/28 18:22:13 joerg Exp $ */ #include @@ -45,19 +45,12 @@ _tcb_ctor(struct pthread *thread, int initial) old_tcb = 0; flags = 0; - if (initial) { - /* - * We may have to replace a TLS already created by the low - * level libc startup code - */ - struct tls_info info; - if (sys_get_tls_area(0, &info, sizeof(info)) == 0) - old_tcb = info.base; - } - tcb = _rtld_allocate_tls(old_tcb); + if (initial) + tcb = tls_get_tcb(); + else + tcb = _rtld_allocate_tls(old_tcb); - if (tcb) - tcb->tcb_pthread = thread; + tcb->tcb_pthread = thread; return (tcb); } -- 2.41.0