[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] qemu/atomic.h: add #ifdef guards for stdatomic.h
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH] qemu/atomic.h: add #ifdef guards for stdatomic.h |
Date: |
Thu, 26 Mar 2020 19:05:41 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
On 26/03/20 18:14, Peter Maydell wrote:
>> +#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...
That's not a problem as long as they are all functions, the macros would
simply override the function-based implementation.
Paolo
Re: [PATCH] qemu/atomic.h: add #ifdef guards for stdatomic.h, Richard Henderson, 2020/03/26