6 #include <linux/futex.h>
9 #include <asm/uaccess.h>
11 #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
12 __asm__ __volatile (SYNC_ON_SMP \
13 "1: lwarx %0,0,%2\n" \
18 3: .section .fixup,\"ax\"\n\
22 .section __ex_table,\"a\"\n\
26 : "=&r" (oldval), "=&r" (ret) \
27 : "b" (uaddr), "i" (-EFAULT), "1" (oparg) \
31 futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
33 int op = (encoded_op >> 28) & 7;
34 int cmp = (encoded_op >> 24) & 15;
35 int oparg = (encoded_op << 8) >> 20;
36 int cmparg = (encoded_op << 20) >> 20;
38 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
41 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
48 __futex_atomic_op("", ret, oldval, uaddr, oparg);
51 __futex_atomic_op("add %1,%0,%1\n", ret, oldval, uaddr, oparg);
54 __futex_atomic_op("or %1,%0,%1\n", ret, oldval, uaddr, oparg);
57 __futex_atomic_op("andc %1,%0,%1\n", ret, oldval, uaddr, oparg);
60 __futex_atomic_op("xor %1,%0,%1\n", ret, oldval, uaddr, oparg);
70 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
71 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
72 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
73 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
74 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
75 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
76 default: ret = -ENOSYS;