Hi Atle,

Atle Nissestad wrote:
Fix cmpxchg

Signed-off-by: Atle Nissestad <[EMAIL PROTECTED]>

Applied, thanks.

Regards
Greg



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 */

--
------------------------------------------------------------------------
Greg Ungerer  --  Chief Software Dude       EMAIL:     [EMAIL PROTECTED]
Secure Computing Corporation                PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com
_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to