qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC v1 05/12] atomic: introduce cmpxchg_bool


From: Alex Bennée
Subject: Re: [Qemu-devel] [RFC v1 05/12] atomic: introduce cmpxchg_bool
Date: Fri, 03 Jun 2016 20:12:44 +0100
User-agent: mu4e 0.9.17; emacs 25.0.94.4

Sergey Fedorov <address@hidden> writes:

> On 15/04/16 17:23, Alex Bennée wrote:
>> diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
>> index 5dba7db..94e7110 100644
>> --- a/include/qemu/atomic.h
>> +++ b/include/qemu/atomic.h
>> @@ -123,6 +123,16 @@
>>      _old;                                                               \
>>      })
>>
>> +#define atomic_bool_cmpxchg(ptr, old, new)                              \
>> +    ({                                                                  \
>> +    typeof(*ptr) _old = (old), _new = (new);                            \
>> +    bool r;                                                             \
>> +    r = __atomic_compare_exchange(ptr, &_old, &_new, false,             \
>> +                                  __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);  \
>> +    r;                                                                  \
>> +    })
>> +
>> +
>
> Could be more simple:
>
> #define atomic_bool_cmpxchg(ptr, old, new)                              \
>     ({                                                                  \
>     typeof(*ptr) _old = (old), _new = (new);                            \
>     __atomic_compare_exchange(ptr, &_old, &_new, false,                 \
>                               __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);      \
>     })

OK that makes sense. I'll have to ask my toolchain colleague what the
rules are for results from {} blocks.

--
Alex Bennée



reply via email to

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