atomic_cmpset_64 vs atomic_cas_64
Andriy Gapon
avg at FreeBSD.org
Fri Oct 4 14:37:41 UTC 2019
On 04/10/2019 17:35, Mateusz Guzik wrote:
> On 10/4/19, Andriy Gapon <avg at freebsd.org> wrote:
>>
>> I see that almost all 64-bit platforms provide atomic_cmpset_64, but
>> sparc64
>> provides atomic_cas_64 (instead?).
>> I think that the meanings of "cas" and "cmpset" are really the same, but I
>> am
>> not sure if there are any differences in that the functions do.
>> Could anyone who knows that stuff (sparc64 assembly) please shed some
>> light?
>> Thanks!
>>
>> #define atomic_cas_64(p, e, s) casxa((p), (e), (s), __ASI_ATOMIC)
>>
>
> cas returns the found value, while cmpset throws it away.
Ah, now it's obvious. Thank you!
> static __inline int \
> atomic_cmpset_ ## name(volatile ptype p, vtype e, vtype s) \
> { \
> return (((vtype)atomic_cas((p), (e), (s), sz)) == (e)); \
> }
>
>
> Just use fcmpset instead.
fcmpset really beats both in its convenience.
--
Andriy Gapon
More information about the freebsd-arch
mailing list