Debian Codegraph @

upstream/debian-unstable/man3/ntp_gettime.3

raw
1 '\" t
2 .\" Copyright 2016, Michael Kerrisk <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH ntp_gettime 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 ntp_gettime, ntp_gettimex \- get time parameters (NTP daemon interface)
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <sys/timex.h>
16 .P
17 .BI "int ntp_gettime(struct ntptimeval *" ntv );
18 .BI "int ntp_gettimex(struct ntptimeval *" ntv );
19 .fi
20 .SH DESCRIPTION
21 Both of these APIs return information to the caller via the
22 .I ntv
23 argument, a structure of the following type:
24 .P
25 .in +4n
26 .EX
27 struct ntptimeval {
28 struct timeval time; /* Current time */
29 long maxerror; /* Maximum error */
30 long esterror; /* Estimated error */
31 long tai; /* TAI offset */
32 \&
33 /* Further padding bytes allowing for future expansion */
34 };
35 .EE
36 .in
37 .P
38 The fields of this structure are as follows:
39 .TP
40 .I time
41 The current time, expressed as a
42 .I timeval
43 structure:
44 .IP
45 .in +4n
46 .EX
47 struct timeval {
48 time_t tv_sec; /* Seconds since the Epoch */
49 suseconds_t tv_usec; /* Microseconds */
50 };
51 .EE
52 .in
53 .TP
54 .I maxerror
55 Maximum error, in microseconds.
56 This value can be initialized by
57 .BR ntp_adjtime (3),
58 and is increased periodically (on Linux: each second),
59 but is clamped to an upper limit (the kernel constant
60 .BR NTP_PHASE_MAX ,
61 with a value of 16,000).
62 .TP
63 .I esterror
64 Estimated error, in microseconds.
65 This value can be set via
66 .BR ntp_adjtime (3)
67 to contain an estimate of the difference between the system clock
68 and the true time.
69 This value is not used inside the kernel.
70 .TP
71 .I tai
72 TAI (Atomic International Time) offset.
73 .P
74 .BR ntp_gettime ()
75 returns an
76 .I ntptimeval
77 structure in which the
78 .IR time ,
79 .IR maxerror ,
80 and
81 .I esterror
82 fields are filled in.
83 .P
84 .BR ntp_gettimex ()
85 performs the same task as
86 .BR ntp_gettime (),
87 but also returns information in the
88 .I tai
89 field.
90 .SH RETURN VALUE
91 The return values for
92 .BR ntp_gettime ()
93 and
94 .BR ntp_gettimex ()
95 are as for
96 .BR adjtimex (2).
97 Given a correct pointer argument, these functions always succeed.
98 .\" FIXME . the info page incorrectly describes the return values.
99 .SH ATTRIBUTES
100 For an explanation of the terms used in this section, see
101 .BR attributes (7).
102 .TS
103 allbox;
104 lbx lb lb
105 l l l.
106 Interface Attribute Value
107 T{
108 .na
109 .nh
110 .BR ntp_gettime (),
111 .BR ntp_gettimex ()
112 T} Thread safety MT-Safe
113 .TE
114 .SH STANDARDS
115 .TP
116 .BR ntp_gettime ()
117 NTP Kernel Application Program Interface.
118 .TP
119 .BR ntp_gettimex ()
120 GNU.
121 .SH HISTORY
122 .TP
123 .BR ntp_gettime ()
124 glibc 2.1.
125 .TP
126 .BR ntp_gettimex ()
127 glibc 2.12.
128 .SH SEE ALSO
129 .BR adjtimex (2),
130 .BR ntp_adjtime (3),
131 .BR time (7)
132 .P
133 .ad l
134 .UR http:\://www.slac.stanford.edu/comp/unix/\:package/\:rtems/\:src/\:ssrlApps/\:ntpNanoclock/\:api.htm
135 NTP "Kernel Application Program Interface"
136 .UE