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

NAME

6       ntp_gettime, ntp_gettimex  - get time parameters (NTP daemon interface)
7

SYNOPSIS

9       #include <sys/timex.h>
10
11       int ntp_gettime(struct ntptimeval *ntv);
12       int ntp_gettimex(struct ntptimeval *ntv);
13

DESCRIPTION

15       Both  of  these APIs return information to the caller via the ntv argu‐
16       ment, a structure of the following type:
17
18           struct ntptimeval {
19               struct timeval time;    /* Current time */
20               long maxerror;          /* Maximum error */
21               long esterror;          /* Estimated error */
22               long tai;               /* TAI offset */
23
24               /* Further padding bytes allowing for future expansion */
25           };
26
27       The fields of this structure are as follows:
28
29       time   The current time, expressed as a timeval structure:
30
31                  struct timeval {
32                      time_t      tv_sec;   /* Seconds since the Epoch */
33                      suseconds_t tv_usec;  /* Microseconds */
34                  };
35
36       maxerror
37              Maximum error, in microseconds.  This value can  be  initialized
38              by ntp_adjtime(3), and is increased periodically (on Linux: each
39              second), but is clamped to an upper limit (the  kernel  constant
40              NTP_PHASE_MAX, with a value of 16,000).
41
42       esterror
43              Estimated  error,  in  microseconds.   This value can be set via
44              ntp_adjtime(3) to contain an estimate of the difference  between
45              the  system clock and the true time.  This value is not used in‐
46              side the kernel.
47
48       tai    TAI (Atomic International Time) offset.
49
50       ntp_gettime() returns an ntptimeval structure in which the time, maxer‐
51       ror, and esterror fields are filled in.
52
53       ntp_gettimex()  performs  the  same task as ntp_gettime(), but also re‐
54       turns information in the tai field.
55

RETURN VALUE

57       The return values for ntp_gettime() and ntp_gettimex() are as for  adj‐
58       timex(2).   Given  a  correct  pointer argument, these functions always
59       succeed.
60

VERSIONS

62       The ntp_gettime() function is available since glibc 2.1.  The  ntp_get‐
63       timex() function is available since glibc 2.12.
64

ATTRIBUTES

66       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
67       tributes(7).
68
69       ┌────────────────────────────────────────────┬───────────────┬─────────┐
70Interface                                   Attribute     Value   
71       ├────────────────────────────────────────────┼───────────────┼─────────┤
72ntp_gettime(), ntp_gettimex()               │ Thread safety │ MT-Safe │
73       └────────────────────────────────────────────┴───────────────┴─────────┘
74

CONFORMING TO

76       ntp_gettime() is described in the NTP Kernel Application Program Inter‐
77       face.  ntp_gettimex() is a GNU extension.
78

SEE ALSO

80       adjtimex(2), ntp_adjtime(3), time(7)
81
82       NTP "Kernel Application Program Interface"
83http://www.slac.stanford.edu/comp/unix/package/rtems/src/ssrlApps/
84       ntpNanoclock/api.htm⟩
85

COLOPHON

87       This page is part of release 5.12 of the Linux man-pages project.  A
88       description of the project, information about reporting bugs, and the
89       latest version of this page, can be found at
90       https://www.kernel.org/doc/man-pages/.
91
92
93
94Linux                             2021-03-22                    NTP_GETTIME(3)
Impressum