1 #ifndef _ASM_ARM_FUTEX_H
2 #define _ASM_ARM_FUTEX_H
8 #include <asm-generic/futex.h>
10 #else /* !SMP, we can work around lack of atomic ops by disabling preemption */
12 #include <linux/futex.h>
13 #include <linux/preempt.h>
14 #include <linux/uaccess.h>
15 #include <asm/errno.h>
17 #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
18 __asm__ __volatile__( \
19 "1: ldrt %1, [%2]\n" \
21 "2: strt %0, [%2]\n" \
24 " .pushsection __ex_table,\"a\"\n" \
26 " .long 1b, 4f, 2b, 4f\n" \
28 " .pushsection .fixup,\"ax\"\n" \
32 : "=&r" (ret), "=&r" (oldval) \
33 : "r" (uaddr), "r" (oparg), "Ir" (-EFAULT) \
37 futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
39 int op = (encoded_op >> 28) & 7;
40 int cmp = (encoded_op >> 24) & 15;
41 int oparg = (encoded_op << 8) >> 20;
42 int cmparg = (encoded_op << 20) >> 20;
45 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
48 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
51 pagefault_disable(); /* implies preempt_disable() */
55 __futex_atomic_op("mov %0, %3", ret, oldval, uaddr, oparg);
58 __futex_atomic_op("add %0, %1, %3", ret, oldval, uaddr, oparg);
61 __futex_atomic_op("orr %0, %1, %3", ret, oldval, uaddr, oparg);
64 __futex_atomic_op("and %0, %1, %3", ret, oldval, uaddr, ~oparg);
67 __futex_atomic_op("eor %0, %1, %3", ret, oldval, uaddr, oparg);
73 pagefault_enable(); /* subsumes preempt_enable() */
77 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
78 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
79 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
80 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
81 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
82 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
83 default: ret = -ENOSYS;
90 futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
94 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
97 pagefault_disable(); /* implies preempt_disable() */
99 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
102 " it eq @ explicit IT needed for the 2b label\n"
103 "2: streqt %2, [%3]\n"
105 " .pushsection __ex_table,\"a\"\n"
107 " .long 1b, 4f, 2b, 4f\n"
109 " .pushsection .fixup,\"ax\"\n"
114 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
117 pagefault_enable(); /* subsumes preempt_enable() */
124 #endif /* __KERNEL__ */
125 #endif /* _ASM_ARM_FUTEX_H */