man-pages/man3/ntp_gettime.3.html
2021-03-31 01:06:50 +01:00

219 lines
5.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of NTP_GETTIME</TITLE>
</HEAD><BODY>
<H1>NTP_GETTIME</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
ntp_gettime, ntp_gettimex - get time parameters (NTP daemon interface)
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/sys/timex.h">sys/timex.h</A>&gt;</B>
<B>int ntp_gettime(struct ntptimeval *</B><I>ntv</I><B>);</B>
<B>int ntp_gettimex(struct ntptimeval *</B><I>ntv</I><B>);</B>
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
Both of these APIs return information to the caller via the
<I>ntv</I>
argument, a structure of the following type:
<P>
struct ntptimeval {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;struct&nbsp;timeval&nbsp;time;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Current&nbsp;time&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;long&nbsp;int&nbsp;maxerror;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Maximum&nbsp;error&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;long&nbsp;int&nbsp;esterror;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Estimated&nbsp;error&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;long&nbsp;int&nbsp;tai;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;TAI&nbsp;offset&nbsp;*/
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Further&nbsp;padding&nbsp;bytes&nbsp;allowing&nbsp;for&nbsp;future&nbsp;expansion&nbsp;*/
};
<P>
The fields of this structure are as follows:
<DL COMPACT>
<DT id="1"><I>time</I>
<DD>
The current time, expressed as a
<I>timeval</I>
structure:
<DT id="2"><DD>
struct timeval {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;time_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tv_sec;&nbsp;&nbsp;&nbsp;/*&nbsp;Seconds&nbsp;since&nbsp;the&nbsp;Epoch&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;suseconds_t&nbsp;tv_usec;&nbsp;&nbsp;/*&nbsp;Microseconds&nbsp;*/
};
<DT id="3"><DD>
<DT id="4"><I>maxerror</I>
<DD>
Maximum error, in microseconds.
This value can be initialized by
<B><A HREF="/cgi-bin/man/man2html?3+ntp_adjtime">ntp_adjtime</A></B>(3),
and is increased periodically (on Linux: each second),
but is clamped to an upper limit (the kernel constant
<B>NTP_PHASE_MAX</B>,
with a value of 16,000).
<DT id="5"><I>esterror</I>
<DD>
Estimated error, in microseconds.
This value can be set via
<B><A HREF="/cgi-bin/man/man2html?3+ntp_adjtime">ntp_adjtime</A></B>(3)
to contain an estimate of the difference between the system clock
and the true time.
This value is not used inside the kernel.
<DT id="6"><I>tai</I>
<DD>
TAI (Atomic International Time) offset.
</DL>
<P>
<B>ntp_gettime</B>()
returns an
<I>ntptimeval</I>
structure in which the
<I>time</I>,
<I>maxerror</I>,
and
<I>esterror</I>
fields are filled in.
<P>
<B>ntp_gettimex</B>()
performs the same task as
<B>ntp_gettime</B>(),
but also returns information in the
<I>tai</I>
field.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
The return values for
<B>ntp_gettime</B>()
and
<B>ntp_gettimex</B>()
are as for
<B><A HREF="/cgi-bin/man/man2html?2+adjtimex">adjtimex</A></B>(2).
Given a correct pointer argument, these functions always succeed.
<A NAME="lbAF">&nbsp;</A>
<H2>VERSIONS</H2>
The
<B>ntp_gettime</B>()
function is available since glibc 2.1.
The
<B>ntp_gettimex</B>()
function is available since glibc 2.12.
<A NAME="lbAG">&nbsp;</A>
<H2>ATTRIBUTES</H2>
For an explanation of the terms used in this section, see
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
<TABLE BORDER>
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
<TR VALIGN=top><TD>
<B>ntp_gettime</B>(),
<B>ntp_gettimex</B>()
</TD><TD>Thread safety</TD><TD>MT-Safe<BR></TD></TR>
</TABLE>
<A NAME="lbAH">&nbsp;</A>
<H2>CONFORMING TO</H2>
<B>ntp_gettime</B>()
is described in the NTP Kernel Application Program Interface.
<B>ntp_gettimex</B>()
is a GNU extension.
<A NAME="lbAI">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+adjtimex">adjtimex</A></B>(2)
<B><A HREF="/cgi-bin/man/man2html?3+ntp_adjtime">ntp_adjtime</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?7+time">time</A></B>(7)
<P>
NTP &quot;Kernel Application Program Interface&quot;
<A NAME="lbAJ">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="7"><A HREF="#lbAB">NAME</A><DD>
<DT id="8"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="9"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="10"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="11"><A HREF="#lbAF">VERSIONS</A><DD>
<DT id="12"><A HREF="#lbAG">ATTRIBUTES</A><DD>
<DT id="13"><A HREF="#lbAH">CONFORMING TO</A><DD>
<DT id="14"><A HREF="#lbAI">SEE ALSO</A><DD>
<DT id="15"><A HREF="#lbAJ">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:49 GMT, March 31, 2021
</BODY>
</HTML>