Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
[linux/fpc-iii.git] / arch / sh / include / asm / futex-irq.h
blob63d33129ea2348c9228d42987b7e8dab77887745
1 #ifndef __ASM_SH_FUTEX_IRQ_H
2 #define __ASM_SH_FUTEX_IRQ_H
5 static inline int atomic_futex_op_xchg_set(int oparg, u32 __user *uaddr,
6 int *oldval)
8 unsigned long flags;
9 int ret;
11 local_irq_save(flags);
13 ret = get_user(*oldval, uaddr);
14 if (!ret)
15 ret = put_user(oparg, uaddr);
17 local_irq_restore(flags);
19 return ret;
22 static inline int atomic_futex_op_xchg_add(int oparg, u32 __user *uaddr,
23 int *oldval)
25 unsigned long flags;
26 int ret;
28 local_irq_save(flags);
30 ret = get_user(*oldval, uaddr);
31 if (!ret)
32 ret = put_user(*oldval + oparg, uaddr);
34 local_irq_restore(flags);
36 return ret;
39 static inline int atomic_futex_op_xchg_or(int oparg, u32 __user *uaddr,
40 int *oldval)
42 unsigned long flags;
43 int ret;
45 local_irq_save(flags);
47 ret = get_user(*oldval, uaddr);
48 if (!ret)
49 ret = put_user(*oldval | oparg, uaddr);
51 local_irq_restore(flags);
53 return ret;
56 static inline int atomic_futex_op_xchg_and(int oparg, u32 __user *uaddr,
57 int *oldval)
59 unsigned long flags;
60 int ret;
62 local_irq_save(flags);
64 ret = get_user(*oldval, uaddr);
65 if (!ret)
66 ret = put_user(*oldval & oparg, uaddr);
68 local_irq_restore(flags);
70 return ret;
73 static inline int atomic_futex_op_xchg_xor(int oparg, u32 __user *uaddr,
74 int *oldval)
76 unsigned long flags;
77 int ret;
79 local_irq_save(flags);
81 ret = get_user(*oldval, uaddr);
82 if (!ret)
83 ret = put_user(*oldval ^ oparg, uaddr);
85 local_irq_restore(flags);
87 return ret;
90 static inline int atomic_futex_op_cmpxchg_inatomic(u32 *uval,
91 u32 __user *uaddr,
92 u32 oldval, u32 newval)
94 unsigned long flags;
95 int ret;
96 u32 prev = 0;
98 local_irq_save(flags);
100 ret = get_user(prev, uaddr);
101 if (!ret && oldval == prev)
102 ret = put_user(newval, uaddr);
104 local_irq_restore(flags);
106 *uval = prev;
107 return ret;
110 #endif /* __ASM_SH_FUTEX_IRQ_H */