NAME

atomic_signal_fence, atomic_thread_fence — fence operations

SYNOPSIS

#include <stdatomic.h>

void atomic_signal_fence(memory_order
order);
void atomic_thread_fence(memory_order
order);

DESCRIPTION

[CX] [Option Start] 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. [Option End]

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:

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.

RETURN VALUE

These functions shall not return a value.

ERRORS

No errors are defined.


The following sections are informative.

EXAMPLES

None.

APPLICATION USAGE

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.

RATIONALE

None.

FUTURE DIRECTIONS

None.

SEE ALSO

XBD 4.15.1 Memory Ordering , <stdatomic.h>

CHANGE HISTORY

First released in Issue 8. Included for alignment with the ISO/IEC 9899:2018 standard.

End of informative text.