$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] Notice: Boost.Atomic (atomic operations library)
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2009-12-04 12:06:31
Hi Helge,
In your x86 code you have:
bool compare_exchange_strong(T &e, T d, memory_order
order=memory_order_seq_cst) volatile
{
T prev=e;
__asm__ __volatile__("lock cmpxchgb %1, %2\n" : "=a" (prev) : "q"
(d), "m" (i), "a" (e) : "memory");
bool success=(prev==e);
e=prev;
return success;
}
Can you explain why 'e' is a reference and why you assign back to it?
Maybe it would help if you could write out what that asm does in
pseudo-code. The kernel_cmpxchg that I have does:
if (*ptr == oldval) {
*ptr = newval;
return 0;
} else {
return !0;
}
I think I can just write
bool compare_exchange_strong(T &e, T d, memory_order
order=memory_order_seq_cst) volatile
{
return kernel_cmpxchg(e,d,&i) == 0;
}
but the extra stuff in your x86 version makes me suspect there is more
to it.
Phil.