xref: /netbsd/sys/dev/raidframe/rf_etimer.h (revision de4337ab)
1 /*	$NetBSD: rf_etimer.h,v 1.11 2006/06/07 22:33:37 kardel 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@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 #include <sys/kernel.h>
36 
37 struct RF_Etimer_s {
38         struct timeval st;
39         struct timeval et;
40         struct timeval diff;
41 };
42 
43 #define RF_ETIMER_START(_t_)                                    \
44                 {                                               \
45                         memset(&(_t_), 0, sizeof (_t_));        \
46 			getmicrouptime(&(_t_).st);		\
47                 }
48 
49 #define RF_ETIMER_STOP(_t_)                                     \
50                 {                                               \
51 			getmicrouptime(&(_t_).et);		\
52                 }
53 
54 #define RF_ETIMER_EVAL(_t_)                                     \
55         {                                                       \
56                 RF_TIMEVAL_DIFF(&(_t_).st, &(_t_).et, &(_t_).diff) \
57         }
58 
59 #define RF_ETIMER_VAL_US(_t_)      (RF_TIMEVAL_TO_US((_t_).diff))
60 #define RF_ETIMER_VAL_MS(_t_)      (RF_TIMEVAL_TO_US((_t_).diff)/1000)
61 
62 #endif				/* !_RF__RF_TIMER_H_ */
63