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  * Data types and functions for timing certain parts of the library.
00440  */
00441 typedef struct {
00442     double      utime;          /*user time                     */
00443     double      stime;          /*system time                   */
00444     double      etime;          /*elapsed wall-clock time       */
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/*in,out*/,
00450                            H5_timer_t *timer/*in,out*/);
00451 H5_DLL void H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds);
00452 H5_DLL time_t H5_now(void);
00453 
00454 /* Depth of object copy */
00455 typedef enum {
00456     H5_COPY_SHALLOW,    /* Shallow copy from source to destination, just copy field pointers */
00457     H5_COPY_DEEP        /* Deep copy from source to destination, including duplicating fields pointed to */
00458 } H5_copy_depth_t;
00459 
00460 /* Common object copying udata (right now only used for groups and datasets) */
00461 typedef struct H5O_copy_file_ud_common_t {
00462     struct H5O_pline_t *src_pline;      /* Copy of filter pipeline for object */
00463 } H5O_copy_file_ud_common_t;
00464 
00465 /* Unique object "position" */
00466 typedef struct {
00467     unsigned long fileno;       /* The unique identifier for the file of the object */
00468     haddr_t addr;               /* The unique address of the object's header in that file */
00469 } H5_obj_t;
00470 
00471 /*
00472  * Redefine all the POSIX functions.  We should never see a POSIX
00473  * function (or any other non-HDF5 function) in the source!
00474  */
00475 
00476  /* Use platform-specific versions if necessary */
00477 #include "H5win32defs.h"
00478 
00479 #ifndef HDabort
00480     #define HDabort()           abort()
00481 #endif /* HDabort */
00482 #ifndef HDabs
00483     #define HDabs(X)            abs(X)
00484 #endif /* HDabs */
00485 #ifndef HDaccess
00486     #define HDaccess(F,M)               access(F, M)
00487 #endif /* HDaccess */
00488 #ifndef HDacos
00489     #define HDacos(X)           acos(X)
00490 #endif /* HDacos */
00491 #ifndef HDalarm
00492     #ifdef H5_HAVE_ALARM
00493         #define HDalarm(N)              alarm(N)
00494     #else /* H5_HAVE_ALARM */
00495         #define HDalarm(N)              (0)
00496     #endif /* H5_HAVE_ALARM */
00497 #endif /* HDalarm */
00498 #ifndef HDasctime
00499     #define HDasctime(T)                asctime(T)
00500 #endif /* HDasctime */
00501 #ifndef HDasin
00502     #define HDasin(X)           asin(X)
00503 #endif /* HDasin */
00504 #ifndef HDassert
00505     #define HDassert(X)         assert(X)
00506 #endif /* HDassert */
00507 #ifndef HDatan
00508     #define HDatan(X)           atan(X)
00509 #endif /* HDatan */
00510 #ifndef HDatan2
00511     #define HDatan2(X,Y)                atan2(X,Y)
00512 #endif /* HDatan2 */
00513 #ifndef HDatexit
00514     #define HDatexit(F)         atexit(F)
00515 #endif /* HDatexit */
00516 #ifndef HDatof
00517     #define HDatof(S)           atof(S)
00518 #endif /* HDatof */
00519 #ifndef HDatoi
00520     #define HDatoi(S)           atoi(S)
00521 #endif /* HDatoi */
00522 #ifndef HDatol
00523     #define HDatol(S)           atol(S)
00524 #endif /* HDatol */
00525 #ifndef HDBSDgettimeofday
00526     #define HDBSDgettimeofday(S,P)      BSDgettimeofday(S,P)
00527 #endif /* HDBSDgettimeofday */
00528 #ifndef HDbsearch
00529     #define HDbsearch(K,B,N,Z,F)        bsearch(K,B,N,Z,F)
00530 #endif /* HDbsearch */
00531 #ifndef HDcalloc
00532     #define HDcalloc(N,Z)               calloc(N,Z)
00533 #endif /* HDcalloc */
00534 #ifndef HDceil
00535     #define HDceil(X)           ceil(X)
00536 #endif /* HDceil */
00537 #ifndef HDcfgetispeed
00538     #define HDcfgetispeed(T)    cfgetispeed(T)
00539 #endif /* HDcfgetispeed */
00540 #ifndef HDcfgetospeed
00541     #define HDcfgetospeed(T)    cfgetospeed(T)
00542 #endif /* HDcfgetospeed */
00543 #ifndef HDcfsetispeed
00544     #define HDcfsetispeed(T,S)  cfsetispeed(T,S)
00545 #endif /* HDcfsetispeed */
00546 #ifndef HDcfsetospeed
00547     #define HDcfsetospeed(T,S)  cfsetospeed(T,S)
00548 #endif /* HDcfsetospeed */
00549 #ifndef HDchdir
00550     #define HDchdir(S)          chdir(S)
00551 #endif /* HDchdir */
00552 #ifndef HDchmod
00553     #define HDchmod(S,M)                chmod(S,M)
00554 #endif /* HDchmod */
00555 #ifndef HDchown
00556     #define HDchown(S,O,G)              chown(S,O,G)
00557 #endif /* HDchown */
00558 #ifndef HDclearerr
00559     #define HDclearerr(F)               clearerr(F)
00560 #endif /* HDclearerr */
00561 #ifndef HDclock
00562     #define HDclock()           clock()
00563 #endif /* HDclock */
00564 #ifndef HDclose
00565     #define HDclose(F)          close(F)
00566 #endif /* HDclose */
00567 #ifndef HDclosedir
00568     #define HDclosedir(D)               closedir(D)
00569 #endif /* HDclosedir */
00570 #ifndef HDcos
00571     #define HDcos(X)            cos(X)
00572 #endif /* HDcos */
00573 #ifndef HDcosh
00574     #define HDcosh(X)           cosh(X)
00575 #endif /* HDcosh */
00576 #ifndef HDcreat
00577     #define HDcreat(S,M)                creat(S,M)
00578 #endif /* HDcreat */
00579 #ifndef HDctermid
00580     #define HDctermid(S)                ctermid(S)
00581 #endif /* HDctermid */
00582 #ifndef HDctime
00583     #define HDctime(T)          ctime(T)
00584 #endif /* HDctime */
00585 #ifndef HDcuserid
00586     #define HDcuserid(S)                cuserid(S)
00587 #endif /* HDcuserid */
00588 #ifndef HDdifftime
00589     #ifdef H5_HAVE_DIFFTIME
00590         #define HDdifftime(X,Y)         difftime(X,Y)
00591     #else /* H5_HAVE_DIFFTIME */
00592         #define HDdifftime(X,Y)         ((double)(X)-(double)(Y))
00593     #endif /* H5_HAVE_DIFFTIME */
00594 #endif /* HDdifftime */
00595 #ifndef HDdiv
00596     #define HDdiv(X,Y)          div(X,Y)
00597 #endif /* HDdiv */
00598 #ifndef HDdup
00599     #define HDdup(F)            dup(F)
00600 #endif /* HDdup */
00601 #ifndef HDdup2
00602     #define HDdup2(F,I)         dup2(F,I)
00603 #endif /* HDdup2 */
00604 /* execl() variable arguments */
00605 /* execle() variable arguments */
00606 /* execlp() variable arguments */
00607 #ifndef HDexecv
00608     #define HDexecv(S,AV)               execv(S,AV)
00609 #endif /* HDexecv */
00610 #ifndef HDexecve
00611     #define HDexecve(S,AV,E)    execve(S,AV,E)
00612 #endif /* HDexecve */
00613 #ifndef HDexecvp
00614     #define HDexecvp(S,AV)              execvp(S,AV)
00615 #endif /* HDexecvp */
00616 #ifndef HDexit
00617     #define HDexit(N)           exit(N)
00618 #endif /* HDexit */
00619 #ifndef HD_exit
00620     #define HD_exit(N)          _exit(N)
00621 #endif /* HD_exit */
00622 #ifndef HDexp
00623     #define HDexp(X)            exp(X)
00624 #endif /* HDexp */
00625 #ifndef HDfabs
00626     #define HDfabs(X)           fabs(X)
00627 #endif /* HDfabs */
00628 /* use ABS() because fabsf() fabsl() are not common yet. */
00629 #ifndef HDfabsf
00630     #define HDfabsf(X)          ABS(X)
00631 #endif /* HDfabsf */
00632 #ifndef HDfabsl
00633     #define HDfabsl(X)          ABS(X)
00634 #endif /* HDfabsl */
00635 #ifndef HDfclose
00636     #define HDfclose(F)         fclose(F)
00637 #endif /* HDfclose */
00638 /* fcntl() variable arguments */
00639 #ifndef HDfdopen
00640     #define HDfdopen(N,S)               fdopen(N,S)
00641 #endif /* HDfdopen */
00642 #ifndef HDfeof
00643     #define HDfeof(F)           feof(F)
00644 #endif /* HDfeof */
00645 #ifndef HDferror
00646     #define HDferror(F)         ferror(F)
00647 #endif /* HDferror */
00648 #ifndef HDfflush
00649     #define HDfflush(F)         fflush(F)
00650 #endif /* HDfflush */
00651 #ifndef HDfgetc
00652     #define HDfgetc(F)          fgetc(F)
00653 #endif /* HDfgetc */
00654 #ifndef HDfgetpos
00655     #define HDfgetpos(F,P)              fgetpos(F,P)
00656 #endif /* HDfgetpos */
00657 #ifndef HDfgets
00658     #define HDfgets(S,N,F)              fgets(S,N,F)
00659 #endif /* HDfgets */
00660 #ifndef HDfileno
00661     #define HDfileno(F)         fileno(F)
00662 #endif /* HDfileno */
00663 #ifndef HDfloor
00664     #define HDfloor(X)          floor(X)
00665 #endif /* HDfloor */
00666 #ifndef HDfmod
00667     #define HDfmod(X,Y)         fmod(X,Y)
00668 #endif /* HDfmod */
00669 #ifndef HDfopen
00670     #define HDfopen(S,M)                fopen(S,M)
00671 #endif /* HDfopen */
00672 #ifndef HDfork
00673     #define HDfork()            fork()
00674 #endif /* HDfork */
00675 #ifndef HDfpathconf
00676     #define HDfpathconf(F,N)    fpathconf(F,N)
00677 #endif /* HDfpathconf */
00678 H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
00679 #ifndef HDfputc
00680     #define HDfputc(C,F)                fputc(C,F)
00681 #endif /* HDfputc */
00682 #ifndef HDfputs
00683     #define HDfputs(S,F)                fputs(S,F)
00684 #endif /* HDfputs */
00685 #ifndef HDfread
00686     #define HDfread(M,Z,N,F)    fread(M,Z,N,F)
00687 #endif /* HDfread */
00688 #ifndef HDfree
00689     #define HDfree(M)           free(M)
00690 #endif /* HDfree */
00691 #ifndef HDfreopen
00692     #define HDfreopen(S,M,F)    freopen(S,M,F)
00693 #endif /* HDfreopen */
00694 #ifndef HDfrexp
00695     #define HDfrexp(X,N)                frexp(X,N)
00696 #endif /* HDfrexp */
00697 /* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */
00698 #ifndef HDfrexpf
00699     #ifdef H5_HAVE_FREXPF
00700         #define HDfrexpf(X,N)           frexpf(X,N)
00701     #else /* H5_HAVE_FREXPF */
00702         #define HDfrexpf(X,N)           frexp(X,N)
00703     #endif /* H5_HAVE_FREXPF */
00704 #endif /* HDfrexpf */
00705 #ifndef HDfrexpl
00706     #ifdef H5_HAVE_FREXPL
00707         #define HDfrexpl(X,N)           frexpl(X,N)
00708     #else /* H5_HAVE_FREXPL */
00709         #define HDfrexpl(X,N)           frexp(X,N)
00710     #endif /* H5_HAVE_FREXPL */
00711 #endif /* HDfrexpl */
00712 /* fscanf() variable arguments */
00713 #ifndef HDfseek
00714     #ifdef H5_HAVE_FSEEKO
00715              #define HDfseek(F,O,W)     fseeko(F,O,W)
00716     #else /* H5_HAVE_FSEEKO */
00717              #define HDfseek(F,O,W)     fseek(F,O,W)
00718     #endif /* H5_HAVE_FSEEKO */
00719 #endif /* HDfseek */
00720 #ifndef HDfsetpos
00721     #define HDfsetpos(F,P)              fsetpos(F,P)
00722 #endif /* HDfsetpos */
00723 /* definitions related to the file stat utilities.
00724  * For Unix, if off_t is not 64bit big, try use the pseudo-standard
00725  * xxx64 versions if available.
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 /* HDfstat */
00732         #ifndef HDlstat
00733             #define HDlstat(S,B)        lstat64(S,B)
00734         #endif /* HDlstat */
00735         #ifndef HDstat
00736             #define HDstat(S,B)         stat64(S,B)
00737         #endif /* HDstat */
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 /* H5_SIZEOF_OFF_T!=8 && ... */
00742         #ifndef HDfstat
00743             #define HDfstat(F,B)        fstat(F,B)
00744         #endif /* HDfstat */
00745         #ifndef HDlstat
00746             #define HDlstat(S,B)        lstat(S,B)
00747         #endif /* HDlstat */
00748         #ifndef HDstat
00749             #define HDstat(S,B)         stat(S,B)
00750         #endif /* HDstat */
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 /* H5_SIZEOF_OFF_T!=8 && ... */
00755 #endif /* !defined(HDfstat) || !defined(HDstat) */
00756 
00757 #ifndef HDftell
00758     #define HDftell(F)          ftell(F)
00759 #endif /* HDftell */
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 /* HDftruncate */
00767 #ifndef HDfwrite
00768     #define HDfwrite(M,Z,N,F)   fwrite(M,Z,N,F)
00769 #endif /* HDfwrite */
00770 #ifndef HDgetc
00771     #define HDgetc(F)           getc(F)
00772 #endif /* HDgetc */
00773 #ifndef HDgetchar
00774     #define HDgetchar()         getchar()
00775 #endif /* HDgetchar */
00776 #ifndef HDgetcwd
00777     #define HDgetcwd(S,Z)               getcwd(S,Z)
00778 #endif /* HDgetcwd */
00779 #ifndef HDgetdcwd
00780     #define HDgetdcwd(D,S,Z)    getcwd(S,Z)
00781 #endif /* HDgetdcwd */
00782 #ifndef HDgetdrive
00783     #define HDgetdrive()                0
00784 #endif /* HDgetdrive */
00785 #ifndef HDgetegid
00786     #define HDgetegid()         getegid()
00787 #endif /* HDgetegid() */
00788 #ifndef HDgetenv
00789     #define HDgetenv(S)         getenv(S)
00790 #endif /* HDgetenv */
00791 #ifndef HDgeteuid
00792     #define HDgeteuid()         geteuid()
00793 #endif /* HDgeteuid */
00794 #ifndef HDgetgid
00795     #define HDgetgid()          getgid()
00796 #endif /* HDgetgid */
00797 #ifndef HDgetgrgid
00798     #define HDgetgrgid(G)               getgrgid(G)
00799 #endif /* HDgetgrgid */
00800 #ifndef HDgetgrnam
00801     #define HDgetgrnam(S)               getgrnam(S)
00802 #endif /* HDgetgrnam */
00803 #ifndef HDgetgroups
00804     #define HDgetgroups(Z,G)    getgroups(Z,G)
00805 #endif /* HDgetgroups */
00806 #ifndef HDgetlogin
00807     #define HDgetlogin()                getlogin()
00808 #endif /* HDgetlogin */
00809 #ifndef HDgetpgrp
00810     #define HDgetpgrp()         getpgrp()
00811 #endif /* HDgetpgrp */
00812 #ifndef HDgetpid
00813     #define HDgetpid()          getpid()
00814 #endif /* HDgetpid */
00815 #ifndef HDgetppid
00816     #define HDgetppid()         getppid()
00817 #endif /* HDgetppid */
00818 #ifndef HDgetpwnam
00819     #define HDgetpwnam(S)               getpwnam(S)
00820 #endif /* HDgetpwnam */
00821 #ifndef HDgetpwuid
00822     #define HDgetpwuid(U)               getpwuid(U)
00823 #endif /* HDgetpwuid */
00824 #ifndef HDgetrusage
00825     #define HDgetrusage(X,S)    getrusage(X,S)
00826 #endif /* HDgetrusage */
00827 #ifndef HDgets
00828     #define HDgets(S)           gets(S)
00829 #endif /* HDgets */
00830 #ifndef HDgettimeofday
00831     #define HDgettimeofday(S,P) gettimeofday(S,P)
00832 #endif /* HDgettimeofday */
00833 #ifndef HDgetuid
00834     #define HDgetuid()          getuid()
00835 #endif /* HDgetuid */
00836 #ifndef HDgmtime
00837     #define HDgmtime(T)         gmtime(T)
00838 #endif /* HDgmtime */
00839 #ifndef HDisalnum
00840     #define HDisalnum(C)                isalnum((int)(C)) /*cast for solaris warning*/
00841 #endif /* HDisalnum */
00842 #ifndef HDisalpha
00843     #define HDisalpha(C)                isalpha((int)(C)) /*cast for solaris warning*/
00844 #endif /* HDisalpha */
00845 #ifndef HDisatty
00846     #define HDisatty(F)         isatty(F)
00847 #endif /* HDisatty */
00848 #ifndef HDiscntrl
00849     #define HDiscntrl(C)                iscntrl((int)(C)) /*cast for solaris warning*/
00850 #endif /* HDiscntrl */
00851 #ifndef HDisdigit
00852     #define HDisdigit(C)                isdigit((int)(C)) /*cast for solaris warning*/
00853 #endif /* HDisdigit */
00854 #ifndef HDisgraph
00855     #define HDisgraph(C)                isgraph((int)(C)) /*cast for solaris warning*/
00856 #endif /* HDisgraph */
00857 #ifndef HDislower
00858     #define HDislower(C)                islower((int)(C)) /*cast for solaris warning*/
00859 #endif /* HDislower */
00860 #ifndef HDisprint
00861     #define HDisprint(C)                isprint((int)(C)) /*cast for solaris warning*/
00862 #endif /* HDisprint */
00863 #ifndef HDispunct
00864     #define HDispunct(C)                ispunct((int)(C)) /*cast for solaris warning*/
00865 #endif /* HDispunct */
00866 #ifndef HDisspace
00867     #define HDisspace(C)                isspace((int)(C)) /*cast for solaris warning*/
00868 #endif /* HDisspace */
00869 #ifndef HDisupper
00870     #define HDisupper(C)                isupper((int)(C)) /*cast for solaris warning*/
00871 #endif /* HDisupper */
00872 #ifndef HDisxdigit
00873     #define HDisxdigit(C)               isxdigit((int)(C)) /*cast for solaris warning*/
00874 #endif /* HDisxdigit */
00875 #ifndef HDkill
00876     #define HDkill(P,S)         kill(P,S)
00877 #endif /* HDkill */
00878 #ifndef HDlabs
00879     #define HDlabs(X)           labs(X)
00880 #endif /* HDlabs */
00881 #ifndef HDldexp
00882     #define HDldexp(X,N)                ldexp(X,N)
00883 #endif /* HDldexp */
00884 #ifndef HDldiv
00885     #define HDldiv(X,Y)         ldiv(X,Y)
00886 #endif /* HDldiv */
00887 #ifndef HDlink
00888     #define HDlink(OLD,NEW)             link(OLD,NEW)
00889 #endif /* HDlink */
00890 #ifndef HDlocaleconv
00891     #define HDlocaleconv()              localeconv()
00892 #endif /* HDlocaleconv */
00893 #ifndef HDlocaltime
00894     #define HDlocaltime(T)              localtime(T)
00895 #endif /* HDlocaltime */
00896 #ifndef HDlog
00897     #define HDlog(X)            log(X)
00898 #endif /* HDlog */
00899 #ifndef HDlog10
00900     #define HDlog10(X)          log10(X)
00901 #endif /* HDlog10 */
00902 #ifndef HDlongjmp
00903     #define HDlongjmp(J,N)              longjmp(J,N)
00904 #endif /* HDlongjmp */
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 /* HDlseek */
00912 #ifndef HDmalloc
00913     #define HDmalloc(Z)         malloc(Z)
00914 #endif /* HDmalloc */
00915 #ifndef HDposix_memalign
00916     #define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z)
00917 #endif /* HDposix_memalign */
00918 #ifndef HDmblen
00919     #define HDmblen(S,N)                mblen(S,N)
00920 #endif /* HDmblen */
00921 #ifndef HDmbstowcs
00922     #define HDmbstowcs(P,S,Z)   mbstowcs(P,S,Z)
00923 #endif /* HDmbstowcs */
00924 #ifndef HDmbtowc
00925     #define HDmbtowc(P,S,Z)             mbtowc(P,S,Z)
00926 #endif /* HDmbtowc */
00927 #ifndef HDmemchr
00928     #define HDmemchr(S,C,Z)             memchr(S,C,Z)
00929 #endif /* HDmemchr */
00930 #ifndef HDmemcmp
00931     #define HDmemcmp(X,Y,Z)             memcmp(X,Y,Z)
00932 #endif /* HDmemcmp */
00933 /*
00934  * The (char*) casts are required for the DEC when optimizations are turned
00935  * on and the source and/or destination are not aligned.
00936  */
00937 #ifndef HDmemcpy
00938     #define HDmemcpy(X,Y,Z)             memcpy((char*)(X),(const char*)(Y),Z)
00939 #endif /* HDmemcpy */
00940 #ifndef HDmemmove
00941     #define HDmemmove(X,Y,Z)    memmove((char*)(X),(const char*)(Y),Z)
00942 #endif /* HDmemmove */
00943 #ifndef HDmemset
00944     #define HDmemset(X,C,Z)             memset(X,C,Z)
00945 #endif /* HDmemset */
00946 #ifndef HDmkdir
00947     #define HDmkdir(S,M)                mkdir(S,M)
00948 #endif /* HDmkdir */
00949 #ifndef HDmkfifo
00950     #define HDmkfifo(S,M)               mkfifo(S,M)
00951 #endif /* HDmkfifo */
00952 #ifndef HDmktime
00953     #define HDmktime(T)         mktime(T)
00954 #endif /* HDmktime */
00955 #ifndef HDmodf
00956     #define HDmodf(X,Y)         modf(X,Y)
00957 #endif /* HDmodf */
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 /* HDopen */
00965 #ifndef HDopendir
00966     #define HDopendir(S)                opendir(S)
00967 #endif /* HDopendir */
00968 #ifndef HDpathconf
00969     #define HDpathconf(S,N)             pathconf(S,N)
00970 #endif /* HDpathconf */
00971 #ifndef HDpause
00972     #define HDpause()           pause()
00973 #endif /* HDpause */
00974 #ifndef HDperror
00975     #define HDperror(S)         perror(S)
00976 #endif /* HDperror */
00977 #ifndef HDpipe
00978     #define HDpipe(F)           pipe(F)
00979 #endif /* HDpipe */
00980 #ifndef HDpow
00981     #define HDpow(X,Y)          pow(X,Y)
00982 #endif /* HDpow */
00983 /* printf() variable arguments */
00984 #ifndef HDputc
00985     #define HDputc(C,F)         putc(C,F)
00986 #endif /* HDputc*/
00987 #ifndef HDputchar
00988     #define HDputchar(C)                putchar(C)
00989 #endif /* HDputchar */
00990 #ifndef HDputs
00991     #define HDputs(S)           puts(S)
00992 #endif /* HDputs */
00993 #ifndef HDqsort
00994     #define HDqsort(M,N,Z,F)    qsort(M,N,Z,F)
00995 #endif /* HDqsort*/
00996 #ifndef HDraise
00997     #define HDraise(N)          raise(N)
00998 #endif /* HDraise */
00999 
01000 #ifdef H5_HAVE_RAND_R
01001     #ifndef HDrandom
01002         #define HDrandom()              HDrand()
01003     #endif /* HDrandom */
01004     H5_DLL int HDrand(void);
01005 #elif H5_HAVE_RANDOM
01006     #ifndef HDrand
01007         #define HDrand()                random()
01008     #endif /* HDrand */
01009     #ifndef HDrandom
01010         #define HDrandom()              random()
01011     #endif /* HDrandom */
01012 #else /* H5_HAVE_RANDOM */
01013     #ifndef HDrand
01014         #define HDrand()                rand()
01015     #endif /* HDrand */
01016     #ifndef HDrandom
01017         #define HDrandom()              rand()
01018     #endif /* HDrandom */
01019 #endif /* H5_HAVE_RANDOM */
01020 
01021 #ifndef HDread
01022     #define HDread(F,M,Z)               read(F,M,Z)
01023 #endif /* HDread */
01024 #ifndef HDreaddir
01025     #define HDreaddir(D)                readdir(D)
01026 #endif /* HDreaddir */
01027 #ifndef HDrealloc
01028     #define HDrealloc(M,Z)              realloc(M,Z)
01029 #endif /* HDrealloc */
01030 #ifndef HDrealpath
01031     #define HDrealpath(F1,F2)           realpath(F1,F2)
01032 #endif /* HDrealloc */
01033 #ifdef H5_VMS
01034     #ifdef __cplusplus
01035         extern "C" {
01036     #endif /* __cplusplus */
01037     int HDremove_all(const char * fname);
01038     #ifdef __cplusplus
01039         }
01040     #endif /* __cplusplus */
01041     #ifndef HDremove
01042         #define HDremove(S)             HDremove_all(S)
01043     #endif /* HDremove */
01044 #else /* H5_VMS */
01045     #ifndef HDremove
01046         #define HDremove(S)             remove(S)
01047     #endif /* HDremove */
01048 #endif /*H5_VMS*/
01049 #ifndef HDrename
01050     #define HDrename(OLD,NEW)   rename(OLD,NEW)
01051 #endif /* HDrename */
01052 #ifndef HDrewind
01053     #define HDrewind(F)         rewind(F)
01054 #endif /* HDrewind */
01055 #ifndef HDrewinddir
01056     #define HDrewinddir(D)              rewinddir(D)
01057 #endif /* HDrewinddir */
01058 #ifndef HDrmdir
01059     #define HDrmdir(S)          rmdir(S)
01060 #endif /* HDrmdir */
01061 /* scanf() variable arguments */
01062 #ifndef HDsetbuf
01063     #define HDsetbuf(F,S)               setbuf(F,S)
01064 #endif /* HDsetbuf */
01065 #ifndef HDsetgid
01066     #define HDsetgid(G)         setgid(G)
01067 #endif /* HDsetgid */
01068 #ifndef HDsetjmp
01069     #define HDsetjmp(J)         setjmp(J)
01070 #endif /* HDsetjmp */
01071 #ifndef HDsetlocale
01072     #define HDsetlocale(N,S)    setlocale(N,S)
01073 #endif /* HDsetlocale */
01074 #ifndef HDsetpgid
01075     #define HDsetpgid(P,PG)             setpgid(P,PG)
01076 #endif /* HDsetpgid */
01077 #ifndef HDsetsid
01078     #define HDsetsid()          setsid()
01079 #endif /* HDsetsid */
01080 #ifndef HDsetuid
01081     #define HDsetuid(U)         setuid(U)
01082 #endif /* HDsetuid */
01083 #ifndef HDsetvbuf
01084     #define HDsetvbuf(F,S,M,Z)  setvbuf(F,S,M,Z)
01085 #endif /* HDsetvbuf */
01086 #ifndef HDsigaddset
01087     #define HDsigaddset(S,N)    sigaddset(S,N)
01088 #endif /* HDsigaddset */
01089 #ifndef HDsigdelset
01090     #define HDsigdelset(S,N)    sigdelset(S,N)
01091 #endif /* HDsigdelset */
01092 #ifndef HDsigemptyset
01093     #define HDsigemptyset(S)    sigemptyset(S)
01094 #endif /* HDsigemptyset */
01095 #ifndef HDsigfillset
01096     #define HDsigfillset(S)             sigfillset(S)
01097 #endif /* HDsigfillset */
01098 #ifndef HDsigismember
01099     #define HDsigismember(S,N)  sigismember(S,N)
01100 #endif /* HDsigismember */
01101 #ifndef HDsiglongjmp
01102     #define HDsiglongjmp(J,N)   siglongjmp(J,N)
01103 #endif /* HDsiglongjmp */
01104 #ifndef HDsignal
01105     #define HDsignal(N,F)               signal(N,F)
01106 #endif /* HDsignal */
01107 #ifndef HDsigpending
01108     #define HDsigpending(S)             sigpending(S)
01109 #endif /* HDsigpending */
01110 #ifndef HDsigprocmask
01111     #define HDsigprocmask(H,S,O)        sigprocmask(H,S,O)
01112 #endif /* HDsigprocmask */
01113 #ifndef HDsigsetjmp
01114     #define HDsigsetjmp(J,N)    sigsetjmp(J,N)
01115 #endif /* HDsigsetjmp */
01116 #ifndef HDsigsuspend
01117     #define HDsigsuspend(S)             sigsuspend(S)
01118 #endif /* HDsigsuspend */
01119 #ifndef HDsin
01120     #define HDsin(X)            sin(X)
01121 #endif /* HDsin */
01122 #ifndef HDsinh
01123     #define HDsinh(X)           sinh(X)
01124 #endif /* HDsinh */
01125 #ifndef HDsleep
01126     #define HDsleep(N)          sleep(N)
01127 #endif /* HDsleep */
01128 #ifndef HDsnprintf
01129     #define HDsnprintf          snprintf /*varargs*/
01130 #endif /* HDsnprintf */
01131 /* sprintf() variable arguments */
01132 #ifndef HDsqrt
01133     #define HDsqrt(X)           sqrt(X)
01134 #endif /* HDsqrt */
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 /* HDsrandom */
01140 #elif H5_HAVE_RANDOM
01141     #ifndef HDsrand
01142         #define HDsrand(S)              srandom(S)
01143     #endif /* HDsrand */
01144     #ifndef HDsrandom
01145         #define HDsrandom(S)            srandom(S)
01146     #endif /* HDsrandom */
01147 #else /* H5_HAVE_RAND_R */
01148     #ifndef HDsrand
01149         #define HDsrand(S)              srand(S)
01150     #endif /* HDsrand */
01151     #ifndef HDsrandom
01152         #define HDsrandom(S)            srand(S)
01153     #endif /* HDsrandom */
01154 #endif /* H5_HAVE_RAND_R */
01155 /* sscanf() variable arguments */
01156 
01157 #ifndef HDstrcat
01158     #define HDstrcat(X,Y)               strcat(X,Y)
01159 #endif /* HDstrcat */
01160 #ifndef HDstrchr
01161     #define HDstrchr(S,C)               strchr(S,C)
01162 #endif /* HDstrchr */
01163 #ifndef HDstrcmp
01164     #define HDstrcmp(X,Y)               strcmp(X,Y)
01165 #endif /* HDstrcmp */
01166 #ifndef HDstrcasecmp
01167     #define HDstrcasecmp(X,Y)       strcasecmp(X,Y)
01168 #endif /* HDstrcasecmp */
01169 #ifndef HDstrcoll
01170     #define HDstrcoll(X,Y)              strcoll(X,Y)
01171 #endif /* HDstrcoll */
01172 #ifndef HDstrcpy
01173     #define HDstrcpy(X,Y)               strcpy(X,Y)
01174 #endif /* HDstrcpy */
01175 #ifndef HDstrcspn
01176     #define HDstrcspn(X,Y)              strcspn(X,Y)
01177 #endif /* HDstrcspn */
01178 #ifndef HDstrerror
01179     #define HDstrerror(N)               strerror(N)
01180 #endif /* HDstrerror */
01181 #ifndef HDstrftime
01182     #define HDstrftime(S,Z,F,T) strftime(S,Z,F,T)
01183 #endif /* HDstrftime */
01184 #ifndef HDstrlen
01185     #define HDstrlen(S)         strlen(S)
01186 #endif /* HDstrlen */
01187 #ifndef HDstrncat
01188     #define HDstrncat(X,Y,Z)    strncat(X,Y,Z)
01189 #endif /* HDstrncat */
01190 #ifndef HDstrncmp
01191     #define HDstrncmp(X,Y,Z)    strncmp(X,Y,Z)
01192 #endif /* HDstrncmp */
01193 #ifndef HDstrncpy
01194     #define HDstrncpy(X,Y,Z)    strncpy(X,Y,Z)
01195 #endif /* HDstrncpy */
01196 #ifndef HDstrpbrk
01197     #define HDstrpbrk(X,Y)              strpbrk(X,Y)
01198 #endif /* HDstrpbrk */
01199 #ifndef HDstrrchr
01200     #define HDstrrchr(S,C)              strrchr(S,C)
01201 #endif /* HDstrrchr */
01202 #ifndef HDstrspn
01203     #define HDstrspn(X,Y)               strspn(X,Y)
01204 #endif /* HDstrspn */
01205 #ifndef HDstrstr
01206     #define HDstrstr(X,Y)               strstr(X,Y)
01207 #endif /* HDstrstr */
01208 #ifndef HDstrtod
01209     #define HDstrtod(S,R)               strtod(S,R)
01210 #endif /* HDstrtod */
01211 #ifndef HDstrtok
01212     #define HDstrtok(X,Y)               strtok(X,Y)
01213 #endif /* HDstrtok */
01214 #ifndef HDstrtol
01215     #define HDstrtol(S,R,N)             strtol(S,R,N)
01216 #endif /* HDstrtol */
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 /* HDstrtoul */
01221 #ifndef HDstrtoull
01222     #define HDstrtoull(S,R,N)   strtoull(S,R,N)
01223 #endif /* HDstrtoul */
01224 #ifndef HDstrxfrm
01225     #define HDstrxfrm(X,Y,Z)    strxfrm(X,Y,Z)
01226 #endif /* HDstrxfrm */
01227 #ifdef H5_HAVE_SYMLINK
01228     #ifndef HDsymlink
01229         #define HDsymlink(F1,F2)        symlink(F1,F2)
01230     #endif /* HDsymlink */
01231 #endif /* H5_HAVE_SYMLINK */
01232 #ifndef HDsysconf
01233     #define HDsysconf(N)                sysconf(N)
01234 #endif /* HDsysconf */
01235 #ifndef HDsystem
01236     #define HDsystem(S)         system(S)
01237 #endif /* HDsystem */
01238 #ifndef HDtan
01239     #define HDtan(X)            tan(X)
01240 #endif /* HDtan */
01241 #ifndef HDtanh
01242     #define HDtanh(X)           tanh(X)
01243 #endif /* HDtanh */
01244 #ifndef HDtcdrain
01245     #define HDtcdrain(F)                tcdrain(F)
01246 #endif /* HDtcdrain */
01247 #ifndef HDtcflow
01248     #define HDtcflow(F,A)               tcflow(F,A)
01249 #endif /* HDtcflow */
01250 #ifndef HDtcflush
01251     #define HDtcflush(F,N)              tcflush(F,N)
01252 #endif /* HDtcflush */
01253 #ifndef HDtcgetattr
01254     #define HDtcgetattr(F,T)    tcgetattr(F,T)
01255 #endif /* HDtcgetattr */
01256 #ifndef HDtcgetpgrp
01257     #define HDtcgetpgrp(F)              tcgetpgrp(F)
01258 #endif /* HDtcgetpgrp */
01259 #ifndef HDtcsendbreak
01260     #define HDtcsendbreak(F,N)  tcsendbreak(F,N)
01261 #endif /* HDtcsendbreak */
01262 #ifndef HDtcsetattr
01263     #define HDtcsetattr(F,O,T)  tcsetattr(F,O,T)
01264 #endif /* HDtcsetattr */
01265 #ifndef HDtcsetpgrp
01266     #define HDtcsetpgrp(F,N)    tcsetpgrp(F,N)
01267 #endif /* HDtcsetpgrp */
01268 #ifndef HDtime
01269     #define HDtime(T)           time(T)
01270 #endif /* HDtime */
01271 #ifndef HDtimes
01272     #define HDtimes(T)          times(T)
01273 #endif /* HDtimes*/
01274 #ifndef HDtmpfile
01275     #define HDtmpfile()         tmpfile()
01276 #endif /* HDtmpfile */
01277 #ifndef HDtmpnam
01278     #define HDtmpnam(S)         tmpnam(S)
01279 #endif /* HDtmpnam */
01280 #ifndef HDtolower
01281     #define HDtolower(C)                tolower(C)
01282 #endif /* HDtolower */
01283 #ifndef HDtoupper
01284     #define HDtoupper(C)                toupper(C)
01285 #endif /* HDtoupper */
01286 #ifndef HDttyname
01287     #define HDttyname(F)                ttyname(F)
01288 #endif /* HDttyname */
01289 #ifndef HDtzset
01290     #define HDtzset()           tzset()
01291 #endif /* HDtzset */
01292 #ifndef HDumask
01293     #define HDumask(N)          umask(N)
01294 #endif /* HDumask */
01295 #ifndef HDuname
01296     #define HDuname(S)          uname(S)
01297 #endif /* HDuname */
01298 #ifndef HDungetc
01299     #define HDungetc(C,F)               ungetc(C,F)
01300 #endif /* HDungetc */
01301 #ifndef HDunlink
01302     #define HDunlink(S)         unlink(S)
01303 #endif /* HDunlink */
01304 #ifndef HDutime
01305     #define HDutime(S,T)                utime(S,T)
01306 #endif /* HDutime */
01307 #ifndef HDva_arg
01308     #define HDva_arg(A,T)               va_arg(A,T)
01309 #endif /* HDva_arg */
01310 #ifndef HDva_end
01311     #define HDva_end(A)         va_end(A)
01312 #endif /* HDva_end */
01313 #ifndef HDva_start
01314     #define HDva_start(A,P)             va_start(A,P)
01315 #endif /* HDva_start */
01316 #ifndef HDvasprintf
01317     #define HDvasprintf(RET,FMT,A)  vasprintf(RET,FMT,A)
01318 #endif /* HDvasprintf */
01319 #ifndef HDvfprintf
01320     #define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A)
01321 #endif /* HDvfprintf */
01322 #ifndef HDvprintf
01323     #define HDvprintf(FMT,A)    vprintf(FMT,A)
01324 #endif /* HDvprintf */
01325 #ifndef HDvsprintf
01326     #define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A)
01327 #endif /* HDvsprintf */
01328 #ifndef HDvsnprintf
01329     #define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A)
01330 #endif /* HDvsnprintf */
01331 #ifndef HDwait
01332     #define HDwait(W)           wait(W)
01333 #endif /* HDwait */
01334 #ifndef HDwaitpid
01335     #define HDwaitpid(P,W,O)    waitpid(P,W,O)
01336 #endif /* HDwaitpid */
01337 #ifndef HDwcstombs
01338     #define HDwcstombs(S,P,Z)   wcstombs(S,P,Z)
01339 #endif /* HDwcstombs */
01340 #ifndef HDwctomb
01341     #define HDwctomb(S,C)               wctomb(S,C)
01342 #endif /* HDwctomb */
01343 #ifndef HDwrite
01344     #define HDwrite(F,M,Z)              write(F,M,Z)
01345 #endif /* HDwrite */
01346 
01347 /*
01348  * And now for a couple non-Posix functions...  Watch out for systems that
01349  * define these in terms of macros.
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 /* HDstrdup */
01358 
01359 #ifndef HDpthread_self
01360     #define HDpthread_self()    pthread_self()
01361 #endif /* HDpthread_self */
01362 
01363 /* Use this version of pthread_self for printing the thread ID */
01364 #ifndef HDpthread_self_ulong
01365     #define HDpthread_self_ulong()    ((unsigned long)pthread_self())
01366 #endif /* HDpthread_self_ulong */
01367 
01368 /*
01369  * A macro for detecting over/under-flow when casting between types
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 /* NDEBUG */
01378 #define H5_CHECK_OVERFLOW(var, vartype, casttype)
01379 #endif /* NDEBUG */
01380 
01381 /*
01382  * A macro for detecting over/under-flow when assigning between types
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 /* Include the generated overflow header file */
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 /* NDEBUG */
01436 #define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype)  \
01437     (dst) = (dsttype)(src);
01438 #endif /* NDEBUG */
01439 
01440 #if defined(H5_HAVE_WINDOW_PATH)
01441 
01442 /* directory delimiter for Windows: slash and backslash are acceptable on Windows */
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 /* OpenVMS pathname: <disk name>$<partition>:[path]<file name>
01464  *     i.g. SYS$SYSUSERS:[LU.HDF5.SRC]H5system.c */
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  * These macros check whether debugging has been requested for a certain
01490  * package at run-time.  Code for debugging is conditionally compiled by
01491  * defining constants like `H5X_DEBUG'.  In order to see the output though
01492  * the code must be enabled at run-time with an environment variable
01493  * HDF5_DEBUG which is a list of packages to debug.
01494  *
01495  * Note:  If you add/remove items from this enum then be sure to update the
01496  *        information about the package in H5_init_library().
01497  */
01498 typedef enum {
01499     H5_PKG_A,                           /*Attributes                    */
01500     H5_PKG_AC,                          /*Meta data cache               */
01501     H5_PKG_B,                           /*B-trees                       */
01502     H5_PKG_D,                           /*Datasets                      */
01503     H5_PKG_E,                           /*Error handling                */
01504     H5_PKG_F,                           /*Files                         */
01505     H5_PKG_G,                           /*Groups                        */
01506     H5_PKG_HG,                          /*Global heap                   */
01507     H5_PKG_HL,                          /*Local heap                    */
01508     H5_PKG_I,                           /*Interface                     */
01509     H5_PKG_MF,                          /*File memory management        */
01510     H5_PKG_MM,                          /*Core memory management        */
01511     H5_PKG_O,                           /*Object headers                */
01512     H5_PKG_P,                           /*Property lists                */
01513     H5_PKG_S,                           /*Data spaces                   */
01514     H5_PKG_T,                           /*Data types                    */
01515     H5_PKG_V,                           /*Vector functions              */
01516     H5_PKG_Z,                           /*Raw data filters              */
01517     H5_NPKGS                            /*Must be last                  */
01518 } H5_pkg_t;
01519 
01520 typedef struct H5_debug_t {
01521     FILE                *trace;         /*API trace output stream       */
01522     hbool_t             ttop;           /*Show only top-level calls?    */
01523     hbool_t             ttimes;         /*Show trace event times?       */
01524     struct {
01525         const char      *name;          /*package name                  */
01526         FILE            *stream;        /*output stream or NULL         */
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  * Purpose:     These macros are inserted automatically just after the
01535  *              FUNC_ENTER() macro of API functions and are used to trace
01536  *              application program execution. Unless H5_DEBUG_API has been
01537  *              defined they are no-ops.
01538  *
01539  * Arguments:   R       - Return type encoded as a string
01540  *              T       - Argument types encoded as a string
01541  *              A0-An   - Arguments.  The number at the end of the macro name
01542  *                        indicates the number of arguments.
01543  *
01544  * Programmer:  Robb Matzke
01545  *
01546  * Modifications:
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                                    /*void*/
01590 #define H5TRACE0(R,T)                                   /*void*/
01591 #define H5TRACE1(R,T,A0)                                /*void*/
01592 #define H5TRACE2(R,T,A0,A1)                             /*void*/
01593 #define H5TRACE3(R,T,A0,A1,A2)                          /*void*/
01594 #define H5TRACE4(R,T,A0,A1,A2,A3)                       /*void*/
01595 #define H5TRACE5(R,T,A0,A1,A2,A3,A4)                    /*void*/
01596 #define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5)                 /*void*/
01597 #define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6)              /*void*/
01598 #define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7)           /*void*/
01599 #define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8)        /*void*/
01600 #define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9)    /*void*/
01601 #define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) /*void*/
01602 #define H5TRACE_RETURN(V)                               /*void*/
01603 #endif
01604 
01605 H5_DLL double H5_trace(const double *calltime, const char *func, const char *type, ...);
01606 
01607 
01608 /*-------------------------------------------------------------------------
01609  * Purpose:     Register function entry for library initialization and code
01610  *              profiling.
01611  *
01612  * Notes:       Every file must have a file-scope variable called
01613  *              `initialize_interface_g' of type hbool_t which is initialized
01614  *              to FALSE.
01615  *
01616  *              Don't use local variable initializers which contain
01617  *              calls to other library functions since the initializer
01618  *              would happen before the FUNC_ENTER() gets called.  Don't
01619  *              use initializers that require special cleanup code to
01620  *              execute if FUNC_ENTER() fails since a failing FUNC_ENTER()
01621  *              returns immediately without branching to the `done' label.
01622  *
01623  * Programmer:  Quincey Koziol
01624  *
01625  * Modifications:
01626  *
01627  *-------------------------------------------------------------------------
01628  */
01629 
01630 /* `S' is the name of a function which is being tested to check if its */
01631 /*      an API function */
01632 #define H5_IS_API(S) ('_'!=S[2] && '_'!=S[3] && (!S[4] || '_'!=S[4]))
01633 
01634 /* global library version information string */
01635 extern char     H5_lib_vers_info_g[];
01636 
01637 /* Lock headers */
01638 #ifdef H5_HAVE_THREADSAFE
01639 
01640 /* Include required thread-safety header */
01641 #include "H5TSprivate.h"
01642 
01643 /* replacement structure for original global variable */
01644 typedef struct H5_api_struct {
01645     H5TS_mutex_t init_lock;  /* API entrance mutex */
01646     hbool_t H5_libinit_g;    /* Has the library been initialized? */
01647 } H5_api_t;
01648 
01649 /* Macros for accessing the global variables */
01650 #define H5_INIT_GLOBAL H5_g.H5_libinit_g
01651 
01652 /* Macro for first thread initialization */
01653 #define H5_FIRST_THREAD_INIT                                                  \
01654    pthread_once(&H5TS_first_init_g, H5TS_first_thread_init);
01655 
01656 /* Macros for threadsafe HDF-5 Phase I locks */
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 /* Macros for thread cancellation-safe mechanism */
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 /* H5_HAVE_THREADSAFE */
01672 
01673 /* disable any first thread init mechanism */
01674 #define H5_FIRST_THREAD_INIT
01675 
01676 /* disable locks (sequential version) */
01677 #define H5_API_LOCK
01678 #define H5_API_UNLOCK
01679 
01680 /* disable cancelability (sequential version) */
01681 #define H5_API_UNSET_CANCEL
01682 #define H5_API_SET_CANCEL
01683 
01684 /* extern global variables */
01685 extern hbool_t H5_libinit_g;    /* Has the library been initialized? */
01686 
01687 /* Macros for accessing the global variables */
01688 #define H5_INIT_GLOBAL H5_libinit_g
01689 
01690 #endif /* H5_HAVE_THREADSAFE */
01691 
01692 #ifdef H5_HAVE_CODESTACK
01693 
01694 /* Include required function stack header */
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 /* H5_HAVE_CODESTACK */
01700 #define H5_PUSH_FUNC(func_name) /* void */
01701 #define H5_POP_FUNC             /* void */
01702 #endif /* H5_HAVE_CODESTACK */
01703 
01704 #ifdef H5_HAVE_MPE
01705 extern hbool_t H5_MPEinit_g;   /* Has the MPE Library been initialized? */
01706 #endif
01707 
01708 /* Check if the function name is correct (if the compiler supports __FUNCTION__) */
01709 #ifdef H5_HAVE_FUNCTION
01710 #define H5_CHECK_FUNCNAME(func_name) \
01711     assert(!HDstrcmp(#func_name, __FUNCTION__))
01712 #else /* H5_HAVE_FUNCTION */
01713 #define H5_CHECK_FUNCNAME(func_name) \
01714     assert(func_name)
01715 #endif /* H5_HAVE_FUNCTION */
01716 
01717 /* Macros for defining interface initialization routines */
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    /* Initialize this interface or bust */                                    \
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 /* H5_INTERFACE_INIT_FUNC */
01732 #define H5_INTERFACE_INIT(err)
01733 #endif /* H5_INTERFACE_INIT_FUNC */
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         /* Check API status */                                                \
01742         HDassert(asrt);                                                       \
01743                                                                               \
01744         /* Check function name */                                             \
01745         H5_CHECK_FUNCNAME(func_name);                                         \
01746                                                                               \
01747         /* Don't check again */                                               \
01748         func_check = TRUE;                                                    \
01749     } /* end if */
01750 #else /* NDEBUG */
01751 #define FUNC_ENTER_COMMON_NOFUNC(func_name,asrt)
01752 #endif /* NDEBUG */
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 /* Threadsafety initialization code for API routines */
01764 #define FUNC_ENTER_API_THREADSAFE                                             \
01765    /* Initialize the thread-safe code */                                      \
01766    H5_FIRST_THREAD_INIT                                                       \
01767                                                                               \
01768    /* Grab the mutex for the library */                                       \
01769    H5_API_UNSET_CANCEL                                                        \
01770    H5_API_LOCK
01771 
01772 /* Local variables for API routines */
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    /* Initialize the library */                                               \
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    /* Initialize the interface, if appropriate */                             \
01792    H5_INTERFACE_INIT(err)                                                     \
01793                                                                               \
01794    /* Push the name of this function on the function stack */                 \
01795    H5_PUSH_FUNC(#func_name)                                                   \
01796                                                                               \
01797    BEGIN_MPE_LOG(func_name)
01798 
01799 /* Use this macro for all "normal" API functions */
01800 #define FUNC_ENTER_API(func_name,err) {{                                      \
01801     FUNC_ENTER_API_COMMON(func_name)                                          \
01802     FUNC_ENTER_API_INIT(func_name,err);                                       \
01803     /* Clear thread error stack entering public functions */                  \
01804     H5E_clear_stack(NULL);                                                    \
01805     {
01806 
01807 /*
01808  * Use this macro for API functions that shouldn't clear the error stack
01809  *      like H5Eprint and H5Ewalk.
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  * Use this macro for API functions that shouldn't perform _any_ initialization
01818  *      of the library or an interface, just perform tracing, etc.  Examples
01819  *      are: H5check_version, etc.
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  * Use this macro for API functions that shouldn't perform _any_ initialization
01830  *      of the library or an interface or push themselves on the function
01831  *      stack, just perform tracing, etc.  Examples
01832  *      are: H5close, H5check_version, etc.
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 /* Note: this macro only works when there's _no_ interface initialization routine for the module */
01843 #define FUNC_ENTER_NOAPI_INIT(func_name,err)                                  \
01844    /* Initialize the interface, if appropriate */                             \
01845    H5_INTERFACE_INIT(err)                                                     \
01846                                                                               \
01847    /* Push the name of this function on the function stack */                 \
01848    H5_PUSH_FUNC(#func_name)
01849 
01850 /* Use this macro for all "normal" non-API functions */
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 /* Use this macro for all non-API functions, which propagate errors, but don't issue them */
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 /* Use this macro for all non-API functions which don't issue errors */
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  * Use this macro for non-API functions which fall into these categories:
01870  *      - static functions, since they must be called from a function in the
01871  *              interface, the library and interface must already be
01872  *              initialized.
01873  *      - functions which are called during library shutdown, since we don't
01874  *              want to re-initialize the library.
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  * Use this macro for non-API functions which fall into these categories:
01883  *      - static functions, since they must be called from a function in the
01884  *              interface, the library and interface must already be
01885  *              initialized.
01886  *      - functions which are called during library shutdown, since we don't
01887  *              want to re-initialize the library.
01888  *      - functions that propagate, but don't issue errors
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  * Use this macro for non-API functions which fall into these categories:
01897  *      - static functions, since they must be called from a function in the
01898  *              interface, the library and interface must already be
01899  *              initialized.
01900  *      - functions which are called during library shutdown, since we don't
01901  *              want to re-initialize the library.
01902  *
01903  * This macro is used for functions which fit the above categories _and_
01904  * also don't use the 'FUNC' variable (i.e. don't push errors on the error stack)
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  * Use this macro for non-API functions which fall into these categories:
01914  *      - functions which shouldn't push their name on the function stack
01915  *              (so far, just the H5CS routines themselves)
01916  *
01917  * This macro is used for functions which fit the above categories _and_
01918  * also don't use the 'FUNC' variable (i.e. don't push errors on the error stack)
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  * Purpose:     Register function exit for code profiling.  This should be
01927  *              the last statement executed by a function.
01928  *
01929  * Programmer:  Quincey Koziol
01930  *
01931  *-------------------------------------------------------------------------
01932  */
01933 /* Threadsafety termination code for API routines */
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     } /*end scope from end of FUNC_ENTER*/                                    \
01947 }} /*end scope from beginning of FUNC_ENTER*/
01948 
01949 /* Use this macro to match the FUNC_ENTER_API_NOFS macro */
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     } /*end scope from end of FUNC_ENTER*/                                    \
01956 }} /*end scope from beginning of FUNC_ENTER*/
01957 
01958 #define FUNC_LEAVE_NOAPI(ret_value)                                           \
01959         H5_POP_FUNC                                                           \
01960         return(ret_value);                                                    \
01961     } /*end scope from end of FUNC_ENTER*/                                    \
01962 } /*end scope from beginning of FUNC_ENTER*/
01963 
01964 #define FUNC_LEAVE_NOAPI_VOID                                                 \
01965         H5_POP_FUNC                                                           \
01966         return;                                                               \
01967     } /*end scope from end of FUNC_ENTER*/                                    \
01968 } /*end scope from beginning of FUNC_ENTER*/
01969 
01970 /*
01971  * Use this macro for non-API functions which fall into these categories:
01972  *      - functions which didn't push their name on the function stack
01973  *              (so far, just the H5CS routines themselves)
01974  */
01975 #define FUNC_LEAVE_NOAPI_NOFS(ret_value)                                      \
01976         return(ret_value);                                                    \
01977     } /*end scope from end of FUNC_ENTER*/                                    \
01978 } /*end scope from beginning of FUNC_ENTER*/
01979 
01980 
01981 /* Macro for "glueing" together items, for re-scanning macros */
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 /* Compile-time "assert" macro */
01987 #define HDcompile_assert(e)     do { enum { compile_assert__ = 1 / (e) }; } while(0)
01988 
01989 /* Private functions, not part of the publicly documented API */
01990 H5_DLL herr_t H5_init_library(void);
01991 H5_DLL void H5_term_library(void);
01992 
01993 /* Functions to terminate interfaces */
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 /* Checksum functions */
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 /* Functions for building paths, etc. */
02017 H5_DLL herr_t   H5_build_extpath(const char *, char ** /*out*/ );
02018 
02019 /* Functions for debugging */
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 /* _H5private_H */
02024