From 424706ad4e048c933773cfabf0244cb80bbc8e64 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Fri, 14 Feb 2003 20:38:11 -0800 Subject: [PATCH] compat_sys_futex 1/3 generic, parisc, ppc64, s390x and x86_64 This is the generic part of the patch and the architecture specific parts I have been asked to forward directly to you. --- kernel/compat.c | 17 +++++++++++++++++ kernel/futex.c | 37 +++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 20 deletions(-) (limited to 'kernel') 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 #include #include +#include /* for MAX_SCHEDULE_TIMEOUT */ #include @@ -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) -- cgit v1.2.3