ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
util/atomic.h
Go to the documentation of this file.
1
32
33#pragma once
34
35#include <libplatform/atomic.h>
36#include <stdbool.h>
37#include <stdint.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
61#define SHOULD_EXIT() (atomic_load(&g_should_exit))
62
78#define CLIENT_SHOULD_EXIT() (atomic_load(&g_should_exit))
79
91#define ATOMIC_LOAD_BOOL(ptr) atomic_load((atomic_t *)(ptr))
92
104#define ATOMIC_LOAD_UINT32(ptr) atomic_load((atomic_uint32_t *)(ptr))
105
117#define ATOMIC_LOAD_UINT64(ptr) atomic_load((atomic_uint64_t *)(ptr))
118
130#define ATOMIC_STORE_BOOL(ptr, value) atomic_store((atomic_t *)(ptr), (value))
131
143#define ATOMIC_STORE_UINT32(ptr, value) \
144 atomic_store((atomic_uint32_t *)(ptr), (value))
145
157#define ATOMIC_STORE_UINT64(ptr, value) \
158 atomic_store((atomic_uint64_t *)(ptr), (value))
159
180#define ATOMIC_CAS_BOOL(ptr, expected, new_value) \
181 atomic_compare_exchange_strong((atomic_t *)(ptr), &(expected), (new_value))
182
199#define ATOMIC_CAS_UINT32(ptr, expected, new_value) \
200 atomic_compare_exchange_strong((atomic_uint32_t *)(ptr), (expected), \
201 (new_value))
202
216#define ATOMIC_ADD_UINT32(ptr, delta) \
217 atomic_fetch_add((atomic_uint32_t *)(ptr), (delta))
218
232#define ATOMIC_SUB_UINT32(ptr, delta) \
233 atomic_fetch_sub((atomic_uint32_t *)(ptr), (delta))
234
235#endif
236
237#ifdef __cplusplus
238}
239#endif