From owner-svn-src-all@FreeBSD.ORG Fri Feb 10 06:53:26 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 93604106566B; Fri, 10 Feb 2012 06:53:26 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 67CA58FC12; Fri, 10 Feb 2012 06:53:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q1A6rQa4058609; Fri, 10 Feb 2012 06:53:26 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1A6rQRb058606; Fri, 10 Feb 2012 06:53:26 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201202100653.q1A6rQRb058606@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Fri, 10 Feb 2012 06:53:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r231350 - in head/lib/libthr/arch/mips: include mips X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Feb 2012 06:53:26 -0000 Author: gonzo Date: Fri Feb 10 06:53:25 2012 New Revision: 231350 URL: http://svn.freebsd.org/changeset/base/231350 Log: Switch MIPS TLS implementation to Variant I: Save pointer to the TLS structure taking into account TP_OFFSET and TCB structure size. Modified: head/lib/libthr/arch/mips/include/pthread_md.h head/lib/libthr/arch/mips/mips/pthread_md.c Modified: head/lib/libthr/arch/mips/include/pthread_md.h ============================================================================== --- head/lib/libthr/arch/mips/include/pthread_md.h Fri Feb 10 06:44:30 2012 (r231349) +++ head/lib/libthr/arch/mips/include/pthread_md.h Fri Feb 10 06:53:25 2012 (r231350) @@ -39,15 +39,19 @@ #define CPU_SPINWAIT #define DTV_OFFSET offsetof(struct tcb, tcb_dtv) +#ifdef __mips_n64 +#define TP_OFFSET 0x7010 +#else +#define TP_OFFSET 0x7008 +#endif /* - * Variant II tcb, first two members are required by rtld. + * Variant I tcb. The structure layout is fixed, don't blindly + * change it! */ struct tcb { - struct tcb *tcb_self; /* required by rtld */ - void *tcb_dtv; /* required by rtld */ - struct pthread *tcb_thread; /* our hook */ - void *tcb_spare[1]; + void *tcb_dtv; + struct pthread *tcb_thread; }; /* @@ -61,7 +65,7 @@ static __inline void _tcb_set(struct tcb *tcb) { - sysarch(MIPS_SET_TLS, tcb); + sysarch(MIPS_SET_TLS, ((uint8_t*)tcb + TP_OFFSET)); } /* @@ -70,10 +74,10 @@ _tcb_set(struct tcb *tcb) static __inline struct tcb * _tcb_get(void) { - void *tcb; + uint8_t *tcb; sysarch(MIPS_GET_TLS, &tcb); - return tcb; + return ((struct tcb *)(tcb - TP_OFFSET)); } extern struct pthread *_thr_initial; Modified: head/lib/libthr/arch/mips/mips/pthread_md.c ============================================================================== --- head/lib/libthr/arch/mips/mips/pthread_md.c Fri Feb 10 06:44:30 2012 (r231349) +++ head/lib/libthr/arch/mips/mips/pthread_md.c Fri Feb 10 06:53:25 2012 (r231350) @@ -34,6 +34,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include "pthread_md.h" struct tcb * @@ -41,16 +43,17 @@ _tcb_ctor(struct pthread *thread, int in { struct tcb *tcb; - tcb = malloc(sizeof(struct tcb)); - if (tcb) { - bzero(tcb, sizeof(struct tcb)); + tcb = _rtld_allocate_tls((initial) ? _tcb_get() : NULL, + sizeof(struct tcb), 16); + if (tcb) tcb->tcb_thread = thread; - } + return (tcb); } void _tcb_dtor(struct tcb *tcb) { - free(tcb); + + _rtld_free_tls(tcb, sizeof(struct tcb), 16); }