atomic_signal_fence, atomic_thread_fence — fence operations
#include <stdatomic.h>
void atomic_signal_fence(memory_order order);
void atomic_thread_fence(memory_order order);
[CX] The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1-2024 defers to the ISO C standard.Implementations that define the macro __STDC_NO_ATOMICS__ need not provide the <stdatomic.h> header nor support these generic functions.
The atomic_signal_fence() and atomic_thread_fence() functions provide synchronization primitives called fences. Fences can have acquire semantics, release semantics, or both. A fence with acquire semantics is called an acquire fence; a fence with release semantics is called a release fence.
A release fence A synchronizes with an acquire fence B if there exist atomic operations X and Y, both operating on some atomic object M, such that A is sequenced before X, X modifies M, Y is sequenced before B, and Y reads the value written by X or a value written by any side effect in the hypothetical release sequence X would head if it were a release operation.
A release fence A synchronizes with an atomic operation B that performs an acquire operation on an atomic object M if there exists an atomic operation X such that A is sequenced before X, X modifies M, and B reads the value written by X or a value written by any side effect in the hypothetical release sequence X would head if it were a release operation.
An atomic operation A that is a release operation on an atomic object M synchronizes with an acquire fence B if there exists some atomic operation X on M such that X is sequenced before B and reads the value written by A or a value written by any side effect in the release sequence headed by A.
Depending on the value of order, the operation performed by atomic_thread_fence() shall:
have no effects, if order is equal to memory_order_relaxed;
be an acquire fence, if order is equal to memory_order_acquire or memory_order_consume;
be a release fence, if order is equal to memory_order_release;
be both an acquire fence and a release fence, if order is equal to memory_order_acq_rel;
be a sequentially consistent acquire and release fence, if order is equal to memory_order_seq_cst.
The atomic_signal_fence() function shall be equivalent to atomic_thread_fence(), except that the resulting ordering constraints shall be established only between a thread and a signal handler executed in the same thread.
These functions shall not return a value.
No errors are defined.
None.
The atomic_signal_fence() function can be used to specify the order in which actions performed by the thread become visible to the signal handler. Implementation reorderings of loads and stores are inhibited in the same way as with atomic_thread_fence(), but the hardware fence instructions that atomic_thread_fence() would have inserted are not emitted.
None.
None.
First released in Issue 8. Included for alignment with the ISO/IEC 9899:2018 standard.
return to top of page