2023-02-15 09:54:58 +00:00
|
|
|
|
|
|
|
// Note(bumbread): this file is included into threads.h when compiled under
|
2023-02-20 23:15:02 +00:00
|
|
|
// windows. Here we avoid including windows.h directly because it may be
|
|
|
|
// undesireable to include a bunch of non-standard names and types into user's
|
|
|
|
// files just to get a few of them.
|
2023-02-15 09:54:58 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-02-18 23:27:59 +00:00
|
|
|
#define ONCE_FLAG_INIT ((once_flag){0})
|
|
|
|
|
2023-02-15 09:54:58 +00:00
|
|
|
typedef struct thrd_t {
|
|
|
|
void *handle;
|
|
|
|
} thrd_t;
|
|
|
|
|
|
|
|
typedef struct tss_t {
|
2023-02-18 14:58:56 +00:00
|
|
|
unsigned tls_index;
|
2023-02-15 09:54:58 +00:00
|
|
|
} tss_t;
|
|
|
|
|
2023-02-18 23:27:59 +00:00
|
|
|
// We pretend that once_flag defined the same way as INIT_ONCE
|
|
|
|
// from winapi headers (aka _RTL_RUN_ONCE), which itself is defined
|
|
|
|
// as a union
|
|
|
|
typedef union once_flag {
|
|
|
|
void *ptr;
|
|
|
|
} once_flag;
|
|
|
|
|
2023-02-20 23:15:02 +00:00
|
|
|
// This mirrors CONDITION_VARIABLE type (aka _RTL_CONDITION_VARIABLE)
|
2023-02-18 14:58:56 +00:00
|
|
|
typedef struct cnd_t {
|
2023-02-20 23:15:02 +00:00
|
|
|
void *ptr;
|
2023-02-18 14:58:56 +00:00
|
|
|
} cnd_t;
|
|
|
|
|
2023-02-15 09:54:58 +00:00
|
|
|
typedef struct mtx_t {
|
|
|
|
int type;
|
|
|
|
// Done to handle recursive mutexes
|
|
|
|
unsigned long recursion;
|
|
|
|
unsigned long owner;
|
|
|
|
_Atomic(int) counter;
|
|
|
|
void* semaphore;
|
|
|
|
} mtx_t;
|