'\" t .\" SPDX-License-Identifier: 0BSD .\" .TH timespec_get 3 (date) "Linux man-pages (unreleased)" .SH NAME timespec_get, timespec_getres \- ISO C interface to clock and time functions .SH LIBRARY Standard C library .RI ( libc ,\~ \-lc ), .SH SYNOPSIS .nf .B #include .P .BI "int timespec_get(struct timespec *" res ", int " base ); .BI "int timespec_getres(struct timespec *" tp ", int " base ); .fi .SH DESCRIPTION The .BR timespec_get () function stores the current time, based on the specified time base, in the .BR timespec (3type) structure pointed to by .IR res . .P The .BR timespec_getres () function stores the resolution of times retrieved by .BR timespec_get () with the specified time base in the .BR timespec (3type) structure pointed to by .IR tp , if .I tp is non-NULL. For a particular time base, the resolution is constant for the lifetime of the calling process. .P .B 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 .I clock_gettime(CLOCK_REALTIME,\~res) and .IR clock_getres(CLOCK_REALTIME,\~tp) , respectively. Other systems may support additional time bases. .SH RETURN VALUE .BR timespec_get () returns the nonzero .I base if it is a supported time base and the current time was successfully retrieved, or 0 otherwise. .P .BR timespec_getres () returns the nonzero .I base if it is a supported time base, or 0 otherwise. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). .TS allbox; lbx lb lb l l l. Interface Attribute Value T{ .na .nh .BR timespec_get (), .BR timespec_getres () T} Thread safety MT-Safe .TE .SH STANDARDS .TP .BR timespec_get () .TQ .B TIME_UTC C23 (though ISO C doesn't specify the time epoch), POSIX.1-2024. .TP .BR timespec_getres () C23. .SH HISTORY .TP .BR timespec_get () .TQ .B TIME_UTC C11, POSIX.1-2024, glibc 2.16, musl 1.1.10. .TP .BR timespec_getres () C23, glibc 2.34. .SH SEE ALSO .BR clock_gettime (2), .BR clock_getres (2)