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

2013-06-18 Thread Paolo Bonzini
Il 18/06/2013 16:38, 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 v2 1/2] add a header file for atomic operations

2013-06-18 Thread Richard Henderson
On 06/18/2013 01:36 AM, Paolo Bonzini wrote: >> Why all the ifdefs? If __atomic support is present, then __ATOMIC defines >> will >> exist. > > Then I can just use "#ifdef __ATOMIC_RELAXED" instead of > "#if QEMU_GNUC_PREREQ(4, 8)"? I'd say so. > I have no idea, but I can say which semantics I

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

2013-06-18 Thread Paolo Bonzini
Il 18/06/2013 10:36, Paolo Bonzini ha scritto: > Important Note: Note that it is important for both threads to access > the same volatile variable in order to properly set up the happens-before > relationship. It is not the case that everything visible to thread A > when it writes v

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

2013-06-18 Thread Paolo Bonzini
Il 17/06/2013 20:57, Richard Henderson ha scritto: > On 06/16/2013 04:21 AM, Liu Ping Fan wrote: >> +#if QEMU_GNUC_PREREQ(4, 8) >> +#ifndef __ATOMIC_RELAXED >> +#define __ATOMIC_RELAXED 0 >> +#endif > > Why all the ifdefs? If __atomic support is present, then __ATOMIC defines > will > exist. Th

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

2013-06-17 Thread Richard Henderson
On 06/16/2013 04:21 AM, Liu Ping Fan wrote: > +#if QEMU_GNUC_PREREQ(4, 8) > +#ifndef __ATOMIC_RELAXED > +#define __ATOMIC_RELAXED 0 > +#endif Why all the ifdefs? If __atomic support is present, then __ATOMIC defines will exist. > +/* Compiler barrier */ > +#define barrier() ({ asm volatile(""

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

2013-06-16 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 --- docs/atomics.txt | 322 +++ hw/display/qxl.c