br_private_timer.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:1k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  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. #ifndef _BR_PRIVATE_TIMER_H
  15. #define _BR_PRIVATE_TIMER_H
  16. struct br_timer
  17. {
  18. int running;
  19. unsigned long expires;
  20. };
  21. extern __inline__ void br_timer_clear(struct br_timer *t)
  22. {
  23. t->running = 0;
  24. }
  25. extern __inline__ unsigned long br_timer_get_residue(struct br_timer *t)
  26. {
  27. if (t->running)
  28. return jiffies - t->expires;
  29. return 0;
  30. }
  31. extern __inline__ void br_timer_set(struct br_timer *t, unsigned long x)
  32. {
  33. t->expires = x;
  34. t->running = 1;
  35. }
  36. extern __inline__ int br_timer_is_running(struct br_timer *t)
  37. {
  38. return t->running;
  39. }
  40. extern __inline__ int br_timer_has_expired(struct br_timer *t, unsigned long to)
  41. {
  42. return t->running && time_after_eq(jiffies, t->expires + to);
  43. }
  44. #endif