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