summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/include/atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/amd64/include/atomic.h')
-rw-r--r--sys/arch/amd64/include/atomic.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/arch/amd64/include/atomic.h b/sys/arch/amd64/include/atomic.h
index effbb04c4db..48df00fae57 100644
--- a/sys/arch/amd64/include/atomic.h
+++ b/sys/arch/amd64/include/atomic.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: atomic.h,v 1.8 2011/03/23 16:54:34 pirofti Exp $ */
+/* $OpenBSD: atomic.h,v 1.9 2012/11/19 15:18:06 pirofti Exp $ */
/* $NetBSD: atomic.h,v 1.1 2003/04/26 18:39:37 fvdl Exp $ */
/*
@@ -90,6 +90,17 @@ x86_atomic_clearbits_u32(volatile u_int32_t *ptr, u_int32_t bits)
__asm __volatile(LOCK " andl %1,%0" : "=m" (*ptr) : "ir" (~bits));
}
+static __inline int
+x86_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);
+}
+
static __inline u_long
x86_atomic_cas_ul(volatile u_long *ptr, u_long expect, u_long set)
{