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

228 lines
4.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of TIMERADD</TITLE>
</HEAD><BODY>
<H1>TIMERADD</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>
timeradd, timersub, timercmp, timerclear, timerisset - timeval operations
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/sys/time.h">sys/time.h</A>&gt;</B>
<B>void timeradd(struct timeval *</B><I>a</I><B>, struct timeval *</B><I>b</I><B>,</B>
<B> struct timeval *</B><I>res</I><B>);</B>
<B>void timersub(struct timeval *</B><I>a</I><B>, struct timeval *</B><I>b</I><B>,</B>
<B> struct timeval *</B><I>res</I><B>);</B>
<B>void timerclear(struct timeval *</B><I>tvp</I><B>);</B>
<B>int timerisset(struct timeval *</B><I>tvp</I><B>);</B>
<B>int timercmp(struct timeval *</B><I>a</I><B>, struct timeval *</B><I>b</I><B>, </B><I>CMP</I><B>);</B>
</PRE>
<P>
Feature Test Macro Requirements for glibc (see
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
<P>
All functions shown above:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;Since&nbsp;glibc&nbsp;2.19:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_DEFAULT_SOURCE
<BR>&nbsp;&nbsp;&nbsp;&nbsp;Glibc&nbsp;2.19&nbsp;and&nbsp;earlier:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_BSD_SOURCE
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The macros are provided to operate on
<I>timeval</I>
structures, defined in
<I>&lt;<A HREF="file:///usr/include/sys/time.h">sys/time.h</A>&gt;</I>
as:
<P>
struct timeval {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;time_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tv_sec;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;seconds&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;suseconds_t&nbsp;tv_usec;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;microseconds&nbsp;*/
};
<P>
<B>timeradd</B>()
adds the time values in
<I>a</I>
and
<I>b</I>,
and places the sum in the
<I>timeval</I>
pointed to by
<I>res</I>.
The result is normalized such that
<I>res-&gt;tv_usec</I>
has a value in the range 0 to 999,999.
<P>
<B>timersub</B>()
subtracts the time value in
<I>b</I>
from the time value in
<I>a</I>,
and places the result in the
<I>timeval</I>
pointed to by
<I>res</I>.
The result is normalized such that
<I>res-&gt;tv_usec</I>
has a value in the range 0 to 999,999.
<P>
<B>timerclear</B>()
zeros out the
<I>timeval</I>
structure pointed to by
<I>tvp</I>,
so that it represents the Epoch: 1970-01-01 00:00:00 +0000 (UTC).
<P>
<B>timerisset</B>()
returns true (nonzero) if either field of the
<I>timeval</I>
structure pointed to by
<I>tvp</I>
contains a nonzero value.
<P>
<B>timercmp</B>()
compares the timer values in
<I>a</I>
and
<I>b</I>
using the comparison operator
<I>CMP</I>,
and returns true (nonzero) or false (0) depending on
the result of the comparison.
Some systems (but not Linux/glibc),
have a broken
<B>timercmp</B>()
implementation,
in which
<I>CMP</I>
of
<I>&gt;=</I>,
<I>&lt;=</I>,
and
<I>==</I>
do not work;
portable applications can instead use
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;!timercmp(...,&nbsp;&lt;)
<BR>&nbsp;&nbsp;&nbsp;&nbsp;!timercmp(...,&nbsp;&gt;)
<BR>&nbsp;&nbsp;&nbsp;&nbsp;!timercmp(...,&nbsp;!=)
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
<B>timerisset</B>()
and
<B>timercmp</B>()
return true (nonzero) or false (0).
<A NAME="lbAF">&nbsp;</A>
<H2>ERRORS</H2>
No errors are defined.
<A NAME="lbAG">&nbsp;</A>
<H2>CONFORMING TO</H2>
Not in POSIX.1.
Present on most BSD derivatives.
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+gettimeofday">gettimeofday</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?7+time">time</A></B>(7)
<A NAME="lbAI">&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="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="4"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="5"><A HREF="#lbAF">ERRORS</A><DD>
<DT id="6"><A HREF="#lbAG">CONFORMING TO</A><DD>
<DT id="7"><A HREF="#lbAH">SEE ALSO</A><DD>
<DT id="8"><A HREF="#lbAI">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:58 GMT, March 31, 2021
</BODY>
</HTML>