xref: /openbmc/linux/arch/ia64/include/asm/cmpxchg.h (revision 3ddc8b84)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_IA64_CMPXCHG_H
3 #define _ASM_IA64_CMPXCHG_H
4 
5 #include <uapi/asm/cmpxchg.h>
6 
7 #define arch_xchg(ptr, x)	\
8 ({(__typeof__(*(ptr))) __arch_xchg((unsigned long) (x), (ptr), sizeof(*(ptr)));})
9 
10 #define arch_cmpxchg(ptr, o, n)		cmpxchg_acq((ptr), (o), (n))
11 #define arch_cmpxchg64(ptr, o, n)	cmpxchg_acq((ptr), (o), (n))
12 
13 #define arch_cmpxchg_local		arch_cmpxchg
14 #define arch_cmpxchg64_local		arch_cmpxchg64
15 
16 #ifdef CONFIG_IA64_DEBUG_CMPXCHG
17 # define CMPXCHG_BUGCHECK_DECL	int _cmpxchg_bugcheck_count = 128;
18 # define CMPXCHG_BUGCHECK(v)						\
19 do {									\
20 	if (_cmpxchg_bugcheck_count-- <= 0) {				\
21 		void *ip;						\
22 		extern int _printk(const char *fmt, ...);		\
23 		ip = (void *) ia64_getreg(_IA64_REG_IP);		\
24 		_printk("CMPXCHG_BUGCHECK: stuck at %p on word %p\n", ip, (v));\
25 		break;							\
26 	}								\
27 } while (0)
28 #else /* !CONFIG_IA64_DEBUG_CMPXCHG */
29 # define CMPXCHG_BUGCHECK_DECL
30 # define CMPXCHG_BUGCHECK(v)
31 #endif /* !CONFIG_IA64_DEBUG_CMPXCHG */
32 
33 #endif /* _ASM_IA64_CMPXCHG_H */
34