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