Re: [Qemu-devel] [PATCH v3 1/2] add a header file for atomic operations

2013-06-20 Thread Paolo Bonzini
Il 19/06/2013 22:44, Richard Henderson ha scritto: >>> >> +/* Data must be read atomically. We don't really need barrier >>> >> semantics >>> >> + * but it's easier to use atomic_* than roll our own. */ >>> >> +log = atomic_xchg(from, 0); >> > >> > If you really don't need

Re: [Qemu-devel] [PATCH v3 1/2] add a header file for atomic operations

2013-06-19 Thread Richard Henderson
On 06/19/2013 01:39 PM, Torvald Riegel wrote: > On Thu, 2013-06-20 at 04:59 +0800, Liu Ping Fan wrote: >> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c >> index fbabf99..28abe1e 100644 >> --- a/hw/virtio/vhost.c >> +++ b/hw/virtio/vhost.c >> @@ -16,6 +16,7 @@ >> #include >> #include "hw/vir

Re: [Qemu-devel] [PATCH v3 1/2] add a header file for atomic operations

2013-06-19 Thread Torvald Riegel
On Thu, 2013-06-20 at 04:59 +0800, Liu Ping Fan wrote: > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c > index fbabf99..28abe1e 100644 > --- a/hw/virtio/vhost.c > +++ b/hw/virtio/vhost.c > @@ -16,6 +16,7 @@ > #include > #include "hw/virtio/vhost.h" > #include "hw/hw.h" > +#include "qemu/at

Re: [Qemu-devel] [PATCH v3 1/2] add a header file for atomic operations

2013-06-19 Thread Paolo Bonzini
Il 19/06/2013 18:37, Richard Henderson ha scritto: >> > +#ifndef atomic_read >> > +#define atomic_read(ptr) (*(__typeof__(*ptr) *volatile) (ptr)) >> > #endif >> > >> > +#ifndef atomic_set >> > +#define atomic_set(ptr, i) ((*(__typeof__(*ptr) *volatile) (ptr)) = >> > (i)) >> > +#endif

Re: [Qemu-devel] [PATCH v3 1/2] add a header file for atomic operations

2013-06-19 Thread Richard Henderson
On 06/19/2013 01:59 PM, Liu Ping Fan wrote: > +#ifndef atomic_read > +#define atomic_read(ptr) (*(__typeof__(*ptr) *volatile) (ptr)) > #endif > > +#ifndef atomic_set > +#define atomic_set(ptr, i) ((*(__typeof__(*ptr) *volatile) (ptr)) = (i)) > +#endif I still think these should be enh

[Qemu-devel] [PATCH v3 1/2] add a header file for atomic operations

2013-06-19 Thread Liu Ping Fan
From: Paolo Bonzini We're already using them in several places, but __sync builtins are just too ugly to type, and do not provide seqcst load/store operations. Signed-off-by: Paolo Bonzini Cc: Richard Henderson Cc: Andrew Haley , Cc: Torvald Riegel , Cc: Paul E. McKenney --- docs/atomics.tx