xref: /onnv-gate/usr/src/cmd/filebench/common/filebench.h (revision 6084:d5f45b4dae7e)
15184Sek110237 /*
25184Sek110237  * CDDL HEADER START
35184Sek110237  *
45184Sek110237  * The contents of this file are subject to the terms of the
55184Sek110237  * Common Development and Distribution License (the "License").
65184Sek110237  * You may not use this file except in compliance with the License.
75184Sek110237  *
85184Sek110237  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95184Sek110237  * or http://www.opensolaris.org/os/licensing.
105184Sek110237  * See the License for the specific language governing permissions
115184Sek110237  * and limitations under the License.
125184Sek110237  *
135184Sek110237  * When distributing Covered Code, include this CDDL HEADER in each
145184Sek110237  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155184Sek110237  * If applicable, add the following below this CDDL HEADER, with the
165184Sek110237  * fields enclosed by brackets "[]" replaced with your own identifying
175184Sek110237  * information: Portions Copyright [yyyy] [name of copyright owner]
185184Sek110237  *
195184Sek110237  * CDDL HEADER END
205184Sek110237  */
215184Sek110237 /*
22*6084Saw148015  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
235184Sek110237  * Use is subject to license terms.
245184Sek110237  */
255184Sek110237 
265184Sek110237 #ifndef _FB_FILEBENCH_H
275184Sek110237 #define	_FB_FILEBENCH_H
285184Sek110237 
295184Sek110237 #pragma ident	"%Z%%M%	%I%	%E% SMI"
305184Sek110237 
315184Sek110237 #include "config.h"
325184Sek110237 
335184Sek110237 #include <stdio.h>
345184Sek110237 #include <string.h>
355184Sek110237 
365184Sek110237 #include "vars.h"
375184Sek110237 #include "misc.h"
385184Sek110237 #include "flowop.h"
395184Sek110237 #include "ipc.h"
405184Sek110237 
415184Sek110237 #ifdef HAVE_STDINT_H
425184Sek110237 #include <stdint.h>
435184Sek110237 #endif
445184Sek110237 
455184Sek110237 
465184Sek110237 #ifdef __STDC__
475184Sek110237 #include <stdarg.h>
485184Sek110237 #define	__V(x)  x
495184Sek110237 #ifndef __P
505184Sek110237 #define	__P(x)  x
515184Sek110237 #endif
525184Sek110237 #else
535184Sek110237 #include <varargs.h>
545184Sek110237 #define	__V(x)  (va_alist) va_dcl
555184Sek110237 #define	__P(x)  ()
565184Sek110237 #define	const
575184Sek110237 #endif
585184Sek110237 
595184Sek110237 #include <sys/times.h>
605184Sek110237 
615184Sek110237 #ifdef HAVE_SYS_INT_LIMITS_H
625184Sek110237 #include <sys/int_limits.h>
635184Sek110237 #endif /* HAVE_SYS_INT_LIMITS_H */
645184Sek110237 
655184Sek110237 #ifdef	__cplusplus
665184Sek110237 extern "C" {
675184Sek110237 #endif
685184Sek110237 
69*6084Saw148015 extern pid_t my_pid;		/* this process' process id */
70*6084Saw148015 extern procflow_t *my_procflow;	/* if slave process, procflow pointer */
715184Sek110237 extern int errno;
725184Sek110237 extern char *execname;
735184Sek110237 extern int noproc;
745184Sek110237 
755184Sek110237 void filebench_init();
765184Sek110237 void filebench_log __V((int level, const char *fmt, ...));
775184Sek110237 void filebench_shutdown(int error);
785184Sek110237 
795184Sek110237 #ifndef HAVE_UINT64_MAX
805184Sek110237 #define	UINT64_MAX (((off64_t)1UL<<63UL) - 1UL)
815184Sek110237 #endif
825184Sek110237 
835184Sek110237 #define	FILEBENCH_RANDMAX64 UINT64_MAX
845184Sek110237 #define	FILEBENCH_RANDMAX32 UINT32_MAX
855184Sek110237 
865184Sek110237 #if defined(_LP64) || (__WORDSIZE == 64)
875184Sek110237 #define	filebench_randomno filebench_randomno64
885184Sek110237 #define	FILEBENCH_RANDMAX FILEBENCH_RANDMAX64
895184Sek110237 #else
905184Sek110237 #define	filebench_randomno filebench_randomno32
915184Sek110237 #define	FILEBENCH_RANDMAX FILEBENCH_RANDMAX32
925184Sek110237 #endif
935184Sek110237 int filebench_randomno32(uint32_t *, uint32_t, uint32_t);
945184Sek110237 int filebench_randomno64(uint64_t *, uint64_t, uint64_t);
955184Sek110237 
965184Sek110237 #define	KB (1024LL)
975184Sek110237 #define	MB (KB * KB)
985184Sek110237 #define	GB (KB * MB)
995184Sek110237 
1005184Sek110237 #define	MMAP_SIZE	(1024UL * 1024UL * 1024UL)
1015184Sek110237 
1025184Sek110237 #ifndef MIN
1035184Sek110237 #define	MIN(x, y) ((x) < (y) ? (x) : (y))
1045184Sek110237 #endif
1055184Sek110237 
106*6084Saw148015 #define	FILEBENCH_VERSION	"1.1.1"
1075184Sek110237 #define	FILEBENCHDIR	"/usr/benchmarks/filebench"
1085184Sek110237 #define	FILEBENCH_PROMPT	"filebench> "
1095184Sek110237 #define	MAX_LINE_LEN	1024
1105184Sek110237 #define	MAX_CMD_HIST	128
111*6084Saw148015 #define	SHUTDOWN_WAIT_SECONDS	5 /* time to wait for proc / thrd to quit */
112*6084Saw148015 
113*6084Saw148015 #define	FILEBENCH_DONE	 1
114*6084Saw148015 #define	FILEBENCH_OK	 0
115*6084Saw148015 #define	FILEBENCH_ERROR -1
116*6084Saw148015 #define	FILEBENCH_NORSC -2
1175184Sek110237 
1185184Sek110237 /* For MacOSX */
1195184Sek110237 #ifndef HAVE_OFF64_T
1205184Sek110237 #define	mmap64 mmap
1215184Sek110237 #define	off64_t off_t
1225184Sek110237 #define	open64 open
1235184Sek110237 #define	stat64 stat
1245184Sek110237 #define	pread64 pread
1255184Sek110237 #define	pwrite64 pwrite
1265184Sek110237 #define	lseek64 lseek
1275184Sek110237 #define	fstat64 fstat
1285184Sek110237 #endif
1295184Sek110237 
1305184Sek110237 #ifdef	__cplusplus
1315184Sek110237 }
1325184Sek110237 #endif
1335184Sek110237 
1345184Sek110237 #endif	/* _FB_FILEBENCH_H */
135