libfoedus-core
FOEDUS Core Library
raw_atomics.hpp File Reference

Raw atomic operations that work for both C++11 and non-C++11 code. More...

Detailed Description

Raw atomic operations that work for both C++11 and non-C++11 code.

std::atomic provides atomic CAS etc, but it requires the data to be std::atomic<T>, rather than T itself like what gcc's builtin function provides. This is problemetic when we have to store T rather than std::atomic<T>. Also, we want to avoid C++11 in public headers.

The methods in this header fill the gap. This header defines, not just declares [1], the methods so that they are inlined. We simply use gcc/clang's builtin. clang's gcc compatibility is so good that we don't need ifdef.

[1] Except raw_atomic_compare_exchange_strong_uint128(). It's defined in cpp.

See also
foedus/assorted/atomic_fences.hpp

Definition in file raw_atomics.hpp.

#include <stdint.h>
Include dependency graph for raw_atomics.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 foedus
 Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
 
 foedus::assorted
 Assorted Methods/Classes that are too subtle to have their own packages.
 

Functions

template<typename T >
bool foedus::assorted::raw_atomic_compare_exchange_strong (T *target, T *expected, T desired)
 Atomic CAS. More...
 
template<typename T >
bool foedus::assorted::raw_atomic_compare_exchange_weak (T *target, T *expected, T desired)
 Weak version of raw_atomic_compare_exchange_strong(). More...
 
bool foedus::assorted::raw_atomic_compare_exchange_strong_uint128 (uint64_t *ptr, const uint64_t *old_value, const uint64_t *new_value)
 Atomic 128-bit CAS, which is not in the standard yet. More...
 
bool foedus::assorted::raw_atomic_compare_exchange_weak_uint128 (uint64_t *ptr, const uint64_t *old_value, const uint64_t *new_value)
 Weak version of raw_atomic_compare_exchange_strong_uint128(). More...
 
template<typename T >
foedus::assorted::raw_atomic_exchange (T *target, T desired)
 Atomic Swap for raw primitive types rather than std::atomic<T>. More...
 
template<typename T >
foedus::assorted::raw_atomic_fetch_add (T *target, T addendum)
 Atomic fetch-add for raw primitive types rather than std::atomic<T>. More...
 
template<typename T >
foedus::assorted::raw_atomic_fetch_and_bitwise_and (T *target, T operand)
 Atomic fetch-bitwise-and for raw primitive types rather than std::atomic<T>. More...
 
template<typename T >
foedus::assorted::raw_atomic_fetch_and_bitwise_or (T *target, T operand)
 Atomic fetch-bitwise-or for raw primitive types rather than std::atomic<T>. More...
 
template<typename T >
foedus::assorted::raw_atomic_fetch_and_bitwise_xor (T *target, T operand)
 Atomic fetch-bitwise-xor for raw primitive types rather than std::atomic<T> More...