[fpc-devel] NowUTC in the RTL

Marco van de Voort marcov at stack.nl
Fri Dec 9 15:45:37 CET 2011


In our previous episode, Marco van de Voort said:
> In our previous episode, Michael Van Canneyt said:
> > >
> > > But maybe IMHO this kind of stuff should remain out of sysutils, certainly now
> > > it is not entirely clear, and people are still searching for solutions.
> > 
> > That's not the question.
> > 
> > clock_gettime is a linux kernel call. No-one is proposing to add it to sysutils.
> 
> If we decide to use it via libc, we might not have to add it as a syscall.
>  
> > The question is whether clock_gettime is POSIX, and if BSD has it.
> > The linux man page seems to say it is POSIX 2001. My question is if BSD has it.
> 
> FreeBSD has it.  But OS X hasn't it seems, not even in recent versions.

Let's not forget btw that it is not just a matter of the call, the constants
matter too.

E.g. constants for FreeBSD: (even with clock_gettime, it is not guaranteed that
all clock varieties are supported. Can't get that from the manpages).

So while monotonic exists, it seems to be in seconds.  Maybe the precise/fast
 freebsd specific ones have low granularity.

>From manpage:

     The clock_id argument can be one of five values: CLOCK_REALTIME for time
     that increments as a wall clock should, CLOCK_MONOTONIC which
    increments
     in SI seconds, CLOCK_UPTIME which starts at zero when the kernel boots
     and increments monotonically in SI seconds while the machine is
running,
     CLOCK_VIRTUAL for time that increments only when the CPU is running in
     user mode on behalf of the calling process, or CLOCK_PROF for time that
     increments when the CPU is running in user or kernel mode.


and header:

#define CLOCK_REALTIME  0
#ifdef __BSD_VISIBLE
#define CLOCK_VIRTUAL   1
#define CLOCK_PROF      2
#endif
#define CLOCK_MONOTONIC 4
#define CLOCK_UPTIME    5               /* FreeBSD-specific. */
#define CLOCK_UPTIME_PRECISE    7       /* FreeBSD-specific. */
#define CLOCK_UPTIME_FAST       8       /* FreeBSD-specific. */
#define CLOCK_REALTIME_PRECISE  9       /* FreeBSD-specific. */
#define CLOCK_REALTIME_FAST     10      /* FreeBSD-specific. */
#define CLOCK_MONOTONIC_PRECISE 11      /* FreeBSD-specific. */
#define CLOCK_MONOTONIC_FAST    12      /* FreeBSD-specific. */
#define CLOCK_SECOND    13              /* FreeBSD-specific. */
#define CLOCK_THREAD_CPUTIME_ID 14
#endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */




More information about the fpc-devel mailing list