Yesterday I was tired of thinking about the solution and writing stupid. Today I have a fresh mind and I can look at the problem again. it should be better.
I not sure help you furious programmer... i sorry if not help.
You probably solved the riddle.
The first thing is
mach_absolute_time, which is the right time retrieval function. It can be used to get the current time and then, calculate the nanoseconds count.
But the second thing is this article:
http://nadeausoftware.com/articles/2012/04/c_c_tip_how_measure_elapsed_real_time_benchmarking
It turns out that there is a better solution than
mach_absolute_time, that is, the
gettimeofday function. Although the result has microsecond precision, but it is available on many POSIX systems, including
Linux,
BSD,
OSX,
Solaris and so on. And it is declared in
Unix unit with the name
fpgettimeofday.
Thanks to this, I can simplify the project code and use
QPC and
QPF for Windows, and
fpgettimeofday on other systems (with predefined frequency value). Get the time, calculate nanoseconds count and use the result for
fpnanosleep.
@Thausand: huge thanks! It should do the job.