rf_etimer.h revision 1.7 1 /* $NetBSD: rf_etimer.h,v 1.7 2001/10/04 17:41:17 oster Exp $ */
2 /*
3 * Copyright (c) 1995 Carnegie-Mellon University.
4 * All rights reserved.
5 *
6 * Author: Mark Holland
7 *
8 * Permission to use, copy, modify and distribute this software and
9 * its documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
16 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
27 */
28
29 #ifndef _RF__RF_TIMER_H_
30 #define _RF__RF_TIMER_H_
31
32 #include "rf_utils.h"
33
34 #include <sys/time.h>
35
36 struct RF_Etimer_s {
37 struct timeval st;
38 struct timeval et;
39 struct timeval diff;
40 };
41
42 #include <sys/kernel.h>
43
44 #define RF_ETIMER_START(_t_) \
45 { \
46 int s; \
47 memset(&(_t_), 0, sizeof (_t_)); \
48 s = splclock(); \
49 (_t_).st = mono_time; \
50 splx(s); \
51 }
52
53 #define RF_ETIMER_STOP(_t_) \
54 { \
55 int s; \
56 s = splclock(); \
57 (_t_).et = mono_time; \
58 splx(s); \
59 }
60
61 #define RF_ETIMER_EVAL(_t_) \
62 { \
63 RF_TIMEVAL_DIFF(&(_t_).st, &(_t_).et, &(_t_).diff) \
64 }
65
66 #define RF_ETIMER_VAL_US(_t_) (RF_TIMEVAL_TO_US((_t_).diff))
67 #define RF_ETIMER_VAL_MS(_t_) (RF_TIMEVAL_TO_US((_t_).diff)/1000)
68
69 #endif /* !_RF__RF_TIMER_H_ */
70