Veritable Lasagna
An Allocator & Data Structure Library for C.
|
#include "vl_atomic.h"
Go to the source code of this file.
Data Structures | |
struct | vl_tagged_ptr |
A Tagged Pointer structure for use with Atomic, lock-free algorithms. More... | |
Macros | |
#define | vlAtomicPtrInit(atPtr, valPtr) vlAtomicInit((atPtr), valPtr); |
#define | vlAtomicPtrCompareExchangeStrong(atPtr, atPtrExpected, valPtr) vlAtomicPtrCompareExchangeStrongExplicit(atPtr, atPtrExpected, valPtr, VL_MEMORY_ORDER_SEQ_CST, VL_MEMORY_ORDER_SEQ_CST) |
Convenience macro for strong atomic tagged pointer CAS with sequential consistency. | |
#define | vlAtomicPtrCompareExchangeWeak(atPtr, atPtrExpected, valPtr) vlAtomicPtrCompareExchangeWeakExplicit(atPtr, atPtrExpected, valPtr, VL_MEMORY_ORDER_SEQ_CST, VL_MEMORY_ORDER_SEQ_CST) |
Convenience macro for weak atomic tagged pointer CAS with sequential consistency. | |
Typedefs | |
typedef VL_ATOMIC vl_tagged_ptr | vl_atomic_ptr |
Atomic variant of vl_tagged_ptr. | |
Variables | |
const vl_tagged_ptr | VL_TAGPTR_NULL |
Default initialization value for tagged/atomic pointers. | |
struct vl_tagged_ptr |
A Tagged Pointer structure for use with Atomic, lock-free algorithms.
Using extra state, a tagged pointer helps to distinguish atomic changes to memory to eliminate the ABA problem. The pointer tag is a counter that is incremented with write operation. The tag occupies as many bytes as the native system pointer type.
This structure may depend on 128-bit Compare-and-swap on modern platforms to achieve proper atomicity. (Double-width compare-and-swap, aka DWCAS, hardware instruction or similar). Depending on the platform and compiler, it may require an implicit lock.
Data Fields | ||
---|---|---|
vl_uintptr_t | ptr | |
vl_ularge_t | tag |
#define vlAtomicPtrCompareExchangeStrong | ( | atPtr, | |
atPtrExpected, | |||
valPtr ) vlAtomicPtrCompareExchangeStrongExplicit(atPtr, atPtrExpected, valPtr, VL_MEMORY_ORDER_SEQ_CST, VL_MEMORY_ORDER_SEQ_CST) |
Convenience macro for strong atomic tagged pointer CAS with sequential consistency.
atPtr | Pointer to atomic tagged pointer. |
atPtrExpected | Expected pointer/tag (updated on failure). |
valPtr | New pointer value. |
VL_TRUE
if successful, VL_FALSE
otherwise.#define vlAtomicPtrCompareExchangeWeak | ( | atPtr, | |
atPtrExpected, | |||
valPtr ) vlAtomicPtrCompareExchangeWeakExplicit(atPtr, atPtrExpected, valPtr, VL_MEMORY_ORDER_SEQ_CST, VL_MEMORY_ORDER_SEQ_CST) |
Convenience macro for weak atomic tagged pointer CAS with sequential consistency.
atPtr | Pointer to atomic tagged pointer. |
atPtrExpected | Expected pointer/tag (updated on failure). |
valPtr | New pointer value. |
VL_TRUE
if successful, VL_FALSE
otherwise.#define vlAtomicPtrInit | ( | atPtr, | |
valPtr ) vlAtomicInit((atPtr), valPtr); |
typedef VL_ATOMIC vl_tagged_ptr vl_atomic_ptr |
Atomic variant of vl_tagged_ptr.
A Tagged Pointer structure for use with Atomic, lock-free algorithms.
Using extra state, a tagged pointer helps to distinguish atomic changes to memory to eliminate the ABA problem. The pointer tag is a counter that is incremented with write operation. The tag occupies as many bytes as the native system pointer type.
This structure may depend on 128-bit Compare-and-swap on modern platforms to achieve proper atomicity. (Double-width compare-and-swap, aka DWCAS, hardware instruction or similar). Depending on the platform and compiler, it may require an implicit lock.
|
extern |
Default initialization value for tagged/atomic pointers.