diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-03-17 22:10:05 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-03-17 22:10:05 +0000 |
commit | c9bead7d9d0cf02043da8159b6a2a13e903caa6c (patch) | |
tree | afa5137269a3a228c23cea0796c8a674ee1649ee /sys/arch/powerpc | |
parent | 4aa1b31cb7bce6b7e9e60e8302cb13f800273cfc (diff) |
Implement proper atomic.h for powerpc. With help from art@ and drahn@.
ok drahn@
Diffstat (limited to 'sys/arch/powerpc')
-rw-r--r-- | sys/arch/powerpc/include/atomic.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/sys/arch/powerpc/include/atomic.h b/sys/arch/powerpc/include/atomic.h index 1a73b68e157..21f8233844e 100644 --- a/sys/arch/powerpc/include/atomic.h +++ b/sys/arch/powerpc/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/17 22:10:04 kettenis Exp $ */ /* Public Domain */ @@ -10,13 +10,27 @@ static __inline void atomic_setbits_int(__volatile unsigned int *uip, unsigned int v) { - *uip |= v; + unsigned int tmp; + + __asm volatile ( + "1: lwarx %0, 0, %2 \n" + " or %0, %1, %0 \n" + " stwcx. %0, 0, %2 \n" + " bne- 1b \n" + " sync" : "=&r" (tmp) : "r" (v), "r" (uip) : "memory"); } static __inline void atomic_clearbits_int(__volatile unsigned int *uip, unsigned int v) { - *uip &= ~v; + unsigned int tmp; + + __asm volatile ( + "1: lwarx %0, 0, %2 \n" + " andc %0, %0, %1 \n" + " stwcx. %0, 0, %2 \n" + " bne- 1b \n" + " sync" : "=&r" (tmp) : "r" (v), "r" (uip) : "memory"); } #endif /* defined(_KERNEL) */ |