]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: hppa: replace __get_cr27 with __thread_pointer
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 27 Dec 2024 16:41:02 +0000 (17:41 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 27 Dec 2024 16:41:02 +0000 (17:41 +0100)
The addition of the new thread_pointer.h header on HPPA resulted in
duplicated inline asm to get the current thread pointer from the cr27
register.

Include thread_pointer.h in tls.h and replace __get/set_cr27() with
__set_/thread_pointer() with the appropriate casts.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
sysdeps/hppa/nptl/thread_pointer.h
sysdeps/hppa/nptl/tls.h

index 96f5e9b4c0ad922af09eb0b11e227b15e510a129..acd6fa590190b4986aa9d792288d2ec94b1a150a 100644 (file)
@@ -27,4 +27,14 @@ __thread_pointer (void)
   return __thread_register;
 }
 
+/* We write to cr27, clobber r26 as the input argument, and clobber
+   r31 as the link register.  */
+static inline void
+__set_thread_pointer(void *__thread_pointer)
+{
+  asm ( "ble   0xe0(%%sr2, %%r0)\n\t"
+       "copy   %0, %%r26"
+       : : "r" (__thread_pointer) : "r26", "r31" );
+}
+
 #endif /* _SYS_THREAD_POINTER_H */
index 82055fa8a30bb0409c226a30a9b2c0dd7974ece3..c97bdbcff19dd6528f4995eb5828bfb54b221d68 100644 (file)
@@ -40,6 +40,8 @@
 /* Get the thread descriptor definition.  */
 # include <nptl/descr.h>
 
+# include <thread_pointer.h>
+
 typedef struct
 {
   dtv_t *dtv;
@@ -62,7 +64,7 @@ typedef struct
 
 /* Install new dtv for current thread.  */
 # define INSTALL_NEW_DTV(dtv) \
-  ({ tcbhead_t *__tcbp = (tcbhead_t *)__get_cr27();    \
+  ({ tcbhead_t *__tcbp = (tcbhead_t *)__thread_pointer();      \
        __tcbp->dtv = dtv;                              \
    })
 
@@ -74,21 +76,21 @@ typedef struct
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
 # define TLS_INIT_TP(tcbp) \
-  ({ __set_cr27(tcbp); true; })
+  ({ __set_thread_pointer((void *) tcbp); true; })
 
 /* Value passed to 'clone' for initialization of the thread register.  */
 # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
 
 /* Return the address of the dtv for the current thread.  */
 # define THREAD_DTV() \
-  ({ tcbhead_t *__tcbp = (tcbhead_t *)__get_cr27();    \
+  ({ tcbhead_t *__tcbp = (tcbhead_t *)__thread_pointer();      \
        __tcbp->dtv;                                    \
    })
 
 /* Return the thread descriptor for the current thread.  */
 # define THREAD_SELF \
   ({ struct pthread *__self;                   \
-       __self = __get_cr27();                  \
+       __self = (struct pthread *)__thread_pointer();  \
        __self - 1;                             \
    })
 
@@ -100,22 +102,6 @@ typedef struct
 
 # include <tcb-access.h>
 
-static inline struct pthread *__get_cr27(void)
-{
-  long cr27;
-  asm ("mfctl %%cr27, %0" : "=r" (cr27) : );
-  return (struct pthread *) cr27;
-}
-
-/* We write to cr27, clobber r26 as the input argument, and clobber
-   r31 as the link register.  */
-static inline void __set_cr27(struct pthread *cr27)
-{
-  asm ( "ble   0xe0(%%sr2, %%r0)\n\t"
-       "copy   %0, %%r26"
-       : : "r" (cr27) : "r26", "r31" );
-}
-
 /* Get and set the global scope generation counter in struct pthread.  */
 #define THREAD_GSCOPE_FLAG_UNUSED 0
 #define THREAD_GSCOPE_FLAG_USED   1