diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5.c | 65 | ||||
-rw-r--r-- | src/H5Fpublic.h | 16 | ||||
-rw-r--r-- | src/H5O.c | 46 | ||||
-rw-r--r-- | src/H5Oprivate.h | 1 | ||||
-rw-r--r-- | src/H5T.c | 6 | ||||
-rw-r--r-- | src/H5private.h | 6 | ||||
-rw-r--r-- | src/H5public.h | 11 |
7 files changed, 128 insertions, 23 deletions
@@ -312,13 +312,58 @@ H5version(unsigned *majnum, unsigned *minnum, unsigned *relnum, FUNC_ENTER(H5version, FAIL); /* Set the version information */ - if (majnum) *majnum = HDF5_MAJOR_VERSION; - if (minnum) *minnum = HDF5_MINOR_VERSION; - if (relnum) *relnum = HDF5_RELEASE_VERSION; - if (patnum) *patnum = HDF5_PATCH_VERSION; + if (majnum) *majnum = H5_VERS_MAJOR; + if (minnum) *minnum = H5_VERS_MINOR; + if (relnum) *relnum = H5_VERS_RELEASE; + if (patnum) *patnum = H5_VERS_PATCH; FUNC_LEAVE(ret_value); } + + +/*------------------------------------------------------------------------- + * Function: H5vers_check + * + * Purpose: Verifies that the arguments match the version numbers + * compiled into the library. This function is intended to be + * called from user to verify that the versions of header files + * compiled into the application match the version of the hdf5 + * library. + * + * Return: Success: SUCCEED + * + * Failure: abort() + * + * Programmer: Robb Matzke + * Tuesday, April 21, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5vers_check (unsigned majnum, unsigned minnum, unsigned relnum, + unsigned patnum) +{ + /* Don't initialize the library quite yet */ + + if (H5_VERS_MAJOR!=majnum || H5_VERS_MINOR!=minnum || + H5_VERS_RELEASE!=relnum || H5_VERS_PATCH!=patnum) { + fputs ("Warning! The HDF5 header files included by this application " + "do not match the\nversion used by the HDF5 library to which " + "this application is linked. Data\ncorruption or segmentation " + "faults would be likely if the application were\nallowed to " + "continue.\n", stderr); + fprintf (stderr, "Headers are %u.%u.%u%c, library is %u.%u.%u%c\n", + majnum, minnum, relnum, 'a'+patnum, + H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, + 'a'+H5_VERS_PATCH); + fputs ("Bye...\n", stderr); + abort (); + } + return SUCCEED; +} + /*------------------------------------------------------------------------- * Function: H5open @@ -792,8 +837,10 @@ H5_timer_begin (H5_timer_t *timer) #ifdef HAVE_GETRUSAGE getrusage (RUSAGE_SELF, &rusage); - timer->utime = rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec/1e6; - timer->stime = rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec/1e6; + timer->utime = (double)rusage.ru_utime.tv_sec + + (double)rusage.ru_utime.tv_usec/1e6; + timer->stime = (double)rusage.ru_stime.tv_sec + + (double)rusage.ru_stime.tv_usec/1e6; #else timer->utime = 0.0; timer->stime = 0.0; @@ -830,9 +877,9 @@ H5_timer_end (H5_timer_t *sum/*in,out*/, H5_timer_t *timer/*in,out*/) assert (timer); H5_timer_begin (&now); - timer->utime = now.utime - timer->utime; - timer->stime = now.stime - timer->stime; - timer->etime = now.etime - timer->etime; + timer->utime = MAX(0.0, now.utime - timer->utime); + timer->stime = MAX(0.0, now.stime - timer->stime); + timer->etime = MAX(0.0, now.etime - timer->etime); if (sum) { sum->utime += timer->utime; diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index cfce784..2f79a6e 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -23,13 +23,17 @@ /* * These are the bits that can be passed to the `flags' argument of * H5Fcreate() and H5Fopen(). Use the bit-wise OR operator (|) to combine - * them as needed. + * them as needed. As a side effect, they call H5vers_check() to make sure + * that the application is compiled with a version of the hdf5 header files + * which are compatible with the library to which the application is linked. + * We're assuming that these constants are used rather early in the hdf5 + * session. */ -#define H5F_ACC_RDONLY 0x0000u /*absence of write implies read only */ -#define H5F_ACC_RDWR 0x0001u /*open file for reading and writing */ -#define H5F_ACC_TRUNC 0x0002u /*overwrite existing files during create*/ -#define H5F_ACC_EXCL 0x0004u /*create fails if file already exists */ -#define H5F_ACC_DEBUG 0x0008u /*print debug info */ +#define H5F_ACC_RDONLY (H5check(),0x0000u) /*absence of rdwr => rd-only */ +#define H5F_ACC_RDWR (H5check(),0x0001u) /*open for read and write */ +#define H5F_ACC_TRUNC (H5check(),0x0002u) /*overwrite existing files */ +#define H5F_ACC_EXCL (H5check(),0x0004u) /*fail if file already exists*/ +#define H5F_ACC_DEBUG (H5check(),0x0008u) /*print debug info */ #ifdef LATER @@ -732,6 +732,52 @@ H5O_link(H5G_entry_t *ent, intn adjust) /*------------------------------------------------------------------------- + * Function: H5O_count + * + * Purpose: Counts the number of messages in an object header which are a + * certain type. + * + * Return: Success: Number of messages of specified type. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, April 21, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +intn +H5O_count (H5G_entry_t *ent, const H5O_class_t *type) +{ + H5O_t *oh = NULL; + intn i, acc; + + FUNC_ENTER (H5O_count, FAIL); + + /* Check args */ + assert (ent); + assert (ent->file); + assert (H5F_addr_defined (&(ent->header))); + assert (type); + + /* Load the object header */ + if (NULL==(oh=H5AC_find (ent->file, H5AC_OHDR, &(ent->header), + NULL, NULL))) { + HRETURN_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL, + "unable to load object header"); + } + + for (i=acc=0; i<oh->nmesgs; i++) { + if (oh->mesg[i].type==type) acc++; + } + + FUNC_LEAVE (acc); +} + + +/*------------------------------------------------------------------------- * Function: H5O_read * * Purpose: Reads a message from an object header and returns a pointer diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index d3836f4..bd4503e 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -232,6 +232,7 @@ herr_t H5O_create (H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/); herr_t H5O_open (H5G_entry_t *ent); herr_t H5O_close (H5G_entry_t *ent); intn H5O_link (H5G_entry_t *ent, intn adjust); +intn H5O_count (H5G_entry_t *ent, const H5O_class_t *type); void *H5O_read (H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg); intn H5O_modify (H5G_entry_t *ent, const H5O_class_t *type, intn overwrite, @@ -3600,9 +3600,10 @@ H5T_timer_begin (H5_timer_t *timer, H5T_cdata_t *cdata) { assert (timer); assert (cdata); +#ifdef H5T_DEBUG assert (cdata->stats); - H5_timer_begin (timer); +#endif } @@ -3625,11 +3626,12 @@ H5T_timer_end (H5_timer_t *timer, H5T_cdata_t *cdata, size_t nelmts) { assert (timer); assert (cdata); +#ifdef H5T_DEBUG assert (cdata->stats); - H5_timer_end (&(cdata->stats->timer), timer); cdata->stats->ncalls++; cdata->stats->nelmts += nelmts; +#endif } diff --git a/src/H5private.h b/src/H5private.h index 328f907..3d3ca3d 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -21,12 +21,6 @@ #define _H5private_H #include <H5public.h> /* Include Public Definitions */ -/* Version #'s of library code */ -#define HDF5_MAJOR_VERSION 1 /* For major interface changes */ -#define HDF5_MINOR_VERSION 0 /* For minor interface changes */ -#define HDF5_RELEASE_VERSION 1 /* For interface tweaks & bug-fixes */ -#define HDF5_PATCH_VERSION 0 /* For small groups of bug fixes */ - /* Version #'s of the major components of the file format */ #define HDF5_BOOTBLOCK_VERSION 0 /* of the boot block format */ #define HDF5_FREESPACE_VERSION 0 /* of the Free-Space Info */ diff --git a/src/H5public.h b/src/H5public.h index fbf96eb..81bbe17 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -23,6 +23,15 @@ # include <mpio.h> #endif +/* Version numbers */ +#define H5_VERS_MAJOR 1 /* For major interface changes */ +#define H5_VERS_MINOR 0 /* For minor interface changes */ +#define H5_VERS_RELEASE 2 /* For interface tweaks & bug-fixes */ +#define H5_VERS_PATCH 0 /* For small groups of bug fixes */ + +#define H5check() H5vers_check(H5_VERS_MAJOR,H5_VERS_MINOR,\ + H5_VERS_RELEASE, H5_VERS_PATCH) + /* * Status return values. Failed integer functions in HDF5 result almost * always in a negative value (unsigned failing functions sometimes return @@ -64,6 +73,8 @@ herr_t H5close (void); herr_t H5dont_atexit (void); herr_t H5version (unsigned *majnum, unsigned *minnum, unsigned *relnum, unsigned *patnum); +herr_t H5vers_check (unsigned majnum, unsigned minnum, unsigned relnum, + unsigned patnum); #ifdef __cplusplus } |