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>
9 #ifndef futex_atomic_cmpxchg_inatomic
12 * The following implementation only for uniprocessor machines.
13 * It relies on preempt_disable() ensuring mutual exclusion.
16 #define futex_atomic_cmpxchg_inatomic(uval, uaddr, oldval, newval) \
17 futex_atomic_cmpxchg_inatomic_local(uval, uaddr, oldval, newval)
18 #define arch_futex_atomic_op_inuser(op, oparg, oval, uaddr) \
19 futex_atomic_op_inuser_local(op, oparg, oval, uaddr)
20 #endif /* CONFIG_SMP */
24 * futex_atomic_op_inuser_local() - Atomic arithmetic operation with constant
25 * argument and comparison of the previous
26 * futex value with another constant.
28 * @encoded_op: encoded operation to execute
29 * @uaddr: pointer to user space address
33 * -EFAULT - User access resulted in a page fault
34 * -EAGAIN - Atomic operation was unable to complete due to contention
35 * -ENOSYS - Operation not supported
38 futex_atomic_op_inuser_local(int op
, u32 oparg
, int *oval
, u32 __user
*uaddr
)
46 if (unlikely(get_user(oldval
, uaddr
) != 0))
47 goto out_pagefault_enable
;
72 if (ret
== 0 && unlikely(put_user(tmp
, uaddr
) != 0))
85 * futex_atomic_cmpxchg_inatomic_local() - Compare and exchange the content of the
86 * uaddr with newval if the current value is
88 * @uval: pointer to store content of @uaddr
89 * @uaddr: pointer to user space address
91 * @newval: new value to store to @uaddr
95 * -EFAULT - User access resulted in a page fault
96 * -EAGAIN - Atomic operation was unable to complete due to contention
99 futex_atomic_cmpxchg_inatomic_local(u32
*uval
, u32 __user
*uaddr
,
100 u32 oldval
, u32 newval
)
105 if (unlikely(get_user(val
, uaddr
) != 0)) {
110 if (val
== oldval
&& unlikely(put_user(newval
, uaddr
) != 0)) {