P99
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Modules | Macros
+ Collaboration diagram for C11 atomic operations:

Modules

 Stub replacements of C11 atomic operations
 
 Atomic_macros
 
 Atomic_types
 
 Memory Fences
 

Macros

#define atomic_compare_exchange_strong(OBJP, EXPECTED, DESIRED)   atomic_compare_exchange_strong_explicit(OBJP, EXPECTED, DESIRED, memory_order_seq_cst, memory_order_seq_cst)
 
#define atomic_compare_exchange_strong_explicit(OBJP, EXPECTED, DESIRED, SUCC, FAIL)   p00_atomic_compare_exchange(false, OBJP, EXPECTED, DESIRED, SUCC, FAIL,)
 
#define atomic_compare_exchange_weak(OBJP, EXPECTED, DESIRED)   atomic_compare_exchange_weak_explicit(OBJP, EXPECTED, DESIRED, memory_order_seq_cst, memory_order_seq_cst)
 
#define atomic_compare_exchange_weak_explicit(OBJP, EXPECTED, DESIRED, SUCC, FAIL)   p00_atomic_compare_exchange(true, OBJP, EXPECTED, DESIRED, SUCC, FAIL,)
 Atomically compare *OBJP to *EXPECTED and set it to DESIRED if they are equal. More...
 
#define atomic_exchange(OBJP, DESIRED)   atomic_exchange_explicit((OBJP), (DESIRED), memory_order_seq_cst)
 Store DESIRED into the object behind OBJP and return its previous value. More...
 
#define atomic_exchange_explicit(OBJP, DESIRED, ORD)
 Store DESIRED into the object behind OBJP and return its previous value. More...
 
#define atomic_fetch_add(OBJP, OPERAND)   atomic_fetch_add_explicit((OBJP), (OPERAND), memory_order_seq_cst)
 
#define atomic_fetch_add_conditional(OBJP, OPERAND)
 
#define atomic_fetch_add_explicit(OBJP, OPERAND, ORD)   P00_FETCH_OP((OBJP), (OPERAND), p00_atomic_fetch_add, +=, (ORD))
 Atomically add OPERAND to *OBJP. More...
 
#define atomic_fetch_and(OBJP, OPERAND)   atomic_fetch_and_explicit((OBJP), (OPERAND), memory_order_seq_cst)
 
#define atomic_fetch_and_explicit(OBJP, OPERAND, ORD)   P00_FETCH_OP((OBJP), (OPERAND), p00_atomic_fetch_and, &=, (ORD))
 Atomically do a bitwise AND operation between OPERAND and *OBJP. More...
 
#define atomic_fetch_or(OBJP, OPERAND)   atomic_fetch_or_explicit((OBJP), (OPERAND), memory_order_seq_cst)
 
#define atomic_fetch_or_explicit(OBJP, OPERAND, ORD)   P00_FETCH_OP((OBJP), (OPERAND), p00_atomic_fetch_or, |=, (ORD))
 Atomically do a bitwise OR operation between OPERAND and *OBJP. More...
 
#define atomic_fetch_sub(OBJP, OPERAND)   atomic_fetch_sub_explicit((OBJP), (OPERAND), memory_order_seq_cst)
 
#define atomic_fetch_sub_explicit(OBJP, OPERAND, ORD)   P00_FETCH_OP((OBJP), (OPERAND), p00_atomic_fetch_sub, -=, ORD)
 Atomically subtract OPERAND from *OBJP. More...
 
#define atomic_fetch_xor(OBJP, OPERAND)   atomic_fetch_xor_explicit((OBJP), (OPERAND), memory_order_seq_cst)
 
#define atomic_fetch_xor_explicit(OBJP, OPERAND, ORD)   P00_FETCH_OP((OBJP), (OPERAND), p00_atomic_fetch_xor, ^=, (ORD))
 Atomically do a bitwise XOR operation between OPERAND and *OBJP. More...
 
#define atomic_init(OBJP, VAL)
 Initialize the object behind OBJP with value VAL. More...
 
#define atomic_is_lock_free(OBJP)   (!offsetof(__typeof__(*OBJP), p00_xval))
 return true if OBJP points to a lock-free object More...
 
#define atomic_load(OBJP)   atomic_load_explicit((OBJP), memory_order_seq_cst)
 
#define atomic_load_explicit(OBJP, ORD)
 Return the value of the object behind OBJP. More...
 
#define atomic_store(OBJP, DES)   atomic_store_explicit(OBJP, DES, memory_order_seq_cst)
 
#define atomic_store_explicit(OBJP, DES, ORD)
 Store DESIRED into the object behind OBJP. More...
 
#define P99_FIFO(T)   P99_PASTE2(p00_fifo_, T)
 
#define P99_FIFO_APPEND(L, EL)
 Append element EL to an atomic FIFO L. More...
 
#define P99_FIFO_CLEAR(L)
 Atomically clear an atomic FIFO L and return a pointer to the start of the list that it previously contained. More...
 
#define P99_FIFO_DECLARE(T)
 
#define P99_FIFO_INITIALIZER(HEAD, TAIL)
 
#define P99_FIFO_POP(L)
 Pop the front element from an atomic FIFO L. More...
 
#define P99_FIFO_TABULATE(TYPE, TAB, L)   P00_FIFO_TABULATE(TYPE, TAB, P99_UNIQ(TAB), L)
 
#define P99_LIFO(T)   P99_TP(T)
 
#define P99_LIFO_CLEAR(L)
 Atomically clear an atomic LIFO L and return a pointer to the start of the list that it previously contained. More...
 
#define P99_LIFO_DECLARE(T)   P99_TP_DECLARE(T)
 
#define p99_lifo_init(EL, VAL)   p99_tp_init((EL), (VAL))
 
#define P99_LIFO_INITIALIZER(VAL)   P99_TP_INITIALIZER(VAL)
 
#define P99_LIFO_POP(L)
 Pop the top element from an atomic LIFO L. More...
 
#define P99_LIFO_PUSH(L, EL)
 Push element EL into an atomic LIFO L. More...
 
#define P99_LIFO_TABULATE(TYPE, TAB, L)   P00_LIFO_TABULATE(TYPE, TAB, P99_UNIQ(TAB), L)
 
#define P99_LIFO_TOP(L)   P99_TP_GET(L)
 Return a pointer to the top element of an atomic LIFO L. More...
 

Detailed Description

This is a stub implementation of C11 atomic types and operations.

This uses gcc extensions

We also use __sync_lock_test_and_set and other similar built-ins if they are available. If not, __sync_lock_test_and_set and __sync_lock_release are implemented in assembler (for 4 byte integers) and all other operations are synthesized with an atomic_flag that is used as a spinlock.

See also
_Atomic
P99_DECLARE_ATOMIC