summaryrefslogtreecommitdiff
path: root/sys/arch/alpha/include
diff options
context:
space:
mode:
authorMartin Reindl <martin@cvs.openbsd.org>2007-03-17 09:12:04 +0000
committerMartin Reindl <martin@cvs.openbsd.org>2007-03-17 09:12:04 +0000
commit1a3a431bff0ebd6ac122a6cde26596d5e7ed7cc3 (patch)
tree2fb04486ad6bfa57ef280c0f3183b50aab712714 /sys/arch/alpha/include
parentcebc296c4b4d84afa0f516d9503adffd0d2afb3b (diff)
add proper atomic_{set,clear}bits_int implementation
prodded by art@ ok art@
Diffstat (limited to 'sys/arch/alpha/include')
-rw-r--r--sys/arch/alpha/include/atomic.h46
1 files changed, 43 insertions, 3 deletions
diff --git a/sys/arch/alpha/include/atomic.h b/sys/arch/alpha/include/atomic.h
index ef634f7c1a5..d570c4afe7f 100644
--- a/sys/arch/alpha/include/atomic.h
+++ b/sys/arch/alpha/include/atomic.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: atomic.h,v 1.5 2007/02/19 17:18:40 deraadt Exp $ */
+/* $OpenBSD: atomic.h,v 1.6 2007/03/17 09:12:03 martin Exp $ */
/* $NetBSD: atomic.h,v 1.7 2001/12/17 23:34:57 thorpej Exp $ */
/*-
@@ -179,16 +179,56 @@ atomic_loadlatch_ulong(__volatile unsigned long *ulp, unsigned long v)
return (v0);
}
+/*
+ * atomic_setbits_int:
+ *
+ * Atomically set bits in a `unsigned int'.
+ */
static __inline void
atomic_setbits_int(__volatile unsigned int *uip, unsigned int v)
{
- *uip |= v;
+ unsigned int t0;
+
+ __asm __volatile(
+ "# BEGIN atomic_setbits_ulong\n"
+ "1: ldl_l %0, %3 \n"
+ " or %0, %2, %0 \n"
+ " stl_c %0, %1 \n"
+ " beq %0, 2f \n"
+ " mb \n"
+ " br 3f \n"
+ "2: br 1b \n"
+ "3: \n"
+ " # END atomic_setbits_int"
+ : "=&r" (t0), "=m" (*uip)
+ : "r" (v), "m" (*uip)
+ : "memory");
}
+/*
+ * atomic_clearbits_int:
+ *
+ * Atomically clear bits in a `unsigned int'.
+ */
static __inline void
atomic_clearbits_int(__volatile unsigned int *uip, unsigned int v)
{
- *uip &= ~v;
+ unsigned int t0;
+
+ __asm __volatile(
+ "# BEGIN atomic_clearbits_int\n"
+ "1: ldl_l %0, %3 \n"
+ " and %0, %2, %0 \n"
+ " stl_c %0, %1 \n"
+ " beq %0, 2f \n"
+ " mb \n"
+ " br 3f \n"
+ "2: br 1b \n"
+ "3: \n"
+ " # END atomic_clearbits_int"
+ : "=&r" (t0), "=m" (*uip)
+ : "r" (~v), "m" (*uip)
+ : "memory");
}
#endif /* defined(_KERNEL) */