Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Oct 2019 16:35:45 +0200
From:      Mateusz Guzik <mjguzik@gmail.com>
To:        Andriy Gapon <avg@freebsd.org>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: atomic_cmpset_64 vs atomic_cas_64
Message-ID:  <CAGudoHGx0yK4RD7fcBnsmtr3K%2BHGbxeBnBofG_f=QF-O8EwCHQ@mail.gmail.com>
In-Reply-To: <0a330e4a-9b8b-7678-cb54-a379f1e4b0bc@FreeBSD.org>
References:  <0a330e4a-9b8b-7678-cb54-a379f1e4b0bc@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

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.

-- 
Mateusz Guzik <mjguzik gmail.com>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGudoHGx0yK4RD7fcBnsmtr3K%2BHGbxeBnBofG_f=QF-O8EwCHQ>