mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][COMPAT] compat_sys_futex 1/7 generic
@ 2003-02-12  4:47 Stephen Rothwell
  2003-02-12  4:51 ` [PATCH][COMPAT] compat_sys_futex 2/7 ia64 Stephen Rothwell
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Stephen Rothwell @ 2003-02-12  4:47 UTC (permalink / raw)
  To: Linus
  Cc: LKML, anton, David S. Miller, ak, davidm, schwidefsky, ralf, matthew

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)

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2003-02-15 13:48 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-12  4:47 [PATCH][COMPAT] compat_sys_futex 1/7 generic Stephen Rothwell
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

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®