NAME
bintimecmp
,
bintimesub
, bintimeadd
,
bintimeaddfrac
,
BINTIME_TO_TIMEVAL
,
BINTIME_TO_TIMESPEC
,
TIMEVAL_TO_BINTIME
,
TIMESPEC_TO_BINTIME
—
manipulate kernel time
structures
SYNOPSIS
#include
<sys/time.h>
int
bintimecmp
(struct bintime *a,
struct bintime *b,
operator);
void
bintimesub
(const struct bintime
*a, const struct bintime *b,
struct bintime *c);
void
bintimeadd
(const struct bintime
*a, const struct bintime *b,
struct bintime *c);
void
bintimeaddfrac
(const struct bintime
*a, uint64_t fraction, struct
bintime *b);
void
BINTIME_TO_TIMEVAL
(const struct
bintime *bt, struct timeval *tv);
void
BINTIME_TO_TIMESPEC
(const struct
bintime *bt, struct timespec *ts);
void
TIMEVAL_TO_BINTIME
(const struct
timeval *tv, struct bintime *bt);
void
TIMESPEC_TO_BINTIME
(const struct
timespec *ts, struct bintime *bt);
DESCRIPTION
These functions simplify the use of bintime structures and the conversion to and from other time representations.
The following functions are available:
bintimecmp
(a, b, operator)- Test if the expression a operator b is true, where
operator is one of
<
,<=
,==
,!=
,>=
, or>
. bintimesub
(a, b, c)- Subtract b from a and store the result in c.
bintimeadd
(a, b, c)- Add b to a and store the result in c.
bintimeaddfrac
(a, fraction, b)- Add fraction fractional seconds to a and store the result in b. A fractional second is equal to 1 / (2^64) seconds.
BINTIME_TO_TIMEVAL
(bt, tv)- Convert bt to a struct timeval and store the result in tv.
BINTIME_TO_TIMESPEC
(bt, ts)- Convert bt to a struct timespec and store the result in ts.
TIMEVAL_TO_BINTIME
(tv, bt)- Convert tv to a struct bintime and store the result in bt.
TIMESPEC_TO_BINTIME
(ts, bt)- Convert ts to a struct bintime and store the result in bt.
RETURN VALUES
bintimecmp
() returns 1 if the tested
condition holds or 0 otherwise.
CODE REFERENCES
These functions are implemented in the file sys/sys/time.h.
SEE ALSO
HISTORY
Predecessors to these functions first appeared in FreeBSD 5.0 and were ported to OpenBSD 3.6. They were modified to more closely resemble the timeradd(3) macros for OpenBSD 6.6.
AUTHORS
Poul-Henning Kamp <phk@freebsd.org>