diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-01 13:53:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-01 13:53:43 -0400 |
commit | 00e9028a95fb8a4d79f2fb695a853f33ea7d3b57 (patch) | |
tree | 2dea2ae498a6ce57de8890e87185aca5e9f3ad2d /arch/sh/include/asm/futex.h | |
parent | 57b1494d2ba544c62673234da6115c21fac27ffc (diff) | |
parent | 7cb93181629c613ee2b8f4ffe3446f8003074842 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6: (28 commits)
mm/hugetlb.c must #include <asm/io.h>
video: Fix up hp6xx driver build regressions.
sh: defconfig updates.
sh: Kill off stray mach-rsk7203 reference.
serial: sh-sci: Fix up SH7760/SH7780/SH7785 early printk regression.
sh: Move out individual boards without mach groups.
sh: Make sure AT_SYSINFO_EHDR is exposed to userspace in asm/auxvec.h.
sh: Allow SH-3 and SH-5 to use common headers.
sh: Provide common CPU headers, prune the SH-2 and SH-2A directories.
sh/maple: clean maple bus code
sh: More header path fixups for mach dir refactoring.
sh: Move out the solution engine headers to arch/sh/include/mach-se/
sh: I2C fix for AP325RXA and Migo-R
sh: Shuffle the board directories in to mach groups.
sh: dma-sh: Fix up dreamcast dma.h mach path.
sh: Switch KBUILD_DEFCONFIG to shx3_defconfig.
sh: Add ARCH_DEFCONFIG entries for sh and sh64.
sh: Fix compile error of Solution Engine
sh: Proper __put_user_asm() size mismatch fix.
sh: Stub in a dummy ENTRY_OFFSET for uImage offset calculation.
...
Diffstat (limited to 'arch/sh/include/asm/futex.h')
-rw-r--r-- | arch/sh/include/asm/futex.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/arch/sh/include/asm/futex.h b/arch/sh/include/asm/futex.h new file mode 100644 index 000000000000..68256ec5fa35 --- /dev/null +++ b/arch/sh/include/asm/futex.h | |||
@@ -0,0 +1,77 @@ | |||
1 | #ifndef __ASM_SH_FUTEX_H | ||
2 | #define __ASM_SH_FUTEX_H | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | #include <linux/futex.h> | ||
7 | #include <linux/uaccess.h> | ||
8 | #include <asm/errno.h> | ||
9 | |||
10 | /* XXX: UP variants, fix for SH-4A and SMP.. */ | ||
11 | #include <asm/futex-irq.h> | ||
12 | |||
13 | static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | ||
14 | { | ||
15 | int op = (encoded_op >> 28) & 7; | ||
16 | int cmp = (encoded_op >> 24) & 15; | ||
17 | int oparg = (encoded_op << 8) >> 20; | ||
18 | int cmparg = (encoded_op << 20) >> 20; | ||
19 | int oldval = 0, ret; | ||
20 | |||
21 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | ||
22 | oparg = 1 << oparg; | ||
23 | |||
24 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | ||
25 | return -EFAULT; | ||
26 | |||
27 | pagefault_disable(); | ||
28 | |||
29 | switch (op) { | ||
30 | case FUTEX_OP_SET: | ||
31 | ret = atomic_futex_op_xchg_set(oparg, uaddr, &oldval); | ||
32 | break; | ||
33 | case FUTEX_OP_ADD: | ||
34 | ret = atomic_futex_op_xchg_add(oparg, uaddr, &oldval); | ||
35 | break; | ||
36 | case FUTEX_OP_OR: | ||
37 | ret = atomic_futex_op_xchg_or(oparg, uaddr, &oldval); | ||
38 | break; | ||
39 | case FUTEX_OP_ANDN: | ||
40 | ret = atomic_futex_op_xchg_and(~oparg, uaddr, &oldval); | ||
41 | break; | ||
42 | case FUTEX_OP_XOR: | ||
43 | ret = atomic_futex_op_xchg_xor(oparg, uaddr, &oldval); | ||
44 | break; | ||
45 | default: | ||
46 | ret = -ENOSYS; | ||
47 | break; | ||
48 | } | ||
49 | |||
50 | pagefault_enable(); | ||
51 | |||
52 | if (!ret) { | ||
53 | switch (cmp) { | ||
54 | case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break; | ||
55 | case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break; | ||
56 | case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break; | ||
57 | case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break; | ||
58 | case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break; | ||
59 | case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break; | ||
60 | default: ret = -ENOSYS; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | return ret; | ||
65 | } | ||
66 | |||
67 | static inline int | ||
68 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | ||
69 | { | ||
70 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | ||
71 | return -EFAULT; | ||
72 | |||
73 | return atomic_futex_op_cmpxchg_inatomic(uaddr, oldval, newval); | ||
74 | } | ||
75 | |||
76 | #endif /* __KERNEL__ */ | ||
77 | #endif /* __ASM_SH_FUTEX_H */ | ||