diff options
author | cognet <cognet@FreeBSD.org> | 2004-11-05 23:48:12 +0000 |
---|---|---|
committer | cognet <cognet@FreeBSD.org> | 2004-11-05 23:48:12 +0000 |
commit | 78386f3ec2096601ba522a0da7bba3a2fdeb262f (patch) | |
tree | b9fa43fbed7733496b33d27ff984547ed732aa31 /sys/arm/include | |
parent | ab5ce779835b16e91fdb96b3c867841ac3dcf7ff (diff) | |
download | FreeBSD-src-78386f3ec2096601ba522a0da7bba3a2fdeb262f.zip FreeBSD-src-78386f3ec2096601ba522a0da7bba3a2fdeb262f.tar.gz |
Disable interrupts for atomic_cmpset_32, this one is just not atomic.
Don't export it to userland.
Diffstat (limited to 'sys/arm/include')
-rw-r--r-- | sys/arm/include/atomic.h | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/arm/include/atomic.h b/sys/arm/include/atomic.h index 249dc21..9785ba6 100644 --- a/sys/arm/include/atomic.h +++ b/sys/arm/include/atomic.h @@ -106,7 +106,7 @@ static __inline int atomic_load_32(volatile uint32_t *v) { - return (__swp(*v, v)); + return (atomic_op(0, +, v)); } static __inline void @@ -122,20 +122,23 @@ atomic_readandclear_32(volatile u_int32_t *p) return (__swp(0, p)); } +#ifdef _KERNEL static __inline u_int32_t atomic_cmpset_32(volatile u_int32_t *p, u_int32_t cmpval, u_int32_t newval) { - uint32_t r, e; - - for (e = *p;; e = r) { - if (*p == cmpval) { - r = __swp(newval, p); - if (r == e) - return (1); + int done; + + __with_interrupts_disabled( + { + if (*p == cmpval) { + *p = newval; + done = 1; } else - return (0); - } + done = 0; + }); + return (done); } +#endif static __inline void atomic_add_32(volatile u_int32_t *p, u_int32_t val) |