Veritable Lasagna
An Allocator & Data Structure Library for C.
|
Go to the source code of this file.
Macros | |
#define | VL_ATOMIC _Atomic |
#define | VL_ATOMIC_TYPEDEF(x) typedef VL_ATOMIC x |
#define | vlAtomicLoad(ptr) atomic_load(ptr) |
Performs a generic atomic read operation. | |
#define | vlAtomicLoadExplicit(ptr, order) atomic_load_explicit(ptr, (memory_order)(order)) |
Performs a generic atomic read operation. | |
#define | vlAtomicStore(ptr, val) atomic_store(ptr, val) |
Performs a generic atomic write operation. | |
#define | vlAtomicStoreExplicit(ptr, order) atomic_store_explicit(ptr, (memory_order)(order)) |
Performs a generic atomic write operation. | |
#define | vlAtomicFetchAdd(ptr, arg) atomic_fetch_add(ptr, arg) |
Performs a generic atomic addition operation. | |
#define | vlAtomicFetchSub(ptr, arg) atomic_fetch_sub(ptr, arg) |
Performs a generic atomic subtraction operation. | |
#define | vlAtomicFetchOr(ptr, arg) atomic_fetch_or(ptr, arg) |
Performs a generic atomic bitwise OR operation. | |
#define | vlAtomicFetchXor(ptr, arg) atomic_fetch_xor(ptr, arg) |
Performs a generic atomic bitwise XOR operation. | |
#define | vlAtomicFetchAnd(ptr, arg) atomic_fetch_and(ptr, arg) |
Performs a generic atomic bitwise AND operation. | |
#define | vlAtomicFetchAddExplicit(ptr, arg, order) atomic_fetch_add_explicit(ptr, arg, (memory_order)(order)) |
Performs a generic atomic addition operation. | |
#define | vlAtomicFetchSubExplicit(ptr, arg, order) atomic_fetch_sub_explicit(ptr, arg, (memory_order)(order)) |
Performs a generic atomic subtraction operation. | |
#define | vlAtomicFetchOrExplicit(ptr, arg, order) atomic_fetch_or_explicit(ptr, arg, (memory_order)(order)) |
Performs a generic atomic bitwise OR operation. | |
#define | vlAtomicFetchXorExplicit(ptr, arg, order) atomic_fetch_xor_explicit(ptr, arg, (memory_order)(order)) |
Performs a generic atomic bitwise XOR operation. | |
#define | vlAtomicFetchAndExplicit(ptr, arg, order) atomic_fetch_and_explicit(ptr, arg, (memory_order)(order)) |
Performs a generic atomic bitwise AND operation. | |
#define | vlAtomicCompareExchangeWeak(ptr, expectedPtr, desired) atomic_compare_exchange_weak(ptr, expectedPtr, desired) |
Atomically compares the memory at ptr with. If *ptr == *expectedPtr, *ptr = desired. | |
#define | vlAtomicCompareExchangeStrong(ptr, expectedPtr, desired) atomic_compare_exchange_strong(ptr, expectedPtr, desired) |
Atomically compares the memory at ptr with. If *ptr == *expectedPtr, *ptr = desired. | |
#define | vlAtomicCompareExchangeWeakExplicit(ptr, expectedPtr, desired, trueOrder, falseOrder) atomic_compare_exchange_weak_explicit(ptr, expectedPtr, desired, (memory_order)(trueOrder), (memory_order)(falseOrder)) |
Atomically compares the memory at ptr with. If *ptr == *expectedPtr, *ptr = desired. | |
#define | vlAtomicCompareExchangeStrongExplicit(ptr, expectedPtr, desired, trueOrder, falseOrder) atomic_compare_exchange_strong_explicit(ptr, expectedPtr, desired, (memory_order)(trueOrder), (memory_order)(falseOrder)) |
Atomically compares the memory at ptr with. If *ptr == *expectedPtr, *ptr = desired. | |
#define | vlAtomicThreadFence(order) atomic_thread_fence((memory_order)(order)) |
Prepares memory synchronization of non-atomic and relaxed atomic accesses. | |
#define | vlAtomicFlagTestAndSet(ptr) atomic_flag_test_and_set(ptr) |
Atomically sets a flag to true and returns the old value. | |
#define | vlAtomicFlagClear(ptr) atomic_flag_clear(ptr) |
Atomically sets the flag to false. | |
#define | vlAtomicFlagTestAndSetExplicit(ptr, order) atomic_flag_test_and_set_explicit(ptr, (memory_order)(order)) |
Atomically sets a flag to true and returns the old value. | |
#define | vlAtomicFlagClearExplicit(ptr, order) atomic_flag_clear_explicit(ptr, (memory_order)(order)) |
Atomically sets a flag to false. | |
#define | vlAtomicInit(ptr) atomic_init(ptr) |
Initializes an existing atomic object. | |
Enumerations | |
enum | vl_memory_order_t { VL_MEMORY_ORDER_RELAXED = memory_order_relaxed , VL_MEMORY_ORDER_ACQUIRE = memory_order_acquire , VL_MEMORY_ORDER_RELEASE = memory_order_release , VL_MEMORY_ORDER_ACQ_REL = memory_order_acq_rel , VL_MEMORY_ORDER_SEQ_CST = memory_order_seq_cst } |
Memory order enumeration. Dictates reordering of memory accesses surrounding and including atomic operations. More... | |
Functions | |
VL_ATOMIC_TYPEDEF (vl_bool_t) vl_atomic_bool_t | |
VL_ATOMIC_TYPEDEF (vl_int_t) vl_atomic_int_t | |
VL_ATOMIC_TYPEDEF (vl_uint_t) vl_atomic_uint_t | |
VL_ATOMIC_TYPEDEF (vl_intptr_t) vl_atomic_intptr_t | |
VL_ATOMIC_TYPEDEF (vl_uintptr_t) vl_atomic_uintptr_t | |
VL_ATOMIC_TYPEDEF (vl_ularge_t) vl_atomic_ularge_t | |
VL_ATOMIC_TYPEDEF (vl_usmall_t) vl_atomic_usmall_t | |
VL_ATOMIC_TYPEDEF (vl_ilarge_t) vl_atomic_ilarge_t | |
VL_ATOMIC_TYPEDEF (vl_ismall_t) vl_atomic_ismall_t | |
VL_ATOMIC_TYPEDEF (atomic_flag) vl_atomic_flag_t | |
#define VL_ATOMIC _Atomic |
This header provides a wrapper over the C11 atomic functions, providing an abstraction using the VL number types. Primarily used for "all in one place" documentation, the header is intended to "smooth out" usage of atomic types to conform to the way the rest of the library is documented and used.
#define VL_ATOMIC_TYPEDEF | ( | x | ) | typedef VL_ATOMIC x |
#define vlAtomicCompareExchangeStrong | ( | ptr, | |
expectedPtr, | |||
desired ) atomic_compare_exchange_strong(ptr, expectedPtr, desired) |
Atomically compares the memory at ptr with. If *ptr == *expectedPtr, *ptr = desired.
If the comparison is true, this performs a read-modify-write operation. Otherwise, this only performs a read operation.
The memory order used for these operations is VL_MEMORY_ORDER_SEQ_CST.
Guarantees that if the comparison fails, it’s because the value has actually changed. Will never fail spuriously.
ptr | Pointer to the atomic object to perform the operation on. |
expectedPtr | Pointer to do a bitwise comparison with. |
desired | Value to copy to the memory pointed to by ptr. |
#define vlAtomicCompareExchangeStrongExplicit | ( | ptr, | |
expectedPtr, | |||
desired, | |||
trueOrder, | |||
falseOrder ) atomic_compare_exchange_strong_explicit(ptr, expectedPtr, desired, (memory_order)(trueOrder), (memory_order)(falseOrder)) |
Atomically compares the memory at ptr with. If *ptr == *expectedPtr, *ptr = desired.
If the comparison is true, this performs a read-modify-write operation. Otherwise, this only performs a read operation.
Guarantees that if the comparison fails, it’s because the value has actually changed. Will never fail spuriously.
ptr | Pointer to the atomic object to perform the operation on. |
expectedPtr | Pointer to do a bitwise comparison with. |
desired | Value to copy to the memory pointed to by ptr. |
trueOrder | Memory order used in the case of a true comparison. |
falseOrder | Memory order used in the case of a false comparison. |
#define vlAtomicCompareExchangeWeak | ( | ptr, | |
expectedPtr, | |||
desired ) atomic_compare_exchange_weak(ptr, expectedPtr, desired) |
Atomically compares the memory at ptr with. If *ptr == *expectedPtr, *ptr = desired.
If the comparison is true, this performs a read-modify-write operation. Otherwise, this only performs a read operation.
The memory order used for these operations is VL_MEMORY_ORDER_SEQ_CST.
The weak variant of an atomic compare-exchange is allowed to fail spuriously. That is, act as if *ptr != *expectedPtr, even if they are equal. This variant likely offers better performance in loops.
ptr | Pointer to the atomic object to perform the operation on. |
expectedPtr | Pointer to do a bitwise comparison with. |
desired | Value to copy to the memory pointed to by ptr. |
#define vlAtomicCompareExchangeWeakExplicit | ( | ptr, | |
expectedPtr, | |||
desired, | |||
trueOrder, | |||
falseOrder ) atomic_compare_exchange_weak_explicit(ptr, expectedPtr, desired, (memory_order)(trueOrder), (memory_order)(falseOrder)) |
Atomically compares the memory at ptr with. If *ptr == *expectedPtr, *ptr = desired.
If the comparison is true, this performs a read-modify-write operation. Otherwise, this only performs a read operation.
The weak variant of an atomic compare-exchange is allowed to fail spuriously. That is, act as if *ptr != *expectedPtr, even if they are equal. This variant likely offers better performance in loops.
ptr | Pointer to the atomic object to perform the operation on. |
expectedPtr | Pointer to do a bitwise comparison with. |
desired | Value to copy to the memory pointed to by ptr. |
trueOrder | Memory order used in the case of a true comparison. |
falseOrder | Memory order used in the case of a false comparison. |
#define vlAtomicFetchAdd | ( | ptr, | |
arg ) atomic_fetch_add(ptr, arg) |
Performs a generic atomic addition operation.
The memory order used for this operation is VL_MEMORY_ORDER_SEQ_CST.
ptr | Pointer to the atomic object to perform the operation on. |
#define vlAtomicFetchAddExplicit | ( | ptr, | |
arg, | |||
order ) atomic_fetch_add_explicit(ptr, arg, (memory_order)(order)) |
Performs a generic atomic addition operation.
ptr | Pointer to the atomic object to access |
order | Which memory ordering scheme to use for the operation. |
#define vlAtomicFetchAnd | ( | ptr, | |
arg ) atomic_fetch_and(ptr, arg) |
Performs a generic atomic bitwise AND operation.
The memory order used for this operation is VL_MEMORY_ORDER_SEQ_CST.
ptr | Pointer to the atomic object to perform the operation on. |
#define vlAtomicFetchAndExplicit | ( | ptr, | |
arg, | |||
order ) atomic_fetch_and_explicit(ptr, arg, (memory_order)(order)) |
Performs a generic atomic bitwise AND operation.
ptr | Pointer to the atomic object to access |
order | Which memory ordering scheme to use for the operation. |
#define vlAtomicFetchOr | ( | ptr, | |
arg ) atomic_fetch_or(ptr, arg) |
Performs a generic atomic bitwise OR operation.
The memory order used for this operation is VL_MEMORY_ORDER_SEQ_CST.
ptr | Pointer to the atomic object to perform the operation on. |
#define vlAtomicFetchOrExplicit | ( | ptr, | |
arg, | |||
order ) atomic_fetch_or_explicit(ptr, arg, (memory_order)(order)) |
Performs a generic atomic bitwise OR operation.
ptr | Pointer to the atomic object to access |
order | Which memory ordering scheme to use for the operation. |
#define vlAtomicFetchSub | ( | ptr, | |
arg ) atomic_fetch_sub(ptr, arg) |
Performs a generic atomic subtraction operation.
The memory order used for this operation is VL_MEMORY_ORDER_SEQ_CST.
ptr | Pointer to the atomic object to perform the operation on. |
#define vlAtomicFetchSubExplicit | ( | ptr, | |
arg, | |||
order ) atomic_fetch_sub_explicit(ptr, arg, (memory_order)(order)) |
Performs a generic atomic subtraction operation.
ptr | Pointer to the atomic object to access |
order | Which memory ordering scheme to use for the operation. |
#define vlAtomicFetchXor | ( | ptr, | |
arg ) atomic_fetch_xor(ptr, arg) |
Performs a generic atomic bitwise XOR operation.
The memory order used for this operation is VL_MEMORY_ORDER_SEQ_CST.
ptr | Pointer to the atomic object to perform the operation on. |
#define vlAtomicFetchXorExplicit | ( | ptr, | |
arg, | |||
order ) atomic_fetch_xor_explicit(ptr, arg, (memory_order)(order)) |
Performs a generic atomic bitwise XOR operation.
ptr | Pointer to the atomic object to access |
order | Which memory ordering scheme to use for the operation. |
#define vlAtomicFlagClear | ( | ptr | ) | atomic_flag_clear(ptr) |
Atomically sets the flag to false.
The memory order used for this operation is VL_MEMORY_ORDER_SEQ_CST.
ptr | Pointer to the atomic flag instance |
#define vlAtomicFlagClearExplicit | ( | ptr, | |
order ) atomic_flag_clear_explicit(ptr, (memory_order)(order)) |
Atomically sets a flag to false.
ptr | Pointer to the atomic flag instance |
order | Memory order used for the operation. |
#define vlAtomicFlagTestAndSet | ( | ptr | ) | atomic_flag_test_and_set(ptr) |
Atomically sets a flag to true and returns the old value.
The memory order used for this operation is VL_MEMORY_ORDER_SEQ_CST.
ptr | Pointer to the atomic flag instance |
#define vlAtomicFlagTestAndSetExplicit | ( | ptr, | |
order ) atomic_flag_test_and_set_explicit(ptr, (memory_order)(order)) |
Atomically sets a flag to true and returns the old value.
ptr | Pointer to the atomic flag instance |
order | Memory order used for the operation. |
#define vlAtomicInit | ( | ptr | ) | atomic_init(ptr) |
Initializes an existing atomic object.
This is the only way to properly initialize dynamically-allocated atomic objects. Atomic objects allocated on the stack and directly assigned do not need to be initialized.
\ptr Pointer to the atomic object to initialize.
#define vlAtomicLoad | ( | ptr | ) | atomic_load(ptr) |
Performs a generic atomic read operation.
This operation will use the VL_MEMORY_ORDER_SEQ_CST memory order.
ptr | Pointer to the atomic object to access |
#define vlAtomicLoadExplicit | ( | ptr, | |
order ) atomic_load_explicit(ptr, (memory_order)(order)) |
Performs a generic atomic read operation.
The memory order used must be among the following:
ptr | Pointer to the atomic object to access |
order | Which memory ordering scheme to use for the operation. |
#define vlAtomicStore | ( | ptr, | |
val ) atomic_store(ptr, val) |
Performs a generic atomic write operation.
This operation will use the VL_MEMORY_ORDER_SEQ_CST memory order.
ptr | Pointer to the atomic object to write. |
val | Value to store. |
#define vlAtomicStoreExplicit | ( | ptr, | |
order ) atomic_store_explicit(ptr, (memory_order)(order)) |
Performs a generic atomic write operation.
The memory order used must be among the following:
ptr | Pointer to the atomic object to access |
order | Which memory ordering scheme to use for the operation. |
#define vlAtomicThreadFence | ( | order | ) | atomic_thread_fence((memory_order)(order)) |
Prepares memory synchronization of non-atomic and relaxed atomic accesses.
order | Memory order used for the current context. |
enum vl_memory_order_t |
Memory order enumeration. Dictates reordering of memory accesses surrounding and including atomic operations.
Documentation of different orders taken from the following webpage: https://en.cppreference.com/w/c/atomic/memory_order
VL_ATOMIC_TYPEDEF | ( | atomic_flag | ) |
VL_ATOMIC_TYPEDEF | ( | vl_bool_t | ) |
VL_ATOMIC_TYPEDEF | ( | vl_ilarge_t | ) |
VL_ATOMIC_TYPEDEF | ( | vl_int_t | ) |
VL_ATOMIC_TYPEDEF | ( | vl_intptr_t | ) |
VL_ATOMIC_TYPEDEF | ( | vl_ismall_t | ) |
VL_ATOMIC_TYPEDEF | ( | vl_uint_t | ) |
VL_ATOMIC_TYPEDEF | ( | vl_uintptr_t | ) |
VL_ATOMIC_TYPEDEF | ( | vl_ularge_t | ) |
VL_ATOMIC_TYPEDEF | ( | vl_usmall_t | ) |