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