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