Il 02/07/2013 13:44, Jan Kiszka ha scritto:
> On 2013-07-02 13:28, Paolo Bonzini wrote:
>> Il 02/07/2013 13:15, Andreas Färber ha scritto:
>>>>> @@ -683,16 +683,15 @@ GSList *object_class_get_list(const char 
>>>>> *implements_type,
>>>>>  
>>>>>  void object_ref(Object *obj)
>>>>>  {
>>>>> -    obj->ref++;
>>>>> +     __sync_fetch_and_add(&obj->ref, 1);
>>> How widespread are these in GCC/clang? Is there any fallback? I remember
>>> seeing some __sync_* warnings on Mac OS X around 4.2...
>>
>> We are using them already in several places (vhost was the first one to
>> introduce them, I think, but now they are also in migration ad in some
>> tests too).  There is no fallback (asm could be a fallback, but we chose
>> to require GCC 4.2 or newer).
>>
>> I'll change this to atomic_inc/dec when applying.  Otherwise
> 
> But then atomic_dec_and_test or so. Letting the inc/dec return some
> value leaves room for interpretations (value of before or after the
> modification?).

In qemu, I made all atomic_* functions return the old value.  This is
consistent with atomic_cmpxchg and atomic_xchg (where returning the new
value makes no sense).

Paolo


Reply via email to