1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_GENERIC_FUTEX_H
3 #define _ASM_GENERIC_FUTEX_H
5 #include <linux/futex.h>
6 #include <linux/uaccess.h>
11 * The following implementation only for uniprocessor machines.
12 * It relies on preempt_disable() ensuring mutual exclusion.
17 * arch_futex_atomic_op_inuser() - Atomic arithmetic operation with constant
18 * argument and comparison of the previous
19 * futex value with another constant.
21 * @encoded_op: encoded operation to execute
22 * @uaddr: pointer to user space address
26 * -EFAULT - User access resulted in a page fault
27 * -EAGAIN - Atomic operation was unable to complete due to contention
28 * -ENOSYS - Operation not supported
31 arch_futex_atomic_op_inuser(int op
, u32 oparg
, int *oval
, u32 __user
*uaddr
)
39 if (unlikely(get_user(oldval
, uaddr
) != 0))
40 goto out_pagefault_enable
;
65 if (ret
== 0 && unlikely(put_user(tmp
, uaddr
) != 0))
78 * futex_atomic_cmpxchg_inatomic() - Compare and exchange the content of the
79 * uaddr with newval if the current value is
81 * @uval: pointer to store content of @uaddr
82 * @uaddr: pointer to user space address
84 * @newval: new value to store to @uaddr
88 * -EFAULT - User access resulted in a page fault
89 * -EAGAIN - Atomic operation was unable to complete due to contention
90 * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
93 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
94 u32 oldval
, u32 newval
)
99 if (unlikely(get_user(val
, uaddr
) != 0)) {
104 if (val
== oldval
&& unlikely(put_user(newval
, uaddr
) != 0)) {
117 arch_futex_atomic_op_inuser(int op
, u32 oparg
, int *oval
, u32 __user
*uaddr
)
123 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
124 u32 oldval
, u32 newval
)
129 #endif /* CONFIG_SMP */