From 935f8f3fc8915049b0bd70fdb9050bbd1ca65b7c Mon Sep 17 00:00:00 2001 From: beware Date: Wed, 24 Feb 2010 04:01:22 +0000 Subject: [PATCH] simulate gettimeofday on windows git-svn-id: file:///svnroot/lcore/trunk@84 b1de8a11-f9be-4011-bde0-cc7ace90066a --- btime.pas | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/btime.pas b/btime.pas index 9bb9550..33b32d0 100644 --- a/btime.pas +++ b/btime.pas @@ -12,6 +12,11 @@ unit btime; interface +{$ifdef win32} +uses + ltimevalstuff; +{$endif} + type float=extended; @@ -55,6 +60,11 @@ function mmtimefloat:float; function qpctimefloat:float; {$endif} +{$ifdef win32} +procedure gettimeofday(var tv:ttimeval); +{$endif} + + const mmtime_driftavgsize=32; mmtime_warmupnum=4; @@ -169,6 +179,22 @@ end; {$else} {delphi 3} {------------------------------ windows/delphi code to read time} + +{simulate gettimeofday on windows so one can always use gettimeofday if preferred} + +procedure gettimeofday(var tv:ttimeval); +var + e:extended; +begin + e := unixtimefloat; + tv.tv_sec := round(int(e)); + tv.tv_usec := trunc(frac(e)*1000000); + {just in case} + if (tv.tv_usec < 0) then tv.tv_usec := 0; + if (tv.tv_usec > 999999) then tv.tv_usec := 999999; +end; + + { time float: gettickcount resolution: 9x: ~55 ms NT: 1/64th of a second -- 2.30.2