include/bsd/netinet/ip_icmp.h
include/bsd/sys/bitstring.h
include/bsd/sys/queue.h
+ include/bsd/sys/time.h
include/bsd/timeconv.h
include/bsd/vis.h
man/bitstring.3bsd
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
+Files:
+ man/timeradd.3bsd
+Copyright:
+ Copyright © 2009 Jukka Ruohonen <jruohonen@iki.fi>
+ Copyright © 1999 Kelly Yancey <kbyanc@posi.net>
+ All rights reserved.
+License: BSD-3-clause-John-Birrell
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the author nor the names of any co-contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
Files:
man/setproctitle.3bsd
Copyright:
man/fmtcheck.3bsd
man/humanize_number.3bsd
man/stringlist.3bsd
+ man/timeval.3bsd
src/fmtcheck.c
src/humanize_number.c
src/stringlist.c
Copyright:
- Copyright © 1994, 1997-2000, 2002, 2008 The NetBSD Foundation, Inc.
+ Copyright © 1994, 1997-2000, 2002, 2008, 2010 The NetBSD Foundation, Inc.
All rights reserved.
.
Some code was contributed to The NetBSD Foundation by Allen Briggs.
.
Some code is derived from software contributed to The NetBSD Foundation
by Christos Zoulas.
+ .
+ Some code is derived from software contributed to The NetBSD Foundation
+ by Jukka Ruohonen.
License: BSD-2-clause-NetBSD
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
bsd/sys/endian.h \
bsd/sys/poll.h \
bsd/sys/queue.h \
+ bsd/sys/time.h \
bsd/sys/tree.h \
bsd/netinet/ip_icmp.h \
bsd/bitstring.h \
--- /dev/null
+/* $OpenBSD: time.h,v 1.36 2016/09/12 19:41:20 guenther Exp $ */
+/* $NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)time.h 8.2 (Berkeley) 7/10/94
+ */
+
+#ifdef LIBBSD_OVERLAY
+#include_next <sys/time.h>
+#else
+#include <sys/time.h>
+#endif
+
+#ifndef LIBBSD_SYS_TIME_H
+#define LIBBSD_SYS_TIME_H
+
+#ifndef TIMEVAL_TO_TIMESPEC
+#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+}
+#endif
+
+#ifndef TIMESPEC_TO_TIMEVAL
+#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+}
+#endif
+
+/* Operations on timevals. */
+#ifndef timerclear
+#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
+#endif
+
+#ifndef timerisset
+#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#endif
+
+#ifndef timercmp
+#define timercmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#endif
+
+#ifndef timeradd
+#define timeradd(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
+ if ((vvp)->tv_usec >= 1000000) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+#endif
+
+#ifndef timersub
+#define timersub(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
+ if ((vvp)->tv_usec < 0) { \
+ (vvp)->tv_sec--; \
+ (vvp)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif
+
+/* Operations on timespecs. */
+#ifndef timespecclear
+#define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0
+#endif
+
+#ifndef timespecisset
+#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec)
+#endif
+
+#ifndef timespeccmp
+#define timespeccmp(tsp, usp, cmp) \
+ (((tsp)->tv_sec == (usp)->tv_sec) ? \
+ ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
+ ((tsp)->tv_sec cmp (usp)->tv_sec))
+#endif
+
+#ifndef timespecadd
+#define timespecadd(tsp, usp, vsp) \
+ do { \
+ (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \
+ (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \
+ if ((vsp)->tv_nsec >= 1000000000L) { \
+ (vsp)->tv_sec++; \
+ (vsp)->tv_nsec -= 1000000000L; \
+ } \
+ } while (0)
+#endif
+
+#ifndef timespecsub
+#define timespecsub(tsp, usp, vsp) \
+ do { \
+ (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
+ (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
+ if ((vsp)->tv_nsec < 0) { \
+ (vsp)->tv_sec--; \
+ (vsp)->tv_nsec += 1000000000L; \
+ } \
+ } while (0)
+#endif
+
+#endif
TAILQ_PREV.3bsd \
TAILQ_REMOVE.3bsd \
TAILQ_SWAP.3bsd \
+ TIMESPEC_TO_TIMEVAL.3bsd \
+ TIMEVAL_TO_TIMESPEC.3bsd \
arc4random.3bsd \
arc4random_addrandom.3bsd \
arc4random_buf.3bsd \
strunvis.3bsd \
strvis.3bsd \
strvisx.3bsd \
+ timeradd.3bsd \
+ timerclear.3bsd \
+ timercmp.3bsd \
+ timerisset.3bsd \
+ timersub.3bsd \
+ timespecadd.3bsd \
+ timespecclear.3bsd \
+ timespeccmp.3bsd \
+ timespecisset.3bsd \
+ timespecsub.3bsd \
+ timeval.3bsd \
tree.3bsd \
unvis.3bsd \
vis.3bsd \
--- /dev/null
+.so man3/timeval.3bsd
--- /dev/null
+.so man3/timeval.3bsd
.It In sys/endian.h
.It In sys/poll.h
.It In sys/queue.h
+.It In sys/time.h
.It In sys/tree.h
.It In timeconv.h
.It In unistd.h
.Xr strmode 3bsd ,
.Xr strnstr 3bsd ,
.Xr strtonum 3bsd ,
+.Xr timeradd 3bsd ,
+.Xr timeval 3bsd ,
.Xr tree 3bsd ,
.Xr unvis 3bsd ,
.Xr vis 3bsd ,
--- /dev/null
+.\" $NetBSD: timeradd.3,v 1.8 2010/06/07 18:40:16 jruoho Exp $
+.\"
+.\" Copyright (c) 2009 Jukka Ruohonen <jruohonen@iki.fi>
+.\" Copyright (c) 1999 Kelly Yancey <kbyanc@posi.net>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the author nor the names of any co-contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD: src/share/man/man3/timeradd.3,v 1.3 2003/09/08 19:57:19 ru Exp $
+.\"
+.Dd June 7, 2010
+.Dt TIMERADD 3
+.Os
+.Sh NAME
+.Nm timeradd ,
+.Nm timersub ,
+.Nm timerclear ,
+.Nm timerisset ,
+.Nm timercmp ,
+.Nm timespecadd ,
+.Nm timespecsub ,
+.Nm timespecclear ,
+.Nm timespecisset ,
+.Nm timespeccmp
+.Nd operations on time structure
+.Sh LIBRARY
+.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
+.Lb libbsd
+.Sh SYNOPSIS
+.In sys/time.h
+(See
+.Xr libbsd 7
+for include usage.)
+.Ft void
+.Fn timeradd "struct timeval *a" "struct timeval *b" "struct timeval *res"
+.Ft void
+.Fn timersub "struct timeval *a" "struct timeval *b" "struct timeval *res"
+.Ft void
+.Fn timerclear "struct timeval *tv"
+.Ft int
+.Fn timerisset "struct timeval *tv"
+.Ft int
+.Fn timercmp "struct timeval *a" "struct timeval *b" CMP
+.Ft void
+.Fn timespecadd "struct timespec *a" \
+"struct timespec *b" "struct timespec *res"
+.Ft void
+.Fn timespecsub "struct timespec *a" \
+"struct timespec *b" "struct timespec *res"
+.Ft void
+.Fn timespecclear "struct timespec *ts"
+.Ft int
+.Fn timespecisset "struct timespec *ts"
+.Ft int
+.Fn timespeccmp "struct timespec *a" "struct timespec b" CMP
+.Sh DESCRIPTION
+These macros are provided for manipulating the
+.Fa timeval
+and
+.Fa timespec
+structures described in
+.Xr timeval 3 .
+.Pp
+The
+.Fn timeradd
+and
+.Fn timespecadd
+macros add the time information stored in
+.Fa a
+to
+.Fa b ,
+storing the result in
+.Fa res .
+With
+.Fn timeradd
+the results are simplified such that the value of
+.Fa res->tv_usec
+is always less than 1,000,000 (1 second).
+With
+.Fn timespecadd
+the
+.Fa res->tv_nsec
+member of
+.Fa struct timespec
+is always less than 1,000,000,000.
+.Pp
+The
+.Fn timersub
+and
+.Fn timespecsub
+macros subtract the time information stored in
+.Fa b
+from
+.Fa a
+and store the resulting structure
+in
+.Fa res .
+.Pp
+The
+.Fn timerclear
+and
+.Fn timespecclear
+macros initialize the structures
+to midnight (0 hour) January 1st, 1970 (the Epoch).
+In other words, they set the members of the structure to zero.
+.Pp
+The
+.Fn timerisset
+and
+.Fn timespecisset
+macros return true if the input structure
+is set to any time value other than the Epoch.
+.Pp
+The
+.Fn timercmp
+and
+.Fn timespeccmp
+macros compare
+.Fa a
+to
+.Fa b
+using the comparison operator given in
+.Fa CMP .
+The result of the comparison is returned.
+.Sh SEE ALSO
+.Xr timeval 3
+.Sh HISTORY
+The
+.Fn timeradd
+family of macros first appeared in
+.Nx 1.1 .
+These were later ported to
+.Fx 2.2.6 .
+The
+.Fn timespec
+family of macros first appeared in
+.Nx 1.2 .
--- /dev/null
+.so man3/timeradd.3bsd
--- /dev/null
+.so man3/timeradd.3bsd
--- /dev/null
+.so man3/timeradd.3bsd
--- /dev/null
+.so man3/timeradd.3bsd
--- /dev/null
+.so man3/timeradd.3bsd
--- /dev/null
+.so man3/timeradd.3bsd
--- /dev/null
+.so man3/timeradd.3bsd
--- /dev/null
+.so man3/timeradd.3bsd
--- /dev/null
+.so man3/timeradd.3bsd
--- /dev/null
+.\" $NetBSD: timeval.3,v 1.12 2011/04/12 08:39:26 jruoho Exp $
+.\"
+.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Jukka Ruohonen.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd April 12, 2011
+.Dt TIMEVAL 3
+.Os
+.Sh NAME
+.Nm timeval ,
+.Nm timespec
+.Nd time structures
+.Sh LIBRARY
+.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
+.Lb libbsd
+.Sh SYNOPSIS
+.In sys/time.h
+(See
+.Xr libbsd 7
+for include usage.)
+.Ft void
+.Fn TIMEVAL_TO_TIMESPEC "struct timeval *tv" "struct timespec *ts"
+.Ft void
+.Fn TIMESPEC_TO_TIMEVAL "struct timeval *tv" "struct timespec *ts"
+.Sh DESCRIPTION
+The
+.In sys/time.h
+header, included by
+.In time.h ,
+defines various structures related to time and timers.
+.Bl -enum -offset 1n
+.It
+The following structure is used by
+.Xr gettimeofday 2 ,
+among others:
+.Bd -literal -offset indent
+struct timeval {
+ time_t tv_sec;
+ suseconds_t tv_usec;
+};
+.Ed
+.Pp
+The
+.Va tv_sec
+member represents the elapsed time, in whole seconds.
+The
+.Va tv_usec
+member captures rest of the elapsed time,
+represented as the number of microseconds.
+.It
+The following structure is used by
+.Xr nanosleep 2 ,
+among others:
+.Bd -literal -offset indent
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+.Ed
+.Pp
+The
+.Va tv_sec
+member is again the elapsed time in whole seconds.
+The
+.Va tv_nsec
+member represents the rest of the elapsed time in nanoseconds.
+.Pp
+A microsecond is equal to one millionth of a second,
+1000 nanoseconds, or 1/1000 milliseconds.
+To ease the conversions, the macros
+.Fn TIMEVAL_TO_TIMESPEC
+and
+.Fn TIMESPEC_TO_TIMEVAL
+can be used to convert between
+.Em struct timeval
+and
+.Em struct timespec .
+.El
+.Sh EXAMPLES
+It can be stressed that the traditional
+.Tn UNIX
+.Va timeval
+and
+.Va timespec
+structures represent elapsed time, measured by the system clock.
+The following sketch implements a function suitable
+for use in a context where the
+.Va timespec
+structure is required for a conditional timeout:
+.Bd -literal -offset indent
+static void
+example(struct timespec *spec, time_t minutes)
+{
+ struct timeval elapsed;
+
+ (void)gettimeofday(&elapsed, NULL);
+
+ _DIAGASSERT(spec != NULL);
+ TIMEVAL_TO_TIMESPEC(&elapsed, spec);
+
+ /* Add the offset for timeout in minutes. */
+ spec->tv_sec = spec->tv_sec + minutes * 60;
+}
+.Ed
+.Pp
+A better alternative would use the more precise
+.Xr clock_gettime 2 .
+.Sh SEE ALSO
+.Xr timeradd 3