CKTIS / C
timespec_getres — time-base resolution
The C23 function timespec_getres queries the resolution of time supplied by timespec_get, rather than the current time.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <time.h>
int timespec_getres(struct timespec *ts, int base);timespec_getres from <time.h> stores the selected time base's resolution in struct timespec: tv_sec represents seconds and tv_nsec nanoseconds. It does not measure clock accuracy.
For a supported base, it returns base; otherwise it returns 0. TIME_UTC is a standard time base. ts may be null: the function then only checks support. Results for the same base are identical within one program execution.
This is a C23 function. A compiler flag does not guarantee availability in the runtime library; production runtime support has not been attested.
Examples
#include <stdio.h>
#include <time.h>
int main(void)
{
struct timespec resolution;
if (timespec_getres(&resolution, TIME_UTC) != TIME_UTC) return 1;
puts("TIME_UTC supported");
return 0;
}
Result
TIME_UTC supported
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.