Messages in this thread | | | Date | Fri, 24 Mar 2017 19:04:41 +0100 | From | Peter Zijlstra <> | Subject | Re: locking/atomic: Introduce atomic_try_cmpxchg() |
| |
On Fri, Mar 24, 2017 at 07:00:25PM +0100, Peter Zijlstra wrote: > static inline bool try_cmpxchg2(unsigned int *ptr, unsigned int *val, unsigned int new) > { > unsigned int old = *val; > bool success; > > asm volatile goto("lock cmpxchgl %[new], %[ptr]; " > "jnz %[label]" > : /* no output */ > : [ptr] "+m" (*ptr), > [old] "+a" (old) > [new] "r" (new) > : "memory" > : label); > return 1; > > label: > *val = old; > return 0; > }
N/m, I'm apparently so tired I didn't see the compiler errors :/
| |