License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-2.6/btrfs-unstable.git] / arch / alpha / include / asm / cmpxchg.h
blob46ebf14aed4e55348b1b96aa82516348e00171c3
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ALPHA_CMPXCHG_H
3 #define _ALPHA_CMPXCHG_H
5 /*
6 * Atomic exchange routines.
7 */
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>
14 #define xchg_local(ptr, x) \
15 ({ \
16 __typeof__(*(ptr)) _x_ = (x); \
17 (__typeof__(*(ptr))) __xchg_local((ptr), (unsigned long)_x_, \
18 sizeof(*(ptr))); \
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))); \
30 #define cmpxchg64_local(ptr, o, n) \
31 ({ \
32 BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
33 cmpxchg_local((ptr), (o), (n)); \
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>
46 #define xchg(ptr, x) \
47 ({ \
48 __typeof__(*(ptr)) _x_ = (x); \
49 (__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, \
50 sizeof(*(ptr))); \
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)));\
61 #define cmpxchg64(ptr, o, n) \
62 ({ \
63 BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
64 cmpxchg((ptr), (o), (n)); \
67 #undef __ASM__MB
68 #undef ____cmpxchg
70 #endif /* _ALPHA_CMPXCHG_H */