1.\" $OpenBSD: timeradd.3,v 1.2 2019/02/07 17:09:28 schwarze 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: February 7 2019 $ 34.Dt TIMERADD 3 35.Os 36.Sh NAME 37.Nm timerclear , 38.Nm timerisset , 39.Nm timerisvalid , 40.Nm timercmp , 41.Nm timersub , 42.Nm timeradd , 43.Nm timespecclear , 44.Nm timespecisset , 45.Nm timespecisvalid , 46.Nm timespeccmp , 47.Nm timespecsub , 48.Nm timespecadd 49.Nd manipulate time structures 50.Sh SYNOPSIS 51.In sys/time.h 52.Ft void 53.Fn timerclear "struct timeval *a" 54.Ft int 55.Fn timerisset "struct timeval *a" 56.Ft int 57.Fn timerisvalid "struct timeval *a" 58.Ft int 59.Fn timercmp "struct timeval *a" "struct timeval *b" operator 60.Ft void 61.Fn timersub "struct timeval *a" "struct timeval *b" "struct timeval *c" 62.Ft void 63.Fn timeradd "struct timeval *a" "struct timeval *b" "struct timeval *c" 64.Ft void 65.Fn timespecclear "struct timespec *a" 66.Ft int 67.Fn timespecisset "struct timespec *a" 68.Ft int 69.Fn timespecisvalid "struct timespec *a" 70.Ft int 71.Fn timespeccmp "struct timespec *a" "struct timespec *b" operator 72.Ft void 73.Fn timespecsub "struct timespec *a" "struct timespec *b" "struct timespec *c" 74.Ft void 75.Fn timespecadd "struct timespec *a" "struct timespec *b" "struct timespec *c" 76.Sh DESCRIPTION 77The 78.Fn timer* 79and 80.Fn timespec* 81macros defined in 82.In sys/time.h 83simplify the use of 84.Vt timeval 85and 86.Vt timespec 87structures, 88respectively. 89.Pp 90The following macros are available: 91.Bl -tag -width Ds 92.It Fn timerclear a , Fn timespecclear a 93Set the time value in 94.Fa a 95to zero. 96.It Fn timerisset a , Fn timespecisset a 97Test if the time value in 98.Fa a 99is non-zero. 100.It Fn timerisvalid a 101Test if the microsecond value in 102.Fa a 103is greater than or equal to zero and less than one million. 104.It Fn timespecisvalid a 105Test if the nanosecond value in 106.Fa a 107is greater than or equal to zero and less than one billion. 108.It Fn timercmp a b operator , Fn timespeccmp a b operator 109Test if the expression 110.Fa a operator b 111is true, 112where 113.Fa operator 114is one of 115.Cm < , 116.Cm <= , 117.Cm == , 118.Cm != , 119.Cm >= , 120or 121.Cm > . 122.It Fn timersub a b c , Fn timespecsub a b c 123Subtract 124.Fa b 125from 126.Fa a 127and store the result in 128.Fa c . 129.It Fn timeradd a b c , Fn timespecadd a b c 130Add 131.Fa b 132to 133.Fa a 134and store the result in 135.Fa c . 136.El 137.Sh RETURN VALUES 138The macros returning 139.Vt int 140return 1 if the tested condition holds or 0 otherwise. 141.Sh SEE ALSO 142.Xr adjtime 2 , 143.Xr clock_gettime 2 , 144.Xr futex 2 , 145.Xr futimens 2 , 146.Xr futimes 2 , 147.Xr getitimer 2 , 148.Xr gettimeofday 2 , 149.Xr kevent 2 , 150.Xr nanosleep 2 , 151.Xr ppoll 2 , 152.Xr pselect 2 153.Sh STANDARDS 154These macros are non-standard, 155though many systems offer them. 156Similar interfaces are often available in their absence. 157.Sh HISTORY 158The macros 159.Fn timerclear , 160.Fn timerisset , 161and 162.Fn timercmp 163first appeared in 164.Bx 4.1c , 165.Fn timersub 166and 167.Fn timeradd 168in 169.Nx 1.1 , 170and 171.Fn timerisvalid 172in 173.Ox 6.5 . 174