1.\" $NetBSD: timeradd.3,v 1.10 2021/02/23 16:47:04 rillig Exp $ 2.\" 3.\" Copyright (c) 2009 Jukka Ruohonen <jruohonen@iki.fi> 4.\" Copyright (c) 1999 Kelly Yancey <kbyanc@posi.net> 5.\" 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 author nor the names of any co-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 JOHN BIRRELL 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.\" $FreeBSD: src/share/man/man3/timeradd.3,v 1.3 2003/09/08 19:57:19 ru Exp $ 32.\" 33.Dd June 7, 2010 34.Dt TIMERADD 3 35.Os 36.Sh NAME 37.Nm timeradd 38.Nd operations on time structure 39.Sh SYNOPSIS 40.In sys/time.h 41.Ft void 42.Fn timeradd "struct timeval *a" "struct timeval *b" "struct timeval *res" 43.Ft void 44.Fn timersub "struct timeval *a" "struct timeval *b" "struct timeval *res" 45.Ft void 46.Fn timerclear "struct timeval *tv" 47.Ft int 48.Fn timerisset "struct timeval *tv" 49.Ft int 50.Fn timercmp "struct timeval *a" "struct timeval *b" CMP 51.Ft void 52.Fn timespecadd "struct timespec *a" \ 53"struct timespec *b" "struct timespec *res" 54.Ft void 55.Fn timespecsub "struct timespec *a" \ 56"struct timespec *b" "struct timespec *res" 57.Ft void 58.Fn timespecclear "struct timespec *ts" 59.Ft int 60.Fn timespecisset "struct timespec *ts" 61.Ft int 62.Fn timespeccmp "const struct timespec *a" "const struct timespec *b" CMP 63.Sh DESCRIPTION 64These macros are provided for manipulating the 65.Fa timeval 66and 67.Fa timespec 68structures described in 69.Xr timeval 3 . 70.Pp 71The 72.Fn timeradd 73and 74.Fn timespecadd 75macros add the time information stored in 76.Fa a 77to 78.Fa b , 79storing the result in 80.Fa res . 81With 82.Fn timeradd 83the results are simplified such that the value of 84.Fa res->tv_usec 85is always less than 1,000,000 (1 second). 86With 87.Fn timespecadd 88the 89.Fa res->tv_nsec 90member of 91.Fa struct timespec 92is always less than 1,000,000,000. 93.Pp 94The 95.Fn timersub 96and 97.Fn timespecsub 98macros subtract the time information stored in 99.Fa b 100from 101.Fa a 102and store the resulting structure 103in 104.Fa res . 105.Pp 106The 107.Fn timerclear 108and 109.Fn timespecclear 110macros initialize the structures 111to midnight (0 hour) January 1st, 1970 (the Epoch). 112In other words, they set the members of the structure to zero. 113.Pp 114The 115.Fn timerisset 116and 117.Fn timespecisset 118macros return true if the input structure 119is set to any time value other than the Epoch. 120.Pp 121The 122.Fn timercmp 123and 124.Fn timespeccmp 125macros compare 126.Fa a 127to 128.Fa b 129using the comparison operator given in 130.Fa CMP . 131The result of the comparison is returned. 132.Sh SEE ALSO 133.Xr timeval 3 134.Sh HISTORY 135The 136.Fn timeradd 137family of macros first appeared in 138.Nx 1.1 . 139These were later ported to 140.Fx 2.2.6 . 141The 142.Fn timespec 143family of macros first appeared in 144.Nx 1.2 . 145