xref: /netbsd-src/share/man/man9/ts2timo.9 (revision 30a14a5adfec1de56fa897f58c49303edcf5b4dc)
1.\"	$NetBSD: ts2timo.9,v 1.5 2024/10/10 11:14:28 kre Exp $
2.\"
3.\" Copyright (c) 2013 Christos Zoulas
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.\"
28.Dd May 22, 2013
29.Dt TS2TIMO 9
30.Os
31.Sh NAME
32.Nm ts2timo
33.Nd convert time interval to tick count
34.Sh SYNOPSIS
35.In sys/timevar.h
36.Ft int
37.Fn ts2timo "clock_id clock_id" "int flags" "struct timespec *ts" "int *timo" "struct timespec *start"
38.Sh DESCRIPTION
39The
40.Fn ts2timo
41function converts the time interval specified in
42.Fa ts
43into the integral number of system ticks that would elapse (including the
44current tick) and places the result in
45.Fa timo .
46The interval type is specified in the
47.Fa flags
48argument and can be either
49.Dv TIMER_ABSTIME
50or
51.Dv TIMER_RELTIME .
52If the interval is specified as an absolute time, then the
53.Fa clock_id
54clock is used to calculate the corresponding relative time.
55If the
56.Fa start
57argument is not
58.Dv NULL ,
59then current time for the
60.Fa clock_id
61clock is placed in that argument.
62.Sh RETURN VALUES
63On success
64.Fn ts2timo
65returns
66.Dv 0 ,
67and places the computed number of ticks
68in the integer referenced by
69.Fa timo .
70On failure it returns
71.Er ETIMEDOUT
72if  interval computed was
73.Dv 0
74or negative, or
75.Er EINVAL
76if the
77.Fa ts->tv_nsec
78field is out of range, or the
79.Fa clock_id
80argument is invalid, or if
81computing the relative time from a supplied absolute value
82would cause an arithmetic overflow.
83.Sh SEE ALSO
84.Xr clock_gettime 2 ,
85.Xr clock_nanosleep 2
86.Sh HISTORY
87The
88.Nm
89function first appeared in
90.Nx 7.0 .
91