summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-04-05 17:35:12 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-04-05 17:35:12 +0000
commitcea8197c7dfaf7a62d1b667c7b3bf8a8c905c48b (patch)
treef73f7ad7e7f8aa705bb168c22c424ddc2a0291a2 /sys/arch
parent342f1c8c6a5710f960fea7396ec57e8661e389f2 (diff)
Disable interrupts around bit operations for propert atomicity against them.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sh/include/atomic.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/arch/sh/include/atomic.h b/sys/arch/sh/include/atomic.h
index 736b0e5b87a..9ba0a329bdf 100644
--- a/sys/arch/sh/include/atomic.h
+++ b/sys/arch/sh/include/atomic.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: atomic.h,v 1.2 2007/02/19 17:18:43 deraadt Exp $ */
+/* $OpenBSD: atomic.h,v 1.3 2007/04/05 17:35:11 miod Exp $ */
/* Public Domain */
@@ -7,16 +7,28 @@
#if defined(_KERNEL)
+#include <sh/psl.h>
+
static __inline void
atomic_setbits_int(__volatile unsigned int *uip, unsigned int v)
{
+ unsigned int sr;
+
+ __asm__ __volatile__ ("stc sr, %0" : "=r"(sr));
+ __asm__ __volatile__ ("ldc %0, sr" : : "r"(sr | PSL_IMASK));
*uip |= v;
+ __asm__ __volatile__ ("ldc %0, sr" : : "r"(sr));
}
static __inline void
atomic_clearbits_int(__volatile unsigned int *uip, unsigned int v)
{
+ unsigned int sr;
+
+ __asm__ __volatile__ ("stc sr, %0" : "=r"(sr));
+ __asm__ __volatile__ ("ldc %0, sr" : : "r"(sr | PSL_IMASK));
*uip &= ~v;
+ __asm__ __volatile__ ("ldc %0, sr" : : "r"(sr));
}
#endif /* defined(_KERNEL) */