fs/reiserfs/journal.c: change return type of dirty_one_transaction
[linux/fpc-iii.git] / arch / sh / include / asm / futex.h
blob3190ec89df81c3b41597fc7fbec032d2b5de7ba8
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_SH_FUTEX_H
3 #define __ASM_SH_FUTEX_H
5 #ifdef __KERNEL__
7 #include <linux/futex.h>
8 #include <linux/uaccess.h>
9 #include <asm/errno.h>
11 #if !defined(CONFIG_SMP)
12 #include <asm/futex-irq.h>
13 #elif defined(CONFIG_CPU_J2)
14 #include <asm/futex-cas.h>
15 #elif defined(CONFIG_CPU_SH4A)
16 #include <asm/futex-llsc.h>
17 #else
18 #error SMP not supported on this configuration.
19 #endif
21 static inline int
22 futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
23 u32 oldval, u32 newval)
25 if (!access_ok(uaddr, sizeof(u32)))
26 return -EFAULT;
28 return atomic_futex_op_cmpxchg_inatomic(uval, uaddr, oldval, newval);
31 static inline int arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval,
32 u32 __user *uaddr)
34 u32 oldval, newval, prev;
35 int ret;
37 pagefault_disable();
39 do {
40 ret = get_user(oldval, uaddr);
42 if (ret) break;
44 switch (op) {
45 case FUTEX_OP_SET:
46 newval = oparg;
47 break;
48 case FUTEX_OP_ADD:
49 newval = oldval + oparg;
50 break;
51 case FUTEX_OP_OR:
52 newval = oldval | oparg;
53 break;
54 case FUTEX_OP_ANDN:
55 newval = oldval & ~oparg;
56 break;
57 case FUTEX_OP_XOR:
58 newval = oldval ^ oparg;
59 break;
60 default:
61 ret = -ENOSYS;
62 break;
65 if (ret) break;
67 ret = futex_atomic_cmpxchg_inatomic(&prev, uaddr, oldval, newval);
68 } while (!ret && prev != oldval);
70 pagefault_enable();
72 if (!ret)
73 *oval = oldval;
75 return ret;
78 #endif /* __KERNEL__ */
79 #endif /* __ASM_SH_FUTEX_H */