Fix cmpxchg Signed-off-by: Atle Nissestad <[EMAIL PROTECTED]>
diff --git a/linux-2.6.x/include/asm-nios2nommu/system.h b/linux-2.6.x/include/asm-nios2nommu/system.h index 7c35af0..d5b4822 100644 --- a/linux-2.6.x/include/asm-nios2nommu/system.h +++ b/linux-2.6.x/include/asm-nios2nommu/system.h @@ -156,11 +156,15 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz */ #define __HAVE_ARCH_CMPXCHG 1 +/* This function doesn't exist, so you'll get a linker error + if something tries to do an invalid cmpxchg(). */ +extern void __cmpxchg_called_with_bad_pointer(void); + static __inline__ unsigned long -cmpxchg(volatile int *p, int old, int new) +__cmpxchg_u32(volatile unsigned long *p, unsigned long old, unsigned long new) { unsigned long flags; - int prev; + unsigned long prev; local_irq_save(flags); if ((prev = *p) == old) @@ -169,4 +173,22 @@ cmpxchg(volatile int *p, int old, int new) return(prev); } +static inline unsigned long +__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) +{ + if (size == 4) + return __cmpxchg_u32(ptr, old, new); + + __cmpxchg_called_with_bad_pointer(); + return old; +} + +#define cmpxchg(ptr,o,n) \ + ({ \ + __typeof__(*(ptr)) _o_ = (o); \ + __typeof__(*(ptr)) _n_ = (n); \ + (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \ + (unsigned long)_n_, sizeof(*(ptr))); \ + }) + #endif /* _NIOS2NOMMU_SYSTEM_H */ -- 1.5.3.2 _______________________________________________ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev