|
rlib
Convenience library for useful things
|
Atomic load / store / exchange / CAS / fetch-modify operations on integer, unsigned-integer and pointer types. More...
#include <rlib/rtypes.h>Go to the source code of this file.
Macros | |
Atomic boolean (raboolean) sugar | |
Convenience macros over the | |
| #define | r_atomic_bool_load(a) ((rboolean) r_atomic_int_load (a)) |
| Atomically read an raboolean. | |
| #define | r_atomic_bool_store(a, v) r_atomic_int_store (a, (int) (v)) |
Atomically store v into an raboolean. | |
| #define | r_atomic_bool_exchange(a, v) ((rboolean) r_atomic_int_exchange (a, (int) (v))) |
Atomically write v and return the previous value. | |
| #define | r_atomic_bool_set(a) r_atomic_bool_store (a, TRUE) |
Convenience: atomically store TRUE. | |
| #define | r_atomic_bool_unset(a) r_atomic_bool_store (a, FALSE) |
Convenience: atomically store FALSE. | |
Typedefs | |
| typedef int | raint |
| typedef ruint | rauint |
| typedef rpointer | raptr |
| typedef raint | raboolean |
Atomic-friendly boolean; thin alias over raint so the boolean accessors funnel through r_atomic_int_* with rboolean casts. | |
Functions | |
Atomic int (raint) operations | |
| int | r_atomic_int_load (raint *a) |
Atomically read a's value. | |
| void | r_atomic_int_store (raint *a, int val) |
Atomically store val into a. | |
| int | r_atomic_int_exchange (raint *a, int val) |
Atomically write val and return the previous value. | |
| rboolean | r_atomic_int_cmp_xchg_weak (raint *a, int *old, int val) |
Weak compare-and-swap: if *a equals *old, store val and return TRUE; otherwise write the current *a back into *old and return FALSE. | |
| rboolean | r_atomic_int_cmp_xchg_strong (raint *a, int *old, int val) |
| Strong compare-and-swap: as r_atomic_int_cmp_xchg_weak but no spurious failure. | |
| int | r_atomic_int_fetch_add (raint *a, int val) |
Atomically compute *a += val and return the previous *a. | |
| int | r_atomic_int_fetch_sub (raint *a, int val) |
Atomically compute *a -= val and return the previous *a. | |
| int | r_atomic_int_fetch_and (raint *a, int val) |
Atomically compute *a &= val and return the previous *a. | |
| int | r_atomic_int_fetch_or (raint *a, int val) |
Atomically compute *a |= val and return the previous *a. | |
| int | r_atomic_int_fetch_xor (raint *a, int val) |
Atomically compute *a ^= val and return the previous *a. | |
Atomic unsigned int (rauint) operations | |
| ruint | r_atomic_uint_load (rauint *a) |
Atomically read a's value. | |
| void | r_atomic_uint_store (rauint *a, ruint val) |
Atomically store val into a. | |
| ruint | r_atomic_uint_exchange (rauint *a, ruint val) |
Atomically write val and return the previous value. | |
| rboolean | r_atomic_uint_cmp_xchg_weak (rauint *a, ruint *old, ruint val) |
| Weak CAS; see r_atomic_int_cmp_xchg_weak for semantics. | |
| rboolean | r_atomic_uint_cmp_xchg_strong (rauint *a, ruint *old, ruint val) |
| Strong CAS; no spurious failures. | |
| ruint | r_atomic_uint_fetch_add (rauint *a, ruint val) |
Atomically compute *a += val and return the previous *a. | |
| ruint | r_atomic_uint_fetch_sub (rauint *a, ruint val) |
Atomically compute *a -= val and return the previous *a. | |
| ruint | r_atomic_uint_fetch_and (rauint *a, ruint val) |
Atomically compute *a &= val and return the previous *a. | |
| ruint | r_atomic_uint_fetch_or (rauint *a, ruint val) |
Atomically compute *a |= val and return the previous *a. | |
| ruint | r_atomic_uint_fetch_xor (rauint *a, ruint val) |
Atomically compute *a ^= val and return the previous *a. | |
Atomic pointer (raptr) operations | |
| rpointer | r_atomic_ptr_load (raptr *a) |
Atomically read a's pointer value. | |
| void | r_atomic_ptr_store (raptr *a, rpointer val) |
Atomically store val into a. | |
| rpointer | r_atomic_ptr_exchange (raptr *a, rpointer val) |
Atomically write val and return the previous value. | |
| rboolean | r_atomic_ptr_cmp_xchg_weak (raptr *a, rpointer *old, rpointer val) |
| Weak CAS on pointer storage; see r_atomic_int_cmp_xchg_weak for semantics. | |
| rboolean | r_atomic_ptr_cmp_xchg_strong (raptr *a, rpointer *old, rpointer val) |
| Strong CAS on pointer storage; no spurious failures. | |
| rpointer | r_atomic_ptr_fetch_add (raptr *a, rpointer val) |
Pointer-arithmetic fetch-add: atomically *a += val and return the previous pointer. | |
| rpointer | r_atomic_ptr_fetch_sub (raptr *a, rpointer val) |
| Pointer-arithmetic fetch-sub; semantics mirror r_atomic_ptr_fetch_add. | |
| rpointer | r_atomic_ptr_fetch_and (raptr *a, rpointer val) |
Bitwise &= over pointer storage (treat as integer width). | |
| rpointer | r_atomic_ptr_fetch_or (raptr *a, rpointer val) |
Bitwise |= over pointer storage. | |
| rpointer | r_atomic_ptr_fetch_xor (raptr *a, rpointer val) |
Bitwise ^= over pointer storage. | |
Atomic load / store / exchange / CAS / fetch-modify operations on integer, unsigned-integer and pointer types.