diff options
author | 2007-03-17 23:42:06 +0000 | |
---|---|---|
committer | 2007-03-17 23:42:06 +0000 | |
commit | f82411af6f5307636464e1802bb959f5f08652d2 (patch) | |
tree | abdcc8a660c909d18019173f00cb7e027b662105 | |
parent | remove a debug message (diff) | |
download | wireguard-openbsd-f82411af6f5307636464e1802bb959f5f08652d2.tar.xz wireguard-openbsd-f82411af6f5307636464e1802bb959f5f08652d2.zip |
For arm pre-v6 (ie all supported machines) it is necessary to disable
interrupts to be able to have an atomic update of a variable without a mutex.
-rw-r--r-- | sys/arch/arm/include/atomic.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/arch/arm/include/atomic.h b/sys/arch/arm/include/atomic.h index a3ac330fc85..280a48d59ca 100644 --- a/sys/arch/arm/include/atomic.h +++ b/sys/arch/arm/include/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.4 2007/02/19 17:18:42 deraadt Exp $ */ +/* $OpenBSD: atomic.h,v 1.5 2007/03/17 23:42:06 drahn Exp $ */ /* Public Domain */ @@ -7,16 +7,27 @@ #if defined(_KERNEL) +/* + * on pre-v6 arm processors, it is necessary to disable interrupts if + * in the kernel and atomic updates are necessary without full mutexes + */ + static __inline void atomic_setbits_int(__volatile unsigned int *uip, unsigned int v) { + int oldirqstate; + oldirqstate = disable_interrupts(I32_bit|F32_bit); *uip |= v; + restore_interrupts(oldirqstate); } static __inline void atomic_clearbits_int(__volatile unsigned int *uip, unsigned int v) { + int oldirqstate; + oldirqstate = disable_interrupts(I32_bit|F32_bit); *uip &= ~v; + restore_interrupts(oldirqstate); } #endif /* defined(_KERNEL) */ |