1.\" $OpenBSD: bintimeadd.9,v 1.1 2019/06/03 01:27:30 cheloha Exp $ 2.\" $NetBSD: getitimer.2,v 1.6 1995/10/12 15:40:54 jtc Exp $ 3.\" 4.\" Copyright (c) 1983, 1991, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)getitimer.2 8.2 (Berkeley) 12/11/93 32.\" 33.Dd $Mdocdate: June 3 2019 $ 34.Dt BINTIMEADD 9 35.Os 36.Sh NAME 37.Nm bintimecmp , 38.Nm bintimesub , 39.Nm bintimeadd , 40.Nm bintimeaddfrac , 41.Nm BINTIME_TO_TIMEVAL , 42.Nm BINTIME_TO_TIMESPEC , 43.Nm TIMEVAL_TO_BINTIME , 44.Nm TIMESPEC_TO_BINTIME 45.Nd manipulate kernel time structures 46.Sh SYNOPSIS 47.In sys/time.h 48.Ft int 49.Fo bintimecmp 50.Fa "struct bintime *a" 51.Fa "struct bintime *b" 52.Fa operator 53.Fc 54.Ft void 55.Fo bintimesub 56.Fa "const struct bintime *a" 57.Fa "const struct bintime *b" 58.Fa "struct bintime *c" 59.Fc 60.Ft void 61.Fo bintimeadd 62.Fa "const struct bintime *a" 63.Fa "const struct bintime *b" 64.Fa "struct bintime *c" 65.Fc 66.Ft void 67.Fo bintimeaddfrac 68.Fa "const struct bintime *a" 69.Fa "uint64_t fraction" 70.Fa "struct bintime *b" 71.Fc 72.Ft void 73.Fo BINTIME_TO_TIMEVAL 74.Fa "const struct bintime *bt" 75.Fa "struct timeval *tv" 76.Fc 77.Ft void 78.Fo BINTIME_TO_TIMESPEC 79.Fa "const struct bintime *bt" 80.Fa "struct timespec *ts" 81.Fc 82.Ft void 83.Fo TIMEVAL_TO_BINTIME 84.Fa "const struct timeval *tv" 85.Fa "struct bintime *bt" 86.Fc 87.Ft void 88.Fo TIMESPEC_TO_BINTIME 89.Fa "const struct timespec *ts" 90.Fa "struct bintime *bt" 91.Fc 92.Sh DESCRIPTION 93These functions simplify the use of 94.Vt bintime 95structures and the conversion to and from other time representations. 96.Pp 97The following functions are available: 98.Bl -tag -width Ds 99.It Fn bintimecmp a b operator 100Test if the expression 101.Fa a operator b 102is true, 103where 104.Fa operator 105is one of 106.Cm < , 107.Cm <= , 108.Cm == , 109.Cm != , 110.Cm >= , 111or 112.Cm > . 113.It Fn bintimesub a b c 114Subtract 115.Fa b 116from 117.Fa a 118and store the result in 119.Fa c . 120.It Fn bintimeadd a b c 121Add 122.Fa b 123to 124.Fa a 125and store the result in 126.Fa c . 127.It Fn bintimeaddfrac a fraction b 128Add 129.Fa fraction 130fractional seconds to 131.Fa a 132and store the result in 133.Fa b . 134A fractional second is equal to 1 / (2^64) seconds. 135.It Fn BINTIME_TO_TIMEVAL bt tv 136Convert 137.Fa bt 138to a 139.Vt struct timeval 140and store the result in 141.Fa tv . 142.It Fn BINTIME_TO_TIMESPEC bt ts 143Convert 144.Fa bt 145to a 146.Vt struct timespec 147and store the result in 148.Fa ts . 149.It Fn TIMEVAL_TO_BINTIME tv bt 150Convert 151.Fa tv 152to a 153.Vt struct bintime 154and store the result in 155.Fa bt . 156.It Fn TIMESPEC_TO_BINTIME ts bt 157Convert 158.Fa ts 159to a 160.Vt struct bintime 161and store the result in 162.Fa bt . 163.El 164.Sh RETURN VALUES 165.Fn bintimecmp 166returns 1 if the tested condition holds or 0 otherwise. 167.Sh CODE REFERENCES 168These functions are implemented in the file 169.Pa sys/sys/time.h . 170.Sh SEE ALSO 171.Xr timeradd 3 , 172.Xr microtime 9 , 173.Xr tc_init 9 , 174.Xr timeout 9 175.Sh HISTORY 176Predecessors to these functions first appeared in 177.Fx 5.0 178and were ported to 179.Ox 3.6 . 180They were modified to more closely resemble the 181.Xr timeradd 3 182macros for 183.Ox 6.6 . 184.Sh AUTHORS 185.An Poul-Henning Kamp Aq Mt phk@freebsd.org 186