[fpc-devel] NowUTC in the RTL

Helmut Hartl helmut.hartl at firmos.at
Fri Dec 9 16:39:44 CET 2011

Am 09.12.11 16:25, schrieb Michael Van Canneyt:
> On Fri, 9 Dec 2011, Helmut Hartl wrote:
>>> Well, if OS-X does not have it, we can't really say it is POSIX for 
>>> our purposes, so then it goes to the linux unit. It's as simple as 
>>> that.
>> Only if you discriminate BSD  systems :-) - Many professional vendors 
>> use some sort of BSD in their products,
>> and some fpc.
>> Freebsd, Netbsd, Openbsd, and Linux  has it.
>> For OSX there is a substitution: 
>> http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x
> Well, you'll have to convince Marco. But I think it's that time of the 
> month, when he's hard to convince, just for the fun of discussion :)
> But till you do convince him, I'll put it in the linux unit, and Marco 
> can put it in a *BSD specific unit.
> That's what these units are for.
> Michael.

:-) Boy, I am happy that I dont need to convince anybody anymore.

The granularity is not only OS dependend but hardware dependend.
In FreeBSD you have the granularity if you have a hardware high 
precision timer.
This can be queried via sysctls, i assume this is handled in other os's 
For our software we have to handle this target and hardware specific(!).
But we use server appliance hardware with freebsd and fpc software
for our products - and that  is somewhat exotic.

The constants influence highly the time needed for the call, so
in general you want to know what for you need the time base.
Some background:

@portable NowUTC
I would have been happy if FPC had provided me the super ultra fast,
high precise and platform independend timer routine,
But i would not have been happy for long - As fpc simply can't
read ones mind and be better then the underlying hardware/os.
If i recall right we use 4 different timing mechanism throughout our
source because we need them.

So if FPC provides a generic higher precise timing routine is should be
documented that it is a starting point only.

But of course it would be nice for every day usage to have a
cross platform call.


More information about the fpc-devel mailing list