Thread (44 messages) 44 messages, 3 authors, 2013-10-10
STALE4641d

[PATCH] ARM: include: asm: atomic.h: use type cast 's64' for the return value of atomic64_add_return().

From: Russell King - ARM Linux <hidden>
Date: 2013-09-24 10:27:36

On Tue, Sep 24, 2013 at 10:30:41AM +0100, Will Deacon wrote:
On Sat, Sep 21, 2013 at 12:06:47PM +0100, Chen Gang wrote:
quoted
diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
index da1c77d..8cf005d 100644
--- a/arch/arm/include/asm/atomic.h
+++ b/arch/arm/include/asm/atomic.h
@@ -475,7 +475,7 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
 	return ret;
 }
 
-#define atomic64_add_negative(a, v)	(atomic64_add_return((a), (v)) < 0)
+#define atomic64_add_negative(a, v)	((s64)atomic64_add_return((a), (v)) < 0)
 #define atomic64_inc(v)			atomic64_add(1LL, (v))
 #define atomic64_inc_return(v)		atomic64_add_return(1LL, (v))
 #define atomic64_inc_and_test(v)	(atomic64_inc_return(v) == 0)
Is this the right fix? It looks more like atomic[64]_t should be signed, but
some 32-bit architectures (ARM, x86, tile) are actually implementing
atomic64_t as u64. Furthermore, there are discrepencies in the operands to
the various atomic64_* function (long long vs u64) which probably need
sorting out.
Even though our underlying type is u64, we could change the arguments to
be 'long long' as per the asm-generic/atomic64.h version.  Remember that
this is ARM specific code, and we know that long long == 64-bit int.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help