00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef SIO_STANDALONE_H__
00016 #define SIO_PERF_H__
00017
00018
00019
00020
00021
00024 #include "H5public.h"
00025
00026
00027
00028
00029
00030 #ifdef H5_STDC_HEADERS
00031 # include <assert.h>
00032 # include <ctype.h>
00033 # include <errno.h>
00034 # include <fcntl.h>
00035 # include <float.h>
00036 # include <limits.h>
00037 # include <math.h>
00038 # include <signal.h>
00039 # include <stdarg.h>
00040 # include <stdio.h>
00041 # include <stdlib.h>
00042 # include <string.h>
00043 #endif
00044
00045
00046 #undef MAX
00047 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
00048 #define MAX2(a,b) MAX(a,b)
00049 #define MAX3(a,b,c) MAX(a,MAX(b,c))
00050 #define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d))
00051
00052
00053
00054
00055 #ifndef H5_INC_ENUM
00056 # define H5_INC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)+1))
00057 #endif
00058
00059
00060
00061
00062
00063 #define HDabort() abort()
00064 #define HDabs(X) abs(X)
00065 #define HDaccess(F,M) access(F, M)
00066 #define HDacos(X) acos(X)
00067 #ifdef H5_HAVE_ALARM
00068 #define HDalarm(N) alarm(N)
00069 #else
00070 #define HDalarm(N) (0)
00071 #endif
00072 #define HDasctime(T) asctime(T)
00073 #define HDasin(X) asin(X)
00074 #define HDassert(X) assert(X)
00075 #define HDatan(X) atan(X)
00076 #define HDatan2(X,Y) atan2(X,Y)
00077 #define HDatexit(F) atexit(F)
00078 #define HDatof(S) atof(S)
00079 #define HDatoi(S) atoi(S)
00080 #define HDatol(S) atol(S)
00081 #define HDBSDgettimeofday(S,P) BSDgettimeofday(S,P)
00082 #define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F)
00083 #define HDcalloc(N,Z) calloc(N,Z)
00084 #define HDceil(X) ceil(X)
00085 #define HDcfgetispeed(T) cfgetispeed(T)
00086 #define HDcfgetospeed(T) cfgetospeed(T)
00087 #define HDcfsetispeed(T,S) cfsetispeed(T,S)
00088 #define HDcfsetospeed(T,S) cfsetospeed(T,S)
00089 #define HDchdir(S) chdir(S)
00090 #define HDchmod(S,M) chmod(S,M)
00091 #define HDchown(S,O,G) chown(S,O,G)
00092 #define HDclearerr(F) clearerr(F)
00093 #define HDclock() clock()
00094 #define HDclose(F) close(F)
00095 #define HDclosedir(D) closedir(D)
00096 #define HDcos(X) cos(X)
00097 #define HDcosh(X) cosh(X)
00098 #define HDcreat(S,M) creat(S,M)
00099 #define HDctermid(S) ctermid(S)
00100 #define HDctime(T) ctime(T)
00101 #define HDcuserid(S) cuserid(S)
00102 #ifdef H5_HAVE_DIFFTIME
00103 #define HDdifftime(X,Y) difftime(X,Y)
00104 #else
00105 #define HDdifftime(X,Y) ((double)(X)-(double)(Y))
00106 #endif
00107 #define HDdiv(X,Y) div(X,Y)
00108 #define HDdup(F) dup(F)
00109 #define HDdup2(F,I) dup2(F,I)
00110
00111
00112
00113 #define HDexecv(S,AV) execv(S,AV)
00114 #define HDexecve(S,AV,E) execve(S,AV,E)
00115 #define HDexecvp(S,AV) execvp(S,AV)
00116 #define HDexit(N) exit(N)
00117 #if defined __MWERKS__
00118 #include <abort_exit.h>
00119 #define HD_exit(N) __exit(N)
00120 #else
00121 #define HD_exit(N) _exit(N)
00122 #endif
00123 #define HDexp(X) exp(X)
00124 #define HDfabs(X) fabs(X)
00125
00126 #define HDfabsf(X) ABS(X)
00127 #define HDfabsl(X) ABS(X)
00128 #define HDfclose(F) fclose(F)
00129
00130 #define HDfdopen(N,S) fdopen(N,S)
00131 #define HDfeof(F) feof(F)
00132 #define HDferror(F) ferror(F)
00133 #define HDfflush(F) fflush(F)
00134 #define HDfgetc(F) fgetc(F)
00135 #define HDfgetpos(F,P) fgetpos(F,P)
00136 #define HDfgets(S,N,F) fgets(S,N,F)
00137 #ifdef _WIN32
00138 #define HDfileno(F) _fileno(F)
00139 #else
00140 #define HDfileno(F) fileno(F)
00141 #endif
00142 #define HDfloor(X) floor(X)
00143 #define HDfmod(X,Y) fmod(X,Y)
00144 #define HDfopen(S,M) fopen(S,M)
00145 #define HDfork() fork()
00146 #define HDfpathconf(F,N) fpathconf(F,N)
00147 H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
00148 #define HDfputc(C,F) fputc(C,F)
00149 #define HDfputs(S,F) fputs(S,F)
00150 #define HDfread(M,Z,N,F) fread(M,Z,N,F)
00151 #define HDfree(M) free(M)
00152 #define HDfreopen(S,M,F) freopen(S,M,F)
00153 #define HDfrexp(X,N) frexp(X,N)
00154
00155 #ifdef H5_HAVE_FREXPF
00156 #define HDfrexpf(X,N) frexpf(X,N)
00157 #else
00158 #define HDfrexpf(X,N) frexp(X,N)
00159 #endif
00160 #ifdef H5_HAVE_FREXPL
00161 #define HDfrexpl(X,N) frexpl(X,N)
00162 #else
00163 #define HDfrexpl(X,N) frexp(X,N)
00164 #endif
00165
00166 #ifdef H5_HAVE_FSEEKO
00167 #define HDfseek(F,O,W) fseeko(F,O,W)
00168 #else
00169 #define HDfseek(F,O,W) fseek(F,O,W)
00170 #endif
00171 #define HDfsetpos(F,P) fsetpos(F,P)
00172
00173
00174
00175
00176
00177 #ifdef _WIN32
00178 #ifdef __MWERKS__
00179 #define HDfstat(F,B) fstat(F,B)
00180 #define HDlstat(S,B) lstat(S,B)
00181 #define HDstat(S,B) stat(S,B)
00182 typedef struct stat h5_stat_t;
00183 typedef off_t h5_stat_size_t;
00184 #else
00185 #define HDfstat(F,B) _fstati64(F,B)
00186 #define HDlstat(S,B) _lstati64(S,B)
00187 #define HDstat(S,B) _stati64(S,B)
00188 typedef struct _stati64 h5_stat_t;
00189 typedef __int64 h5_stat_size_t;
00190 #endif
00191 #elif H5_SIZEOF_OFF_T!=8 && H5_SIZEOF_OFF64_T==8 && defined(H5_HAVE_STAT64)
00192 #define HDfstat(F,B) fstat64(F,B)
00193 #define HDlstat(S,B) lstat64(S,B)
00194 #define HDstat(S,B) stat64(S,B)
00195 typedef struct stat64 h5_stat_t;
00196 typedef off64_t h5_stat_size_t;
00197 #else
00198 #define HDfstat(F,B) fstat(F,B)
00199 #define HDlstat(S,B) lstat(S,B)
00200 #define HDstat(S,B) stat(S,B)
00201 typedef struct stat h5_stat_t;
00202 typedef off_t h5_stat_size_t;
00203 #endif
00204
00205 #define HDftell(F) ftell(F)
00206 #define HDftruncate(F,L) ftruncate(F,L)
00207 #define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F)
00208 #define HDgetc(F) getc(F)
00209 #define HDgetchar() getchar()
00210 #define HDgetcwd(S,Z) getcwd(S,Z)
00211 #define HDgetegid() getegid()
00212 #define HDgetenv(S) getenv(S)
00213 #define HDgeteuid() geteuid()
00214 #define HDgetgid() getgid()
00215 #define HDgetgrgid(G) getgrgid(G)
00216 #define HDgetgrnam(S) getgrnam(S)
00217 #define HDgetgroups(Z,G) getgroups(Z,G)
00218 #define HDgetlogin() getlogin()
00219 #define HDgetpgrp() getpgrp()
00220 #define HDgetpid() getpid()
00221 #define HDgetppid() getppid()
00222 #define HDgetpwnam(S) getpwnam(S)
00223 #define HDgetpwuid(U) getpwuid(U)
00224 #define HDgetrusage(X,S) getrusage(X,S)
00225 #define HDgets(S) gets(S)
00226 #define HDgettimeofday(S,P) gettimeofday(S,P)
00227 #define HDgetuid() getuid()
00228 #define HDgmtime(T) gmtime(T)
00229 #define HDisalnum(C) isalnum((int)(C))
00230 #define HDisalpha(C) isalpha((int)(C))
00231 #define HDisatty(F) isatty(F)
00232 #define HDiscntrl(C) iscntrl((int)(C))
00233 #define HDisdigit(C) isdigit((int)(C))
00234 #define HDisgraph(C) isgraph((int)(C))
00235 #define HDislower(C) islower((int)(C))
00236 #define HDisprint(C) isprint((int)(C))
00237 #define HDispunct(C) ispunct((int)(C))
00238 #define HDisspace(C) isspace((int)(C))
00239 #define HDisupper(C) isupper((int)(C))
00240 #define HDisxdigit(C) isxdigit((int)(C))
00241 #define HDkill(P,S) kill(P,S)
00242 #define HDlabs(X) labs(X)
00243 #define HDldexp(X,N) ldexp(X,N)
00244 #define HDldiv(X,Y) ldiv(X,Y)
00245 #define HDlink(OLD,NEW) link(OLD,NEW)
00246 #define HDlocaleconv() localeconv()
00247 #define HDlocaltime(T) localtime(T)
00248 #define HDlog(X) log(X)
00249 #define HDlog10(X) log10(X)
00250 #define HDlongjmp(J,N) longjmp(J,N)
00251 #ifdef _WIN32
00252 #ifdef __MWERKS__
00253 #define HDlseek(F,O,W) lseek(F,O,W)
00254 #else
00255 #define HDlseek(F,O,W) _lseeki64(F,O,W)
00256 #endif
00257 #else
00258 #ifdef H5_HAVE_FSEEK64
00259 #define HDlseek(F,O,W) lseek64(F,O,W)
00260 #else
00261 #define HDlseek(F,O,W) lseek(F,O,W)
00262 #endif
00263 #endif
00264 #define HDmalloc(Z) malloc(Z)
00265 #define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z)
00266 #define HDmblen(S,N) mblen(S,N)
00267 #define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z)
00268 #define HDmbtowc(P,S,Z) mbtowc(P,S,Z)
00269 #define HDmemchr(S,C,Z) memchr(S,C,Z)
00270 #define HDmemcmp(X,Y,Z) memcmp(X,Y,Z)
00271
00272
00273
00274
00275 #define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z)
00276 #define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z)
00277
00278
00279
00280 #ifdef _WIN32
00281 #define HDmemset(X,C,Z) memset((void*)(X),C,Z)
00282 #else
00283 #define HDmemset(X,C,Z) memset(X,C,Z)
00284 #endif
00285 #ifdef _WIN32
00286 #define HDmkdir(S,M) _mkdir(S)
00287 #else
00288 #define HDmkdir(S,M) mkdir(S,M)
00289 #endif
00290 #define HDmkfifo(S,M) mkfifo(S,M)
00291 #define HDmktime(T) mktime(T)
00292 #define HDmodf(X,Y) modf(X,Y)
00293 #ifdef _O_BINARY
00294 #define HDopen(S,F,M) open(S,F|_O_BINARY,M)
00295 #else
00296 #define HDopen(S,F,M) open(S,F,M)
00297 #endif
00298 #define HDopendir(S) opendir(S)
00299 #define HDpathconf(S,N) pathconf(S,N)
00300 #define HDpause() pause()
00301 #define HDperror(S) perror(S)
00302 #define HDpipe(F) pipe(F)
00303 #define HDpow(X,Y) pow(X,Y)
00304
00305 #define HDputc(C,F) putc(C,F)
00306 #define HDputchar(C) putchar(C)
00307 #define HDputs(S) puts(S)
00308 #define HDqsort(M,N,Z,F) qsort(M,N,Z,F)
00309 #define HDraise(N) raise(N)
00310
00311 #ifdef H5_HAVE_RAND_R
00312 #define HDrandom() HDrand()
00313 H5_DLL int HDrand(void);
00314 #elif H5_HAVE_RANDOM
00315 #define HDrand() random()
00316 #define HDrandom() random()
00317 #else
00318 #define HDrand() rand()
00319 #define HDrandom() rand()
00320 #endif
00321
00322 #define HDread(F,M,Z) read(F,M,Z)
00323 #define HDreaddir(D) readdir(D)
00324 #define HDrealloc(M,Z) realloc(M,Z)
00325 #ifdef H5_VMS
00326 #ifdef __cplusplus
00327 extern "C" {
00328 #endif
00329 int HDremove_all(const char * fname);
00330 #ifdef __cplusplus
00331 }
00332 #endif
00333 #define HDremove(S) HDremove_all(S)
00334 #else
00335 #define HDremove(S) remove(S)
00336 #endif
00337 #define HDrename(OLD,NEW) rename(OLD,NEW)
00338 #define HDrewind(F) rewind(F)
00339 #define HDrewinddir(D) rewinddir(D)
00340 #define HDrmdir(S) rmdir(S)
00341
00342 #define HDsetbuf(F,S) setbuf(F,S)
00343 #define HDsetgid(G) setgid(G)
00344 #define HDsetjmp(J) setjmp(J)
00345 #define HDsetlocale(N,S) setlocale(N,S)
00346 #define HDsetpgid(P,PG) setpgid(P,PG)
00347 #define HDsetsid() setsid()
00348 #define HDsetuid(U) setuid(U)
00349
00350
00351 #ifndef _WIN32
00352 #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z)
00353 #else
00354 #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2))
00355 #endif
00356 #define HDsigaddset(S,N) sigaddset(S,N)
00357 #define HDsigdelset(S,N) sigdelset(S,N)
00358 #define HDsigemptyset(S) sigemptyset(S)
00359 #define HDsigfillset(S) sigfillset(S)
00360 #define HDsigismember(S,N) sigismember(S,N)
00361 #define HDsiglongjmp(J,N) siglongjmp(J,N)
00362 #define HDsignal(N,F) signal(N,F)
00363 #define HDsigpending(S) sigpending(S)
00364 #define HDsigprocmask(H,S,O) sigprocmask(H,S,O)
00365 #define HDsigsetjmp(J,N) sigsetjmp(J,N)
00366 #define HDsigsuspend(S) sigsuspend(S)
00367 #define HDsin(X) sin(X)
00368 #define HDsinh(X) sinh(X)
00369 #define HDsleep(N) sleep(N)
00370 #ifdef _WIN32
00371 #define HDsnprintf _snprintf
00372 #else
00373 #define HDsnprintf snprintf
00374 #endif
00375
00376 #define HDsqrt(X) sqrt(X)
00377 #ifdef H5_HAVE_RAND_R
00378 H5_DLL void HDsrand(unsigned int seed);
00379 #define HDsrandom(S) HDsrand(S)
00380 #elif H5_HAVE_RANDOM
00381 #define HDsrand(S) srandom(S)
00382 #define HDsrandom(S) srandom(S)
00383 #else
00384 #define HDsrand(S) srand(S)
00385 #define HDsrandom(S) srand(S)
00386 #endif
00387
00388
00389 #define HDstrcat(X,Y) strcat(X,Y)
00390 #define HDstrchr(S,C) strchr(S,C)
00391 #define HDstrcmp(X,Y) strcmp(X,Y)
00392 #define HDstrcoll(X,Y) strcoll(X,Y)
00393 #define HDstrcpy(X,Y) strcpy(X,Y)
00394 #define HDstrcspn(X,Y) strcspn(X,Y)
00395 #define HDstrerror(N) strerror(N)
00396 #define HDstrftime(S,Z,F,T) strftime(S,Z,F,T)
00397 #define HDstrlen(S) strlen(S)
00398 #define HDstrncat(X,Y,Z) strncat(X,Y,Z)
00399 #define HDstrncmp(X,Y,Z) strncmp(X,Y,Z)
00400 #define HDstrncpy(X,Y,Z) strncpy(X,Y,Z)
00401 #define HDstrpbrk(X,Y) strpbrk(X,Y)
00402 #define HDstrrchr(S,C) strrchr(S,C)
00403 #define HDstrspn(X,Y) strspn(X,Y)
00404 #define HDstrstr(X,Y) strstr(X,Y)
00405 #define HDstrtod(S,R) strtod(S,R)
00406 #define HDstrtok(X,Y) strtok(X,Y)
00407 #define HDstrtol(S,R,N) strtol(S,R,N)
00408 H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base);
00409 #define HDstrtoul(S,R,N) strtoul(S,R,N)
00410 #define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z)
00411 #define HDsysconf(N) sysconf(N)
00412 #define HDsystem(S) system(S)
00413 #define HDtan(X) tan(X)
00414 #define HDtanh(X) tanh(X)
00415 #define HDtcdrain(F) tcdrain(F)
00416 #define HDtcflow(F,A) tcflow(F,A)
00417 #define HDtcflush(F,N) tcflush(F,N)
00418 #define HDtcgetattr(F,T) tcgetattr(F,T)
00419 #define HDtcgetpgrp(F) tcgetpgrp(F)
00420 #define HDtcsendbreak(F,N) tcsendbreak(F,N)
00421 #define HDtcsetattr(F,O,T) tcsetattr(F,O,T)
00422 #define HDtcsetpgrp(F,N) tcsetpgrp(F,N)
00423 #define HDtime(T) time(T)
00424 #define HDtimes(T) times(T)
00425 #define HDtmpfile() tmpfile()
00426 #define HDtmpnam(S) tmpnam(S)
00427 #define HDtolower(C) tolower(C)
00428 #define HDtoupper(C) toupper(C)
00429 #define HDttyname(F) ttyname(F)
00430 #define HDtzset() tzset()
00431 #define HDumask(N) umask(N)
00432 #define HDuname(S) uname(S)
00433 #define HDungetc(C,F) ungetc(C,F)
00434 #ifdef _WIN32
00435 #define HDunlink(S) _unlink(S)
00436 #else
00437 #define HDunlink(S) unlink(S)
00438 #endif
00439 #define HDutime(S,T) utime(S,T)
00440 #define HDva_arg(A,T) va_arg(A,T)
00441 #define HDva_end(A) va_end(A)
00442 #define HDva_start(A,P) va_start(A,P)
00443 #define HDvasprintf(RET,FMT,A) vasprintf(RET,FMT,A)
00444 #define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A)
00445 #define HDvprintf(FMT,A) vprintf(FMT,A)
00446 #define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A)
00447 #ifdef _WIN32
00448 # define HDvsnprintf(S,N,FMT,A) _vsnprintf(S,N,FMT,A)
00449 #else
00450 # define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A)
00451 #endif
00452 #define HDwait(W) wait(W)
00453 #define HDwaitpid(P,W,O) waitpid(P,W,O)
00454 #define HDwcstombs(S,P,Z) wcstombs(S,P,Z)
00455 #define HDwctomb(S,C) wctomb(S,C)
00456
00457 #if defined (__MWERKS__)
00458
00459
00460
00461 #define HDwrite(F,M,Z) write(F,(void*)M,Z)
00462 #else
00463 #define HDwrite(F,M,Z) write(F,M,Z)
00464 #endif
00465
00466
00467
00468
00469
00470 #ifdef _WIN32
00471 #define HDstrdup(S) _strdup(S)
00472 #else
00473
00474 #if !defined strdup && !defined H5_HAVE_STRDUP
00475 extern char *strdup(const char *s);
00476 #endif
00477
00478 #define HDstrdup(S) strdup(S)
00479
00480 #endif
00481
00482
00483
00484
00485 #ifndef FALSE
00486 # define FALSE 0
00487 #endif
00488 #ifndef TRUE
00489 # define TRUE 1
00490 #endif
00491
00494 #ifdef H5_HAVE_PARALLEL
00495 extern MPI_Info h5_io_info_g;
00496 #endif
00497
00498 #ifdef H5_HAVE_PARALLEL
00499 H5TEST_DLL int h5_set_info_object(void);
00500 H5TEST_DLL void h5_dump_info_object(MPI_Info info);
00501 #endif
00502
00503
00504
00507 extern int opt_err;
00508 extern int opt_ind;
00509 extern const char *opt_arg;
00510
00511
00512 enum {
00513 no_arg = 0,
00514 require_arg,
00515 optional_arg
00516 };
00517
00518
00519 typedef struct long_options {
00520 const char *name;
00521 int has_arg;
00522 char shortval;
00523
00524 } long_options;
00525
00526 extern int get_option(int argc, const char **argv, const char *opt,
00527 const struct long_options *l_opt);
00528 #endif