p The .Fn clock_gettime function stores the time of the clock identified by .Fa clock_id into the location specified by .Fa tp .
p The .Fn clock_getres function stores the resolution of the clock identified by .Fa clock_id into the location specified by .Fa res , unless .Fa res is .Dv NULL .
p The following .Fa clock_id values are supported: l -tag -width CLOCK_MONOTONIC t Dv CLOCK_REALTIME identifies the realtime clock for the system. For this clock, the values specified by .Fn clock_settime and obtained by .Fn clock_gettime represent the amount of time (in seconds and nanoseconds) since 00:00 Universal Coordinated Time, January 1, 1970. t Dv CLOCK_MONOTONIC identifies a clock that increases at a steady rate (monotonically). This clock is not affected by calls to .Xr adjtime 2 and .Xr settimeofday 2 and will fail with an .Er EINVAL error if it's the clock specified in a call to .Fn clock_settime . The origin of the clock is unspecified. t Dv CLOCK_VIRTUAL identifies a clock that increments only when the CPU is running in user mode on behalf of the calling process. t Dv CLOCK_PROF identifies a clock that increments when the CPU is running in user or kernel mode on behalf of the calling process. t Dv CLOCK_PROCESS_CPUTIME_ID identifies a per process clock based on tick values. This clock is not settable. t Dv CLOCK_THREAD_CPUTIME_ID identifies a per thread clock based on tick values. This clock is not settable. .El
p If the calling user is not the super-user, the .Fn clock_settime system call will fail, and the .Fn clock_settime function in the standard C library will try to use the .Xr clockctl 4 device if present, thus making it possible for non privileged users to set the system time. If .Xr clockctl 4 is not present or not accessible, then .Fn clock_settime returns .Er EPERM . .Sh RETURN VALUES A value of 0 is returned on success. Otherwise, a value of -1 is returned and .Va errno is set to indicate the error. .Sh ERRORS The .Fn clock_settime , .Fn clock_gettime and .Fn clock_getres functions will fail if: l -tag -width Er t Bq Er EINVAL The .Fa clock_id argument does not specify a known clock. t Bq Er ENOSYS The function is not supported by this implementation. .El
p The .Fn clock_settime function will fail if: l -tag -width Er t Bq Er EINVAL The .Fa tp argument is outside the range for the specified clock, .Fa clock_id ; or the .Fa tp argument specified a nanosecond value less than zero of greater than or equal 1000 million; or the .Fa clock_id argument is a clock that can not be adjusted. t Bq Er EPERM The calling process does not have the appropriate privilege to set the specified clock, .Fa clock_id . .El
p
The
.Fn clock_gettime
function will fail if:
l -tag -width Er t Bq Er EFAULT The
.Fa tp
argument specifies an address that is not a valid part of the process address
space.
.El
.Sh SEE ALSO
.Xr ctime 3 ,
.Xr time 3 ,
.Xr timer_gettime 3 ,
.Xr clockctl 4
.Sh STANDARDS
The
.Fn clock_settime ,
.Fn clock_gettime
and
.Fn clock_getres
functions conform to
.St -p1003.1b-93 .