deduplicate TP_ADJ logic out of each arch, replace with TP_OFFSET
authorRich Felker <dalias@aerifal.cx>
Tue, 25 Aug 2020 02:04:52 +0000 (22:04 -0400)
committerRich Felker <dalias@aerifal.cx>
Tue, 25 Aug 2020 02:04:52 +0000 (22:04 -0400)
the only part of TP_ADJ that was not uniquely determined by
TLS_ABOVE_TP was the 0x7000 adjustment used mainly on mips and powerpc
variants.

17 files changed:
arch/aarch64/pthread_arch.h
arch/arm/pthread_arch.h
arch/i386/pthread_arch.h
arch/m68k/pthread_arch.h
arch/microblaze/pthread_arch.h
arch/mips/pthread_arch.h
arch/mips64/pthread_arch.h
arch/mipsn32/pthread_arch.h
arch/or1k/pthread_arch.h
arch/powerpc/pthread_arch.h
arch/powerpc64/pthread_arch.h
arch/riscv64/pthread_arch.h
arch/s390x/pthread_arch.h
arch/sh/pthread_arch.h
arch/x32/pthread_arch.h
arch/x86_64/pthread_arch.h
src/internal/pthread_impl.h

index e64b126..f3c005c 100644 (file)
@@ -7,6 +7,5 @@ static inline struct pthread *__pthread_self()
 
 #define TLS_ABOVE_TP
 #define GAP_ABOVE_TP 16
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread))
 
 #define MC_PC pc
index e689ea2..4864098 100644 (file)
@@ -28,6 +28,5 @@ static inline pthread_t __pthread_self()
 
 #define TLS_ABOVE_TP
 #define GAP_ABOVE_TP 8
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread))
 
 #define MC_PC arm_pc
index 6f600b9..32570a1 100644 (file)
@@ -5,6 +5,4 @@ static inline struct pthread *__pthread_self()
        return self;
 }
 
-#define TP_ADJ(p) (p)
-
 #define MC_PC gregs[REG_EIP]
index 02d5b8a..7c9990c 100644 (file)
@@ -6,8 +6,8 @@ static inline struct pthread *__pthread_self()
 
 #define TLS_ABOVE_TP
 #define GAP_ABOVE_TP 0
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
 
+#define TP_OFFSET 0x7000
 #define DTP_OFFSET 0x8000
 
 #define MC_PC gregs[R_PC]
index f6ba8de..c327f4e 100644 (file)
@@ -5,6 +5,4 @@ static inline struct pthread *__pthread_self()
        return self;
 }
 
-#define TP_ADJ(p) (p)
-
 #define MC_PC regs.pc
index 1e7839e..c22eb34 100644 (file)
@@ -12,8 +12,8 @@ static inline struct pthread *__pthread_self()
 
 #define TLS_ABOVE_TP
 #define GAP_ABOVE_TP 0
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
 
+#define TP_OFFSET 0x7000
 #define DTP_OFFSET 0x8000
 
 #define MC_PC pc
index 1e7839e..c22eb34 100644 (file)
@@ -12,8 +12,8 @@ static inline struct pthread *__pthread_self()
 
 #define TLS_ABOVE_TP
 #define GAP_ABOVE_TP 0
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
 
+#define TP_OFFSET 0x7000
 #define DTP_OFFSET 0x8000
 
 #define MC_PC pc
index 1e7839e..c22eb34 100644 (file)
@@ -12,8 +12,8 @@ static inline struct pthread *__pthread_self()
 
 #define TLS_ABOVE_TP
 #define GAP_ABOVE_TP 0
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
 
+#define TP_OFFSET 0x7000
 #define DTP_OFFSET 0x8000
 
 #define MC_PC pc
index 1b806f8..76d0a8b 100644 (file)
@@ -13,6 +13,5 @@ static inline struct pthread *__pthread_self()
 
 #define TLS_ABOVE_TP
 #define GAP_ABOVE_TP 0
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread))
 
 #define MC_PC regs.pc
index ae0f28d..9697046 100644 (file)
@@ -7,8 +7,8 @@ static inline struct pthread *__pthread_self()
                         
 #define TLS_ABOVE_TP
 #define GAP_ABOVE_TP 0
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
 
+#define TP_OFFSET 0x7000
 #define DTP_OFFSET 0x8000
 
 // the kernel calls the ip "nip", it's the first saved value after the 32
index 79c3ecd..e9dba43 100644 (file)
@@ -7,8 +7,8 @@ static inline struct pthread *__pthread_self()
 
 #define TLS_ABOVE_TP
 #define GAP_ABOVE_TP 0
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
 
+#define TP_OFFSET 0x7000
 #define DTP_OFFSET 0x8000
 
 // the kernel calls the ip "nip", it's the first saved value after the 32
index db414b1..50f0868 100644 (file)
@@ -7,7 +7,6 @@ static inline struct pthread *__pthread_self()
 
 #define TLS_ABOVE_TP
 #define GAP_ABOVE_TP 0
-#define TP_ADJ(p) ((char *)p + sizeof(struct pthread))
 
 #define DTP_OFFSET 0x800
 
index e2251f1..5d22546 100644 (file)
@@ -9,6 +9,4 @@ static inline struct pthread *__pthread_self()
        return self;
 }
 
-#define TP_ADJ(p) (p)
-
 #define MC_PC psw.addr
index 3ee9c1a..c225290 100644 (file)
@@ -7,7 +7,6 @@ static inline struct pthread *__pthread_self()
 
 #define TLS_ABOVE_TP
 #define GAP_ABOVE_TP 8
-#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread))
 
 #define MC_PC sc_pc
 
index f640a1a..fa45283 100644 (file)
@@ -5,8 +5,6 @@ static inline struct pthread *__pthread_self()
        return self;
 }
 
-#define TP_ADJ(p) (p)
-
 #define MC_PC gregs[REG_RIP]
 
 #define CANARY canary2
index 65e880c..1c64a84 100644 (file)
@@ -5,6 +5,4 @@ static inline struct pthread *__pthread_self()
        return self;
 }
 
-#define TP_ADJ(p) (p)
-
 #define MC_PC gregs[REG_RIP]
index 5749a33..3c2bd76 100644 (file)
@@ -105,10 +105,20 @@ struct __timer {
 #define CANARY canary
 #endif
 
+#ifndef TP_OFFSET
+#define TP_OFFSET 0
+#endif
+
 #ifndef DTP_OFFSET
 #define DTP_OFFSET 0
 #endif
 
+#ifdef TLS_ABOVE_TP
+#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + TP_OFFSET)
+#else
+#define TP_ADJ(p) (p)
+#endif
+
 #ifndef tls_mod_off_t
 #define tls_mod_off_t size_t
 #endif