[PATCH 21/45] C++: Set the type of atomic64_t to s64

From: David Howells
Date: Sun Apr 01 2018 - 16:42:29 EST


Always declare the type of atomic64_t to be s64 rather than conditionally
defining it as long in generic code.

Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
---

arch/x86/include/asm/atomic64_64.h | 12 ++++++------
include/linux/types.h | 4 +---
2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
index 738495caf05f..895292a50c77 100644
--- a/arch/x86/include/asm/atomic64_64.h
+++ b/arch/x86/include/asm/atomic64_64.h
@@ -172,20 +172,20 @@ static inline long atomic64_fetch_sub(long i, atomic64_t *v)
#define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
#define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))

-static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
+static inline long atomic64_cmpxchg(atomic64_t *v, s64 old, s64 new_val)
{
- return cmpxchg(&v->counter, old, new);
+ return cmpxchg(&v->counter, old, new_val);
}

#define atomic64_try_cmpxchg atomic64_try_cmpxchg
-static __always_inline bool atomic64_try_cmpxchg(atomic64_t *v, s64 *old, long new)
+static __always_inline bool atomic64_try_cmpxchg(atomic64_t *v, s64 *old, s64 new_val)
{
- return try_cmpxchg(&v->counter, old, new);
+ return try_cmpxchg(&v->counter, *old, new_val);
}

-static inline long atomic64_xchg(atomic64_t *v, long new)
+static inline long atomic64_xchg(atomic64_t *v, long new_val)
{
- return xchg(&v->counter, new);
+ return xchg(&v->counter, new_val);
}

/**
diff --git a/include/linux/types.h b/include/linux/types.h
index 68323cb03910..d233b12c7ebe 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -179,11 +179,9 @@ typedef struct {
int counter;
} atomic_t;

-#ifdef CONFIG_64BIT
typedef struct {
- long counter;
+ s64 counter;
} atomic64_t;
-#endif

struct list_head {
struct list_head *next, *prev;