File: /usr/src/linux/net/bridge/br_private_timer.h

1     /*
2      *	Linux ethernet bridge
3      *
4      *	Authors:
5      *	Lennert Buytenhek		<buytenh@gnu.org>
6      *
7      *	$Id: br_private_timer.h,v 1.1 2000/02/18 16:47:13 davem Exp $
8      *
9      *	This program is free software; you can redistribute it and/or
10      *	modify it under the terms of the GNU General Public License
11      *	as published by the Free Software Foundation; either version
12      *	2 of the License, or (at your option) any later version.
13      */
14     
15     #ifndef _BR_PRIVATE_TIMER_H
16     #define _BR_PRIVATE_TIMER_H
17     
18     struct br_timer
19     {
20     	int running;
21     	unsigned long expires;
22     };
23     
24     extern __inline__ void br_timer_clear(struct br_timer *t)
25     {
26     	t->running = 0;
27     }
28     
29     extern __inline__ unsigned long br_timer_get_residue(struct br_timer *t)
30     {
31     	if (t->running)
32     		return jiffies - t->expires;
33     
34     	return 0;
35     }
36     
37     extern __inline__ void br_timer_set(struct br_timer *t, unsigned long x)
38     {
39     	t->expires = x;
40     	t->running = 1;
41     }
42     
43     extern __inline__ int br_timer_is_running(struct br_timer *t)
44     {
45     	return t->running;
46     }
47     
48     extern __inline__ int br_timer_has_expired(struct br_timer *t, unsigned long to)
49     {
50     	return t->running && time_after_eq(jiffies, t->expires + to);
51     }
52     
53     
54     #endif
55