Not getting expected output using cmpxchg8b for unsigned long

前端 未结 2 1318
日久生厌
日久生厌 2020-12-22 12:48

I am trying to write a simple compare and swap inline assembly code. Here is my code

#include 
#include 
#include 

        
2条回答
  •  执笔经年
    2020-12-22 13:38

    Sorry for not answering your question directly, but my question is: why not use C11's or C++11's ? It's a lot less error-prone than writing your own functions and has the advantage that you're not targeting a specific hardware architecture or compiler.

    In your case you should either be using atomic_compare_exchange_weak() or atomic_compare_exchange_strong().

提交回复
热议问题