From owner-svn-src-head@FreeBSD.ORG Wed Jan 21 16:41:09 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8609DC7C; Wed, 21 Jan 2015 16:41:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6EB57B7E; Wed, 21 Jan 2015 16:41:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0LGf992099875; Wed, 21 Jan 2015 16:41:09 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0LGf59R099855; Wed, 21 Jan 2015 16:41:05 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201501211641.t0LGf59R099855@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 21 Jan 2015 16:41:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r277490 - in head/lib/libthr: . arch/amd64 arch/amd64/amd64 arch/amd64/include arch/arm arch/arm/arm arch/arm/include arch/common arch/i386 arch/i386/i386 arch/i386/include arch/mips ar... X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jan 2015 16:41:09 -0000 Author: andrew Date: Wed Jan 21 16:41:05 2015 New Revision: 277490 URL: https://svnweb.freebsd.org/changeset/base/277490 Log: Merge all the copies of _tcb_ctor and _tcb_dtor. The amd64, i386, and sparc64 versions were identical, with the one difference where the former two used inline asm instead of _tcb_get. I have compared the function before and after replacing the asm with _tcb_get and found the object files to be identical. The arm, mips, and powerpc versions were almost identical. The only difference was the powerpc version used an alignment of 1 where arm and mips used 16. As this is an increase in alignment is will be safe. Along with this arm, mips, and powerpc all passed, when initial was true, the value returned from _tcb_get as the first argument to _rtld_allocate_tls. This would then return this pointer back to the caller. We can remove these extra calls by checking if initial is set and setting the thread control block directly. As this is what the sparc64 code does we can use it directly. As after these observations all the architectures can now have identical code we can merge them into a common file. Differential Revision: https://reviews.freebsd.org/D1556 Reviewed by: kib Sponsored by: The FreeBSD Foundation Added: head/lib/libthr/arch/common/ head/lib/libthr/thread/thr_ctrdtr.c - copied, changed from r277373, head/lib/libthr/arch/sparc64/sparc64/pthread_md.c Deleted: head/lib/libthr/arch/amd64/amd64/pthread_md.c head/lib/libthr/arch/arm/Makefile.inc head/lib/libthr/arch/arm/arm/ head/lib/libthr/arch/i386/i386/pthread_md.c head/lib/libthr/arch/mips/Makefile.inc head/lib/libthr/arch/mips/mips/ head/lib/libthr/arch/powerpc/Makefile.inc head/lib/libthr/arch/powerpc/powerpc/ head/lib/libthr/arch/sparc64/sparc64/pthread_md.c Modified: head/lib/libthr/Makefile head/lib/libthr/arch/amd64/Makefile.inc head/lib/libthr/arch/amd64/include/pthread_md.h head/lib/libthr/arch/arm/include/pthread_md.h head/lib/libthr/arch/i386/Makefile.inc head/lib/libthr/arch/i386/include/pthread_md.h head/lib/libthr/arch/mips/include/pthread_md.h head/lib/libthr/arch/powerpc/include/pthread_md.h head/lib/libthr/arch/sparc64/Makefile.inc head/lib/libthr/arch/sparc64/include/pthread_md.h head/lib/libthr/thread/Makefile.inc head/lib/libthr/thread/thr_private.h Modified: head/lib/libthr/Makefile ============================================================================== --- head/lib/libthr/Makefile Wed Jan 21 16:32:54 2015 (r277489) +++ head/lib/libthr/Makefile Wed Jan 21 16:41:05 2015 (r277490) @@ -45,7 +45,9 @@ PRECIOUSLIB= .PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH}/${MACHINE_CPUARCH} +.if exists(${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc) .include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc" +.endif .include "${.CURDIR}/sys/Makefile.inc" .include "${.CURDIR}/thread/Makefile.inc" Modified: head/lib/libthr/arch/amd64/Makefile.inc ============================================================================== --- head/lib/libthr/arch/amd64/Makefile.inc Wed Jan 21 16:32:54 2015 (r277489) +++ head/lib/libthr/arch/amd64/Makefile.inc Wed Jan 21 16:41:05 2015 (r277490) @@ -1,3 +1,3 @@ #$FreeBSD$ -SRCS+= pthread_md.c _umtx_op_err.S +SRCS+= _umtx_op_err.S Modified: head/lib/libthr/arch/amd64/include/pthread_md.h ============================================================================== --- head/lib/libthr/arch/amd64/include/pthread_md.h Wed Jan 21 16:32:54 2015 (r277489) +++ head/lib/libthr/arch/amd64/include/pthread_md.h Wed Jan 21 16:41:05 2015 (r277490) @@ -77,9 +77,6 @@ struct tcb { __result; \ }) -struct tcb *_tcb_ctor(struct pthread *, int); -void _tcb_dtor(struct tcb *tcb); - static __inline void _tcb_set(struct tcb *tcb) { Modified: head/lib/libthr/arch/arm/include/pthread_md.h ============================================================================== --- head/lib/libthr/arch/arm/include/pthread_md.h Wed Jan 21 16:32:54 2015 (r277489) +++ head/lib/libthr/arch/arm/include/pthread_md.h Wed Jan 21 16:41:05 2015 (r277490) @@ -47,12 +47,6 @@ struct tcb { struct pthread *tcb_thread; /* our hook */ }; -/* - * The tcb constructors. - */ -struct tcb *_tcb_ctor(struct pthread *, int); -void _tcb_dtor(struct tcb *); - /* Called from the thread to set its private data. */ static __inline void _tcb_set(struct tcb *tcb) Modified: head/lib/libthr/arch/i386/Makefile.inc ============================================================================== --- head/lib/libthr/arch/i386/Makefile.inc Wed Jan 21 16:32:54 2015 (r277489) +++ head/lib/libthr/arch/i386/Makefile.inc Wed Jan 21 16:41:05 2015 (r277490) @@ -1,3 +1,3 @@ # $FreeBSD$ -SRCS+= pthread_md.c _umtx_op_err.S +SRCS+= _umtx_op_err.S Modified: head/lib/libthr/arch/i386/include/pthread_md.h ============================================================================== --- head/lib/libthr/arch/i386/include/pthread_md.h Wed Jan 21 16:32:54 2015 (r277489) +++ head/lib/libthr/arch/i386/include/pthread_md.h Wed Jan 21 16:41:05 2015 (r277490) @@ -76,12 +76,6 @@ struct tcb { __result; \ }) -/* - * The constructors. - */ -struct tcb *_tcb_ctor(struct pthread *, int); -void _tcb_dtor(struct tcb *tcb); - /* Called from the thread to set its private data. */ static __inline void _tcb_set(struct tcb *tcb) Modified: head/lib/libthr/arch/mips/include/pthread_md.h ============================================================================== --- head/lib/libthr/arch/mips/include/pthread_md.h Wed Jan 21 16:32:54 2015 (r277489) +++ head/lib/libthr/arch/mips/include/pthread_md.h Wed Jan 21 16:41:05 2015 (r277490) @@ -50,12 +50,6 @@ struct tcb { struct pthread *tcb_thread; }; -/* - * The tcb constructors. - */ -struct tcb *_tcb_ctor(struct pthread *, int); -void _tcb_dtor(struct tcb *); - /* Called from the thread to set its private data. */ static __inline void _tcb_set(struct tcb *tcb) Modified: head/lib/libthr/arch/powerpc/include/pthread_md.h ============================================================================== --- head/lib/libthr/arch/powerpc/include/pthread_md.h Wed Jan 21 16:32:54 2015 (r277489) +++ head/lib/libthr/arch/powerpc/include/pthread_md.h Wed Jan 21 16:41:05 2015 (r277490) @@ -55,9 +55,6 @@ struct tcb { struct pthread *tcb_thread; }; -struct tcb *_tcb_ctor(struct pthread *, int); -void _tcb_dtor(struct tcb *); - static __inline void _tcb_set(struct tcb *tcb) { Modified: head/lib/libthr/arch/sparc64/Makefile.inc ============================================================================== --- head/lib/libthr/arch/sparc64/Makefile.inc Wed Jan 21 16:32:54 2015 (r277489) +++ head/lib/libthr/arch/sparc64/Makefile.inc Wed Jan 21 16:41:05 2015 (r277490) @@ -1,3 +1,3 @@ # $FreeBSD$ -SRCS+= _umtx_op_err.S pthread_md.c +SRCS+= _umtx_op_err.S Modified: head/lib/libthr/arch/sparc64/include/pthread_md.h ============================================================================== --- head/lib/libthr/arch/sparc64/include/pthread_md.h Wed Jan 21 16:32:54 2015 (r277489) +++ head/lib/libthr/arch/sparc64/include/pthread_md.h Wed Jan 21 16:41:05 2015 (r277490) @@ -50,12 +50,6 @@ struct tcb { void *tcb_spare[1]; }; -/* - * The tcb constructors. - */ -struct tcb *_tcb_ctor(struct pthread *, int); -void _tcb_dtor(struct tcb *); - /* Called from the thread to set its private data. */ static __inline void _tcb_set(struct tcb *tcb) Modified: head/lib/libthr/thread/Makefile.inc ============================================================================== --- head/lib/libthr/thread/Makefile.inc Wed Jan 21 16:32:54 2015 (r277489) +++ head/lib/libthr/thread/Makefile.inc Wed Jan 21 16:41:05 2015 (r277490) @@ -14,6 +14,7 @@ SRCS+= \ thr_cond.c \ thr_condattr.c \ thr_create.c \ + thr_ctrdtr.c \ thr_detach.c \ thr_equal.c \ thr_event.c \ Copied and modified: head/lib/libthr/thread/thr_ctrdtr.c (from r277373, head/lib/libthr/arch/sparc64/sparc64/pthread_md.c) ============================================================================== --- head/lib/libthr/arch/sparc64/sparc64/pthread_md.c Mon Jan 19 07:29:28 2015 (r277373, copy source) +++ head/lib/libthr/thread/thr_ctrdtr.c Wed Jan 21 16:41:05 2015 (r277490) @@ -32,7 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include "pthread_md.h" +#include "thr_private.h" struct tcb * _tcb_ctor(struct pthread *thread, int initial) Modified: head/lib/libthr/thread/thr_private.h ============================================================================== --- head/lib/libthr/thread/thr_private.h Wed Jan 21 16:32:54 2015 (r277489) +++ head/lib/libthr/thread/thr_private.h Wed Jan 21 16:41:05 2015 (r277490) @@ -928,6 +928,9 @@ int __thr_sigwait(const sigset_t *set, i int __thr_sigwaitinfo(const sigset_t *set, siginfo_t *info); int __thr_swapcontext(ucontext_t *oucp, const ucontext_t *ucp); +struct tcb *_tcb_ctor(struct pthread *, int); +void _tcb_dtor(struct tcb *); + __END_DECLS #endif /* !_THR_PRIVATE_H */