aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorMichael Jeanson <mjeanson@efficios.com>2024-12-27 17:41:02 +0100
committerFlorian Weimer <fweimer@redhat.com>2024-12-27 17:41:02 +0100
commit0852c4aab7870adbd188f7d27985f1631c8596df (patch)
treebd7c272548d667815fb43e119f53c8e66a61a0b0 /sysdeps
parent6fdb6abeb2db516c436fb34411debba555499e19 (diff)
downloadglibc-0852c4aab7870adbd188f7d27985f1631c8596df.zip
glibc-0852c4aab7870adbd188f7d27985f1631c8596df.tar.gz
glibc-0852c4aab7870adbd188f7d27985f1631c8596df.tar.bz2
nptl: hppa: replace __get_cr27 with __thread_pointer
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>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/hppa/nptl/thread_pointer.h10
-rw-r--r--sysdeps/hppa/nptl/tls.h26
2 files changed, 16 insertions, 20 deletions
diff --git a/sysdeps/hppa/nptl/thread_pointer.h b/sysdeps/hppa/nptl/thread_pointer.h
index 96f5e9b..acd6fa5 100644
--- a/sysdeps/hppa/nptl/thread_pointer.h
+++ b/sysdeps/hppa/nptl/thread_pointer.h
@@ -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 */
diff --git a/sysdeps/hppa/nptl/tls.h b/sysdeps/hppa/nptl/tls.h
index 82055fa..c97bdbc 100644
--- a/sysdeps/hppa/nptl/tls.h
+++ b/sysdeps/hppa/nptl/tls.h
@@ -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