Bug 683 - ftime millitm always returns 0
Summary: ftime millitm always returns 0
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc   
(Show other bugs)
Version: 5.2
Hardware: i386
OS: Linux
low
low
Target Milestone: ---
Assignee: Cristian Gafton
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
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:
Story Points: ---
Clone Of:
Environment:
Last Closed: 1999-01-04 23:54:35 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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,
sTB.dstflag);
        usleep (2000);
    }
    exit(0);
}

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:

===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 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.