1CLOCK_GETRES(2)            Linux Programmer's Manual           CLOCK_GETRES(2)
2
3
4

NAME

6       clock_getres, clock_gettime, clock_settime - clock and time functions
7

SYNOPSIS

9       #include <time.h>
10
11       int clock_getres(clockid_t clockid, struct timespec *res);
12
13       int clock_gettime(clockid_t clockid, struct timespec *tp);
14       int clock_settime(clockid_t clockid, const struct timespec *tp);
15
16       Link with -lrt (only for glibc versions before 2.17).
17
18   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20       clock_getres(), clock_gettime(), clock_settime():
21           _POSIX_C_SOURCE >= 199309L
22

DESCRIPTION

24       The  function  clock_getres()  finds  the resolution (precision) of the
25       specified clock clockid, and, if res is  non-NULL,  stores  it  in  the
26       struct timespec pointed to by res.  The resolution of clocks depends on
27       the implementation and cannot be configured by  a  particular  process.
28       If  the  time value pointed to by the argument tp of clock_settime() is
29       not a multiple of res, then it is truncated to a multiple of res.
30
31       The functions clock_gettime() and clock_settime() retrieve and set  the
32       time of the specified clock clockid.
33
34       The  res  and  tp  arguments  are  timespec structures, as specified in
35       <time.h>:
36
37           struct timespec {
38               time_t   tv_sec;        /* seconds */
39               long     tv_nsec;       /* nanoseconds */
40           };
41
42       The clockid argument is the identifier of the particular clock on which
43       to  act.   A  clock  may  be system-wide and hence visible for all pro‐
44       cesses, or per-process  if  it  measures  time  only  within  a  single
45       process.
46
47       All  implementations  support the system-wide real-time clock, which is
48       identified by CLOCK_REALTIME.  Its time represents seconds and nanosec‐
49       onds  since the Epoch.  When its time is changed, timers for a relative
50       interval are unaffected, but timers for an absolute point in  time  are
51       affected.
52
53       More  clocks may be implemented.  The interpretation of the correspond‐
54       ing time values and the effect on timers is unspecified.
55
56       Sufficiently recent versions of glibc and the Linux kernel support  the
57       following clocks:
58
59       CLOCK_REALTIME
60              A  settable  system-wide  clock  that measures real (i.e., wall-
61              clock) time.  Setting this  clock  requires  appropriate  privi‐
62              leges.   This  clock  is  affected by discontinuous jumps in the
63              system time (e.g., if the system administrator manually  changes
64              the clock), and by the incremental adjustments performed by adj‐
65              time(3) and NTP.
66
67       CLOCK_REALTIME_ALARM (since Linux 3.0; Linux-specific)
68              Like CLOCK_REALTIME, but not settable.  See timer_create(2)  for
69              further details.
70
71       CLOCK_REALTIME_