TS2TIMO(9) | Kernel Developer's Manual | TS2TIMO(9)

# NAME

`ts2timo` — convert time interval to tick count

# SYNOPSIS

`#include <sys/timevar.h>`

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

# DESCRIPTION

The `ts2timo`() function converts the time interval specified in ts into the integral number of system ticks that would elapse (including the current tick) and places the result in timo. The interval type is specified in the flags argument and can be either `TIMER_ABSTIME` or `TIMER_RELTIME`. If the interval is specified as an absolute time, then the clock_id clock is used to calculate the corresponding relative time. If the start argument is not `NULL`, then current time for the clock_id clock is placed in that argument.

# RETURN VALUES

On success `ts2timo`() returns `0`, and places the computed number of ticks in the integer referenced by timo. On failure it returns `ETIMEDOUT` if interval computed was `0` or negative, or `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.

# SEE ALSO

clock_gettime(2), clock_nanosleep(2)

# HISTORY

The `ts2timo` function first appeared in NetBSD 7.0.

May 22, 2013 | NetBSD 11.0