27 #ifndef EMBB_BASE_C_ATOMIC_H_ 28 #define EMBB_BASE_C_ATOMIC_H_ 98 emb_atomic_TYPE* variable,
114 emb_atomic_TYPE* variable
131 embb_atomic_TYPE* variable,
158 embb_atomic_TYPE* variable,
180 embb_atomic_TYPE* variable,
200 const embb_atomic_TYPE* variable
225 embb_atomic_TYPE* variable,
244 embb_atomic_TYPE* variable,
264 embb_atomic_TYPE* variable,
283 embb_atomic_TYPE* variable,
291 #include <embb/base/c/internal/config.h> 292 #include <embb/base/c/internal/platform.h> 298 #ifdef EMBB_THREADING_ANALYSIS_MODE 317 #define EMBB_ATOMIC_MUTEX_INIT(mutex) embb_mutex_init(&(mutex), 0) 318 #define EMBB_ATOMIC_MUTEX_LOCK(mutex) embb_mutex_lock(&(mutex)) 319 #define EMBB_ATOMIC_MUTEX_UNLOCK(mutex) embb_mutex_unlock(&(mutex)) 320 #define EMBB_ATOMIC_MUTEX_DESTROY(mutex) embb_mutex_destroy(&(mutex)) 324 #define EMBB_ATOMIC_MUTEX_INIT(...) 325 #define EMBB_ATOMIC_MUTEX_LOCK(...) 326 #define EMBB_ATOMIC_MUTEX_UNLOCK(...) 327 #define EMBB_ATOMIC_MUTEX_DESTROY(...) 336 static int embb_atomic_test_marker(uint32_t marker) {
337 if (marker == 0x12345678) {
344 #define EMBB_ATOMIC_INIT_CHECK(variable) assert(embb_atomic_test_marker(variable->marker)) 345 #define EMBB_ATOMIC_INIT_MARKER(variable) variable->marker = 0x12345678 346 #define EMBB_ATOMIC_DESTROY_MARKER(variable) variable->marker = 0 350 #define EMBB_ATOMIC_INIT_CHECK(variable) (void)(variable) 351 #define EMBB_ATOMIC_INIT_MARKER(variable) (void)(variable) 352 #define EMBB_ATOMIC_DESTROY_MARKER(variable) (void)(variable) 360 #include <embb/base/c/internal/atomic/atomic.h> 362 #endif //EMBB_BASE_C_ATOMIC_H_ int embb_atomic_compare_and_swap_TYPE(embb_atomic_TYPE *variable, TYPE *expected, TYPE desired)
Compares variable with expected and, if equivalent, swaps its value with desired. ...
void embb_atomic_destroy_TYPE(emb_atomic_TYPE *variable)
Destroys an atomic variable and frees its resources.
void embb_atomic_or_assign_TYPE(embb_atomic_TYPE *variable, TYPE value)
Computes the logical "or" of the value stored in variable and value.
TYPE embb_atomic_fetch_and_add_TYPE(embb_atomic_TYPE *variable, TYPE value)
Adds value to variable and returns its old value.
void embb_atomic_init_TYPE(emb_atomic_TYPE *variable, TYPE initial_value)
Initializes an atomic variable.
int embb_mutex_unlock(embb_mutex_t *mutex)
Unlocks a locked mutex.
TYPE embb_atomic_swap_TYPE(embb_atomic_TYPE *variable, TYPE value)
Swaps the current value of variable with value.
int embb_mutex_init(embb_mutex_t *mutex, int type)
Initializes a mutex.
void embb_atomic_memory_barrier()
Enforces a memory barrier (full fence).
void embb_atomic_store_TYPE(embb_atomic_TYPE *variable, int value)
Stores value in variable.
int embb_mutex_lock(embb_mutex_t *mutex)
Waits until the mutex can be locked and locks it.
void embb_mutex_destroy(embb_mutex_t *mutex)
Destroys a mutex and frees its resources.
opaque_type embb_mutex_t
Opaque type representing a mutex.
Definition: mutex.h:55
void embb_atomic_xor_assign_TYPE(embb_atomic_TYPE *variable, TYPE value)
Computes the logical "xor" of the value stored in variable and value.
TYPE embb_atomic_load_TYPE(const embb_atomic_TYPE *variable)
Loads the value of variable and returns it.
void embb_atomic_and_assign_TYPE(embb_atomic_TYPE *variable, TYPE value)
Computes the logical "and" of the value stored in variable and value.