1224006Shrs/*	$FreeBSD$	*/
2224006Shrs/*	$KAME: timer.h,v 1.5 2002/05/31 13:30:38 jinmei Exp $	*/
3224006Shrs
4224006Shrs/*
5224006Shrs * Copyright (C) 1998 WIDE Project.
6224006Shrs * All rights reserved.
7224006Shrs *
8224006Shrs * Redistribution and use in source and binary forms, with or without
9224006Shrs * modification, are permitted provided that the following conditions
10224006Shrs * are met:
11224006Shrs * 1. Redistributions of source code must retain the above copyright
12224006Shrs *    notice, this list of conditions and the following disclaimer.
13224006Shrs * 2. Redistributions in binary form must reproduce the above copyright
14224006Shrs *    notice, this list of conditions and the following disclaimer in the
15224006Shrs *    documentation and/or other materials provided with the distribution.
16224006Shrs * 3. Neither the name of the project nor the names of its contributors
17224006Shrs *    may be used to endorse or promote products derived from this software
18224006Shrs *    without specific prior written permission.
19224006Shrs *
20224006Shrs * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21224006Shrs * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22224006Shrs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23224006Shrs * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24224006Shrs * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25224006Shrs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26224006Shrs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27224006Shrs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28224006Shrs * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29224006Shrs * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30224006Shrs * SUCH DAMAGE.
31224006Shrs */
32224006Shrs
33224006Shrs#define	SSBUFLEN	1024
34224006Shrs
35253970Shrs#define TS_CMP(tsp, usp, cmp)						\
36253970Shrs	(((tsp)->tv_sec == (usp)->tv_sec) ?				\
37253970Shrs	    ((tsp)->tv_nsec cmp (usp)->tv_nsec) :			\
38253970Shrs	    ((tsp)->tv_sec cmp (usp)->tv_sec))
39253970Shrs#define TS_ADD(tsp, usp, vsp)						\
40253970Shrs	do {								\
41253970Shrs		(vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec;		\
42253970Shrs		(vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec;	\
43253970Shrs		if ((vsp)->tv_nsec >= 1000000000L) {			\
44253970Shrs			(vsp)->tv_sec++;				\
45253970Shrs			(vsp)->tv_nsec -= 1000000000L;			\
46253970Shrs		}							\
47253970Shrs	} while (0)
48253970Shrs#define TS_SUB(tsp, usp, vsp)						\
49253970Shrs	do {								\
50253970Shrs		(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec;		\
51253970Shrs		(vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec;	\
52253970Shrs		if ((vsp)->tv_nsec < 0) {				\
53253970Shrs			(vsp)->tv_sec--;				\
54253970Shrs			(vsp)->tv_nsec += 1000000000L;			\
55253970Shrs		}							\
56253970Shrs	} while (0)
57224006Shrs
58253970Shrsstruct timespec *rtadvd_timer_rest(struct rtadvd_timer *);
59224144Shrschar		*sec2str(uint32_t, char *buf);
60