Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block
[wrt350n-kernel.git] / include / asm-sh / futex-irq.h
bloba9f16a7f9aeaf5bf1a1482c8e38355b1c35c6f2d
1 #ifndef __ASM_SH_FUTEX_IRQ_H
2 #define __ASM_SH_FUTEX_IRQ_H
4 #include <asm/system.h>
6 static inline int atomic_futex_op_xchg_set(int oparg, int __user *uaddr,
7 int *oldval)
9 unsigned long flags;
10 int ret;
12 local_irq_save(flags);
14 ret = get_user(*oldval, uaddr);
15 if (!ret)
16 ret = put_user(oparg, uaddr);
18 local_irq_restore(flags);
20 return ret;
23 static inline int atomic_futex_op_xchg_add(int oparg, int __user *uaddr,
24 int *oldval)
26 unsigned long flags;
27 int ret;
29 local_irq_save(flags);
31 ret = get_user(*oldval, uaddr);
32 if (!ret)
33 ret = put_user(*oldval + oparg, uaddr);
35 local_irq_restore(flags);
37 return ret;
40 static inline int atomic_futex_op_xchg_or(int oparg, int __user *uaddr,
41 int *oldval)
43 unsigned long flags;
44 int ret;
46 local_irq_save(flags);
48 ret = get_user(*oldval, uaddr);
49 if (!ret)
50 ret = put_user(*oldval | oparg, uaddr);
52 local_irq_restore(flags);
54 return ret;
57 static inline int atomic_futex_op_xchg_and(int oparg, int __user *uaddr,
58 int *oldval)
60 unsigned long flags;
61 int ret;
63 local_irq_save(flags);
65 ret = get_user(*oldval, uaddr);
66 if (!ret)
67 ret = put_user(*oldval & oparg, uaddr);
69 local_irq_restore(flags);
71 return ret;
74 static inline int atomic_futex_op_xchg_xor(int oparg, int __user *uaddr,
75 int *oldval)
77 unsigned long flags;
78 int ret;
80 local_irq_save(flags);
82 ret = get_user(*oldval, uaddr);
83 if (!ret)
84 ret = put_user(*oldval ^ oparg, uaddr);
86 local_irq_restore(flags);
88 return ret;
91 static inline int atomic_futex_op_cmpxchg_inatomic(int __user *uaddr,
92 int oldval, int newval)
94 unsigned long flags;
95 int ret, prev = 0;
97 local_irq_save(flags);
99 ret = get_user(prev, uaddr);
100 if (!ret && oldval == prev)
101 ret = put_user(newval, uaddr);
103 local_irq_restore(flags);
105 if (ret)
106 return ret;
108 return prev;
111 #endif /* __ASM_SH_FUTEX_IRQ_H */