Home | History | Annotate | Line # | Download | only in raidframe
rf_etimer.h revision 1.8
      1 /*	$NetBSD: rf_etimer.h,v 1.8 2001/10/04 17:42:29 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 #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                         int s;                                  \
     46                         memset(&(_t_), 0, sizeof (_t_));        \
     47                         s = splclock();                         \
     48                         (_t_).st = mono_time;                   \
     49                         splx(s);                                \
     50                 }
     51 
     52 #define RF_ETIMER_STOP(_t_)                                     \
     53                 {                                               \
     54                         int s;                                  \
     55                         s = splclock();                         \
     56                         (_t_).et = mono_time;                   \
     57                         splx(s);                                \
     58                 }
     59 
     60 #define RF_ETIMER_EVAL(_t_)                                     \
     61         {                                                       \
     62                 RF_TIMEVAL_DIFF(&(_t_).st, &(_t_).et, &(_t_).diff) \
     63         }
     64 
     65 #define RF_ETIMER_VAL_US(_t_)      (RF_TIMEVAL_TO_US((_t_).diff))
     66 #define RF_ETIMER_VAL_MS(_t_)      (RF_TIMEVAL_TO_US((_t_).diff)/1000)
     67 
     68 #endif				/* !_RF__RF_TIMER_H_ */
     69