summaryrefslogtreecommitdiffstats
path: root/lib/libc/sys/ntp_gettime.2
blob: b74c3d9ba9e7703de48e0b0c073722c7eea71e2d (plain)
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
.\"
.\" Copyright (c) 2003 Tom Rhodes
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd June 21, 2003
.Dt NTP_GETTIME 2
.Os
.Sh NAME
.Nm ntp_gettime
.Nd NTP user application interface
.Sh SYNOPSIS
.In sys/timex.h
.Ft int
.Fn ntp_gettime "struct ntptimeval *ntv"
.Sh DESCRIPTION
The time returned by
.Fn ntp_gettime
is in a
.Vt timespec
structure, but may be in either microsecond
(seconds and microseconds) or nanosecond (seconds and nanoseconds) format.
The particular format in use is determined by the
.Dv STA_NANO
bit of the status
word returned by the
.Fn ntp_adjtime
system call.
.Fn ntp_gettime
has as argument a pointer to the
.Vt ntptimeval
structure with the following members:
.Bd -literal
struct ntptimeval {
	struct timespec time;	/* current time (ns) (ro) */
	long maxerror;		/* maximum error (us) (ro) */
	long esterror;		/* estimated error (us) (ro) */
	long tai;		/* TAI-UTC offset */
	int time_state;		/* time status */
};
.Ed
.Pp
These are understood as:
.Bl -tag -width ".Va time_state"
.It Va time
Current time (read-only).
.It Va maxerror
Maximum error in microseconds (read-only).
.It Va esterror
Estimated error in microseconds (read-only).
.It Va tai
Offset in seconds between the TAI and UTC time scales.
This offset is published twice a year and is an integral number of
seconds between TAI (which does not have leap seconds) and UTC (which
does).
.Xr ntpd 8 
or some other agent maintains this value.
A value of 0 means unknown.
As of the date of the manual page, the offset is 32 seconds.
.It Va time_state
Current time status.
.El
.Sh RETURN VALUES
.Rv -std ntp_gettime
.Pp
Possible states of the clock are:
.Pp
.Bl -tag -compact -width ".Dv TIME_ERROR"
.It Dv TIME_OK
Everything okay, no leap second warning.
.It Dv TIME_INS
Positive leap second warning.
At the end of the day, an additional second will be inserted after 23:59:59.
.It Dv TIME_DEL
Negative leap second warning.
At the end of the day, 23:59:59 is skipped.
.It Dv TIME_OOP
Leap second in progress.
.It Dv TIME_WAIT
Leap second has occurred.
.It Dv TIME_ERROR
Clock not synchronized.
.El
.Sh SEE ALSO
.Xr ntp_adjtime 2 ,
.Xr ntpd 8
.Bl -tag -width indent
.It Pa http://www.bipm.fr/enus/5_Scientific/c_time/time_1.html
.It Pa http://www.boulder.nist.gov/timefreq/general/faq.htm
.It Pa ftp://time.nist.gov/pub/leap-seconds.list
.El
.Sh AUTHORS
This manual page was written by
.An Tom Rhodes Aq trhodes@FreeBSD.org .
OpenPOWER on IntegriCloud