[英]Why do we have both __atomic_store_n and __atomic_store
I am working on a simple linux driver and I am trying to understand how the atomic built-ins for the gcc compiler work and how they optimize performance.我正在研究一个简单的 linux 驱动程序,我试图了解 gcc 编译器的原子内置函数如何工作以及它们如何优化性能。 My question is: why do we need both
__atomic_store
and __atomic_store_n
?我的问题是:为什么我们需要
__atomic_store
和__atomic_store_n
? What is their difference?他们有什么区别?
look at gcc manual for the difference between the two atomic_store functions查看 gcc 手册了解两个 atomic_store 函数之间的区别
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
Built-in Function: void __atomic_store_n (type *ptr, type val, int memorder)内置 Function: void __atomic_store_n (type *ptr, type val, int memorder)
This built-in function implements an atomic store operation. It writes val into *ptr.
The valid memory order variants are __ATOMIC_RELAXED, __ATOMIC_SEQ_CST, and __ATOMIC_RELEASE.
Built-in Function: void __atomic_store (type *ptr, type *val, int memorder)内置 Function: void __atomic_store (type *ptr, type *val, int memorder)
This is the generic version of an atomic store. It stores the value of *val into *ptr.
the __atomic.._n methods can be used for any integer scalar or pointer with a size of 1, 2, 4, or 8 bytes, instead the generic version is applicable to any data type. __atomic.._n 方法可用于任何 integer 标量或大小为 1、2、4 或 8 字节的指针,而不是通用版本适用于任何数据类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.