Make detached threads work better

This change adds a double linked list of threads, so that pthread_exit()
will know when it should call exit() from an orphaned child. This change
also improves ftrace and strace logging.
This commit is contained in:
Justine Tunney 2022-11-09 03:58:57 -08:00
parent b74d8c1acd
commit cee6871710
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
37 changed files with 638 additions and 314 deletions

View file

@ -45,18 +45,17 @@ extern unsigned __tls_index;
void __require_tls(void);
void __set_tls(struct CosmoTib *);
#if defined(__GNUC__) && defined(__x86_64__) && !defined(__STRICT_ANSI__)
/**
* Returns location of thread information block.
*
* This can't be used in privileged functions.
*/
static inline struct CosmoTib *__get_tls(void) {
struct CosmoTib *_tib;
asm("mov\t%%fs:0,%0" : "=r"(_tib) : /* no inputs */ : "memory");
return _tib;
}
#endif /* GNU x86-64 */
#define __get_tls() \
({ \
struct CosmoTib *_t; \
asm("mov\t%%fs:0,%0" : "=r"(_t) : /* no inputs */ : "memory"); \
_t; \
})
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */