atomic_flag_test_and_set(), atomic_flag_test_and_set_explicit()
QNX SDP8.0C Library ReferenceAPIDeveloper
Atomically set a flag (C11)
Synopsis:
#include <stdatomic.h>
_Bool atomic_flag_test_and_set( volatile atomic_flag *obj );
_Bool atomic_flag_test_and_set_explicit( volatile atomic_flag *obj,
memory_order order );
Arguments:
- obj
- A pointer to the atomic flag that you want to set.
- order
- (atomic_flag_test_and_set_explicit() only) The memory_order to use for the operation.
Library:
- If the atomic function is lock-free (see atomic_is_lock_free()), no extra library is required.
- If the function isn't lock-free, you need to link against libatomic. Use the -l atomic option to qcc to link against this library.
Description:
The atomic_flag_test_and_set() and atomic_flag_test_and_set_explicit() functions atomically set the given atomic flag to true and return the previous value. The atomic_flag_test_and_set() function orders memory access according to memory_order_seq_cst; atomic_flag_test_and_set_explicit() orders them as specified by order.
The implementation of atomic functions may depend on the architecture.
For more information, see
LL/SC vs LSE atomic operations
in the description in Building Embedded Systems of the cpuinfo area of the system page.
Returns:
The previous value.
Classification:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | Read the Caveats |
Thread | Yes |
Caveats:
If this function is lock-free (see atomic_is_lock_free()), it's safe to call it from a signal handler.
Page updated: