summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018-05-07 22:39:07 -0400
committerRich Felker <dalias@aerifal.cx>2018-05-07 23:37:36 -0400
commit1db9a35569d51155eb7f2ccf26d420ae4e42e416 (patch)
tree4bd0bcefddeaae127c244c0cea659517070a1ba1 /src
parentcdba6b2562bc5c2078e0e1e6f86c8835a42ae4ff (diff)
downloadmusl-1db9a35569d51155eb7f2ccf26d420ae4e42e416.tar.gz
clean up and reduce size of internal pthread structure
over time the pthread structure has accumulated a lot of cruft taking up size. this commit removes unused fields and packs booleans and other small data more efficiently. changes which would also require changing code are not included at this time. non-volatile booleans are packed as unsigned char bitfield members. the canceldisable and cancelasync fields need volatile qualification due to how they're accessed from the cancellation signal handler and cancellable syscalls called from signal handlers. since volatile bitfield semantics are not clearly defined, discrete char objects are used instead. the pid field is completely removed; it has been unused since commit 83dc6eb087633abcf5608ad651d3b525ca2ec35e. the tid field's type is changed to int because its use is as a value in futexes, which are defined as plain int. it has no conceptual relationship to pid_t. also, its position is not ABI. startlock is reduced to a length-1 array. the second element was presumably intended as a waiter count, but it was never used and made no sense, since there is at most one waiter.
Diffstat (limited to 'src')
-rw-r--r--src/internal/pthread_impl.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
index 0a65fa37..fc2def63 100644
--- a/src/internal/pthread_impl.h
+++ b/src/internal/pthread_impl.h
@@ -19,16 +19,21 @@ struct pthread {
void **dtv, *unused1, *unused2;
uintptr_t sysinfo;
uintptr_t canary, canary2;
- pid_t tid, pid;
/* Part 2 -- implementation details, non-ABI. */
- int tsd_used, errno_val;
- volatile int cancel, canceldisable, cancelasync;
+ int tid;
+ int errno_val;
volatile int detach_state;
+ volatile int cancel;
+ volatile unsigned char canceldisable, cancelasync;
+ unsigned char tsd_used:1;
+ unsigned char unblock_cancel:1;
+ unsigned char dlerror_flag:1;
unsigned char *map_base;
size_t map_size;
void *stack;
size_t stack_size;
+ size_t guard_size;
void *start_arg;
void *(*start)(void *);
void *result;
@@ -39,16 +44,13 @@ struct pthread {
long off;
volatile void *volatile pending;
} robust_list;
- int unblock_cancel;
volatile int timer_id;
locale_t locale;
volatile int killlock[1];
- volatile int startlock[2];
+ volatile int startlock[1];
unsigned long sigmask[_NSIG/8/sizeof(long)];
char *dlerror_buf;
- int dlerror_flag;
void *stdio_locks;
- size_t guard_size;
/* Part 3 -- the positions of these fields relative to
* the end of the structure is external and internal ABI. */