1 /*	$OpenBSD: rf_utils.h,v 1.5 2002/12/16 07:01:05 tdeval Exp $	*/
2 /*	$NetBSD: rf_utils.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 /****************************************
32  *
33  * rf_utils.c -- Header file for utils.c
34  *
35  ****************************************/
36 
37 
38 #ifndef	_RF__RF_UTILS_H_
39 #define	_RF__RF_UTILS_H_
40 
41 #include "rf_types.h"
42 #include "rf_alloclist.h"
43 #include "rf_threadstuff.h"
44 
45 char *rf_find_non_white(char *);
46 char *rf_find_white(char *);
47 RF_RowCol_t **rf_make_2d_array(int, int, RF_AllocListElem_t *);
48 RF_RowCol_t *rf_make_1d_array(int, RF_AllocListElem_t *);
49 void  rf_free_2d_array(RF_RowCol_t **, int, int);
50 void  rf_free_1d_array(RF_RowCol_t *, int);
51 int   rf_gcd(int, int);
52 int   rf_atoi(char *);
53 int   rf_htoi(char *);
54 
55 #define	RF_USEC_PER_SEC			1000000
56 #define	RF_TIMEVAL_TO_US(_t_)						\
57 	(((_t_).tv_sec) * RF_USEC_PER_SEC + (_t_).tv_usec)
58 
59 #define	RF_TIMEVAL_DIFF(_start_,_end_,_diff_)				\
60 do {									\
61 	if ((_end_)->tv_usec < (_start_)->tv_usec) {			\
62 		(_diff_)->tv_usec = ((_end_)->tv_usec +			\
63 		    RF_USEC_PER_SEC) - (_start_)->tv_usec;		\
64 		(_diff_)->tv_sec = ((_end_)->tv_sec-1) -		\
65 		    (_start_)->tv_sec;					\
66 	}								\
67 	else {								\
68 		(_diff_)->tv_usec = (_end_)->tv_usec -			\
69 		    (_start_)->tv_usec;					\
70 		(_diff_)->tv_sec  = (_end_)->tv_sec  -			\
71 		    (_start_)->tv_sec;					\
72 	}								\
73 } while (0)
74 
75 #endif	/* !_RF__RF_UTILS_H_ */
76