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