[m-rev.] for review: Use clang compiler intrinsics for more atomic ops.
Peter Wang
novalazy at gmail.com
Mon Sep 2 11:39:56 AEST 2024
On Fri, 30 Aug 2024 17:59:01 +1000 Julien Fischer <jfischer at opturion.com> wrote:
> Hi Peter,
>
> On Thu, 29 Aug 2024 at 12:53, Peter Wang <novalazy at gmail.com> wrote:
> >
> > Use clang compiler intrinsics for more atomic ops.
> >
> > runtime/mercury_atomic_ops.h:
> > Use compiler intrinsic for MR_ATOMIC_ADD_AND_FETCH_WORD_BODY
> > when compiling with clang, instead of falling back to the
> > compare and swap implementation.
> >
> > Use compiler intrinsic for MR_ATOMIC_SUB_INT_BODY
> > when compiling with clang but not targeting x86/x86-64.
> > In those cases, MR_atomic_sub_int() was not being defined,
> > and causing a link error.
>
> Presumably on aarch64, or were you trying something else?
>
Yes, I was trying aarch64.
> > ////////////////////////////////////////////////////////////////////////////
> >
> > -#if (MR_GNUC > 4 || (MR_GNUC == 4 && __GNUC_MINOR__ >= 1)) && \
> > +#if (defined(MR_CLANG) || MR_GNUC > 4 || (MR_GNUC == 4 && __GNUC_MINOR__ >= 1)) && \
> > !defined(MR_AVOID_COMPILER_INTRINSICS)
>
> The first condition in that conjunction is repeated several times and
> is getting quite complicated.
> Can we hide it all behind another macro and use that instead?
>
I've defined MR_HAVE_SYNC_BUILTINS for clang or gcc >= 4.1.
Thanks.
Peter
More information about the reviews
mailing list