H5private.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 /* Programmer:  Robb Matzke <matzke@llnl.gov>
00017  *              Friday, October 30, 1998
00018  *
00019  * Purpose:     This file is included by all HDF5 library source files to
00020  *              define common things which are not defined in the HDF5 API.
00021  *              The configuration constants like H5_HAVE_UNISTD_H etc. are
00022  *              defined in H5config.h which is included by H5public.h.
00023  *
00024  */
00025 
00026 #ifndef _H5private_H
00027 #define _H5private_H
00028 
00029 #include "H5public.h"           /* Include Public Definitions           */
00030 
00031 /* include the pthread header */
00032 #ifdef H5_HAVE_THREADSAFE
00033 #include <pthread.h>
00034 #endif
00035 
00036 /*
00037  * Include ANSI-C header files.
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  * If _POSIX_VERSION is defined in unistd.h then this system is Posix.1
00056  * compliant. Otherwise all bets are off.
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  * C9x integer types
00069  */
00070 #ifndef __cplusplus
00071 #ifdef H5_HAVE_STDINT_H
00072 #   include <stdint.h>
00073 #endif
00074 #endif
00075 
00076 /*
00077  * The `struct stat' data type for stat() and fstat(). This is a Posix file
00078  * but often apears on non-Posix systems also.  The `struct stat' is required
00079  * for hdf5 to compile, although only a few fields are actually used.
00080  */
00081 #ifdef H5_HAVE_SYS_STAT_H
00082 #   include <sys/stat.h>
00083 #endif
00084 
00085 /*
00086  * If a program may include both `time.h' and `sys/time.h' then
00087  * TIME_WITH_SYS_TIME is defined (see AC_HEADER_TIME in configure.in).
00088  * On some older systems, `sys/time.h' includes `time.h' but `time.h' is not
00089  * protected against multiple inclusion, so programs should not explicitly
00090  * include both files. This macro is useful in programs that use, for example,
00091  * `struct timeval' or `struct timezone' as well as `struct tm'.  It is best
00092  * used in conjunction with `HAVE_SYS_TIME_H', whose existence is checked
00093  * by `AC_CHECK_HEADERS(sys/time.h)' in configure.in.
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  * Longjumps are used to detect alignment constrants
00106  */
00107 #ifdef H5_HAVE_SETJMP_H
00108 #   include <setjmp.h>
00109 #endif
00110 
00111 /*
00112  * Resource usage is not Posix.1 but HDF5 uses it anyway for some performance
00113  * and debugging code if available.
00114  */
00115 #ifdef H5_HAVE_SYS_RESOURCE_H
00116 #   include <sys/resource.h>
00117 #endif
00118 
00119 /*
00120  * Unix ioctls.  These are used by h5ls (and perhaps others) to determine a
00121  * resonable output width.
00122  */
00123 #ifdef H5_HAVE_SYS_IOCTL_H
00124 #   include <sys/ioctl.h>
00125 #endif
00126 
00127 /*
00128  * System information. These are needed on the DEC Alpha to turn off fixing
00129  * of unaligned accesses by the operating system during detection of
00130  * alignment constraints in H5detect.c:main().
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            /*Exclude rarely-used stuff from Windows headers */
00146 #include <windows.h>
00147 #include <direct.h>         /* For _getcwd() */
00148 
00149 #endif /*_WIN32*/
00150 
00151 /* H5_inline */
00152 #ifndef H5_inline
00153 #define H5_inline
00154 #endif /* H5_inline */
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  * MPE Instrumentation support
00165  */
00166 #ifdef H5_HAVE_MPE
00167 /*------------------------------------------------------------------------
00168  * Purpose:    Begin to collect MPE log information for a function. It should
00169  *             be ahead of the actual function's process.
00170  *
00171  * Programmer: Long Wang
00172  *
00173  *------------------------------------------------------------------------
00174  */
00175 #include "mpe.h"
00176 /*
00177  * #define eventa(func_name)   h5_mpe_ ## func_name ## _a
00178  * #define eventb(func_name)   h5_mpe_ ## func_name ## _b
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 /* Hardwire the color to "red", since that's what all the routines are using
00189  * now.  In the future, if we want to change that color for a given routine,
00190  * we should define a "FUNC_ENTER_API_COLOR" macro which takes an extra 'color'
00191  * parameter and then make additional FUNC_ENTER_<foo>_COLOR macros to get that
00192  * color information down to the BEGIN_MPE_LOG macro (which should have a new
00193  * BEGIN_MPE_LOG_COLOR variant). -QAK
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  * Purpose:   Finish the collection of MPE log information for a function.
00209  *            It should be after the actual function's process.
00210  *
00211  * Programmer: Long Wang
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 /* H5_HAVE_MPE */
00219 #define MPE_LOG_VARS(func_name) /* void */
00220 #define BEGIN_MPE_LOG(func_name) /* void */
00221 #define FINISH_MPE_LOG   /* void */
00222 
00223 #endif /* H5_HAVE_MPE */
00224 
00225 /*
00226  * dmalloc (debugging malloc) support
00227  */
00228 #ifdef H5_HAVE_DMALLOC_H
00229 #include "dmalloc.h"
00230 #endif /* H5_HAVE_DMALLOC_H */
00231 
00232 /*
00233  * NT doesn't define SIGBUS, but since NT only runs on processors
00234  * that do not have alignment constraints a SIGBUS would never be
00235  * raised, so we just replace it with SIGILL (which also should
00236  * never be raised by the hdf5 library).
00237  */
00238 #ifndef SIGBUS
00239 #       define SIGBUS SIGILL
00240 #endif
00241 
00242 /*
00243  * Does the compiler support the __attribute__(()) syntax?  This is how gcc
00244  * suppresses warnings about unused function arguments.  It's no big deal if
00245  * we don't.
00246  */
00247 #ifdef __cplusplus
00248 #   define __attribute__(X)     /*void*/
00249 #   define UNUSED               /*void*/
00250 #else /* __cplusplus */
00251 #ifdef H5_HAVE_ATTRIBUTE
00252 #   define UNUSED               __attribute__((unused))
00253 #else
00254 #   define __attribute__(X)     /*void*/
00255 #   define UNUSED               /*void*/
00256 #endif
00257 #endif /* __cplusplus */
00258 
00259 /*
00260  * Does the compiler expand __FUNCTION__ to be the name of the function
00261  * currently being defined?  If not then define it to be some constant
00262  * string.
00263  */
00264 #ifndef H5_HAVE_FUNCTION
00265 #   define __FUNCTION__  "NoFunctionName"
00266 #endif
00267 
00268 /*
00269  * Status return values for the `herr_t' type.
00270  * Since some unix/c routines use 0 and -1 (or more precisely, non-negative
00271  * vs. negative) as their return code, and some assumption had been made in
00272  * the code about that, it is important to keep these constants the same
00273  * values.  When checking the success or failure of an integer-valued
00274  * function, remember to compare against zero and not one of these two
00275  * values.
00276  */
00277 #define SUCCEED         0
00278 #define FAIL            (-1)
00279 #define UFAIL           (unsigned)(-1)
00280 
00281 /* number of members in an array */
00282 #ifndef NELMTS
00283 #    define NELMTS(X)           (sizeof(X)/sizeof(X[0]))
00284 #endif
00285 
00286 /* minimum of two, three, or four values */
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 /* maximum of two, three, or four values */
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 /* limit the middle value to be within a range (inclusive) */
00301 #define RANGE(LO,X,HI)          MAX(LO,MIN(X,HI))
00302 
00303 /* absolute value */
00304 #ifndef ABS
00305 #   define ABS(a)               (((a)>=0) ? (a) : -(a))
00306 #endif
00307 
00308 /* sign of argument */
00309 #ifndef SIGN
00310 #   define SIGN(a)              ((a)>0 ? 1 : (a)<0 ? -1 : 0)
00311 #endif
00312 
00313 /* test for number that is a power of 2 */
00314 /* (from: http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2) */
00315 #  define POWER_OF_TWO(n)       (!(n & (n - 1)) && n)
00316 
00317 /*
00318  * HDF Boolean type.
00319  */
00320 #ifndef FALSE
00321 #   define FALSE 0
00322 #endif
00323 #ifndef TRUE
00324 #   define TRUE 1
00325 #endif
00326 
00327 /*
00328  * Numeric data types.  Some of these might be defined in Posix.1g, otherwise
00329  * we define them with the closest available type which is at least as large
00330  * as the number of bits indicated in the type name.  The `int8' types *must*
00331  * be exactly one byte wide because we use it for pointer calculations to
00332  * void* memory.
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 /* Definition of uint32_t was moved to H5public.h */
00396 
00397 /* Definition of int64_t was moved to H5public.h */
00398 /* Definition of uint64_t was moved to H5public.h */
00399 
00400 /*
00401  * Maximum and minimum values.  These should be defined in <limits.h> for the
00402  * most part.
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  * Maximum & minimum values for our typedefs.
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  * A macro to portably increment enumerated types.
00426  */
00427 #ifndef H5_INC_ENUM
00428 #  define H5_INC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)+1))
00429 #endif
00430 
00431 /*
00432  * A macro to portably decrement enumerated types.
00433  */
00434 #ifndef H5_DEC_ENUM
00435 #  define H5_DEC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)-1))
00436 #endif
00437 
00438 /*
00439  * A macro for detecting over/under-flow when casting between types
00440  */
00441 #ifndef NDEBUG
00442 #define H5_CHECK_OVERFLOW(var, vartype, casttype) \
00443 {                                                 \
00444     casttype _tmp_overflow = (casttype)(var);     \
00445     assert((var) == (vartype)_tmp_overflow);      \
00446 }
00447 #else /* NDEBUG */
00448 #define H5_CHECK_OVERFLOW(var, vartype, casttype)
00449 #endif /* NDEBUG */
00450 
00451 /*
00452  * A macro for detecting over/under-flow when assigning between types
00453  */
00454 #ifndef NDEBUG
00455 #define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype)  \
00456 {                                                       \
00457     srctype _tmp_overflow = (srctype)(src);             \
00458     dsttype _tmp_overflow2 = (dsttype)(_tmp_overflow);  \
00459     assert((dsttype)_tmp_overflow == _tmp_overflow2);   \
00460     (dst) = _tmp_overflow2;                             \
00461 }
00462 #else /* NDEBUG */
00463 #define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype)  \
00464     (dst) = (dsttype)(src);
00465 #endif /* NDEBUG */
00466 
00467 /*
00468  * Data types and functions for timing certain parts of the library.
00469  */
00470 typedef struct {
00471     double      utime;          /*user time                     */
00472     double      stime;          /*system time                   */
00473     double      etime;          /*elapsed wall-clock time       */
00474 } H5_timer_t;
00475 
00476 H5_DLL void H5_timer_reset (H5_timer_t *timer);
00477 H5_DLL void H5_timer_begin (H5_timer_t *timer);
00478 H5_DLL void H5_timer_end (H5_timer_t *sum/*in,out*/,
00479                            H5_timer_t *timer/*in,out*/);
00480 H5_DLL void H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds);
00481 H5_DLL time_t H5_now(void);
00482 
00483 /* Depth of object copy */
00484 typedef enum {
00485     H5_COPY_SHALLOW,    /* Shallow copy from source to destination, just copy field pointers */
00486     H5_COPY_DEEP        /* Deep copy from source to destination, including duplicating fields pointed to */
00487 } H5_copy_depth_t;
00488 
00489 /* Unique object "position" */
00490 typedef struct {
00491     unsigned long fileno;       /* The unique identifier for the file of the object */
00492     haddr_t addr;               /* The unique address of the object's header in that file */
00493 } H5_obj_t;
00494 
00495 /*
00496  * Redefine all the POSIX functions.  We should never see a POSIX
00497  * function (or any other non-HDF5 function) in the source!
00498  */
00499 
00500  /* Use platform-specific versions if necessary */
00501 #include "H5win32defs.h"
00502 
00503 #ifndef HDabort
00504     #define HDabort()           abort()
00505 #endif /* HDabort */
00506 #ifndef HDabs
00507     #define HDabs(X)            abs(X)
00508 #endif /* HDabs */
00509 #ifndef HDaccess
00510     #define HDaccess(F,M)               access(F, M)
00511 #endif /* HDaccess */
00512 #ifndef HDacos
00513     #define HDacos(X)           acos(X)
00514 #endif /* HDacos */
00515 #ifndef HDalarm
00516     #ifdef H5_HAVE_ALARM
00517         #define HDalarm(N)              alarm(N)
00518     #else /* H5_HAVE_ALARM */
00519         #define HDalarm(N)              (0)
00520     #endif /* H5_HAVE_ALARM */
00521 #endif /* HDalarm */
00522 #ifndef HDasctime
00523     #define HDasctime(T)                asctime(T)
00524 #endif /* HDasctime */
00525 #ifndef HDasin
00526     #define HDasin(X)           asin(X)
00527 #endif /* HDasin */
00528 #ifndef HDassert
00529     #define HDassert(X)         assert(X)
00530 #endif /* HDassert */
00531 #ifndef HDatan
00532     #define HDatan(X)           atan(X)
00533 #endif /* HDatan */
00534 #ifndef HDatan2
00535     #define HDatan2(X,Y)                atan2(X,Y)
00536 #endif /* HDatan2 */
00537 #ifndef HDatexit
00538     #define HDatexit(F)         atexit(F)
00539 #endif /* HDatexit */
00540 #ifndef HDatof
00541     #define HDatof(S)           atof(S)
00542 #endif /* HDatof */
00543 #ifndef HDatoi
00544     #define HDatoi(S)           atoi(S)
00545 #endif /* HDatoi */
00546 #ifndef HDatol
00547     #define HDatol(S)           atol(S)
00548 #endif /* HDatol */
00549 #ifndef HDBSDgettimeofday
00550     #define HDBSDgettimeofday(S,P)      BSDgettimeofday(S,P)
00551 #endif /* HDBSDgettimeofday */
00552 #ifndef HDbsearch
00553     #define HDbsearch(K,B,N,Z,F)        bsearch(K,B,N,Z,F)
00554 #endif /* HDbsearch */
00555 #ifndef HDcalloc
00556     #define HDcalloc(N,Z)               calloc(N,Z)
00557 #endif /* HDcalloc */
00558 #ifndef HDceil
00559     #define HDceil(X)           ceil(X)
00560 #endif /* HDceil */
00561 #ifndef HDcfgetispeed
00562     #define HDcfgetispeed(T)    cfgetispeed(T)
00563 #endif /* HDcfgetispeed */
00564 #ifndef HDcfgetospeed
00565     #define HDcfgetospeed(T)    cfgetospeed(T)
00566 #endif /* HDcfgetospeed */
00567 #ifndef HDcfsetispeed
00568     #define HDcfsetispeed(T,S)  cfsetispeed(T,S)
00569 #endif /* HDcfsetispeed */
00570 #ifndef HDcfsetospeed
00571     #define HDcfsetospeed(T,S)  cfsetospeed(T,S)
00572 #endif /* HDcfsetospeed */
00573 #ifndef HDchdir
00574     #define HDchdir(S)          chdir(S)
00575 #endif /* HDchdir */
00576 #ifndef HDchmod
00577     #define HDchmod(S,M)                chmod(S,M)
00578 #endif /* HDchmod */
00579 #ifndef HDchown
00580     #define HDchown(S,O,G)              chown(S,O,G)
00581 #endif /* HDchown */
00582 #ifndef HDclearerr
00583     #define HDclearerr(F)               clearerr(F)
00584 #endif /* HDclearerr */
00585 #ifndef HDclock
00586     #define HDclock()           clock()
00587 #endif /* HDclock */
00588 #ifndef HDclose
00589     #define HDclose(F)          close(F)
00590 #endif /* HDclose */
00591 #ifndef HDclosedir
00592     #define HDclosedir(D)               closedir(D)
00593 #endif /* HDclosedir */
00594 #ifndef HDcos
00595     #define HDcos(X)            cos(X)
00596 #endif /* HDcos */
00597 #ifndef HDcosh
00598     #define HDcosh(X)           cosh(X)
00599 #endif /* HDcosh */
00600 #ifndef HDcreat
00601     #define HDcreat(S,M)                creat(S,M)
00602 #endif /* HDcreat */
00603 #ifndef HDctermid
00604     #define HDctermid(S)                ctermid(S)
00605 #endif /* HDctermid */
00606 #ifndef HDctime
00607     #define HDctime(T)          ctime(T)
00608 #endif /* HDctime */
00609 #ifndef HDcuserid
00610     #define HDcuserid(S)                cuserid(S)
00611 #endif /* HDcuserid */
00612 #ifndef HDdifftime
00613     #ifdef H5_HAVE_DIFFTIME
00614         #define HDdifftime(X,Y)         difftime(X,Y)
00615     #else /* H5_HAVE_DIFFTIME */
00616         #define HDdifftime(X,Y)         ((double)(X)-(double)(Y))
00617     #endif /* H5_HAVE_DIFFTIME */
00618 #endif /* HDdifftime */
00619 #ifndef HDdiv
00620     #define HDdiv(X,Y)          div(X,Y)
00621 #endif /* HDdiv */
00622 #ifndef HDdup
00623     #define HDdup(F)            dup(F)
00624 #endif /* HDdup */
00625 #ifndef HDdup2
00626     #define HDdup2(F,I)         dup2(F,I)
00627 #endif /* HDdup2 */
00628 /* execl() variable arguments */
00629 /* execle() variable arguments */
00630 /* execlp() variable arguments */
00631 #ifndef HDexecv
00632     #define HDexecv(S,AV)               execv(S,AV)
00633 #endif /* HDexecv */
00634 #ifndef HDexecve
00635     #define HDexecve(S,AV,E)    execve(S,AV,E)
00636 #endif /* HDexecve */
00637 #ifndef HDexecvp
00638     #define HDexecvp(S,AV)              execvp(S,AV)
00639 #endif /* HDexecvp */
00640 #ifndef HDexit
00641     #define HDexit(N)           exit(N)
00642 #endif /* HDexit */
00643 #ifndef HD_exit
00644     #define HD_exit(N)          _exit(N)
00645 #endif /* HD_exit */
00646 #ifndef HDexp
00647     #define HDexp(X)            exp(X)
00648 #endif /* HDexp */
00649 #ifndef HDfabs
00650     #define HDfabs(X)           fabs(X)
00651 #endif /* HDfabs */
00652 /* use ABS() because fabsf() fabsl() are not common yet. */
00653 #ifndef HDfabsf
00654     #define HDfabsf(X)          ABS(X)
00655 #endif /* HDfabsf */
00656 #ifndef HDfabsl
00657     #define HDfabsl(X)          ABS(X)
00658 #endif /* HDfabsl */
00659 #ifndef HDfclose
00660     #define HDfclose(F)         fclose(F)
00661 #endif /* HDfclose */
00662 /* fcntl() variable arguments */
00663 #ifndef HDfdopen
00664     #define HDfdopen(N,S)               fdopen(N,S)
00665 #endif /* HDfdopen */
00666 #ifndef HDfeof
00667     #define HDfeof(F)           feof(F)
00668 #endif /* HDfeof */
00669 #ifndef HDferror
00670     #define HDferror(F)         ferror(F)
00671 #endif /* HDferror */
00672 #ifndef HDfflush
00673     #define HDfflush(F)         fflush(F)
00674 #endif /* HDfflush */
00675 #ifndef HDfgetc
00676     #define HDfgetc(F)          fgetc(F)
00677 #endif /* HDfgetc */
00678 #ifndef HDfgetpos
00679     #define HDfgetpos(F,P)              fgetpos(F,P)
00680 #endif /* HDfgetpos */
00681 #ifndef HDfgets
00682     #define HDfgets(S,N,F)              fgets(S,N,F)
00683 #endif /* HDfgets */
00684 #ifndef HDfileno
00685     #define HDfileno(F)         fileno(F)
00686 #endif /* HDfileno */
00687 #ifndef HDfloor
00688     #define HDfloor(X)          floor(X)
00689 #endif /* HDfloor */
00690 #ifndef HDfmod
00691     #define HDfmod(X,Y)         fmod(X,Y)
00692 #endif /* HDfmod */
00693 #ifndef HDfopen
00694     #define HDfopen(S,M)                fopen(S,M)
00695 #endif /* HDfopen */
00696 #ifndef HDfork
00697     #define HDfork()            fork()
00698 #endif /* HDfork */
00699 #ifndef HDfpathconf
00700     #define HDfpathconf(F,N)    fpathconf(F,N)
00701 #endif /* HDfpathconf */
00702 H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
00703 #ifndef HDfputc
00704     #define HDfputc(C,F)                fputc(C,F)
00705 #endif /* HDfputc */
00706 #ifndef HDfputs
00707     #define HDfputs(S,F)                fputs(S,F)
00708 #endif /* HDfputs */
00709 #ifndef HDfread
00710     #define HDfread(M,Z,N,F)    fread(M,Z,N,F)
00711 #endif /* HDfread */
00712 #ifndef HDfree
00713     #define HDfree(M)           free(M)
00714 #endif /* HDfree */
00715 #ifndef HDfreopen
00716     #define HDfreopen(S,M,F)    freopen(S,M,F)
00717 #endif /* HDfreopen */
00718 #ifndef HDfrexp
00719     #define HDfrexp(X,N)                frexp(X,N)
00720 #endif /* HDfrexp */
00721 /* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */
00722 #ifndef HDfrexpf
00723     #ifdef H5_HAVE_FREXPF
00724         #define HDfrexpf(X,N)           frexpf(X,N)
00725     #else /* H5_HAVE_FREXPF */
00726         #define HDfrexpf(X,N)           frexp(X,N)
00727     #endif /* H5_HAVE_FREXPF */
00728 #endif /* HDfrexpf */
00729 #ifndef HDfrexpl
00730     #ifdef H5_HAVE_FREXPL
00731         #define HDfrexpl(X,N)           frexpl(X,N)
00732     #else /* H5_HAVE_FREXPL */
00733         #define HDfrexpl(X,N)           frexp(X,N)
00734     #endif /* H5_HAVE_FREXPL */
00735 #endif /* HDfrexpl */
00736 /* fscanf() variable arguments */
00737 #ifndef HDfseek
00738     #ifdef H5_HAVE_FSEEKO
00739              #define HDfseek(F,O,W)     fseeko(F,O,W)
00740     #else /* H5_HAVE_FSEEKO */
00741              #define HDfseek(F,O,W)     fseek(F,O,W)
00742     #endif /* H5_HAVE_FSEEKO */
00743 #endif /* HDfseek */
00744 #ifndef HDfsetpos
00745     #define HDfsetpos(F,P)              fsetpos(F,P)
00746 #endif /* HDfsetpos */
00747 /* definitions related to the file stat utilities.
00748  * For Unix, if off_t is not 64bit big, try use the pseudo-standard
00749  * xxx64 versions if available.
00750  */
00751 #if !defined(HDfstat) || !defined(HDstat)
00752     #if H5_SIZEOF_OFF_T!=8 && H5_SIZEOF_OFF64_T==8 && defined(H5_HAVE_STAT64)
00753         #ifndef HDfstat
00754             #define HDfstat(F,B)        fstat64(F,B)
00755         #endif /* HDfstat */
00756         #ifndef HDstat
00757             #define HDstat(S,B)         stat64(S,B)
00758         #endif /* HDstat */
00759         typedef struct stat64       h5_stat_t;
00760         typedef off64_t             h5_stat_size_t;
00761     #else /* H5_SIZEOF_OFF_T!=8 && ... */
00762         #ifndef HDfstat
00763             #define HDfstat(F,B)        fstat(F,B)
00764         #endif /* HDfstat */
00765         #ifndef HDstat
00766             #define HDstat(S,B)         stat(S,B)
00767         #endif /* HDstat */
00768         typedef struct stat         h5_stat_t;
00769         typedef off_t               h5_stat_size_t;
00770     #endif /* H5_SIZEOF_OFF_T!=8 && ... */
00771 #endif /* !defined(HDfstat) || !defined(HDstat) */
00772 
00773 #ifndef HDftell
00774     #define HDftell(F)          ftell(F)
00775 #endif /* HDftell */
00776 #ifndef HDftruncate
00777   #ifdef H5_HAVE_FTRUNCATE64
00778     #define HDftruncate(F,L)        ftruncate64(F,L)
00779   #else
00780     #define HDftruncate(F,L)        ftruncate(F,L)
00781   #endif
00782 #endif /* HDftruncate */
00783 #ifndef HDfwrite
00784     #define HDfwrite(M,Z,N,F)   fwrite(M,Z,N,F)
00785 #endif /* HDfwrite */
00786 #ifndef HDgetc
00787     #define HDgetc(F)           getc(F)
00788 #endif /* HDgetc */
00789 #ifndef HDgetchar
00790     #define HDgetchar()         getchar()
00791 #endif /* HDgetchar */
00792 #ifndef HDgetcwd
00793     #define HDgetcwd(S,Z)               getcwd(S,Z)
00794 #endif /* HDgetcwd */
00795 #ifndef HDgetdcwd
00796     #define HDgetdcwd(D,S,Z)    getcwd(S,Z)
00797 #endif /* HDgetdcwd */
00798 #ifndef HDgetdrive
00799     #define HDgetdrive()                0
00800 #endif /* HDgetdrive */
00801 #ifndef HDgetegid
00802     #define HDgetegid()         getegid()
00803 #endif /* HDgetegid() */
00804 #ifndef HDgetenv
00805     #define HDgetenv(S)         getenv(S)
00806 #endif /* HDgetenv */
00807 #ifndef HDgeteuid
00808     #define HDgeteuid()         geteuid()
00809 #endif /* HDgeteuid */
00810 #ifndef HDgetgid
00811     #define HDgetgid()          getgid()
00812 #endif /* HDgetgid */
00813 #ifndef HDgetgrgid
00814     #define HDgetgrgid(G)               getgrgid(G)
00815 #endif /* HDgetgrgid */
00816 #ifndef HDgetgrnam
00817     #define HDgetgrnam(S)               getgrnam(S)
00818 #endif /* HDgetgrnam */
00819 #ifndef HDgetgroups
00820     #define HDgetgroups(Z,G)    getgroups(Z,G)
00821 #endif /* HDgetgroups */
00822 #ifndef HDgetlogin
00823     #define HDgetlogin()                getlogin()
00824 #endif /* HDgetlogin */
00825 #ifndef HDgetpgrp
00826     #define HDgetpgrp()         getpgrp()
00827 #endif /* HDgetpgrp */
00828 #ifndef HDgetpid
00829     #define HDgetpid()          getpid()
00830 #endif /* HDgetpid */
00831 #ifndef HDgetppid
00832     #define HDgetppid()         getppid()
00833 #endif /* HDgetppid */
00834 #ifndef HDgetpwnam
00835     #define HDgetpwnam(S)               getpwnam(S)
00836 #endif /* HDgetpwnam */
00837 #ifndef HDgetpwuid
00838     #define HDgetpwuid(U)               getpwuid(U)
00839 #endif /* HDgetpwuid */
00840 #ifndef HDgetrusage
00841     #define HDgetrusage(X,S)    getrusage(X,S)
00842 #endif /* HDgetrusage */
00843 #ifndef HDgets
00844     #define HDgets(S)           gets(S)
00845 #endif /* HDgets */
00846 #ifndef HDgettimeofday
00847     #define HDgettimeofday(S,P) gettimeofday(S,P)
00848 #endif /* HDgettimeofday */
00849 #ifndef HDgetuid
00850     #define HDgetuid()          getuid()
00851 #endif /* HDgetuid */
00852 #ifndef HDgmtime
00853     #define HDgmtime(T)         gmtime(T)
00854 #endif /* HDgmtime */
00855 #ifndef HDisalnum
00856     #define HDisalnum(C)                isalnum((int)(C)) /*cast for solaris warning*/
00857 #endif /* HDisalnum */
00858 #ifndef HDisalpha
00859     #define HDisalpha(C)                isalpha((int)(C)) /*cast for solaris warning*/
00860 #endif /* HDisalpha */
00861 #ifndef HDisatty
00862     #define HDisatty(F)         isatty(F)
00863 #endif /* HDisatty */
00864 #ifndef HDiscntrl
00865     #define HDiscntrl(C)                iscntrl((int)(C)) /*cast for solaris warning*/
00866 #endif /* HDiscntrl */
00867 #ifndef HDisdigit
00868     #define HDisdigit(C)                isdigit((int)(C)) /*cast for solaris warning*/
00869 #endif /* HDisdigit */
00870 #ifndef HDisgraph
00871     #define HDisgraph(C)                isgraph((int)(C)) /*cast for solaris warning*/
00872 #endif /* HDisgraph */
00873 #ifndef HDislower
00874     #define HDislower(C)                islower((int)(C)) /*cast for solaris warning*/
00875 #endif /* HDislower */
00876 #ifndef HDisprint
00877     #define HDisprint(C)                isprint((int)(C)) /*cast for solaris warning*/
00878 #endif /* HDisprint */
00879 #ifndef HDispunct
00880     #define HDispunct(C)                ispunct((int)(C)) /*cast for solaris warning*/
00881 #endif /* HDispunct */
00882 #ifndef HDisspace
00883     #define HDisspace(C)                isspace((int)(C)) /*cast for solaris warning*/
00884 #endif /* HDisspace */
00885 #ifndef HDisupper
00886     #define HDisupper(C)                isupper((int)(C)) /*cast for solaris warning*/
00887 #endif /* HDisupper */
00888 #ifndef HDisxdigit
00889     #define HDisxdigit(C)               isxdigit((int)(C)) /*cast for solaris warning*/
00890 #endif /* HDisxdigit */
00891 #ifndef HDkill
00892     #define HDkill(P,S)         kill(P,S)
00893 #endif /* HDkill */
00894 #ifndef HDlabs
00895     #define HDlabs(X)           labs(X)
00896 #endif /* HDlabs */
00897 #ifndef HDldexp
00898     #define HDldexp(X,N)                ldexp(X,N)
00899 #endif /* HDldexp */
00900 #ifndef HDldiv
00901     #define HDldiv(X,Y)         ldiv(X,Y)
00902 #endif /* HDldiv */
00903 #ifndef HDlink
00904     #define HDlink(OLD,NEW)             link(OLD,NEW)
00905 #endif /* HDlink */
00906 #ifndef HDlocaleconv
00907     #define HDlocaleconv()              localeconv()
00908 #endif /* HDlocaleconv */
00909 #ifndef HDlocaltime
00910     #define HDlocaltime(T)              localtime(T)
00911 #endif /* HDlocaltime */
00912 #ifndef HDlog
00913     #define HDlog(X)            log(X)
00914 #endif /* HDlog */
00915 #ifndef HDlog10
00916     #define HDlog10(X)          log10(X)
00917 #endif /* HDlog10 */
00918 #ifndef HDlongjmp
00919     #define HDlongjmp(J,N)              longjmp(J,N)
00920 #endif /* HDlongjmp */
00921 #ifndef HDlseek
00922     #ifdef H5_HAVE_LSEEK64
00923        #define HDlseek(F,O,W)   lseek64(F,O,W)
00924     #else
00925        #define HDlseek(F,O,W)   lseek(F,O,W)
00926     #endif
00927 #endif /* HDlseek */
00928 #ifndef HDmalloc
00929     #define HDmalloc(Z)         malloc(Z)
00930 #endif /* HDmalloc */
00931 #ifndef HDposix_memalign
00932     #define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z)
00933 #endif /* HDposix_memalign */
00934 #ifndef HDmblen
00935     #define HDmblen(S,N)                mblen(S,N)
00936 #endif /* HDmblen */
00937 #ifndef HDmbstowcs
00938     #define HDmbstowcs(P,S,Z)   mbstowcs(P,S,Z)
00939 #endif /* HDmbstowcs */
00940 #ifndef HDmbtowc
00941     #define HDmbtowc(P,S,Z)             mbtowc(P,S,Z)
00942 #endif /* HDmbtowc */
00943 #ifndef HDmemchr
00944     #define HDmemchr(S,C,Z)             memchr(S,C,Z)
00945 #endif /* HDmemchr */
00946 #ifndef HDmemcmp
00947     #define HDmemcmp(X,Y,Z)             memcmp(X,Y,Z)
00948 #endif /* HDmemcmp */
00949 /*
00950  * The (char*) casts are required for the DEC when optimizations are turned
00951  * on and the source and/or destination are not aligned.
00952  */
00953 #ifndef HDmemcpy
00954     #define HDmemcpy(X,Y,Z)             memcpy((char*)(X),(const char*)(Y),Z)
00955 #endif /* HDmemcpy */
00956 #ifndef HDmemmove
00957     #define HDmemmove(X,Y,Z)    memmove((char*)(X),(const char*)(Y),Z)
00958 #endif /* HDmemmove */
00959 #ifndef HDmemset
00960     #define HDmemset(X,C,Z)             memset(X,C,Z)
00961 #endif /* HDmemset */
00962 #ifndef HDmkdir
00963     #define HDmkdir(S,M)                mkdir(S,M)
00964 #endif /* HDmkdir */
00965 #ifndef HDmkfifo
00966     #define HDmkfifo(S,M)               mkfifo(S,M)
00967 #endif /* HDmkfifo */
00968 #ifndef HDmktime
00969     #define HDmktime(T)         mktime(T)
00970 #endif /* HDmktime */
00971 #ifndef HDmodf
00972     #define HDmodf(X,Y)         modf(X,Y)
00973 #endif /* HDmodf */
00974 #ifndef HDopen
00975     #ifdef _O_BINARY
00976         #define HDopen(S,F,M)           open(S,F|_O_BINARY,M)
00977     #else
00978         #define HDopen(S,F,M)           open(S,F,M)
00979     #endif
00980 #endif /* HDopen */
00981 #ifndef HDopendir
00982     #define HDopendir(S)                opendir(S)
00983 #endif /* HDopendir */
00984 #ifndef HDpathconf
00985     #define HDpathconf(S,N)             pathconf(S,N)
00986 #endif /* HDpathconf */
00987 #ifndef HDpause
00988     #define HDpause()           pause()
00989 #endif /* HDpause */
00990 #ifndef HDperror
00991     #define HDperror(S)         perror(S)
00992 #endif /* HDperror */
00993 #ifndef HDpipe
00994     #define HDpipe(F)           pipe(F)
00995 #endif /* HDpipe */
00996 #ifndef HDpow
00997     #define HDpow(X,Y)          pow(X,Y)
00998 #endif /* HDpow */
00999 /* printf() variable arguments */
01000 #ifndef HDputc
01001     #define HDputc(C,F)         putc(C,F)
01002 #endif /* HDputc*/
01003 #ifndef HDputchar
01004     #define HDputchar(C)                putchar(C)
01005 #endif /* HDputchar */
01006 #ifndef HDputs
01007     #define HDputs(S)           puts(S)
01008 #endif /* HDputs */
01009 #ifndef HDqsort
01010     #define HDqsort(M,N,Z,F)    qsort(M,N,Z,F)
01011 #endif /* HDqsort*/
01012 #ifndef HDraise
01013     #define HDraise(N)          raise(N)
01014 #endif /* HDraise */
01015 
01016 #ifdef H5_HAVE_RAND_R
01017     #ifndef HDrandom
01018         #define HDrandom()              HDrand()
01019     #endif /* HDrandom */
01020     H5_DLL int HDrand(void);
01021 #elif H5_HAVE_RANDOM
01022     #ifndef HDrand
01023         #define HDrand()                random()
01024     #endif /* HDrand */
01025     #ifndef HDrandom
01026         #define HDrandom()              random()
01027     #endif /* HDrandom */
01028 #else /* H5_HAVE_RANDOM */
01029     #ifndef HDrand
01030         #define HDrand()                rand()
01031     #endif /* HDrand */
01032     #ifndef HDrandom
01033         #define HDrandom()              rand()
01034     #endif /* HDrandom */
01035 #endif /* H5_HAVE_RANDOM */
01036 
01037 #ifndef HDread
01038     #define HDread(F,M,Z)               read(F,M,Z)
01039 #endif /* HDread */
01040 #ifndef HDreaddir
01041     #define HDreaddir(D)                readdir(D)
01042 #endif /* HDreaddir */
01043 #ifndef HDrealloc
01044     #define HDrealloc(M,Z)              realloc(M,Z)
01045 #endif /* HDrealloc */
01046 #ifdef H5_VMS
01047     #ifdef __cplusplus
01048         extern "C" {
01049     #endif /* __cplusplus */
01050     int HDremove_all(const char * fname);
01051     #ifdef __cplusplus
01052         }
01053     #endif /* __cplusplus */
01054     #ifndef HDremove
01055         #define HDremove(S)             HDremove_all(S)
01056     #endif /* HDremove */
01057 #else /* H5_VMS */
01058     #ifndef HDremove
01059         #define HDremove(S)             remove(S)
01060     #endif /* HDremove */
01061 #endif /*H5_VMS*/
01062 #ifndef HDrename
01063     #define HDrename(OLD,NEW)   rename(OLD,NEW)
01064 #endif /* HDrename */
01065 #ifndef HDrewind
01066     #define HDrewind(F)         rewind(F)
01067 #endif /* HDrewind */
01068 #ifndef HDrewinddir
01069     #define HDrewinddir(D)              rewinddir(D)
01070 #endif /* HDrewinddir */
01071 #ifndef HDrmdir
01072     #define HDrmdir(S)          rmdir(S)
01073 #endif /* HDrmdir */
01074 /* scanf() variable arguments */
01075 #ifndef HDsetbuf
01076     #define HDsetbuf(F,S)               setbuf(F,S)
01077 #endif /* HDsetbuf */
01078 #ifndef HDsetgid
01079     #define HDsetgid(G)         setgid(G)
01080 #endif /* HDsetgid */
01081 #ifndef HDsetjmp
01082     #define HDsetjmp(J)         setjmp(J)
01083 #endif /* HDsetjmp */
01084 #ifndef HDsetlocale
01085     #define HDsetlocale(N,S)    setlocale(N,S)
01086 #endif /* HDsetlocale */
01087 #ifndef HDsetpgid
01088     #define HDsetpgid(P,PG)             setpgid(P,PG)
01089 #endif /* HDsetpgid */
01090 #ifndef HDsetsid
01091     #define HDsetsid()          setsid()
01092 #endif /* HDsetsid */
01093 #ifndef HDsetuid
01094     #define HDsetuid(U)         setuid(U)
01095 #endif /* HDsetuid */
01096 #ifndef HDsetvbuf
01097     #define HDsetvbuf(F,S,M,Z)  setvbuf(F,S,M,Z)
01098 #endif /* HDsetvbuf */
01099 #ifndef HDsigaction
01100     #define HDsigaction(N,A)    sigaction(N,A)
01101 #endif /* HDsigaction */
01102 #ifndef HDsigaddset
01103     #define HDsigaddset(S,N)    sigaddset(S,N)
01104 #endif /* HDsigaddset */
01105 #ifndef HDsigdelset
01106     #define HDsigdelset(S,N)    sigdelset(S,N)
01107 #endif /* HDsigdelset */
01108 #ifndef HDsigemptyset
01109     #define HDsigemptyset(S)    sigemptyset(S)
01110 #endif /* HDsigemptyset */
01111 #ifndef HDsigfillset
01112     #define HDsigfillset(S)             sigfillset(S)
01113 #endif /* HDsigfillset */
01114 #ifndef HDsigismember
01115     #define HDsigismember(S,N)  sigismember(S,N)
01116 #endif /* HDsigismember */
01117 #ifndef HDsiglongjmp
01118     #define HDsiglongjmp(J,N)   siglongjmp(J,N)
01119 #endif /* HDsiglongjmp */
01120 #ifndef HDsignal
01121     #define HDsignal(N,F)               signal(N,F)
01122 #endif /* HDsignal */
01123 #ifndef HDsigpending
01124     #define HDsigpending(S)             sigpending(S)
01125 #endif /* HDsigpending */
01126 #ifndef HDsigprocmask
01127     #define HDsigprocmask(H,S,O)        sigprocmask(H,S,O)
01128 #endif /* HDsigprocmask */
01129 #ifndef HDsigsetjmp
01130     #define HDsigsetjmp(J,N)    sigsetjmp(J,N)
01131 #endif /* HDsigsetjmp */
01132 #ifndef HDsigsuspend
01133     #define HDsigsuspend(S)             sigsuspend(S)
01134 #endif /* HDsigsuspend */
01135 #ifndef HDsin
01136     #define HDsin(X)            sin(X)
01137 #endif /* HDsin */
01138 #ifndef HDsinh
01139     #define HDsinh(X)           sinh(X)
01140 #endif /* HDsinh */
01141 #ifndef HDsleep
01142     #define HDsleep(N)          sleep(N)
01143 #endif /* HDsleep */
01144 #ifndef HDsnprintf
01145     #define HDsnprintf          snprintf /*varargs*/
01146 #endif /* HDsnprintf */
01147 /* sprintf() variable arguments */
01148 #ifndef HDsqrt
01149     #define HDsqrt(X)           sqrt(X)
01150 #endif /* HDsqrt */
01151 #ifdef H5_HAVE_RAND_R
01152     H5_DLL void HDsrand(unsigned int seed);
01153     #ifndef HDsrandom
01154         #define HDsrandom(S)            HDsrand(S)
01155     #endif /* HDsrandom */
01156     #elif H5_HAVE_RANDOM
01157     #ifndef HDsrand
01158         #define HDsrand(S)              srandom(S)
01159     #endif /* HDsrand */
01160     #ifndef HDsrandom
01161         #define HDsrandom(S)            srandom(S)
01162     #endif /* HDsrandom */
01163 #else /* H5_HAVE_RAND_R */
01164     #ifndef HDsrand
01165         #define HDsrand(S)              srand(S)
01166     #endif /* HDsrand */
01167     #ifndef HDsrandom
01168         #define HDsrandom(S)            srand(S)
01169     #endif /* HDsrandom */
01170 #endif /* H5_HAVE_RAND_R */
01171 /* sscanf() variable arguments */
01172 
01173 #ifndef HDstrcat
01174     #define HDstrcat(X,Y)               strcat(X,Y)
01175 #endif /* HDstrcat */
01176 #ifndef HDstrchr
01177     #define HDstrchr(S,C)               strchr(S,C)
01178 #endif /* HDstrchr */
01179 #ifndef HDstrcmp
01180     #define HDstrcmp(X,Y)               strcmp(X,Y)
01181 #endif /* HDstrcmp */
01182 #ifndef HDstrcoll
01183     #define HDstrcoll(X,Y)              strcoll(X,Y)
01184 #endif /* HDstrcoll */
01185 #ifndef HDstrcpy
01186     #define HDstrcpy(X,Y)               strcpy(X,Y)
01187 #endif /* HDstrcpy */
01188 #ifndef HDstrcspn
01189     #define HDstrcspn(X,Y)              strcspn(X,Y)
01190 #endif /* HDstrcspn */
01191 #ifndef HDstrerror
01192     #define HDstrerror(N)               strerror(N)
01193 #endif /* HDstrerror */
01194 #ifndef HDstrftime
01195     #define HDstrftime(S,Z,F,T) strftime(S,Z,F,T)
01196 #endif /* HDstrftime */
01197 #ifndef HDstrlen
01198     #define HDstrlen(S)         strlen(S)
01199 #endif /* HDstrlen */
01200 #ifndef HDstrncat
01201     #define HDstrncat(X,Y,Z)    strncat(X,Y,Z)
01202 #endif /* HDstrncat */
01203 #ifndef HDstrncmp
01204     #define HDstrncmp(X,Y,Z)    strncmp(X,Y,Z)
01205 #endif /* HDstrncmp */
01206 #ifndef HDstrncpy
01207     #define HDstrncpy(X,Y,Z)    strncpy(X,Y,Z)
01208 #endif /* HDstrncpy */
01209 #ifndef HDstrpbrk
01210     #define HDstrpbrk(X,Y)              strpbrk(X,Y)
01211 #endif /* HDstrpbrk */
01212 #ifndef HDstrrchr
01213     #define HDstrrchr(S,C)              strrchr(S,C)
01214 #endif /* HDstrrchr */
01215 #ifndef HDstrspn
01216     #define HDstrspn(X,Y)               strspn(X,Y)
01217 #endif /* HDstrspn */
01218 #ifndef HDstrstr
01219     #define HDstrstr(X,Y)               strstr(X,Y)
01220 #endif /* HDstrstr */
01221 #ifndef HDstrtod
01222     #define HDstrtod(S,R)               strtod(S,R)
01223 #endif /* HDstrtod */
01224 #ifndef HDstrtok
01225     #define HDstrtok(X,Y)               strtok(X,Y)
01226 #endif /* HDstrtok */
01227 #ifndef HDstrtol
01228     #define HDstrtol(S,R,N)             strtol(S,R,N)
01229 #endif /* HDstrtol */
01230 H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base);
01231 #ifndef HDstrtoul
01232     #define HDstrtoul(S,R,N)    strtoul(S,R,N)
01233 #endif /* HDstrtoul */
01234 #ifndef HDstrxfrm
01235     #define HDstrxfrm(X,Y,Z)    strxfrm(X,Y,Z)
01236 #endif /* HDstrxfrm */
01237 #ifndef HDsysconf
01238     #define HDsysconf(N)                sysconf(N)
01239 #endif /* HDsysconf */
01240 #ifndef HDsystem
01241     #define HDsystem(S)         system(S)
01242 #endif /* HDsystem */
01243 #ifndef HDtan
01244     #define HDtan(X)            tan(X)
01245 #endif /* HDtan */
01246 #ifndef HDtanh
01247     #define HDtanh(X)           tanh(X)
01248 #endif /* HDtanh */
01249 #ifndef HDtcdrain
01250     #define HDtcdrain(F)                tcdrain(F)
01251 #endif /* HDtcdrain */
01252 #ifndef HDtcflow
01253     #define HDtcflow(F,A)               tcflow(F,A)
01254 #endif /* HDtcflow */
01255 #ifndef HDtcflush
01256     #define HDtcflush(F,N)              tcflush(F,N)
01257 #endif /* HDtcflush */
01258 #ifndef HDtcgetattr
01259     #define HDtcgetattr(F,T)    tcgetattr(F,T)
01260 #endif /* HDtcgetattr */
01261 #ifndef HDtcgetpgrp
01262     #define HDtcgetpgrp(F)              tcgetpgrp(F)
01263 #endif /* HDtcgetpgrp */
01264 #ifndef HDtcsendbreak
01265     #define HDtcsendbreak(F,N)  tcsendbreak(F,N)
01266 #endif /* HDtcsendbreak */
01267 #ifndef HDtcsetattr
01268     #define HDtcsetattr(F,O,T)  tcsetattr(F,O,T)
01269 #endif /* HDtcsetattr */
01270 #ifndef HDtcsetpgrp
01271     #define HDtcsetpgrp(F,N)    tcsetpgrp(F,N)
01272 #endif /* HDtcsetpgrp */
01273 #ifndef HDtime
01274     #define HDtime(T)           time(T)
01275 #endif /* HDtime */
01276 #ifndef HDtimes
01277     #define HDtimes(T)          times(T)
01278 #endif /* HDtimes*/
01279 #ifndef HDtmpfile
01280     #define HDtmpfile()         tmpfile()
01281 #endif /* HDtmpfile */
01282 #ifndef HDtmpnam
01283     #define HDtmpnam(S)         tmpnam(S)
01284 #endif /* HDtmpnam */
01285 #ifndef HDtolower
01286     #define HDtolower(C)                tolower(C)
01287 #endif /* HDtolower */
01288 #ifndef HDtoupper
01289     #define HDtoupper(C)                toupper(C)
01290 #endif /* HDtoupper */
01291 #ifndef HDttyname
01292     #define HDttyname(F)                ttyname(F)
01293 #endif /* HDttyname */
01294 #ifndef HDtzset
01295     #define HDtzset()           tzset()
01296 #endif /* HDtzset */
01297 #ifndef HDumask
01298     #define HDumask(N)          umask(N)
01299 #endif /* HDumask */
01300 #ifndef HDuname
01301     #define HDuname(S)          uname(S)
01302 #endif /* HDuname */
01303 #ifndef HDungetc
01304     #define HDungetc(C,F)               ungetc(C,F)
01305 #endif /* HDungetc */
01306 #ifndef HDunlink
01307     #define HDunlink(S)         unlink(S)
01308 #endif /* HDunlink */
01309 #ifndef HDutime
01310     #define HDutime(S,T)                utime(S,T)
01311 #endif /* HDutime */
01312 #ifndef HDva_arg
01313     #define HDva_arg(A,T)               va_arg(A,T)
01314 #endif /* HDva_arg */
01315 #ifndef HDva_end
01316     #define HDva_end(A)         va_end(A)
01317 #endif /* HDva_end */
01318 #ifndef HDva_start
01319     #define HDva_start(A,P)             va_start(A,P)
01320 #endif /* HDva_start */
01321 #ifndef HDvasprintf
01322     #define HDvasprintf(RET,FMT,A)  vasprintf(RET,FMT,A)
01323 #endif /* HDvasprintf */
01324 #ifndef HDvfprintf
01325     #define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A)
01326 #endif /* HDvfprintf */
01327 #ifndef HDvprintf
01328     #define HDvprintf(FMT,A)    vprintf(FMT,A)
01329 #endif /* HDvprintf */
01330 #ifndef HDvsprintf
01331     #define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A)
01332 #endif /* HDvsprintf */
01333 #ifndef HDvsnprintf
01334     #define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A)
01335 #endif /* HDvsnprintf */
01336 #ifndef HDwait
01337     #define HDwait(W)           wait(W)
01338 #endif /* HDwait */
01339 #ifndef HDwaitpid
01340     #define HDwaitpid(P,W,O)    waitpid(P,W,O)
01341 #endif /* HDwaitpid */
01342 #ifndef HDwcstombs
01343     #define HDwcstombs(S,P,Z)   wcstombs(S,P,Z)
01344 #endif /* HDwcstombs */
01345 #ifndef HDwctomb
01346     #define HDwctomb(S,C)               wctomb(S,C)
01347 #endif /* HDwctomb */
01348 #ifndef HDwrite
01349     #define HDwrite(F,M,Z)              write(F,M,Z)
01350 #endif /* HDwrite */
01351 
01352 /*
01353  * And now for a couple non-Posix functions...  Watch out for systems that
01354  * define these in terms of macros.
01355  */
01356 #if !defined strdup && !defined H5_HAVE_STRDUP
01357 extern char *strdup(const char *s);
01358 #endif
01359 
01360 #ifndef HDstrdup
01361     #define HDstrdup(S)     strdup(S)
01362 #endif /* HDstrdup */
01363 
01364 #ifndef HDpthread_self
01365     #define HDpthread_self()    pthread_self()
01366 #endif /* HDpthread_self */
01367 
01368 /* Use this version of pthread_self for printing the thread ID */
01369 #ifndef HDpthread_self_ulong
01370     #define HDpthread_self_ulong()    ((unsigned long)pthread_self())
01371 #endif /* HDpthread_self_ulong */
01372 
01373 #if defined(H5_HAVE_WINDOW_PATH)
01374 
01375 /* directory delimiter for Windows: slash and backslash are acceptable on Windows */
01376 #define DIR_SLASH_SEPC          '/'
01377 #define DIR_SEPC                '\\'
01378 #define DIR_SEPS                "\\"
01379 #define CHECK_DELIMITER(SS)     ((SS == DIR_SEPC)||(SS == DIR_SLASH_SEPC))
01380 #define CHECK_ABSOLUTE(NAME)    ((isalpha(NAME[0])) && (NAME[1] == ':') && (CHECK_DELIMITER(NAME[2])))
01381 #define CHECK_ABS_DRIVE(NAME)   ((isalpha(NAME[0])) && (NAME[1] == ':'))
01382 #define CHECK_ABS_PATH(NAME)    (CHECK_DELIMITER(NAME[0]))
01383 
01384 #define GET_LAST_DELIMITER(NAME, ptr) {                 \
01385     char        *slash, *backslash;                     \
01386     slash = strrchr(NAME, DIR_SLASH_SEPC);              \
01387     backslash = strrchr(NAME, DIR_SEPC);                \
01388     if (backslash > slash)                              \
01389         (ptr = backslash);                              \
01390     else                                                \
01391         (ptr = slash);                                  \
01392 }
01393 
01394 #elif defined(H5_HAVE_VMS_PATH)
01395 
01396 /* OpenVMS pathname: <disk name>$<partition>:[path]<file name>
01397  *     i.g. SYS$SYSUSERS:[LU.HDF5.SRC]H5system.c */
01398 #define         DIR_SEPC        '.'
01399 #define         DIR_SEPS        "."
01400 #define         CHECK_DELIMITER(SS)             (SS == DIR_SEPC)
01401 #define         CHECK_ABSOLUTE(NAME)            (strrchr(NAME, ':') && strrchr(NAME, '['))
01402 #define         CHECK_ABS_DRIVE(NAME)           (0)
01403 #define         CHECK_ABS_PATH(NAME)            (0)
01404 #define         GET_LAST_DELIMITER(NAME, ptr)   ptr = strrchr(NAME, ']');
01405 
01406 #else
01407 
01408 #define         DIR_SEPC        '/'
01409 #define         DIR_SEPS        "/"
01410 #define         CHECK_DELIMITER(SS)             (SS == DIR_SEPC)
01411 #define         CHECK_ABSOLUTE(NAME)            (CHECK_DELIMITER(*NAME))
01412 #define         CHECK_ABS_DRIVE(NAME)           (0)
01413 #define         CHECK_ABS_PATH(NAME)            (0)
01414 #define         GET_LAST_DELIMITER(NAME, ptr)   ptr = strrchr(NAME, DIR_SEPC);
01415 
01416 #endif
01417 
01418 #define         COLON_SEPC      ':'
01419 H5_DLL herr_t   H5_build_extpath(const char *, char ** /*out*/ );
01420 
01421 
01422 /*
01423  * These macros check whether debugging has been requested for a certain
01424  * package at run-time.  Code for debugging is conditionally compiled by
01425  * defining constants like `H5X_DEBUG'.  In order to see the output though
01426  * the code must be enabled at run-time with an environment variable
01427  * HDF5_DEBUG which is a list of packages to debug.
01428  *
01429  * Note:  If you add/remove items from this enum then be sure to update the
01430  *        information about the package in H5_init_library().
01431  */
01432 typedef enum {
01433     H5_PKG_A,                           /*Attributes                    */
01434     H5_PKG_AC,                          /*Meta data cache               */
01435     H5_PKG_B,                           /*B-trees                       */
01436     H5_PKG_D,                           /*Datasets                      */
01437     H5_PKG_E,                           /*Error handling                */
01438     H5_PKG_F,                           /*Files                         */
01439     H5_PKG_G,                           /*Groups                        */
01440     H5_PKG_HG,                          /*Global heap                   */
01441     H5_PKG_HL,                          /*Local heap                    */
01442     H5_PKG_I,                           /*Interface                     */
01443     H5_PKG_MF,                          /*File memory management        */
01444     H5_PKG_MM,                          /*Core memory management        */
01445     H5_PKG_O,                           /*Object headers                */
01446     H5_PKG_P,                           /*Property lists                */
01447     H5_PKG_S,                           /*Data spaces                   */
01448     H5_PKG_T,                           /*Data types                    */
01449     H5_PKG_V,                           /*Vector functions              */
01450     H5_PKG_Z,                           /*Raw data filters              */
01451     H5_NPKGS                            /*Must be last                  */
01452 } H5_pkg_t;
01453 
01454 typedef struct H5_debug_t {
01455     FILE                *trace;         /*API trace output stream       */
01456     hbool_t             ttop;           /*Show only top-level calls?    */
01457     hbool_t             ttimes;         /*Show trace event times?       */
01458     struct {
01459         const char      *name;          /*package name                  */
01460         FILE            *stream;        /*output stream or NULL         */
01461     } pkg[H5_NPKGS];
01462 } H5_debug_t;
01463 
01464 extern H5_debug_t               H5_debug_g;
01465 #define H5DEBUG(X)              (H5_debug_g.pkg[H5_PKG_##X].stream)
01466 
01467 /*-------------------------------------------------------------------------
01468  * Purpose:     These macros are inserted automatically just after the
01469  *              FUNC_ENTER() macro of API functions and are used to trace
01470  *              application program execution. Unless H5_DEBUG_API has been
01471  *              defined they are no-ops.
01472  *
01473  * Arguments:   R       - Return type encoded as a string
01474  *              T       - Argument types encoded as a string
01475  *              A0-An   - Arguments.  The number at the end of the macro name
01476  *                        indicates the number of arguments.
01477  *
01478  * Programmer:  Robb Matzke
01479  *
01480  * Modifications:
01481  *-------------------------------------------------------------------------
01482  */
01483 #ifdef H5_DEBUG_API
01484 #define H5TRACE_DECL                       const char *RTYPE=NULL;                                      \
01485                                            double CALLTIME;
01486 #define H5TRACE0(R,T)                      RTYPE=R;                                                     \
01487                                            CALLTIME=H5_trace(NULL,FUNC,T)
01488 #define H5TRACE1(R,T,A0)                   RTYPE=R;                                                     \
01489                                            CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0)
01490 #define H5TRACE2(R,T,A0,A1)                RTYPE=R;                                                     \
01491                                            CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1)
01492 #define H5TRACE3(R,T,A0,A1,A2)             RTYPE=R;                                                     \
01493                                            CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2)
01494 #define H5TRACE4(R,T,A0,A1,A2,A3)          RTYPE=R;                                                     \
01495                                            CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3)
01496 #define H5TRACE5(R,T,A0,A1,A2,A3,A4)       RTYPE=R;                                                     \
01497                                            CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,   \
01498                                                              #A4,A4)
01499 #define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5)    RTYPE=R;                                                     \
01500                                            CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,   \
01501                                                              #A4,A4,#A5,A5)
01502 #define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6) RTYPE=R;                                                     \
01503                                            CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,   \
01504                                                              #A4,A4,#A5,A5,#A6,A6)
01505 #define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7) RTYPE=R;                                                  \
01506                                            CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,   \
01507                                                              #A4,A4,#A5,A5,#A6,A6,#A7,A7)
01508 #define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8) RTYPE=R;                                               \
01509                                            CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,   \
01510                                                              #A4,A4,#A5,A5,#A6,A6,#A7,A7,#A8,A8)
01511 #define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9) RTYPE=R;                                           \
01512                                            CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,   \
01513                                                              #A4,A4,#A5,A5,#A6,A6,#A7,A7,#A8,A8,#A9,A9)
01514 #define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) RTYPE=R;                                       \
01515                                            CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,   \
01516                                                              #A4,A4,#A5,A5,#A6,A6,#A7,A7,#A8,A8,#A9,A9, \
01517                                                              #A10,A10)
01518 #define H5TRACE_RETURN(V)                  if (RTYPE) {                                                 \
01519                                               H5_trace(&CALLTIME,FUNC,RTYPE,NULL,V);                    \
01520                                               RTYPE=NULL;                                               \
01521                                            }
01522 #else
01523 #define H5TRACE_DECL                                    /*void*/
01524 #define H5TRACE0(R,T)                                   /*void*/
01525 #define H5TRACE1(R,T,A0)                                /*void*/
01526 #define H5TRACE2(R,T,A0,A1)                             /*void*/
01527 #define H5TRACE3(R,T,A0,A1,A2)                          /*void*/
01528 #define H5TRACE4(R,T,A0,A1,A2,A3)                       /*void*/
01529 #define H5TRACE5(R,T,A0,A1,A2,A3,A4)                    /*void*/
01530 #define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5)                 /*void*/
01531 #define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6)              /*void*/
01532 #define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7)           /*void*/
01533 #define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8)        /*void*/
01534 #define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9)    /*void*/
01535 #define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) /*void*/
01536 #define H5TRACE_RETURN(V)                               /*void*/
01537 #endif
01538 
01539 H5_DLL double H5_trace(const double *calltime, const char *func, const char *type, ...);
01540 
01541 
01542 /*-------------------------------------------------------------------------
01543  * Purpose:     Register function entry for library initialization and code
01544  *              profiling.
01545  *
01546  * Notes:       Every file must have a file-scope variable called
01547  *              `initialize_interface_g' of type hbool_t which is initialized
01548  *              to FALSE.
01549  *
01550  *              Don't use local variable initializers which contain
01551  *              calls to other library functions since the initializer
01552  *              would happen before the FUNC_ENTER() gets called.  Don't
01553  *              use initializers that require special cleanup code to
01554  *              execute if FUNC_ENTER() fails since a failing FUNC_ENTER()
01555  *              returns immediately without branching to the `done' label.
01556  *
01557  * Programmer:  Quincey Koziol
01558  *
01559  * Modifications:
01560  *
01561  *-------------------------------------------------------------------------
01562  */
01563 
01564 /* `S' is the name of a function which is being tested to check if its */
01565 /*      an API function */
01566 #define H5_IS_API(S) ('_'!=S[2] && '_'!=S[3] && (!S[4] || '_'!=S[4]))
01567 
01568 /* global library version information string */
01569 extern char     H5_lib_vers_info_g[];
01570 
01571 /* Lock headers */
01572 #ifdef H5_HAVE_THREADSAFE
01573 
01574 /* Include required thread-safety header */
01575 #include "H5TSprivate.h"
01576 
01577 /* replacement structure for original global variable */
01578 typedef struct H5_api_struct {
01579     H5TS_mutex_t init_lock;  /* API entrance mutex */
01580     hbool_t H5_libinit_g;    /* Has the library been initialized? */
01581 } H5_api_t;
01582 
01583 /* Macros for accessing the global variables */
01584 #define H5_INIT_GLOBAL H5_g.H5_libinit_g
01585 
01586 /* Macro for first thread initialization */
01587 #define H5_FIRST_THREAD_INIT                                                  \
01588    pthread_once(&H5TS_first_init_g, H5TS_first_thread_init);
01589 
01590 /* Macros for threadsafe HDF-5 Phase I locks */
01591 #define H5_API_LOCK                                                           \
01592      H5TS_mutex_lock(&H5_g.init_lock);
01593 #define H5_API_UNLOCK                                                         \
01594      H5TS_mutex_unlock(&H5_g.init_lock);
01595 
01596 /* Macros for thread cancellation-safe mechanism */
01597 #define H5_API_UNSET_CANCEL                                                   \
01598     H5TS_cancel_count_inc();
01599 
01600 #define H5_API_SET_CANCEL                                                     \
01601     H5TS_cancel_count_dec();
01602 
01603 extern H5_api_t H5_g;
01604 
01605 #else /* H5_HAVE_THREADSAFE */
01606 
01607 /* disable any first thread init mechanism */
01608 #define H5_FIRST_THREAD_INIT
01609 
01610 /* disable locks (sequential version) */
01611 #define H5_API_LOCK
01612 #define H5_API_UNLOCK
01613 
01614 /* disable cancelability (sequential version) */
01615 #define H5_API_UNSET_CANCEL
01616 #define H5_API_SET_CANCEL
01617 
01618 /* extern global variables */
01619 extern hbool_t H5_libinit_g;    /* Has the library been initialized? */
01620 
01621 /* Macros for accessing the global variables */
01622 #define H5_INIT_GLOBAL H5_libinit_g
01623 
01624 #endif /* H5_HAVE_THREADSAFE */
01625 
01626 #ifdef H5_HAVE_CODESTACK
01627 
01628 /* Include required function stack header */
01629 #include "H5CSprivate.h"
01630 
01631 #define H5_PUSH_FUNC(func_name) H5CS_push(#func_name)
01632 #define H5_POP_FUNC             H5CS_pop()
01633 #else /* H5_HAVE_CODESTACK */
01634 #define H5_PUSH_FUNC(func_name) /* void */
01635 #define H5_POP_FUNC             /* void */
01636 #endif /* H5_HAVE_CODESTACK */
01637 
01638 #ifdef H5_HAVE_MPE
01639 extern hbool_t H5_MPEinit_g;   /* Has the MPE Library been initialized? */
01640 #endif
01641 
01642 /* Check if the function name is correct (if the compiler supports __FUNCTION__) */
01643 #ifdef H5_HAVE_FUNCTION
01644 #define H5_CHECK_FUNCNAME(func_name) \
01645     assert(!HDstrcmp(#func_name, __FUNCTION__))
01646 #else /* H5_HAVE_FUNCTION */
01647 #define H5_CHECK_FUNCNAME(func_name) \
01648     assert(func_name)
01649 #endif /* H5_HAVE_FUNCTION */
01650 
01651 /* Macros for defining interface initialization routines */
01652 #ifdef H5_INTERFACE_INIT_FUNC
01653 static int              H5_interface_initialize_g = 0;
01654 static herr_t           H5_INTERFACE_INIT_FUNC(void);
01655 #define H5_INTERFACE_INIT(err)                                                \
01656    /* Initialize this interface or bust */                                    \
01657    if (!H5_interface_initialize_g) {                                          \
01658       H5_interface_initialize_g = 1;                                          \
01659       if (H5_INTERFACE_INIT_FUNC()<0) {                                       \
01660          H5_interface_initialize_g = 0;                                       \
01661          HGOTO_ERROR (H5E_FUNC, H5E_CANTINIT, err,                            \
01662             "interface initialization failed")                                \
01663       }                                                                       \
01664    }
01665 #else /* H5_INTERFACE_INIT_FUNC */
01666 #define H5_INTERFACE_INIT(err)
01667 #endif /* H5_INTERFACE_INIT_FUNC */
01668 
01669 
01670 #ifndef NDEBUG
01671 #define FUNC_ENTER_COMMON_NOFUNC(func_name,asrt)                              \
01672     static hbool_t func_check = FALSE;                                        \
01673                                                                               \
01674     if(!func_check) {                                                         \
01675         /* Check API status */                                                \
01676         HDassert(asrt);                                                       \
01677                                                                               \
01678         /* Check function name */                                             \
01679         H5_CHECK_FUNCNAME(func_name);                                         \
01680                                                                               \
01681         /* Don't check again */                                               \
01682         func_check = TRUE;                                                    \
01683     } /* end if */
01684 #else /* NDEBUG */
01685 #define FUNC_ENTER_COMMON_NOFUNC(func_name,asrt)
01686 #endif /* NDEBUG */
01687 
01688 #define FUNC_ENTER_COMMON(func_name,asrt)                                     \
01689     static const char FUNC[]=#func_name;                                      \
01690     FUNC_ENTER_COMMON_NOFUNC(func_name,asrt);
01691 
01692 /* Threadsafety initialization code for API routines */
01693 #define FUNC_ENTER_API_THREADSAFE                                             \
01694    /* Initialize the thread-safe code */                                      \
01695    H5_FIRST_THREAD_INIT                                                       \
01696                                                                               \
01697    /* Grab the mutex for the library */                                       \
01698    H5_API_UNSET_CANCEL                                                        \
01699    H5_API_LOCK
01700 
01701 /* Threadsafety termination code for API routines */
01702 #define FUNC_LEAVE_API_THREADSAFE                                             \
01703     H5_API_UNLOCK                                                             \
01704     H5_API_SET_CANCEL
01705 
01706 /* Local variables for API routines */
01707 #define FUNC_ENTER_API_VARS(func_name)                                        \
01708     MPE_LOG_VARS(func_name)                                                   \
01709     H5TRACE_DECL
01710 
01711 /* Use this macro for all "normal" API functions */
01712 #define FUNC_ENTER_API(func_name,err) {{                                      \
01713     FUNC_ENTER_API_VARS(func_name)                                            \
01714     FUNC_ENTER_COMMON(func_name,H5_IS_API(#func_name));                       \
01715     FUNC_ENTER_API_THREADSAFE;                                                \
01716     FUNC_ENTER_API_COMMON(func_name,err);                                     \
01717     /* Clear thread error stack entering public functions */                  \
01718     H5E_clear_stack(NULL);                                                    \
01719     {
01720 
01721 /*
01722  * Use this macro for API functions that shouldn't clear the error stack
01723  *      like H5Eprint and H5Ewalk.
01724  */
01725 #define FUNC_ENTER_API_NOCLEAR(func_name,err) {{                              \
01726     FUNC_ENTER_API_VARS(func_name)                                            \
01727     FUNC_ENTER_COMMON(func_name,H5_IS_API(#func_name));                       \
01728     FUNC_ENTER_API_THREADSAFE;                                                \
01729     FUNC_ENTER_API_COMMON(func_name,err);                                     \
01730     {
01731 
01732 /*
01733  * Use this macro for API functions that shouldn't perform _any_ initialization
01734  *      of the library or an interface, just perform tracing, etc.  Examples
01735  *      are: H5check_version, etc.
01736  *
01737  */
01738 #define FUNC_ENTER_API_NOINIT(func_name) {{                                   \
01739     FUNC_ENTER_API_VARS(func_name)                                            \
01740     FUNC_ENTER_COMMON(func_name,H5_IS_API(#func_name));                       \
01741     FUNC_ENTER_API_THREADSAFE;                                                \
01742     H5_PUSH_FUNC(func_name);                                                  \
01743     BEGIN_MPE_LOG(func_name);                                                 \
01744     {
01745 
01746 /*
01747  * Use this macro for API functions that shouldn't perform _any_ initialization
01748  *      of the library or an interface or push themselves on the function
01749  *      stack, just perform tracing, etc.  Examples
01750  *      are: H5close, H5check_version, etc.
01751  *
01752  */
01753 #define FUNC_ENTER_API_NOINIT_NOFS(func_name) {{                              \
01754     FUNC_ENTER_API_VARS(func_name)                                            \
01755     FUNC_ENTER_COMMON(func_name,H5_IS_API(#func_name));                       \
01756     FUNC_ENTER_API_THREADSAFE;                                                \
01757     BEGIN_MPE_LOG(func_name);                                                 \
01758     {
01759 
01760 /* Use this macro for all "normal" non-API functions */
01761 #define FUNC_ENTER_NOAPI(func_name,err) {                                     \
01762     FUNC_ENTER_COMMON(func_name,!H5_IS_API(#func_name));                      \
01763     FUNC_ENTER_NOAPI_INIT(func_name,err)                                      \
01764     {
01765 
01766 /* Use this macro for all non-API functions which don't issue errors */
01767 #define FUNC_ENTER_NOAPI_NOFUNC(func_name) {                                  \
01768     FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name));               \
01769     FUNC_ENTER_NOAPI_INIT(func_name,err)                                      \
01770     {
01771 
01772 /*
01773  * Use this macro for non-API functions which fall into these categories:
01774  *      - static functions, since they must be called from a function in the
01775  *              interface, the library and interface must already be
01776  *              initialized.
01777  *      - functions which are called during library shutdown, since we don't
01778  *              want to re-initialize the library.
01779  */
01780 #define FUNC_ENTER_NOAPI_NOINIT(func_name) {                                        \
01781     FUNC_ENTER_COMMON(func_name,!H5_IS_API(#func_name));                      \
01782     H5_PUSH_FUNC(func_name);                                                  \
01783     {
01784 
01785 /*
01786  * Use this macro for non-API functions which fall into these categories:
01787  *      - static functions, since they must be called from a function in the
01788  *              interface, the library and interface must already be
01789  *              initialized.
01790  *      - functions which are called during library shutdown, since we don't
01791  *              want to re-initialize the library.
01792  *
01793  * This macro is used for functions which fit the above categories _and_
01794  * also don't use the 'FUNC' variable (i.e. don't push errors on the error stack)
01795  *
01796  */
01797 #define FUNC_ENTER_NOAPI_NOINIT_NOFUNC(func_name) {                           \
01798     FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name));               \
01799     H5_PUSH_FUNC(func_name);                                                  \
01800     {
01801 
01802 /*
01803  * Use this macro for non-API functions which fall into these categories:
01804  *      - functions which shouldn't push their name on the function stack
01805  *              (so far, just the H5CS routines themselves)
01806  *
01807  * This macro is used for functions which fit the above categories _and_
01808  * also don't use the 'FUNC' variable (i.e. don't push errors on the error stack)
01809  *
01810  */
01811 #define FUNC_ENTER_NOAPI_NOFUNC_NOFS(func_name) {                             \
01812     FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name));               \
01813     {
01814 
01815 #define FUNC_ENTER_API_COMMON(func_name,err)                                  \
01816    /* Initialize the library */                                               \
01817    if (!(H5_INIT_GLOBAL)) {                                                   \
01818        H5_INIT_GLOBAL = TRUE;                                                 \
01819        if (H5_init_library()<0)                                               \
01820           HGOTO_ERROR (H5E_FUNC, H5E_CANTINIT, err,                           \
01821             "library initialization failed")                                  \
01822    }                                                                          \
01823                                                                               \
01824    /* Initialize the interface, if appropriate */                             \
01825    H5_INTERFACE_INIT(err)                                                     \
01826                                                                               \
01827    /* Push the name of this function on the function stack */                 \
01828    H5_PUSH_FUNC(func_name);                                                   \
01829                                                                               \
01830    BEGIN_MPE_LOG(func_name)
01831 
01832 /* Note: this macro only works when there's _no_ interface initialization routine for the module */
01833 #define FUNC_ENTER_NOAPI_INIT(func_name,err)                                  \
01834    /* Initialize the interface, if appropriate */                             \
01835    H5_INTERFACE_INIT(err)                                                     \
01836                                                                               \
01837    /* Push the name of this function on the function stack */                 \
01838    H5_PUSH_FUNC(func_name);
01839 
01840 /*-------------------------------------------------------------------------
01841  * Purpose:     Register function exit for code profiling.  This should be
01842  *              the last statement executed by a function.
01843  *
01844  * Programmer:  Quincey Koziol
01845  *
01846  * Modifications:
01847  *
01848  *      Robb Matzke, 4 Aug 1997
01849  *      The pablo mask comes from the constant PABLO_MASK defined on a
01850  *      per-file basis.  The pablo_func_id comes from an auto variable
01851  *      defined by FUNC_ENTER.
01852  *      PABLO was deleted on January 21, 2005 EIP
01853  *
01854  *-------------------------------------------------------------------------
01855  */
01856 #define FUNC_LEAVE_API(ret_value)                                             \
01857         FINISH_MPE_LOG;                                                       \
01858         H5TRACE_RETURN(ret_value);                                            \
01859         H5_POP_FUNC;                                                          \
01860         FUNC_LEAVE_API_THREADSAFE                                             \
01861         return (ret_value);                                                   \
01862     } /*end scope from end of FUNC_ENTER*/                                    \
01863 }} /*end scope from beginning of FUNC_ENTER*/
01864 
01865 #define FUNC_LEAVE_API_NOFS(ret_value)                                        \
01866         FINISH_MPE_LOG;                                                       \
01867         H5TRACE_RETURN(ret_value);                                            \
01868         FUNC_LEAVE_API_THREADSAFE                                             \
01869         return (ret_value);                                                   \
01870     } /*end scope from end of FUNC_ENTER*/                                    \
01871 }} /*end scope from beginning of FUNC_ENTER*/
01872 
01873 #define FUNC_LEAVE_NOAPI(ret_value)                                           \
01874         H5_POP_FUNC;                                                          \
01875         return (ret_value);                                                   \
01876     } /*end scope from end of FUNC_ENTER*/                                    \
01877 } /*end scope from beginning of FUNC_ENTER*/
01878 
01879 #define FUNC_LEAVE_NOAPI_VOID                                                 \
01880         H5_POP_FUNC;                                                          \
01881         return;                                                               \
01882     } /*end scope from end of FUNC_ENTER*/                                    \
01883 } /*end scope from beginning of FUNC_ENTER*/
01884 
01885 /*
01886  * Use this macro for non-API functions which fall into these categories:
01887  *      - functions which didn't push their name on the function stack
01888  *              (so far, just the H5CS routines themselves)
01889  */
01890 #define FUNC_LEAVE_NOAPI_NOFS(ret_value)                                      \
01891         return (ret_value);                                                   \
01892     } /*end scope from end of FUNC_ENTER*/                                    \
01893 } /*end scope from beginning of FUNC_ENTER*/
01894 
01895 
01896 /* Macro for "glueing" together items, for re-scanning macros */
01897 #define H5_GLUE(x,y)       x##y
01898 #define H5_GLUE3(x,y,z)    x##y##z
01899 
01900 /* Compile-time "assert" macro */
01901 #define HDcompile_assert(e)     do { enum { compile_assert__ = 1 / (e) }; } while(0)
01902 
01903 /* Private functions, not part of the publicly documented API */
01904 H5_DLL herr_t H5_init_library(void);
01905 H5_DLL void H5_term_library(void);
01906 
01907 /* Functions to terminate interfaces */
01908 H5_DLL int H5A_term_interface(void);
01909 H5_DLL int H5AC_term_interface(void);
01910 H5_DLL int H5D_term_interface(void);
01911 H5_DLL int H5E_term_interface(void);
01912 H5_DLL int H5F_term_interface(void);
01913 H5_DLL int H5FS_term_interface(void);
01914 H5_DLL int H5G_term_interface(void);
01915 H5_DLL int H5I_term_interface(void);
01916 H5_DLL int H5L_term_interface(void);
01917 H5_DLL int H5P_term_interface(void);
01918 H5_DLL int H5R_term_interface(void);
01919 H5_DLL int H5S_term_interface(void);
01920 H5_DLL int H5T_term_interface(void);
01921 H5_DLL int H5Z_term_interface(void);
01922 
01923 /* Checksum functions */
01924 H5_DLL uint32_t H5_checksum_fletcher32(const void *data, size_t len);
01925 H5_DLL uint32_t H5_checksum_crc(const void *data, size_t len);
01926 H5_DLL uint32_t H5_checksum_lookup3(const void *data, size_t len, uint32_t initval);
01927 H5_DLL uint32_t H5_checksum_metadata(const void *data, size_t len, uint32_t initval);
01928 H5_DLL uint32_t H5_hash_string(const char *str);
01929 
01930 /* Functions for debugging */
01931 H5_DLL herr_t H5_buffer_dump(FILE *stream, int indent, uint8_t *buf,
01932     uint8_t *marker, size_t buf_offset, size_t buf_size);
01933 
01934 #endif /* _H5private_H */
01935