> Date: Wed, 19 Sep 2012 15:41:09 +0300 > From: Paul Irofti <p...@irofti.net> > > 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)
I disagree with the off-topic bit. What we do need is a consistent set of atomic operations across platforms. Haphazardly adding stuff to match the local MD naming conventions isn't going to help. And there is another issue in this case. The i386 version does the whole PCB_FAULT dance, whereas this version doesn't. So I think the #define atomic_ucas_32 ucas_32 that was added (by you) is a mistake. > 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) > {