BINTIMEADD(9)
π BINTIMEADD(9) π
okay bestie, so this is from the Kernel Developer's Manual β section 9, kernel land, big brain hours π β and it's literally all about poking at kernel time structures without losing your mind. stay with me, it's gonna slay π
β¨ NAME β¨
bintimecmp, bintimesub, bintimeadd, bintimeaddfrac, BINTIME_TO_TIMEVAL, BINTIME_TO_TIMESPEC, TIMEVAL_TO_BINTIME, TIMESPEC_TO_BINTIME β these are the little helpers that let you manipulate kernel time structures, bestie π«Ά
πΈ SYNOPSIS πΈ
so first, you gotta bring in the header, no cap:
#include <sys/time.h>
and then here's the whole squad, exactly as they show up:
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 π¦
bestie, the whole point of these functions is that they simplify the use of bintime structures and the conversion to and from other time representations. that's it, that's the vibe π«
The following functions are available β line them up, they're all iconic:
bintimecmp(a, b, operator)β test if the expressiona operator bis true, where operator is one of<,<=,==,!=,>=, or>. like a vibe check for time comparisons fr fr βbintimesub(a, b, c)β subtractbfromaand store the result inc. bye subtraction anxiety, hellocπbintimeadd(a, b, c)β addbtoaand store the result inc. math but make it cute πbintimeaddfrac(a, fraction, b)β addfractionfractional seconds toaand store the result inb. and heads up, a fractional second is equal to1 / (2^64)seconds β tiny tiny tiny, microscopic even π₯BINTIME_TO_TIMEVAL(bt, tv)β convertbtto astruct timevaland store the result intv. glow-up from one struct to another β¨BINTIME_TO_TIMESPEC(bt, ts)β convertbtto astruct timespecand store the result ints. same energy, different struct πTIMEVAL_TO_BINTIME(tv, bt)β converttvto astruct bintimeand store the result inbt. coming back the other way, main character energy πTIMESPEC_TO_BINTIME(ts, bt)β converttsto astruct bintimeand store the result inbt. round trip complete, we love to see it π
π RETURN VALUES π
bintimecmp() returns 1 if the tested condition holds or 0 otherwise. that's it. binary queen behavior, periodt π
π CODE REFERENCES π
These functions are implemented in the file sys/sys/time.h β that's the spot, go look, iykyk π
π§ SEE ALSO π§
okay so go read these too, they're literally right there:
πΈ HISTORY πΈ
Predecessors to these functions first appeared in FreeBSD 5.0 and were ported to OpenBSD 3.6. then they got modified to more closely resemble the timeradd(3) macros for OpenBSD 6.6. a whole origin story, honestly ππ
π« AUTHORS π«
Poul-Henning Kamp <phk@freebsd.org> β thank you king π«Ά
lowkey remember: these are tiny helpers, so don't try to make them do something they don't do. the manpage says exactly what it says, and that's the whole tea π΅
and that's a wrap bestie!! this page is from Debian, dated June 3, 2019, and you just read the whole thing β no skimming, i'm so proud of you πππ
π¦ where this page comes from
- nixpkgs unstable: cvs-export
- Copyright (c) 1983, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms