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

Re: [Xen-devel] [PATCH 1/2] x86: drop unused barrier parameter from build_{read, write}_atomic()



On 09/06/17 13:43, Jan Beulich wrote:
> Also take the opportunity and make an attempt at making the macro
> definitions readable. Drop pointless casts while doing so.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, although as I've
said before ...

>
> --- a/xen/include/asm-x86/atomic.h
> +++ b/xen/include/asm-x86/atomic.h
> @@ -4,15 +4,19 @@
>  #include <xen/atomic.h>
>  #include <asm/system.h>
>  
> -#define build_read_atomic(name, size, type, reg, barrier) \
> +#define build_read_atomic(name, size, type, reg) \
>  static inline type name(const volatile type *addr) \
> -{ type ret; asm volatile("mov" size " %1,%0":reg (ret) \
> -:"m" (*(volatile type *)addr) barrier); return ret; }
> +{ \
> +    type ret; \
> +    asm volatile ( "mov" size " %1,%0" : reg (ret) : "m" (*addr) ); \
> +    return ret; \
> +}

... this style of \'s is still less readable than lining them out of the
way on the right hand side.

Actually, for the sake of a couple of lines, I don't think having these
definitions obfuscated by macros is helpful in the first place.

~Andrew

>  
> -#define build_write_atomic(name, size, type, reg, barrier) \
> +#define build_write_atomic(name, size, type, reg) \
>  static inline void name(volatile type *addr, type val) \
> -{ asm volatile("mov" size " %1,%0": "=m" (*(volatile type *)addr) \
> -:reg (val) barrier); }
> +{ \
> +    asm volatile ( "mov" size " %1,%0" : "=m" (*addr) : reg (val) ); \
> +}
>  
>  #define build_add_sized(name, size, type, reg) \
>      static inline void name(volatile type *addr, type val)              \
> @@ -22,15 +26,15 @@ static inline void name(volatile type *a
>                       : reg (val));                                      \
>      }
>  
> -build_read_atomic(read_u8_atomic, "b", uint8_t, "=q", )
> -build_read_atomic(read_u16_atomic, "w", uint16_t, "=r", )
> -build_read_atomic(read_u32_atomic, "l", uint32_t, "=r", )
> -build_read_atomic(read_u64_atomic, "q", uint64_t, "=r", )
> -
> -build_write_atomic(write_u8_atomic, "b", uint8_t, "q", )
> -build_write_atomic(write_u16_atomic, "w", uint16_t, "r", )
> -build_write_atomic(write_u32_atomic, "l", uint32_t, "r", )
> -build_write_atomic(write_u64_atomic, "q", uint64_t, "r", )
> +build_read_atomic(read_u8_atomic, "b", uint8_t, "=q")
> +build_read_atomic(read_u16_atomic, "w", uint16_t, "=r")
> +build_read_atomic(read_u32_atomic, "l", uint32_t, "=r")
> +build_read_atomic(read_u64_atomic, "q", uint64_t, "=r")
> +
> +build_write_atomic(write_u8_atomic, "b", uint8_t, "q")
> +build_write_atomic(write_u16_atomic, "w", uint16_t, "r")
> +build_write_atomic(write_u32_atomic, "l", uint32_t, "r")
> +build_write_atomic(write_u64_atomic, "q", uint64_t, "r")
>  
>  build_add_sized(add_u8_sized, "b", uint8_t, "qi")
>  build_add_sized(add_u16_sized, "w", uint16_t, "ri")
>
>
>


_______________________________________________
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®.