xref: /onnv-gate/usr/src/cmd/filebench/common/filebench.h (revision 6701:4213fadfdec4)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  * Portions Copyright 2008 Denis Cheng
26  */
27 
28 #ifndef _FB_FILEBENCH_H
29 #define	_FB_FILEBENCH_H
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #include "config.h"
34 
35 #include <stdio.h>
36 #include <string.h>
37 #include <errno.h>
38 
39 #ifndef HAVE_BOOLEAN_T
40 typedef enum { B_FALSE, B_TRUE } boolean_t;
41 #endif
42 
43 #ifndef HAVE_U_LONGLONG_T
44 typedef unsigned long long u_longlong_t;
45 #endif
46 
47 #include "procflow.h"
48 #include "misc.h"
49 #include "ipc.h"
50 
51 #ifdef HAVE_STDINT_H
52 #include <stdint.h>
53 #endif
54 
55 
56 #ifdef __STDC__
57 #include <stdarg.h>
58 #define	__V(x)  x
59 #ifndef __P
60 #define	__P(x)  x
61 #endif
62 #else
63 #include <varargs.h>
64 #define	__V(x)  (va_alist) va_dcl
65 #define	__P(x)  ()
66 #define	const
67 #endif
68 
69 #include <sys/times.h>
70 
71 #ifdef HAVE_SYS_INT_LIMITS_H
72 #include <sys/int_limits.h>
73 #endif /* HAVE_SYS_INT_LIMITS_H */
74 
75 #ifdef	__cplusplus
76 extern "C" {
77 #endif
78 
79 #ifndef TRUE
80 #define	TRUE 1
81 #endif
82 
83 #ifndef FALSE
84 #define	FALSE 0
85 #endif
86 
87 extern pid_t my_pid;		/* this process' process id */
88 extern procflow_t *my_procflow;	/* if slave process, procflow pointer */
89 extern int errno;
90 extern char *execname;
91 extern int noproc;
92 
93 void filebench_init();
94 void filebench_log __V((int level, const char *fmt, ...));
95 void filebench_shutdown(int error);
96 
97 #ifndef HAVE_UINT64_MAX
98 #define	UINT64_MAX (((off64_t)1UL<<63UL) - 1UL)
99 #endif
100 
101 #define	FILEBENCH_RANDMAX64 UINT64_MAX
102 #define	FILEBENCH_RANDMAX32 UINT32_MAX
103 
104 #if defined(_LP64) || (__WORDSIZE == 64)
105 #define	filebench_randomno filebench_randomno64
106 #define	FILEBENCH_RANDMAX FILEBENCH_RANDMAX64
107 #else
108 #define	filebench_randomno filebench_randomno32
109 #define	FILEBENCH_RANDMAX FILEBENCH_RANDMAX32
110 #endif
111 
112 #define	KB (1024LL)
113 #define	MB (KB * KB)
114 #define	GB (KB * MB)
115 
116 #define	MMAP_SIZE	(1024UL * 1024UL * 1024UL)
117 
118 #ifndef MIN
119 #define	MIN(x, y) ((x) < (y) ? (x) : (y))
120 #endif
121 
122 #define	FILEBENCH_VERSION	"1.3.2"
123 #define	FILEBENCHDIR	"/usr/benchmarks/filebench"
124 #define	FILEBENCH_PROMPT	"filebench> "
125 #define	MAX_LINE_LEN	1024
126 #define	MAX_CMD_HIST	128
127 #define	SHUTDOWN_WAIT_SECONDS	5 /* time to wait for proc / thrd to quit */
128 
129 #define	FILEBENCH_DONE	 1
130 #define	FILEBENCH_OK	 0
131 #define	FILEBENCH_ERROR -1
132 #define	FILEBENCH_NORSC -2
133 
134 /* For MacOSX */
135 #ifndef HAVE_OFF64_T
136 #define	mmap64 mmap
137 #define	off64_t off_t
138 #define	open64 open
139 #define	stat64 stat
140 #define	pread64 pread
141 #define	pwrite64 pwrite
142 #define	lseek64 lseek
143 #define	fstat64 fstat
144 #endif
145 
146 #ifdef	__cplusplus
147 }
148 #endif
149 
150 #endif	/* _FB_FILEBENCH_H */
151