简体   繁体   English

为什么std :: atomic_thread_fence具有“ C”链接?

[英]Why does std::atomic_thread_fence have “C” linkage?

我不知道为什么希望此功能具有“ C”而不是“ C ++”链接。

That was added by LWG issue 1479 which was addressing a last-minute comment on C++11. LWG问题1479在解决有关C ++ 11的最新评论时对此进行了补充。

The rationale for this change was C language compatibility (C11 thread library has identically-named function atomic_thread_fence in stdatomic.h). 进行此更改的理由是C语言兼容(C11线程库在stdatomic.h中具有相同名称的函数atomic_thread_fence )。

As far as I understand, it was always a plan that C and C++ atomic libraries can coexist: other examples of compatiblity are the C-compatible type aliases for std::atomic, such as atomic_int and the C-compatibility macro ATOMIC_VAR_INIT 据我了解,C和C ++原子库始终可以共存是一个计划:兼容性的其他示例是std :: atomic的C兼容类型别名,例如atomic_int和C兼容性宏ATOMIC_VAR_INIT

atomic_thread_fence establishes memory synchronization ordering of non-atomic and relaxed atomic accesses. atomic_thread_fence建立非原子访问和宽松原子访问的内存同步顺序。
Concurrency, especially relaxed-memory concurrency, is a notoriously subtle and error-prone domain, and so verifying such optimisations is of great interest. 并发,尤其是宽松的内存并发,是一个众所周知的微妙且容易出错的领域,因此验证这种优化非常令人感兴趣。 Ref1 . 参考1
For such thing is widely used CompCertTSO . 为此, CompCertTSO被广泛使用。
CompCertTSO is a compiler that generates x86 assembly code from ClightTSO, a large subset of the C programming language enhanced with concurrency primitives for thread management and synchronisation, and with a TSO relaxed memory model based on the x86-TSO model. CompCertTSO是从ClightTSO生成x86汇编代码的编译器,ClightTSO是C编程语言的大子集,并增强了用于线程管理和同步的并发原语,以及基于x86-TSO模型的TSO宽松内存模型。

So, for verification, optimisation and testing purposes is desirable for this function to have "C" linkage. 因此,出于验证,优化和测试的目的,希望此功能具有“ C”链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么这个 `std::atomic_thread_fence` 工作 - Why does this `std::atomic_thread_fence` work 这种std :: atomic_thread_fence的使用是否正确? - Is this use of std::atomic_thread_fence correct? atomic_thread_fence不是std的成员 - atomic_thread_fence is not a member of std std :: __ Atomic_thread_fence(大写A)正确吗? - std::_Atomic_thread_fence (with capital A) is this correct? std :: atomic_thread_fence具有未定义的引用 - std::atomic_thread_fence has undefined reference atomic_thread_fence(memory_order_seq_cst) 是否具有完整内存屏障的语义? - Does atomic_thread_fence(memory_order_seq_cst) have the semantics of a full memory barrier? 在具有相同顺序的原子加载/存储之前使用 std::atomic_thread_fence 总是多余的吗? - Is using std::atomic_thread_fence right before an atomic load/store with the same order always redundant? 获取条件std :: atomic_thread_fence的优点和缺点是什么? - Benefits & drawbacks of as-needed conditional std::atomic_thread_fence acquire? 在 x86 上实现 std::atomic_thread_fence(std::memory_order_seq_cst) 没有额外的性能损失 - An implementation of std::atomic_thread_fence(std::memory_order_seq_cst) on x86 without extra performance penalties atomic_thread_fence(memory_order_release) 与使用memory_order_acq_rel 有什么不同? - Is atomic_thread_fence(memory_order_release) different from using memory_order_acq_rel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM