Messages in this thread | | | Date | Tue, 23 Aug 2011 13:45:08 -0700 | From | "H. Peter Anvin" <> | Subject | Re: [PATCH 13/15] x86: add cmpxchg_flag() variant |
| |
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
| |