Simplify _get_curthread() and _tcb_ctor because libc and rtld now
already allocate thread pointer space in tls block for initial thread. Only i386 and amd64 have been done, others still have to be tested.
This commit is contained in:
parent
8f2ba610da
commit
7bd761788d
@ -38,13 +38,11 @@ struct tcb *
|
||||
_tcb_ctor(struct pthread *thread, int initial)
|
||||
{
|
||||
struct tcb *tcb;
|
||||
void *oldtls;
|
||||
|
||||
if (initial)
|
||||
__asm __volatile("movq %%fs:0, %0" : "=r" (oldtls));
|
||||
__asm __volatile("movq %%fs:0, %0" : "=r" (tcb));
|
||||
else
|
||||
oldtls = NULL;
|
||||
tcb = _rtld_allocate_tls(oldtls, sizeof(struct tcb), 16);
|
||||
tcb = _rtld_allocate_tls(NULL, sizeof(struct tcb), 16);
|
||||
if (tcb)
|
||||
tcb->tcb_thread = thread;
|
||||
return (tcb);
|
||||
|
@ -96,8 +96,6 @@ extern struct pthread *_thr_initial;
|
||||
static __inline struct pthread *
|
||||
_get_curthread(void)
|
||||
{
|
||||
if (_thr_initial)
|
||||
return (TCB_GET64(tcb_thread));
|
||||
return (NULL);
|
||||
return (TCB_GET64(tcb_thread));
|
||||
}
|
||||
#endif
|
||||
|
@ -39,14 +39,11 @@ struct tcb *
|
||||
_tcb_ctor(struct pthread *thread, int initial)
|
||||
{
|
||||
struct tcb *tcb;
|
||||
void *oldtls;
|
||||
|
||||
if (initial)
|
||||
__asm __volatile("movl %%gs:0, %0" : "=r" (oldtls));
|
||||
__asm __volatile("movl %%gs:0, %0" : "=r" (tcb));
|
||||
else
|
||||
oldtls = NULL;
|
||||
|
||||
tcb = _rtld_allocate_tls(oldtls, sizeof(struct tcb), 16);
|
||||
tcb = _rtld_allocate_tls(NULL, sizeof(struct tcb), 16);
|
||||
if (tcb)
|
||||
tcb->tcb_thread = thread;
|
||||
return (tcb);
|
||||
|
@ -100,8 +100,6 @@ extern struct pthread *_thr_initial;
|
||||
static __inline struct pthread *
|
||||
_get_curthread(void)
|
||||
{
|
||||
if (_thr_initial)
|
||||
return (TCB_GET32(tcb_thread));
|
||||
return (NULL);
|
||||
return (TCB_GET32(tcb_thread));
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user