[Lazarus] Better implementation of GetTickcount using clock_gettime

Marco van de Voort marcov at stack.nl
Wed Apr 2 14:49:05 CEST 2014


On Wed, Apr 02, 2014 at 02:29:00PM +0200, Marco van de Voort wrote:
> I don't see _RAW and _COARSE anywhere in the mentioned opengroup link.
> Keep in mind this is UNIX gettickcount, not linux gettickcount.

Seems freebsd (7 in this case) also has a load of options, also
further MONOTONIC ones. _PRECISE and FAST.

Seems on FreeBSD UPTIME is the way to go. These are also monotonic, and like
WIndows gettickcount since boot.

/* These macros are also in sys/time.h. */
#if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112
#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 Lazarus mailing list