[patch,fortran] Fix corner case where consecutive calls to date_and_time can return times out of sequence (PR30015)

Tobias Burnus burnus@net-b.de
Sun Dec 10 11:41:00 GMT 2006


Hi Thomas,

Thomas Koenig wrote:
> If I understand the system calls correctly, gettimeofday() returns
> both the seconds and the milliseconds since epoch.  That's all we
> need to fill out the fields of DATE_AND_TIME
>
> If gettimeofday succeeds, why is there a need to call time() at all?
>   

Because I missed this when I copied the patch from the PR. Yesterday,
during a concert I asked myself the same question. (I should go more
often into concerts, especially if they are given for free in the
conservatoire ;-)

Short description of the bug:
- Currently, libgfortran uses  "time()" for the
seconds/minutes/hours/... and gettimeofday for the milliseconds.
- This patch uses gettimeofday for both and removes thus a corner case,
where a second call could return an earlier time than the first one.

Patch based on the one by Mat Cross, see PR.


Regression tested on x86_64-unknown-linux-gnu. Ok for the trunk and
after a week for 4.2 (and 4.1?).


Tobias


2006-12-09  Mat Cross  <mathewc@nag.co.uk>
            Tobias Burnus  <burnus@net-b.de>

	PR fortran/30015
	* intrinsics/date_and_time.c (date_and_time): Fix case where time
	  can go backwards.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: time.diff
Type: text/x-patch
Size: 2318 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061210/edac8b00/attachment.bin>


More information about the Gcc-patches mailing list