Skip to contentSkip to conversation

x86_64: remove duplicated sys_time64

PATCH In review [email protected] 3 participants 6 messages Mar 30, 2005 – Mar 31, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 x86_64: remove duplicated sys_time64

CC Andi Kleen <[email protected]>

Keeping this function does not makes sense because it's a copied (and buggy) copy of sys_time. The only difference is that now.tv_sec (which is a time_t, i.e. a 64-bit long) is copied (and truncated) into a int (32-bit).

The prototype is the same (they both take a long __user *), so let's drop this and redirect it to sys_time (and make sure it exists by defining __ARCH_WANT_SYS_TIME).

Only disadvantage is that the sys_stime definition is also compiled (may be fixed if needed by adding a separate __ARCH_WANT_SYS_STIME macro, and defining it for all arch's defining __ARCH_WANT_SYS_TIME except x86_64).

Not compile-tested, sorry.

---

 linux-2.6.11-paolo/arch/x86_64/kernel/sys_x86_64.c |   14 --------------
 linux-2.6.11-paolo/include/asm-x86_64/unistd.h     |    3 ++-
 2 files changed, 2 insertions(+), 15 deletions(-)
include/asm-x86_64/unistd.h renamed from include/asm-x86_64/unistd.h~x86_64-remove-sys-time-x86-64 +2 -1
diff -puN include/asm-x86_64/unistd.h~x86_64-remove-sys-time-x86-64 include/asm-x86_64/unistd.h
@@ -462,7 +462,7 @@ __SYSCALL(__NR_fremovexattr, sys_fremove
 #define __NR_tkill	200
 __SYSCALL(__NR_tkill, sys_tkill) 
 #define __NR_time      201
-__SYSCALL(__NR_time, sys_time64)
+__SYSCALL(__NR_time, sys_time)
 #define __NR_futex     202
 __SYSCALL(__NR_futex, sys_futex)
 #define __NR_sched_setaffinity    203
@@ -600,6 +600,7 @@ do { \
 #define __ARCH_WANT_SYS_SIGPENDING
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
+#define __ARCH_WANT_SYS_TIME
 #define __ARCH_WANT_COMPAT_SYS_TIME
 #endif
 
arch/x86_64/kernel/sys_x86_64.c renamed from arch/x86_64/kernel/sys_x86_64.c~x86_64-remove-sys-time-x86-64 +0 -14
diff -puN arch/x86_64/kernel/sys_x86_64.c~x86_64-remove-sys-time-x86-64 arch/x86_64/kernel/sys_x86_64.c
@@ -158,17 +158,3 @@ asmlinkage long wrap_sys_shmat(int shmid
 	unsigned long raddr;
 	return do_shmat(shmid,shmaddr,shmflg,&raddr) ?: (long)raddr;
 }
-
-asmlinkage long sys_time64(long __user * tloc)
-{
-	struct timeval now; 
-	int i; 
-
-	do_gettimeofday(&now);
-	i = now.tv_sec;
-	if (tloc) {
-		if (put_user(i,tloc))
-			i = -EFAULT;
-	}
-	return i;
-}

_

#1 lore raw
Quoted 11 lines · On Wed, Mar 30, 2005 at 07:32:16PM +0200, [email protected] wrote:
CC Andi Kleen <[email protected]>

Keeping this function does not makes sense because it's a copied (and buggy) copy of sys_time. The only difference is that now.tv_sec (which is a time_t, i.e. a 64-bit long) is copied (and truncated) into a int (32-bit).

The prototype is the same (they both take a long __user *), so let's drop this and redirect it to sys_time (and make sure it exists by defining __ARCH_WANT_SYS_TIME).

Quoted 5 lines

Only disadvantage is that the sys_stime definition is also compiled (may be fixed if needed by adding a separate __ARCH_WANT_SYS_STIME macro, and defining it for all arch's defining __ARCH_WANT_SYS_TIME except x86_64).

Not compile-tested, sorry.

Nack. The generic sys_time still writes to int, not long. That is why x86-64 has a private one. Please keep that.

-Andi

#2 lore raw
Quoted 3 lines · On Thu, 31 Mar 2005 12:38:34 +0200 Andi Kleen <[email protected]> wrote:

Nack. The generic sys_time still writes to int, not long. That is why x86-64 has a private one. Please keep that.

It writes to a time_t which is a __kernel_time_t which is a long on x86-64, isn't it?

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#3 lore raw
Quoted 7 lines · Stephen Rothwell
Quoted 3 lines · On Thu, 31 Mar 2005 12:38:34 +0200 Andi Kleen <[email protected]> wrote:

Nack. The generic sys_time still writes to int, not long. That is why x86-64 has a private one. Please keep that.

It writes to a time_t which is a __kernel_time_t which is a long on x86-64, isn't it?

At least in 2.6.10 it writes to int.

-Andi

#4 lore raw
Quoted 11 lines · On Thu, 31 Mar 2005 13:12:35 +0200 Andi Kleen <[email protected]> wrote:
Quoted 7 lines · Stephen Rothwell
Quoted 3 lines · On Thu, 31 Mar 2005 12:38:34 +0200 Andi Kleen <[email protected]> wrote:

Nack. The generic sys_time still writes to int, not long. That is why x86-64 has a private one. Please keep that.

It writes to a time_t which is a __kernel_time_t which is a long on x86-64, isn't it?

At least in 2.6.10 it writes to int.

I was looking at current bk where it looks like this:

asmlinkage long sys_time(time_t __user * tloc)

{
        time_t i;
        struct timeval tv;

        do_gettimeofday(&tv);
        i = tv.tv_sec;

        if (tloc) {
                if (put_user(i,tloc))
                        i = -EFAULT;
        }
        return i;
}

I have no idea when it changed.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#5 lore raw
Quoted 8 lines · Stephen Rothwell
Quoted 7 lines · On Thu, 31 Mar 2005 13:12:35 +0200 Andi Kleen <[email protected]> wrote:
Quoted 5 lines · Stephen Rothwell
Quoted 3 lines · On Thu, 31 Mar 2005 12:38:34 +0200 Andi Kleen <[email protected]> wrote:

Nack. The generic sys_time still writes to int, not long. That is why x86-64 has a private one. Please keep that.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

It writes to a time_t which is a __kernel_time_t which is a long on x86-64, isn't it?

At least in 2.6.10 it writes to int.

I was looking at current bk where it looks like this:

asmlinkage long sys_time(time_t __user * tloc)

Ok with that change the patch is ok.

Quoted 14 lines
{
        time_t i;
        struct timeval tv;

        do_gettimeofday(&tv);
        i = tv.tv_sec;

        if (tloc) {
                if (put_user(i,tloc))
                        i = -EFAULT;
        }
        return i;
}
Quoted 1 line

I have no idea when it changed.

I was looking at an older tree, sorry.
-Andi