[Lazarus] Better implementation of GetTickcount using clock_gettime

zeljko zeljko at holobit.net
Tue Apr 1 14:38:59 CEST 2014


On 04/01/2014 01:57 PM, Henry Vermaak wrote:
> On Tue, Apr 01, 2014 at 12:45:54PM +0200, zeljko wrote:
>> On 04/01/2014 12:20 PM, Luca Olivetti wrote:
>>
>>> For linux a more accurate implementation could be
>>>
>>> function GetTickCount64: QWord;
>>> var
>>>    tp: timespec;
>>> begin
>>>    clock_gettime(CLOCK_MONOTONIC, @tp);
>>>    Result := (Int64(tp.tv_sec) * 1000) + (tp.tv_nsec div 1000000);
>>> end;
>>>
>>>
>>> And I say linux because CLOCK_MONOTONIC is only defined there in fpc,
>>> though it should be available even in other systems:
>>
>> CLOCK_MONOTONIC is available only for kernels >= 2.6.26.
>
> No, it's been around since before 2.6.

You're right. I've been on CLOCK_MONOTONIC_RAW which is available since 
2.6.28 actually .... so my complete information was wrong ;)

zeljko





More information about the Lazarus mailing list