Merge tag 'locking-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / sh / include / asm / futex-cas.h
blobed738e32b5ec45d23a5713af7a2e4c9933b0b01b
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_SH_FUTEX_CAS_H
3 #define __ASM_SH_FUTEX_CAS_H
5 static inline int atomic_futex_op_cmpxchg_inatomic(u32 *uval,
6 u32 __user *uaddr,
7 u32 oldval, u32 newval)
9 int err = 0;
10 __asm__ __volatile__(
11 "1:\n\t"
12 "cas.l %2, %1, @r0\n"
13 "2:\n\t"
14 #ifdef CONFIG_MMU
15 ".section .fixup,\"ax\"\n"
16 "3:\n\t"
17 "mov.l 4f, %0\n\t"
18 "jmp @%0\n\t"
19 " mov %3, %0\n\t"
20 ".balign 4\n"
21 "4: .long 2b\n\t"
22 ".previous\n"
23 ".section __ex_table,\"a\"\n\t"
24 ".long 1b, 3b\n\t"
25 ".previous"
26 #endif
27 :"+r" (err), "+r" (newval)
28 :"r" (oldval), "i" (-EFAULT), "z" (uaddr)
29 :"t", "memory");
30 if (err) return err;
31 *uval = newval;
32 return 0;
35 #endif /* __ASM_SH_FUTEX_CAS_H */