1 #ifndef _ASM_HEXAGON_FUTEX_H
2 #define _ASM_HEXAGON_FUTEX_H
6 #include <linux/futex.h>
7 #include <linux/uaccess.h>
10 /* XXX TODO-- need to add sync barriers! */
12 #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
14 "1: %0 = memw_locked(%3);\n" \
15 /* For example: %1 = %4 */ \
17 "2: memw_locked(%3,p2) = %1;\n" \
18 " if !p2 jump 1b;\n" \
21 ".section .fixup,\"ax\"\n" \
25 ".section __ex_table,\"a\"\n" \
26 ".long 1b,4b,2b,4b\n" \
28 : "=&r" (oldval), "=&r" (ret), "+m" (*uaddr) \
29 : "r" (uaddr), "r" (oparg), "i" (-EFAULT) \
34 futex_atomic_op_inuser(int encoded_op
, int __user
*uaddr
)
36 int op
= (encoded_op
>> 28) & 7;
37 int cmp
= (encoded_op
>> 24) & 15;
38 int oparg
= (encoded_op
<< 8) >> 20;
39 int cmparg
= (encoded_op
<< 20) >> 20;
41 if (encoded_op
& (FUTEX_OP_OPARG_SHIFT
<< 28))
44 if (!access_ok(VERIFY_WRITE
, uaddr
, sizeof(int)))
51 __futex_atomic_op("%1 = %4\n", ret
, oldval
, uaddr
, oparg
);
54 __futex_atomic_op("%1 = add(%0,%4)\n", ret
, oldval
, uaddr
,
58 __futex_atomic_op("%1 = or(%0,%4)\n", ret
, oldval
, uaddr
,
62 __futex_atomic_op("%1 = not(%4); %1 = and(%0,%1)\n", ret
,
63 oldval
, uaddr
, oparg
);
66 __futex_atomic_op("%1 = xor(%0,%4)\n", ret
, oldval
, uaddr
,
78 ret
= (oldval
== cmparg
);
81 ret
= (oldval
!= cmparg
);
84 ret
= (oldval
< cmparg
);
87 ret
= (oldval
>= cmparg
);
90 ret
= (oldval
<= cmparg
);
93 ret
= (oldval
> cmparg
);
103 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
, u32 oldval
,
109 if (!access_ok(VERIFY_WRITE
, uaddr
, sizeof(u32
)))
112 __asm__
__volatile__ (
113 "1: %1 = memw_locked(%3)\n"
115 " p2 = cmp.eq(%1,%4)\n"
116 " if !p2.new jump:NT 3f\n"
118 "2: memw_locked(%3,p2) = %5\n"
121 ".section .fixup,\"ax\"\n"
125 ".section __ex_table,\"a\"\n"
126 ".long 1b,4b,2b,4b\n"
128 : "+r" (ret
), "=&r" (prev
), "+m" (*uaddr
)
129 : "r" (uaddr
), "r" (oldval
), "r" (newval
), "i"(-EFAULT
)
136 #endif /* __KERNEL__ */
137 #endif /* _ASM_HEXAGON_FUTEX_H */