00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _H5private_H
00027 #define _H5private_H
00028
00029 #include "H5public.h"
00030
00031
00032 #ifdef H5_HAVE_THREADSAFE
00033 #include <pthread.h>
00034 #endif
00035
00036
00037
00038
00039 #ifdef H5_STDC_HEADERS
00040 # include <assert.h>
00041 # include <ctype.h>
00042 # include <errno.h>
00043 # include <fcntl.h>
00044 # include <float.h>
00045 # include <limits.h>
00046 # include <math.h>
00047 # include <signal.h>
00048 # include <stdarg.h>
00049 # include <stdio.h>
00050 # include <stdlib.h>
00051 # include <string.h>
00052 #endif
00053
00054
00055
00056
00057
00058 #ifdef H5_HAVE_UNISTD_H
00059 # include <sys/types.h>
00060 # include <unistd.h>
00061 #endif
00062 #ifdef _POSIX_VERSION
00063 # include <sys/wait.h>
00064 # include <pwd.h>
00065 #endif
00066
00067
00068
00069
00070 #ifndef __cplusplus
00071 #ifdef H5_HAVE_STDINT_H
00072 # include <stdint.h>
00073 #endif
00074 #endif
00075
00076
00077
00078
00079
00080
00081 #ifdef H5_HAVE_SYS_STAT_H
00082 # include <sys/stat.h>
00083 #endif
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 #if defined(H5_TIME_WITH_SYS_TIME)
00096 # include <sys/time.h>
00097 # include <time.h>
00098 #elif defined(H5_HAVE_SYS_TIME_H)
00099 # include <sys/time.h>
00100 #else
00101 # include <time.h>
00102 #endif
00103
00104
00105
00106
00107 #ifdef H5_HAVE_SETJMP_H
00108 # include <setjmp.h>
00109 #endif
00110
00111
00112
00113
00114
00115 #ifdef H5_HAVE_SYS_RESOURCE_H
00116 # include <sys/resource.h>
00117 #endif
00118
00119
00120
00121
00122
00123 #ifdef H5_HAVE_SYS_IOCTL_H
00124 # include <sys/ioctl.h>
00125 #endif
00126
00127
00128
00129
00130
00131
00132 #ifdef H5_HAVE_SYS_SYSINFO_H
00133 # include <sys/sysinfo.h>
00134 #endif
00135 #ifdef H5_HAVE_SYS_PROC_H
00136 # include <sys/proc.h>
00137 #endif
00138 #ifdef H5_HAVE_IO_H
00139 # include <io.h>
00140 #endif
00141
00142
00143 #ifdef _WIN32
00144
00145 #define VC_EXTRALEAN
00146 #include <windows.h>
00147 #include <direct.h>
00148
00149 #endif
00150
00151
00152 #ifndef H5_inline
00153 #define H5_inline
00154 #endif
00155
00156
00157 #ifndef F_OK
00158 # define F_OK 00
00159 # define W_OK 02
00160 # define R_OK 04
00161 #endif
00162
00163
00164
00165
00166 #ifdef H5_HAVE_MPE
00167
00168
00169
00170
00171
00172
00173
00174
00175 #include "mpe.h"
00176
00177
00178
00179
00180 #define eventa(func_name) h5_mpe_eventa
00181 #define eventb(func_name) h5_mpe_eventb
00182 #define MPE_LOG_VARS(func_name) \
00183 static int eventa(func_name) = -1; \
00184 static int eventb(func_name) = -1; \
00185 const char* p_end_funcname = #func_name; \
00186 const char* p_event_start = "start" #func_name;
00187
00188
00189
00190
00191
00192
00193
00194
00195 #define BEGIN_MPE_LOG(func_name) \
00196 if (H5_MPEinit_g){ \
00197 if (eventa(func_name) == -1 && eventb(func_name) == -1) { \
00198 const char* p_color = "red"; \
00199 eventa(func_name)=MPE_Log_get_event_number(); \
00200 eventb(func_name)=MPE_Log_get_event_number(); \
00201 MPE_Describe_state(eventa(func_name), eventb(func_name), (char *)p_end_funcname, (char *)p_color); \
00202 } \
00203 MPE_Log_event(eventa(func_name), 0, (char *)p_event_start); \
00204 }
00205
00206
00207
00208
00209
00210
00211
00212
00213 #define FINISH_MPE_LOG \
00214 if (H5_MPEinit_g) { \
00215 MPE_Log_event(eventb(func_name), 0, (char *)p_end_funcname); \
00216 }
00217
00218 #else
00219 #define MPE_LOG_VARS(func_name)
00220 #define BEGIN_MPE_LOG(func_name)
00221 #define FINISH_MPE_LOG
00222
00223 #endif
00224
00225
00226
00227
00228 #ifdef H5_HAVE_DMALLOC_H
00229 #include "dmalloc.h"
00230 #endif
00231
00232
00233
00234
00235
00236
00237
00238 #ifndef SIGBUS
00239 # define SIGBUS SIGILL
00240 #endif
00241
00242
00243
00244
00245
00246
00247 #ifdef __cplusplus
00248 # define __attribute__(X)
00249 # define UNUSED
00250 #else
00251 #ifdef H5_HAVE_ATTRIBUTE
00252 # define UNUSED __attribute__((unused))
00253 #else
00254 # define __attribute__(X)
00255 # define UNUSED
00256 #endif
00257 #endif
00258
00259
00260
00261
00262
00263
00264 #ifndef H5_HAVE_FUNCTION
00265 # define __FUNCTION__ "NoFunctionName"
00266 #endif
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 #define SUCCEED 0
00278 #define FAIL (-1)
00279 #define UFAIL (unsigned)(-1)
00280
00281
00282 #ifndef NELMTS
00283 # define NELMTS(X) (sizeof(X)/sizeof(X[0]))
00284 #endif
00285
00286
00287 #undef MIN
00288 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
00289 #define MIN2(a,b) MIN(a,b)
00290 #define MIN3(a,b,c) MIN(a,MIN(b,c))
00291 #define MIN4(a,b,c,d) MIN(MIN(a,b),MIN(c,d))
00292
00293
00294 #undef MAX
00295 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
00296 #define MAX2(a,b) MAX(a,b)
00297 #define MAX3(a,b,c) MAX(a,MAX(b,c))
00298 #define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d))
00299
00300
00301 #define RANGE(LO,X,HI) MAX(LO,MIN(X,HI))
00302
00303
00304 #ifndef ABS
00305 # define ABS(a) (((a)>=0) ? (a) : -(a))
00306 #endif
00307
00308
00309 #ifndef SIGN
00310 # define SIGN(a) ((a)>0 ? 1 : (a)<0 ? -1 : 0)
00311 #endif
00312
00313
00314
00315 # define POWER_OF_TWO(n) (!(n & (n - 1)) && n)
00316
00317
00318
00319
00320 #ifndef FALSE
00321 # define FALSE 0
00322 #endif
00323 #ifndef TRUE
00324 # define TRUE 1
00325 #endif
00326
00327
00328
00329
00330
00331
00332
00333
00334 #if H5_SIZEOF_INT8_T==0
00335 typedef signed char int8_t;
00336 # undef H5_SIZEOF_INT8_T
00337 # define H5_SIZEOF_INT8_T H5_SIZEOF_CHAR
00338 #elif H5_SIZEOF_INT8_T==1
00339 #else
00340 # error "the int8_t type must be 1 byte wide"
00341 #endif
00342
00343 #if H5_SIZEOF_UINT8_T==0
00344 typedef unsigned char uint8_t;
00345 # undef H5_SIZEOF_UINT8_T
00346 # define H5_SIZEOF_UINT8_T H5_SIZEOF_CHAR
00347 #elif H5_SIZEOF_UINT8_T==1
00348 #else
00349 # error "the uint8_t type must be 1 byte wide"
00350 #endif
00351
00352 #if H5_SIZEOF_INT16_T>=2
00353 #elif H5_SIZEOF_SHORT>=2
00354 typedef short int16_t;
00355 # undef H5_SIZEOF_INT16_T
00356 # define H5_SIZEOF_INT16_T H5_SIZEOF_SHORT
00357 #elif H5_SIZEOF_INT>=2
00358 typedef int int16_t;
00359 # undef H5_SIZEOF_INT16_T
00360 # define H5_SIZEOF_INT16_T H5_SIZEOF_INT
00361 #else
00362 # error "nothing appropriate for int16_t"
00363 #endif
00364
00365 #if H5_SIZEOF_UINT16_T>=2
00366 #elif H5_SIZEOF_SHORT>=2
00367 typedef unsigned short uint16_t;
00368 # undef H5_SIZEOF_UINT16_T
00369 # define H5_SIZEOF_UINT16_T H5_SIZEOF_SHORT
00370 #elif H5_SIZEOF_INT>=2
00371 typedef unsigned uint16_t;
00372 # undef H5_SIZEOF_UINT16_T
00373 # define H5_SIZEOF_UINT16_T H5_SIZEOF_INT
00374 #else
00375 # error "nothing appropriate for uint16_t"
00376 #endif
00377
00378 #if H5_SIZEOF_INT32_T>=4
00379 #elif H5_SIZEOF_SHORT>=4
00380 typedef short int32_t;
00381 # undef H5_SIZEOF_INT32_T
00382 # define H5_SIZEOF_INT32_T H5_SIZEOF_SHORT
00383 #elif H5_SIZEOF_INT>=4
00384 typedef int int32_t;
00385 # undef H5_SIZEOF_INT32_T
00386 # define H5_SIZEOF_INT32_T H5_SIZEOF_INT
00387 #elif H5_SIZEOF_LONG>=4
00388 typedef long int32_t;
00389 # undef H5_SIZEOF_INT32_T
00390 # define H5_SIZEOF_INT32_T H5_SIZEOF_LONG
00391 #else
00392 # error "nothing appropriate for int32_t"
00393 #endif
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404 #ifndef LLONG_MAX
00405 # define LLONG_MAX ((long long)(((unsigned long long)1 \
00406 <<(8*sizeof(long long)-1))-1))
00407 # define LLONG_MIN ((long long)(-LLONG_MAX)-1)
00408 #endif
00409 #ifndef ULLONG_MAX
00410 # define ULLONG_MAX ((unsigned long long)((long long)(-1)))
00411 #endif
00412 #ifndef SIZET_MAX
00413 # define SIZET_MAX ((size_t)(ssize_t)(-1))
00414 # define SSIZET_MAX ((ssize_t)(((size_t)1<<(8*sizeof(ssize_t)-1))-1))
00415 #endif
00416
00417
00418
00419
00420 #define HSIZET_MAX ((hsize_t)ULLONG_MAX)
00421 #define HSSIZET_MAX ((hssize_t)LLONG_MAX)
00422 #define HSSIZET_MIN (~(HSSIZET_MAX))
00423
00424
00425
00426
00427 #ifndef H5_INC_ENUM
00428 # define H5_INC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)+1))
00429 #endif
00430
00431
00432
00433
00434 #ifndef H5_DEC_ENUM
00435 # define H5_DEC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)-1))
00436 #endif
00437
00438
00439
00440
00441 typedef struct {
00442 double utime;
00443 double stime;
00444 double etime;
00445 } H5_timer_t;
00446
00447 H5_DLL void H5_timer_reset (H5_timer_t *timer);
00448 H5_DLL void H5_timer_begin (H5_timer_t *timer);
00449 H5_DLL void H5_timer_end (H5_timer_t *sum,
00450 H5_timer_t *timer);
00451 H5_DLL void H5_bandwidth(char *buf, double nbytes, double nseconds);
00452 H5_DLL time_t H5_now(void);
00453
00454
00455 typedef enum {
00456 H5_COPY_SHALLOW,
00457 H5_COPY_DEEP
00458 } H5_copy_depth_t;
00459
00460
00461 typedef struct H5O_copy_file_ud_common_t {
00462 struct H5O_pline_t *src_pline;
00463 } H5O_copy_file_ud_common_t;
00464
00465
00466 typedef struct {
00467 unsigned long fileno;
00468 haddr_t addr;
00469 } H5_obj_t;
00470
00471
00472
00473
00474
00475
00476
00477 #include "H5win32defs.h"
00478
00479 #ifndef HDabort
00480 #define HDabort() abort()
00481 #endif
00482 #ifndef HDabs
00483 #define HDabs(X) abs(X)
00484 #endif
00485 #ifndef HDaccess
00486 #define HDaccess(F,M) access(F, M)
00487 #endif
00488 #ifndef HDacos
00489 #define HDacos(X) acos(X)
00490 #endif
00491 #ifndef HDalarm
00492 #ifdef H5_HAVE_ALARM
00493 #define HDalarm(N) alarm(N)
00494 #else
00495 #define HDalarm(N) (0)
00496 #endif
00497 #endif
00498 #ifndef HDasctime
00499 #define HDasctime(T) asctime(T)
00500 #endif
00501 #ifndef HDasin
00502 #define HDasin(X) asin(X)
00503 #endif
00504 #ifndef HDassert
00505 #define HDassert(X) assert(X)
00506 #endif
00507 #ifndef HDatan
00508 #define HDatan(X) atan(X)
00509 #endif
00510 #ifndef HDatan2
00511 #define HDatan2(X,Y) atan2(X,Y)
00512 #endif
00513 #ifndef HDatexit
00514 #define HDatexit(F) atexit(F)
00515 #endif
00516 #ifndef HDatof
00517 #define HDatof(S) atof(S)
00518 #endif
00519 #ifndef HDatoi
00520 #define HDatoi(S) atoi(S)
00521 #endif
00522 #ifndef HDatol
00523 #define HDatol(S) atol(S)
00524 #endif
00525 #ifndef HDBSDgettimeofday
00526 #define HDBSDgettimeofday(S,P) BSDgettimeofday(S,P)
00527 #endif
00528 #ifndef HDbsearch
00529 #define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F)
00530 #endif
00531 #ifndef HDcalloc
00532 #define HDcalloc(N,Z) calloc(N,Z)
00533 #endif
00534 #ifndef HDceil
00535 #define HDceil(X) ceil(X)
00536 #endif
00537 #ifndef HDcfgetispeed
00538 #define HDcfgetispeed(T) cfgetispeed(T)
00539 #endif
00540 #ifndef HDcfgetospeed
00541 #define HDcfgetospeed(T) cfgetospeed(T)
00542 #endif
00543 #ifndef HDcfsetispeed
00544 #define HDcfsetispeed(T,S) cfsetispeed(T,S)
00545 #endif
00546 #ifndef HDcfsetospeed
00547 #define HDcfsetospeed(T,S) cfsetospeed(T,S)
00548 #endif
00549 #ifndef HDchdir
00550 #define HDchdir(S) chdir(S)
00551 #endif
00552 #ifndef HDchmod
00553 #define HDchmod(S,M) chmod(S,M)
00554 #endif
00555 #ifndef HDchown
00556 #define HDchown(S,O,G) chown(S,O,G)
00557 #endif
00558 #ifndef HDclearerr
00559 #define HDclearerr(F) clearerr(F)
00560 #endif
00561 #ifndef HDclock
00562 #define HDclock() clock()
00563 #endif
00564 #ifndef HDclose
00565 #define HDclose(F) close(F)
00566 #endif
00567 #ifndef HDclosedir
00568 #define HDclosedir(D) closedir(D)
00569 #endif
00570 #ifndef HDcos
00571 #define HDcos(X) cos(X)
00572 #endif
00573 #ifndef HDcosh
00574 #define HDcosh(X) cosh(X)
00575 #endif
00576 #ifndef HDcreat
00577 #define HDcreat(S,M) creat(S,M)
00578 #endif
00579 #ifndef HDctermid
00580 #define HDctermid(S) ctermid(S)
00581 #endif
00582 #ifndef HDctime
00583 #define HDctime(T) ctime(T)
00584 #endif
00585 #ifndef HDcuserid
00586 #define HDcuserid(S) cuserid(S)
00587 #endif
00588 #ifndef HDdifftime
00589 #ifdef H5_HAVE_DIFFTIME
00590 #define HDdifftime(X,Y) difftime(X,Y)
00591 #else
00592 #define HDdifftime(X,Y) ((double)(X)-(double)(Y))
00593 #endif
00594 #endif
00595 #ifndef HDdiv
00596 #define HDdiv(X,Y) div(X,Y)
00597 #endif
00598 #ifndef HDdup
00599 #define HDdup(F) dup(F)
00600 #endif
00601 #ifndef HDdup2
00602 #define HDdup2(F,I) dup2(F,I)
00603 #endif
00604
00605
00606
00607 #ifndef HDexecv
00608 #define HDexecv(S,AV) execv(S,AV)
00609 #endif
00610 #ifndef HDexecve
00611 #define HDexecve(S,AV,E) execve(S,AV,E)
00612 #endif
00613 #ifndef HDexecvp
00614 #define HDexecvp(S,AV) execvp(S,AV)
00615 #endif
00616 #ifndef HDexit
00617 #define HDexit(N) exit(N)
00618 #endif
00619 #ifndef HD_exit
00620 #define HD_exit(N) _exit(N)
00621 #endif
00622 #ifndef HDexp
00623 #define HDexp(X) exp(X)
00624 #endif
00625 #ifndef HDfabs
00626 #define HDfabs(X) fabs(X)
00627 #endif
00628
00629 #ifndef HDfabsf
00630 #define HDfabsf(X) ABS(X)
00631 #endif
00632 #ifndef HDfabsl
00633 #define HDfabsl(X) ABS(X)
00634 #endif
00635 #ifndef HDfclose
00636 #define HDfclose(F) fclose(F)
00637 #endif
00638
00639 #ifndef HDfdopen
00640 #define HDfdopen(N,S) fdopen(N,S)
00641 #endif
00642 #ifndef HDfeof
00643 #define HDfeof(F) feof(F)
00644 #endif
00645 #ifndef HDferror
00646 #define HDferror(F) ferror(F)
00647 #endif
00648 #ifndef HDfflush
00649 #define HDfflush(F) fflush(F)
00650 #endif
00651 #ifndef HDfgetc
00652 #define HDfgetc(F) fgetc(F)
00653 #endif
00654 #ifndef HDfgetpos
00655 #define HDfgetpos(F,P) fgetpos(F,P)
00656 #endif
00657 #ifndef HDfgets
00658 #define HDfgets(S,N,F) fgets(S,N,F)
00659 #endif
00660 #ifndef HDfileno
00661 #define HDfileno(F) fileno(F)
00662 #endif
00663 #ifndef HDfloor
00664 #define HDfloor(X) floor(X)
00665 #endif
00666 #ifndef HDfmod
00667 #define HDfmod(X,Y) fmod(X,Y)
00668 #endif
00669 #ifndef HDfopen
00670 #define HDfopen(S,M) fopen(S,M)
00671 #endif
00672 #ifndef HDfork
00673 #define HDfork() fork()
00674 #endif
00675 #ifndef HDfpathconf
00676 #define HDfpathconf(F,N) fpathconf(F,N)
00677 #endif
00678 H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
00679 #ifndef HDfputc
00680 #define HDfputc(C,F) fputc(C,F)
00681 #endif
00682 #ifndef HDfputs
00683 #define HDfputs(S,F) fputs(S,F)
00684 #endif
00685 #ifndef HDfread
00686 #define HDfread(M,Z,N,F) fread(M,Z,N,F)
00687 #endif
00688 #ifndef HDfree
00689 #define HDfree(M) free(M)
00690 #endif
00691 #ifndef HDfreopen
00692 #define HDfreopen(S,M,F) freopen(S,M,F)
00693 #endif
00694 #ifndef HDfrexp
00695 #define HDfrexp(X,N) frexp(X,N)
00696 #endif
00697
00698 #ifndef HDfrexpf
00699 #ifdef H5_HAVE_FREXPF
00700 #define HDfrexpf(X,N) frexpf(X,N)
00701 #else
00702 #define HDfrexpf(X,N) frexp(X,N)
00703 #endif
00704 #endif
00705 #ifndef HDfrexpl
00706 #ifdef H5_HAVE_FREXPL
00707 #define HDfrexpl(X,N) frexpl(X,N)
00708 #else
00709 #define HDfrexpl(X,N) frexp(X,N)
00710 #endif
00711 #endif
00712
00713 #ifndef HDfseek
00714 #ifdef H5_HAVE_FSEEKO
00715 #define HDfseek(F,O,W) fseeko(F,O,W)
00716 #else
00717 #define HDfseek(F,O,W) fseek(F,O,W)
00718 #endif
00719 #endif
00720 #ifndef HDfsetpos
00721 #define HDfsetpos(F,P) fsetpos(F,P)
00722 #endif
00723
00724
00725
00726
00727 #if !defined(HDfstat) || !defined(HDstat) || !defined(HDlstat)
00728 #if H5_SIZEOF_OFF_T!=8 && H5_SIZEOF_OFF64_T==8 && defined(H5_HAVE_STAT64)
00729 #ifndef HDfstat
00730 #define HDfstat(F,B) fstat64(F,B)
00731 #endif
00732 #ifndef HDlstat
00733 #define HDlstat(S,B) lstat64(S,B)
00734 #endif
00735 #ifndef HDstat
00736 #define HDstat(S,B) stat64(S,B)
00737 #endif
00738 typedef struct stat64 h5_stat_t;
00739 typedef off64_t h5_stat_size_t;
00740 #define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF64_T
00741 #else
00742 #ifndef HDfstat
00743 #define HDfstat(F,B) fstat(F,B)
00744 #endif
00745 #ifndef HDlstat
00746 #define HDlstat(S,B) lstat(S,B)
00747 #endif
00748 #ifndef HDstat
00749 #define HDstat(S,B) stat(S,B)
00750 #endif
00751 typedef struct stat h5_stat_t;
00752 typedef off_t h5_stat_size_t;
00753 #define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF_T
00754 #endif
00755 #endif
00756
00757 #ifndef HDftell
00758 #define HDftell(F) ftell(F)
00759 #endif
00760 #ifndef HDftruncate
00761 #ifdef H5_HAVE_FTRUNCATE64
00762 #define HDftruncate(F,L) ftruncate64(F,L)
00763 #else
00764 #define HDftruncate(F,L) ftruncate(F,L)
00765 #endif
00766 #endif
00767 #ifndef HDfwrite
00768 #define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F)
00769 #endif
00770 #ifndef HDgetc
00771 #define HDgetc(F) getc(F)
00772 #endif
00773 #ifndef HDgetchar
00774 #define HDgetchar() getchar()
00775 #endif
00776 #ifndef HDgetcwd
00777 #define HDgetcwd(S,Z) getcwd(S,Z)
00778 #endif
00779 #ifndef HDgetdcwd
00780 #define HDgetdcwd(D,S,Z) getcwd(S,Z)
00781 #endif
00782 #ifndef HDgetdrive
00783 #define HDgetdrive() 0
00784 #endif
00785 #ifndef HDgetegid
00786 #define HDgetegid() getegid()
00787 #endif
00788 #ifndef HDgetenv
00789 #define HDgetenv(S) getenv(S)
00790 #endif
00791 #ifndef HDgeteuid
00792 #define HDgeteuid() geteuid()
00793 #endif
00794 #ifndef HDgetgid
00795 #define HDgetgid() getgid()
00796 #endif
00797 #ifndef HDgetgrgid
00798 #define HDgetgrgid(G) getgrgid(G)
00799 #endif
00800 #ifndef HDgetgrnam
00801 #define HDgetgrnam(S) getgrnam(S)
00802 #endif
00803 #ifndef HDgetgroups
00804 #define HDgetgroups(Z,G) getgroups(Z,G)
00805 #endif
00806 #ifndef HDgetlogin
00807 #define HDgetlogin() getlogin()
00808 #endif
00809 #ifndef HDgetpgrp
00810 #define HDgetpgrp() getpgrp()
00811 #endif
00812 #ifndef HDgetpid
00813 #define HDgetpid() getpid()
00814 #endif
00815 #ifndef HDgetppid
00816 #define HDgetppid() getppid()
00817 #endif
00818 #ifndef HDgetpwnam
00819 #define HDgetpwnam(S) getpwnam(S)
00820 #endif
00821 #ifndef HDgetpwuid
00822 #define HDgetpwuid(U) getpwuid(U)
00823 #endif
00824 #ifndef HDgetrusage
00825 #define HDgetrusage(X,S) getrusage(X,S)
00826 #endif
00827 #ifndef HDgets
00828 #define HDgets(S) gets(S)
00829 #endif
00830 #ifndef HDgettimeofday
00831 #define HDgettimeofday(S,P) gettimeofday(S,P)
00832 #endif
00833 #ifndef HDgetuid
00834 #define HDgetuid() getuid()
00835 #endif
00836 #ifndef HDgmtime
00837 #define HDgmtime(T) gmtime(T)
00838 #endif
00839 #ifndef HDisalnum
00840 #define HDisalnum(C) isalnum((int)(C))
00841 #endif
00842 #ifndef HDisalpha
00843 #define HDisalpha(C) isalpha((int)(C))
00844 #endif
00845 #ifndef HDisatty
00846 #define HDisatty(F) isatty(F)
00847 #endif
00848 #ifndef HDiscntrl
00849 #define HDiscntrl(C) iscntrl((int)(C))
00850 #endif
00851 #ifndef HDisdigit
00852 #define HDisdigit(C) isdigit((int)(C))
00853 #endif
00854 #ifndef HDisgraph
00855 #define HDisgraph(C) isgraph((int)(C))
00856 #endif
00857 #ifndef HDislower
00858 #define HDislower(C) islower((int)(C))
00859 #endif
00860 #ifndef HDisprint
00861 #define HDisprint(C) isprint((int)(C))
00862 #endif
00863 #ifndef HDispunct
00864 #define HDispunct(C) ispunct((int)(C))
00865 #endif
00866 #ifndef HDisspace
00867 #define HDisspace(C) isspace((int)(C))
00868 #endif
00869 #ifndef HDisupper
00870 #define HDisupper(C) isupper((int)(C))
00871 #endif
00872 #ifndef HDisxdigit
00873 #define HDisxdigit(C) isxdigit((int)(C))
00874 #endif
00875 #ifndef HDkill
00876 #define HDkill(P,S) kill(P,S)
00877 #endif
00878 #ifndef HDlabs
00879 #define HDlabs(X) labs(X)
00880 #endif
00881 #ifndef HDldexp
00882 #define HDldexp(X,N) ldexp(X,N)
00883 #endif
00884 #ifndef HDldiv
00885 #define HDldiv(X,Y) ldiv(X,Y)
00886 #endif
00887 #ifndef HDlink
00888 #define HDlink(OLD,NEW) link(OLD,NEW)
00889 #endif
00890 #ifndef HDlocaleconv
00891 #define HDlocaleconv() localeconv()
00892 #endif
00893 #ifndef HDlocaltime
00894 #define HDlocaltime(T) localtime(T)
00895 #endif
00896 #ifndef HDlog
00897 #define HDlog(X) log(X)
00898 #endif
00899 #ifndef HDlog10
00900 #define HDlog10(X) log10(X)
00901 #endif
00902 #ifndef HDlongjmp
00903 #define HDlongjmp(J,N) longjmp(J,N)
00904 #endif
00905 #ifndef HDlseek
00906 #ifdef H5_HAVE_LSEEK64
00907 #define HDlseek(F,O,W) lseek64(F,O,W)
00908 #else
00909 #define HDlseek(F,O,W) lseek(F,O,W)
00910 #endif
00911 #endif
00912 #ifndef HDmalloc
00913 #define HDmalloc(Z) malloc(Z)
00914 #endif
00915 #ifndef HDposix_memalign
00916 #define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z)
00917 #endif
00918 #ifndef HDmblen
00919 #define HDmblen(S,N) mblen(S,N)
00920 #endif
00921 #ifndef HDmbstowcs
00922 #define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z)
00923 #endif
00924 #ifndef HDmbtowc
00925 #define HDmbtowc(P,S,Z) mbtowc(P,S,Z)
00926 #endif
00927 #ifndef HDmemchr
00928 #define HDmemchr(S,C,Z) memchr(S,C,Z)
00929 #endif
00930 #ifndef HDmemcmp
00931 #define HDmemcmp(X,Y,Z) memcmp(X,Y,Z)
00932 #endif
00933
00934
00935
00936
00937 #ifndef HDmemcpy
00938 #define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z)
00939 #endif
00940 #ifndef HDmemmove
00941 #define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z)
00942 #endif
00943 #ifndef HDmemset
00944 #define HDmemset(X,C,Z) memset(X,C,Z)
00945 #endif
00946 #ifndef HDmkdir
00947 #define HDmkdir(S,M) mkdir(S,M)
00948 #endif
00949 #ifndef HDmkfifo
00950 #define HDmkfifo(S,M) mkfifo(S,M)
00951 #endif
00952 #ifndef HDmktime
00953 #define HDmktime(T) mktime(T)
00954 #endif
00955 #ifndef HDmodf
00956 #define HDmodf(X,Y) modf(X,Y)
00957 #endif
00958 #ifndef HDopen
00959 #ifdef _O_BINARY
00960 #define HDopen(S,F,M) open(S,F|_O_BINARY,M)
00961 #else
00962 #define HDopen(S,F,M) open(S,F,M)
00963 #endif
00964 #endif
00965 #ifndef HDopendir
00966 #define HDopendir(S) opendir(S)
00967 #endif
00968 #ifndef HDpathconf
00969 #define HDpathconf(S,N) pathconf(S,N)
00970 #endif
00971 #ifndef HDpause
00972 #define HDpause() pause()
00973 #endif
00974 #ifndef HDperror
00975 #define HDperror(S) perror(S)
00976 #endif
00977 #ifndef HDpipe
00978 #define HDpipe(F) pipe(F)
00979 #endif
00980 #ifndef HDpow
00981 #define HDpow(X,Y) pow(X,Y)
00982 #endif
00983
00984 #ifndef HDputc
00985 #define HDputc(C,F) putc(C,F)
00986 #endif
00987 #ifndef HDputchar
00988 #define HDputchar(C) putchar(C)
00989 #endif
00990 #ifndef HDputs
00991 #define HDputs(S) puts(S)
00992 #endif
00993 #ifndef HDqsort
00994 #define HDqsort(M,N,Z,F) qsort(M,N,Z,F)
00995 #endif
00996 #ifndef HDraise
00997 #define HDraise(N) raise(N)
00998 #endif
00999
01000 #ifdef H5_HAVE_RAND_R
01001 #ifndef HDrandom
01002 #define HDrandom() HDrand()
01003 #endif
01004 H5_DLL int HDrand(void);
01005 #elif H5_HAVE_RANDOM
01006 #ifndef HDrand
01007 #define HDrand() random()
01008 #endif
01009 #ifndef HDrandom
01010 #define HDrandom() random()
01011 #endif
01012 #else
01013 #ifndef HDrand
01014 #define HDrand() rand()
01015 #endif
01016 #ifndef HDrandom
01017 #define HDrandom() rand()
01018 #endif
01019 #endif
01020
01021 #ifndef HDread
01022 #define HDread(F,M,Z) read(F,M,Z)
01023 #endif
01024 #ifndef HDreaddir
01025 #define HDreaddir(D) readdir(D)
01026 #endif
01027 #ifndef HDrealloc
01028 #define HDrealloc(M,Z) realloc(M,Z)
01029 #endif
01030 #ifndef HDrealpath
01031 #define HDrealpath(F1,F2) realpath(F1,F2)
01032 #endif
01033 #ifdef H5_VMS
01034 #ifdef __cplusplus
01035 extern "C" {
01036 #endif
01037 int HDremove_all(const char * fname);
01038 #ifdef __cplusplus
01039 }
01040 #endif
01041 #ifndef HDremove
01042 #define HDremove(S) HDremove_all(S)
01043 #endif
01044 #else
01045 #ifndef HDremove
01046 #define HDremove(S) remove(S)
01047 #endif
01048 #endif
01049 #ifndef HDrename
01050 #define HDrename(OLD,NEW) rename(OLD,NEW)
01051 #endif
01052 #ifndef HDrewind
01053 #define HDrewind(F) rewind(F)
01054 #endif
01055 #ifndef HDrewinddir
01056 #define HDrewinddir(D) rewinddir(D)
01057 #endif
01058 #ifndef HDrmdir
01059 #define HDrmdir(S) rmdir(S)
01060 #endif
01061
01062 #ifndef HDsetbuf
01063 #define HDsetbuf(F,S) setbuf(F,S)
01064 #endif
01065 #ifndef HDsetgid
01066 #define HDsetgid(G) setgid(G)
01067 #endif
01068 #ifndef HDsetjmp
01069 #define HDsetjmp(J) setjmp(J)
01070 #endif
01071 #ifndef HDsetlocale
01072 #define HDsetlocale(N,S) setlocale(N,S)
01073 #endif
01074 #ifndef HDsetpgid
01075 #define HDsetpgid(P,PG) setpgid(P,PG)
01076 #endif
01077 #ifndef HDsetsid
01078 #define HDsetsid() setsid()
01079 #endif
01080 #ifndef HDsetuid
01081 #define HDsetuid(U) setuid(U)
01082 #endif
01083 #ifndef HDsetvbuf
01084 #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z)
01085 #endif
01086 #ifndef HDsigaddset
01087 #define HDsigaddset(S,N) sigaddset(S,N)
01088 #endif
01089 #ifndef HDsigdelset
01090 #define HDsigdelset(S,N) sigdelset(S,N)
01091 #endif
01092 #ifndef HDsigemptyset
01093 #define HDsigemptyset(S) sigemptyset(S)
01094 #endif
01095 #ifndef HDsigfillset
01096 #define HDsigfillset(S) sigfillset(S)
01097 #endif
01098 #ifndef HDsigismember
01099 #define HDsigismember(S,N) sigismember(S,N)
01100 #endif
01101 #ifndef HDsiglongjmp
01102 #define HDsiglongjmp(J,N) siglongjmp(J,N)
01103 #endif
01104 #ifndef HDsignal
01105 #define HDsignal(N,F) signal(N,F)
01106 #endif
01107 #ifndef HDsigpending
01108 #define HDsigpending(S) sigpending(S)
01109 #endif
01110 #ifndef HDsigprocmask
01111 #define HDsigprocmask(H,S,O) sigprocmask(H,S,O)
01112 #endif
01113 #ifndef HDsigsetjmp
01114 #define HDsigsetjmp(J,N) sigsetjmp(J,N)
01115 #endif
01116 #ifndef HDsigsuspend
01117 #define HDsigsuspend(S) sigsuspend(S)
01118 #endif
01119 #ifndef HDsin
01120 #define HDsin(X) sin(X)
01121 #endif
01122 #ifndef HDsinh
01123 #define HDsinh(X) sinh(X)
01124 #endif
01125 #ifndef HDsleep
01126 #define HDsleep(N) sleep(N)
01127 #endif
01128 #ifndef HDsnprintf
01129 #define HDsnprintf snprintf
01130 #endif
01131
01132 #ifndef HDsqrt
01133 #define HDsqrt(X) sqrt(X)
01134 #endif
01135 #ifdef H5_HAVE_RAND_R
01136 H5_DLL void HDsrand(unsigned int seed);
01137 #ifndef HDsrandom
01138 #define HDsrandom(S) HDsrand(S)
01139 #endif
01140 #elif H5_HAVE_RANDOM
01141 #ifndef HDsrand
01142 #define HDsrand(S) srandom(S)
01143 #endif
01144 #ifndef HDsrandom
01145 #define HDsrandom(S) srandom(S)
01146 #endif
01147 #else
01148 #ifndef HDsrand
01149 #define HDsrand(S) srand(S)
01150 #endif
01151 #ifndef HDsrandom
01152 #define HDsrandom(S) srand(S)
01153 #endif
01154 #endif
01155
01156
01157 #ifndef HDstrcat
01158 #define HDstrcat(X,Y) strcat(X,Y)
01159 #endif
01160 #ifndef HDstrchr
01161 #define HDstrchr(S,C) strchr(S,C)
01162 #endif
01163 #ifndef HDstrcmp
01164 #define HDstrcmp(X,Y) strcmp(X,Y)
01165 #endif
01166 #ifndef HDstrcasecmp
01167 #define HDstrcasecmp(X,Y) strcasecmp(X,Y)
01168 #endif
01169 #ifndef HDstrcoll
01170 #define HDstrcoll(X,Y) strcoll(X,Y)
01171 #endif
01172 #ifndef HDstrcpy
01173 #define HDstrcpy(X,Y) strcpy(X,Y)
01174 #endif
01175 #ifndef HDstrcspn
01176 #define HDstrcspn(X,Y) strcspn(X,Y)
01177 #endif
01178 #ifndef HDstrerror
01179 #define HDstrerror(N) strerror(N)
01180 #endif
01181 #ifndef HDstrftime
01182 #define HDstrftime(S,Z,F,T) strftime(S,Z,F,T)
01183 #endif
01184 #ifndef HDstrlen
01185 #define HDstrlen(S) strlen(S)
01186 #endif
01187 #ifndef HDstrncat
01188 #define HDstrncat(X,Y,Z) strncat(X,Y,Z)
01189 #endif
01190 #ifndef HDstrncmp
01191 #define HDstrncmp(X,Y,Z) strncmp(X,Y,Z)
01192 #endif
01193 #ifndef HDstrncpy
01194 #define HDstrncpy(X,Y,Z) strncpy(X,Y,Z)
01195 #endif
01196 #ifndef HDstrpbrk
01197 #define HDstrpbrk(X,Y) strpbrk(X,Y)
01198 #endif
01199 #ifndef HDstrrchr
01200 #define HDstrrchr(S,C) strrchr(S,C)
01201 #endif
01202 #ifndef HDstrspn
01203 #define HDstrspn(X,Y) strspn(X,Y)
01204 #endif
01205 #ifndef HDstrstr
01206 #define HDstrstr(X,Y) strstr(X,Y)
01207 #endif
01208 #ifndef HDstrtod
01209 #define HDstrtod(S,R) strtod(S,R)
01210 #endif
01211 #ifndef HDstrtok
01212 #define HDstrtok(X,Y) strtok(X,Y)
01213 #endif
01214 #ifndef HDstrtol
01215 #define HDstrtol(S,R,N) strtol(S,R,N)
01216 #endif
01217 H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base);
01218 #ifndef HDstrtoul
01219 #define HDstrtoul(S,R,N) strtoul(S,R,N)
01220 #endif
01221 #ifndef HDstrtoull
01222 #define HDstrtoull(S,R,N) strtoull(S,R,N)
01223 #endif
01224 #ifndef HDstrxfrm
01225 #define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z)
01226 #endif
01227 #ifdef H5_HAVE_SYMLINK
01228 #ifndef HDsymlink
01229 #define HDsymlink(F1,F2) symlink(F1,F2)
01230 #endif
01231 #endif
01232 #ifndef HDsysconf
01233 #define HDsysconf(N) sysconf(N)
01234 #endif
01235 #ifndef HDsystem
01236 #define HDsystem(S) system(S)
01237 #endif
01238 #ifndef HDtan
01239 #define HDtan(X) tan(X)
01240 #endif
01241 #ifndef HDtanh
01242 #define HDtanh(X) tanh(X)
01243 #endif
01244 #ifndef HDtcdrain
01245 #define HDtcdrain(F) tcdrain(F)
01246 #endif
01247 #ifndef HDtcflow
01248 #define HDtcflow(F,A) tcflow(F,A)
01249 #endif
01250 #ifndef HDtcflush
01251 #define HDtcflush(F,N) tcflush(F,N)
01252 #endif
01253 #ifndef HDtcgetattr
01254 #define HDtcgetattr(F,T) tcgetattr(F,T)
01255 #endif
01256 #ifndef HDtcgetpgrp
01257 #define HDtcgetpgrp(F) tcgetpgrp(F)
01258 #endif
01259 #ifndef HDtcsendbreak
01260 #define HDtcsendbreak(F,N) tcsendbreak(F,N)
01261 #endif
01262 #ifndef HDtcsetattr
01263 #define HDtcsetattr(F,O,T) tcsetattr(F,O,T)
01264 #endif
01265 #ifndef HDtcsetpgrp
01266 #define HDtcsetpgrp(F,N) tcsetpgrp(F,N)
01267 #endif
01268 #ifndef HDtime
01269 #define HDtime(T) time(T)
01270 #endif
01271 #ifndef HDtimes
01272 #define HDtimes(T) times(T)
01273 #endif
01274 #ifndef HDtmpfile
01275 #define HDtmpfile() tmpfile()
01276 #endif
01277 #ifndef HDtmpnam
01278 #define HDtmpnam(S) tmpnam(S)
01279 #endif
01280 #ifndef HDtolower
01281 #define HDtolower(C) tolower(C)
01282 #endif
01283 #ifndef HDtoupper
01284 #define HDtoupper(C) toupper(C)
01285 #endif
01286 #ifndef HDttyname
01287 #define HDttyname(F) ttyname(F)
01288 #endif
01289 #ifndef HDtzset
01290 #define HDtzset() tzset()
01291 #endif
01292 #ifndef HDumask
01293 #define HDumask(N) umask(N)
01294 #endif
01295 #ifndef HDuname
01296 #define HDuname(S) uname(S)
01297 #endif
01298 #ifndef HDungetc
01299 #define HDungetc(C,F) ungetc(C,F)
01300 #endif
01301 #ifndef HDunlink
01302 #define HDunlink(S) unlink(S)
01303 #endif
01304 #ifndef HDutime
01305 #define HDutime(S,T) utime(S,T)
01306 #endif
01307 #ifndef HDva_arg
01308 #define HDva_arg(A,T) va_arg(A,T)
01309 #endif
01310 #ifndef HDva_end
01311 #define HDva_end(A) va_end(A)
01312 #endif
01313 #ifndef HDva_start
01314 #define HDva_start(A,P) va_start(A,P)
01315 #endif
01316 #ifndef HDvasprintf
01317 #define HDvasprintf(RET,FMT,A) vasprintf(RET,FMT,A)
01318 #endif
01319 #ifndef HDvfprintf
01320 #define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A)
01321 #endif
01322 #ifndef HDvprintf
01323 #define HDvprintf(FMT,A) vprintf(FMT,A)
01324 #endif
01325 #ifndef HDvsprintf
01326 #define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A)
01327 #endif
01328 #ifndef HDvsnprintf
01329 #define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A)
01330 #endif
01331 #ifndef HDwait
01332 #define HDwait(W) wait(W)
01333 #endif
01334 #ifndef HDwaitpid
01335 #define HDwaitpid(P,W,O) waitpid(P,W,O)
01336 #endif
01337 #ifndef HDwcstombs
01338 #define HDwcstombs(S,P,Z) wcstombs(S,P,Z)
01339 #endif
01340 #ifndef HDwctomb
01341 #define HDwctomb(S,C) wctomb(S,C)
01342 #endif
01343 #ifndef HDwrite
01344 #define HDwrite(F,M,Z) write(F,M,Z)
01345 #endif
01346
01347
01348
01349
01350
01351 #if !defined strdup && !defined H5_HAVE_STRDUP
01352 extern char *strdup(const char *s);
01353 #endif
01354
01355 #ifndef HDstrdup
01356 #define HDstrdup(S) strdup(S)
01357 #endif
01358
01359 #ifndef HDpthread_self
01360 #define HDpthread_self() pthread_self()
01361 #endif
01362
01363
01364 #ifndef HDpthread_self_ulong
01365 #define HDpthread_self_ulong() ((unsigned long)pthread_self())
01366 #endif
01367
01368
01369
01370
01371 #ifndef NDEBUG
01372 #define H5_CHECK_OVERFLOW(var, vartype, casttype) \
01373 { \
01374 casttype _tmp_overflow = (casttype)(var); \
01375 assert((var) == (vartype)_tmp_overflow); \
01376 }
01377 #else
01378 #define H5_CHECK_OVERFLOW(var, vartype, casttype)
01379 #endif
01380
01381
01382
01383
01384 #ifndef NDEBUG
01385 #define ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) \
01386 { \
01387 srctype _tmp_src = (srctype)(src); \
01388 dsttype _tmp_dst = (dsttype)(_tmp_src); \
01389 assert(_tmp_src == (srctype)_tmp_dst); \
01390 (dst) = _tmp_dst; \
01391 }
01392
01393 #define ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) \
01394 (dst) = (dsttype)(src);
01395
01396 #define ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \
01397 { \
01398 srctype _tmp_src = (srctype)(src); \
01399 dsttype _tmp_dst = (dsttype)(_tmp_src); \
01400 assert(_tmp_src >= 0); \
01401 assert(_tmp_src == _tmp_dst); \
01402 (dst) = _tmp_dst; \
01403 }
01404
01405 #define ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \
01406 (dst) = (dsttype)(src);
01407
01408 #define ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \
01409 { \
01410 srctype _tmp_src = (srctype)(src); \
01411 dsttype _tmp_dst = (dsttype)(_tmp_src); \
01412 assert(_tmp_dst >= 0); \
01413 assert(_tmp_src == (srctype)_tmp_dst); \
01414 (dst) = _tmp_dst; \
01415 }
01416
01417 #define ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \
01418 { \
01419 srctype _tmp_src = (srctype)(src); \
01420 dsttype _tmp_dst = (dsttype)(_tmp_src); \
01421 assert(_tmp_src >= 0); \
01422 assert(_tmp_src == (srctype)_tmp_dst); \
01423 (dst) = _tmp_dst; \
01424 }
01425
01426 #define ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) \
01427 (dst) = (dsttype)(src);
01428
01429
01430 #include "H5overflow.h"
01431
01432 #define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \
01433 H5_GLUE4(ASSIGN_,srctype,_TO_,dsttype)(dst,dsttype,src,srctype)\
01434
01435 #else
01436 #define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \
01437 (dst) = (dsttype)(src);
01438 #endif
01439
01440 #if defined(H5_HAVE_WINDOW_PATH)
01441
01442
01443 #define DIR_SLASH_SEPC '/'
01444 #define DIR_SEPC '\\'
01445 #define DIR_SEPS "\\"
01446 #define CHECK_DELIMITER(SS) ((SS == DIR_SEPC)||(SS == DIR_SLASH_SEPC))
01447 #define CHECK_ABSOLUTE(NAME) ((isalpha(NAME[0])) && (NAME[1] == ':') && (CHECK_DELIMITER(NAME[2])))
01448 #define CHECK_ABS_DRIVE(NAME) ((isalpha(NAME[0])) && (NAME[1] == ':'))
01449 #define CHECK_ABS_PATH(NAME) (CHECK_DELIMITER(NAME[0]))
01450
01451 #define GET_LAST_DELIMITER(NAME, ptr) { \
01452 char *slash, *backslash; \
01453 slash = strrchr(NAME, DIR_SLASH_SEPC); \
01454 backslash = strrchr(NAME, DIR_SEPC); \
01455 if (backslash > slash) \
01456 (ptr = backslash); \
01457 else \
01458 (ptr = slash); \
01459 }
01460
01461 #elif defined(H5_HAVE_VMS_PATH)
01462
01463
01464
01465 #define DIR_SEPC '.'
01466 #define DIR_SEPS "."
01467 #define CHECK_DELIMITER(SS) (SS == DIR_SEPC)
01468 #define CHECK_ABSOLUTE(NAME) (strrchr(NAME, ':') && strrchr(NAME, '['))
01469 #define CHECK_ABS_DRIVE(NAME) (0)
01470 #define CHECK_ABS_PATH(NAME) (0)
01471 #define GET_LAST_DELIMITER(NAME, ptr) ptr = strrchr(NAME, ']');
01472
01473 #else
01474
01475 #define DIR_SEPC '/'
01476 #define DIR_SEPS "/"
01477 #define CHECK_DELIMITER(SS) (SS == DIR_SEPC)
01478 #define CHECK_ABSOLUTE(NAME) (CHECK_DELIMITER(*NAME))
01479 #define CHECK_ABS_DRIVE(NAME) (0)
01480 #define CHECK_ABS_PATH(NAME) (0)
01481 #define GET_LAST_DELIMITER(NAME, ptr) ptr = strrchr(NAME, DIR_SEPC);
01482
01483 #endif
01484
01485 #define COLON_SEPC ':'
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498 typedef enum {
01499 H5_PKG_A,
01500 H5_PKG_AC,
01501 H5_PKG_B,
01502 H5_PKG_D,
01503 H5_PKG_E,
01504 H5_PKG_F,
01505 H5_PKG_G,
01506 H5_PKG_HG,
01507 H5_PKG_HL,
01508 H5_PKG_I,
01509 H5_PKG_MF,
01510 H5_PKG_MM,
01511 H5_PKG_O,
01512 H5_PKG_P,
01513 H5_PKG_S,
01514 H5_PKG_T,
01515 H5_PKG_V,
01516 H5_PKG_Z,
01517 H5_NPKGS
01518 } H5_pkg_t;
01519
01520 typedef struct H5_debug_t {
01521 FILE *trace;
01522 hbool_t ttop;
01523 hbool_t ttimes;
01524 struct {
01525 const char *name;
01526 FILE *stream;
01527 } pkg[H5_NPKGS];
01528 } H5_debug_t;
01529
01530 extern H5_debug_t H5_debug_g;
01531 #define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream)
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549 #ifdef H5_DEBUG_API
01550 #define H5TRACE_DECL const char *RTYPE=NULL; \
01551 double CALLTIME;
01552 #define H5TRACE0(R,T) RTYPE=R; \
01553 CALLTIME=H5_trace(NULL,FUNC,T)
01554 #define H5TRACE1(R,T,A0) RTYPE=R; \
01555 CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0)
01556 #define H5TRACE2(R,T,A0,A1) RTYPE=R; \
01557 CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1)
01558 #define H5TRACE3(R,T,A0,A1,A2) RTYPE=R; \
01559 CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2)
01560 #define H5TRACE4(R,T,A0,A1,A2,A3) RTYPE=R; \
01561 CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3)
01562 #define H5TRACE5(R,T,A0,A1,A2,A3,A4) RTYPE=R; \
01563 CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \
01564 #A4,A4)
01565 #define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) RTYPE=R; \
01566 CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \
01567 #A4,A4,#A5,A5)
01568 #define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6) RTYPE=R; \
01569 CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \
01570 #A4,A4,#A5,A5,#A6,A6)
01571 #define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7) RTYPE=R; \
01572 CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \
01573 #A4,A4,#A5,A5,#A6,A6,#A7,A7)
01574 #define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8) RTYPE=R; \
01575 CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \
01576 #A4,A4,#A5,A5,#A6,A6,#A7,A7,#A8,A8)
01577 #define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9) RTYPE=R; \
01578 CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \
01579 #A4,A4,#A5,A5,#A6,A6,#A7,A7,#A8,A8,#A9,A9)
01580 #define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) RTYPE=R; \
01581 CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \
01582 #A4,A4,#A5,A5,#A6,A6,#A7,A7,#A8,A8,#A9,A9, \
01583 #A10,A10)
01584 #define H5TRACE_RETURN(V) if (RTYPE) { \
01585 H5_trace(&CALLTIME,FUNC,RTYPE,NULL,V); \
01586 RTYPE=NULL; \
01587 }
01588 #else
01589 #define H5TRACE_DECL
01590 #define H5TRACE0(R,T)
01591 #define H5TRACE1(R,T,A0)
01592 #define H5TRACE2(R,T,A0,A1)
01593 #define H5TRACE3(R,T,A0,A1,A2)
01594 #define H5TRACE4(R,T,A0,A1,A2,A3)
01595 #define H5TRACE5(R,T,A0,A1,A2,A3,A4)
01596 #define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5)
01597 #define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6)
01598 #define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7)
01599 #define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8)
01600 #define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9)
01601 #define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10)
01602 #define H5TRACE_RETURN(V)
01603 #endif
01604
01605 H5_DLL double H5_trace(const double *calltime, const char *func, const char *type, ...);
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632 #define H5_IS_API(S) ('_'!=S[2] && '_'!=S[3] && (!S[4] || '_'!=S[4]))
01633
01634
01635 extern char H5_lib_vers_info_g[];
01636
01637
01638 #ifdef H5_HAVE_THREADSAFE
01639
01640
01641 #include "H5TSprivate.h"
01642
01643
01644 typedef struct H5_api_struct {
01645 H5TS_mutex_t init_lock;
01646 hbool_t H5_libinit_g;
01647 } H5_api_t;
01648
01649
01650 #define H5_INIT_GLOBAL H5_g.H5_libinit_g
01651
01652
01653 #define H5_FIRST_THREAD_INIT \
01654 pthread_once(&H5TS_first_init_g, H5TS_first_thread_init);
01655
01656
01657 #define H5_API_LOCK \
01658 H5TS_mutex_lock(&H5_g.init_lock);
01659 #define H5_API_UNLOCK \
01660 H5TS_mutex_unlock(&H5_g.init_lock);
01661
01662
01663 #define H5_API_UNSET_CANCEL \
01664 H5TS_cancel_count_inc();
01665
01666 #define H5_API_SET_CANCEL \
01667 H5TS_cancel_count_dec();
01668
01669 extern H5_api_t H5_g;
01670
01671 #else
01672
01673
01674 #define H5_FIRST_THREAD_INIT
01675
01676
01677 #define H5_API_LOCK
01678 #define H5_API_UNLOCK
01679
01680
01681 #define H5_API_UNSET_CANCEL
01682 #define H5_API_SET_CANCEL
01683
01684
01685 extern hbool_t H5_libinit_g;
01686
01687
01688 #define H5_INIT_GLOBAL H5_libinit_g
01689
01690 #endif
01691
01692 #ifdef H5_HAVE_CODESTACK
01693
01694
01695 #include "H5CSprivate.h"
01696
01697 #define H5_PUSH_FUNC(func_name) H5CS_push(#func_name)
01698 #define H5_POP_FUNC H5CS_pop();
01699 #else
01700 #define H5_PUSH_FUNC(func_name)
01701 #define H5_POP_FUNC
01702 #endif
01703
01704 #ifdef H5_HAVE_MPE
01705 extern hbool_t H5_MPEinit_g;
01706 #endif
01707
01708
01709 #ifdef H5_HAVE_FUNCTION
01710 #define H5_CHECK_FUNCNAME(func_name) \
01711 assert(!HDstrcmp(#func_name, __FUNCTION__))
01712 #else
01713 #define H5_CHECK_FUNCNAME(func_name) \
01714 assert(func_name)
01715 #endif
01716
01717
01718 #ifdef H5_INTERFACE_INIT_FUNC
01719 static int H5_interface_initialize_g = 0;
01720 static herr_t H5_INTERFACE_INIT_FUNC(void);
01721 #define H5_INTERFACE_INIT(err) \
01722 \
01723 if (!H5_interface_initialize_g) { \
01724 H5_interface_initialize_g = 1; \
01725 if (H5_INTERFACE_INIT_FUNC()<0) { \
01726 H5_interface_initialize_g = 0; \
01727 HGOTO_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
01728 "interface initialization failed") \
01729 } \
01730 }
01731 #else
01732 #define H5_INTERFACE_INIT(err)
01733 #endif
01734
01735
01736 #ifndef NDEBUG
01737 #define FUNC_ENTER_COMMON_NOFUNC(func_name,asrt) \
01738 static hbool_t func_check = FALSE; \
01739 \
01740 if(!func_check) { \
01741 \
01742 HDassert(asrt); \
01743 \
01744 \
01745 H5_CHECK_FUNCNAME(func_name); \
01746 \
01747 \
01748 func_check = TRUE; \
01749 }
01750 #else
01751 #define FUNC_ENTER_COMMON_NOFUNC(func_name,asrt)
01752 #endif
01753
01754 #define FUNC_ENTER_COMMON(func_name, asrt) \
01755 static const char FUNC[] = #func_name; \
01756 hbool_t err_occurred = FALSE; \
01757 FUNC_ENTER_COMMON_NOFUNC(func_name, asrt);
01758
01759 #define FUNC_ENTER_COMMON_NOERR(func_name, asrt) \
01760 static const char FUNC[] = #func_name; \
01761 FUNC_ENTER_COMMON_NOFUNC(func_name, asrt);
01762
01763
01764 #define FUNC_ENTER_API_THREADSAFE \
01765 \
01766 H5_FIRST_THREAD_INIT \
01767 \
01768 \
01769 H5_API_UNSET_CANCEL \
01770 H5_API_LOCK
01771
01772
01773 #define FUNC_ENTER_API_VARS(func_name) \
01774 MPE_LOG_VARS(func_name) \
01775 H5TRACE_DECL
01776
01777 #define FUNC_ENTER_API_COMMON(func_name) \
01778 FUNC_ENTER_API_VARS(func_name) \
01779 FUNC_ENTER_COMMON(func_name, H5_IS_API(#func_name)); \
01780 FUNC_ENTER_API_THREADSAFE;
01781
01782 #define FUNC_ENTER_API_INIT(func_name,err) \
01783 \
01784 if(!(H5_INIT_GLOBAL)) { \
01785 H5_INIT_GLOBAL = TRUE; \
01786 if(H5_init_library() < 0) \
01787 HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, \
01788 "library initialization failed") \
01789 } \
01790 \
01791 \
01792 H5_INTERFACE_INIT(err) \
01793 \
01794 \
01795 H5_PUSH_FUNC(#func_name) \
01796 \
01797 BEGIN_MPE_LOG(func_name)
01798
01799
01800 #define FUNC_ENTER_API(func_name,err) {{ \
01801 FUNC_ENTER_API_COMMON(func_name) \
01802 FUNC_ENTER_API_INIT(func_name,err); \
01803 \
01804 H5E_clear_stack(NULL); \
01805 {
01806
01807
01808
01809
01810
01811 #define FUNC_ENTER_API_NOCLEAR(func_name,err) {{ \
01812 FUNC_ENTER_API_COMMON(func_name) \
01813 FUNC_ENTER_API_INIT(func_name,err); \
01814 {
01815
01816
01817
01818
01819
01820
01821
01822 #define FUNC_ENTER_API_NOINIT(func_name) {{ \
01823 FUNC_ENTER_API_COMMON(func_name) \
01824 H5_PUSH_FUNC(func_name); \
01825 BEGIN_MPE_LOG(func_name); \
01826 {
01827
01828
01829
01830
01831
01832
01833
01834
01835 #define FUNC_ENTER_API_NOINIT_NOERR_NOFS(func_name) {{ \
01836 FUNC_ENTER_API_VARS(func_name) \
01837 FUNC_ENTER_COMMON_NOERR(func_name, H5_IS_API(#func_name)); \
01838 FUNC_ENTER_API_THREADSAFE; \
01839 BEGIN_MPE_LOG(func_name); \
01840 {
01841
01842
01843 #define FUNC_ENTER_NOAPI_INIT(func_name,err) \
01844 \
01845 H5_INTERFACE_INIT(err) \
01846 \
01847 \
01848 H5_PUSH_FUNC(#func_name)
01849
01850
01851 #define FUNC_ENTER_NOAPI(func_name,err) { \
01852 FUNC_ENTER_COMMON(func_name, !H5_IS_API(#func_name)); \
01853 FUNC_ENTER_NOAPI_INIT(func_name,err) \
01854 {
01855
01856
01857 #define FUNC_ENTER_NOAPI_NOERR(func_name,err) { \
01858 FUNC_ENTER_COMMON_NOERR(func_name, !H5_IS_API(#func_name)); \
01859 FUNC_ENTER_NOAPI_INIT(func_name,err) \
01860 {
01861
01862
01863 #define FUNC_ENTER_NOAPI_NOFUNC(func_name) { \
01864 FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name)); \
01865 FUNC_ENTER_NOAPI_INIT(func_name,err) \
01866 {
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876 #define FUNC_ENTER_NOAPI_NOINIT(func_name) { \
01877 FUNC_ENTER_COMMON(func_name, !H5_IS_API(#func_name)); \
01878 H5_PUSH_FUNC(func_name); \
01879 {
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890 #define FUNC_ENTER_NOAPI_NOINIT_NOERR(func_name) { \
01891 FUNC_ENTER_COMMON_NOERR(func_name, !H5_IS_API(#func_name)); \
01892 H5_PUSH_FUNC(#func_name) \
01893 {
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907 #define FUNC_ENTER_NOAPI_NOINIT_NOFUNC(func_name) { \
01908 FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name)); \
01909 H5_PUSH_FUNC(func_name); \
01910 {
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921 #define FUNC_ENTER_NOAPI_NOFUNC_NOFS(func_name) { \
01922 FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name)); \
01923 {
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934 #define FUNC_LEAVE_API_THREADSAFE \
01935 H5_API_UNLOCK \
01936 H5_API_SET_CANCEL
01937
01938 #define FUNC_LEAVE_API(ret_value) \
01939 FINISH_MPE_LOG; \
01940 H5TRACE_RETURN(ret_value); \
01941 H5_POP_FUNC \
01942 if(err_occurred) \
01943 (void)H5E_dump_api_stack(TRUE); \
01944 FUNC_LEAVE_API_THREADSAFE \
01945 return(ret_value); \
01946 } \
01947 }}
01948
01949
01950 #define FUNC_LEAVE_API_NOFS(ret_value) \
01951 FINISH_MPE_LOG; \
01952 H5TRACE_RETURN(ret_value); \
01953 FUNC_LEAVE_API_THREADSAFE \
01954 return(ret_value); \
01955 } \
01956 }}
01957
01958 #define FUNC_LEAVE_NOAPI(ret_value) \
01959 H5_POP_FUNC \
01960 return(ret_value); \
01961 } \
01962 }
01963
01964 #define FUNC_LEAVE_NOAPI_VOID \
01965 H5_POP_FUNC \
01966 return; \
01967 } \
01968 }
01969
01970
01971
01972
01973
01974
01975 #define FUNC_LEAVE_NOAPI_NOFS(ret_value) \
01976 return(ret_value); \
01977 } \
01978 }
01979
01980
01981
01982 #define H5_GLUE(x,y) x##y
01983 #define H5_GLUE3(x,y,z) x##y##z
01984 #define H5_GLUE4(w,x,y,z) w##x##y##z
01985
01986
01987 #define HDcompile_assert(e) do { enum { compile_assert__ = 1 / (e) }; } while(0)
01988
01989
01990 H5_DLL herr_t H5_init_library(void);
01991 H5_DLL void H5_term_library(void);
01992
01993
01994 H5_DLL int H5A_term_interface(void);
01995 H5_DLL int H5AC_term_interface(void);
01996 H5_DLL int H5D_term_interface(void);
01997 H5_DLL int H5E_term_interface(void);
01998 H5_DLL int H5F_term_interface(void);
01999 H5_DLL int H5FS_term_interface(void);
02000 H5_DLL int H5G_term_interface(void);
02001 H5_DLL int H5I_term_interface(void);
02002 H5_DLL int H5L_term_interface(void);
02003 H5_DLL int H5P_term_interface(void);
02004 H5_DLL int H5R_term_interface(void);
02005 H5_DLL int H5S_term_interface(void);
02006 H5_DLL int H5T_term_interface(void);
02007 H5_DLL int H5Z_term_interface(void);
02008
02009
02010 H5_DLL uint32_t H5_checksum_fletcher32(const void *data, size_t len);
02011 H5_DLL uint32_t H5_checksum_crc(const void *data, size_t len);
02012 H5_DLL uint32_t H5_checksum_lookup3(const void *data, size_t len, uint32_t initval);
02013 H5_DLL uint32_t H5_checksum_metadata(const void *data, size_t len, uint32_t initval);
02014 H5_DLL uint32_t H5_hash_string(const char *str);
02015
02016
02017 H5_DLL herr_t H5_build_extpath(const char *, char ** );
02018
02019
02020 H5_DLL herr_t H5_buffer_dump(FILE *stream, int indent, uint8_t *buf,
02021 uint8_t *marker, size_t buf_offset, size_t buf_size);
02022
02023 #endif
02024