deduplicate __pthread_self thread pointer adjustment out of each arch
[musl] / src / internal / pthread_impl.h
index 3c2bd76..58e0613 100644 (file)
@@ -115,8 +115,10 @@ struct __timer {
 
 #ifdef TLS_ABOVE_TP
 #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + TP_OFFSET)
+#define __pthread_self() ((pthread_t)(__get_tp() - sizeof(struct __pthread) - TP_OFFSET))
 #else
 #define TP_ADJ(p) (p)
+#define __pthread_self() ((pthread_t)__get_tp())
 #endif
 
 #ifndef tls_mod_off_t