Generally not part of the API standards, but available as intrinsics in most compilers in one form or another.
For example, Visual Studio compilers have _ReadBarrier
, _ReadWriteBarrier
and _WriteBarrier
. (I only linked one, as there are links from that page to the rest. And no, these are not all the levels you have listed - but they are all the levels that x86 has... The list in std::memory_order
covers a bunch of other architectures too. [And obvioously memory_order_relaxed
is "nothing"].
GCC has a different type of builtin functionality described here, which is aimed at supplying atomic updates, rather than specifically barriers.
However, in general, I would leave it to the compiler/OS to deal with atomic things - use std::atomic<>
and similar.