1 /*	$NetBSD: rf_utils.h,v 1.5 2001/10/04 15:58:56 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@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 /***************************************
30  *
31  * rf_utils.c -- header file for utils.c
32  *
33  ***************************************/
34 
35 
36 #ifndef _RF__RF_UTILS_H_
37 #define _RF__RF_UTILS_H_
38 
39 #include <dev/raidframe/raidframevar.h>
40 #include "rf_alloclist.h"
41 #include "rf_threadstuff.h"
42 
43 char   *rf_find_non_white(char *p);
44 char   *rf_find_white(char *p);
45 RF_RowCol_t **rf_make_2d_array(int b, int k, RF_AllocListElem_t * allocList);
46 RF_RowCol_t *rf_make_1d_array(int c, RF_AllocListElem_t * allocList);
47 void    rf_free_2d_array(RF_RowCol_t ** a, int b, int k);
48 void    rf_free_1d_array(RF_RowCol_t * a, int n);
49 int     rf_gcd(int m, int n);
50 int     rf_atoi(char *p);
51 int     rf_htoi(char *p);
52 
53 #define RF_USEC_PER_SEC 1000000
54 #define RF_TIMEVAL_TO_US(_t_) (((_t_).tv_sec) \
55                 * RF_USEC_PER_SEC + (_t_).tv_usec)
56 
57 #define RF_TIMEVAL_DIFF(_start_,_end_,_diff_) { \
58 	if ((_end_)->tv_usec < (_start_)->tv_usec) { \
59 		(_diff_)->tv_usec = ((_end_)->tv_usec + RF_USEC_PER_SEC) \
60 				- (_start_)->tv_usec; \
61 		(_diff_)->tv_sec = ((_end_)->tv_sec-1) - (_start_)->tv_sec; \
62 	} \
63 	else { \
64 		(_diff_)->tv_usec = (_end_)->tv_usec - (_start_)->tv_usec; \
65 		(_diff_)->tv_sec  = (_end_)->tv_sec  - (_start_)->tv_sec; \
66 	} \
67 }
68 
69 #endif				/* !_RF__RF_UTILS_H_ */
70