summaryrefslogtreecommitdiff
path: root/server/timer.h
blob: 04131825e49a63bf10ee9dad5ffad4dbea98e477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* This file is part of the Project Athena Zephyr Notification System.
 * It contains definitions used by timer.c
 *
 *	Created by:	John T. Kohl
 *	Derived from timer_manager_.h by Ken Raeburn
 *
 *	$Source$
 *	$Author$
 *	$Header$
 *
 */

/*
 * timer_manager_ -- routines for handling timers in login_shell
 * (and elsewhere)
 *
 * Copyright 1986 Student Information Processing Board,
 * Massachusetts Institute of Technology
 *
 * written by Ken Raeburn

Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of M.I.T. and the Student
Information Processing Board not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
M.I.T. and the Student Information Processing Board
make no representations about the suitability of
this software for any purpose.  It is provided "as is"
without express or implied warranty.

 */

#ifdef __STDC__
# define        P(s) s
#else
# define P(s) ()
#endif

typedef struct _timer {
	struct _timer 	*next;		/*  Next one to go off.. */
	struct _timer   *prev;		/*  Previous one to go off.. */
	/* time for timer to go off, absolute time */
	long 	alarm_time;
	/* procedure to call when timer goes off */
	void 	(*func)P((void*));
	/* argument for that procedure */
	void *	arg;
} *timer;

#define ALARM_TIME(x) ((x)->alarm_time)
#define ALARM_FUNC(x) ((x)->func)
#define ALARM_NEXT(x) ((x)->next)
#define ALARM_PREV(x) ((x)->prev)
#define ALARM_ARG(x)  ((x)->arg)
#define TIMER_SIZE sizeof(struct _timer)

#define NOW (gettimeofday(&t_local, (struct timezone *)0), t_local.tv_sec)
typedef void (*timer_proc) P((void *));
extern timer timer_set_rel P((long, timer_proc, void*));
extern timer timer_set_abs P((long, timer_proc, void*));
extern void timer_reset P((timer)), timer_process P((void));

#undef P

#define	timer_when(x)	ALARM_TIME(x)

extern struct timeval t_local;
extern long nexttimo;			/* Unix time of next timout */