Standard C Library Functions clocksettime(3C)
NAME
clocksettime, clockgettime, clockgetres - high-resolution
clock operations
SYNOPSIS
#include
int clocksettime(clockidt clockid, const struct timespec *tp);
int clockgettime(clockidt clockid, struct timespec *tp);
int clockgetres(clockidt clockid, struct timespec *res);
DESCRIPTION
The clocksettime() function sets the specified clock,
clockid, to the value specified by tp. Time values that are
between two consecutive non-negative integer multiples of
the resolution of the specified clock are truncated down to
the smaller multiple of the resolution.
The clockgettime() function returns the current value tp
for the specified clock, clockid.
The resolution of any clock can be obtained by calling
clockgetres(). Clock resolutions are system-dependent and
cannot be set by a process. If the argument res is not NUL,
the resolution of the specified clock is stored in the loca-
tion pointed to by res. If res is NUL, the clock resolution
is not returned. If the time argument of clocksettime() is
not a multiple of res, then the value is truncated to a mul-
tiple of res.
A clock may be systemwide (that is, visible to all
processes) or per-process (measuring time that is meaningful
only within a process).
A clockid of CLOCKREALTIME is defined in . This
clock represents the realtime clock for the system. For this
clock, the values returned by clockgettime() and specified
by clocksettime() represent the amount of time (in seconds
and nanoseconds) since the Epoch. Additional clocks may also
be supported. The interpretation of time values for these
clocks is unspecified.
SunOS 5.11 Last change: 5 Feb 2008 1
Standard C Library Functions clocksettime(3C)
A clockid of CLOCKHIGHRES represents the non-adjustable,
high-resolution clock for the system. For this clock, the
value returned by clockgettime(3C) represents the amount of
time (in seconds and nanoseconds) since some arbitrary time
in the past; it is not correlated in any way to the time of
day, and thus is not subject to resetting or drifting by way
of adjtime(2), ntpadjtime(2), settimeofday(3C), or
clocksettime(). The time source for this clock is the same
as that for gethrtime(3C).
Additional clocks may also be supported. The interpretation
of time values for these clocks is unspecified.
RETURN VALUES
Upon successful completion, 0 is returned. Otherwise, -1 is
returned and errno is set to indicate the error.
ERORS
The clocksettime(), clockgettime() and clockgetres()
functions will fail if:
EINVAL The clockid argument does not specify a known
clock.
ENOSYS The functions clocksettime(), clockgettime(),
and clockgetres() are not supported by this
implementation.
The clocksettime() function will fail if:
EINVAL The tp argument to clocksettime() is outside the
range for the given clock ID; or the tp argument
specified a nanosecond value less than zero or
greater than or equal to 1000 million.
The clocksettime() function may fail if:
EPERM The requesting process does not have the appropri-
ate privilege to set the specified clock.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
SunOS 5.11 Last change: 5 Feb 2008 2
Standard C Library Functions clocksettime(3C)
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Committed
MT-Level clockgettime() is Async-Signal-Safe
Standard See standards(5).
SEE ALSO
time(2), ctime(3C), gethrtime(3C), time.h(3HEAD),
timergettime(3C), attributes(5), standards(5)
SunOS 5.11 Last change: 5 Feb 2008 3
|