diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/compat.c | 17 | ||||
| -rw-r--r-- | kernel/futex.c | 37 |
2 files changed, 34 insertions, 20 deletions
diff --git a/kernel/compat.c b/kernel/compat.c index 0c51a4de67a8..892b49f14f5f 100644 --- a/kernel/compat.c +++ b/kernel/compat.c @@ -16,6 +16,7 @@ #include <linux/errno.h> #include <linux/time.h> #include <linux/signal.h> +#include <linux/sched.h> /* for MAX_SCHEDULE_TIMEOUT */ #include <asm/uaccess.h> @@ -208,3 +209,19 @@ asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t *set, ret = put_user(s, oset); return ret; } + +extern long do_futex(u32 *, int, int, unsigned long); + +asmlinkage long compat_sys_futex(u32 *uaddr, int op, int val, + struct compat_timespec *utime) +{ + struct timespec t; + unsigned long timeout = MAX_SCHEDULE_TIMEOUT; + + if ((op == FUTEX_WAIT) && utime) { + if (get_compat_timespec(&t, utime)) + return -EFAULT; + timeout = timespec_to_jiffies(t) + 1; + } + return do_futex((unsigned long)uaddr, op, val, timeout); +} diff --git a/kernel/futex.c b/kernel/futex.c index 16775292bdc4..9813932a6a0a 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -315,23 +315,6 @@ out: return ret; } -static inline int futex_wait_utime(unsigned long uaddr, - int offset, - int val, - struct timespec* utime) -{ - unsigned long time = MAX_SCHEDULE_TIMEOUT; - - if (utime) { - struct timespec t; - if (copy_from_user(&t, utime, sizeof(t)) != 0) - return -EFAULT; - time = timespec_to_jiffies(&t) + 1; - } - - return futex_wait(uaddr, offset, val, time); -} - static int futex_close(struct inode *inode, struct file *filp) { struct futex_q *q = filp->private_data; @@ -437,7 +420,7 @@ out: return ret; } -asmlinkage int sys_futex(unsigned long uaddr, int op, int val, struct timespec *utime) +long do_futex(unsigned long uaddr, int op, int val, unsinged long timeout) { unsigned long pos_in_page; int ret; @@ -445,12 +428,12 @@ asmlinkage int sys_futex(unsigned long uaddr, int op, int val, struct timespec * pos_in_page = uaddr % PAGE_SIZE; /* Must be "naturally" aligned */ - if (pos_in_page % sizeof(int)) + if (pos_in_page % sizeof(u32)) return -EINVAL; switch (op) { case FUTEX_WAIT: - ret = futex_wait_utime(uaddr, pos_in_page, val, utime); + ret = futex_wait(uaddr, pos_in_page, val, timeout); break; case FUTEX_WAKE: ret = futex_wake(uaddr, pos_in_page, val); @@ -465,6 +448,20 @@ asmlinkage int sys_futex(unsigned long uaddr, int op, int val, struct timespec * return ret; } +asmlinkage long sys_futex(u32 *uaddr, int op, int val, struct timespec *utime) +{ + struct timespec t; + unsigned long timeout = MAX_SCHEDULE_TIMEOUT; + + + if ((op == FUTEX_WAIT) && utime) { + if (copy_from_user(&t, utime, sizeof(t)) != 0) + return -EFAULT; + timeout = timespec_to_jiffies(t) + 1; + } + return do_futex((unsigned long)uaddr, op, val, timeout); +} + static struct super_block * futexfs_get_sb(struct file_system_type *fs_type, int flags, char *dev_name, void *data) |
