命名空间
变体
操作

ATOMIC_*_LOCK_FREE

来自 cppreference.cn
< c‎ | atomic
定义于头文件 <stdatomic.h>
#define ATOMIC_BOOL_LOCK_FREE     /* implementation-defined */

#define ATOMIC_CHAR_LOCK_FREE     /* implementation-defined */
#define ATOMIC_CHAR16_T_LOCK_FREE /* implementation-defined */
#define ATOMIC_CHAR32_T_LOCK_FREE /* implementation-defined */
#define ATOMIC_WCHAR_T_LOCK_FREE  /* implementation-defined */
#define ATOMIC_SHORT_LOCK_FREE    /* implementation-defined */
#define ATOMIC_INT_LOCK_FREE      /* implementation-defined */
#define ATOMIC_LONG_LOCK_FREE     /* implementation-defined */
#define ATOMIC_LLONG_LOCK_FREE    /* implementation-defined */

#define ATOMIC_POINTER_LOCK_FREE  /* implementation-defined */
(自 C11 起)
#define ATOMIC_CHAR8_T_LOCK_FREE  /* implementation-defined */
(自 C23 起)

展开为 预处理器常量表达式,其求值结果为 012,表示相应原子类型(有符号和无符号)的无锁属性。

解释
0 原子类型从不无锁
1 原子类型有时无锁
2 原子类型始终无锁

[编辑] 参考

  • C17 标准 (ISO/IEC 9899:2018)
  • 7.17.1/3 原子无锁宏 (页码: 200)
  • C11 标准 (ISO/IEC 9899:2011)
  • 7.17.1/3 原子无锁宏 (页码: 273)