是否可以哄骗std :: atomic <t>输出CMPXCHG16B </t>

时间:2015-01-26 01:58:33

标签: c++ windows visual-studio c++11 icc

是否可以哄骗std :: atomic输出CMPXCHG16B用于我对在Windows x64上使用原子互锁操作不感兴趣的类型,或者我只需要将它吸收并手动执行原子操作?我可以让GCC / Clang在Linux上这样做,所以我怀疑它只是微软标准库的一个问题。

struct Byte16
{
    int64_t a, b;
};

std::atomic<Byte16> atm;
Byte16 a = { 1, 2 };
atm.compare_exchange_strong(...); // This has a lock on Windows, not on Linux version of code

1 个答案:

答案 0 :(得分:-3)

在windows中使用__m128

#include <emmintrin.h>
//...
  std::atomic<__m128> a, c;
  __m128 b;
  a.compare_exchange_strong(b,c);
///...