TIMESPEC_GET(3C) | Standard C Library Functions | TIMESPEC_GET(3C) |
timespec_get
,
timespec_getres
— get time
information
#include
<time.h>
int
timespec_get
(struct timespec
*ts, int base);
int
timespec_getres
(struct timespec
*ts, int base);
The
timespec_get
()
function provides access to nanosecond resolution time. The
timespec_getres
()
function provides access to the underlying clock's resolution. The meaning
and source of time is defined by the base argument.
The following values are defined for base:
TIME_UTC
CLOCK_REALTIME
.TIME_MONOTONIC
CLOCK_HIGHRES
and
CLOCK_MONOTONIC
clocks or calling
gethrtime(3C).TIME_THREAD_ACTIVE
This is logically equivalent to using the
CLOCK_THREAD_CPUTIME_ID
clock . This clock is
optional and may not be present on other platforms.
TIME_THREAD_ACTIVE_USR
TIME_THREAD_ACTIVE
clock, except it only counts user time that has elapsed. This is logically
equivalent to using the CLOCK_VIRTUAL
clock or
calling gethrvtime(3C). This
clock is an extension and may not be available on other platforms.TIME_ACTIVE
For the definition of the timespec structure, see time.h(3HEAD).
Upon successful completion, the
timespec_get
() and
timespec_getres
() functions return the passed in
value of base. Otherwise,
0 is returned to
represent an error.
Unlike other functions, the timespec_get
()
and timespec_getres
() functions are not defined to
set errno. However, the
timespec_get
() and
timespec_getres
() functions will fail if:
clock_getres(3C), clock_gettime(3C), gethrtime(3C), gethrvtime(3C), time.h(3HEAD), attributes(7)
January 12, 2025 | OmniOS |