cosmopolitan/libc/thread/posixthread.internal.h
Justine Tunney 12d9e1e128
Improve quality of our ANSI C clock() function
It now works most excellently across all supported operating
sytsems (earlier it didn't work on NT and XNU). Demo code is
available in examples/clock.c and this change also adds some
of the newer ANSI C time functions like timespec_get(), plus
timespec_getres() which hasn't even come out yet as it's C23
2022-09-05 23:03:49 -07:00

35 lines
854 B
C

#ifndef COSMOPOLITAN_LIBC_THREAD_POSIXTHREAD_INTERNAL_H_
#define COSMOPOLITAN_LIBC_THREAD_POSIXTHREAD_INTERNAL_H_
#include "libc/runtime/runtime.h"
#include "libc/thread/spawn.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/**
* @fileoverview Cosmopolitan POSIX Thread Internals
*/
enum PosixThreadStatus {
kPosixThreadStarted,
kPosixThreadDetached,
kPosixThreadTerminated,
kPosixThreadZombie,
};
struct PosixThread {
struct spawn spawn;
void *(*start_routine)(void *);
void *arg;
void *rc;
int tid;
_Atomic(enum PosixThreadStatus) status;
jmp_buf exiter;
};
void pthread_zombies_add(struct PosixThread *);
void pthread_zombies_decimate(void);
void pthread_zombies_harvest(void);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_THREAD_POSIXTHREAD_INTERNAL_H_ */