228 lines
4.6 KiB
HTML
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"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
timeradd, timersub, timercmp, timerclear, timerisset - timeval operations
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/sys/time.h">sys/time.h</A>></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> Since glibc 2.19:
|
|
<BR> _DEFAULT_SOURCE
|
|
<BR> Glibc 2.19 and earlier:
|
|
<BR> _BSD_SOURCE
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The macros are provided to operate on
|
|
<I>timeval</I>
|
|
|
|
structures, defined in
|
|
<I><<A HREF="file:///usr/include/sys/time.h">sys/time.h</A>></I>
|
|
|
|
as:
|
|
<P>
|
|
|
|
|
|
|
|
struct timeval {
|
|
<BR> time_t tv_sec; /* seconds */
|
|
<BR> suseconds_t tv_usec; /* microseconds */
|
|
};
|
|
|
|
|
|
<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->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->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>>=</I>,
|
|
|
|
<I><=</I>,
|
|
|
|
and
|
|
<I>==</I>
|
|
|
|
do not work;
|
|
portable applications can instead use
|
|
<P>
|
|
|
|
<BR> !timercmp(..., <)
|
|
<BR> !timercmp(..., >)
|
|
<BR> !timercmp(..., !=)
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
<B>timerisset</B>()
|
|
|
|
and
|
|
<B>timercmp</B>()
|
|
|
|
return true (nonzero) or false (0).
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
No errors are defined.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
Not in POSIX.1.
|
|
Present on most BSD derivatives.
|
|
<A NAME="lbAH"> </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"> </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"> </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>
|