From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Linus <torvalds@transmeta.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
anton@samba.org, "David S. Miller" <davem@redhat.com>,
ak@muc.de, davidm@hpl.hp.com, schwidefsky@de.ibm.com,
ralf@gnu.org, matthew@wil.cx
Subject: [PATCH][COMPAT] compat_sys_futex 1/7 generic
Date: Wed, 12 Feb 2003 15:47:16 +1100 [thread overview]
Message-ID: <20030212154716.7c101942.sfr@canb.auug.org.au> (raw)
Hi Linus,
This patch creates compat_sys_futex and changes the 64 bit architextures
to use it. This also changes sys_futex to take a "u32 *" as its first
argument as discussed with Rusty and yourself.
This is just the generic part of the patch. The architecture specific
parts will follow.
There is no mip64 part as the mips port currently does not support
sys_futex.
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
diff -ruN 2.5.60-32bit.1/kernel/compat.c 2.5.60-32bit.2/kernel/compat.c
--- 2.5.60-32bit.1/kernel/compat.c 2003-01-17 14:01:08.000000000 +1100
+++ 2.5.60-32bit.2/kernel/compat.c 2003-02-11 12:21:56.000000000 +1100
@@ -208,3 +208,19 @@
ret = put_user(s, oset);
return ret;
}
+
+extern long do_futex(u32 *, int, int, struct timespec *);
+
+asmlinkage long compat_sys_futex(u32 *uaddr, int op, int val,
+ struct compat_timespec *ct)
+{
+ struct timespec *ts = NULL;
+ struct timespec t;
+
+ if ((op == FUTEX_WAIT) && ct) {
+ if (get_compat_timespec(&t, ct))
+ return -EFAULT;
+ ts = &t;
+ }
+ return do_futex((unsigned long)uaddr, op, val, ts);
+}
diff -ruN 2.5.60-32bit.1/kernel/futex.c 2.5.60-32bit.2/kernel/futex.c
--- 2.5.60-32bit.1/kernel/futex.c 2002-11-28 10:34:59.000000000 +1100
+++ 2.5.60-32bit.2/kernel/futex.c 2003-02-11 12:21:56.000000000 +1100
@@ -318,17 +318,12 @@
static inline int futex_wait_utime(unsigned long uaddr,
int offset,
int val,
- struct timespec* utime)
+ struct timespec* ts)
{
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;
- }
-
+ if (ts)
+ time = timespec_to_jiffies(ts) + 1;
return futex_wait(uaddr, offset, val, time);
}
@@ -437,7 +432,7 @@
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, struct timespec *ts)
{
unsigned long pos_in_page;
int ret;
@@ -445,12 +440,12 @@
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_utime(uaddr, pos_in_page, val, ts);
break;
case FUTEX_WAKE:
ret = futex_wake(uaddr, pos_in_page, val);
@@ -465,6 +460,19 @@
return ret;
}
+asmlinkage long sys_futex(u32 *uaddr, int op, int val, struct timespec *utime)
+{
+ struct timespec *ts = NULL;
+ struct timespec t;
+
+ if ((op == FUTEX_WAIT) && utime) {
+ if (copy_from_user(&t, utime, sizeof(t)) != 0)
+ return -EFAULT;
+ ts = &t;
+ }
+ return do_futex((unsigned long)uaddr, op, val, ts);
+}
+
static struct super_block *
futexfs_get_sb(struct file_system_type *fs_type,
int flags, char *dev_name, void *data)
next reply other threads:[~2003-02-12 4:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-12 4:47 Stephen Rothwell [this message]
2003-02-12 4:51 ` [PATCH][COMPAT] compat_sys_futex 2/7 ia64 Stephen Rothwell
2003-02-12 4:55 ` [PATCH][COMPAT] compat_sys_futex 3/7 parisc Stephen Rothwell
2003-02-12 4:57 ` [PATCH][COMPAT] compat_sys_futex 4/7 ppc64 Stephen Rothwell
2003-02-12 5:00 ` [PATCH][COMPAT] compat_sys_futex 5/7 s390x Stephen Rothwell
2003-02-12 5:06 ` [PATCH][COMPAT] compat_sys_futex 6/7 sparc64 Stephen Rothwell
2003-02-12 5:09 ` [PATCH][COMPAT] compat_sys_futex 7/7 x86_64 Stephen Rothwell
2003-02-13 3:28 ` Stephen Rothwell
2003-02-12 5:26 ` [PATCH][COMPAT] compat_sys_futex 1/7 generic Linus Torvalds
2003-02-12 6:28 ` Stephen Rothwell
2003-02-15 13:51 ` [PATCH][COMPAT] compat_sys_futex 1/3 generic, parisc, ppc64, s390x and x86_64 Stephen Rothwell
2003-02-15 13:55 ` [PATCH][COMPAT] compat_sys_futex 2/3 ia64 Stephen Rothwell
2003-02-15 13:58 ` [PATCH][COMPAT] compat_sys_futex 3/3 sparc64 Stephen Rothwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030212154716.7c101942.sfr@canb.auug.org.au \
--to=sfr@canb.auug.org.au \
--cc=ak@muc.de \
--cc=anton@samba.org \
--cc=davem@redhat.com \
--cc=davidm@hpl.hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=ralf@gnu.org \
--cc=schwidefsky@de.ibm.com \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®