qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v5 05/18] atomics: add atomic_test_and_set_acqui


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v5 05/18] atomics: add atomic_test_and_set_acquire
Date: Mon, 16 May 2016 12:05:17 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1


On 14/05/2016 05:34, Emilio G. Cota wrote:
> This new helper expands to __atomic_test_and_set with acquire semantics
> where available; otherwise it expands to __sync_test_and_set, which
> has acquire semantics.
> 
> Signed-off-by: Emilio G. Cota <address@hidden>

Non-seqcst read-modify-write operations are beyond what I expected to
have in qemu/atomic.h, but I guess it's okay for test-and-set because of
__sync_test_and_set.

Paolo

> ---
>  include/qemu/atomic.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
> index 5bc4d6c..6061a46 100644
> --- a/include/qemu/atomic.h
> +++ b/include/qemu/atomic.h
> @@ -113,6 +113,7 @@
>  } while(0)
>  #endif
>  
> +#define atomic_test_and_set_acquire(ptr) __atomic_test_and_set(ptr, 
> __ATOMIC_ACQUIRE)
>  
>  /* All the remaining operations are fully sequentially consistent */
>  
> @@ -327,6 +328,8 @@
>  #endif
>  #endif
>  
> +#define atomic_test_and_set_acquire(ptr) __sync_lock_test_and_set(ptr, true)
> +
>  /* Provide shorter names for GCC atomic builtins.  */
>  #define atomic_fetch_inc(ptr)  __sync_fetch_and_add(ptr, 1)
>  #define atomic_fetch_dec(ptr)  __sync_fetch_and_add(ptr, -1)
> 



reply via email to

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