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