Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be available on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 683 - ftime millitm always returns 0
Summary: ftime millitm always returns 0
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 5.2
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Cristian Gafton
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 1999-01-04 16:24 UTC by whampton
Modified: 2008-05-01 15:37 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 1999-01-04 23:54:35 UTC

Attachments (Terms of Use)

Description whampton 1999-01-04 16:24:19 UTC
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,
        usleep (2000);

Comment 1 David Lawrence 1999-01-04 20:57:59 UTC
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 23:54:59 UTC
According to Single Unix Spec ver 2:


     #include <sys/timeb.h>

     int ftime(struct timeb *tp);


     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.

For guaranteed granularity one should use gettimeofday() instead of

Comment 3 baitisj 1999-08-26 19:03:59 UTC
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.