carta
sbttots(9)

sbttots9

Q32.32 fixed point representation of time

Part of bttosbt(9).

Usage

typedef __int64_t __sbintime_t; typedef __sbintime_t sbintime_t;

int

sbintime_t

struct bintime

int64_t

sbintime_t

int64_t

sbintime_t

int64_t

sbintime_t

struct timespec

sbintime_t

struct timeval

sbintime_t

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.

History

The sbintime_t type and most of the helper functions first appeared in FreeBSD 10.0. The Xstosbt functions first appeared in FreeBSD 12.0.

Authors

This manual page was written by Ka Ho Ng ⟨[email protected]⟩.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.