X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/2d2676149292e4e388bb102a41a3d64349ac88ed..6e5673aa1dcdb1ba7688b75f7f065353abc86159:/btime.pas?ds=sidebyside diff --git a/btime.pas b/btime.pas old mode 100755 new mode 100644 index 9bb9550..33b32d0 --- 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