timespec_get(3) — Linux manual page

NAME | LIBRARY | SYNOPSIS | DESCRIPTION | RETURN VALUE | ERRORS | ATTRIBUTES | STANDARDS | HISTORY | SEE ALSO | COLOPHON

timespec_get(3)          Library Functions Manual         timespec_get(3)

NAME         top

       timespec_get, timespec_getres - ISO C interface to clock and time
       functions

LIBRARY         top

       Standard C library (libc, -lc),

SYNOPSIS         top

       #include <time.h>

       int timespec_get(struct timespec *res, int base);
       int timespec_getres(struct timespec *tp, int base);

DESCRIPTION         top

       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         top

       On success, base is returned.  On error, -1 is returned.

ERRORS         top

       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         top

       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         top

       timespec_get()
       TIME_UTC
              C23 (though ISO C doesn't specify the time epoch),
              POSIX.1-2024.

       timespec_getres()
              C23.

HISTORY         top

       timespec_get()
       TIME_UTC
              C11, POSIX.1-2024, glibc 2.16, musl 1.1.10.

       timespec_getres()
              C23, glibc 2.34.

SEE ALSO         top

       clock_gettime(2), clock_getres(2)

COLOPHON         top

       This page is part of the man-pages (Linux kernel and C library
       user-space interface documentation) project.  Information about
       the project can be found at 
       ⟨https://www.kernel.org/doc/man-pages/⟩.  If you have a bug report
       for this manual page, see
       ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.
       This page was obtained from the tarball man-pages-6.10.tar.gz
       fetched from
       ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on
       2025-02-02.  If you discover any rendering problems in this HTML
       version of the page, or you believe there is a better or more up-
       to-date source for the page, or you have corrections or
       improvements to the information in this COLOPHON (which is not
       part of the original manual page), send a mail to
       man-pages@man7.org

Linux man-pages 6.10            2024-09-08                timespec_get(3)