qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 01/15] atomic: introduce atomic operations


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 01/15] atomic: introduce atomic operations
Date: Wed, 8 Aug 2012 14:09:25 +0100

On Wed, Aug 8, 2012 at 10:21 AM, Peter Maydell <address@hidden> wrote:
> On 8 August 2012 07:25, Liu Ping Fan <address@hidden> wrote:
>> +static inline void atomic_sub(int i, Atomic *v)
>> +{
>> +    asm volatile("lock; subl %1,%0"
>> +             : "+m" (v->counter)
>> +             : "ir" (i));
>> +}
>
> NAK. We don't want random inline assembly implementations of locking
> primitives in QEMU, they are way too hard to keep working with all the
> possible host architectures we support. I spent some time a while back
> getting rid of the (variously busted) versions we had previously.
>
> If you absolutely must use atomic ops, use the gcc builtins. For
> preference, stick to higher level and less error-prone abstractions.

We're spoilt for choice here:

1. Atomic built-ins from gcc
2. glib atomics

No need to roll our own or copy the implementation from the kernel.

Stefan



reply via email to

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