TS2TIMO(9)

πŸ“¦ version 11.0, in nixpkgs unstable

πŸ’… TS2TIMO(9) πŸ’…

okay bestie, welcome to the Kernel Developer's Manual β€” yes that's the manual name, and yes you're gonna read it. this one's about ts2timo, and honestly? she's lowkey iconic. ✨


🌸 NAME 🌸

ts2timo β€” convert time interval to tick count. that's it. that's the whole vibe. time ➑️ ticks. πŸ•°οΈβž‘οΈβœ…


πŸ¦‹ SYNOPSIS πŸ¦‹

like, literally just:

#include <sys/timevar.h>

int
ts2timo(clock_id clock_id, int flags, struct timespec *ts, int *timo,
    struct timespec *start);

copy it exactly, don't be weird about it. 🫢


πŸ’– DESCRIPTION πŸ’–

okay so here's the tea: ts2timo() takes the time interval you specified in ts and converts it into the integral number of system ticks that would elapse β€” and yes, that includes the current tick, she's thorough πŸ’… β€” then plops the result right into timo.

the interval type is specified in the flags argument, and it can be either TIMER_ABSTIME or TIMER_RELTIME. pick your fighter. βš”οΈ

if the interval is specified as an absolute time, then the clock_id clock is used to calculate the corresponding relative time. math era fr fr.

and if the start argument is not NULL, then the current time for the clock_id clock gets placed in that argument. free real estate. 🎁


πŸ”₯ RETURN VALUES πŸ”₯

on success, ts2timo() returns 0 and places the computed number of ticks in the integer referenced by timo. slay. πŸ‘‘

on failure? buckle up:

  • returns ETIMEDOUT if the interval computed was 0 or negative 😭
  • returns EINVAL if the ts->tv_nsec field is out of range, or the clock_id argument is invalid, or if computing the relative time from a supplied absolute value would cause an arithmetic overflow πŸ’€
ngl bestie, those EINVAL conditions are not a vibe. check your tv_nsec range and your clock_id before you come crying to me. πŸ™ˆ

πŸŽ€ SEE ALSO πŸŽ€

go read those too, iykyk 🧚


🌈 HISTORY 🌈

the ts2timo function first appeared in NetBSD 7.0. a legend was born. ⭐


~ and that's the whole page, bestie ~ this cutie came to you from the Debian edition, dated May 22, 2013, and honestly she still ate. periodt. πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from