2 * Copyright (C) 2014 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
4 * This file is licensed under the terms of the GNU General Public License
5 * version 2. This program is licensed "as is" without any warranty of any
6 * kind, whether express or implied.
9 #ifndef __ASM_OPENRISC_CMPXCHG_H
10 #define __ASM_OPENRISC_CMPXCHG_H
12 #include <linux/types.h>
15 * This function doesn't exist, so you'll get a linker error
16 * if something tries to do an invalid cmpxchg().
18 extern void __cmpxchg_called_with_bad_pointer(void);
20 #define __HAVE_ARCH_CMPXCHG 1
22 static inline unsigned long
23 __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
26 __cmpxchg_called_with_bad_pointer();
31 "1: l.lwa %0, 0(%1) \n"
40 : "r"(ptr), "r"(old), "r"(new)
46 #define cmpxchg(ptr, o, n) \
48 (__typeof__(*(ptr))) __cmpxchg((ptr), \
55 * This function doesn't exist, so you'll get a linker error if
56 * something tries to do an invalidly-sized xchg().
58 extern void __xchg_called_with_bad_pointer(void);
60 static inline unsigned long __xchg(unsigned long val, volatile void *ptr,
64 __xchg_called_with_bad_pointer();
69 "1: l.lwa %0, 0(%1) \n"
80 #define xchg(ptr, with) \
82 (__typeof__(*(ptr))) __xchg((unsigned long)(with), \
87 #endif /* __ASM_OPENRISC_CMPXCHG_H */