2003-03-21 06:03:00

by Randy.Dunlap

[permalink] [raw]
Subject: [PATCH] arch-independent syscalls to return long

patch_name: syscalls-long-2560.patch
patch_version: 2003-02-13.22:58:43
author: Randy.Dunlap <[email protected]>
description: convert arch-independent syscalls to long return values;
product: Linux
product_versions: 2.5.65
diffstat: =
arch/x86_64/ia32/sys_ia32.c | 4 ++--
fs/dcookies.c | 2 +-
fs/readdir.c | 2 +-
include/linux/mm.h | 2 +-
kernel/fork.c | 2 +-
kernel/sched.c | 4 ++--
kernel/signal.c | 2 +-
mm/fremap.c | 2 +-
8 files changed, 10 insertions(+), 10 deletions(-)


diff -Naur ./arch/x86_64/ia32/sys_ia32.c%LONG ./arch/x86_64/ia32/sys_ia32.c
--- ./arch/x86_64/ia32/sys_ia32.c%LONG Mon Feb 10 10:38:29 2003
+++ ./arch/x86_64/ia32/sys_ia32.c Thu Feb 13 22:15:24 2003
@@ -2071,8 +2071,8 @@
return -ENOSYS ;
}

-int sys_sched_getaffinity(pid_t pid, unsigned int len, unsigned long *new_mask_ptr);
-int sys_sched_setaffinity(pid_t pid, unsigned int len, unsigned long *new_mask_ptr);
+long sys_sched_getaffinity(pid_t pid, unsigned int len, unsigned long *new_mask_ptr);
+long sys_sched_setaffinity(pid_t pid, unsigned int len, unsigned long *new_mask_ptr);

