pio_standalone.h

00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00002  * Copyright by The HDF Group.                                               *
00003  * Copyright by the Board of Trustees of the University of Illinois.         *
00004  * All rights reserved.                                                      *
00005  *                                                                           *
00006  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00007  * terms governing use, modification, and redistribution, is contained in    *
00008  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00009  * of the source code distribution tree; Copyright.html can be found at the  *
00010  * root level of an installed copy of the electronic HDF5 document set and   *
00011  * is linked from the top-level documents page.  It can also be found at     *
00012  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00013  * access to either file, you may request a copy from help@hdfgroup.org.     *
00014  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00015 
00016 #ifndef PIO_STANDALONE_H__
00017 #define PIO_PERF_H__
00018 
00019 /* Header file for building h5perf by standalone mode.
00020  * Created: Christian Chilan, 2005/5/18.
00021  */
00022 
00025 #include "H5public.h"           /* Include Public Definitions           */
00026 
00027 
00028 /*
00029  * Include ANSI-C header files.
00030  */
00031 #ifdef H5_STDC_HEADERS
00032 #   include <assert.h>
00033 #   include <ctype.h>
00034 #   include <errno.h>
00035 #   include <fcntl.h>
00036 #   include <float.h>
00037 #   include <limits.h>
00038 #   include <math.h>
00039 #   include <signal.h>
00040 #   include <stdarg.h>
00041 #   include <stdio.h>
00042 #   include <stdlib.h>
00043 #   include <string.h>
00044 #endif
00045 
00046 /*
00047  * And now for a couple non-Posix functions...  Watch out for systems that
00048  * define these in terms of macros.
00049  */
00050 #ifdef _WIN32
00051 #define HDstrdup(S)                _strdup(S)
00052 #else /* _WIN32 */
00053 
00054 #if !defined strdup && !defined H5_HAVE_STRDUP
00055 extern char *strdup(const char *s);
00056 #endif
00057 
00058 #define HDstrdup(S)               strdup(S)
00059 
00060 #endif /* _WIN32 */
00061 
00062 H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
00063 #define HDstrcmp(S,T)             strcmp(S,T)
00064 #define HDstrlen(S)               strlen(S)
00065 #define HDstrncmp(S,T,L)          strncmp(S,T,L)
00066 #define HDstrncpy(X,Y,Z)          strncpy(X,Y,Z)
00067 #define HDstrchr(S,C)             strchr(S,C)
00068 #define HDfree(M)                 free(M)
00069 
00070 
00071 #ifdef _O_BINARY
00072 #define HDopen(S,F,M)             open(S,F|_O_BINARY,M)
00073 #else
00074 #define HDopen(S,F,M)             open(S,F,M)
00075 #endif
00076 #define HDclose(F)                close(F)
00077 
00078 #ifdef _WIN32
00079      #ifdef __MWERKS__
00080         #define HDlseek(F,O,W)  lseek(F,O,W)
00081      #else /*MSVS */
00082         #define HDlseek(F,O,W)  _lseeki64(F,O,W)
00083      #endif
00084 #else
00085 #define HDlseek(F,O,W)           lseek(F,O,W)
00086 #endif
00087 
00088 #if defined (__MWERKS__)
00089 /* workaround for a bug in the Metrowerks version 6.0 header file for write
00090  which is not defined as const void*
00091  */
00092 #define HDwrite(F,M,Z)          write(F,(void*)M,Z)
00093 #else
00094 #define HDwrite(F,M,Z)          write(F,M,Z)
00095 #endif
00096 
00097 #define HDread(F,M,Z)           read(F,M,Z)
00098 
00099 #ifdef _WIN32
00100      #ifdef __MWERKS__
00101      #define HDstat(S,B)        stat(S,B)
00102      #else /*MSVC*/
00103      #define HDstat(S,B)        _stati64(S,B)
00104      #endif
00105 #else
00106 #define HDstat(S,B)  stat(S,B)
00107 #endif
00108 
00109 #ifdef _WIN32
00110      #ifdef __MWERKS__
00111      #define HDfstat(F,B)       fstat(F,B)
00112      typedef struct stat        h5_stat_t;
00113      typedef off_t              h5_stat_size_t;
00114      #else /*MSVC*/
00115      #define HDfstat(F,B)       _fstati64(F,B)
00116      typedef struct _stati64    h5_stat_t;
00117      typedef __int64            h5_stat_size_t;
00118      #endif
00119 #else
00120 #define HDfstat(F,B)            fstat(F,B)
00121 typedef struct stat             h5_stat_t;
00122 typedef off_t                   h5_stat_size_t;
00123 #endif
00124 
00125 /*
00126  * HDF Boolean type.
00127  */
00128 #ifndef FALSE
00129 #   define FALSE 0
00130 #endif
00131 #ifndef TRUE
00132 #   define TRUE 1
00133 #endif
00134 
00135 
00138 #ifdef H5_HAVE_PARALLEL
00139 extern MPI_Info h5_io_info_g;         /* MPI INFO object for IO */
00140 #endif
00141 
00142 #ifdef H5_HAVE_PARALLEL
00143 H5TEST_DLL int h5_set_info_object(void);
00144 H5TEST_DLL void h5_dump_info_object(MPI_Info info);
00145 #endif
00146 
00147 
00148 
00151 extern int         opt_err;     /* getoption prints errors if this is on    */
00152 extern int         opt_ind;     /* token pointer                            */
00153 extern const char *opt_arg;     /* flag argument (or value)                 */
00154 
00155 
00156 enum {
00157     no_arg = 0,         /* doesn't take an argument     */
00158     require_arg,        /* requires an argument         */
00159     optional_arg        /* argument is optional         */
00160 };
00161 
00162 
00163 typedef struct long_options {
00164     const char  *name;          /* name of the long option              */
00165     int          has_arg;       /* whether we should look for an arg    */
00166     char         shortval;      /* the shortname equivalent of long arg
00167                                  * this gets returned from get_option   */
00168 } long_options;
00169 
00170 extern int    get_option(int argc, const char **argv, const char *opt,
00171                          const struct long_options *l_opt);
00172 
00173 extern int     nCols;               /*max number of columns for outputting  */
00174 
00175 /* Definitions of useful routines */
00176 extern void     print_version(const char *progname);
00177 
00178 #endif