Bug 683
| Summary: | ftime millitm always returns 0 | ||
|---|---|---|---|
| Product: | [Retired] Red Hat Linux | Reporter: | whampton |
| Component: | glibc | Assignee: | Cristian Gafton <gafton> |
| Status: | CLOSED NOTABUG | QA Contact: | |
| Severity: | low | Docs Contact: | |
| Priority: | low | ||
| Version: | 5.2 | CC: | whampton |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | i386 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| 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: | --- | Target Upstream Version: | |
| Embargoed: | |||
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. 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.
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. |
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); }