diff options
author | Paul Irofti <pirofti@cvs.openbsd.org> | 2012-11-19 15:18:07 +0000 |
---|---|---|
committer | Paul Irofti <pirofti@cvs.openbsd.org> | 2012-11-19 15:18:07 +0000 |
commit | 0e08eeef6781467acc87f53e95ba005c5680186b (patch) | |
tree | 3f249c46080de729a84a6f6cb1c62172c2c5e398 /sys/arch/i386 | |
parent | d6b26a98fcca45808b4798c6ea16a2341cf4f2a9 (diff) |
Add atomic 32-bit cas operations.
This is needed for future acpi global locking routines.
Okay kettenis@
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/include/atomic.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/arch/i386/include/atomic.h b/sys/arch/i386/include/atomic.h index 292654f39d8..eac3adc86c6 100644 --- a/sys/arch/i386/include/atomic.h +++ b/sys/arch/i386/include/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.10 2012/11/19 15:03:55 pirofti Exp $ */ +/* $OpenBSD: atomic.h,v 1.11 2012/11/19 15:18:06 pirofti Exp $ */ /* $NetBSD: atomic.h,v 1.1.2.2 2000/02/21 18:54:07 sommerfeld Exp $ */ /*- @@ -99,6 +99,17 @@ i486_atomic_cas_int(volatile u_int *ptr, u_int expect, u_int set) return (res); } +static __inline int +i386_atomic_cas_int32(volatile int32_t *ptr, int32_t expect, int32_t set) +{ + int res; + + __asm volatile(LOCK " cmpxchgl %2, %1" : "=a" (res), "=m" (*ptr) + : "r" (set), "a" (expect), "m" (*ptr) : "memory"); + + return (res); +} + int ucas_32(volatile int32_t *, int32_t, int32_t); #define futex_atomic_ucas_int32 ucas_32 |