Calico
wclock.h File Reference

Functions for accessing a monotonic wall clock. More...

Functions

static double get_wclock (const wclock *clock)
 Retrieve the time from a monotonic wall clock in seconds. More...
 
static double get_wclock_res (const wclock *clock)
 Obtain the resolution of the monotonic wall clock in seconds. More...
 
static int init_wclock (wclock *clock)
 Initialize a value needed to access the monotonic wall clock. More...
 

Detailed Description

Functions for accessing a monotonic wall clock.

Note: on systems other than Windows or Mac OS X, it is strongly recommended to define _POSIX_C_SOURCE to a value of at least 199309L before the inclusion of this header or any system header.

Function Documentation

double get_wclock ( const wclock *  clock)
inlinestatic

Retrieve the time from a monotonic wall clock in seconds.

Parameters
clockAn wclock value previously initialized by init_wclock.
Returns
Duration relative to some unspecified reference time in seconds. If an error occurs, NAN is returned.

Due to the use of double-precision floating point numbers, the precision is at worst (for an ideal system with hundreds of years in uptime) limited to about a few microseconds. In practice, it is usually much less.

double get_wclock_res ( const wclock *  clock)
inlinestatic

Obtain the resolution of the monotonic wall clock in seconds.

Parameters
clockAn wclock value previously initialized by init_wclock.
Returns
Duration relative to some unspecified reference time in seconds. If an error occurs, NAN is returned.
int init_wclock ( wclock *  clock)
inlinestatic

Initialize a value needed to access the monotonic wall clock.

The clock does not need to be deinitialized.

Parameters
clockAn existing wclock value to be initialized.
Returns
Zero on success, nonzero on failure.