Liste des Groupes | Revenir à c arch |
On 12/20/24 12:46, jseigh wrote:Alright, my bad. I should have double checked the docs.On 12/19/24 19:43, Chris M. Thomasson wrote:That should be a ref paramter. I though I updated the pasted code.Why in the world would GCC use an XCHG instruction for the following code. The damn XCHG has an implied LOCK prefix! Yikes!>
>
Speaking of strange code
>
#include <atomic>
bool test1(std::atomic<int>& var, int addend)
{
int expected = var.load(std::memory_order_relaxed);
int update = expected + addend;
return var.compare_exchange_weak(expected, update, std::memory_order_acq_rel, std::memory_order_seq_cst);
}
Les messages affichés proviennent d'usenet.