CLOCK_SETTIME(2) | System Calls Manual | CLOCK_SETTIME(2) |
int
clock_settime(clockid_t clock_id, const struct timespec *tp);
int
clock_gettime(clockid_t clock_id, struct timespec *tp);
int
clock_getres(clockid_t clock_id, struct timespec *res);
The clock_gettime() function stores the time of the clock identified by clock_id into the location specified by tp.
The clock_getres() function stores the resolution of the clock identified by clock_id into the location specified by res, unless res is NULL.
A clock_id of CLOCK_REALTIME identifies the realtime clock for the system. For this clock, the values specified by clock_settime() and obtained by clock_gettime() represent the amount of time (in seconds and nanoseconds) since 00:00 Universal Coordinated Time, January 1, 1970.
A clock_id of CLOCK_MONOTONIC identifies a clock that increases at a steady rate (monotonically). This clock is not affected by calls to adjtime(2) and settimeofday(2) and will fail with an EINVAL error if it's the clock specified in a call to clock_settime(). The origin of the clock is unspecified.
If the calling user is not the super-user, then the clock_settime() function in the standard C library will try to use the clockctl(4) device if present, thus making possible for non privileged users to set the system time. If clockctl(4) is not present or not accessible, then clock_settime() reverts to the clock_settime() system call, which is restricted to the super user.
The clock_settime() function will fail if:
The clock_gettime() function will fail if:
February 11, 1999 | NetBSD 6.1 |