qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4 15/35] tcg: Add CONFIG_ATOMIC64


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v4 15/35] tcg: Add CONFIG_ATOMIC64
Date: Tue, 4 Oct 2016 16:58:10 +0100

On 4 October 2016 at 16:47, Alex Bennée <address@hidden> wrote:
>
> Richard Henderson <address@hidden> writes:
>>
>> +#########################################
>> +# See if 64-bit atomic operations are supported.
>> +# Note that without __atomic builtins, we can only
>> +# assume atomic loads/stores max at pointer size.
>> +
>> +cat > $TMPC << EOF
>> +#include <stdint.h>
>> +int main(void)
>> +{
>> +  uint64_t x = 0, y = 0;
>> +#ifdef __ATOMIC_RELAXED
>> +  y = __atomic_load_8(&x, 0);
>> +  __atomic_store_8(&x, y, 0);
>> +  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
>> +  __atomic_exchange_8(&x, y, 0);
>> +  __atomic_fetch_add_8(&x, y, 0);
>> +#else
>> +  char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
> <snip>
>
> This breaks with --enable-werror (and my Travis images):
>
> config-temp/qemu-conf.c: In function ‘main’:
> config-temp/qemu-conf.c:12:8: error: unused variable ‘is_host64’ 
> [-Werror=unused-variable]
>
> I'm not sure what the best fix is here? Pass -no-werror to the test compile?

I would write this as:

#define QEMU_BUILD_BUG_ON(x) \
    typedef char glue(qemu_build_bug_on__,__LINE__)[(x)?-1:1]
__attribute__((unused));
QEMU_BUILD_BUG_ON(sizeof(void *) >= sizeof(uint64_t))

which is (more or less) what we do for the existing
"is size_t the same as GLIB_SIZEOF_SIZE_T" test.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]