Home | History | Annotate | Line # | Download | only in raidframe
rf_etimer.h revision 1.5
      1 /*	$NetBSD: rf_etimer.h,v 1.5 2001/07/18 06:45:33 thorpej 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_options.h"
     33 #include "rf_utils.h"
     34 
     35 #include <sys/time.h>
     36 
     37 struct RF_Etimer_s {
     38         struct timeval st;
     39         struct timeval et;
     40         struct timeval diff;
     41 };
     42 
     43 #if defined(_KERNEL)
     44 #include <sys/kernel.h>
     45 
     46 #define RF_ETIMER_START(_t_)                                    \
     47                 {                                               \
     48                         int s;                                  \
     49                         memset(&(_t_), 0, sizeof (_t_));        \
     50                         s = splclock();                         \
     51                         (_t_).st = mono_time;                   \
     52                         splx(s);                                \
     53                 }
     54 
     55 #define RF_ETIMER_STOP(_t_)                                     \
     56                 {                                               \
     57                         int s;                                  \
     58                         s = splclock();                         \
     59                         (_t_).et = mono_time;                   \
     60                         splx(s);                                \
     61                 }
     62 
     63 #define RF_ETIMER_EVAL(_t_)                                     \
     64         {                                                       \
     65                 RF_TIMEVAL_DIFF(&(_t_).st, &(_t_).et, &(_t_).diff) \
     66         }
     67 
     68 #define RF_ETIMER_VAL_US(_t_)      (RF_TIMEVAL_TO_US((_t_).diff))
     69 #define RF_ETIMER_VAL_MS(_t_)      (RF_TIMEVAL_TO_US((_t_).diff)/1000)
     70 
     71 #endif /* _KERNEL */
     72 
     73 #endif				/* !_RF__RF_TIMER_H_ */
     74