Re: [PATCH 13/15] x86: add cmpxchg_flag() variant

From: H. Peter Anvin
Date: Tue Aug 23 2011 - 16:45:47 EST


On 08/23/2011 12:53 PM, Jeremy Fitzhardinge wrote:
>
> Yes, that would ideal. The closest you can get is asm goto(), but the
> syntax for that would be awful; something like:
>
> #define cmpxchg_jump(ptr, old, new, fail)\
> asm goto (...)
>
>
> :
> :
>
> again:
> old = *thingp;
> new = frobulate(old);
> cmpxchg_jump(thingp, old, new, again);
> /* worked */
>
> Would this be useful enough?
>

Actually there is a trick:

static inline bool ....
{
asm goto(... yes);
no:
return false;
yes:
return true;
}

... which makes syntax a heckuva lot less awkward.

-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/