QEMU-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [PATCH] qemu/atomic.h: add #ifdef guards for stdatomic.h
Date: Thu, 26 Mar 2020 17:14:38 +0000
Message-ID: <CAFEAcA8Lo84gNk2tFCKsgM_O50bXTCs6Z9jH6aCvfDA56TDCmA@mail.gmail.com> (raw)
In-Reply-To: <20200326170121.13045-1-alex.bennee@linaro.org>

On Thu, 26 Mar 2020 at 17:01, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Deep inside the FreeBSD netmap headers we end up including stdatomic.h
> which clashes with qemu's atomic functions which are modelled along
> the C11 standard. To avoid a massive rename lets just ifdef around the
> problem.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  include/qemu/atomic.h | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
> index f9cd24c8994..ff72db51154 100644
> --- a/include/qemu/atomic.h
> +++ b/include/qemu/atomic.h
> @@ -208,11 +208,14 @@
>  /* Provide shorter names for GCC atomic builtins, return old value */
>  #define atomic_fetch_inc(ptr)  __atomic_fetch_add(ptr, 1, __ATOMIC_SEQ_CST)
>  #define atomic_fetch_dec(ptr)  __atomic_fetch_sub(ptr, 1, __ATOMIC_SEQ_CST)
> +
> +#ifndef atomic_fetch_add
>  #define atomic_fetch_add(ptr, n) __atomic_fetch_add(ptr, n, __ATOMIC_SEQ_CST)
>  #define atomic_fetch_sub(ptr, n) __atomic_fetch_sub(ptr, n, __ATOMIC_SEQ_CST)
>  #define atomic_fetch_and(ptr, n) __atomic_fetch_and(ptr, n, __ATOMIC_SEQ_CST)
>  #define atomic_fetch_or(ptr, n)  __atomic_fetch_or(ptr, n, __ATOMIC_SEQ_CST)
>  #define atomic_fetch_xor(ptr, n) __atomic_fetch_xor(ptr, n, __ATOMIC_SEQ_CST)
> +#endif

This will work around FreeBSD's current implementation in particular,
but I don't think there's anything in the C11 spec that mandates that
atomic_fetch_add() and friends have to be macros and not simply
functions...

thanks
-- PMM


  reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 17:01 Alex Bennée
2020-03-26 17:14 ` Peter Maydell [this message]
2020-03-26 17:32   ` Alex Bennée
2020-03-26 18:05   ` Paolo Bonzini
2020-03-26 20:19     ` Peter Maydell
2020-03-27  9:51       ` Alex Bennée
2020-03-27 13:35         ` Richard Henderson
2020-03-26 19:58 ` Richard Henderson
2020-03-26 20:05   ` Paolo Bonzini

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=CAFEAcA8Lo84gNk2tFCKsgM_O50bXTCs6Z9jH6aCvfDA56TDCmA@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=pbonzini@redhat.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

QEMU-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/qemu-devel/0 qemu-devel/git/0.git
	git clone --mirror https://lore.kernel.org/qemu-devel/1 qemu-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 qemu-devel qemu-devel/ https://lore.kernel.org/qemu-devel \
		qemu-devel@nongnu.org
	public-inbox-index qemu-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.nongnu.qemu-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git