public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix ftime
@ 2002-03-04  7:45 Jakub Jelinek
  2002-03-04  7:57 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2002-03-04  7:45 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

I couldn't find anything which would mandate this, but at least it is very
weird to have millitm = 1000 returned (in 0.0999% of cases) when it is supposed
to mean millisecond part of the time.

2002-03-04  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/unix/bsd/ftime.c (ftime): Don't return 1000 in millitm.

--- libc/sysdeps/unix/bsd/ftime.c.jj	Thu Aug 23 18:50:29 2001
+++ libc/sysdeps/unix/bsd/ftime.c	Mon Mar  4 16:47:20 2002
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 1997, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -33,5 +33,10 @@ ftime (timebuf)
   timebuf->millitm = (tv.tv_usec + 999) / 1000;
   timebuf->timezone = tz.tz_minuteswest;
   timebuf->dstflag = tz.tz_dsttime;
+  if (timebuf->millitm == 1000)
+    {
+      timebuf->time++;
+      timebuf->millitm = 0;
+    }
   return 0;
 }

	Jakub

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

* Re: [PATCH] Fix ftime
  2002-03-04  7:45 [PATCH] Fix ftime Jakub Jelinek
@ 2002-03-04  7:57 ` Andreas Schwab
  2002-03-11 13:21   ` Ulrich Drepper
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2002-03-04  7:57 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Ulrich Drepper, Glibc hackers

Jakub Jelinek <jakub@redhat.com> writes:

|> Hi!
|> 
|> I couldn't find anything which would mandate this, but at least it is very
|> weird to have millitm = 1000 returned (in 0.0999% of cases) when it is supposed
|> to mean millisecond part of the time.
|> 
|> 2002-03-04  Jakub Jelinek  <jakub@redhat.com>
|> 
|> 	* sysdeps/unix/bsd/ftime.c (ftime): Don't return 1000 in millitm.
|> 
|> --- libc/sysdeps/unix/bsd/ftime.c.jj	Thu Aug 23 18:50:29 2001
|> +++ libc/sysdeps/unix/bsd/ftime.c	Mon Mar  4 16:47:20 2002
|> @@ -1,4 +1,4 @@
|> -/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
|> +/* Copyright (C) 1994, 1997, 2002 Free Software Foundation, Inc.
|>     This file is part of the GNU C Library.
|>  
|>     The GNU C Library is free software; you can redistribute it and/or
|> @@ -33,5 +33,10 @@ ftime (timebuf)
|>    timebuf->millitm = (tv.tv_usec + 999) / 1000;

Perhaps we should actually truncate here instead of rounding up.

|>    timebuf->timezone = tz.tz_minuteswest;
|>    timebuf->dstflag = tz.tz_dsttime;
|> +  if (timebuf->millitm == 1000)
|> +    {
|> +      timebuf->time++;
|> +      timebuf->millitm = 0;
|> +    }
|>    return 0;
|>  }

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH] Fix ftime
  2002-03-04  7:57 ` Andreas Schwab
@ 2002-03-11 13:21   ` Ulrich Drepper
  0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Drepper @ 2002-03-11 13:21 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Jakub Jelinek, Glibc hackers

[-- Attachment #1: Type: text/plain, Size: 564 bytes --]

On Mon, 2002-03-04 at 07:57, Andreas Schwab wrote:

> Perhaps we should actually truncate here instead of rounding up.

I wonder way anything but rounding to nearest is used.  I've checked in
a patch to do along with Jakub's change.  Truncating is also possible
but the rules for stable arithmetic really suggest round to nearest.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 232 bytes --]

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

end of thread, other threads:[~2002-03-11 21:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-04  7:45 [PATCH] Fix ftime Jakub Jelinek
2002-03-04  7:57 ` Andreas Schwab
2002-03-11 13:21   ` Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).