OpenBSD manual page server

Manual Page Search Parameters

BINTIMEADD(9) Kernel Developer's Manual BINTIMEADD(9)

bintimecmp, bintimesub, bintimeadd, bintimeaddfrac, BINTIME_TO_TIMEVAL, BINTIME_TO_TIMESPEC, TIMEVAL_TO_BINTIME, TIMESPEC_TO_BINTIME
manipulate kernel time structures

#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);

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.

bintimecmp() returns 1 if the tested condition holds or 0 otherwise.

These functions are implemented in the file sys/sys/time.h.

timeradd(3), microtime(9), tc_init(9), timeout(9)

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.

Poul-Henning Kamp <phk@freebsd.org>
June 3, 2019 OpenBSD-current