| 
    
 [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCHv4 3/8] x86: provide add_sized()
 >>> On 30.04.15 at 17:33, <david.vrabel@xxxxxxxxxx> wrote:
> @@ -55,6 +69,20 @@ void __bad_atomic_size(void);
>      __x;                                                                \
>  })
>  
> +#define add_sized(p, x) ({                                              \
> +    typeof(*(p)) __x = (x);                                             \
> +    unsigned long x_ = (unsigned long)__x;                              \
I don't see the need for this triple type conversion (together with the
code below): original -> typeof(*(p)) -> unsigned long -> uintN_t.
(For write_atomic() I think this aids writing pointers, but add_sized()
surely isn't meant to do that?)
> +    switch ( sizeof(*(p)) )                                             \
> +        {                                                               \
> +        case 1: add_u8_sized((uint8_t *)(p), (uint8_t)x_); break;       \
> +        case 2: add_u16_sized((uint16_t *)(p), (uint16_t)x_); break;    \
> +        case 4: add_u32_sized((uint32_t *)(p), (uint32_t)x_); break;    \
> +        case 8: add_u64_sized((uint64_t *)(p), (uint64_t)x_); break;    \
> +        default: __bad_atomic_size(); break;                            \
> +        }                                                               \
> +    __x;                                                                \
I don't see why write_atomic() needs this, and I even less so
understand why add_sized() would need to return its second
input.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
  | 
  
![]()  | 
            
         Lists.xenproject.org is hosted with RackSpace, monitoring our  |