X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/8cccf85821f547f5cb8abb81b499e4bb0ffbacc4..dc073bfadb411ab43bc39e2a39f48811706dfc0e:/btime.pas diff --git a/btime.pas b/btime.pas index ff77de9..46cdf48 100644 --- a/btime.pas +++ b/btime.pas @@ -9,6 +9,11 @@ works on windows/delphi, and on freepascal on unix. unit btime; +{$ifdef fpc} + {$mode delphi} +{$endif} + +{$include lcoreconfig.inc} interface @@ -31,6 +36,7 @@ var tickcount:integer; settimebias:tunixtimeint; performancecountfreq:extended; + btimenowin8:boolean; function irctimefloat:float; function irctimeint:tunixtimeint; @@ -55,6 +61,9 @@ function timestrshort(i:tunixtimeint):string; // Wed Aug 15 16:21:09 2012 function timestriso(i:tunixtimeint):string; // 2012-08-15 16:21:09 function timestrisoutc(i:float):string; // 2012-08-15T14:21:09.255553Z +procedure beginhightimerrate; +procedure endhightimerrate; + {$ifdef mswindows} function unixtimefloat_systemtime:float; {$endif} @@ -105,9 +114,7 @@ var implementation -{$ifdef fpc} - {$mode delphi} -{$endif} + uses {$ifdef UNIX} @@ -592,10 +599,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; @@ -762,10 +771,19 @@ begin end; +procedure beginhightimerrate; +begin + {$ifdef mswindows}timebeginperiod(1);{$endif} +end; + +procedure endhightimerrate; +begin + {$ifdef mswindows}timeendperiod(1);{$endif} +end; procedure init; begin - {$ifdef mswindows}timebeginperiod(1);{$endif} //ensure stable unchanging clock + {$ifdef btimehighrate}beginhightimerrate;{$endif} fillchar(mmtime_driftavg,sizeof(mmtime_driftavg),0); settimebias := 0; gettimezone;