6 #include <linux/futex.h>
8 #include <asm/system.h>
9 #include <asm/uaccess.h>
11 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
12 __asm__ __volatile ( \
14 "2: .section .fixup,\"ax\"\n\
18 .section __ex_table,\"a\"\n\
22 : "=r" (oldval), "=r" (ret), "=m" (*uaddr) \
23 : "i" (-EFAULT), "m" (*uaddr), "0" (oparg), "1" (0))
25 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
26 __asm__ __volatile ( \
30 "2: " LOCK_PREFIX "cmpxchgl %3, %2\n\
32 3: .section .fixup,\"ax\"\n\
36 .section __ex_table,\"a\"\n\
40 : "=&a" (oldval), "=&r" (ret), "=m" (*uaddr), \
42 : "r" (oparg), "i" (-EFAULT), "m" (*uaddr), "1" (0))
45 futex_atomic_op_inuser (int encoded_op
, int __user
*uaddr
)
47 int op
= (encoded_op
>> 28) & 7;
48 int cmp
= (encoded_op
>> 24) & 15;
49 int oparg
= (encoded_op
<< 8) >> 20;
50 int cmparg
= (encoded_op
<< 20) >> 20;
51 int oldval
= 0, ret
, tem
;
52 if (encoded_op
& (FUTEX_OP_OPARG_SHIFT
<< 28))
55 if (! access_ok (VERIFY_WRITE
, uaddr
, sizeof(int)))
62 __futex_atomic_op1("xchgl %0, %2", ret
, oldval
, uaddr
, oparg
);
65 __futex_atomic_op1(LOCK_PREFIX
"xaddl %0, %2", ret
, oldval
,
69 __futex_atomic_op2("orl %4, %3", ret
, oldval
, uaddr
, oparg
);
72 __futex_atomic_op2("andl %4, %3", ret
, oldval
, uaddr
, ~oparg
);
75 __futex_atomic_op2("xorl %4, %3", ret
, oldval
, uaddr
, oparg
);
85 case FUTEX_OP_CMP_EQ
: ret
= (oldval
== cmparg
); break;
86 case FUTEX_OP_CMP_NE
: ret
= (oldval
!= cmparg
); break;
87 case FUTEX_OP_CMP_LT
: ret
= (oldval
< cmparg
); break;
88 case FUTEX_OP_CMP_GE
: ret
= (oldval
>= cmparg
); break;
89 case FUTEX_OP_CMP_LE
: ret
= (oldval
<= cmparg
); break;
90 case FUTEX_OP_CMP_GT
: ret
= (oldval
> cmparg
); break;
91 default: ret
= -ENOSYS
;
98 futex_atomic_cmpxchg_inatomic(int __user
*uaddr
, int oldval
, int newval
)
100 if (!access_ok(VERIFY_WRITE
, uaddr
, sizeof(int)))
103 __asm__
__volatile__(
104 "1: " LOCK_PREFIX
"cmpxchgl %3, %1 \n"
106 "2: .section .fixup, \"ax\" \n"
111 " .section __ex_table, \"a\" \n"
116 : "=a" (oldval
), "=m" (*uaddr
)
117 : "i" (-EFAULT
), "r" (newval
), "0" (oldval
)
This page took 0.032848 seconds and 5 git commands to generate.