]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
powerpc: Make PT_THREAD_POINTER available to assembly code
authorMatheus Castanho <msc@linux.ibm.com>
Mon, 19 Oct 2020 14:06:56 +0000 (11:06 -0300)
committerMatheus Castanho <msc@linux.ibm.com>
Tue, 24 Nov 2020 17:15:01 +0000 (14:15 -0300)
PT_THREAD_POINTER is currenty defined inside a #ifndef __ASSEMBLER__ block, but
its usage should not be limited to C code, as it can be useful when accessing
the TLS from assembly code as well.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
sysdeps/powerpc/nptl/tls.h

index 261eecfd18167e4a45c7254229cea07e32ca17b4..d585968d045e87fe86f7266bec22f7dc57dbfe17 100644 (file)
 
 #else /* __ASSEMBLER__ */
 # include <tcb-offsets.h>
+# define __ASSEMBLY__
+# include <asm/ptrace.h>
 #endif /* __ASSEMBLER__ */
 
+#ifndef __powerpc64__
+/* Register r2 (tp) is reserved by the ABI as "thread pointer". */
+# define PT_THREAD_POINTER PT_R2
+# ifndef __ASSEMBLER__
+register void *__thread_register __asm__ ("r2");
+# endif
+
+#else /* __powerpc64__ */
+/* Register r13 (tp) is reserved by the ABI as "thread pointer". */
+# define PT_THREAD_POINTER PT_R13
+# ifndef __ASSEMBLER__
+register void *__thread_register __asm__ ("r13");
+# endif
+#endif /* __powerpc64__ */
 
 #ifndef __ASSEMBLER__
 
@@ -106,16 +122,6 @@ typedef struct
   (sizeof (struct pthread)                                                   \
    + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
 
-# ifndef __powerpc64__
-/* Register r2 (tp) is reserved by the ABI as "thread pointer". */
-register void *__thread_register __asm__ ("r2");
-#  define PT_THREAD_POINTER PT_R2
-# else
-/* Register r13 (tp) is reserved by the ABI as "thread pointer". */
-register void *__thread_register __asm__ ("r13");
-#  define PT_THREAD_POINTER PT_R13
-# endif
-
 /* The following assumes that TP (R2 or R13) points to the end of the
    TCB + 0x7000 (per the ABI).  This implies that TCB address is
    TP - 0x7000.  As we define TLS_DTV_AT_TP we can