xref: /onnv-gate/usr/src/cmd/filebench/common/filebench.h (revision 9801:4a9784073e11)
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 /*
228615SAndrew.W.Wilson@sun.com  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
235184Sek110237  * Use is subject to license terms.
246613Sek110237  *
256613Sek110237  * Portions Copyright 2008 Denis Cheng
265184Sek110237  */
275184Sek110237 
285184Sek110237 #ifndef _FB_FILEBENCH_H
295184Sek110237 #define	_FB_FILEBENCH_H
305184Sek110237 
315184Sek110237 #include "config.h"
325184Sek110237 
335184Sek110237 #include <stdio.h>
345184Sek110237 #include <string.h>
356613Sek110237 #include <errno.h>
365184Sek110237 
376613Sek110237 #ifndef HAVE_BOOLEAN_T
386613Sek110237 typedef enum { B_FALSE, B_TRUE } boolean_t;
396613Sek110237 #endif
406613Sek110237 
416613Sek110237 #ifndef HAVE_U_LONGLONG_T
426613Sek110237 typedef unsigned long long u_longlong_t;
436613Sek110237 #endif
446613Sek110237 
459513SAndrew.W.Wilson@sun.com #ifndef HAVE_UINT_T
469513SAndrew.W.Wilson@sun.com typedef unsigned int uint_t;
479513SAndrew.W.Wilson@sun.com #endif
489513SAndrew.W.Wilson@sun.com 
497556SAndrew.W.Wilson@sun.com #ifndef TRUE
507556SAndrew.W.Wilson@sun.com #define	TRUE 1
517556SAndrew.W.Wilson@sun.com #endif
527556SAndrew.W.Wilson@sun.com 
537556SAndrew.W.Wilson@sun.com #ifndef FALSE
547556SAndrew.W.Wilson@sun.com #define	FALSE 0
557556SAndrew.W.Wilson@sun.com #endif
567556SAndrew.W.Wilson@sun.com 
576613Sek110237 #include "procflow.h"
585184Sek110237 #include "misc.h"
595184Sek110237 #include "ipc.h"
605184Sek110237 
615184Sek110237 #ifdef HAVE_STDINT_H
625184Sek110237 #include <stdint.h>
635184Sek110237 #endif
645184Sek110237 
655184Sek110237 
665184Sek110237 #ifdef __STDC__
675184Sek110237 #include <stdarg.h>
685184Sek110237 #define	__V(x)  x
695184Sek110237 #ifndef __P
705184Sek110237 #define	__P(x)  x
715184Sek110237 #endif
725184Sek110237 #else
735184Sek110237 #include <varargs.h>
745184Sek110237 #define	__V(x)  (va_alist) va_dcl
755184Sek110237 #define	__P(x)  ()
765184Sek110237 #define	const
775184Sek110237 #endif
785184Sek110237 
795184Sek110237 #include <sys/times.h>
805184Sek110237 
815184Sek110237 #ifdef HAVE_SYS_INT_LIMITS_H
825184Sek110237 #include <sys/int_limits.h>
835184Sek110237 #endif /* HAVE_SYS_INT_LIMITS_H */
845184Sek110237 
855184Sek110237 #ifdef	__cplusplus
865184Sek110237 extern "C" {
875184Sek110237 #endif
885184Sek110237 
896084Saw148015 extern pid_t my_pid;		/* this process' process id */
906084Saw148015 extern procflow_t *my_procflow;	/* if slave process, procflow pointer */
915184Sek110237 extern int errno;
925184Sek110237 extern char *execname;
939513SAndrew.W.Wilson@sun.com extern char *fbbasepath;
945184Sek110237 extern int noproc;
955184Sek110237 
965184Sek110237 void filebench_init();
975184Sek110237 void filebench_log __V((int level, const char *fmt, ...));
985184Sek110237 void filebench_shutdown(int error);
998615SAndrew.W.Wilson@sun.com void filebench_plugin_funcvecinit(void);
1005184Sek110237 
1015184Sek110237 #ifndef HAVE_UINT64_MAX
1025184Sek110237 #define	UINT64_MAX (((off64_t)1UL<<63UL) - 1UL)
1035184Sek110237 #endif
1045184Sek110237 
1055184Sek110237 #define	FILEBENCH_RANDMAX64 UINT64_MAX
1065184Sek110237 #define	FILEBENCH_RANDMAX32 UINT32_MAX
1075184Sek110237 
1085184Sek110237 #if defined(_LP64) || (__WORDSIZE == 64)
1095184Sek110237 #define	filebench_randomno filebench_randomno64
1105184Sek110237 #define	FILEBENCH_RANDMAX FILEBENCH_RANDMAX64
1115184Sek110237 #else
1125184Sek110237 #define	filebench_randomno filebench_randomno32
1135184Sek110237 #define	FILEBENCH_RANDMAX FILEBENCH_RANDMAX32
1145184Sek110237 #endif
1155184Sek110237 
1165184Sek110237 #define	KB (1024LL)
1175184Sek110237 #define	MB (KB * KB)
1185184Sek110237 #define	GB (KB * MB)
1195184Sek110237 
1205184Sek110237 #define	MMAP_SIZE	(1024UL * 1024UL * 1024UL)
1215184Sek110237 
1225184Sek110237 #ifndef MIN
1235184Sek110237 #define	MIN(x, y) ((x) < (y) ? (x) : (y))
1245184Sek110237 #endif
1255184Sek110237 
126*9801SAndrew.W.Wilson@sun.com #define	FILEBENCH_VERSION	"1.4.8"
1275184Sek110237 #define	FILEBENCHDIR	"/usr/benchmarks/filebench"
1285184Sek110237 #define	FILEBENCH_PROMPT	"filebench> "
1295184Sek110237 #define	MAX_LINE_LEN	1024
1305184Sek110237 #define	MAX_CMD_HIST	128
1318762SAndrew.W.Wilson@sun.com #define	SHUTDOWN_WAIT_SECONDS	3 /* time to wait for proc / thrd to quit */
1326084Saw148015 
1336084Saw148015 #define	FILEBENCH_DONE	 1
1346084Saw148015 #define	FILEBENCH_OK	 0
1356084Saw148015 #define	FILEBENCH_ERROR -1
1366084Saw148015 #define	FILEBENCH_NORSC -2
1375184Sek110237 
1385184Sek110237 /* For MacOSX */
1395184Sek110237 #ifndef HAVE_OFF64_T
1405184Sek110237 #define	mmap64 mmap
1415184Sek110237 #define	off64_t off_t
1425184Sek110237 #define	open64 open
1435184Sek110237 #define	stat64 stat
1445184Sek110237 #define	pread64 pread
1455184Sek110237 #define	pwrite64 pwrite
1465184Sek110237 #define	lseek64 lseek
1475184Sek110237 #define	fstat64 fstat
1485184Sek110237 #endif
1495184Sek110237 
1505184Sek110237 #ifdef	__cplusplus
1515184Sek110237 }
1525184Sek110237 #endif
1535184Sek110237 
1545184Sek110237 #endif	/* _FB_FILEBENCH_H */
155