lkml.org 
[lkml]   [1999]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectSolution proposal: linux-2.0.34: clock() return -1 after 248 days
uptime
Reply-To:
In-Reply-To: <19990223015653.A24729@niksula.cs.hut.fi>; from Ville Herva on Tue, Feb 23, 1999 at 01:56:53AM +0200

Yesterday I wrote:

> A closer inspection revealed that Linux seems return a signed long
> as the return value of sys_times:
>
> linux-2.0.3[46]/kernel/sys.c:
> asmlinkage long sys_times(struct tms * tbuf)
> {
> if (tbuf) {
> int error = verify_area(VERIFY_WRITE,tbuf,sizeof *tbuf);
> if (error)
> return error;
> put_user(current->utime,&tbuf->tms_utime);
> put_user(current->stime,&tbuf->tms_stime);
> put_user(current->cutime,&tbuf->tms_cutime);
> put_user(current->cstime,&tbuf->tms_cstime);
> }
> return jiffies;
> }
>
> linux-2.2.1/kernel/sys.c:
> asmlinkage long sys_times(struct tms * tbuf)
> {
> /*
> * In the SMP world we might just be unlucky and have one of
> * the times increment as we use it. Since the value is an
> * atomically safe type this is just fine. Conceptually its
> * as if the syscall took an instant longer to occur.
> */
> if (tbuf)
> if (copy_to_user(tbuf, &current->times, sizeof(struct
> tms)))
> return -EFAULT;
> return jiffies;
> }
>
> However, jiffies is a unsigned variable:
>
> linux-2.2.1/kernel/sched.c: unsigned long volatile jiffies=0;
> linux-2.0.3[46]/kernel/sched.c: unsigned long volatile jiffies=0;
>
> Now, glibc seems to treat this value as signed:
>
> glibc-2.0.6:
> posix/sys/times.h:extern clock_t __times __P ((struct tms *__buffer));
>
> glibc-2.0.108-0.981221:
> include/sys/times.h:extern clock_t __times __P ((struct tms *__buffer));

I still haven't read the standard, but would it make sense to strip the
sign bit before returning jiffies in sys_times? It seems pointless to
return negative error codes otherwise.


-- v --

v@iki.fi

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.029 / U:0.448 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site