X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/3f8290b4a13c15cf62776aa427f62a8ae77ee07c..fed3bacaa7e5da92ab4cf44995b5a2bc26a81faa:/btime.pas diff --git a/btime.pas b/btime.pas index 87801b5..a0bfc5e 100644 --- a/btime.pas +++ b/btime.pas @@ -36,6 +36,7 @@ var tickcount:integer; settimebias:tunixtimeint; performancecountfreq:extended; + btimenowin8:boolean; function irctimefloat:float; function irctimeint:tunixtimeint; @@ -175,9 +176,14 @@ end; function unixtimefloat:float; var tv:ttimeval; + sec:tunixtimeint; begin gettimeofday(tv); - result := tv.tv_sec+(tv.tv_usec/1000000); + sec := tv.tv_sec; + {$ifndef cpu64} + if (sec < 0) then inc(sec,$100000000); //tv_sec is 32 bits + {$endif} + result := sec+(tv.tv_usec/1000000); end; {$ifdef linux} @@ -262,9 +268,14 @@ end; function unixtimeint:tunixtimeint; var tv:ttimeval; + sec:tunixtimeint; begin gettimeofday(tv); - result := tv.tv_sec; + sec := tv.tv_sec; + {$ifndef cpu64} + if (sec < 0) then inc(sec,$100000000); //tv_sec is 32 bits + {$endif} + result := sec; end; {------------------------------ end of *nix/freepascal section} @@ -598,10 +609,12 @@ const var f,g,h:float; begin - if not win8inited then initwin8; - if assigned(@GetSystemTimePreciseAsFileTime) then begin - result := unixtimefloat_win8; - exit; + if not btimenowin8 then begin + if not win8inited then initwin8; + if assigned(@GetSystemTimePreciseAsFileTime) then begin + result := unixtimefloat_win8; + exit; + end; end; result := monotimefloat+timefloatbias;