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