PSk*_*cik 7 c gcc intrinsics stdatomic
根据https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html,存在:
type __atomic_load_n (type *ptr, int memorder)
和(“通用”):
void __atomic_load (type *ptr, type *ret, int memorder)
然后
void __atomic_store_n (type *ptr, type val, int memorder)
和(“通用”)
void __atomic_store (type *ptr, type *val, int memorder)
等等
后一个版本有什么通用性(前一个版本不通用),为什么需要它们?
答案在 GCC 手册第 6.55 节中是正确的中,其中写道:
\n\n\n\n\xe2\x80\x98__atomic\xe2\x80\x99 内置函数可与长度为 1、2、4 或 8 字节的任何整型标量或指针类型一起使用。如果体系结构支持 \xe2\x80\x98__int128\xe2\x80\x99 (请参阅 __int128),则也允许使用 16 字节整数类型。
\n\n四个非算术函数(加载、存储、交换和比较交换)也都有一个通用版本。这个通用版本适用于任何数据类型。如果特定的数据类型大小允许,它会使用无锁内置函数;否则,外部调用将在运行时解决。此外部调用的格式相同,但添加了一个 \xe2\x80\x98size_t\xe2\x80\x99 参数作为第一个参数插入,指示所指向对象的大小。所有对象必须具有相同的大小。
\n
| 归档时间: | 
 | 
| 查看次数: | 53 次 | 
| 最近记录: |