2022-09-11 18:02:07 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_THREAD_WAIT_INTERNAL_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_THREAD_WAIT_INTERNAL_H_
|
2023-07-06 13:57:28 +00:00
|
|
|
#include "libc/intrin/dll.h"
|
2022-09-11 18:02:07 +00:00
|
|
|
#include "third_party/nsync/atomic.h"
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
|
|
|
/* Implementations of "struct nsync_waitable_s" must provide functions
|
|
|
|
in struct nsync_waitable_funcs_s (see public/nsync_wait.h). When
|
|
|
|
nsync_wait_n() waits on a client's object, those functions are called
|
|
|
|
with v pointing to the client's object and nw pointing to a struct
|
|
|
|
nsync_waiter_s. */
|
|
|
|
struct nsync_waiter_s {
|
|
|
|
uint32_t tag; /* used for debugging */
|
2022-10-08 04:29:40 +00:00
|
|
|
uint32_t flags; /* see below */
|
2023-07-06 13:57:28 +00:00
|
|
|
struct Dll q; /* used to link children of parent */
|
2022-09-11 18:02:07 +00:00
|
|
|
nsync_atomic_uint32_ waiting; /* non-zero <=> the waiter is waiting */
|
|
|
|
struct nsync_semaphore_s_ *sem; /* *sem will be Ved when waiter is woken */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* set if waiter is embedded in Mu/CV's internal structures */
|
|
|
|
#define NSYNC_WAITER_FLAG_MUCV 0x1
|
|
|
|
|
2023-11-10 09:42:06 +00:00
|
|
|
void nsync_waiter_destroy(void *);
|
|
|
|
|
2022-09-11 18:02:07 +00:00
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_THREAD_WAIT_INTERNAL_H_ */
|