]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/ntp_gettime.3
err.3: EXAMPLES: use EXIT_FAILURE rather than 1 as exit status
[thirdparty/man-pages.git] / man3 / ntp_gettime.3
CommitLineData
6d78bc96
MK
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.\"
4b8c67d9 25.TH NTP_GETTIME 3 2017-09-15 "Linux" "Linux Programmer's Manual"
6d78bc96
MK
26.SH NAME
27ntp_gettime, ntp_gettimex \- get time parameters (NTP daemon interface)
28.SH SYNOPSIS
29.nf
30.B #include <sys/timex.h>
dbfe9c70 31.PP
6d78bc96 32.BI "int ntp_gettime(struct ntptimeval *" ntv );
dbfe9c70 33.PP
6d78bc96
MK
34.BI "int ntp_gettimex(struct ntptimeval *" ntv );
35.fi
36.SH DESCRIPTION
37Both of these APIs return information to the caller via the
38.I ntv
39argument, a structure of the following type:
847e0d88 40.PP
6d78bc96 41.in +4n
b8302363 42.EX
6d78bc96
MK
43struct 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};
b8302363 51.EE
6d78bc96 52.in
847e0d88 53.PP
6d78bc96
MK
54The fields of this structure are as follows:
55.TP
56.I time
57The current time, expressed as a
58.I timeval
59structure:
847e0d88 60.IP
6d78bc96 61.in +4n
b8302363 62.EX
6d78bc96
MK
63struct timeval {
64 time_t tv_sec; /* Seconds since the Epoch */
65 suseconds_t tv_usec; /* Microseconds */
66};
e646a1ba 67.EE
6d78bc96 68.in
e646a1ba 69.IP
6d78bc96
MK
70.TP
71.I maxerror
72Maximum error, in microseconds.
b5133e9a 73This value can be initialized by
6d78bc96
MK
74.BR ntp_adjtime (3),
75and is increased periodically (on Linux: each second),
76but is clamped to an upper limit (the kernel constant
77.BR NTP_PHASE_MAX ,
78with a value of 16,000).
79.TP
80.I esterror
81Estimated error, in microseconds.
82This value can be set via
83.BR ntp_adjtime (3)
84to contain an estimate of the difference between the system clock
85and the true time.
86This value is not used inside the kernel.
87.TP
88.I tai
89TAI (Atomic International Time) offset.
90.PP
91.BR ntp_gettime ()
92returns an
93.I ntptimeval
94structure in which the
95.IR time ,
96.IR maxerror ,
97and
98.IR esterror
99fields are filled in.
100.PP
101.BR ntp_gettimex ()
102performs the same task as
103.BR ntp_gettime (),
104but also returns information in the
105.I tai
106field.
107.SH RETURN VALUE
108The return values for
109.BR ntp_gettime ()
110and
111.BR ntp_gettimex ()
112are as for
113.BR adjtimex (2).
b5133e9a 114Given a correct pointer argument, these functions always succeed.
6d78bc96 115.\" FIXME . the info page incorrectly describes the return values.
355b6107
MK
116.SH VERSIONS
117The
118.BR ntp_gettime ()
119function is available since glibc 2.1.
120The
121.BR ntp_gettimex ()
122function is available since glibc 2.12.
85c30f7e
MK
123.SH ATTRIBUTES
124For an explanation of the terms used in this section, see
125.BR attributes (7).
126.TS
127allbox;
128lbw30 lb lb
129l l l.
130Interface Attribute Value
131T{
132.BR ntp_gettime (),
133.BR ntp_gettimex ()
134T} Thread safety MT-Safe
135.TE
6d78bc96
MK
136.SH CONFORMING TO
137.BR ntp_gettime ()
138is described in the NTP Kernel Application Program Interface.
139.BR ntp_gettimex ()
140is a GNU extension.
141.SH SEE ALSO
bba4bbbd 142.BR adjtimex (2),
6d78bc96
MK
143.BR ntp_adjtime (3),
144.BR time (7)
847e0d88 145.PP
6d78bc96
MK
146.ad l
147.UR http://www.slac.stanford.edu/comp/unix/\:package/\:rtems/\:src/\:ssrlApps/\:ntpNanoclock/\:api.htm
148NTP "Kernel Application Program Interface"
149.UE