Bug 683 - ftime millitm always returns 0
ftime millitm always returns 0
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
5.2
i386 Linux
low Severity low
: ---
: ---
Assigned To: Cristian Gafton
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-01-04 11:24 EST by whampton
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 1999-01-04 18:54:35 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description whampton 1999-01-04 11:24:19 EST
With other versions of UNIX and LIBC5 Linux, ftime
returned a value for the milliseconds.  With RedHat 5.x
and glibc, ftime always returns a 0 for the millitm
field.  See sample:

/* ftime test:  gcc -o ftimetest -Wall ftimetest.c
 */
#include <stdio.h>
#include <sys/timeb.h>
#include <unistd.h>

int main()
{
    struct timeb sTB;
    int    ii;

    for (ii=0; ii<100; ii++) {
        ftime (&sTB);
        printf ("%010ld.%03d %05d %d\n",
                sTB.time, sTB.millitm, sTB.timezone,
sTB.dstflag);
        usleep (2000);
    }
    exit(0);
}
Comment 1 David Lawrence 1999-01-04 15:57:59 EST
I have verified this report to be true. I compile the included code
and observed the difference on a 4.2 machine and a 5.2 machine. It has
been assigned to a developer for further review.
Comment 2 Cristian Gafton 1999-01-04 18:54:59 EST
According to Single Unix Spec ver 2:

===QUOTE===
SYNOPSIS

     #include <sys/timeb.h>

     int ftime(struct timeb *tp);


DESCRIPTION

     The ftime() function sets the time and millitm members of the
timeb structure pointed to by tp to contain the seconds
     and milliseconds portions, respectively, of the current time in
seconds since 00:00:00 UTC (Coordinated Universal Time),
     January 1, 1970. The contents of the timezone and dstflag members
of tp after a call to ftime() are unspecified.

     The system clock need not have millisecond granularity. Depending
on any granularity (particularly a granularity of one)
     renders code non-portable.
===END QUOTE===

For guaranteed granularity one should use gettimeofday() instead of
ftime.
Comment 3 baitisj 1999-08-26 15:03:59 EDT
I have verified that this bug still exists in RedHat version 6.0
package glibc-2.1.1-6-i386 by compiling and executing the given code.
Re-opening bug.

Note You need to log in before you can comment on or make changes to this bug.