1 #ifndef __ASM_SH_FUTEX_H
2 #define __ASM_SH_FUTEX_H
6 #include <linux/futex.h>
7 #include <linux/uaccess.h>
10 /* XXX: UP variants, fix for SH-4A and SMP.. */
11 #include <asm/futex-irq.h>
13 static inline int futex_atomic_op_inuser(int encoded_op
, u32 __user
*uaddr
)
15 int op
= (encoded_op
>> 28) & 7;
16 int cmp
= (encoded_op
>> 24) & 15;
17 int oparg
= (encoded_op
<< 8) >> 20;
18 int cmparg
= (encoded_op
<< 20) >> 20;
21 if (encoded_op
& (FUTEX_OP_OPARG_SHIFT
<< 28))
24 if (!access_ok(VERIFY_WRITE
, uaddr
, sizeof(u32
)))
31 ret
= atomic_futex_op_xchg_set(oparg
, uaddr
, &oldval
);
34 ret
= atomic_futex_op_xchg_add(oparg
, uaddr
, &oldval
);
37 ret
= atomic_futex_op_xchg_or(oparg
, uaddr
, &oldval
);
40 ret
= atomic_futex_op_xchg_and(~oparg
, uaddr
, &oldval
);
43 ret
= atomic_futex_op_xchg_xor(oparg
, uaddr
, &oldval
);
54 case FUTEX_OP_CMP_EQ
: ret
= (oldval
== cmparg
); break;
55 case FUTEX_OP_CMP_NE
: ret
= (oldval
!= cmparg
); break;
56 case FUTEX_OP_CMP_LT
: ret
= (oldval
< cmparg
); break;
57 case FUTEX_OP_CMP_GE
: ret
= (oldval
>= cmparg
); break;
58 case FUTEX_OP_CMP_LE
: ret
= (oldval
<= cmparg
); break;
59 case FUTEX_OP_CMP_GT
: ret
= (oldval
> cmparg
); break;
60 default: ret
= -ENOSYS
;
68 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
69 u32 oldval
, u32 newval
)
71 if (!access_ok(VERIFY_WRITE
, uaddr
, sizeof(u32
)))
74 return atomic_futex_op_cmpxchg_inatomic(uval
, uaddr
, oldval
, newval
);
77 #endif /* __KERNEL__ */
78 #endif /* __ASM_SH_FUTEX_H */