MSTOHZ(9)
π MSTOHZ(9) β the manual page, but make it group chat
Okay so bestie, let me tell you about MSTOHZ(9), the kernel dev manual page that's literally the main character for converting between milliseconds and system clock ticks. No cap, this one's a little icon.
β¨ NAME β¨
mstohz, hztoms β convert between milliseconds and system clock ticks π°οΈπ
πΈ SYNOPSIS πΈ
#include <sys/param.h>
unsigned int
mstohz(unsigned int ms);
unsigned int
hztoms(unsigned int hz);
π DESCRIPTION π
The mstohz() macro is your go-to bestie for converting time in milliseconds to system clock ticks β the same kind the callout(9) facility uses β and it does it in an integer-overflow safe way. Slay. π
Conversely, hztoms() converts system clock ticks back to milliseconds. The way these two just vibe with each other? Obsessed.
These macros are defined in the <sys/param.h> header, periodt. And fr fr, individual ports can have a processor-specific, more efficient version implemented in their <machine/param.h> header as a define. That's some main character energy right there. π§β¨
π RETURN VALUES π
The return value is either the number of clock ticks or milliseconds for the specified value. Simple as that, bestie. π«Ά
π¦ SEE ALSO π¦
These are the linked besties, iykyk. β¨
π BUGS π
Neithermstohz()norhztoms()make use of expensive 64-bit integer arithmetic. The result frommstohz()will be rounded down to one second if the parameter is larger than131072milliseconds. π
So like, lowkey important: don't come for these macros unless you know the math is intentionally lightweight. It's giving "efficient but with a catch," and that catch is real. π
π SIGN-OFF π
That's the whole vibe for this one! Big Debian energy, dated September 28, 2019, and honestly? Iconic. πππ
Go forth and convert your ticks, bestie. π¦πΈ
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2002 Manuel Bouyer
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms