94084c
commit cb976fba4c51ede7bf8cee5035888527c308dfbc
94084c
Author: Florian Weimer <fweimer@redhat.com>
94084c
Date:   Wed Dec 15 16:06:25 2021 +0100
94084c
94084c
    powerpc: Use global register variable in <thread_pointer.h>
94084c
    
94084c
    A local register variable is merely a compiler hint, and so not
94084c
    appropriate in this context.  Move the global register variable into
94084c
    <thread_pointer.h> and include it from <tls.h>, as there can only
94084c
    be one global definition for one particular register.
94084c
    
94084c
    Fixes commit 8dbeb0561eeb876f557ac9eef5721912ec074ea5
94084c
    ("nptl: Add <thread_pointer.h> for defining __thread_pointer").
94084c
    
94084c
    Reported-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
94084c
    Reviewed-by: Raphael M Zinsly <rzinsly@linux.ibm.com>
94084c
94084c
diff --git a/sysdeps/powerpc/nptl/thread_pointer.h b/sysdeps/powerpc/nptl/thread_pointer.h
94084c
index 8fd5ba671f6f5e64..4feba5961062cfaf 100644
94084c
--- a/sysdeps/powerpc/nptl/thread_pointer.h
94084c
+++ b/sysdeps/powerpc/nptl/thread_pointer.h
94084c
@@ -19,15 +19,16 @@
94084c
 #ifndef _SYS_THREAD_POINTER_H
94084c
 #define _SYS_THREAD_POINTER_H
94084c
 
94084c
-static inline void *
94084c
-__thread_pointer (void)
94084c
-{
94084c
 #ifdef __powerpc64__
94084c
-  register void *__result asm ("r13");
94084c
+register void *__thread_register asm ("r13");
94084c
 #else
94084c
-  register void *__result asm ("r2");
94084c
+register void *__thread_register asm ("r2");
94084c
 #endif
94084c
-  return __result;
94084c
+
94084c
+static inline void *
94084c
+__thread_pointer (void)
94084c
+{
94084c
+  return __thread_register;
94084c
 }
94084c
 
94084c
 #endif /* _SYS_THREAD_POINTER_H */
94084c
diff --git a/sysdeps/powerpc/nptl/tls.h b/sysdeps/powerpc/nptl/tls.h
94084c
index e194b334216eaa02..050beb06a8f7de65 100644
94084c
--- a/sysdeps/powerpc/nptl/tls.h
94084c
+++ b/sysdeps/powerpc/nptl/tls.h
94084c
@@ -26,6 +26,7 @@
94084c
 # include <stddef.h>
94084c
 # include <stdint.h>
94084c
 # include <dl-dtv.h>
94084c
+# include <thread_pointer.h>
94084c
 
94084c
 #else /* __ASSEMBLER__ */
94084c
 # include <tcb-offsets.h>
94084c
@@ -36,16 +37,10 @@
94084c
 #ifndef __powerpc64__
94084c
 /* Register r2 (tp) is reserved by the ABI as "thread pointer". */
94084c
 # define PT_THREAD_POINTER PT_R2
94084c
-# ifndef __ASSEMBLER__
94084c
-register void *__thread_register __asm__ ("r2");
94084c
-# endif
94084c
 
94084c
 #else /* __powerpc64__ */
94084c
 /* Register r13 (tp) is reserved by the ABI as "thread pointer". */
94084c
 # define PT_THREAD_POINTER PT_R13
94084c
-# ifndef __ASSEMBLER__
94084c
-register void *__thread_register __asm__ ("r13");
94084c
-# endif
94084c
 #endif /* __powerpc64__ */
94084c
 
94084c
 #ifndef __ASSEMBLER__