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>
This commit is contained in:
Michael Jeanson 2024-12-27 17:41:02 +01:00 committed by Florian Weimer
parent 6fdb6abeb2
commit 0852c4aab7
2 changed files with 16 additions and 20 deletions

View 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 */

View 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