Skip to content

Commit 5ba840f

Browse files
author
Paul Gortmaker
committed
alpha: fix build failures from system.h dismemberment
commit ec22120 "Disintegrate asm/system.h for Alpha" combined with commit b4816af "Move the asm-generic/system.h xchg() implementation to asm-generic/cmpxchg.h" introduced the concept of asm/cmpxchg.h but the alpha arch never got one. Fork the cmpxchg content out of the asm/atomic.h file to create one. Some minor whitespace fixups were done on the block of code that created the new file. Cc: Richard Henderson <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Matt Turner <[email protected]> Cc: David Howells <[email protected]> Acked-by: Matt Turner <[email protected]> Signed-off-by: Paul Gortmaker <[email protected]>
1 parent 0034102 commit 5ba840f

File tree

3 files changed

+74
-69
lines changed

3 files changed

+74
-69
lines changed

arch/alpha/include/asm/atomic.h

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <linux/types.h>
55
#include <asm/barrier.h>
6+
#include <asm/cmpxchg.h>
67

78
/*
89
* Atomic operations that C can't guarantee us. Useful for
@@ -168,73 +169,6 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
168169
return result;
169170
}
170171

171-
/*
172-
* Atomic exchange routines.
173-
*/
174-
175-
#define __ASM__MB
176-
#define ____xchg(type, args...) __xchg ## type ## _local(args)
177-
#define ____cmpxchg(type, args...) __cmpxchg ## type ## _local(args)
178-
#include <asm/xchg.h>
179-
180-
#define xchg_local(ptr,x) \
181-
({ \
182-
__typeof__(*(ptr)) _x_ = (x); \
183-
(__typeof__(*(ptr))) __xchg_local((ptr), (unsigned long)_x_, \
184-
sizeof(*(ptr))); \
185-
})
186-
187-
#define cmpxchg_local(ptr, o, n) \
188-
({ \
189-
__typeof__(*(ptr)) _o_ = (o); \
190-
__typeof__(*(ptr)) _n_ = (n); \
191-
(__typeof__(*(ptr))) __cmpxchg_local((ptr), (unsigned long)_o_, \
192-
(unsigned long)_n_, \
193-
sizeof(*(ptr))); \
194-
})
195-
196-
#define cmpxchg64_local(ptr, o, n) \
197-
({ \
198-
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
199-
cmpxchg_local((ptr), (o), (n)); \
200-
})
201-
202-
#ifdef CONFIG_SMP
203-
#undef __ASM__MB
204-
#define __ASM__MB "\tmb\n"
205-
#endif
206-
#undef ____xchg
207-
#undef ____cmpxchg
208-
#define ____xchg(type, args...) __xchg ##type(args)
209-
#define ____cmpxchg(type, args...) __cmpxchg ##type(args)
210-
#include <asm/xchg.h>
211-
212-
#define xchg(ptr,x) \
213-
({ \
214-
__typeof__(*(ptr)) _x_ = (x); \
215-
(__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, \
216-
sizeof(*(ptr))); \
217-
})
218-
219-
#define cmpxchg(ptr, o, n) \
220-
({ \
221-
__typeof__(*(ptr)) _o_ = (o); \
222-
__typeof__(*(ptr)) _n_ = (n); \
223-
(__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
224-
(unsigned long)_n_, sizeof(*(ptr)));\
225-
})
226-
227-
#define cmpxchg64(ptr, o, n) \
228-
({ \
229-
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
230-
cmpxchg((ptr), (o), (n)); \
231-
})
232-
233-
#undef __ASM__MB
234-
#undef ____cmpxchg
235-
236-
#define __HAVE_ARCH_CMPXCHG 1
237-
238172
#define atomic64_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), old, new))
239173
#define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
240174

arch/alpha/include/asm/cmpxchg.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#ifndef _ALPHA_CMPXCHG_H
2+
#define _ALPHA_CMPXCHG_H
3+
4+
/*
5+
* Atomic exchange routines.
6+
*/
7+
8+
#define __ASM__MB
9+
#define ____xchg(type, args...) __xchg ## type ## _local(args)
10+
#define ____cmpxchg(type, args...) __cmpxchg ## type ## _local(args)
11+
#include <asm/xchg.h>
12+
13+
#define xchg_local(ptr, x) \
14+
({ \
15+
__typeof__(*(ptr)) _x_ = (x); \
16+
(__typeof__(*(ptr))) __xchg_local((ptr), (unsigned long)_x_, \
17+
sizeof(*(ptr))); \
18+
})
19+
20+
#define cmpxchg_local(ptr, o, n) \
21+
({ \
22+
__typeof__(*(ptr)) _o_ = (o); \
23+
__typeof__(*(ptr)) _n_ = (n); \
24+
(__typeof__(*(ptr))) __cmpxchg_local((ptr), (unsigned long)_o_, \
25+
(unsigned long)_n_, \
26+
sizeof(*(ptr))); \
27+
})
28+
29+
#define cmpxchg64_local(ptr, o, n) \
30+
({ \
31+
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
32+
cmpxchg_local((ptr), (o), (n)); \
33+
})
34+
35+
#ifdef CONFIG_SMP
36+
#undef __ASM__MB
37+
#define __ASM__MB "\tmb\n"
38+
#endif
39+
#undef ____xchg
40+
#undef ____cmpxchg
41+
#define ____xchg(type, args...) __xchg ##type(args)
42+
#define ____cmpxchg(type, args...) __cmpxchg ##type(args)
43+
#include <asm/xchg.h>
44+
45+
#define xchg(ptr, x) \
46+
({ \
47+
__typeof__(*(ptr)) _x_ = (x); \
48+
(__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, \
49+
sizeof(*(ptr))); \
50+
})
51+
52+
#define cmpxchg(ptr, o, n) \
53+
({ \
54+
__typeof__(*(ptr)) _o_ = (o); \
55+
__typeof__(*(ptr)) _n_ = (n); \
56+
(__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
57+
(unsigned long)_n_, sizeof(*(ptr)));\
58+
})
59+
60+
#define cmpxchg64(ptr, o, n) \
61+
({ \
62+
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
63+
cmpxchg((ptr), (o), (n)); \
64+
})
65+
66+
#undef __ASM__MB
67+
#undef ____cmpxchg
68+
69+
#define __HAVE_ARCH_CMPXCHG 1
70+
71+
#endif /* _ALPHA_CMPXCHG_H */

arch/alpha/include/asm/xchg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#ifndef _ALPHA_ATOMIC_H
1+
#ifndef _ALPHA_CMPXCHG_H
22
#error Do not include xchg.h directly!
33
#else
44
/*
55
* xchg/xchg_local and cmpxchg/cmpxchg_local share the same code
66
* except that local version do not have the expensive memory barrier.
7-
* So this file is included twice from asm/system.h.
7+
* So this file is included twice from asm/cmpxchg.h.
88
*/
99

1010
/*

0 commit comments

Comments
 (0)