xref: /linux/arch/sh/include/asm/futex-irq.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2f15cbe6fSPaul Mundt #ifndef __ASM_SH_FUTEX_IRQ_H
3f15cbe6fSPaul Mundt #define __ASM_SH_FUTEX_IRQ_H
4f15cbe6fSPaul Mundt 
atomic_futex_op_cmpxchg_inatomic(u32 * uval,u32 __user * uaddr,u32 oldval,u32 newval)58d7718aaSMichel Lespinasse static inline int atomic_futex_op_cmpxchg_inatomic(u32 *uval,
68d7718aaSMichel Lespinasse 						   u32 __user *uaddr,
78d7718aaSMichel Lespinasse 						   u32 oldval, u32 newval)
8f15cbe6fSPaul Mundt {
9f15cbe6fSPaul Mundt 	unsigned long flags;
108d7718aaSMichel Lespinasse 	int ret;
118d7718aaSMichel Lespinasse 	u32 prev = 0;
12f15cbe6fSPaul Mundt 
13f15cbe6fSPaul Mundt 	local_irq_save(flags);
14f15cbe6fSPaul Mundt 
15f15cbe6fSPaul Mundt 	ret = get_user(prev, uaddr);
16f15cbe6fSPaul Mundt 	if (!ret && oldval == prev)
17f15cbe6fSPaul Mundt 		ret = put_user(newval, uaddr);
18f15cbe6fSPaul Mundt 
19f15cbe6fSPaul Mundt 	local_irq_restore(flags);
20f15cbe6fSPaul Mundt 
2137a9d912SMichel Lespinasse 	*uval = prev;
22f15cbe6fSPaul Mundt 	return ret;
23f15cbe6fSPaul Mundt }
24f15cbe6fSPaul Mundt 
25f15cbe6fSPaul Mundt #endif /* __ASM_SH_FUTEX_IRQ_H */
26