timespec_get(3) Library Functions Manual timespec_get(3) NAME timespec_get, timespec_getres - ISO C interface to clock and time functions LIBRARY Standard C library (libc, -lc), SYNOPSIS #include int timespec_get(struct timespec *res, int base); int timespec_getres(struct timespec *tp, int base); DESCRIPTION timespec_get(tp, TIME_UTC) is defined as clock_gettime(CLOCK_REALTIME, tp). timespec_getres(res, TIME_UTC) is equivalent to clock_getres(CLOCK_REALTIME, res). TIME_UTC is universally guaranteed to be a valid base, and is the only one supported under Linux. Some other systems support different time bases. RETURN VALUE On success, base is returned. On error, -1 is returned. ERRORS Some C libraries may set errno to the same value as would be set by clock_gettime(2) or clock_getres(2). Neither C nor POSIX specify this, but they don't really indicate it shouldn't happen, either. Don't rely on this. ATTRIBUTES For an explanation of the terms used in this section, see attributes(7). +--------------------------------------------+---------------+---------+ |Interface | Attribute | Value | +--------------------------------------------+---------------+---------+ |timespec_get (), timespec_getres () | Thread safety | MT-Safe | +--------------------------------------------+---------------+---------+ STANDARDS timespec_get() TIME_UTC C23 (though ISO C doesn't specify the time epoch), POSIX.1-2024. timespec_getres() C23. HISTORY timespec_get() TIME_UTC C11, POSIX.1-2024, glibc 2.16, musl 1.1.10. timespec_getres() C23, glibc 2.34. SEE ALSO clock_gettime(2), clock_getres(2) Linux man-pages 6.10 2024-09-08 timespec_get(3)