Russell King wrote:
On Sat, Nov 05, 2005 at 06:57:28PM +1100, Nick Piggin wrote:Index: linux-2.6/include/asm-arm/atomic.h =================================================================== --- linux-2.6.orig/include/asm-arm/atomic.h +++ linux-2.6/include/asm-arm/atomic.h@@ -80,6 +80,23 @@ static inline int atomic_sub_return(int return result;} +static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) +{ + u32 oldval, res; + + do { + __asm__ __volatile__("@ atomic_cmpxchg\n" + "ldrex %1, [%2]\n" + "teq %1, %3\n" + "strexeq %0, %4, [%2]\n" + : "=&r" (res), "=&r" (oldval) + : "r" (&ptr->counter), "r" (old), "r" (new) + : "cc"); + } while (res); + + return oldval; +} + static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) { unsigned long tmp, tmp2;@@ -131,6 +148,21 @@ static inline int atomic_sub_return(int return val;} +static inline int atomic_cmpxchg(atomic_t *v, int old, int new) +{ + int ret; + unsigned long flags; + + local_irq_save(flags); + ret = v->counter; + if (likely(ret == old)) + v->counter = new; + local_irq_restore(flags); + + return ret; +} + +static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)This is obviously going to break ARM...
Ah dang sorry. Must be a cut-n-paste-o. While you're here, does the assembly code for the SMP version look OK? You basically provided me with it but I don't think you saw its final form. -- SUSE Labs, Novell Inc.Send instant messages to your online friends http://au.messenger.yahoo.com -
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- Re: [patch 2/5] atomic: cmpxchg
- From: Russell King <[email protected]>
- Re: [patch 2/5] atomic: cmpxchg
- References:
- [patch 0/4] atomic primitives again
- From: Nick Piggin <[email protected]>
- [patch 1/5] i386: generic cmpxchg
- From: Nick Piggin <[email protected]>
- [patch 2/5] atomic: cmpxchg
- From: Nick Piggin <[email protected]>
- Re: [patch 2/5] atomic: cmpxchg
- From: Russell King <[email protected]>
- [patch 0/4] atomic primitives again
- Prev by Date: Re: 3ware 9550SX problems - mke2fs incredibly slow writing last third of inode tables
- Next by Date: Re: [patch 2/5] atomic: cmpxchg
- Previous by thread: Re: [patch 2/5] atomic: cmpxchg
- Next by thread: Re: [patch 2/5] atomic: cmpxchg
- Index(es):