core.stdc.stdatomic

A D implementation of the C stdatomic.h header.

Note

If it compiles it should produce similar assembly to the system C toolchain

and should not introduce when optimizing unnecessary behaviors, if you do not care about this guarantee use the _impl suffix.

Note

The D shared type qualifier is the closest to the _Atomic type qualifier from C. It may be changed from shared in the future.

Note

Fail memory order is currently ignored due to limitations with internal implementation of atomics.

Types 40

enummemory_order
memory_order_relaxed = MemoryOrder.rawNo ordering provided
memory_order_consume = MemoryOrder.acqAs per cppreference.com circa 2015 no compiler supports consume memory order and in practice it devolves to acquire.
memory_order_acquire = MemoryOrder.acqPrevent reordering before operation
memory_order_release = MemoryOrder.relPrevent reordering after operation
memory_order_acq_rel = MemoryOrder.acq_relPrevent reordering before and after operation
memory_order_seq_cst = MemoryOrder.seqPrevent reordering before for read operations and after for writes.
structatomic_flag

Guaranteed to be a atomic boolean type

Fields
private bool b
aliasatomic_bool = shared(bool)
aliasatomic_char = shared(char)
aliasatomic_schar = shared(byte)
aliasatomic_uchar = shared(ubyte)
aliasatomic_short = shared(short)
aliasatomic_ushort = shared(ushort)
aliasatomic_int = shared(int)
aliasatomic_uint = shared(uint)
aliasatomic_long = shared(c_long)
aliasatomic_ulong = shared(c_ulong)
aliasatomic_llong = shared(long)
aliasatomic_ullong = shared(ulong)
aliasatomic_char8_t = shared(char)
aliasatomic_char16_t = shared(wchar)
aliasatomic_char32_t = shared(dchar)
aliasatomic_wchar_t = shared(wchar_t)
aliasatomic_int_least8_t = shared(int_least8_t)
aliasatomic_uint_least8_t = shared(uint_least8_t)
aliasatomic_int_least16_t = shared(int_least16_t)
aliasatomic_uint_least16_t = shared(uint_least16_t)
aliasatomic_int_least32_t = shared(int_least32_t)
aliasatomic_uint_least32_t = shared(uint_least32_t)
aliasatomic_int_least64_t = shared(int_least64_t)
aliasatomic_uint_least64_t = shared(uint_least64_t)
aliasatomic_int_fast8_t = shared(int_fast8_t)
aliasatomic_uint_fast8_t = shared(uint_fast8_t)
aliasatomic_int_fast16_t = shared(int_fast16_t)
aliasatomic_uint_fast16_t = shared(uint_fast16_t)
aliasatomic_int_fast32_t = shared(int_fast32_t)
aliasatomic_uint_fast32_t = shared(uint_fast32_t)
aliasatomic_int_fast64_t = shared(int_fast64_t)
aliasatomic_uint_fast64_t = shared(uint_fast64_t)
aliasatomic_intptr_t = shared(intptr_t)
aliasatomic_uintptr_t = shared(uintptr_t)
aliasatomic_size_t = shared(size_t)
aliasatomic_ptrdiff_t = shared(ptrdiff_t)
aliasatomic_intmax_t = shared(intmax_t)
aliasatomic_uintmax_t = shared(uintmax_t)

Functions 30

fnbool atomic_is_lock_free(A)(const shared(A) * obj) @safe nothrow @nogc
fnvoid atomic_flag_clear_impl()(atomic_flag * obj) @safe nothrow @nogc
fnvoid atomic_flag_clear_explicit_impl()(atomic_flag * obj, memory_order order) @safe nothrow @nogc
fnbool atomic_flag_test_and_set_impl()(atomic_flag * obj) @safe nothrow @nogc
fnbool atomic_flag_test_and_set_explicit_impl()(atomic_flag * obj, memory_order order) @safe nothrow @nogc
fnvoid atomic_init(A, C)(out shared(A) obj, C desired) @safe nothrow @nogc @trustedInitializes an atomic variable, the destination should not have any expression associated with it prior to this call.
fnA kill_dependency(A)(A y) @safe nothrow @nogc @trustedNo-op function, doesn't apply to D
fnvoid atomic_signal_fence_impl()(memory_order order) @safe nothrow @nogcDon't allow reordering, does not emit any instructions.
fnvoid atomic_thread_fence_impl()(memory_order order) @safe nothrow @nogcDon't allow reordering, and emit a fence instruction.
fnvoid atomic_store_impl(A, C)(shared(A) * obj, C desired) @safe nothrow @nogc @trusted
fnvoid atomic_store_explicit_impl(A, C)(shared(A) * obj, C desired, memory_order order) @safe nothrow @nogc @trusted
fnA atomic_load_impl(A)(const shared(A) * obj) @safe nothrow @nogc @trusted
fnA atomic_load_explicit_impl(A)(const shared(A) * obj, memory_order order) @safe nothrow @nogc @trusted
fnA atomic_exchange_impl(A, C)(shared(A) * obj, C desired) @safe nothrow @nogc @trusted
fnA atomic_exchange_explicit_impl(A, C)(shared(A) * obj, C desired, memory_order order) @safe nothrow @nogc @trusted
fnbool atomic_compare_exchange_strong_impl(A, B, C)(shared(A) * obj, B * expected, C desired) @safe nothrow @nogc @trusted
fnbool atomic_compare_exchange_weak_impl(A, B, C)(shared(A) * obj, B * expected, C desired) @safe nothrow @nogc @trusted
fnbool atomic_compare_exchange_strong_explicit_impl(A, B, C)(shared(A) * obj, B * expected, C desired, memory_order succ, memory_order fail) @safe nothrow @nogc @trusted
fnbool atomic_compare_exchange_weak_explicit_impl(A, B, C)(shared(A) * obj, B * expected, C desired, memory_order succ, memory_order fail) @safe nothrow @nogc @trusted
fnA atomic_fetch_add_impl(A, M)(shared(A) * obj, M arg) @safe nothrow @nogc @trusted
fnA atomic_fetch_sub_impl(A, M)(shared(A) * obj, M arg) @safe nothrow @nogc @trusted
fnA atomic_fetch_add_explicit_impl(A, M)(shared(A) * obj, M arg, memory_order order) @safe nothrow @nogc @trusted
fnA atomic_fetch_sub_explicit_impl(A, M)(shared(A) * obj, M arg, memory_order order) @safe nothrow @nogc @trusted
fnA atomic_fetch_or_impl(A, M)(shared(A) * obj, M arg) @safe nothrow @nogc @trusted
fnA atomic_fetch_or_explicit_impl(A, M)(shared(A) * obj, M arg, memory_order order) @safe nothrow @nogc @trusted
fnA atomic_fetch_xor_impl(A, M)(shared(A) * obj, M arg) @safe nothrow @nogc @trusted
fnA atomic_fetch_xor_explicit_impl(A, M)(shared(A) * obj, M arg, memory_order order) @safe nothrow @nogc @trusted
fnA atomic_fetch_and_impl(A, M)(shared(A) * obj, M arg) @safe nothrow @nogc @trusted
fnA atomic_fetch_and_explicit_impl(A, M)(shared(A) * obj, M arg, memory_order order) @safe nothrow @nogc @trusted
private fnA atomic_fetch_op(memory_order order, string op, A, M)(A * obj, M arg) @safe nothrow @nogc @trusted

Variables 1

enumvarATOMIC_FLAG_INIT = atomic_flag.init