]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/ntp_gettime.3
exec.3: Minor wording fix in subsection title
[thirdparty/man-pages.git] / man3 / ntp_gettime.3
1 .\" Copyright (c) 2016 by Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH NTP_GETTIME 3 2017-09-15 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 ntp_gettime, ntp_gettimex \- get time parameters (NTP daemon interface)
28 .SH SYNOPSIS
29 .nf
30 .B #include <sys/timex.h>
31 .PP
32 .BI "int ntp_gettime(struct ntptimeval *" ntv );
33 .PP
34 .BI "int ntp_gettimex(struct ntptimeval *" ntv );
35 .fi
36 .SH DESCRIPTION
37 Both of these APIs return information to the caller via the
38 .I ntv
39 argument, a structure of the following type:
40 .PP
41 .in +4n
42 .EX
43 struct ntptimeval {
44 struct timeval time; /* Current time */
45 long int maxerror; /* Maximum error */
46 long int esterror; /* Estimated error */
47 long int tai; /* TAI offset */
48
49 /* Further padding bytes allowing for future expansion */
50 };
51 .EE
52 .in
53 .PP
54 The fields of this structure are as follows:
55 .TP
56 .I time
57 The current time, expressed as a
58 .I timeval
59 structure:
60 .IP
61 .in +4n
62 .EX
63 struct timeval {
64 time_t tv_sec; /* Seconds since the Epoch */
65 suseconds_t tv_usec; /* Microseconds */
66 };
67 .EE
68 .in
69 .IP
70 .TP
71 .I maxerror
72 Maximum error, in microseconds.
73 This value can be initialized by
74 .BR ntp_adjtime (3),
75 and is increased periodically (on Linux: each second),
76 but is clamped to an upper limit (the kernel constant
77 .BR NTP_PHASE_MAX ,
78 with a value of 16,000).
79 .TP
80 .I esterror
81 Estimated error, in microseconds.
82 This value can be set via
83 .BR ntp_adjtime (3)
84 to contain an estimate of the difference between the system clock
85 and the true time.
86 This value is not used inside the kernel.
87 .TP
88 .I tai
89 TAI (Atomic International Time) offset.
90 .PP
91 .BR ntp_gettime ()
92 returns an
93 .I ntptimeval
94 structure in which the
95 .IR time ,
96 .IR maxerror ,
97 and
98 .IR esterror
99 fields are filled in.
100 .PP
101 .BR ntp_gettimex ()
102 performs the same task as
103 .BR ntp_gettime (),
104 but also returns information in the
105 .I tai
106 field.
107 .SH RETURN VALUE
108 The return values for
109 .BR ntp_gettime ()
110 and
111 .BR ntp_gettimex ()
112 are as for
113 .BR adjtimex (2).
114 Given a correct pointer argument, these functions always succeed.
115 .\" FIXME . the info page incorrectly describes the return values.
116 .SH VERSIONS
117 The
118 .BR ntp_gettime ()
119 function is available since glibc 2.1.
120 The
121 .BR ntp_gettimex ()
122 function is available since glibc 2.12.
123 .SH ATTRIBUTES
124 For an explanation of the terms used in this section, see
125 .BR attributes (7).
126 .TS
127 allbox;
128 lbw30 lb lb
129 l l l.
130 Interface Attribute Value
131 T{
132 .BR ntp_gettime (),
133 .BR ntp_gettimex ()
134 T} Thread safety MT-Safe
135 .TE
136 .SH CONFORMING TO
137 .BR ntp_gettime ()
138 is described in the NTP Kernel Application Program Interface.
139 .BR ntp_gettimex ()
140 is a GNU extension.
141 .SH SEE ALSO
142 .BR adjtimex (2)
143 .BR ntp_adjtime (3),
144 .BR time (7)
145 .PP
146 .ad l
147 .UR http://www.slac.stanford.edu/comp/unix/\:package/\:rtems/\:src/\:ssrlApps/\:ntpNanoclock/\:api.htm
148 NTP "Kernel Application Program Interface"
149 .UE