PATCH : cmpxchg does not handle int * arguments on LP64

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,

I have been using the asm-generic/system.h header to implement my
version of arch/xx/include/asm/system.h: it appears that the version of
cmpxchg defined in this generic header does not handle correctly
non-long arguments on an LP64 arch. 

The attached patch appears to work on my port: I suspect that it's not
the right 'fix'. If so, I would be happy to be pointed in the right
direction. The following inline patch was generated against
davem/net-next-2.6/ (and attached to this email since I don't know what
the proper insertion policy is)

diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h
index efa403b..da31909 100644
--- a/include/asm-generic/system.h
+++ b/include/asm-generic/system.h
@@ -136,24 +136,7 @@ unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
 #define xchg(ptr, x) \
 	((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
 
-static inline unsigned long __cmpxchg(volatile unsigned long *m,
-				      unsigned long old, unsigned long new)
-{
-	unsigned long retval;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	retval = *m;
-	if (retval == old)
-		*m = new;
-	local_irq_restore(flags);
-	return retval;
-}
-
-#define cmpxchg(ptr, o, n)					\
-	((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
-					(unsigned long)(o),	\
-					(unsigned long)(n)))
+#define cmpxchg(ptr, o, n) cmpxchg_local(ptr, o, n)
 
 #endif /* !__ASSEMBLY__ */
 


Mathieu
-- 
Mathieu Lacage <mathieu.lacage@xxxxxxxxxxxxxxx>
Tel: +33 4 9238 5056
diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h
index efa403b..da31909 100644
--- a/include/asm-generic/system.h
+++ b/include/asm-generic/system.h
@@ -136,24 +136,7 @@ unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
 #define xchg(ptr, x) \
 	((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
 
-static inline unsigned long __cmpxchg(volatile unsigned long *m,
-				      unsigned long old, unsigned long new)
-{
-	unsigned long retval;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	retval = *m;
-	if (retval == old)
-		*m = new;
-	local_irq_restore(flags);
-	return retval;
-}
-
-#define cmpxchg(ptr, o, n)					\
-	((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
-					(unsigned long)(o),	\
-					(unsigned long)(n)))
+#define cmpxchg(ptr, o, n) cmpxchg_local(ptr, o, n)
 
 #endif /* !__ASSEMBLY__ */
 

[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux