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