SBINTIME(9)
β¨ SBINTIME(9) β Q32.32 fixed point time, but make it make sense β¨
okay bestie, gather round, because this one is genuinely iconic once you get it. this is the sbintime_t manual page, from the Kernel Developer's Manual. it's a Q32.32 fixed point representation of time and honestly? it ate. let's get into it π
πΈ NAME πΈ
sbintime_t, sbintime_getsec, bttosbt, sbttobt, sbttons, nstosbt, sbttous, ustosbt, sbttoms, mstosbt, sbttots, tstosbt, sbttotv, tvtosbt β a Q32.32 fixed point representation of time π°οΈ
π SYNOPSIS π
like, the whole cast list, fr fr:
#include <sys/types.h>
#include <sys/time.h>
typedef __int64_t __sbintime_t;
typedef __sbintime_t sbintime_t;
#define SBT_1S ((sbintime_t)1 << 32)
#define SBT_1M (SBT_1S * 60)
#define SBT_1MS (SBT_1S / 1000)
#define SBT_1US (SBT_1S / 1000000)
#define SBT_1NS (SBT_1S / 1000000000)
int
sbintime_getsec(sbintime_t sbt);
sbintime_t
bttosbt(const struct bintime bt);
struct bintime
sbttobt(sbintime_t sbt);
int64_t
sbttons(sbintime_t sbt);
sbintime_t
nstosbt(int64_t ns);
int64_t
sbttous(sbintime_t sbt);
sbintime_t
ustosbt(int64_t us);
int64_t
sbttoms(sbintime_t sbt);
sbintime_t
mstosbt(int64_t ms);
struct timespec
sbttots(sbintime_t sbt);
sbintime_t
tstosbt(struct timespec ts);
struct timeval
sbttotv(sbintime_t sbt);
sbintime_t
tvtosbt(struct timeval tv);
π DESCRIPTION π
so. the sbintime_t type is a Q32.32 fixed point representation of time. the high 32-bit integral bits are the number of seconds, and the low 32-bit fractional bits are the sub-second part. and because the lower 32 bits are counting with a base unit of 1/2^32 seconds, (sbintime_t)0x1 is just under 250 picoseconds. like, tiny tiny. microscopic. a crumb of a second π«Ά
and here's the slay: all of these conversion functions are designed to do the conversion without the large truncation errors you'd get from naive math. no cap, that's the whole point. it's giving precision.
π the functions π
sbintime_getsec(sbt)β returns the whole number of seconds from thesbintime_tyou passed as the sbt argument. just the whole ones, no fractional crumbs.bttosbt(bt)β converts astruct bintime(that's the bt argument) into ansbintime_t.sbttobt(sbt)β converts ansbintime_t(the sbt argument) into astruct bintime.sbttons(sbt)β converts ansbintime_t(the sbt argument) into the number of nanoseconds.nstosbt(ns)β converts the number of nanoseconds (the ns argument) into ansbintime_t.sbttous(sbt)β converts ansbintime_t(the sbt argument) into the number of microseconds.ustosbt(us)β converts the number of microseconds (the us argument) into ansbintime_t.sbttoms(sbt)β converts ansbintime_t(the sbt argument) into the number of milliseconds.mstosbt(ms)β converts the number of milliseconds (the ms argument) into ansbintime_t.sbttots(sbt)β converts ansbintime_t(the sbt argument) into astruct timespec.tstosbt(ts)β converts astruct timespec(the ts argument) into ansbintime_t.sbttotv(sbt)β converts ansbintime_t(the sbt argument) into astruct timeval.tvtosbt(tv)β converts astruct timeval(the tv argument) into ansbintime_t.
the pattern is lowkey genius: sbttosomething goes out of sbintime_t, somethingtosbt comes in to sbintime_t. iykyk π
π¦ SEE ALSO π¦
go read those too, bestie, they're in the same friend group π
β HISTORY β
the sbintime_t type and most of the helper functions first appeared in FreeBSD 10.0. and the Xstosbt functions first appeared in FreeBSD 12.0. glow-up timeline fr fr π₯
π AUTHORS π
this manual page was written by Ka Ho Ng <khng@FreeBSD.org>. iconic behavior, thank you for your service π«‘
ok that's the whole page, no skips, no cuts π every function accounted for, every argument named, every header included. you're welcome.
πΈ this Debian build of the page is dated July 12, 2026 β that's the source/version and date, bestie, consider it mentioned. mwah, go convert some time π β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- π the page's license: BSD-2-Clause
- Copyright (c) 2026 Ka Ho Ng
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms