提交 1db9a355 编写于 作者: R Rich Felker

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
83dc6eb0.

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.
上级 cdba6b25
......@@ -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. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册