Date: Fri, 4 Oct 2019 17:37:36 +0300 From: Andriy Gapon <avg@FreeBSD.org> To: Mateusz Guzik <mjguzik@gmail.com> Cc: freebsd-arch@freebsd.org Subject: Re: atomic_cmpset_64 vs atomic_cas_64 Message-ID: <bcfc3d61-b57a-46c2-1609-c2a15a05397d@FreeBSD.org> In-Reply-To: <CAGudoHGx0yK4RD7fcBnsmtr3K%2BHGbxeBnBofG_f=QF-O8EwCHQ@mail.gmail.com> References: <0a330e4a-9b8b-7678-cb54-a379f1e4b0bc@FreeBSD.org> <CAGudoHGx0yK4RD7fcBnsmtr3K%2BHGbxeBnBofG_f=QF-O8EwCHQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 04/10/2019 17:35, Mateusz Guzik wrote:
> On 10/4/19, Andriy Gapon <avg@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bcfc3d61-b57a-46c2-1609-c2a15a05397d>
