Re: [Qemu-devel] [PATCH 54/66] add a header file for atomic operations

2013-10-21 Thread Paolo Bonzini
Il 21/10/2013 14:53, Peter Maydell ha scritto: > Yes, using __sync_swap seems to work OK. Does clang on linux > require the four-argument __atomic_exchange() or can we just > make the #ifdef __clang__ come first in the #if ladder? Please do that (change the ladder), it's definitely a good idea. >

Re: [Qemu-devel] [PATCH 54/66] add a header file for atomic operations

2013-10-21 Thread Peter Maydell
On 21 October 2013 07:06, Paolo Bonzini wrote: > Il 20/10/2013 17:20, Peter Maydell ha scritto: >> CCutil/qemu-thread-posix.o >> util/qemu-thread-posix.c:351:13: warning: implicit declaration of >> function '__sync_exchange' is invalid in >> C99 [-Wimplicit-function-declaration] >>

Re: [Qemu-devel] [PATCH 54/66] add a header file for atomic operations

2013-10-20 Thread Paolo Bonzini
Il 20/10/2013 17:20, Peter Maydell ha scritto: > CCutil/qemu-thread-posix.o > util/qemu-thread-posix.c:351:13: warning: implicit declaration of > function '__sync_exchange' is invalid in > C99 [-Wimplicit-function-declaration] > if (atomic_xchg(&ev->value, EV_SET) == EV_BUSY) {

Re: [Qemu-devel] [PATCH 54/66] add a header file for atomic operations

2013-10-20 Thread Peter Maydell
On 4 July 2013 16:13, Paolo Bonzini wrote: > +#ifndef atomic_xchg > +#ifdef __ATOMIC_SEQ_CST > +#define atomic_xchg(ptr, i)({ \ > +typeof(*ptr) _new = (i), _old; \ > +__atomic_exchange(ptr, &_new, &_old, __ATOMIC_SEQ_CST); \ > +_ol

[Qemu-devel] [PATCH 54/66] add a header file for atomic operations

2013-07-04 Thread 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. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- docs/atomics.txt | 352 +++ hw/display/