All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, philippe.mathieu.daude@gmail.com,
	peter.maydell@linaro.org
Subject: Re: [PATCH v2 2/2] meson: fix CONFIG_ATOMIC128 check
Date: Mon, 28 Feb 2022 11:20:36 -1000	[thread overview]
Message-ID: <b5c0c9bc-2a93-96cf-5f4a-d50da912aca8@linaro.org> (raw)
In-Reply-To: <20220228200032.777433-2-marcandre.lureau@redhat.com>

On 2/28/22 10:00, marcandre.lureau@redhat.com wrote:
> -# See if 64-bit atomic operations are supported.
> -# Note that without __atomic builtins, we can only
> -# assume atomic loads/stores max at pointer size.
> -config_host_data.set('CONFIG_ATOMIC64', cc.links('''
> +atomic_test = '''
>     #include <stdint.h>
>     int main(void)
>     {
> -    uint64_t x = 0, y = 0;
> +    @0@ x = 0, y = 0;
>       y = __atomic_load_n(&x, __ATOMIC_RELAXED);
>       __atomic_store_n(&x, y, __ATOMIC_RELAXED);
>       __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
>       __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
>       __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
>       return 0;
> -  }'''))
> +  }'''
> +
> +# See if 64-bit atomic operations are supported.
> +# Note that without __atomic builtins, we can only
> +# assume atomic loads/stores max at pointer size.
> +config_host_data.set('CONFIG_ATOMIC64', cc.links(atomic_test.format('uint64_t')))
>   
>   has_int128 = cc.links('''
>     __int128_t a;
> @@ -1837,15 +1839,10 @@ has_int128 = cc.links('''
>   config_host_data.set('CONFIG_INT128', has_int128)
>   
>   if has_int128
> -  has_atomic128 = cc.links('''
> -    int main(void)
> -    {
> -      unsigned __int128 x = 0, y = 0;
> -      y = __atomic_load(&x, 0);
> -      __atomic_store(&x, y, 0);
> -      __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
> -      return 0;
> -    }''')
> +  # "do we have 128-bit atomics which are handled inline and specifically not
> +  # via libatomic". The reason we can't use libatomic is documented in the
> +  # comment starting "GCC is a house divided" in include/qemu/atomic128.h.
> +  has_atomic128 = cc.links(atomic_test.format('unsigned __int128'))

Nice fix.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


  reply	other threads:[~2022-02-28 21:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28 20:00 [PATCH v2 1/2] meson: move int128 checks from configure marcandre.lureau
2022-02-28 20:00 ` [PATCH v2 2/2] meson: fix CONFIG_ATOMIC128 check marcandre.lureau
2022-02-28 21:20   ` Richard Henderson [this message]
2022-02-28 23:12   ` Philippe Mathieu-Daudé
2022-02-28 21:19 ` [PATCH v2 1/2] meson: move int128 checks from configure Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b5c0c9bc-2a93-96cf-5f4a-d50da912aca8@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philippe.mathieu.daude@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.