1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __ASM_SH_FUTEX_CAS_H 3 #define __ASM_SH_FUTEX_CAS_H 4 5 static inline int atomic_futex_op_cmpxchg_inatomic(u32 *uval, 6 u32 __user *uaddr, 7 u32 oldval, u32 newval) 8 { 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; 33 } 34 35 #endif /* __ASM_SH_FUTEX_CAS_H */ 36