|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCHv3 1/4] x86: provide xadd()
>>> On 21.04.15 at 12:11, <david.vrabel@xxxxxxxxxx> wrote:
> +static always_inline unsigned long __xadd(
> + volatile void *ptr, unsigned long v, int size)
> +{
> + switch ( size )
> + {
> + case 1:
> + asm volatile ( "lock; xaddb %b0,%1"
> + : "+r" (v), "+m" (*__xg((volatile void *)ptr))
> + :: "memory");
> + return v;
This doesn't seem to guarantee to return the old value: When the
passed in v has more than 8 significant bits (which will get ignored
as input), nothing will zap those bits from the register. Same for
the 16-bit case obviously.
> +#define xadd(ptr, v) ({ \
> + __xadd((ptr), (unsigned long)(v), sizeof(*(ptr))); \
> + })
Assuming only xadd() is supposed to be used directly, perhaps
the easiest would be to cast v to typeof(*(ptr)) (instead of
unsigned long) here?
Also note that there's still a superfluous pair of parentheses
left here.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |