qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 1/5] bitops: introduce change_bit_atomic


From: Dr. David Alan Gilbert
Subject: Re: [Qemu-devel] [PATCH v3 1/5] bitops: introduce change_bit_atomic
Date: Fri, 23 Nov 2018 10:23:35 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

* address@hidden (address@hidden) wrote:
> From: Xiao Guangrong <address@hidden>
> 
> It will be used by threaded workqueue
> 
> Signed-off-by: Xiao Guangrong <address@hidden>

Reviewed-by: Dr. David Alan Gilbert <address@hidden>

> ---
>  include/qemu/bitops.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
> index 3f0926cf40..c522958852 100644
> --- a/include/qemu/bitops.h
> +++ b/include/qemu/bitops.h
> @@ -79,6 +79,19 @@ static inline void change_bit(long nr, unsigned long *addr)
>      *p ^= mask;
>  }
>  
> +/**
> + * change_bit_atomic - Toggle a bit in memory atomically
> + * @nr: Bit to change
> + * @addr: Address to start counting from
> + */
> +static inline void change_bit_atomic(long nr, unsigned long *addr)
> +{
> +    unsigned long mask = BIT_MASK(nr);
> +    unsigned long *p = addr + BIT_WORD(nr);
> +
> +    atomic_xor(p, mask);
> +}
> +
>  /**
>   * test_and_set_bit - Set a bit and return its old value
>   * @nr: Bit to set
> -- 
> 2.14.5
> 
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK



reply via email to

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