From owner-svn-src-stable@FreeBSD.ORG Wed Jul 27 11:21:50 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47EDA1065674; Wed, 27 Jul 2011 11:21:50 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 361788FC0A; Wed, 27 Jul 2011 11:21:50 +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 p6RBLoEU055176; Wed, 27 Jul 2011 11:21:50 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6RBLon3055171; Wed, 27 Jul 2011 11:21:50 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201107271121.p6RBLon3055171@svn.freebsd.org> From: Marius Strobl Date: Wed, 27 Jul 2011 11:21:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224467 - in stable/8/lib/libthr/arch/sparc64: . include sparc64 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2011 11:21:50 -0000 Author: marius Date: Wed Jul 27 11:21:49 2011 New Revision: 224467 URL: http://svn.freebsd.org/changeset/base/224467 Log: MFC: r223228 Merge from r161730: o Set TP using inline assembly to avoid dead code elimination. o Eliminate _tcb. Merge from r161840: Stylize: avoid using a global register variable. Merge from r157461: Simplify _get_curthread() and _tcb_ctor because libc and rtld now already allocate thread pointer space in tls block for initial thread. Merge from r177853: Replace function _umtx_op with _umtx_op_err, the later function directly returns errno, because errno can be mucked by user's signal handler and most of pthread api heavily depends on errno to be correct, this change should improve stability of the thread library. Added: stable/8/lib/libthr/arch/sparc64/sparc64/_umtx_op_err.S - copied unchanged from r223228, head/lib/libthr/arch/sparc64/sparc64/_umtx_op_err.S Modified: stable/8/lib/libthr/arch/sparc64/Makefile.inc stable/8/lib/libthr/arch/sparc64/include/pthread_md.h stable/8/lib/libthr/arch/sparc64/sparc64/pthread_md.c Directory Properties: stable/8/lib/libthr/ (props changed) Modified: stable/8/lib/libthr/arch/sparc64/Makefile.inc ============================================================================== --- stable/8/lib/libthr/arch/sparc64/Makefile.inc Wed Jul 27 07:02:33 2011 (r224466) +++ stable/8/lib/libthr/arch/sparc64/Makefile.inc Wed Jul 27 11:21:49 2011 (r224467) @@ -2,4 +2,4 @@ .PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/${MACHINE_ARCH} -SRCS+= pthread_md.c +SRCS+= _umtx_op_err.S pthread_md.c Modified: stable/8/lib/libthr/arch/sparc64/include/pthread_md.h ============================================================================== --- stable/8/lib/libthr/arch/sparc64/include/pthread_md.h Wed Jul 27 07:02:33 2011 (r224466) +++ stable/8/lib/libthr/arch/sparc64/include/pthread_md.h Wed Jul 27 11:21:49 2011 (r224467) @@ -50,10 +50,6 @@ struct tcb { void *tcb_spare[1]; }; -register struct tcb *_tp __asm("%g7"); - -#define _tcb (_tp) - /* * The tcb constructors. */ @@ -64,26 +60,25 @@ void _tcb_dtor(struct tcb *); static __inline void _tcb_set(struct tcb *tcb) { - _tp = tcb; + + __asm __volatile("mov %0, %%g7" : : "r" (tcb)); } -/* - * Get the current tcb. - */ static __inline struct tcb * _tcb_get(void) { - return (_tcb); -} + register struct tcb *tp __asm("%g7"); -extern struct pthread *_thr_initial; + return (tp); +} static __inline struct pthread * _get_curthread(void) { - if (_thr_initial) - return (_tcb->tcb_thread); - return (NULL); + + return (_tcb_get()->tcb_thread); } +#define HAS__UMTX_OP_ERR 1 + #endif /* _PTHREAD_MD_H_ */ Copied: stable/8/lib/libthr/arch/sparc64/sparc64/_umtx_op_err.S (from r223228, head/lib/libthr/arch/sparc64/sparc64/_umtx_op_err.S) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/lib/libthr/arch/sparc64/sparc64/_umtx_op_err.S Wed Jul 27 11:21:49 2011 (r224467, copy of r223228, head/lib/libthr/arch/sparc64/sparc64/_umtx_op_err.S) @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 2011 Marius Strobl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include + +ENTRY(_umtx_op_err) + mov SYS__umtx_op, %g1 + retl + ta %xcc, ST_SYSCALL +END(_umtx_op_err) Modified: stable/8/lib/libthr/arch/sparc64/sparc64/pthread_md.c ============================================================================== --- stable/8/lib/libthr/arch/sparc64/sparc64/pthread_md.c Wed Jul 27 07:02:33 2011 (r224466) +++ stable/8/lib/libthr/arch/sparc64/sparc64/pthread_md.c Wed Jul 27 11:21:49 2011 (r224467) @@ -24,10 +24,11 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ +#include +__FBSDID("$FreeBSD$"); + #include #include @@ -37,13 +38,11 @@ struct tcb * _tcb_ctor(struct pthread *thread, int initial) { struct tcb *tcb; - void *oldtls; if (initial) - oldtls = _tp; + tcb = _tcb_get(); else - oldtls = NULL; - tcb = _rtld_allocate_tls(oldtls, sizeof(struct tcb), 16); + tcb = _rtld_allocate_tls(NULL, sizeof(struct tcb), 16); if (tcb) tcb->tcb_thread = thread; return (tcb); @@ -52,5 +51,6 @@ _tcb_ctor(struct pthread *thread, int in void _tcb_dtor(struct tcb *tcb) { + _rtld_free_tls(tcb, sizeof(struct tcb), 16); }