Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Jan 2015 03:50:44 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r276734 - in head/lib: libc/powerpc/gen libc/powerpc64/gen libthr/arch/powerpc/include
Message-ID:  <201501060350.t063oiZX034861@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Tue Jan  6 03:50:43 2015
New Revision: 276734
URL: https://svnweb.freebsd.org/changeset/base/276734

Log:
  Avoid use of register variables.  Clang 3.5 treats this as undefined behavior,
  and bad things happen.
  
  MFC after:	1 week

Modified:
  head/lib/libc/powerpc/gen/_set_tp.c
  head/lib/libc/powerpc64/gen/_set_tp.c
  head/lib/libthr/arch/powerpc/include/pthread_md.h

Modified: head/lib/libc/powerpc/gen/_set_tp.c
==============================================================================
--- head/lib/libc/powerpc/gen/_set_tp.c	Tue Jan  6 03:49:22 2015	(r276733)
+++ head/lib/libc/powerpc/gen/_set_tp.c	Tue Jan  6 03:50:43 2015	(r276734)
@@ -29,7 +29,6 @@
 void
 _set_tp(void *tpval)
 {
-	register void *tp __asm__("r2");
 
-	__asm __volatile("mr %0,%1" : "=r"(tp) : "r"((char*)tpval + 0x7008));
+	__asm __volatile("mr 2,%0" :: "r"((char*)tpval + 0x7008));
 }

Modified: head/lib/libc/powerpc64/gen/_set_tp.c
==============================================================================
--- head/lib/libc/powerpc64/gen/_set_tp.c	Tue Jan  6 03:49:22 2015	(r276733)
+++ head/lib/libc/powerpc64/gen/_set_tp.c	Tue Jan  6 03:50:43 2015	(r276734)
@@ -29,7 +29,6 @@
 void
 _set_tp(void *tpval)
 {
-	register void *tp __asm__("r13");
 
-	__asm __volatile("mr %0,%1" : "=r"(tp) : "r"((char*)tpval + 0x7010));
+	__asm __volatile("mr 13,%0" :: "r"((char*)tpval + 0x7010));
 }

Modified: head/lib/libthr/arch/powerpc/include/pthread_md.h
==============================================================================
--- head/lib/libthr/arch/powerpc/include/pthread_md.h	Tue Jan  6 03:49:22 2015	(r276733)
+++ head/lib/libthr/arch/powerpc/include/pthread_md.h	Tue Jan  6 03:50:43 2015	(r276734)
@@ -62,22 +62,22 @@ static __inline void
 _tcb_set(struct tcb *tcb)
 {
 #ifdef __powerpc64__
-	register uint8_t *_tp __asm__("%r13");
+	__asm __volatile("mr 13,%0" ::
+	    "r"((uint8_t *)tcb + TP_OFFSET));
 #else
-	register uint8_t *_tp __asm__("%r2");
-#endif
-
-	__asm __volatile("mr %0,%1" : "=r"(_tp) :
+	__asm __volatile("mr 2,%0" ::
 	    "r"((uint8_t *)tcb + TP_OFFSET));
+#endif
 }
 
 static __inline struct tcb *
 _tcb_get(void)
 {
+	register uint8_t *_tp;
 #ifdef __powerpc64__
-	register uint8_t *_tp __asm__("%r13");
+	__asm __volatile("mr %0,13" : "=r"(_tp));
 #else
-	register uint8_t *_tp __asm__("%r2");
+	__asm __volatile("mr %0,2" : "=r"(_tp));
 #endif
 
 	return ((struct tcb *)(_tp - TP_OFFSET));



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