[fpc-devel] About GetTickCount
Tomas Hajny
XHajT03 at hajny.biz
Thu Nov 3 10:23:43 CET 2011
On Thu, November 3, 2011 09:41, zeljko wrote:
> I guess that there's no GetTickCount in RTL.
> Is it possible to add it there ?
> Why ?
> Because current GetTickCount in lazarus uses Now() which is movable
> backward/forward by ntpd under unixes, and that could be a huge problem.
>
> This is what MSDN says about GetTickCount:
> Retrieves the number of milliseconds that have elapsed since the system
> was
> started, up to 49.7 days (what they do after 49.7 days ? ).
>
> So, according to POSIX clock_gettime(CLOCK_MONOTONIC) is supported on
> linux,
> bsd and others, and in that case we can have exact GetTickCount.
> If there's no support for monotonic clock on some platform , now() can be
> returned anytime.
There is already GetMsCount in unit Dos. It should be possible to add it
to sysutils too. This does not guarantee to be monotonic, but the primary
goal is a simple and fast call which should allow checking time difference
between two consecutive calls. It uses GetTickCount on Win32 and similar
calls on other platforms. As implemented now, it doesn't protect you from
time changes on all platforms though (but that is a limitation of
implementation for those platforms).
Tomas
More information about the fpc-devel
mailing list