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...

Andrew Turner andrew at FreeBSD.org
Wed Jan 21 16:41:09 UTC 2015


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 <sys/types.h>
 #include <rtld_tls.h>
 
-#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 */


More information about the svn-src-head mailing list