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

Re: [Xen-devel] [PATCH 02/16] x86: fix: make atomic_read() param const



On 09/07/16 05:12, Corneliu ZUZU wrote:
> This wouldn't let me make a param of a function that used atomic_read() const.
>
> Signed-off-by: Corneliu ZUZU <czuzu@xxxxxxxxxxxxxxx>

This is a good improvement, but you must make an identical adjustment to
the arm code, otherwise you will end up with subtle build failures.

If you are really feeling up to it, having a common xen/atomic.h with

typedef struct { int counter; } atomic_t;
#define ATOMIC_INIT(i) { (i) }

and some prototypes such as:

static inline int atomic_read(const atomic_t *v);

would be great, but this looks like it has the possibility to turn into
a rats nest.  If it does, then just doubling up this code for arm is ok.

~Andrew

> ---
>  xen/include/asm-x86/atomic.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/xen/include/asm-x86/atomic.h b/xen/include/asm-x86/atomic.h
> index d246b70..0b250c8 100644
> --- a/xen/include/asm-x86/atomic.h
> +++ b/xen/include/asm-x86/atomic.h
> @@ -94,7 +94,7 @@ typedef struct { int counter; } atomic_t;
>   *
>   * Atomically reads the value of @v.
>   */
> -static inline int atomic_read(atomic_t *v)
> +static inline int atomic_read(const atomic_t *v)
>  {
>      return read_atomic(&v->counter);
>  }
> @@ -105,7 +105,7 @@ static inline int atomic_read(atomic_t *v)
>   *
>   * Non-atomically reads the value of @v
>   */
> -static inline int _atomic_read(atomic_t v)
> +static inline int _atomic_read(const atomic_t v)
>  {
>      return v.counter;
>  }


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.