mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-10-26 19:16:41 +00:00
Add pthread attributes and other libc functions
This commit is contained in:
parent
d5c9308a43
commit
4339d9f15e
81 changed files with 1111 additions and 428 deletions
|
|
@ -44,9 +44,9 @@ void pthread_zombies_add(struct PosixThread *pt) {
|
|||
}
|
||||
}
|
||||
|
||||
void pthread_zombies_destroy(struct Zombie *z) {
|
||||
_join(&z->pt->spawn);
|
||||
free(z->pt);
|
||||
static void pthread_zombies_collect(struct Zombie *z) {
|
||||
pthread_wait(z->pt);
|
||||
pthread_free(z->pt);
|
||||
free(z);
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ void pthread_zombies_decimate(void) {
|
|||
while ((z = atomic_load(&pthread_zombies)) &&
|
||||
atomic_load(&z->pt->status) == kPosixThreadZombie) {
|
||||
if (atomic_compare_exchange_strong(&pthread_zombies, &z, z->next)) {
|
||||
pthread_zombies_destroy(z);
|
||||
pthread_zombies_collect(z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ void pthread_zombies_harvest(void) {
|
|||
struct Zombie *z;
|
||||
while ((z = atomic_load(&pthread_zombies))) {
|
||||
if (atomic_compare_exchange_weak(&pthread_zombies, &z, z->next)) {
|
||||
pthread_zombies_destroy(z);
|
||||
pthread_zombies_collect(z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue