diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2007-03-21 05:28:52 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2007-03-21 05:28:52 +0000 |
commit | 3c9c9dbc6b89ccdcab10e22257d989eaab6b91fb (patch) | |
tree | fa67b100cfdd0ee34a0f3fd1d25cd26cea1eac0d /sys/arch/m88k/include/atomic.h | |
parent | f3670beea1e30c96c45e286914486527148fa021 (diff) |
Real atomic_{set,clear}bits_int implementation, ok deraadt
Diffstat (limited to 'sys/arch/m88k/include/atomic.h')
-rw-r--r-- | sys/arch/m88k/include/atomic.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sys/arch/m88k/include/atomic.h b/sys/arch/m88k/include/atomic.h index 16ebc203af6..d551ba1885c 100644 --- a/sys/arch/m88k/include/atomic.h +++ b/sys/arch/m88k/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/03/21 05:28:51 miod Exp $ */ /* Public Domain */ @@ -10,13 +10,25 @@ static __inline void atomic_setbits_int(__volatile unsigned int *uip, unsigned int v) { - *uip |= v; + unsigned int old, new; + + do { + old = *uip; + new = old | v; + __asm__ __volatile__ ("xmem %0, %1, r0" : "+r"(new) : "r"(uip)); + } while (old != new); } static __inline void atomic_clearbits_int(__volatile unsigned int *uip, unsigned int v) { - *uip &= ~v; + unsigned int old, new; + + do { + old = *uip; + new = old & ~v; + __asm__ __volatile__ ("xmem %0, %1, r0" : "+r"(new) : "r"(uip)); + } while (old != new); } #endif /* defined(_KERNEL) */ |