path: root/src/internal/pthread_impl.h
diff options
authorRich Felker <>2018-10-12 00:30:34 -0400
committerRich Felker <>2018-10-12 00:39:56 -0400
commitb6d701a47504e5ef9c6a19b2f6a703c72cb9e8ac (patch)
tree861aaaf569834e7ce9ec03c879f53955d15b73e7 /src/internal/pthread_impl.h
parent09a805a62307307230a31125425d0c2b0b6f332e (diff)
combine arch ABI's DTP_OFFSET into DTV pointers
as explained in commit 6ba5517a460c6c438f64d69464fdfc3269a4c91a, some archs use an offset (typicaly -0x8000) with their DTPOFF relocations, which __tls_get_addr needs to invert. on affected archs, which lack direct support for large immediates, this can cost multiple extra instructions in the hot path. instead, incorporate the DTP_OFFSET into the DTV entries. this means they are no longer valid pointers, so store them as an array of uintptr_t rather than void *; this also makes it easier to access slot 0 as a valid slot count. commit e75b16cf93ebbc1ce758d3ea6b2923e8b2457c68 left behind cruft in two places, __reset_tls and __tls_get_new, from back when it was possible to have uninitialized gap slots indicated by a null pointer in the DTV. since the concept of null pointer is no longer meaningful with an offset applied, remove this cruft. presently there are no archs with both TLSDESC and nonzero DTP_OFFSET, but the dynamic TLSDESC relocation code is also updated to apply an inverted offset to its offset field, so that the offset DTV would not impose a runtime cost in TLSDESC resolver functions.
Diffstat (limited to 'src/internal/pthread_impl.h')
1 files changed, 3 insertions, 2 deletions
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
index d491f975..7a25b88e 100644
--- a/src/internal/pthread_impl.h
+++ b/src/internal/pthread_impl.h
@@ -17,7 +17,8 @@ struct pthread {
/* Part 1 -- these fields may be external or
* internal (accessed via asm) ABI. Do not change. */
struct pthread *self;
- void **dtv, *unused1, *unused2;
+ uintptr_t *dtv;
+ void *unused1, *unused2;
uintptr_t sysinfo;
uintptr_t canary, canary2;
@@ -54,7 +55,7 @@ struct pthread {
/* Part 3 -- the positions of these fields relative to
* the end of the structure is external and internal ABI. */
uintptr_t canary_at_end;
- void **dtv_copy;
+ uintptr_t *dtv_copy;
struct start_sched_args {