table of contents
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 <time.h>
int timespec_get(struct timespec *res, int base); int timespec_getres(struct timespec *tp, int base);
DESCRIPTION¶
The timespec_get() function stores the current time, based on the specified time base, in the timespec(3type) structure pointed to by res.
The timespec_getres() function stores the resolution of times retrieved by timespec_get() with the specified time base in the timespec(3type) structure pointed to by tp, if tp is non-NULL. For a particular time base, the resolution is constant for the lifetime of the calling process.
TIME_UTC is always a supported time base, and is the only time base supported on Linux. The time and resolution in this time base are the same as those retrieved by clock_gettime(CLOCK_REALTIME, res) and clock_getres(CLOCK_REALTIME, tp), respectively. Other systems may support additional time bases.
RETURN VALUE¶
timespec_get() returns the nonzero base if it is a supported time base and the current time was successfully retrieved, or 0 otherwise.
timespec_getres() returns the nonzero base if it is a supported time base, or 0 otherwise.
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¶
2025-02-10 | Linux man-pages (unreleased) |