2021-10-13 18:26:05 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_THREAD_DESCRIPTOR_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_THREAD_DESCRIPTOR_H_
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
2022-05-27 20:25:46 +00:00
|
|
|
#include "libc/runtime/runtime.h"
|
2021-10-13 18:26:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview thread types
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum cthread_state {
|
|
|
|
cthread_started = 0,
|
|
|
|
cthread_joining = 1,
|
|
|
|
cthread_finished = 2,
|
|
|
|
cthread_detached = 4,
|
2021-10-25 23:02:26 +00:00
|
|
|
cthread_main = 127,
|
2021-10-13 18:26:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct cthread_descriptor_t {
|
2022-05-27 20:25:46 +00:00
|
|
|
struct cthread_descriptor_t *self; /* 0x00 */
|
|
|
|
void *(*func)(void *); /* 0x08 */
|
|
|
|
int32_t __pad0; /* 0x10 */
|
|
|
|
int32_t state; /* 0x14 */
|
|
|
|
void *arg; /* 0x18 */
|
|
|
|
void *pthread_ret_ptr; /* 0x20 */
|
|
|
|
int64_t __pad1; /* 0x28 */
|
|
|
|
struct cthread_descriptor_t *self2; /* 0x30 */
|
|
|
|
int32_t tid; /* 0x38 */
|
|
|
|
int32_t err; /* 0x3c */
|
|
|
|
void *exitcode;
|
2021-10-13 18:26:05 +00:00
|
|
|
struct {
|
2022-05-27 20:25:46 +00:00
|
|
|
char *top, *bottom;
|
|
|
|
} stack, alloc;
|
|
|
|
jmp_buf exiter;
|
2021-10-13 18:26:05 +00:00
|
|
|
};
|
|
|
|
|
2022-05-27 20:25:46 +00:00
|
|
|
typedef struct cthread_descriptor_t *cthread_t;
|
2021-10-13 18:26:05 +00:00
|
|
|
|
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_THREAD_DESCRIPTOR_H_ */
|