8#ifndef LIBCLOD_THREAD_H
9#define LIBCLOD_THREAD_H
12 #define clod_atomic_load(ptr) __atomic_load_n(ptr, __ATOMIC_SEQ_CST)
13 #define clod_atomic_cas(ptr, expected, desired) __atomic_compare_exchange_n(\
14 ptr, expected, desired,\
15 false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST\
17 #define clod_atomic_store(ptr, val) __atomic_store_n(ptr, val, __ATOMIC_SEQ_CST)
18 #define clod_atomic_add(ptr, val) __atomic_add_fetch(ptr, val, __ATOMIC_SEQ_CST)
66enum clod_process_result {
68 CLOD_PROCESS_INVALID = 1,
69 CLOD_PROCESS_NO_MEMORY = 2,
70 CLOD_PROCESS_UNSUPPORTED = 3
73typedef int clod_process_main(
int argc,
char **argv);
102typedef uintptr_t clod_process;
110CLOD_API CLOD_NONNULL(1)
111enum clod_process_result
118enum clod_process_result
121#define CLOD_SPINLOCK_INIT 0
128CLOD_API CLOD_NONNULL(1)
133CLOD_API CLOD_NONNULL(1)
136#define CLOD_ONCE_INIT 0
138#define CLOD_ONCE(once) for (bool _do_once = clod_once_do(once); _do_once; clod_once_done(once), _do_once = false)
147CLOD_API CLOD_NONNULL(1)
152CLOD_API CLOD_NONNULL(1)
183int64_t
clod_timer(int64_t *time, int64_t duration_us);
189#define CLOD_MUTEX_INIT 0
196CLOD_API CLOD_NONNULL(1)
201CLOD_API CLOD_NONNULL(1)
int64_t clod_timer(int64_t *time, int64_t duration_us)
enum clod_process_result clod_process_join(clod_process process)
void clod_once_done(clod_once *once)
void clod_mutex_unlock(clod_mutex *mutex)
void clod_spinlock_lock(clod_spinlock *spinlock)
void clod_spinlock_unlock(clod_spinlock *spinlock)
bool clod_once_do(clod_once *once)
void clod_mutex_lock(clod_mutex *mutex)
enum clod_process_result clod_process_start(struct clod_process_opts *opts, clod_process *process_out)
clod_process_main * main
Process entry point.
int arg_count
Number of arguments passed to main.
enum clod_process_type type
Type of process to create.