sbintime9
Q32.32 fixed point representation of time
Usage
#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);
Overview
The sbintime_t type is a Q32.32 fixed point representation of time. The high 32-bit integral bits specify the number of seconds, and the low 32-bit fractional bits specify the sub-second portion. Since the lower 32 bits are counting with a base unit of 1/2^32 seconds, ‘(sbintime_t)0x1’ is just under 250 picoseconds.
All of the conversion functions are designed to do the conversion without large truncation errors that are possible with naive math.
sbintime_getsec(sbt)-
Return the whole number of seconds from a sbintime_t specified by the sbt argument.
bttosbt(bt)-
Convert a struct bintime specified by the bt argument to a sbintime_t.
sbttobt(sbt)-
Convert a sbintime_t specified by the sbt argument to a struct bintime.
sbttons(sbt)-
Convert a sbintime_t specified by the sbt argument to the number of nanoseconds.
nstosbt(ns)-
Convert the number of nanoseconds specified by the ns argument to a sbintime_t.
sbttous(sbt)-
Convert a sbintime_t specified by the sbt argument to the number of microseconds.
ustosbt(us)-
Convert the number of microseconds specified by the us argument to a sbintime_t.
sbttoms(sbt)-
Convert a sbintime_t specified by the sbt argument to the number of milliseconds.
mstosbt(ms)-
Convert the number of milliseconds specified by the ms argument to a sbintime_t.
sbttots(sbt)-
Convert a sbintime_t specified by the sbt argument to a struct timespec.
tstosbt(ts)-
Convert a struct timespec specified by the ts argument to a sbintime_t.
sbttotv(sbt)-
Convert a sbintime_t specified by the sbt argument to a struct timeval.
tvtosbt(tv)-
Convert a struct timeval specified by the tv argument to a sbintime_t.
Releases
Unchanged in 2 releases since FreeBSD 14.5-RELEASE.