Macros that indicate whether an atomic type is lock-free (C11)
#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 ...
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.