xref: /titanic_44/usr/src/cmd/sendmail/include/sm/clock.h (revision e1c679fa4b0ab8c4bcaa6263974ca0c46e5b027f)
1 /*
2  * Copyright (c) 1998-2001, 2004 Sendmail, Inc. and its suppliers.
3  *	All rights reserved.
4  * Copyright (c) 1983, 1995-1997 Eric P. Allman.  All rights reserved.
5  * Copyright (c) 1988, 1993
6  *	The Regents of the University of California.  All rights reserved.
7  *
8  * By using this file, you agree to the terms and conditions set
9  * forth in the LICENSE file which can be found at the top level of
10  * the sendmail distribution.
11  *
12  *	$Id: clock.h,v 1.12 2004/08/03 19:57:21 ca Exp $
13  */
14 
15 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17 /*
18 **  CLOCK.H -- for co-ordinating timed events
19 */
20 
21 #ifndef _SM_CLOCK_H
22 # define _SM_CLOCK_H 1
23 
24 # include <sm/signal.h>
25 # if SM_CONF_SETITIMER
26 #  include <sys/time.h>
27 # endif /* SM_CONF_SETITIMER */
28 
29 /*
30 **  STRUCT SM_EVENT -- event queue.
31 **
32 **	Maintained in sorted order.
33 **
34 **	We store the pid of the process that set this event to insure
35 **	that when we fork we will not take events intended for the parent.
36 */
37 
38 struct sm_event
39 {
40 # if SM_CONF_SETITIMER
41 	struct timeval	ev_time;	/* time of the call (microseconds) */
42 # else /* SM_CONF_SETITIMER */
43 	time_t		ev_time;	/* time of the call (seconds) */
44 # endif /* SM_CONF_SETITIMER */
45 	void		(*ev_func)__P((int));
46 					/* function to call */
47 	int		ev_arg;		/* argument to ev_func */
48 	pid_t		ev_pid;		/* pid that set this event */
49 	struct sm_event	*ev_link;	/* link to next item */
50 };
51 
52 typedef struct sm_event	SM_EVENT;
53 
54 /* functions */
55 extern void	sm_clrevent __P((SM_EVENT *));
56 extern void	sm_clear_events __P((void));
57 extern SM_EVENT	*sm_seteventm __P((int, void(*)__P((int)), int));
58 extern SM_EVENT	*sm_sigsafe_seteventm __P((int, void(*)__P((int)), int));
59 extern SIGFUNC_DECL	sm_tick __P((int));
60 
61 /*
62 **  SM_SETEVENT -- set an event to happen at a specific time in seconds.
63 **
64 **	Translates the seconds into millseconds and calls sm_seteventm()
65 **	to get a specific event to happen in the future at a specific time.
66 **
67 **	Parameters:
68 **		t -- intvl until next event occurs (seconds).
69 **		f -- function to call on event.
70 **		a -- argument to func on event.
71 **
72 **	Returns:
73 **		result of sm_seteventm().
74 **
75 **	Side Effects:
76 **		Any that sm_seteventm() have.
77 */
78 
79 #define sm_setevent(t, f, a) sm_seteventm((int)((t) * 1000), (f), (a))
80 #define sm_sigsafe_setevent(t, f, a) sm_sigsafe_seteventm((int)((t) * 1000), (f), (a))
81 
82 #endif /* _SM_CLOCK_H */
83