xref: /onnv-gate/usr/src/cmd/filebench/common/filebench.h (revision 9326:475779da8c08)
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 2009 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 #include "config.h"
32 
33 #include <stdio.h>
34 #include <string.h>
35 #include <errno.h>
36 
37 #ifndef HAVE_BOOLEAN_T
38 typedef enum { B_FALSE, B_TRUE } boolean_t;
39 #endif
40 
41 #ifndef HAVE_U_LONGLONG_T
42 typedef unsigned long long u_longlong_t;
43 #endif
44 
45 #ifndef TRUE
46 #define	TRUE 1
47 #endif
48 
49 #ifndef FALSE
50 #define	FALSE 0
51 #endif
52 
53 #include "procflow.h"
54 #include "misc.h"
55 #include "ipc.h"
56 
57 #ifdef HAVE_STDINT_H
58 #include <stdint.h>
59 #endif
60 
61 
62 #ifdef __STDC__
63 #include <stdarg.h>
64 #define	__V(x)  x
65 #ifndef __P
66 #define	__P(x)  x
67 #endif
68 #else
69 #include <varargs.h>
70 #define	__V(x)  (va_alist) va_dcl
71 #define	__P(x)  ()
72 #define	const
73 #endif
74 
75 #include <sys/times.h>
76 
77 #ifdef HAVE_SYS_INT_LIMITS_H
78 #include <sys/int_limits.h>
79 #endif /* HAVE_SYS_INT_LIMITS_H */
80 
81 #ifdef	__cplusplus
82 extern "C" {
83 #endif
84 
85 extern pid_t my_pid;		/* this process' process id */
86 extern procflow_t *my_procflow;	/* if slave process, procflow pointer */
87 extern int errno;
88 extern char *execname;
89 extern int noproc;
90 
91 void filebench_init();
92 void filebench_log __V((int level, const char *fmt, ...));
93 void filebench_shutdown(int error);
94 void filebench_plugin_funcvecinit(void);
95 
96 #ifndef HAVE_UINT64_MAX
97 #define	UINT64_MAX (((off64_t)1UL<<63UL) - 1UL)
98 #endif
99 
100 #define	FILEBENCH_RANDMAX64 UINT64_MAX
101 #define	FILEBENCH_RANDMAX32 UINT32_MAX
102 
103 #if defined(_LP64) || (__WORDSIZE == 64)
104 #define	filebench_randomno filebench_randomno64
105 #define	FILEBENCH_RANDMAX FILEBENCH_RANDMAX64
106 #else
107 #define	filebench_randomno filebench_randomno32
108 #define	FILEBENCH_RANDMAX FILEBENCH_RANDMAX32
109 #endif
110 
111 #define	KB (1024LL)
112 #define	MB (KB * KB)
113 #define	GB (KB * MB)
114 
115 #define	MMAP_SIZE	(1024UL * 1024UL * 1024UL)
116 
117 #ifndef MIN
118 #define	MIN(x, y) ((x) < (y) ? (x) : (y))
119 #endif
120 
121 #define	FILEBENCH_VERSION	"1.4.5"
122 #define	FILEBENCHDIR	"/usr/benchmarks/filebench"
123 #define	FILEBENCH_PROMPT	"filebench> "
124 #define	MAX_LINE_LEN	1024
125 #define	MAX_CMD_HIST	128
126 #define	SHUTDOWN_WAIT_SECONDS	3 /* time to wait for proc / thrd to quit */
127 
128 #define	FILEBENCH_DONE	 1
129 #define	FILEBENCH_OK	 0
130 #define	FILEBENCH_ERROR -1
131 #define	FILEBENCH_NORSC -2
132 
133 /* For MacOSX */
134 #ifndef HAVE_OFF64_T
135 #define	mmap64 mmap
136 #define	off64_t off_t
137 #define	open64 open
138 #define	stat64 stat
139 #define	pread64 pread
140 #define	pwrite64 pwrite
141 #define	lseek64 lseek
142 #define	fstat64 fstat
143 #endif
144 
145 #ifdef	__cplusplus
146 }
147 #endif
148 
149 #endif	/* _FB_FILEBENCH_H */
150