Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005734OCamlplatform support (windows, cross-compilation, etc)public2012-08-19 18:072015-12-11 19:08
Assigned To 
PlatformOSOS Version
Product Version3.12.1 
Target Version4.01.0+devFixed in Version4.01.0+dev 
Summary0005734: Unix.gettimeofday correct resolution under Windows
DescriptionCurrent implementation of Unix.gettimeofday is not accurate as it is initialised with a time source with a resolution in seconds.
Steps To ReproduceFirst call to Unix.gettimeofday under Windows always returns a time rounded to the nearest number of seconds.
Additional InformationThe attached patch uses the Win32 API GetLocalTime (*not* GetSystemTime as the result is used to pass a struct to mktime) which returns the current time to the nearest millisecond. This is used to initialise initial_time in gettimeofday.c

Patch was made against 3.12.1, but the file is unchanged in trunk. Patch respects m.h's definition of HAS_MKTIME but this is redundant under Windows as it always does have MKTIME.

Note that using GetTickCount means that Unix.gettimeofday never responds to the local clock being corrected *forwards*. For long lived processes this could be a problem? GetTickCount is recommended for measuring elapsed time - shouldn't Unix.gettimeofday always query the local clock?
TagsNo tags attached.
Attached Filespatch file icon ocaml-3.12.1-GetTimeOfDay.patch [^] (1,272 bytes) 2012-08-19 18:07 [Show Content]

- Relationships

-  Notes
xleroy (administrator)
2012-09-24 13:39

Thanks for the patch. It's merged in trunk (r12949), will be part of the next major release (4.01).

For the record, the original code probably predates the introduction of GetLocalTime in the Win32 API at the time of Win2000.

- Issue History
Date Modified Username Field Change
2012-08-19 18:07 dra New Issue
2012-08-19 18:07 dra File Added: ocaml-3.12.1-GetTimeOfDay.patch
2012-09-06 16:43 doligez Target Version => 4.00.1+dev
2012-09-24 13:39 xleroy Note Added: 0008152
2012-09-24 13:39 xleroy Status new => resolved
2012-09-24 13:39 xleroy Resolution open => fixed
2012-09-24 13:39 xleroy Fixed in Version => 4.01.0+dev
2012-09-24 13:39 xleroy Target Version 4.00.1+dev => 4.01.0+dev
2015-12-11 19:08 xleroy Status resolved => closed
2017-02-23 16:46 doligez Category OCaml windows => platform support (windows, etc)
2017-02-23 17:16 doligez Category platform support (windows, etc) => platform support (windows, cross-compilation, etc)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker