I need this for acpi locking, okay? (I'd also like to get rid of the silly x86_* prefix to match the i386 function name, but that's a different topic)
Index: arch/amd64/include/atomic.h =================================================================== RCS file: /cvs/src/sys/arch/amd64/include/atomic.h,v retrieving revision 1.8 diff -u -p -r1.8 atomic.h --- arch/amd64/include/atomic.h 23 Mar 2011 16:54:34 -0000 1.8 +++ arch/amd64/include/atomic.h 19 Sep 2012 12:38:31 -0000 @@ -90,6 +90,17 @@ x86_atomic_clearbits_u32(volatile u_int3 __asm __volatile(LOCK " andl %1,%0" : "=m" (*ptr) : "ir" (~bits)); } +static __inline int +x86_atomic_ucas_32(volatile uint32_t *ptr, uint32_t expect, uint32_t set) +{ + u_long res; + + __asm volatile(LOCK " cmpxchgl %2, %1" : "=a" (res), "=m" (*ptr) + : "r" (set), "a" (expect), "m" (*ptr) : "memory"); + + return (res); +} + static __inline u_long x86_atomic_cas_ul(volatile u_long *ptr, u_long expect, u_long set) {