ARM: 7409/1: Do not call flush_cache_user_range with mmap_sem held
[linux/fpc-iii.git] / arch / sh / include / asm / futex-irq.h
blob6cb9f193a95ea5cc7c7b3471a92758206a394527
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, u32 __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, u32 __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, u32 __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, u32 __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, u32 __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(u32 *uval,
92 u32 __user *uaddr,
93 u32 oldval, u32 newval)
95 unsigned long flags;
96 int ret;
97 u32 prev = 0;
99 local_irq_save(flags);
101 ret = get_user(prev, uaddr);
102 if (!ret && oldval == prev)
103 ret = put_user(newval, uaddr);
105 local_irq_restore(flags);
107 *uval = prev;
108 return ret;
111 #endif /* __ASM_SH_FUTEX_IRQ_H */