Liste des Groupes | Revenir à c arch |
On 12/20/2024 3:55 AM, jseigh wrote:AHHHHHH!!!!!!!!!!!On 12/19/24 20:02, Chris M. Thomasson wrote:https://en.cppreference.com/w/cpp/atomic/atomic/storeOn 12/19/2024 4:43 PM, Chris M. Thomasson wrote:>Why in the world would GCC use an XCHG instruction for the following code. The damn XCHG has an implied LOCK prefix! Yikes!^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
https://godbolt.org/z/Thxchdcr8
_______________________
#include <atomic>
>
int main()
{
>
std::atomic<unsigned long> m_state = 0;
>
m_state.store(std::memory_order_relaxed);
>
Strange to me that this even compiled at all. I clearly forgot to put in a value. aka:
>
m_state.store(1, std::memory_order_release);
>
Sorry about that. ;^o
The 2nd parameter has a default value, std::memory_order_cst.
Your 1st argument was a std::memory_order value which is an
integer value. So basically
>
m.state.store(std::memory_order_relaxed, std::memory_order_cst);
>
The first param is the value we want to store. The second one is memory order.
Les messages affichés proviennent d'usenet.