/* only works on LE */
long sys32_sched_setaffinity(pid_t pid, unsigned int len,
diff -Naur ./fs/dcookies.c%LONG ./fs/dcookies.c
--- ./fs/dcookies.c%LONG Mon Feb 10 10:37:55 2003
+++ ./fs/dcookies.c Thu Feb 13 21:40:48 2003
@@ -142,7 +142,7 @@
/* And here is where the userspace process can look up the cookie value
* to retrieve the path.
*/
-asmlinkage int sys_lookup_dcookie(u64 cookie64, char * buf, size_t len)
+asmlinkage long sys_lookup_dcookie(u64 cookie64, char * buf, size_t len)
{
unsigned long cookie = (unsigned long)cookie64;
int err = -EINVAL;
diff -Naur ./fs/readdir.c%LONG ./fs/readdir.c
--- ./fs/readdir.c%LONG Mon Feb 10 10:38:31 2003
+++ ./fs/readdir.c Thu Feb 13 22:50:16 2003
@@ -85,7 +85,7 @@
return 0;
}

-asmlinkage int old_readdir(unsigned int fd, void * dirent, unsigned int count)
+asmlinkage long old_readdir(unsigned int fd, void * dirent, unsigned int count)
{
int error;
struct file * file;
diff -Naur ./kernel/fork.c%LONG ./kernel/fork.c
--- ./kernel/fork.c%LONG Mon Feb 10 10:37:58 2003
+++ ./kernel/fork.c Thu Feb 13 21:21:07 2003
@@ -736,7 +736,7 @@
p->flags = new_flags;
}

-asmlinkage int sys_set_tid_address(int *tidptr)
+asmlinkage long sys_set_tid_address(int *tidptr)
{
current->clear_child_tid = tidptr;

diff -Naur ./kernel/sched.c%LONG ./kernel/sched.c
--- ./kernel/sched.c%LONG Mon Feb 10 10:38:49 2003
+++ ./kernel/sched.c Thu Feb 13 22:16:05 2003
@@ -1902,7 +1902,7 @@
* @len: length in bytes of the bitmask pointed to by user_mask_ptr
* @user_mask_ptr: user-space pointer to the new cpu mask
*/
-asmlinkage int sys_sched_setaffinity(pid_t pid, unsigned int len,
+asmlinkage long sys_sched_setaffinity(pid_t pid, unsigned int len,
unsigned long *user_mask_ptr)
{
unsigned long new_mask;
@@ -1954,7 +1954,7 @@
* @len: length in bytes of the bitmask pointed to by user_mask_ptr
* @user_mask_ptr: user-space pointer to hold the current cpu mask
*/
-asmlinkage int sys_sched_getaffinity(pid_t pid, unsigned int len,
+asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len,
unsigned long *user_mask_ptr)
{
unsigned int real_len;
diff -Naur ./kernel/signal.c%LONG ./kernel/signal.c
--- ./kernel/signal.c%LONG Mon Feb 10 10:38:26 2003
+++ ./kernel/signal.c Thu Feb 13 21:43:45 2003
@@ -2254,7 +2254,7 @@

#ifndef HAVE_ARCH_SYS_PAUSE

-asmlinkage int
+asmlinkage long
sys_pause(void)
{
current->state = TASK_INTERRUPTIBLE;
diff -Naur ./mm/fremap.c%LONG ./mm/fremap.c
--- ./mm/fremap.c%LONG Mon Feb 10 10:37:56 2003
+++ ./mm/fremap.c Thu Feb 13 21:52:58 2003
@@ -110,7 +110,7 @@
* or use PROT_NONE in the original linear mapping and add a special
* SIGBUS pagefault handler to reinstall zapped mappings.
*/
-int sys_remap_file_pages(unsigned long start, unsigned long size,
+long sys_remap_file_pages(unsigned long start, unsigned long size,
unsigned long prot, unsigned long pgoff, unsigned long flags)
{
struct mm_struct *mm = current->mm;
--- ./include/linux/mm.h%LONG Mon Mar 17 13:43:39 2003
+++ ./include/linux/mm.h Thu Mar 20 21:48:00 2003
@@ -421,7 +421,7 @@
extern int handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, unsigned long address, int write_access);
extern int make_pages_present(unsigned long addr, unsigned long end);
extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
-extern int sys_remap_file_pages(unsigned long start, unsigned long size, unsigned long prot, unsigned long pgoff, unsigned long nonblock);
+extern long sys_remap_file_pages(unsigned long start, unsigned long size, unsigned long prot, unsigned long pgoff, unsigned long nonblock);


int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start,


Attachments:
syscalls-long-2565.patch (4.86 kB)

2003-03-21 06:13:28

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] arch-independent syscalls to return long

"Randy.Dunlap" <[email protected]> wrote:
>
> Hi,
>
> I posted this about 1 month ago (as [RFC]), to no avail.
> However, tonight Andi needs it for pause() [which is failing
> on x86_64], and Robert Love mentioned converting the affinity
> syscalls. I had already done them, so here they are again.
>

Thanks. Is that all of them done now?

2003-03-21 06:30:51

by Randy.Dunlap

[permalink] [raw]
Subject: Re: [PATCH] arch-independent syscalls to return long

Andrew Morton wrote:
>
> "Randy.Dunlap" <[email protected]> wrote:
> >
> > Hi,
> >
> > I posted this about 1 month ago (as [RFC]), to no avail.
> > However, tonight Andi needs it for pause() [which is failing
> > on x86_64], and Robert Love mentioned converting the affinity
> > syscalls. I had already done them, so here they are again.
> >
>
> Thanks. Is that all of them done now?

AFAIK, without guarantees. I used a list from Jamie Lokier and then
went thru bunches of source files & syscalls myself and came up with
these.

There are still some syscall prototypes that are declared as int
instead of long, but I can't fix them tonight (zzz). Examples:

sys_sched_setaffinity
arch/sparc64/, arch/ppc64/, arch/s390x/ (FIX PROTO)
sys_sched_getaffinity
arch/sparc64/, arch/ppc64/, arch/s390x/ (FIX PROTO)
sys_remap_file_pages
arch/sparc/ (FIX PROTO)
sys_lookup_dcookie
arch/sparc64/, arch/ppc64/, arch/parisc/ (FIX PROTO)


That's all that I know of.

~Randy

2003-03-21 06:42:33

by Robert Love

[permalink] [raw]
Subject: Re: [PATCH] arch-independent syscalls to return long

On Fri, 2003-03-21 at 01:23, Andrew Morton wrote:

> Thanks. Is that all of them done now?

I think so, I just grepped the whole tree.

But... Here are some related cleanups that should accompany the original
patch.

Against 2.5.65.

Robert Love


Documentation/DocBook/kernel-hacking.tmpl | 2 +-
drivers/macintosh/via-pmu.c | 2 +-
drivers/message/fusion/mptctl.c | 2 +-
include/asm-parisc/unistd.h | 10 +++++-----
include/linux/ioctl32.h | 2 +-
kernel/suspend.c | 2 +-
net/compat.c | 6 +++---
7 files changed, 13 insertions(+), 13 deletions(-)


diff -urN linux-2.5.65/Documentation/DocBook/kernel-hacking.tmpl linux/Documentation/DocBook/kernel-hacking.tmpl
--- linux-2.5.65/Documentation/DocBook/kernel-hacking.tmpl 2003-03-17 16:44:07.000000000 -0500
+++ linux/Documentation/DocBook/kernel-hacking.tmpl 2003-03-21 01:46:28.202341104 -0500
@@ -319,7 +319,7 @@
</para>

<programlisting>
-asmlinkage int sys_mycall(int arg)
+asmlinkage long sys_mycall(int arg)
{
return 0;
}
diff -urN linux-2.5.65/drivers/macintosh/via-pmu.c linux/drivers/macintosh/via-pmu.c
--- linux-2.5.65/drivers/macintosh/via-pmu.c 2003-03-17 16:44:43.000000000 -0500
+++ linux/drivers/macintosh/via-pmu.c 2003-03-21 01:41:26.874149952 -0500
@@ -2002,7 +2002,7 @@
last_jiffy_stamp(0) = tb_last_stamp = get_tbl();
}

-extern int sys_sync(void);
+extern long sys_sync(void);

#define GRACKLE_PM (1<<7)
#define GRACKLE_DOZE (1<<5)
diff -urN linux-2.5.65/drivers/message/fusion/mptctl.c linux/drivers/message/fusion/mptctl.c
--- linux-2.5.65/drivers/message/fusion/mptctl.c 2003-03-17 16:43:38.000000000 -0500
+++ linux/drivers/message/fusion/mptctl.c 2003-03-21 01:40:43.187791288 -0500
@@ -2743,7 +2743,7 @@
unsigned long,
struct file *));
int unregister_ioctl32_conversion(unsigned int cmd);
-extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
+extern long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/* sparc32_XXX functions are used to provide a conversion between
diff -urN linux-2.5.65/include/asm-parisc/unistd.h linux/include/asm-parisc/unistd.h
--- linux-2.5.65/include/asm-parisc/unistd.h 2003-03-17 16:43:37.000000000 -0500
+++ linux/include/asm-parisc/unistd.h 2003-03-21 01:45:35.018426288 -0500
@@ -842,19 +842,19 @@

static inline pid_t setsid(void)
{
- extern int sys_setsid(void);
+ extern long sys_setsid(void);
return sys_setsid();
}

static inline int write(int fd, const char *buf, off_t count)
{
- extern int sys_write(int, const char *, int);
+ extern long sys_write(int, const char *, int);
return sys_write(fd, buf, count);
}

static inline int read(int fd, char *buf, off_t count)
{
- extern int sys_read(int, char *, int);
+ extern long sys_read(int, char *, int);
return sys_read(fd, buf, count);
}

@@ -866,7 +866,7 @@

static inline int dup(int fd)
{
- extern int sys_dup(int);
+ extern long sys_dup(int);
return sys_dup(fd);
}

@@ -891,7 +891,7 @@

static inline int _exit(int exitcode)
{
- extern int sys_exit(int) __attribute__((noreturn));
+ extern long sys_exit(int) __attribute__((noreturn));
return sys_exit(exitcode);
}

diff -urN linux-2.5.65/include/linux/ioctl32.h linux/include/linux/ioctl32.h
--- linux-2.5.65/include/linux/ioctl32.h 2003-03-17 16:43:38.000000000 -0500
+++ linux/include/linux/ioctl32.h 2003-03-21 01:45:54.559455600 -0500
@@ -3,7 +3,7 @@

struct file;

-int sys_ioctl(unsigned int, unsigned int, unsigned long);
+extern long sys_ioctl(unsigned int, unsigned int, unsigned long);

/*
* Register an 32bit ioctl translation handler for ioctl cmd.
diff -urN linux-2.5.65/kernel/suspend.c linux/kernel/suspend.c
--- linux-2.5.65/kernel/suspend.c 2003-03-17 16:43:49.000000000 -0500
+++ linux/kernel/suspend.c 2003-03-21 01:40:50.000000000 -0500
@@ -65,7 +65,7 @@
#include <asm/pgtable.h>
#include <asm/io.h>

-extern int sys_sync(void);
+extern long sys_sync(void);

unsigned char software_suspend_enabled = 0;

diff -urN linux-2.5.65/net/compat.c linux/net/compat.c
--- linux-2.5.65/net/compat.c 2003-03-17 16:44:11.000000000 -0500
+++ linux/net/compat.c 2003-03-21 01:44:53.000000000 -0500
@@ -365,8 +365,8 @@
kmsg->msg_control = (void *) orig_cmsg_uptr;
}

-extern asmlinkage int sys_setsockopt(int fd, int level, int optname,
- char *optval, int optlen);
+extern long sys_setsockopt(int fd, int level, int optname,
+ char *optval, int optlen);

static int do_netfilter_replace(int fd, int level, int optname,
char *optval, int optlen)
@@ -530,7 +530,7 @@
return err;
}

-asmlinkage int compat_sys_setsockopt(int fd, int level, int optname,
+asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
char *optval, int optlen)
{
if (optname == IPT_SO_SET_REPLACE)



2003-03-21 19:14:03

by Robert Love

[permalink] [raw]
Subject: Re: [PATCH] arch-independent syscalls to return long

On Fri, 2003-03-21 at 13:46, Randy.Dunlap wrote:

> On 21 Mar 2003 01:51:50 -0500 Robert Love <[email protected]> wrote:
>
> | -extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
> | +extern long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
>
> keep the asmlinkage (or why not?)

I always that it did not matter, but Arjan just pointed out otherwise
(as you saw). So I guess these need to be reverted.

There are a handful of other such cases around the kernel...

Robert Love

2003-03-21 19:19:18

by Robert Love

[permalink] [raw]
Subject: Re: [PATCH] arch-independent syscalls to return long

On Fri, 2003-03-21 at 14:23, Robert Love wrote:

> I always that it did not matter, but Arjan just pointed out
> otherwise (as you saw). So I guess these need to be reverted.

And here is a patch to do so.

This patch, against 2.5.65 + the previous two, replaces the missing
asmlinkage on prototypes.

Robert Love


drivers/message/fusion/mptctl.c | 3 ++-
net/compat.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)


diff -urN linux-2.5.65/drivers/message/fusion/mptctl.c linux/drivers/message/fusion/mptctl.c
--- linux-2.5.65/drivers/message/fusion/mptctl.c 2003-03-21 14:23:30.878772704 -0500
+++ linux/drivers/message/fusion/mptctl.c 2003-03-21 14:24:24.599605896 -0500
@@ -2743,7 +2743,8 @@
unsigned long,
struct file *));
int unregister_ioctl32_conversion(unsigned int cmd);
-extern long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
+extern asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd,
+ unsigned long arg);

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/* sparc32_XXX functions are used to provide a conversion between
diff -urN linux-2.5.65/net/compat.c linux/net/compat.c
--- linux-2.5.65/net/compat.c 2003-03-21 14:23:31.000000000 -0500
+++ linux/net/compat.c 2003-03-21 14:25:03.000000000 -0500
@@ -365,8 +365,8 @@
kmsg->msg_control = (void *) orig_cmsg_uptr;
}

-extern long sys_setsockopt(int fd, int level, int optname,
- char *optval, int optlen);
+extern asmlinkage long sys_setsockopt(int fd, int level, int optname,
+ char *optval, int optlen);

static int do_netfilter_replace(int fd, int level, int optname,
char *optval, int optlen)



2003-03-21 18:43:26

by Randy.Dunlap

[permalink] [raw]
Subject: Re: [PATCH] arch-independent syscalls to return long

On 21 Mar 2003 01:51:50 -0500 Robert Love <[email protected]> wrote:

| -extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
| +extern long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);

keep the asmlinkage (or why not?)


| -extern asmlinkage int sys_setsockopt(int fd, int level, int optname,
| - char *optval, int optlen);
| +extern long sys_setsockopt(int fd, int level, int optname,
| + char *optval, int optlen);

ditto

--
~Randy [resending after error on first attempt]