1NTP_GETTIME(3) Linux Programmer's Manual NTP_GETTIME(3)
2
3
4
6 ntp_gettime, ntp_gettimex - get time parameters (NTP daemon interface)
7
9 #include <sys/timex.h>
10
11 int ntp_gettime(struct ntptimeval *ntv);
12
13 int ntp_gettimex(struct ntptimeval *ntv);
14
16 Both of these APIs return information to the caller via the ntv argu‐
17 ment, a structure of the following type:
18
19 struct ntptimeval {
20 struct timeval time; /* Current time */
21 long int maxerror; /* Maximum error */
22 long int esterror; /* Estimated error */
23 long int tai; /* TAI offset */
24
25 /* Further padding bytes allowing for future expansion */
26 };
27
28 The fields of this structure are as follows:
29
30 time The current time, expressed as a timeval structure:
31
32 struct timeval {
33 time_t tv_sec; /* Seconds since the Epoch */
34 suseconds_t tv_usec; /* Microseconds */
35 };
36
37 maxerror
38 Maximum error, in microseconds. This value can be initialized
39 by ntp_adjtime(3), and is increased periodically (on Linux: each
40 second), but is clamped to an upper limit (the kernel constant
41 NTP_PHASE_MAX, with a value of 16,000).
42
43 esterror
44 Estimated error, in microseconds. This value can be set via
45 ntp_adjtime(3) to contain an estimate of the difference between
46 the system clock and the true time. This value is not used
47 inside the kernel.
48
49 tai TAI (Atomic International Time) offset.
50
51 ntp_gettime() returns an ntptimeval structure in which the time, maxer‐
52 ror, and esterror fields are filled in.
53
54 ntp_gettimex() performs the same task as ntp_gettime(), but also
55 returns information in the tai field.
56
58 The return values for ntp_gettime() and ntp_gettimex() are as for adj‐
59 timex(2). Given a correct pointer argument, these functions always
60 succeed.
61
63 The ntp_gettime() function is available since glibc 2.1. The ntp_get‐
64 timex() function is available since glibc 2.12.
65
67 For an explanation of the terms used in this section, see
68 attributes(7).
69
70 ┌───────────────────────────────┬───────────────┬─────────┐
71 │Interface │ Attribute │ Value │
72 ├───────────────────────────────┼───────────────┼─────────┤
73 │ntp_gettime(), ntp_gettimex() │ Thread safety │ MT-Safe │
74 └───────────────────────────────┴───────────────┴─────────┘
76 ntp_gettime() is described in the NTP Kernel Application Program Inter‐
77 face. ntp_gettimex() is a GNU extension.
78
80 adjtimex(2), ntp_adjtime(3), time(7)
81
82 NTP "Kernel Application Program Interface"
83 ⟨http://www.slac.stanford.edu/comp/unix/package/rtems/src/ssrlApps/
84 ntpNanoclock/api.htm⟩
85
87 This page is part of release 5.07 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 2020-06-09 NTP_GETTIME(3)