ATOMIC_*_LOCK_FREE

Updated: April 19, 2023

Macros that indicate whether an atomic type is lock-free (C11)

Synopsis:

#include <stdatomic.h>

#define ATOMIC_BOOL_LOCK_FREE ...
#define ATOMIC_CHAR_LOCK_FREE ...
#define ATOMIC_CHAR16_T_LOCK_FREE ...
#define ATOMIC_CHAR32_T_LOCK_FREE ...
#define ATOMIC_WCHAR_T_LOCK_FREE ...
#define ATOMIC_SHORT_LOCK_FREE ...
#define ATOMIC_INT_LOCK_FREE ...
#define ATOMIC_LONG_LOCK_FREE ...
#define ATOMIC_LLONG_LOCK_FREE ...
#define ATOMIC_POINTER_LOCK_FREE ...

Description:

The ATOMIC_*_LOCK_FREE macros expand to preprocessor constant expressions that indicate whether the associated atomic types (see the atomic_* types) are lock-free:

Value Meaning
0 The atomic type is never lock-free.
1 The atomic type is sometimes lock-free.
2 The atomic type is always lock-free.

This depends on your target platform; if the compiler can't generate lock-free instructions for your target, you need to link your program against libatomic.

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.

Classification:

C11