Merge from vendor branch LIBSTDC++:
[dragonfly.git] / contrib / sendmail / include / sm / clock.h
1 /*
2  * Copyright (c) 1998-2001 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.11 2001/05/14 23:25:37 gshapiro Exp $
13  */
14
15 /*
16 **  CLOCK.H -- for co-ordinating timed events
17 */
18
19 #ifndef _SM_CLOCK_H
20 # define _SM_CLOCK_H 1
21
22 # include <sm/signal.h>
23 # if SM_CONF_SETITIMER
24 #  include <sys/time.h>
25 # endif /* SM_CONF_SETITIMER */
26
27 /*
28 **  STRUCT SM_EVENT -- event queue.
29 **
30 **      Maintained in sorted order.
31 **
32 **      We store the pid of the process that set this event to insure
33 **      that when we fork we will not take events intended for the parent.
34 */
35
36 struct sm_event
37 {
38 # if SM_CONF_SETITIMER
39         struct timeval  ev_time;        /* time of the call (microseconds) */
40 # else /* SM_CONF_SETITIMER */
41         time_t          ev_time;        /* time of the call (seconds) */
42 # endif /* SM_CONF_SETITIMER */
43         void            (*ev_func)__P((int));
44                                         /* function to call */
45         int             ev_arg;         /* argument to ev_func */
46         pid_t           ev_pid;         /* pid that set this event */
47         struct sm_event *ev_link;       /* link to next item */
48 };
49
50 typedef struct sm_event SM_EVENT;
51
52 /* functions */
53 extern void     sm_clrevent __P((SM_EVENT *));
54 extern void     sm_clear_events __P((void));
55 extern SM_EVENT *sm_setevent __P((time_t, void(*)(), int));
56 extern SM_EVENT *sm_seteventm __P((int, void(*)(), int));
57 extern SM_EVENT *sm_sigsafe_seteventm __P((int, void(*)(), int));
58 extern SIGFUNC_DECL     sm_tick __P((int));
59
60 /*
61 **  SM_SETEVENT -- set an event to happen at a specific time in seconds.
62 **
63 **      Translates the seconds into millseconds and calls sm_seteventm()
64 **      to get a specific event to happen in the future at a specific time.
65 **
66 **      Parameters:
67 **              t -- intvl until next event occurs (seconds).
68 **              f -- function to call on event.
69 **              a -- argument to func on event.
70 **
71 **      Returns:
72 **              result of sm_seteventm().
73 **
74 **      Side Effects:
75 **              Any that sm_seteventm() have.
76 */
77
78 #define sm_setevent(t, f, a) sm_seteventm((int)((t) * 1000), (f), (a))
79 #define sm_sigsafe_setevent(t, f, a) sm_sigsafe_seteventm((int)((t) * 1000), (f), (a))
80
81 #endif /* _SM_CLOCK_H */