xref: /titanic_52/usr/src/cmd/sendmail/include/sm/time.h (revision ac88567a7a5bb7f01cf22cf366bc9d6203e24d7a)
1 /*
2  * Copyright (c) 2005 Sendmail, Inc. and its suppliers.
3  *	All rights reserved.
4  *
5  * By using this file, you agree to the terms and conditions set
6  * forth in the LICENSE file which can be found at the top level of
7  * the sendmail distribution.
8  *
9  *	$Id: time.h,v 1.1 2005/06/14 23:07:19 ca Exp $
10  */
11 
12 #pragma ident	"%Z%%M%	%I%	%E% SMI"
13 
14 #ifndef SM_TIME_H
15 # define SM_TIME_H 1
16 
17 # include <sm/config.h>
18 
19 # include <sys/time.h>
20 
21 /* should be defined in sys/time.h */
22 #ifndef timersub
23 # define timersub(tvp, uvp, vvp)					\
24 	do								\
25 	{								\
26 		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
27 		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;	\
28 		if ((vvp)->tv_usec < 0)					\
29 		{							\
30 			(vvp)->tv_sec--;				\
31 			(vvp)->tv_usec += 1000000;			\
32 		}							\
33 	} while (0)
34 #endif /* !timersub */
35 
36 #ifndef timeradd
37 # define timeradd(tvp, uvp, vvp)					\
38 	do								\
39 	{								\
40 		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;		\
41 		(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;	\
42 		if ((vvp)->tv_usec >= 1000000)				\
43 		{							\
44 			(vvp)->tv_sec++;				\
45 			(vvp)->tv_usec -= 1000000;			\
46 		}							\
47 	} while (0)
48 #endif /* !timeradd */
49 
50 #ifndef timercmp
51 # define timercmp(tvp, uvp, cmp)					\
52 	(((tvp)->tv_sec == (uvp)->tv_sec) ?				\
53 	    ((tvp)->tv_usec cmp (uvp)->tv_usec) :			\
54 	    ((tvp)->tv_sec cmp (uvp)->tv_sec))
55 #endif /* !timercmp */
56 
57 
58 #endif /* ! SM_TIME_H */
59