1 #ifndef _ASM_ALPHA_FUTEX_H
2 #define _ASM_ALPHA_FUTEX_H
6 #include <linux/futex.h>
7 #include <linux/uaccess.h>
9 #include <asm/barrier.h>
11 #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
12 __asm__ __volatile__( \
14 "1: ldl_l %0,0(%2)\n" \
16 "2: stl_c %1,0(%2)\n" \
19 "3: .subsection 2\n" \
22 " .section __ex_table,\"a\"\n" \
24 " lda $31,3b-1b(%1)\n" \
26 " lda $31,3b-2b(%1)\n" \
28 : "=&r" (oldval), "=&r"(ret) \
29 : "r" (uaddr), "r"(oparg) \
32 static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
34 int op = (encoded_op >> 28) & 7;
35 int cmp = (encoded_op >> 24) & 15;
36 int oparg = (encoded_op << 8) >> 20;
37 int cmparg = (encoded_op << 20) >> 20;
39 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
42 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
49 __futex_atomic_op("mov %3,%1\n", ret, oldval, uaddr, oparg);
52 __futex_atomic_op("addl %0,%3,%1\n", ret, oldval, uaddr, oparg);
55 __futex_atomic_op("or %0,%3,%1\n", ret, oldval, uaddr, oparg);
58 __futex_atomic_op("andnot %0,%3,%1\n", ret, oldval, uaddr, oparg);
61 __futex_atomic_op("xor %0,%3,%1\n", ret, oldval, uaddr, oparg);
71 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
72 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
73 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
74 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
75 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
76 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
77 default: ret = -ENOSYS;
84 futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
88 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
91 __asm__ __volatile__ (
102 " .section __ex_table,\"a\"\n"
104 " lda $31,3b-1b(%0)\n"
106 " lda $31,3b-2b(%0)\n"
108 : "=&r"(prev), "=&r"(cmp)
109 : "r"(uaddr), "r"((long)oldval), "r"(newval)
115 #endif /* __KERNEL__ */
116 #endif /* _ASM_ALPHA_FUTEX_H */