Changes.old: Add missing entry in 5.13 changelog
[man-pages.git] / man3 / ntp_gettime.3
blob71e619609c6b21b53f079221f3dbbbaa5e9bbd8b
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 2021-03-22 "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 .BI "int ntp_gettimex(struct ntptimeval *" ntv );
34 .fi
35 .SH DESCRIPTION
36 Both of these APIs return information to the caller via the
37 .I ntv
38 argument, a structure of the following type:
39 .PP
40 .in +4n
41 .EX
42 struct ntptimeval {
43     struct timeval time;    /* Current time */
44     long maxerror;          /* Maximum error */
45     long esterror;          /* Estimated error */
46     long tai;               /* TAI offset */
48     /* Further padding bytes allowing for future expansion */
50 .EE
51 .in
52 .PP
53 The fields of this structure are as follows:
54 .TP
55 .I time
56 The current time, expressed as a
57 .I timeval
58 structure:
59 .IP
60 .in +4n
61 .EX
62 struct timeval {
63     time_t      tv_sec;   /* Seconds since the Epoch */
64     suseconds_t tv_usec;  /* Microseconds */
66 .EE
67 .in
68 .TP
69 .I maxerror
70 Maximum error, in microseconds.
71 This value can be initialized by
72 .BR ntp_adjtime (3),
73 and is increased periodically (on Linux: each second),
74 but is clamped to an upper limit (the kernel constant
75 .BR NTP_PHASE_MAX ,
76 with a value of 16,000).
77 .TP
78 .I esterror
79 Estimated error, in microseconds.
80 This value can be set via
81 .BR ntp_adjtime (3)
82 to contain an estimate of the difference between the system clock
83 and the true time.
84 This value is not used inside the kernel.
85 .TP
86 .I tai
87 TAI (Atomic International Time) offset.
88 .PP
89 .BR ntp_gettime ()
90 returns an
91 .I ntptimeval
92 structure in which the
93 .IR time ,
94 .IR maxerror ,
95 and
96 .IR esterror
97 fields are filled in.
98 .PP
99 .BR ntp_gettimex ()
100 performs the same task as
101 .BR ntp_gettime (),
102 but also returns information in the
103 .I tai
104 field.
105 .SH RETURN VALUE
106 The return values for
107 .BR ntp_gettime ()
109 .BR ntp_gettimex ()
110 are as for
111 .BR adjtimex (2).
112 Given a correct pointer argument, these functions always succeed.
113 .\" FIXME . the info page incorrectly describes the return values.
114 .SH VERSIONS
116 .BR ntp_gettime ()
117 function is available since glibc 2.1.
119 .BR ntp_gettimex ()
120 function is available since glibc 2.12.
121 .SH ATTRIBUTES
122 For an explanation of the terms used in this section, see
123 .BR attributes (7).
124 .ad l
127 allbox;
128 lbx lb lb
129 l l l.
130 Interface       Attribute       Value
132 .BR ntp_gettime (),
133 .BR ntp_gettimex ()
134 T}      Thread safety   MT-Safe
138 .sp 1
139 .SH CONFORMING TO
140 .BR ntp_gettime ()
141 is described in the NTP Kernel Application Program Interface.
142 .BR ntp_gettimex ()
143 is a GNU extension.
144 .SH SEE ALSO
145 .BR adjtimex (2),
146 .BR ntp_adjtime (3),
147 .BR time (7)
149 .ad l
150 .UR http://www.slac.stanford.edu/comp/unix/\:package/\:rtems/\:src/\:ssrlApps/\:ntpNanoclock/\:api.htm
151 NTP "Kernel Application Program Interface"