1 #ifndef _ASM_GENERIC_FUTEX_H
2 #define _ASM_GENERIC_FUTEX_H
4 #include <linux/futex.h>
5 #include <linux/uaccess.h>
10 * The following implementation only for uniprocessor machines.
11 * It relies on preempt_disable() ensuring mutual exclusion.
16 * futex_atomic_op_inuser() - Atomic arithmetic operation with constant
17 * argument and comparison of the previous
18 * futex value with another constant.
20 * @encoded_op: encoded operation to execute
21 * @uaddr: pointer to user space address
28 futex_atomic_op_inuser(int encoded_op
, u32 __user
*uaddr
)
30 int op
= (encoded_op
>> 28) & 7;
31 int cmp
= (encoded_op
>> 24) & 15;
32 int oparg
= (encoded_op
<< 8) >> 20;
33 int cmparg
= (encoded_op
<< 20) >> 20;
37 if (encoded_op
& (FUTEX_OP_OPARG_SHIFT
<< 28))
44 if (unlikely(get_user(oldval
, uaddr
) != 0))
45 goto out_pagefault_enable
;
70 if (ret
== 0 && unlikely(put_user(tmp
, uaddr
) != 0))
79 case FUTEX_OP_CMP_EQ
: ret
= (oldval
== cmparg
); break;
80 case FUTEX_OP_CMP_NE
: ret
= (oldval
!= cmparg
); break;
81 case FUTEX_OP_CMP_LT
: ret
= (oldval
< cmparg
); break;
82 case FUTEX_OP_CMP_GE
: ret
= (oldval
>= cmparg
); break;
83 case FUTEX_OP_CMP_LE
: ret
= (oldval
<= cmparg
); break;
84 case FUTEX_OP_CMP_GT
: ret
= (oldval
> cmparg
); break;
85 default: ret
= -ENOSYS
;
92 * futex_atomic_cmpxchg_inatomic() - Compare and exchange the content of the
93 * uaddr with newval if the current value is
95 * @uval: pointer to store content of @uaddr
96 * @uaddr: pointer to user space address
98 * @newval: new value to store to @uaddr
105 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
106 u32 oldval
, u32 newval
)
111 if (unlikely(get_user(val
, uaddr
) != 0))
114 if (val
== oldval
&& unlikely(put_user(newval
, uaddr
) != 0))
125 futex_atomic_op_inuser (int encoded_op
, u32 __user
*uaddr
)
127 int op
= (encoded_op
>> 28) & 7;
128 int cmp
= (encoded_op
>> 24) & 15;
129 int oparg
= (encoded_op
<< 8) >> 20;
130 int cmparg
= (encoded_op
<< 20) >> 20;
132 if (encoded_op
& (FUTEX_OP_OPARG_SHIFT
<< 28))
135 if (! access_ok (VERIFY_WRITE
, uaddr
, sizeof(u32
)))
154 case FUTEX_OP_CMP_EQ
: ret
= (oldval
== cmparg
); break;
155 case FUTEX_OP_CMP_NE
: ret
= (oldval
!= cmparg
); break;
156 case FUTEX_OP_CMP_LT
: ret
= (oldval
< cmparg
); break;
157 case FUTEX_OP_CMP_GE
: ret
= (oldval
>= cmparg
); break;
158 case FUTEX_OP_CMP_LE
: ret
= (oldval
<= cmparg
); break;
159 case FUTEX_OP_CMP_GT
: ret
= (oldval
> cmparg
); break;
160 default: ret
= -ENOSYS
;
167 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
168 u32 oldval
, u32 newval
)
173 #endif /* CONFIG_SMP */