Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Aug 2010 20:50:08 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r211773 - in head/lib/libthr: . arch/powerpc arch/powerpc/include arch/powerpc64
Message-ID:  <201008242050.o7OKo8mA087463@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Tue Aug 24 20:50:08 2010
New Revision: 211773
URL: http://svn.freebsd.org/changeset/base/211773

Log:
  Unify 32-bit and 64-bit PowerPC libthr support. This reduces code
  duplication, and simplifies the TBEMD import.
  
  Requested by:	imp

Deleted:
  head/lib/libthr/arch/powerpc64/
Modified:
  head/lib/libthr/Makefile
  head/lib/libthr/arch/powerpc/Makefile.inc
  head/lib/libthr/arch/powerpc/include/pthread_md.h

Modified: head/lib/libthr/Makefile
==============================================================================
--- head/lib/libthr/Makefile	Tue Aug 24 20:45:21 2010	(r211772)
+++ head/lib/libthr/Makefile	Tue Aug 24 20:50:08 2010	(r211773)
@@ -19,7 +19,7 @@ WARNS?=	3
 CFLAGS+=-DPTHREAD_KERNEL
 CFLAGS+=-I${.CURDIR}/../libc/include -I${.CURDIR}/thread \
 	-I${.CURDIR}/../../include
-CFLAGS+=-I${.CURDIR}/arch/${MACHINE_ARCH}/include
+CFLAGS+=-I${.CURDIR}/arch/${MACHINE_CPUARCH}/include
 CFLAGS+=-I${.CURDIR}/sys
 CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf
 CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf/${MACHINE_ARCH}
@@ -38,7 +38,7 @@ CFLAGS+=-D_PTHREADS_INVARIANTS
 
 PRECIOUSLIB=
 
-.include "${.CURDIR}/arch/${MACHINE_ARCH}/Makefile.inc"
+.include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc"
 .include "${.CURDIR}/sys/Makefile.inc"
 .include "${.CURDIR}/thread/Makefile.inc"
 

Modified: head/lib/libthr/arch/powerpc/Makefile.inc
==============================================================================
--- head/lib/libthr/arch/powerpc/Makefile.inc	Tue Aug 24 20:45:21 2010	(r211772)
+++ head/lib/libthr/arch/powerpc/Makefile.inc	Tue Aug 24 20:50:08 2010	(r211773)
@@ -1,5 +1,5 @@
 # $FreeBSD$
 
-.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}
+.PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH}/${MACHINE_CPUARCH}
 
 SRCS+=	pthread_md.c

Modified: head/lib/libthr/arch/powerpc/include/pthread_md.h
==============================================================================
--- head/lib/libthr/arch/powerpc/include/pthread_md.h	Tue Aug 24 20:45:21 2010	(r211772)
+++ head/lib/libthr/arch/powerpc/include/pthread_md.h	Tue Aug 24 20:50:08 2010	(r211773)
@@ -39,12 +39,16 @@
 #define	CPU_SPINWAIT
 
 #define	DTV_OFFSET		offsetof(struct tcb, tcb_dtv)
+#ifdef __powerpc64__
+#define	TP_OFFSET		0x7010
+#else
 #define	TP_OFFSET		0x7008
+#endif
 
 /*
  * Variant I tcb. The structure layout is fixed, don't blindly
  * change it.
- * %r2 points to end of the structure.
+ * %r2 (32-bit) or %r13 (64-bit) points to end of the structure.
  */
 struct tcb {
 	void			*tcb_dtv;
@@ -57,7 +61,11 @@ void		_tcb_dtor(struct tcb *);
 static __inline void
 _tcb_set(struct tcb *tcb)
 {
+#ifdef __powerpc64__
+	register uint8_t *_tp __asm__("%r13");
+#else
 	register uint8_t *_tp __asm__("%r2");
+#endif
 
 	__asm __volatile("mr %0,%1" : "=r"(_tp) :
 	    "r"((uint8_t *)tcb + TP_OFFSET));
@@ -66,7 +74,11 @@ _tcb_set(struct tcb *tcb)
 static __inline struct tcb *
 _tcb_get(void)
 {
+#ifdef __powerpc64__
+	register uint8_t *_tp __asm__("%r13");
+#else
 	register uint8_t *_tp __asm__("%r2");
+#endif
 
 	return ((struct tcb *)(_tp - TP_OFFSET));
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008242050.o7OKo8mA087463>