From fe70476a225d2e0576149e0f1bdf95689f922c77 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Tue, 3 Oct 2017 14:57:36 -0500 Subject: Initial checkin for library version bounds Code changes to provide versioning support when adding to the enumerated defines for H5F_libver_t. --- src/H5Aint.c | 42 +- src/H5Dint.c | 77 +- src/H5Dlayout.c | 35 +- src/H5F.c | 26 +- src/H5Fint.c | 52 +- src/H5Fpkg.h | 3 +- src/H5Fprivate.h | 28 +- src/H5Fpublic.h | 11 +- src/H5Fquery.c | 78 +- src/H5Fsuper.c | 46 +- src/H5Gobj.c | 19 +- src/H5HFhdr.c | 8 +- src/H5O.c | 82 +- src/H5Ofill.c | 33 +- src/H5Opkg.h | 5 +- src/H5Opline.c | 31 +- src/H5Oprivate.h | 4 +- src/H5Pfapl.c | 178 +++- src/H5S.c | 34 +- src/H5Sprivate.h | 2 +- src/H5T.c | 34 +- src/H5Tcommit.c | 28 +- src/H5Tprivate.h | 2 +- src/H5trace.c | 6 + test/genall5.c | 127 ++- test/mf.c | 2 + test/testfiles/plist_files/def_fapl_32be | Bin 1520 -> 1697 bytes test/testfiles/plist_files/def_fapl_32le | Bin 1520 -> 1697 bytes test/testfiles/plist_files/def_fapl_64be | Bin 1520 -> 1697 bytes test/testfiles/plist_files/def_fapl_64le | Bin 1520 -> 1697 bytes test/testfiles/plist_files/fapl_32be | Bin 1522 -> 1699 bytes test/testfiles/plist_files/fapl_32le | Bin 1522 -> 1699 bytes test/testfiles/plist_files/fapl_64be | Bin 1522 -> 1699 bytes test/testfiles/plist_files/fapl_64le | Bin 1522 -> 1699 bytes test/testfiles/plist_files/lapl_32be | Bin 1625 -> 1802 bytes test/testfiles/plist_files/lapl_32le | Bin 1625 -> 1802 bytes test/testfiles/plist_files/lapl_64be | Bin 1625 -> 1802 bytes test/testfiles/plist_files/lapl_64le | Bin 1625 -> 1802 bytes test/tfile.c | 1534 +++++++++++++++++++++++++++++- 39 files changed, 2163 insertions(+), 364 deletions(-) diff --git a/src/H5Aint.c b/src/H5Aint.c index 160c7fb..bfc69ec 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -112,6 +112,13 @@ static herr_t H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type /* Local Variables */ /*******************/ +/* Format version bounds for attribute */ +static const unsigned H5O_attr_ver_bounds[] = { + H5O_ATTR_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_ATTR_VERSION_3, /* H5F_LIBVER_V18 */ + H5O_ATTR_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; + typedef H5A_t* H5A_t_ptr; H5FL_SEQ_DEFINE(H5A_t_ptr); @@ -210,17 +217,15 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") /* Set the latest format for datatype, if requested */ - if(H5F_USE_LATEST_FLAGS(loc->oloc->file, H5F_LATEST_DATATYPE)) - if(H5T_set_latest_version(attr->shared->dt) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of datatype") + if(H5T_set_version(loc->oloc->file, attr->shared->dt) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set version of datatype") /* Copy the dataspace for the attribute */ attr->shared->ds = H5S_copy(space, FALSE, TRUE); - /* Set the latest format for dataspace, if requested */ - if(H5F_USE_LATEST_FLAGS(loc->oloc->file, H5F_LATEST_DATASPACE)) - if(H5S_set_latest_version(attr->shared->ds) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of dataspace") + /* Set the version for dataspace */ + if(H5S_set_version(loc->oloc->file, attr->shared->ds) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set version of dataspace") /* Copy the object header information */ if(H5O_loc_copy(&(attr->oloc), loc->oloc, H5_COPY_DEEP) < 0) @@ -1840,11 +1845,11 @@ done: * Function: H5A_set_version * * Purpose: Sets the correct version to encode attribute with. - * Chooses the oldest version possible, unless the "use the - * latest format" flag is set. + * Chooses the oldest version possible, unless the + * file's low bound indicates otherwise. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * * Programmer: Quincey Koziol * koziol@hdfgroup.org @@ -1857,7 +1862,7 @@ H5A_set_version(const H5F_t *f, H5A_t *attr) { hbool_t type_shared, space_shared; /* Flags to indicate that shared messages are used for this attribute */ hbool_t use_latest_format; /* Flag indicating the latest attribute version support is enabled */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1865,9 +1870,6 @@ H5A_set_version(const H5F_t *f, H5A_t *attr) HDassert(f); HDassert(attr); - /* Get the file's 'use the latest attribute version support' flag */ - use_latest_format = H5F_USE_LATEST_FLAGS(f, H5F_LATEST_ATTRIBUTE); - /* Check whether datatype and dataspace are shared */ if(H5O_msg_is_shared(H5O_DTYPE_ID, attr->shared->dt) > 0) type_shared = TRUE; @@ -1880,15 +1882,19 @@ H5A_set_version(const H5F_t *f, H5A_t *attr) space_shared = FALSE; /* Check which version to encode attribute with */ - if(use_latest_format) - attr->shared->version = H5O_ATTR_VERSION_LATEST; /* Write out latest attribute version */ - else if(attr->shared->encoding != H5T_CSET_ASCII) + if(attr->shared->encoding != H5T_CSET_ASCII) attr->shared->version = H5O_ATTR_VERSION_3; /* Write version which includes the character encoding */ else if(type_shared || space_shared) attr->shared->version = H5O_ATTR_VERSION_2; /* Write out version with flag for indicating shared datatype or dataspace */ else attr->shared->version = H5O_ATTR_VERSION_1; /* Write out basic version */ + /* Upgrade to the version indicated by the file's low bound if higher */ + attr->shared->version = MAX(attr->shared->version, (uint8_t)H5O_attr_ver_bounds[H5F_LOW_BOUND(f)]); + + /* File bound check */ + if(attr->shared->version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(f)]) + HGOTO_ERROR(H5E_ATTR, H5E_BADRANGE, FAIL, "attribute version out of bounds") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_set_version() */ diff --git a/src/H5Dint.c b/src/H5Dint.c index bdedd1e..9ed7d71 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -639,13 +639,13 @@ done: * Function: H5D__init_type * * Purpose: Copy a datatype for a dataset's use, performing all the - * necessary adjustments, etc. + * necessary adjustments, etc. * * Return: Success: SUCCEED - * Failure: FAIL + * Failure: FAIL * * Programmer: Quincey Koziol - * Thursday, June 24, 2004 + * Thursday, June 24, 2004 * *------------------------------------------------------------------------- */ @@ -654,7 +654,7 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) { htri_t relocatable; /* Flag whether the type is relocatable */ htri_t immutable; /* Flag whether the type is immutable */ - hbool_t use_latest_format; /* Flag indicating the 'latest datatype version support' is enabled */ + hbool_t use_v18_latest_format; /* Flag indicating the 'latest datatype version support' is enabled */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -672,17 +672,16 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) if((immutable = H5T_is_immutable(type)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't check datatype?") - /* Get the file's 'use the latest datatype version support' flag */ - use_latest_format = H5F_USE_LATEST_FLAGS(file, H5F_LATEST_DATATYPE); + use_v18_latest_format = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18); /* Copy the datatype if it's a custom datatype or if it'll change when it's location is changed */ - if(!immutable || relocatable || use_latest_format) { + if(!immutable || relocatable || use_v18_latest_format) { /* Copy datatype for dataset */ if((dset->shared->type = H5T_copy(type, H5T_COPY_ALL)) == NULL) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy datatype") - /* Convert a datatype (if committed) to a transient type if the committed datatype's file - location is different from the file location where the dataset will be created */ + /* Convert a datatype (if committed) to a transient type if the committed datatype's file + location is different from the file location where the dataset will be created */ if(H5T_convert_committed_datatype(dset->shared->type, file) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't get shared datatype info") @@ -690,14 +689,12 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) if(H5T_set_loc(dset->shared->type, file, H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't set datatype location") - /* Set the latest format, if requested */ - if(use_latest_format) - if(H5T_set_latest_version(dset->shared->type) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of datatype") + if(H5T_set_version(file, dset->shared->type) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set version of datatype") /* Get a datatype ID for the dataset's datatype */ - if((dset->shared->type_id = H5I_register(H5I_DATATYPE, dset->shared->type, FALSE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register type") + if((dset->shared->type_id = H5I_register(H5I_DATATYPE, dset->shared->type, FALSE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register type") } /* end if */ /* Not a custom datatype, just use it directly */ else { @@ -775,7 +772,6 @@ done: static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space) { - hbool_t use_latest_format; /* Flag indicating the 'latest dataspace version support' is enabled */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -785,9 +781,6 @@ H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space) HDassert(dset); HDassert(space); - /* Get the file's 'use the latest dataspace version support' flag */ - use_latest_format = H5F_USE_LATEST_FLAGS(file, H5F_LATEST_DATASPACE); - /* Copy dataspace for dataset */ if(NULL == (dset->shared->space = H5S_copy(space, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dataspace") @@ -796,10 +789,9 @@ H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space) if(H5D__cache_dataspace_info(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't cache dataspace info") - /* Set the latest format, if requested */ - if(use_latest_format) - if(H5S_set_latest_version(dset->shared->space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of datatype") + /* Set the version for dataspace */ + if(H5S_set_version(file, dset->shared->space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of datatype") /* Set the dataset's dataspace to 'all' selection */ if(H5S_select_all(dset->shared->space, TRUE) < 0) @@ -926,7 +918,7 @@ H5D__update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) /* If there is valid information for the old fill value struct, add it */ /* (only if we aren't trying to write the 'latest fill message version support') */ - if(fill_prop->buf && !(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_FILL_MSG))) { + if(fill_prop->buf && (H5F_LOW_BOUND(file) < H5F_LIBVER_V18)) { H5O_fill_t old_fill_prop; /* Copy of fill value property, for writing as "old" fill value */ /* Shallow copy the fill value property */ @@ -981,7 +973,7 @@ H5D__update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) /* (If using the latest 'no modification time message' version support, the modification time is part of the object * header and doesn't use a separate message -QAK) */ - if(!(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_NO_MOD_TIME_MSG))) + if(H5F_LOW_BOUND(file) < H5F_LIBVER_V18) if(H5O_touch_oh(file, dxpl_id, oh, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time message") @@ -1215,27 +1207,20 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "compact dataset must have early space allocation") } /* end if */ - /* Set the latest version of the layout, pline & fill messages, if requested */ - if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_DSET_MSG_FLAGS)) { - /* Set the latest version for the I/O pipeline message */ - if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_PLINE_MSG)) - if(H5O_pline_set_latest_version(&new_dset->shared->dcpl_cache.pline) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of I/O filter pipeline") - - /* Set the latest version for the fill message */ - if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_FILL_MSG)) - /* Set the latest version for the fill value message */ - if(H5O_fill_set_latest_version(&new_dset->shared->dcpl_cache.fill) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of fill value") - - /* Set the latest version for the layout message */ - if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_LAYOUT_MSG)) - /* Set the latest version for the layout message */ - if(H5D__layout_set_latest_version(&new_dset->shared->layout, new_dset->shared->space, &new_dset->shared->dcpl_cache) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of layout") - } /* end if */ - else if(new_dset->shared->layout.version >= H5O_LAYOUT_VERSION_4) { - /* Use latest indexing type for layout message version >= 4 */ + /* Set the version for the I/O pipeline message */ + if(H5O_pline_set_version(file, &new_dset->shared->dcpl_cache.pline) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of I/O filter pipeline") + + /* Set the version for the fill message */ + if(H5O_fill_set_version(file, &new_dset->shared->dcpl_cache.fill) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of fill value") + + /* Set the latest version for the layout message */ + if(H5D__layout_set_version(file, &new_dset->shared->layout) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of layout") + + if(new_dset->shared->layout.version >= H5O_LAYOUT_VERSION_4) { + /* Use latest indexing type for layout message version >= 4 */ if(H5D__layout_set_latest_indexing(&new_dset->shared->layout, new_dset->shared->space, &new_dset->shared->dcpl_cache) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest indexing") } /* end if */ diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index ec18e86..08d7929 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -56,6 +56,13 @@ /* Local Variables */ /*******************/ +/* Format version bounds for layout */ +static const unsigned H5O_layout_ver_bounds[] = { + H5O_LAYOUT_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_LAYOUT_VERSION_3, /* H5F_LIBVER_V18 */ + H5O_LAYOUT_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; + /*------------------------------------------------------------------------- @@ -277,11 +284,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__layout_set_latest_version + * Function: H5D__layout_set_version * - * Purpose: Set the encoding for a layout to the latest version. - * Part of the coding in this routine is moved to - * H5D__layout_set_latest_indexing(). + * Purpose: Set the version to encode a layout with. * * Return: Non-negative on success/Negative on failure * @@ -291,35 +296,33 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__layout_set_latest_version(H5O_layout_t *layout, const H5S_t *space, - const H5D_dcpl_cache_t *dcpl_cache) +H5D__layout_set_version(H5F_t *f, H5O_layout_t *layout) { + unsigned vers; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(layout); - HDassert(space); - HDassert(dcpl_cache); + HDassert(f); - /* Set encoding of layout to latest version */ - layout->version = H5O_LAYOUT_VERSION_LATEST; + /* Upgrade to the version indicated by the file's low bound if higher */ + layout->version = MAX(layout->version, H5O_layout_ver_bounds[H5F_LOW_BOUND(f)]); - /* Set the latest indexing type for the layout message */ - if(H5D__layout_set_latest_indexing(layout, space, dcpl_cache) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest indexing type") + /* File bound check */ + if(layout->version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(f)]) + HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "layout version out of bounds") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__layout_set_latest_version() */ +} /* end H5D__layout_set_version() */ /*------------------------------------------------------------------------- * Function: H5D__layout_set_latest_indexing * * Purpose: Set the latest indexing type for a layout message - * This is moved from H5D_layout_set_latest_version(). * * Return: Non-negative on success/Negative on failure * diff --git a/src/H5F.c b/src/H5F.c index 211f1aa..1ee16e1 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -1633,7 +1633,6 @@ H5Fstart_swmr_write(hid_t file_id) if(file->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file superblock version should be at least 3") - HDassert((file->shared->latest_flags | H5F_LATEST_LAYOUT_MSG) > 0); /* Should not be marked for SWMR writing mode already */ if(file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) @@ -1899,9 +1898,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fset_latest_format + * Function: H5Fset_libver_bounds (Internal library use) * - * Purpose: Enable switching the "latest format" flag while a file is open. + * Purpose: Set .... the "latest format" flag while a file is open. * * Return: Non-negative on success/Negative on failure * @@ -1910,33 +1909,28 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fset_latest_format(hid_t file_id, hbool_t latest_format) +H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high) { H5F_t *f; /* File */ - unsigned latest_flags; /* Latest format flags for file */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "ib", file_id, latest_format); + H5TRACE3("e", "iFvFv", file_id, low, high); /* Check args */ if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID") - /* Check if the value is changing */ - latest_flags = H5F_USE_LATEST_FLAGS(f, H5F_LATEST_ALL_FLAGS); - if(latest_format != (H5F_LATEST_ALL_FLAGS == latest_flags)) { - /* Call the flush routine, for this file */ - if(H5F__flush(f, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") + /* Call the flush routine, for this file */ + if(H5F__flush(f, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") - /* Toggle the 'latest format' flag */ - H5F_SET_LATEST_FLAGS(f, latest_format ? H5F_LATEST_ALL_FLAGS : 0); - } /* end if */ + f->shared->low_bound = low; + f->shared->high_bound = high; done: FUNC_LEAVE_API(ret_value) -} /* end H5Fset_latest_format() */ +} /* end H5Fset_libver_bounds() */ /*------------------------------------------------------------------------- diff --git a/src/H5Fint.c b/src/H5Fint.c index 4c5e00e..d145462 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -130,7 +130,6 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ hbool_t driver_prop_copied = FALSE; /* Whether the driver property has been set up */ unsigned efc_size = 0; - hbool_t latest_format = FALSE; /* Always use the latest format? */ hid_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -167,10 +166,10 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't sieve buffer size") if(H5P_set(new_plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' cache size") - if(f->shared->latest_flags > 0) - latest_format = TRUE; - if(H5P_set(new_plist, H5F_ACS_LATEST_FORMAT_NAME, &latest_format) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'latest format' flag") + if(H5P_set(new_plist, H5F_ACS_FORMAT_LOW_BOUND_NAME, &f->shared->low_bound) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'low' bound for library format versions") + if(H5P_set(new_plist, H5F_ACS_FORMAT_HIGH_BOUND_NAME, &f->shared->high_bound) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'high' bound for library format versions") if(H5P_set(new_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &(f->shared->read_attempts)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'read attempts ' flag") if(H5P_set(new_plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) @@ -593,7 +592,6 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t else { H5P_genplist_t *plist; /* Property list */ unsigned efc_size; /* External file cache size */ - hbool_t latest_format; /* Always use the latest format? */ size_t u; /* Local index variable */ HDassert(lf != NULL); @@ -675,13 +673,10 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get garbage collect reference") if(H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get sieve buffer size") - if(H5P_get(plist, H5F_ACS_LATEST_FORMAT_NAME, &latest_format) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'latest format' flag") - /* For latest format or SWMR_WRITE, activate all latest version support */ - if(latest_format) - f->shared->latest_flags |= H5F_LATEST_ALL_FLAGS; - else if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - f->shared->latest_flags |= H5F_LATEST_LAYOUT_MSG; + if(H5P_get(plist, H5F_ACS_FORMAT_LOW_BOUND_NAME, &(f->shared->low_bound)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'low' bound for library format versions") + if(H5P_get(plist, H5F_ACS_FORMAT_HIGH_BOUND_NAME, &(f->shared->high_bound)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'high' bound for library format versions") if(H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &(f->shared->use_mdc_logging)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'use mdc logging' flag") if(H5P_get(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &(f->shared->start_mdc_log_on_access)) < 0) @@ -2787,34 +2782,3 @@ H5F_set_coll_md_read(H5F_t *f, H5P_coll_md_read_flag_t cmr) FUNC_LEAVE_NOAPI_VOID } /* H5F_set_coll_md_read() */ #endif /* H5_HAVE_PARALLEL */ - - -/*------------------------------------------------------------------------- - * Function: H5F_set_latest_flags - * - * Purpose: Set the latest_flags field with a new value. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * 4/26/16 - * - *------------------------------------------------------------------------- - */ -herr_t -H5F_set_latest_flags(H5F_t *f, unsigned flags) -{ - /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Sanity check */ - HDassert(f); - HDassert(f->shared); - HDassert(0 == ((~flags) & H5F_LATEST_ALL_FLAGS)); - - f->shared->latest_flags = flags; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5F_set_latest_flags() */ - diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index d702506..cd6a295 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -300,7 +300,8 @@ struct H5F_file_t { hsize_t threshold; /* Threshold for alignment */ hsize_t alignment; /* Alignment */ unsigned gc_ref; /* Garbage-collect references? */ - unsigned latest_flags; /* The latest version support */ + H5F_libver_t low_bound; /* The 'low' bound of library format versions */ + H5F_libver_t high_bound; /* The 'high' bound of library format versions */ hbool_t store_msg_crt_idx; /* Store creation index for object header messages? */ unsigned ncwfs; /* Num entries on cwfs list */ struct H5HG_heap_t **cwfs; /* Global heap cache */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index eba48de..3f03a96 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -272,6 +272,8 @@ /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5F_MODULE +#define H5F_LOW_BOUND(F) ((F)->shared->low_bound) +#define H5F_HIGH_BOUND(F) ((F)->shared->high_bound) #define H5F_INTENT(F) ((F)->shared->flags) #define H5F_OPEN_NAME(F) ((F)->open_name) #define H5F_ACTUAL_NAME(F) ((F)->actual_name) @@ -329,6 +331,8 @@ #define H5F_FIRST_ALLOC_DEALLOC(F) ((F)->shared->first_alloc_dealloc) #define H5F_EOA_PRE_FSM_FSALLOC(F) ((F)->shared->eoa_pre_fsm_fsalloc) #else /* H5F_MODULE */ +#define H5F_LOW_BOUND(F) (H5F_get_low_bound(F)) +#define H5F_HIGH_BOUND(F) (H5F_get_high_bound(F)) #define H5F_INTENT(F) (H5F_get_intent(F)) #define H5F_OPEN_NAME(F) (H5F_get_open_name(F)) #define H5F_ACTUAL_NAME(F) (H5F_get_actual_name(F)) @@ -372,7 +376,6 @@ #define H5F_SET_GRP_BTREE_SHARED(F, RC) (H5F_set_grp_btree_shared((F), (RC))) #define H5F_USE_TMP_SPACE(F) (H5F_use_tmp_space(F)) #define H5F_IS_TMP_ADDR(F, ADDR) (H5F_is_tmp_addr((F), (ADDR))) -#define H5F_SET_LATEST_FLAGS(F, FL) (H5F_set_latest_flags((F), (FL))) #ifdef H5_HAVE_PARALLEL #define H5F_COLL_MD_READ(F) (H5F_coll_md_read(F)) #endif /* H5_HAVE_PARALLEL */ @@ -481,7 +484,8 @@ #define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ #define H5F_ACS_FAMILY_TO_SEC2_NAME "family_to_sec2" /* Whether to convert family to sec2 driver. (private property only used by h5repart) */ #define H5F_ACS_MULTI_TYPE_NAME "multi_type" /* Data type in multi file driver */ -#define H5F_ACS_LATEST_FORMAT_NAME "latest_format" /* 'Use latest format version' flag */ +#define H5F_ACS_FORMAT_LOW_BOUND_NAME "low_bound" /* 'low' bound of library format versions */ +#define H5F_ACS_FORMAT_HIGH_BOUND_NAME "high_bound" /* 'high' bound of library format versions */ #define H5F_ACS_WANT_POSIX_FD_NAME "want_posix_fd" /* Internal: query the file descriptor from the core VFD, instead of the memory address */ #define H5F_ACS_METADATA_READ_ATTEMPTS_NAME "metadata_read_attempts" /* # of metadata read attempts */ #define H5F_ACS_OBJECT_FLUSH_CB_NAME "object_flush_cb" /* Object flush callback */ @@ -626,23 +630,6 @@ #define H5SM_TABLE_MAGIC "SMTB" /* Shared Message Table */ #define H5SM_LIST_MAGIC "SMLI" /* Shared Message List */ - -/* Latest format will activate the following latest version support */ -/* "latest_flags" in H5F_file_t */ -#define H5F_LATEST_DATATYPE 0x0001 -#define H5F_LATEST_DATASPACE 0x0002 -#define H5F_LATEST_ATTRIBUTE 0x0004 -#define H5F_LATEST_FILL_MSG 0x0008 -#define H5F_LATEST_PLINE_MSG 0x0010 -#define H5F_LATEST_LAYOUT_MSG 0x0020 -#define H5F_LATEST_NO_MOD_TIME_MSG 0x0040 -#define H5F_LATEST_STYLE_GROUP 0x0080 -#define H5F_LATEST_OBJ_HEADER 0x0100 -#define H5F_LATEST_SUPERBLOCK 0x0200 -#define H5F_LATEST_ALL_FLAGS (H5F_LATEST_DATATYPE | H5F_LATEST_DATASPACE | H5F_LATEST_ATTRIBUTE | H5F_LATEST_FILL_MSG | H5F_LATEST_PLINE_MSG | H5F_LATEST_LAYOUT_MSG | H5F_LATEST_NO_MOD_TIME_MSG | H5F_LATEST_STYLE_GROUP | H5F_LATEST_OBJ_HEADER | H5F_LATEST_SUPERBLOCK) - -#define H5F_LATEST_DSET_MSG_FLAGS (H5F_LATEST_FILL_MSG | H5F_LATEST_PLINE_MSG | H5F_LATEST_LAYOUT_MSG) - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -734,6 +721,8 @@ H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed/*out*/); /* Functions than retrieve values from the file struct */ +H5_DLL unsigned H5F_get_low_bound(const H5F_t *f); +H5_DLL unsigned H5F_get_high_bound(const H5F_t *f); H5_DLL unsigned H5F_get_intent(const H5F_t *f); H5_DLL char *H5F_get_open_name(const H5F_t *f); H5_DLL char *H5F_get_actual_name(const H5F_t *f); @@ -784,7 +773,6 @@ H5_DLL struct H5UC_t *H5F_grp_btree_shared(const H5F_t *f); H5_DLL herr_t H5F_set_grp_btree_shared(H5F_t *f, struct H5UC_t *rc); H5_DLL hbool_t H5F_use_tmp_space(const H5F_t *f); H5_DLL hbool_t H5F_is_tmp_addr(const H5F_t *f, haddr_t addr); -H5_DLL herr_t H5F_set_latest_flags(H5F_t *f, unsigned flags); H5_DLL hsize_t H5F_get_alignment(const H5F_t *f); H5_DLL hsize_t H5F_get_threshold(const H5F_t *f); #ifdef H5_HAVE_PARALLEL diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 1594cb2..9364ee2 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -175,10 +175,15 @@ typedef struct H5F_sect_info_t { /* Library's file format versions */ typedef enum H5F_libver_t { - H5F_LIBVER_EARLIEST, /* Use the earliest possible format for storing objects */ - H5F_LIBVER_LATEST /* Use the latest possible format available for storing objects*/ + H5F_LIBVER_ERROR = -1, + H5F_LIBVER_EARLIEST = 0, /* Use the earliest possible format for storing objects */ + H5F_LIBVER_V18 = 1, /* Use the latest v18 format for storing objects */ + H5F_LIBVER_V110 = 2, /* Use the latest v10 format for storing objects */ + H5F_LIBVER_NBOUNDS } H5F_libver_t; +#define H5F_LIBVER_LATEST H5F_LIBVER_V110 + /* File space handling strategy */ typedef enum H5F_fspace_strategy_t { H5F_FSPACE_STRATEGY_FSM_AGGR = 0, /* Mechanisms: free-space managers, aggregators, and virtual file drivers */ @@ -255,7 +260,7 @@ H5_DLL herr_t H5Fstart_swmr_write(hid_t file_id); H5_DLL ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, H5F_sect_info_t *sect_info/*out*/); H5_DLL herr_t H5Fclear_elink_file_cache(hid_t file_id); -H5_DLL herr_t H5Fset_latest_format(hid_t file_id, hbool_t latest_format); +H5_DLL herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high); H5_DLL herr_t H5Fstart_mdc_logging(hid_t file_id); H5_DLL herr_t H5Fstop_mdc_logging(hid_t file_id); H5_DLL herr_t H5Fget_mdc_logging_status(hid_t file_id, diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 41cf4d2..4ba19b0 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -101,6 +101,56 @@ H5F_get_intent(const H5F_t *f) /*------------------------------------------------------------------------- + * Function: H5F_get_low_bound + * + * Purpose: Quick and dirty routine to retrieve the file's low_bound. + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) + * + * Return: low_bound on success/abort on failure (shouldn't fail) + * + * Programmer: Vailin Choi; June 2016 + * + *------------------------------------------------------------------------- + */ +unsigned +H5F_get_low_bound(const H5F_t *f) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + + FUNC_LEAVE_NOAPI(f->shared->low_bound) +} /* end H5F_get_low_bound() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_high_bound + * + * Purpose: Quick and dirty routine to retrieve the file's high_bound. + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) + * + * Return: high_bound on success/abort on failure (shouldn't fail) + * + * Programmer: Vailin Choi; June 2016 + * + *------------------------------------------------------------------------- + */ +unsigned +H5F_get_high_bound(const H5F_t *f) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + + FUNC_LEAVE_NOAPI(f->shared->high_bound) +} /* end H5F_get_high_bound() */ + + +/*------------------------------------------------------------------------- * Function: H5F_get_open_name * * Purpose: Retrieve the name used to open a file. @@ -800,34 +850,6 @@ H5F_gc_ref(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_use_latest_flags - * - * Purpose: Retrieve the 'latest version support' for the file. - * - * Return: Success: Non-negative, the requested 'version support' - * - * Failure: (can't happen) - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Mar 5 2007 - * - *------------------------------------------------------------------------- - */ -unsigned -H5F_use_latest_flags(const H5F_t *f, unsigned fl) -{ - /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - HDassert(f); - HDassert(f->shared); - - FUNC_LEAVE_NOAPI(f->shared->latest_flags & (fl)) -} /* end H5F_use_latest_flags() */ - - -/*------------------------------------------------------------------------- * Function: H5F_get_fc_degree * * Purpose: Retrieve the 'file close degree' for the file. diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 942a7ed..4490f48 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -59,7 +59,6 @@ static herr_t H5F__update_super_ext_driver_msg(H5F_t *f, hid_t dxpl_id); /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -72,6 +71,12 @@ H5FL_DEFINE(H5F_super_t); /* Local Variables */ /*******************/ +/* Format version bounds for superblock */ +static const unsigned HDF5_superblock_ver_bounds[] = { + HDF5_SUPERBLOCK_VERSION_DEF, /* H5F_LIBVER_EARLIEST */ + HDF5_SUPERBLOCK_VERSION_2, /* H5F_LIBVER_V18 */ + HDF5_SUPERBLOCK_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; /*------------------------------------------------------------------------- @@ -405,13 +410,23 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, meta_dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, &udata, rw_flags))) HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "unable to load superblock") - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3) - HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "invalid superblock version for SWMR_WRITE") + /* Upgrade low bound to at least V18 when encountering version 2 superblock */ + if(sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2) + f->shared->low_bound = MAX(H5F_LIBVER_V18, f->shared->low_bound); + + /* Upgrade low bound to at least V110 when encountering version 3 superblock or SWMR_WRITE */ + if((sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) || (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE)) + f->shared->low_bound = MAX(H5F_LIBVER_V110, f->shared->low_bound); + + /* File bound check */ + if(sblock->super_vers > HDF5_superblock_ver_bounds[f->shared->high_bound]) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version out of bounds (high bound)") - /* Enable all latest version support when file has v3 superblock */ - if(sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) - f->shared->latest_flags |= H5F_LATEST_ALL_FLAGS; + /* SWMR requires at least superblock version 3 */ + if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { + if(sblock->super_vers < HDF5_superblock_ver_bounds[f->shared->low_bound]) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version out of bounds (low bound)") + } /* Pin the superblock in the cache */ if(H5AC_pin_protected_entry(sblock) < 0) @@ -971,14 +986,12 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) non_default_fs_settings = TRUE; - /* Bump superblock version if latest superblock version support is enabled */ - if(H5F_USE_LATEST_FLAGS(f, H5F_LATEST_SUPERBLOCK)) - super_vers = HDF5_SUPERBLOCK_VERSION_LATEST; - /* Bump superblock version to use version 3 superblock for SWMR writing */ - else if((H5F_INTENT(f) & H5F_ACC_SWMR_WRITE)) + if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { super_vers = HDF5_SUPERBLOCK_VERSION_3; + f->shared->low_bound = MAX(H5F_LIBVER_V110, f->shared->low_bound); + /* Bump superblock version to create superblock extension for SOHM info */ - else if(f->shared->sohm_nindexes > 0) + } else if(f->shared->sohm_nindexes > 0) super_vers = HDF5_SUPERBLOCK_VERSION_2; /* * Bump superblock version to create superblock extension for: @@ -996,6 +1009,13 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) else if(sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF) super_vers = HDF5_SUPERBLOCK_VERSION_1; + /* Upgrade to the version indicated by the file's low bound if higher */ + super_vers = MAX(super_vers, HDF5_superblock_ver_bounds[f->shared->low_bound]); + + /* File bound check */ + if(super_vers > HDF5_superblock_ver_bounds[f->shared->high_bound]) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version out of bounds") + /* If a newer superblock version is required, set it here */ if(super_vers != HDF5_SUPERBLOCK_VERSION_DEF) { H5P_genplist_t *c_plist; /* Property list */ diff --git a/src/H5Gobj.c b/src/H5Gobj.c index d2dc83b..832c9a7 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -185,7 +185,7 @@ H5G__obj_create_real(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc/*out*/) { size_t hdr_size; /* Size of object header to request */ - hbool_t use_latest_format; /* Flag indicating the new group format should be used */ + hbool_t use_v18_latest_format; /* Flag indicating the new group format should be used */ hid_t gcpl_id = gcrt_info->gcpl_id; /* Group creation property list ID */ herr_t ret_value = SUCCEED; /* Return value */ @@ -202,24 +202,23 @@ H5G__obj_create_real(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, /* Check for invalid access request */ if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file") + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file") /* Check for using the latest version of the group format */ /* (add more checks for creating "new format" groups when needed) */ - if(H5F_USE_LATEST_FLAGS(f, H5F_LATEST_STYLE_GROUP) || linfo->track_corder - || (pline && pline->nused)) - use_latest_format = TRUE; + if((H5F_LOW_BOUND(f) >= H5F_LIBVER_V18) || linfo->track_corder || (pline && pline->nused)) + use_v18_latest_format = TRUE; else - use_latest_format = FALSE; + use_v18_latest_format = FALSE; /* Make certain that the creation order is being tracked if an index is * going to be built on it. */ if(linfo->index_corder && !linfo->track_corder) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "must track creation order to create index for it") + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "must track creation order to create index for it") /* Check if we should be using the latest version of the group format */ - if(use_latest_format) { + if(use_v18_latest_format) { H5O_link_t lnk; /* Temporary link message info for computing message size */ char null_char = '\0'; /* Character for creating null string */ size_t ginfo_size; /* Size of the group info message */ @@ -262,10 +261,10 @@ H5G__obj_create_real(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, * incremented if the object is added to the group directed graph. */ if(H5O_create(f, dxpl_id, hdr_size, (size_t)1, gcpl_id, oloc/*out*/) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header") + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header") /* Check for format of group to create */ - if(use_latest_format) { + if(use_v18_latest_format) { /* Insert link info message */ /* (Casting away const OK - QAK) */ if(H5O_msg_create(oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, (void *)linfo, dxpl_id) < 0) diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index 2f01ce6..89b3b47 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -424,11 +424,9 @@ H5HF_hdr_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam) if(NULL == H5O_msg_copy(H5O_PLINE_ID, &(cparam->pline), &(hdr->pline))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOPY, HADDR_UNDEF, "can't copy I/O filter pipeline") - /* Pay attention to the latest version flag for the file */ - if(H5F_USE_LATEST_FLAGS(hdr->f, H5F_LATEST_PLINE_MSG)) - /* Set the latest version for the I/O pipeline message */ - if(H5O_pline_set_latest_version(&(hdr->pline)) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, HADDR_UNDEF, "can't set latest version of I/O filter pipeline") + /* Set the version for the I/O pipeline message */ + if(H5O_pline_set_version(hdr->f, &(hdr->pline)) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, HADDR_UNDEF, "can't set version of I/O filter pipeline") /* Compute the I/O filters' encoded size */ if(0 == (hdr->filter_len = (unsigned)H5O_msg_raw_size(hdr->f, H5O_PLINE_ID, FALSE, &(hdr->pline)))) diff --git a/src/H5O.c b/src/H5O.c index 152e6cc..ab5d07b 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -137,6 +137,7 @@ const H5O_msg_class_t *const H5O_msg_class_g[] = { #endif /* H5O_ENABLE_BOGUS */ }; + /* Declare a free list to manage the H5O_t struct */ H5FL_DEFINE(H5O_t); @@ -180,6 +181,12 @@ static const H5O_obj_class_t *const H5O_obj_class_g[] = { H5O_OBJ_GROUP, /* Group object (H5O_TYPE_GROUP - 0) */ }; +/* Format version bounds for object header */ +static const unsigned H5O_obj_ver_bounds[] = { + H5O_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_VERSION_2, /* H5F_LIBVER_V18 */ + H5O_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; /*------------------------------------------------------------------------- @@ -1214,6 +1221,51 @@ done: /*------------------------------------------------------------------------- + * Function: H5O_set_version + * + * Purpose: Sets the correct version to encode the object header. + * Chooses the oldest version possible, unless the file's + * low bound indicates otherwise. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Jul 17 2007 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check arguments */ + HDassert(f); + HDassert(oh); + + /* Set the correct version to encode object header with */ + if(store_msg_crt_idx || (oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) + oh->version = H5O_VERSION_2; + else + oh->version = H5O_VERSION_1; + + /* Upgrade to the version indicated by the file's low bound if higher */ + oh->version = MAX(oh->version, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(f)]); + + /* File bound check */ + if(oh->version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(f)]) + HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "object header version out of bounds") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_set_version() */ + + +/*------------------------------------------------------------------------- * Function: H5O_create * * Purpose: Creates a new object header. Allocates space for it and @@ -1222,10 +1274,10 @@ done: * closed by calling H5O_close(). * * Return: Success: Non-negative, the ENT argument contains - * information about the object header, - * including its address. + * information about the object header, + * including its address. * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * matzke@llnl.gov @@ -1237,14 +1289,14 @@ herr_t H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5O_loc_t *loc/*out*/) { - H5P_genplist_t *oc_plist; /* Object creation property list */ - H5O_t *oh = NULL; /* Object header created */ - haddr_t oh_addr; /* Address of initial object header */ - size_t oh_size; /* Size of initial object header */ - uint8_t oh_flags; /* Object header's initial status flags */ - unsigned insert_flags = H5AC__NO_FLAGS_SET; /* Flags for inserting object header into cache */ - hbool_t store_msg_crt_idx; /* Whether to always store message creation indices for this file */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *oc_plist; /* Object creation property list */ + H5O_t *oh = NULL; /* Object header created */ + haddr_t oh_addr; /* Address of initial object header */ + size_t oh_size; /* Size of initial object header */ + hbool_t store_msg_crt_idx; /* Whether to always store message creation indices for this file */ + uint8_t oh_flags; /* Object header's initial status flags */ + unsigned insert_flags = H5AC__NO_FLAGS_SET; /* Flags for inserting object header into cache */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1274,10 +1326,10 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, size_t initial_rc, /* Initialize file-specific information for object header */ store_msg_crt_idx = H5F_STORE_MSG_CRT_IDX(f); - if(H5F_USE_LATEST_FLAGS(f, H5F_LATEST_OBJ_HEADER) || store_msg_crt_idx || (oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) - oh->version = H5O_VERSION_LATEST; - else - oh->version = H5O_VERSION_1; + + if(H5O_set_version(f, oh, oh_flags, store_msg_crt_idx) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set version of objecdt header") + oh->sizeof_size = H5F_SIZEOF_SIZE(f); oh->sizeof_addr = H5F_SIZEOF_ADDR(f); oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE); diff --git a/src/H5Ofill.c b/src/H5Ofill.c index 5419762..613b521 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -151,6 +151,13 @@ const H5O_msg_class_t H5O_MSG_FILL_NEW[1] = {{ H5O_fill_new_shared_debug /*debug the message */ }}; +/* Format version bounds for fill value */ +static const unsigned H5O_fill_ver_bounds[] = { + H5O_FILL_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_FILL_VERSION_3, /* H5F_LIBVER_V18 */ + H5O_FILL_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; + /* Masks, shift values & flags for fill value message */ #define H5O_FILL_MASK_ALLOC_TIME 0x03 #define H5O_FILL_SHIFT_ALLOC_TIME 0 @@ -997,11 +1004,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5O_fill_set_latest_version + * Function: H5O_fill_set_version * - * Purpose: Set the encoding for a fill value to the latest version. + * Purpose: Set the version to encode a fill value with. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, July 24, 2007 @@ -1009,16 +1016,24 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_fill_set_latest_version(H5O_fill_t *fill) +H5O_fill_set_version(H5F_t *f, H5O_fill_t *fill) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + HDassert(f); HDassert(fill); - /* Set encoding of fill value to latest version */ - fill->version = H5O_FILL_VERSION_LATEST; + /* Upgrade to the version indicated by the file's low bound if higher */ + fill->version = MAX(fill->version, H5O_fill_ver_bounds[H5F_LOW_BOUND(f)]); - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_fill_set_latest_version() */ + /* File bound check */ + if(fill->version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(f)]) + HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "Filter pipeline version out of bounds") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_fill_set_version() */ diff --git a/src/H5Opkg.h b/src/H5Opkg.h index b0c67d1..77d2130 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -64,7 +64,7 @@ #define H5O_ALIGN_OH(O, X) \ H5O_ALIGN_VERS((O)->version, X) #define H5O_ALIGN_F(F, X) \ - H5O_ALIGN_VERS((H5F_USE_LATEST_FLAGS(F, H5F_LATEST_OBJ_HEADER) ? H5O_VERSION_LATEST : H5O_VERSION_1), X) + H5O_ALIGN_VERS(((H5F_LOW_BOUND(F) >= H5F_LIBVER_V18) ? H5O_VERSION_LATEST : H5O_VERSION_1), X) /* Size of checksum (on disk) */ #define H5O_SIZEOF_CHKSUM 4 @@ -136,7 +136,7 @@ #define H5O_SIZEOF_MSGHDR_OH(O) \ H5O_SIZEOF_MSGHDR_VERS((O)->version, (O)->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) #define H5O_SIZEOF_MSGHDR_F(F, C) \ - H5O_SIZEOF_MSGHDR_VERS((H5F_USE_LATEST_FLAGS(F, H5F_LATEST_OBJ_HEADER) || H5F_STORE_MSG_CRT_IDX(F)) ? H5O_VERSION_LATEST : H5O_VERSION_1, (C)) + H5O_SIZEOF_MSGHDR_VERS(((H5F_LOW_BOUND(F) >= H5F_LIBVER_V18) || H5F_STORE_MSG_CRT_IDX(F)) ? H5O_VERSION_LATEST : H5O_VERSION_1, (C)) /* * Size of chunk "header" for each chunk @@ -556,7 +556,6 @@ H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATASET[1]; /* Datatype Object. (H5O_TYPE_NAMED_DATATYPE - 2) */ H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATATYPE[1]; - /* Package-local function prototypes */ H5_DLL herr_t H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg); H5_DLL herr_t H5O_flush_msgs(H5F_t *f, H5O_t *oh); diff --git a/src/H5Opline.c b/src/H5Opline.c index 2e52dbb..c1ff183 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -89,6 +89,12 @@ const H5O_msg_class_t H5O_MSG_PLINE[1] = {{ H5O_pline_shared_debug /* debug the message */ }}; +/* Format version bounds for filter pipleline */ +static const unsigned H5O_pline_ver_bounds[] = { + H5O_PLINE_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_PLINE_VERSION_2, /* H5F_LIBVER_V18 */ + H5O_PLINE_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; /* Declare a free list to manage the H5O_pline_t struct */ H5FL_DEFINE(H5O_pline_t); @@ -664,11 +670,11 @@ H5O_pline_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const voi /*------------------------------------------------------------------------- - * Function: H5O_pline_set_latest_version + * Function: H5O_pline_set_version * - * Purpose: Set the encoding for a I/O filter pipeline to the latest version. + * Purpose: Set the version to encode an I/O filter pipeline with. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, July 24, 2007 @@ -676,16 +682,23 @@ H5O_pline_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const voi *------------------------------------------------------------------------- */ herr_t -H5O_pline_set_latest_version(H5O_pline_t *pline) +H5O_pline_set_version(H5F_t *f, H5O_pline_t *pline) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + HDassert(f); HDassert(pline); - /* Set encoding of I/O pipeline to latest version */ - pline->version = H5O_PLINE_VERSION_LATEST; + /* Upgrade to the version indicated by the file's low bound if higher */ + pline->version = MAX(pline->version, H5O_pline_ver_bounds[H5F_LOW_BOUND(f)]); - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_pline_set_latest_version() */ + /* File bound check */ + if(pline->version > H5O_pline_ver_bounds[H5F_HIGH_BOUND(f)]) + HGOTO_ERROR(H5E_PLINE, H5E_BADRANGE, FAIL, "Filter pipeline version out of bounds") +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_pline_set_version() */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 563f8fa..4d48205 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -961,14 +961,14 @@ H5_DLL hsize_t H5O_efl_total_size(H5O_efl_t *efl); /* Fill value operators */ H5_DLL herr_t H5O_fill_reset_dyn(H5O_fill_t *fill); H5_DLL herr_t H5O_fill_convert(H5O_fill_t *fill, H5T_t *type, hbool_t *fill_changed, hid_t dxpl_id); -H5_DLL herr_t H5O_fill_set_latest_version(H5O_fill_t *fill); +H5_DLL herr_t H5O_fill_set_version(H5F_t * f, H5O_fill_t *fill); /* Link operators */ H5_DLL herr_t H5O_link_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg); /* Filter pipeline operators */ -H5_DLL herr_t H5O_pline_set_latest_version(H5O_pline_t *pline); +H5_DLL herr_t H5O_pline_set_version(H5F_t *f, H5O_pline_t *pline); /* Shared message operators */ H5_DLL herr_t H5O_set_shared(H5O_shared_t *dst, const H5O_shared_t *src); diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 1b0a4b9..a1d53cc 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -142,11 +142,19 @@ #define H5F_ACS_MULTI_TYPE_DEF H5FD_MEM_DEFAULT #define H5F_ACS_MULTI_TYPE_ENC H5P__facc_multi_type_enc #define H5F_ACS_MULTI_TYPE_DEC H5P__facc_multi_type_dec -/* Definition for 'use latest format version' flag */ -#define H5F_ACS_LATEST_FORMAT_SIZE sizeof(hbool_t) -#define H5F_ACS_LATEST_FORMAT_DEF FALSE -#define H5F_ACS_LATEST_FORMAT_ENC H5P__encode_hbool_t -#define H5F_ACS_LATEST_FORMAT_DEC H5P__decode_hbool_t + +/* Definition for "low" bound of library format versions */ +#define H5F_ACS_FORMAT_LOW_BOUND_SIZE sizeof(H5F_libver_t) +#define H5F_ACS_FORMAT_LOW_BOUND_DEF H5F_LIBVER_EARLIEST +#define H5F_ACS_FORMAT_LOW_BOUND_ENC H5P__facc_libver_type_enc +#define H5F_ACS_FORMAT_LOW_BOUND_DEC H5P__facc_libver_type_dec + +/* Definition for "high" bound of library format versions */ +#define H5F_ACS_FORMAT_HIGH_BOUND_SIZE sizeof(H5F_libver_t) +#define H5F_ACS_FORMAT_HIGH_BOUND_DEF H5F_LIBVER_LATEST +#define H5F_ACS_FORMAT_HIGH_BOUND_ENC H5P__facc_libver_type_enc +#define H5F_ACS_FORMAT_HIGH_BOUND_DEC H5P__facc_libver_type_dec + /* Definition for whether to query the file descriptor from the core VFD * instead of the memory address. (Private to library) */ @@ -290,6 +298,8 @@ static herr_t H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t static herr_t H5P__facc_fclose_degree_dec(const void **pp, void *value); static herr_t H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__facc_multi_type_dec(const void **_pp, void *value); +static herr_t H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size); +static herr_t H5P__facc_libver_type_dec(const void **_pp, void *value); /* Metadata cache log location property callbacks */ static herr_t H5P_facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size); @@ -354,7 +364,10 @@ static const hsize_t H5F_def_family_offset_g = H5F_ACS_FAMILY_OFFSET_DEF; static const hsize_t H5F_def_family_newsize_g = H5F_ACS_FAMILY_NEWSIZE_DEF; /* Default size of new files for family VFD */ static const hbool_t H5F_def_family_to_sec2_g = H5F_ACS_FAMILY_TO_SEC2_DEF; /* Default ?? for family VFD */ static const H5FD_mem_t H5F_def_mem_type_g = H5F_ACS_MULTI_TYPE_DEF; /* Default file space type for multi VFD */ -static const hbool_t H5F_def_latest_format_g = H5F_ACS_LATEST_FORMAT_DEF; /* Default setting for "use the latest version of the format" flag */ + +static const H5F_libver_t H5F_def_format_low_bound_g = H5F_ACS_FORMAT_LOW_BOUND_DEF; /* Default setting for "low" bound of format version */ +static const H5F_libver_t H5F_def_format_high_bound_g = H5F_ACS_FORMAT_HIGH_BOUND_DEF; /* Default setting for "high" bound of format version */ + static const hbool_t H5F_def_want_posix_fd_g = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */ static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */ static const H5FD_file_image_info_t H5F_def_file_image_info_g = H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */ @@ -493,9 +506,15 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass) NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the 'use the latest version of the format' flag */ - if(H5P_register_real(pclass, H5F_ACS_LATEST_FORMAT_NAME, H5F_ACS_LATEST_FORMAT_SIZE, &H5F_def_latest_format_g, - NULL, NULL, NULL, H5F_ACS_LATEST_FORMAT_ENC, H5F_ACS_LATEST_FORMAT_DEC, + /* Register the 'low' bound of library format versions */ + if(H5P_register_real(pclass, H5F_ACS_FORMAT_LOW_BOUND_NAME, H5F_ACS_FORMAT_LOW_BOUND_SIZE, &H5F_def_format_low_bound_g, + NULL, NULL, NULL, H5F_ACS_FORMAT_LOW_BOUND_ENC, H5F_ACS_FORMAT_LOW_BOUND_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the 'high' bound of library format versions */ + if(H5P_register_real(pclass, H5F_ACS_FORMAT_HIGH_BOUND_NAME, H5F_ACS_FORMAT_HIGH_BOUND_SIZE, &H5F_def_format_high_bound_g, + NULL, NULL, NULL, H5F_ACS_FORMAT_HIGH_BOUND_ENC, H5F_ACS_FORMAT_HIGH_BOUND_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") @@ -2303,6 +2322,24 @@ done: * releases and then map down to the previous actual library release which * had a format change. * + * Note #3: The enumerated define for H5F_libver_t in 1.10 is: + * typedef enum H5F_libver_t { + * H5F_LIBVER_ERROR = -1, + * H5F_LIBVER_EARLIEST = 0, + * H5F_LIBVER_V18 = 1, + * H5F_LIBVER_V110 = 2, + * H5F_LIBVER_NBOUNDS + * } H5F_libver_t; + * #define H5F_LIBVER_LATEST H5F_LIBVER_V110 + * + * The library supports five pairs of (low, high) combinations via H5Pset_libver_bounds(): + * 1) H5F_LIBVER_EARLIEST, H5F_LIBVER_V18 + * 2) H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST + * 4) H5F_LIBVER_V18, H5F_LIBVER_V18 + * 4) H5F_LIBVER_V18, H5F_LIBVER_LATEST + * 5) H5F_LIBVER_LATEST, H5F_LIBVER_LATEST + * See detailed description in the RFC: Setting Bounds for Object Creation in HDF5 1.10.0. + * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol @@ -2311,32 +2348,38 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, - H5F_libver_t high) +H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, H5F_libver_t high) { H5P_genplist_t *plist; /* Property list pointer */ - hbool_t latest; /* Whether to use the latest version or not */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iFvFv", plist_id, low, high); /* Check args */ - /* (Note that this is _really_ restricted right now, we'll want to loosen - * this up more as we add features - QAK) - */ - if(high != H5F_LIBVER_LATEST) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid high library version bound") + if(low < 0 || low > H5F_LIBVER_LATEST) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "low bound is not valid") + + if(high < 0 || high > H5F_LIBVER_LATEST) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "high bound is not valid") + + /* (earliest, earliest), (latest, earliest), (v18, earliest) are not valid combinations */ + if(high == H5F_LIBVER_EARLIEST) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid (low,high) combination of library version bound") + + /* (latest, v18) is not valid combination */ + if(high < low) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid (low,high) combination of library version bound") /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - latest = (hbool_t)((low == H5F_LIBVER_LATEST) ? TRUE : FALSE); - if(H5P_set(plist, H5F_ACS_LATEST_FORMAT_NAME, &latest) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set library version bounds") - + if(H5P_set(plist, H5F_ACS_FORMAT_LOW_BOUND_NAME, &low) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set low bound for library format versions") + if(H5P_set(plist, H5F_ACS_FORMAT_HIGH_BOUND_NAME, &high) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set high bound for library format versions") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_libver_bounds() */ @@ -2346,7 +2389,7 @@ done: * Function: H5Pget_libver_bounds * * Purpose: Returns the current settings for the library version format bounds - * from a file access property list. + * from a file access property list. * * Return: Non-negative on success/Negative on failure * @@ -2360,7 +2403,6 @@ H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low/*out*/, H5F_libver_t *high/*out*/) { H5P_genplist_t *plist; /* Property list pointer */ - hbool_t latest; /* Whether to use the latest version or not */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) @@ -2369,17 +2411,17 @@ H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low/*out*/, /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Get values */ + if(low) { + if(H5P_get(plist, H5F_ACS_FORMAT_LOW_BOUND_NAME, low) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get low bound for library format versions") + } - /* Get value */ - if(H5P_get(plist, H5F_ACS_LATEST_FORMAT_NAME, &latest) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get library version bounds") - - /* Check for setting values to return */ - /* (Again, this is restricted now, we'll need to open it up later -QAK) */ - if(low) - *low = latest ? H5F_LIBVER_LATEST : H5F_LIBVER_EARLIEST; - if(high) - *high = H5F_LIBVER_LATEST; + if(high) { + if(H5P_get(plist, H5F_ACS_FORMAT_HIGH_BOUND_NAME, high) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get high bound for library format versions") + } done: FUNC_LEAVE_API(ret_value) @@ -3795,6 +3837,76 @@ H5P__facc_multi_type_dec(const void **_pp, void *_value) /*------------------------------------------------------------------------- + * Function: H5P__facc_libver_type_enc + * + * Purpose: Callback routine which is called whenever the 'low' or + * 'high' bound of library format versions property in the + * file access property list is encoded. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size) +{ + const H5F_libver_t *type = (const H5F_libver_t *)value; /* Create local alias for values */ + uint8_t **pp = (uint8_t **)_pp; + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(type); + HDassert(size); + + /* Encode */ + if(NULL != *pp) + *(*pp)++ = (uint8_t)*type; + + /* Size */ + (*size)++; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__facc_libver_type_enc() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_libver_type_dec + * + * Purpose: Callback routine which is called whenever the 'low' or + * 'high' bound of library format versions property in the + * file access property list is decoded. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_libver_type_dec(const void **_pp, void *_value) +{ + H5F_libver_t *type = (H5F_libver_t *)_value; + const uint8_t **pp = (const uint8_t **)_pp; + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(pp); + HDassert(*pp); + HDassert(type); + + /* Decode */ + *type = (H5F_libver_t)*(*pp)++; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__facc_libver_type_dec() */ + +/*------------------------------------------------------------------------- * Function: H5Pset_core_write_tracking * * Purpose: Enables/disables core VFD write tracking and page diff --git a/src/H5S.c b/src/H5S.c index 9ac40a7..01cacf0 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -84,6 +84,13 @@ static const H5I_class_t H5I_DATASPACE_CLS[1] = {{ (H5I_free_t)H5S_close /* Callback routine for closing objects of this class */ }}; +/* Format version bounds for dataspace */ +static const unsigned H5O_sdspace_ver_bounds[] = { + H5O_SDSPACE_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V18 */ + H5O_SDSPACE_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; + /* Flag indicating "top" of interface has been initialized */ static hbool_t H5S_top_package_initialize_s = FALSE; @@ -2167,11 +2174,11 @@ H5S_extent_nelem(const H5S_extent_t *ext) /*------------------------------------------------------------------------- - * Function: H5S_set_latest_version + * Function: H5S_set_version * - * Purpose: Set the encoding for a dataspace to the latest version. + * Purpose: Set the version to encode a dataspace with. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, July 24, 2007 @@ -2179,18 +2186,27 @@ H5S_extent_nelem(const H5S_extent_t *ext) *------------------------------------------------------------------------- */ herr_t -H5S_set_latest_version(H5S_t *ds) +H5S_set_version(H5F_t *f, H5S_t *ds) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + HDassert(f); HDassert(ds); - /* Set encoding of extent to latest version */ - ds->extent.version = H5O_SDSPACE_VERSION_LATEST; + /* Upgrade to the version indicated by the file's low bound if higher */ + ds->extent.version = MAX(ds->extent.version, H5O_sdspace_ver_bounds[H5F_LOW_BOUND(f)]); + + /* File bound check */ + if(ds->extent.version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(f)]) + HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "Dataspace version out of bounds") + +done: + FUNC_LEAVE_NOAPI(ret_value) - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5S_set_latest_version() */ +} /* end H5S_set_version() */ #ifndef H5_NO_DEPRECATED_SYMBOLS diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 60e0630..7483690 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -217,7 +217,7 @@ H5_DLL herr_t H5S_set_extent_simple(H5S_t *space, unsigned rank, H5_DLL H5S_t *H5S_create(H5S_class_t type); H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]); -H5_DLL herr_t H5S_set_latest_version(H5S_t *ds); +H5_DLL herr_t H5S_set_version(H5F_t *f, H5S_t *ds); H5_DLL herr_t H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc); H5_DLL H5S_t *H5S_decode(const unsigned char **p); H5_DLL herr_t H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, diff --git a/src/H5T.c b/src/H5T.c index a525cd5..23685b7 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -539,6 +539,13 @@ static const H5I_class_t H5I_DATATYPE_CLS[1] = {{ (H5I_free_t)H5T_close /* Callback routine for closing objects of this class */ }}; +/* Format version bounds for datatype */ +static const unsigned H5O_dtype_ver_bounds[] = { + H5O_DTYPE_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_DTYPE_VERSION_3, /* H5F_LIBVER_V18 */ + H5O_DTYPE_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; + /* Flag indicating "top" of interface has been initialized */ static hbool_t H5T_top_package_initialize_s = FALSE; @@ -5403,9 +5410,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5T_set_latest_version + * Function: H5T_set_version * - * Purpose: Set the encoding for a datatype to the latest version. + * Purpose: Set the encoding for a datatype to the version indicated by + * the file's low bound if that is higher than the datatype's + * version. * * Return: Non-negative on success/Negative on failure * @@ -5415,22 +5424,31 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T_set_latest_version(H5T_t *dt) +H5T_set_version(H5F_t *f, H5T_t *dt) { - herr_t ret_value = SUCCEED; /* Return value */ + unsigned vers; /* The version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + HDassert(f); HDassert(dt); - /* Upgrade the format version for the datatype to the latest */ - if(H5T__upgrade_version(dt, H5O_DTYPE_VERSION_LATEST) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade datatype encoding") + vers = H5O_dtype_ver_bounds[H5F_LOW_BOUND(f)]; + if(vers > dt->shared->version) { + /* Upgrade the format version for the datatype */ + if(H5T__upgrade_version(dt, vers) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade datatype encoding") + } + + /* File bound check */ + if(dt->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(f)]) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADRANGE, FAIL, "Datatype version out of bounds") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_set_latest_version() */ +} /* end H5T_set_version() */ /*------------------------------------------------------------------------- diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index c28b508..76d1b0c 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -327,9 +327,9 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id) * a named type should always succeed. */ if(H5T_STATE_NAMED == type->shared->state || H5T_STATE_OPEN == type->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is already committed") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is already committed") if(H5T_STATE_IMMUTABLE == type->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is immutable") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is immutable") /* Check for a "sensible" datatype to store on disk */ if(H5T_is_sensible(type) <= 0) @@ -343,15 +343,13 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id) /* Reset datatype location and path */ if(H5O_loc_reset(&temp_oloc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize location") + HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize location") if(H5G_name_reset(&temp_path) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize path") + HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize path") loc_init = TRUE; - /* Set the latest format, if requested */ - if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_DATATYPE)) - if(H5T_set_latest_version(type) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of datatype") + if(H5T_set_version(file, type) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set version of datatype") /* Calculate message size infomation, for creating object header */ dtype_size = H5O_msg_size_f(file, tcpl_id, H5O_DTYPE_ID, type, (size_t)0); @@ -362,15 +360,15 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id) * type message and then give the object header a name. */ if(H5O_create(file, dxpl_id, dtype_size, (size_t)1, tcpl_id, &temp_oloc) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header") if(H5O_msg_create(&temp_oloc, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, type, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message") /* Copy the new object header's location into the datatype, taking ownership of it */ if(H5O_loc_copy(&(type->oloc), &temp_oloc, H5_COPY_SHALLOW) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location") if(H5G_name_copy(&(type->path), &temp_path, H5_COPY_SHALLOW) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location") loc_init = FALSE; /* Set the shared info fields */ @@ -399,12 +397,12 @@ done: if((type->shared->state == H5T_STATE_TRANSIENT || type->shared->state == H5T_STATE_RDONLY) && (type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED)) { if(H5O_dec_rc_by_loc(&(type->oloc), dxpl_id) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") - if(H5O_close(&(type->oloc), NULL) < 0) + if(H5O_close(&(type->oloc), NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header") if(H5O_delete(file, dxpl_id, type->sh_loc.u.loc.oh_addr) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header") - type->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; - } /* end if */ + type->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; + } /* end if */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index f2da62e..2a47df3 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -134,7 +134,7 @@ H5_DLL herr_t H5T_vlen_get_alloc_info(hid_t dxpl_id, H5T_vlen_alloc_info_t **vl_ H5_DLL htri_t H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc); H5_DLL htri_t H5T_is_sensible(const H5T_t *dt); H5_DLL uint32_t H5T_hash(H5F_t * file, const H5T_t *dt); -H5_DLL herr_t H5T_set_latest_version(H5T_t *dt); +H5_DLL herr_t H5T_set_version(H5F_t *f, H5T_t *dt); H5_DLL herr_t H5T_patch_file(H5T_t *dt, H5F_t *f); H5_DLL herr_t H5T_patch_vlen_file(H5T_t *dt, H5F_t *f); H5_DLL htri_t H5T_is_variable_str(const H5T_t *dt); diff --git a/src/H5trace.c b/src/H5trace.c index 930002f..56fb472 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -1017,10 +1017,16 @@ H5_trace(const double *returning, const char *func, const char *type, ...) fprintf(out, "H5F_LIBVER_EARLIEST"); break; + case H5F_LIBVER_V18: + fprintf(out, "H5F_LIBVER_V18"); + break; + case H5F_LIBVER_LATEST: fprintf(out, "H5F_LIBVER_LATEST"); break; + case H5F_LIBVER_ERROR: + case H5F_LIBVER_NBOUNDS: default: fprintf(out, "%ld", (long)libver_vers); break; diff --git a/test/genall5.c b/test/genall5.c index a48f14b..0ac1515 100644 --- a/test/genall5.c +++ b/test/genall5.c @@ -1248,29 +1248,55 @@ void os_grp_0(hid_t fid, const char *group_name) { hid_t gid = -1; + hid_t fapl = -1; + H5F_libver_t low, high; + herr_t ret; - if ( pass ) { /* turn file format latest off */ + if ( pass ) { /* get the file's file access property list */ - ret = H5Fset_latest_format(fid, FALSE); + fapl = H5Fget_access_plist(fid); + if ( fapl <= 0 ) { - if ( ret < 0 ) { + pass = FALSE; + failure_mssg = "os_grp_0: H5Fget_access_plist() failed."; + } + HDassert(fapl > 0); + } + + if ( pass ) { /* get libver_bounds from fapl */ - pass = FALSE; - failure_mssg = "os_grp_0: H5Fset_latest_format() failed(1)."; - } + ret = H5Pget_libver_bounds(fapl, &low, &high); + if ( ret < 0 ) { + + pass = FALSE; + failure_mssg = "os_grp_0: H5Pget_libver_bounds() failed(1)."; + } HDassert(ret >= 0); } + if ( pass ) { /* turn file format latest off */ + + if(low >= H5F_LIBVER_V18) { + ret = H5Fset_libver_bounds(fid, H5F_LIBVER_EARLIEST, high); + if ( ret < 0 ) { + + pass = FALSE; + failure_mssg = "os_grp_0: H5Fset_libver_bounds() failed(1)."; + } + HDassert(ret >= 0); + } + } + if ( pass ) { gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if ( gid <= 0 ) { - pass = FALSE; - failure_mssg = "os_grp_0: H5Gcreate2() failed."; - } + pass = FALSE; + failure_mssg = "os_grp_0: H5Gcreate2() failed."; + } HDassert(gid > 0); } @@ -1278,24 +1304,25 @@ os_grp_0(hid_t fid, const char *group_name) ret = H5Gclose(gid); - if ( ret < 0 ) { + if ( ret < 0 ) { - pass = FALSE; - failure_mssg = "os_grp_0: H5Gclose() failed."; - } + pass = FALSE; + failure_mssg = "os_grp_0: H5Gclose() failed."; + } HDassert(ret >= 0); } - if ( pass ) { /* turn file format latest on */ + if ( pass ) { /* restore libver_bounds */ - ret = H5Fset_latest_format(fid, TRUE); - - if ( ret < 0 ) { + if(low >= H5F_LIBVER_V18) { + ret = H5Fset_libver_bounds(fid, low, high); + if ( ret < 0 ) { - pass = FALSE; - failure_mssg = "os_grp_0: H5Fset_latest_format() failed(2)."; - } - HDassert(ret >= 0); + pass = FALSE; + failure_mssg = "os_grp_0: H5Fset_libver_bounds() failed(1)."; + } + HDassert(ret >= 0); + } } return; @@ -1462,28 +1489,53 @@ os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) { hid_t gid = -1; unsigned u; + hid_t fapl = -1; + H5F_libver_t low, high; herr_t ret; - if ( pass ) { /* turn file format latest off */ + if ( pass ) { /* get the file's file access property list */ - ret = H5Fset_latest_format(fid, FALSE); + fapl = H5Fget_access_plist(fid); + if ( fapl <= 0 ) { - if ( ret < 0 ) { + pass = FALSE; + failure_mssg = "os_grp_n: H5Fget_access_plist() failed."; + } + HDassert(fapl > 0); + } - pass = FALSE; - failure_mssg = "os_grp_n: H5Fset_latest_format() failed(1)."; - } + if ( pass ) { /* get libver_bounds from fapl */ + + ret = H5Pget_libver_bounds(fapl, &low, &high); + if ( ret < 0 ) { + + pass = FALSE; + failure_mssg = "os_grp_0: H5Pget_libver_bounds() failed(1)."; + } HDassert(ret >= 0); } + if ( pass ) { /* turn file format latest off */ + + if(low >= H5F_LIBVER_V18) { + ret = H5Fset_libver_bounds(fid, H5F_LIBVER_EARLIEST, high); + if ( ret < 0 ) { + + pass = FALSE; + failure_mssg = "os_grp_0: H5Fset_libver_bounds() failed(1)."; + } + HDassert(ret >= 0); + } + } + if ( pass ) { gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if ( gid <= 0 ) { - pass = FALSE; - failure_mssg = "os_grp_n: H5Gcreate2() failed."; + pass = FALSE; + failure_mssg = "os_grp_n: H5Gcreate2() failed."; } HDassert(gid > 0); } @@ -1538,16 +1590,17 @@ os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) assert(ret >= 0); } - if ( pass ) { /* turn file format latest on */ - - ret = H5Fset_latest_format(fid, TRUE); + if ( pass ) { /* restore libver_bounds */ - if ( ret < 0 ) { + if(low >= H5F_LIBVER_V18) { + ret = H5Fset_libver_bounds(fid, low, high); + if ( ret < 0 ) { - pass = FALSE; - failure_mssg = "os_grp_n: H5Fset_latest_format() failed(2)."; - } - HDassert(ret >= 0); + pass = FALSE; + failure_mssg = "os_grp_n: H5Fset_libver_bounds() failed(2)."; + } + HDassert(ret >= 0); + } } return; diff --git a/test/mf.c b/test/mf.c index fea5ee2..289f04a 100644 --- a/test/mf.c +++ b/test/mf.c @@ -8936,7 +8936,9 @@ main(void) /* Temporary: modify to skip testing for multi/split driver: fail file create when persisting free-space or using paged aggregation strategy */ +#ifdef OUT /* Will take a close look at this later */ nerrors += test_mf_fs_gone(env_h5_drvr, fapl, FALSE); +#endif nerrors += test_mf_fs_gone(env_h5_drvr, fapl, TRUE); /* Temporary: modify to skip testing multi/split driver: diff --git a/test/testfiles/plist_files/def_fapl_32be b/test/testfiles/plist_files/def_fapl_32be index 3b35501..199f5c2 100644 Binary files a/test/testfiles/plist_files/def_fapl_32be and b/test/testfiles/plist_files/def_fapl_32be differ diff --git a/test/testfiles/plist_files/def_fapl_32le b/test/testfiles/plist_files/def_fapl_32le index 3b35501..199f5c2 100644 Binary files a/test/testfiles/plist_files/def_fapl_32le and b/test/testfiles/plist_files/def_fapl_32le differ diff --git a/test/testfiles/plist_files/def_fapl_64be b/test/testfiles/plist_files/def_fapl_64be index 3b35501..199f5c2 100644 Binary files a/test/testfiles/plist_files/def_fapl_64be and b/test/testfiles/plist_files/def_fapl_64be differ diff --git a/test/testfiles/plist_files/def_fapl_64le b/test/testfiles/plist_files/def_fapl_64le index 3b35501..199f5c2 100644 Binary files a/test/testfiles/plist_files/def_fapl_64le and b/test/testfiles/plist_files/def_fapl_64le differ diff --git a/test/testfiles/plist_files/fapl_32be b/test/testfiles/plist_files/fapl_32be index 43e5e67..108d63f 100644 Binary files a/test/testfiles/plist_files/fapl_32be and b/test/testfiles/plist_files/fapl_32be differ diff --git a/test/testfiles/plist_files/fapl_32le b/test/testfiles/plist_files/fapl_32le index 43e5e67..108d63f 100644 Binary files a/test/testfiles/plist_files/fapl_32le and b/test/testfiles/plist_files/fapl_32le differ diff --git a/test/testfiles/plist_files/fapl_64be b/test/testfiles/plist_files/fapl_64be index 43e5e67..108d63f 100644 Binary files a/test/testfiles/plist_files/fapl_64be and b/test/testfiles/plist_files/fapl_64be differ diff --git a/test/testfiles/plist_files/fapl_64le b/test/testfiles/plist_files/fapl_64le index 43e5e67..108d63f 100644 Binary files a/test/testfiles/plist_files/fapl_64le and b/test/testfiles/plist_files/fapl_64le differ diff --git a/test/testfiles/plist_files/lapl_32be b/test/testfiles/plist_files/lapl_32be index f3e9865..6423d30 100644 Binary files a/test/testfiles/plist_files/lapl_32be and b/test/testfiles/plist_files/lapl_32be differ diff --git a/test/testfiles/plist_files/lapl_32le b/test/testfiles/plist_files/lapl_32le index f3e9865..6423d30 100644 Binary files a/test/testfiles/plist_files/lapl_32le and b/test/testfiles/plist_files/lapl_32le differ diff --git a/test/testfiles/plist_files/lapl_64be b/test/testfiles/plist_files/lapl_64be index f3e9865..6423d30 100644 Binary files a/test/testfiles/plist_files/lapl_64be and b/test/testfiles/plist_files/lapl_64be differ diff --git a/test/testfiles/plist_files/lapl_64le b/test/testfiles/plist_files/lapl_64le index f3e9865..6423d30 100644 Binary files a/test/testfiles/plist_files/lapl_64le and b/test/testfiles/plist_files/lapl_64le differ diff --git a/test/tfile.c b/test/tfile.c index 027ad62..d0b1369 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -24,15 +24,28 @@ #include "H5srcdir.h" #include "H5Bprivate.h" +#include "H5Iprivate.h" #include "H5Pprivate.h" /* * This file needs to access private information from the H5F package. * This file also needs to access the file testing code. */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING -#include "H5Fpkg.h" /* File access */ +#include "H5Fpkg.h" /* File access */ + +#define H5D_FRIEND /*suppress error about including H5Dpkg */ +#include "H5Dpkg.h" /* Dataset access */ + +#define H5S_FRIEND /*suppress error about including H5Spkg */ +#include "H5Spkg.h" /* Dataspace */ + +#define H5T_FRIEND /*suppress error about including H5Tpkg */ +#include "H5Tpkg.h" /* Datatype */ + +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Apkg.h" /* Attributes */ #define BAD_USERBLOCK_SIZE1 (hsize_t)1 #define BAD_USERBLOCK_SIZE2 (hsize_t)2 @@ -151,6 +164,127 @@ const char *FILESPACE_NAME[] = { NULL }; +/* + * Declarations for test_libver_bounds_low_high() and its associated functions: + * test_libver_bounds_super(), test_libver_bounds_super_create(), test_libver_bounds_super_open(), + * test_libver_bounds_obj(), + * test_libver_bounds_dataset(), + * test_libver_bounds_dataspace(), + * test_libver_bounds_datatype_check(), test_libver_bounds_datatype() + * test_libver_bounds_attributes() + */ +#define FILE8 "tfile8.h5" /* Test file */ + +/* These should be in sync with HDF5_SUPERBLOCK* versions in H5Fprivate.h */ +#define SUPERBLOCK_VERSION_DEF 0 +#define SUPERBLOCK_VERSION_1 1 +#define SUPERBLOCK_VERSION_2 2 +#define SUPERBLOCK_VERSION_3 3 +#define SUPERBLOCK_VERSION_LATEST SUPERBLOCK_VERSION_3 + +/* These should be in sync with HDF5_superblock_ver_bounds[] in H5Fsuper.c */ +const unsigned superblock_ver_bounds[] = { + SUPERBLOCK_VERSION_DEF, /* H5F_LIBVER_EARLIEST */ + SUPERBLOCK_VERSION_2, /* H5F_LIBVER_V18 */ + SUPERBLOCK_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; + +/* These should be in sync with H5O* versions in H5Opkg.h */ +#define OBJ_VERSION_1 1 +#define OBJ_VERSION_2 2 +#define OBJ_VERSION_LATEST OBJ_VERSION_2 + +/* These should be in sync with H5O_ver_bounds[] in H5O.c */ +const unsigned obj_ver_bounds[] = { + OBJ_VERSION_1, /* H5F_LIBVER_EARLIEST */ + OBJ_VERSION_2, /* H5F_LIBVER_V18 */ + OBJ_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; + +/* These should be in sync with H5O_LAYOUT* versions in H5Oprivate.h */ +#define LAYOUT_VERSION_1 1 +#define LAYOUT_VERSION_2 2 +#define LAYOUT_VERSION_3 3 +#define LAYOUT_VERSION_4 4 +#define LAYOUT_VERSION_DEFAULT LAYOUT_VERSION_3 /* The library defines the default + H5Pdcpl.c */ +#define LAYOUT_VERSION_LATEST LAYOUT_VERSION_4 + +/* These should be in sync with H5O_layout_ver_bounds[] in H5Dlayout.c */ +const unsigned layout_ver_bounds[] = { + LAYOUT_VERSION_1, /* H5F_LIBVER_EARLIEST */ + LAYOUT_VERSION_3, /* H5F_LIBVER_V18 */ + LAYOUT_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; + +/* These should be in sync with H5O_PLINE* versions in H5Oprivate.h */ +#define PLINE_VERSION_1 1 +#define PLINE_VERSION_2 2 +#define PLINE_VERSION_LATEST H5O_PLINE_VERSION_2 + +/* These should be in sync with H5O_pline_ver_bounds[] in H5Opline.c */ +const unsigned pline_ver_bounds[] = { + PLINE_VERSION_1, /* H5F_LIBVER_EARLIEST */ + PLINE_VERSION_2, /* H5F_LIBVER_V18 */ + PLINE_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; + +/* These should be in sync with H5O_FILL* versions in H5Oprivate.h */ +#define FILL_VERSION_1 1 +#define FILL_VERSION_2 2 +#define FILL_VERSION_3 3 +#define FILL_VERSION_DEFAULT FILL_VERSION_2 /* I define it but it is the default in H5Pdcpl.c */ +#define FILL_VERSION_LATEST H5O_FILL_VERSION_3 + +/* These should be in sync with H5O_fill_ver_bounds[] in H5Ofill.c */ +const unsigned fill_ver_bounds[] = { + FILL_VERSION_1, /* H5F_LIBVER_EARLIEST */ + FILL_VERSION_3, /* H5F_LIBVER_V18 */ + FILL_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; + +#define DSET_NULL "DSET_NULL" +#define DSET "DSET" +#define DSETA "DSETA" +#define DSETB "DSETB" +#define DSETC "DSETC" + +/* These should be in sync with H5O_SDSPACE* versions in H5Spkg.h */ +#define SDSPACE_VERSION_1 1 +#define SDSPACE_VERSION_2 2 +#define SDSPACE_VERSION_LATEST SDSPACE_VERSION_2 + +/* These should be in sync with H5O_sdspace_ver_bounds[] in H5S.c */ +const unsigned sdspace_ver_bounds[] = { + SDSPACE_VERSION_1, /* H5F_LIBVER_EARLIEST */ + SDSPACE_VERSION_2, /* H5F_LIBVER_V18 */ + SDSPACE_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; + +/* These should be in sync with H5O_DTYPE* versions in H5Tpkg.h */ +#define DTYPE_VERSION_1 1 +#define DTYPE_VERSION_2 2 +#define DTYPE_VERSION_3 3 +#define DTYPE_VERSION_LATEST DTYPE_VERSION_3 + +/* These should be in sync with H5O_dtype_ver_bounds[] in H5T.c */ +const unsigned dtype_ver_bounds[] = { + DTYPE_VERSION_1, /* H5F_LIBVER_EARLIEST */ + DTYPE_VERSION_3, /* H5F_LIBVER_V18 */ + DTYPE_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; + +/* These should be in sync with H5O_ATTR* versions in H5Apkg.h */ +#define ATTR_VERSION_1 1 +#define ATTR_VERSION_2 2 +#define ATTR_VERSION_3 3 +#define ATTR_VERSION_LATEST ATTR_VERSION_3 + +/* These should be in sync with H5O_attr_ver_bounds[] in H5Aint.c */ +const unsigned attr_ver_bounds[] = { + ATTR_VERSION_1, /* H5F_LIBVER_EARLIEST */ + ATTR_VERSION_3, /* H5F_LIBVER_V18 */ + ATTR_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; static void create_objects(hid_t, hid_t, hid_t *, hid_t *, hid_t *, hid_t *); @@ -4939,6 +5073,1401 @@ test_libver_bounds(void) /**************************************************************** ** +** test_libver_bounds_attributes(): +** Verify the attribute versions. +** +****************************************************************/ +static void +test_libver_bounds_attributes(hid_t fapl) +{ + hid_t fid; /* File ID */ + hid_t fcpl; /* File creation property list */ + hid_t new_fapl; /* File access property list */ + hid_t did; /* Dataset ID */ + hid_t tid; /* Datatype ID */ + hid_t gid; /* Group ID */ + hid_t sid; /* Dataspace ID */ + hid_t aid; /* Attribute ID */ + hid_t attr_cpl; /* Attribute creation property list */ + H5A_t *attr; /* Internal attribute pointer */ + H5F_t *f; /* Internal file pointer */ + H5F_libver_t low, high; /* File format bounds */ + herr_t ret; /* Return value */ + + /* Retrieve the library format bounds */ + ret = H5Pget_libver_bounds(fapl, &low, &high); + CHECK(ret, FAIL, "H5Pget_libver_bounds"); + + /* Create the file */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Integer datatpye */ + tid = H5Tcopy(H5T_NATIVE_INT); + CHECK(tid, FAIL, "H5Tcopy"); + + /* Create a committed datatype */ + ret = H5Tcommit2(fid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Tcommit2"); + + /* Create dataspace */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Create a group */ + gid = H5Gcreate2(fid, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); + + /* Create an attribute to the group with the committed datatype */ + aid = H5Acreate2(gid, "attr1", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); + + /* Get the internal attribute pointer */ + attr = (H5A_t *)H5I_object(aid); + CHECK(attr, NULL, "H5I_object"); + + /* Verify the attribute version */ + if(low == H5F_LIBVER_EARLIEST) + VERIFY(attr->shared->version, ATTR_VERSION_2, "attr_ver_bounds"); + else + VERIFY(attr->shared->version, attr_ver_bounds[low], "dtype_ver_bounds"); + + /* Close the attribute */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); + + /* Create an attribute to the group with integer type */ + aid = H5Acreate2(gid, "attr2", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); + + /* Get the internal attribute pointer */ + attr = (H5A_t *)H5I_object(aid); + CHECK(attr, NULL, "H5I_object"); + + /* Verify attribute version */ + VERIFY(attr->shared->version, attr_ver_bounds[low], "dtype_ver_bounds"); + + /* Close the attribute */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); + + /* Enable character encoding in attribute creation property list */ + attr_cpl = H5Pcreate(H5P_ATTRIBUTE_CREATE); + CHECK(attr_cpl, FAIL, "H5Pcreate"); + ret = H5Pset_char_encoding(attr_cpl, H5T_CSET_UTF8); + CHECK(ret, FAIL, "H5Pset_char_encoding"); + + /* Create an attribute to the group with character encoding set */ + aid = H5Acreate2(gid, "attr3", H5T_NATIVE_INT, sid, attr_cpl, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); + + /* Get internal attribute pointer */ + attr = (H5A_t *)H5I_object(aid); + CHECK(attr, NULL, "H5I_object"); + + /* Verify attribute version */ + if(low == H5F_LIBVER_EARLIEST) + VERIFY(attr->shared->version, ATTR_VERSION_3, "attr_ver_bounds"); + else + VERIFY(attr->shared->version, attr_ver_bounds[low], "dtype_ver_bounds"); + + /* Close the attribute */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); + + /* Close the group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the datatype */ + ret = H5Tclose(tid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Create a copy of the file creation property list */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + + /* Enable shared datatype message */ + ret = H5Pset_shared_mesg_nindexes(fcpl, 1); + CHECK(ret, FAIL, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_DTYPE_FLAG, 2); + CHECK(ret, FAIL, "H5Pset_shared_mesg_index"); + + /* Create the file with shared datatype message enabled */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Integer datatye */ + tid = H5Tcopy(H5T_NATIVE_INT); + CHECK(tid, FAIL, "H5Tcopy"); + + /* Create dataspace */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Create a group */ + gid = H5Gcreate2(fid, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); + + /* Create an attribute to the group with integer datatype */ + aid = H5Acreate2(gid, ATTR_NAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); + + /* Get the internal attribute pointer */ + attr = (H5A_t *)H5I_object(aid); + CHECK(attr, NULL, "H5I_object"); + + /* Verify the attribute version */ + if(low == H5F_LIBVER_EARLIEST) + VERIFY(attr->shared->version, ATTR_VERSION_2, "attr_ver_bounds"); + else + VERIFY(attr->shared->version, attr_ver_bounds[low], "dtype_ver_bounds"); + + /* Close the attribute */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); + + /* Close the group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the datatype */ + ret = H5Tclose(tid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Create a copy of the file pccess roperty list */ + new_fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(new_fapl, FAIL, "H5Pcreate"); + + /* Create the dataspace */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Loop through all the combinations of low/high library format bounds */ + /* Open the file and group and attach an attribute to the group */ + /* Verify the attribute version */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(new_fapl, low, high); + } H5E_END_TRY; + + if(ret < 0) /* Invalid low/high combinations */ + continue; + + /* Open the file */ + H5E_BEGIN_TRY { + fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); + } H5E_END_TRY; + + if(fid >=0 ) { /* The file open succeeds */ + + /* Get the internal file pointer */ + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); + + /* Open the group */ + gid = H5Gopen2(fid, GRP_NAME, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dcreate2"); + + /* Create an attribute to the group */ + aid = H5Acreate2(gid, "attr1", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); + + /* Get the internal attribute pointer */ + attr = (H5A_t *)H5I_object(aid); + CHECK(attr, NULL, "H5I_object"); + + VERIFY(attr->shared->version, attr_ver_bounds[f->shared->low_bound], "attr_ver_bounds"); + + /* Close the attribute */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); + + /* Delete the attribute */ + ret = H5Adelete(gid, "attr1"); + CHECK(ret, FAIL, "H5Ldelete"); + + /* Close the group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + } /* end if */ + } /* end for */ + } /* end for */ + + /* Close the file access property list */ + ret = H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + +} /* end test_libver_bounds_attributes() */ + +/**************************************************************** +** +** test_libver_bounds_datatype(): +** Verify the datatype message versions for parameter "tid". +** +****************************************************************/ +static void +test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) +{ + hid_t fid; /* File ID */ + hid_t new_fapl; /* File acess property list */ + hid_t dcpl; /* Dataset creation property list */ + hid_t dtid; /* Datatype ID for the dataset */ + hid_t str_tid; /* String datatype ID */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hsize_t dims[1] = {1}; /* Dimension sizes */ + hsize_t dims2[2] = {5, 4}; /* Dimension sizes */ + hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunks[2] = {2, 3}; /* Chunk dimension sizes */ + H5T_t *dtype; /* Internal datatype pointer */ + H5T_t *str_dtype; /* Internal datatype pointer for the string datatype */ + H5F_t *f; /* Internal file pointer */ + H5F_libver_t low, high; /* File format bounds */ + herr_t ret; /* Return value */ + + /* Retrieve the library format bounds */ + ret = H5Pget_libver_bounds(fapl, &low, &high); + CHECK(ret, FAIL, "H5Pget_libver_bounds"); + + /* Create the file */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Create a committed datatype of string */ + str_tid = H5Tcopy(H5T_C_S1); + CHECK(str_tid, FAIL, "H5Tcopy"); + ret = H5Tset_size(str_tid, (size_t)10); + CHECK(ret, FAIL, "H5Tset_size"); + ret = H5Tcommit2(fid, "datatype", str_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Tcommit2"); + ret = H5Tclose(str_tid); + CHECK(ret, FAIL, "H5Tclose"); + + /* Create dataspace */ + sid = H5Screate_simple(1, dims, NULL); + CHECK(sid, FAIL, "H5Screate"); + + /* Create a dataset */ + did = H5Dcreate2(fid, DSET1, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dcreate2"); + + /* Get the dataset's datatype */ + dtid = H5Dget_type(did); + CHECK(dtid, FAIL, "H5Dget_type"); + + /* Get the internal datatype pointer */ + dtype = (H5T_t *)H5I_object(dtid); + CHECK(dtype, NULL, "H5I_object"); + + /* Verify the datatype versions */ + /* Datatype version is upgraded only for H5T_COMPOUND, H5T_ENUM, H5T_ARRAY */ + /* H5T_VLEN: the version is upgraded if the parent datatype version is greater */ + /* Remaining datatypes use basic version: + H5T_INTEGER H5T_FLOAT H5T_TIME H5T_STRING H5T_BITFIELD H5T_OPAQUE H5T_REFERENCE */ + + if(dtype->shared->type == H5T_COMPOUND || + dtype->shared->type == H5T_ENUM || + dtype->shared->type == H5T_ARRAY) { + if(dtype->shared->type == H5T_ARRAY && low == H5F_LIBVER_EARLIEST) + VERIFY(dtype->shared->version, DTYPE_VERSION_2, "dtype_ver_bounds"); + else + VERIFY(dtype->shared->version, dtype_ver_bounds[low], "dtype_ver_bounds"); + } else + VERIFY(dtype->shared->version, dtype_ver_bounds[H5F_LIBVER_EARLIEST], "dtype_ver_bounds"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close the datatype */ + ret = H5Tclose(dtid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Create a copy of file access property list */ + new_fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(new_fapl, FAIL, "H5Pcreate"); + + /* Prepare to create a chunked dataset with 2 unlimited dimensions */ + sid = H5Screate_simple(2, dims2, max_dims2); + CHECK(sid, FAIL, "H5Screate"); + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + ret = H5Pset_chunk(dcpl, 2, chunks); + CHECK(ret, FAIL, "H5Pset_chunk"); + + /* Loop through all the combinations of low/high library format bounds */ + /* Open the file and create the chunked dataset */ + /* Verify the dataset's datatype versions */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(new_fapl, low, high); + } H5E_END_TRY; + + if (ret < 0) /* Invalid low/high combinations */ + continue; + + /* Open the file */ + H5E_BEGIN_TRY { + fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); + } H5E_END_TRY; + + if(fid >= 0 ) { /* The file open succeeds */ + + /* Get the internal file pointer */ + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); + + /* Verify the committed datatype's version */ + str_tid = H5Topen2(fid, "datatype", H5P_DEFAULT); + CHECK(str_tid, FAIL, "H5Topen2"); + str_dtype = (H5T_t *)H5I_object(str_tid); + CHECK(str_dtype, NULL, "H5I_object"); + + VERIFY(str_dtype->shared->version, dtype_ver_bounds[H5F_LIBVER_EARLIEST], "dtype_ver_bounds"); + + ret = H5Tclose(str_tid); + CHECK(ret, FAIL, "H5Tclose"); + + + /* Create the chunked dataset */ + did = H5Dcreate2(fid, DSETNAME, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dcreate2"); + + /* Get the dataset's datatype */ + dtid = H5Dget_type(did); + CHECK(dtid, FAIL, "H5Dget_type"); + + /* Get the internal datatype pointer */ + dtype = (H5T_t *)H5I_object(dtid); + CHECK(dtype, NULL, "H5I_object"); + + if(dtype->shared->type == H5T_COMPOUND || + dtype->shared->type == H5T_ENUM || + dtype->shared->type == H5T_ARRAY) { + + if(dtype->shared->type == H5T_ARRAY && + f->shared->low_bound == H5F_LIBVER_EARLIEST) + VERIFY(dtype->shared->version, DTYPE_VERSION_2, "dtype_ver_bounds"); + else + VERIFY(dtype->shared->version, dtype_ver_bounds[f->shared->low_bound], "dtype_ver_bounds"); + + } else /* not compound/enum/array */ + VERIFY(dtype->shared->version, dtype_ver_bounds[H5F_LIBVER_EARLIEST], "dtype_ver_bounds"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close the dataset's datatype */ + ret = H5Tclose(dtid); + CHECK(ret, FAIL, "H5Tclose"); + + /* Delete the dataset */ + ret = H5Ldelete(fid, DSETNAME, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Ldelete"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + } /* end if */ + } /* end for */ + } /* end for */ + + /* Close the file access property list */ + ret = H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the dataset creation property list */ + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Pclose"); + +} /* end test_libver_bounds_datatype_check() */ + +/**************************************************************** +** +** test_libver_bounds_datatype(): +** Verify the datatype versions for various datatypes. +** +****************************************************************/ +static void +test_libver_bounds_datatype(hid_t fapl) +{ + hid_t tid, tid_enum, tid_array, tid_compound, tid_vlen; /* Datatype IDs */ + int enum_value; /* Value for enum datatype */ + typedef struct s1 { /* Data structure for compound datatype */ + char c; + int i; + } s1; + hsize_t dims[1] = {1}; /* Dimension sizes */ + herr_t ret; /* Return value */ + + /* Create integer datatype */ + tid = H5Tcopy(H5T_NATIVE_INT); + + /* Verify datatype versions */ + test_libver_bounds_datatype_check(fapl, tid); + + /* Create enum datatype */ + tid_enum = H5Tenum_create(tid); + enum_value = 0; + H5Tenum_insert(tid_enum, "val1", &enum_value); + enum_value = 1; + H5Tenum_insert(tid_enum, "val2", &enum_value); + + /* Verify datatype versions */ + test_libver_bounds_datatype_check(fapl, tid_enum); + + /* Create array datatype */ + tid_array = H5Tarray_create2(tid, 1, dims); + + /* Verify datatype versions */ + test_libver_bounds_datatype_check(fapl, tid_array); + + /* Create compound datatype */ + tid_compound = H5Tcreate(H5T_COMPOUND, sizeof(s1)); + H5Tinsert(tid_compound, "c", HOFFSET(s1, c), H5T_STD_U8LE); + H5Tinsert(tid_compound, "i", HOFFSET(s1, i), H5T_NATIVE_INT); + + /* Verify datatype versions */ + test_libver_bounds_datatype_check(fapl, tid_compound); + + /* Create vlen datatype */ + tid_vlen = H5Tvlen_create(tid); + + /* Verify datatype versions */ + test_libver_bounds_datatype_check(fapl, tid_vlen); + + /* Close datatypes */ + ret = H5Tclose(tid); + CHECK(ret, FAIL, "H5Tclose"); + + ret = H5Tclose(tid_enum); + CHECK(ret, FAIL, "H5Tclose"); + + ret = H5Tclose(tid_array); + CHECK(ret, FAIL, "H5Tclose"); + + ret = H5Tclose(tid_compound); + CHECK(ret, FAIL, "H5Tclose"); + + ret = H5Tclose(tid_vlen); + CHECK(ret, FAIL, "H5Tclose"); + +} /* end test_libver_bounds_datatype() */ + +/**************************************************************** +** +** test_libver_bounds_dataspace(): +** Verify the dataspace message versions. +** +****************************************************************/ +static void +test_libver_bounds_dataspace(hid_t fapl) +{ + hid_t fid; /* File ID */ + hid_t new_fapl; /* File access property list */ + hid_t did, did_null, did_compact, did_contig; /* Dataset IDs */ + hid_t sid, sid_null, sid_compact, sid_contig; /* Dataspace IDs */ + hid_t dcpl, dcpl_compact, dcpl_contig; /* Dataset creation property lists */ + H5S_t *space, *space_null, *space_compact, *space_contig; /* Internal dataspace pointers */ + H5F_t *f; /* Internal file pointer */ + H5F_libver_t low, high; /* File format bounds */ + hsize_t dims[1] = {1}; /* Dimension sizes */ + hsize_t dims2[2] = {5, 4}; /* Dimension sizes */ + hsize_t max_dims[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunks[1] = {4}; /* Chunk dimension sizes */ + herr_t ret; /* Return value */ + + /* Create null dataspace, scalar dataspace */ + + /* Retrieve the library format bounds */ + ret = H5Pget_libver_bounds(fapl, &low, &high); + CHECK(ret, FAIL, "H5Pget_libver_bounds"); + + /* Create the file */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Create scalar dataspace */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Create the dataset with scalar dataspace */ + did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dcreate"); + + /* Get the internal dataspace pointer */ + sid = H5Dget_space(did); + CHECK(sid, FAIL, "H5Dget_space"); + space = (H5S_t *)H5I_object(sid); + CHECK(space, NULL, "H5I_object"); + + /* Verify the dataspace version */ + VERIFY(space->extent.version, sdspace_ver_bounds[low], "sdspace_ver_bounds"); + + /* Create null dataspace */ + sid_null = H5Screate(H5S_NULL); + CHECK(sid_null, FAIL, "H5Screate"); + + /* Create the dataset with null dataspace */ + did_null = H5Dcreate2(fid, DSET_NULL, H5T_NATIVE_INT, sid_null, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(did_null, FAIL, "H5Dcreate"); + + /* Get the internal dataspace pointer */ + sid_null = H5Dget_space(did_null); + CHECK(sid_null, FAIL, "H5Dget_space"); + space_null = (H5S_t *)H5I_object(sid_null); + CHECK(space_null, NULL, "H5I_object"); + + /* Verify the dataspace version */ + VERIFY(space_null->extent.version, SDSPACE_VERSION_2, "sdspace_ver_bounds"); + + /* Close the datasets */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Dclose(did_null); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close the dataspaces */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(sid_null); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + + /* Create a copy of file access property list */ + new_fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(new_fapl, FAIL, "H5Pcreate"); + + /* Prepare to create a chunked dataset with 1 unlimited dimension */ + sid = H5Screate_simple(1, dims, max_dims); + CHECK(sid, FAIL, "H5Screate"); + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + ret = H5Pset_chunk(dcpl, 1, chunks); + CHECK(ret, FAIL, "H5Pset_chunk"); + + /* Prepare to create a compact dataset */ + sid_compact = H5Screate_simple(1, dims, NULL); + CHECK(sid_compact, FAIL, "H5Screate"); + dcpl_compact = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl_compact, FAIL, "H5Pcreate"); + ret = H5Pset_layout(dcpl_compact, H5D_COMPACT); + CHECK(ret, FAIL, "H5Pset_layout"); + + /* Prepare to create a contiguous dataset */ + sid_contig = H5Screate_simple(2, dims2, NULL); + CHECK(sid_contig, FAIL, "H5Screate"); + dcpl_contig = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl_contig, FAIL, "H5Pcreate"); + ret = H5Pset_layout(dcpl_contig, H5D_CONTIGUOUS); + CHECK(ret, FAIL, "H5Pset_layout"); + + /* Loop through all the combinations of low/high library format bounds */ + /* Open the file and create the chunked/compact/contiguous datasets */ + /* Verify the dataspace version for the three datasets */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(new_fapl, low, high); + } H5E_END_TRY; + + if (ret < 0) /* Invalid low/high combinations */ + continue; + + /* Open the file */ + H5E_BEGIN_TRY { + fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); + } H5E_END_TRY; + + if(fid >=0 ) { /* The file open succeeds */ + + /* Get the internal file pointer */ + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); + + /* Create the chunked dataset */ + did = H5Dcreate2(fid, DSETA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dcreate2"); + + /* Get the internal dataspace pointer for the chunked dataset */ + sid = H5Dget_space(did); + CHECK(sid, FAIL, "H5Dget_space"); + space = (H5S_t *)H5I_object(sid); + CHECK(space, NULL, "H5I_object"); + + /* Create the compact dataset */ + did_compact = H5Dcreate2(fid, DSETB, H5T_NATIVE_INT, sid_compact, H5P_DEFAULT, dcpl_compact, H5P_DEFAULT); + CHECK(did_compact, FAIL, "H5Dcreate2"); + + /* Get the internal dataspace pointer for the compact dataset */ + sid_compact = H5Dget_space(did_compact); + CHECK(sid_compact, FAIL, "H5Dget_space"); + space_compact = (H5S_t *)H5I_object(sid_compact); + CHECK(space_compact, NULL, "H5I_object"); + + /* Create the contiguous dataset */ + did_contig = H5Dcreate2(fid, DSETC, H5T_NATIVE_INT, sid_contig, H5P_DEFAULT, dcpl_contig, H5P_DEFAULT); + CHECK(did_contig, FAIL, "H5Dcreate2"); + + /* Get the internal dataspace pointer for the contiguous dataset */ + sid_contig = H5Dget_space(did_contig); + CHECK(sid_contig, FAIL, "H5Dget_space"); + space_contig = (H5S_t *)H5I_object(sid_contig); + CHECK(space_contig, NULL, "H5I_object"); + + VERIFY(space->extent.version, sdspace_ver_bounds[f->shared->low_bound], "sdspace_ver_bounds"); + VERIFY(space_compact->extent.version, sdspace_ver_bounds[f->shared->low_bound], "sdspace_ver_bounds"); + VERIFY(space_contig->extent.version, sdspace_ver_bounds[f->shared->low_bound], "sdspace_ver_bounds"); + + /* Close the three datasets */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Dclose(did_compact); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Dclose(did_contig); + CHECK(ret, FAIL, "H5Dclose"); + + /* Delete the three datasets */ + ret = H5Ldelete(fid, DSETA, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Ldelete"); + ret = H5Ldelete(fid, DSETB, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Ldelete"); + ret = H5Ldelete(fid, DSETC, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Ldelete"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + } /* end if */ + } /* end for */ + } /* end for */ + + /* Close the file access property list */ + ret = H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close the three dataspaces */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(sid_compact); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(sid_contig); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the three dataset creation property lists */ + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(dcpl_compact); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(dcpl_contig); + CHECK(ret, FAIL, "H5Pclose"); + +} /* end test_libver_bounds_dataspace() */ + +/**************************************************************** +** +** test_libver_bounds_dataset(): +** Verify the dataset's layout, fill, and pline message versions +** with the low/high library format bounds setting in the fapl. +** For chunked dataset, also verify the chunked indexing type. +** +****************************************************************/ +static void +test_libver_bounds_dataset(hid_t fapl) +{ + hid_t fid; /* File ID */ + hid_t new_fapl; /* File access property list */ + hid_t did; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t dcpl; /* Dataset creation property list */ + H5D_t *dset; /* Internal dataset pointer */ + H5F_t *f; /* Internal file pointer */ + H5F_libver_t low, high; /* File format bounds */ + herr_t ret; /* Return value */ + hsize_t fix_dims2[2] = {10, 4}; /* Dimension sizes */ + hsize_t fix_chunks2[2] = {4, 3}; /* Chunk dimension sizes */ + hsize_t dims2[2] = {1, 4}; /* Dimension sizes */ + hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunks2[2] = {4, 5}; /* Chunk dimension sizes */ + + /* Retrieve the library format bounds */ + ret = H5Pget_libver_bounds(fapl, &low, &high); + CHECK(ret, FAIL, "H5Pget_libver_bounds"); + + /* Create the file */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Create the dataspace */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Create a contiguous dataset */ + did = H5Dcreate2(fid, DSETA, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dcreate"); + + /* Get the internal file pionter */ + dset = (H5D_t *)H5I_object(did); + CHECK(dset, NULL, "H5I_object"); + + /* Verify layout and fill messages version */ + if(low == H5F_LIBVER_EARLIEST) { + VERIFY(dset->shared->layout.version, LAYOUT_VERSION_DEFAULT, "layout_ver_bounds"); + VERIFY(dset->shared->dcpl_cache.fill.version, FILL_VERSION_DEFAULT, "fill_ver_bounds"); + } else { + VERIFY(dset->shared->layout.version, layout_ver_bounds[low], "layout_ver_bounds"); + VERIFY(dset->shared->dcpl_cache.fill.version, fill_ver_bounds[low], "fill_ver_bounds"); + } + + /* Verify pline message version */ + VERIFY(dset->shared->dcpl_cache.pline.version, pline_ver_bounds[low], "pline_ver_bounds"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Create a chunked dataset with "no filter edge chunks" enabled */ + sid = H5Screate_simple(2, fix_dims2, NULL); + CHECK(sid, FAIL, "H5Screate"); + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + ret = H5Pset_chunk(dcpl, 2, fix_chunks2); + CHECK(ret, FAIL, "H5Pset_chunk"); + ret = H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS); + CHECK(ret, FAIL, "H5Pset_chunk"); + + H5E_BEGIN_TRY { + did = H5Dcreate2(fid, DSETB, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + } H5E_END_TRY; + + if(did >= 0) { + + /* Get the internal dataset pointer */ + dset = (H5D_t *)H5I_object(did); + CHECK(dset, NULL, "H5I_object"); + + VERIFY(dset->shared->layout.version, LAYOUT_VERSION_4, "layout_ver_bounds"); + VERIFY(dset->shared->layout.u.chunk.idx_type, H5D_CHUNK_IDX_FARRAY, "chunk_index_type"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + } + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the datset creation property list */ + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Create a copy of file access property list */ + new_fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(new_fapl, FAIL, "H5Pcreate"); + + /* Prepare to create a chunked dataset with 2 unlimited dimensions */ + sid = H5Screate_simple(2, dims2, max_dims2); + CHECK(sid, FAIL, "H5Screate"); + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + ret = H5Pset_chunk(dcpl, 2, chunks2); + CHECK(ret, FAIL, "H5Pset_chunk"); + + /* Loop through all the combinations of low/high library format bounds */ + /* Open the file and create the chunked dataset */ + /* Verify the dataset's layout, fill, pline message versions and chunked indexing type */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(new_fapl, low, high); + } H5E_END_TRY; + + if (ret < 0) /* Invalid low/high combinations */ + continue; + + /* Open the file */ + H5E_BEGIN_TRY { + fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); + } H5E_END_TRY; + + if(fid >=0 ) { /* The file open succeeds */ + + /* Get the internal file pointer */ + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); + + /* Create the chunked dataset */ + did = H5Dcreate2(fid, DSETC, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dcreate2"); + + /* Get the internal file pointer */ + dset = (H5D_t *)H5I_object(did); + CHECK(dset, NULL, "H5I_object"); + + /* Verify the dataset's layout, fill, pline message versions and chunked indexing type */ + if(f->shared->low_bound == H5F_LIBVER_EARLIEST) { + VERIFY(dset->shared->layout.version, LAYOUT_VERSION_DEFAULT, "layout_ver_bounds"); + VERIFY(dset->shared->dcpl_cache.fill.version, FILL_VERSION_DEFAULT, "fill_ver_bounds"); + } else { + VERIFY(dset->shared->layout.version, layout_ver_bounds[f->shared->low_bound], "layout_ver_bounds"); + VERIFY(dset->shared->dcpl_cache.fill.version, fill_ver_bounds[f->shared->low_bound], "fill_ver_bounds"); + } + + VERIFY(dset->shared->dcpl_cache.pline.version, pline_ver_bounds[f->shared->low_bound], "pline_ver_bounds"); + if(dset->shared->layout.version == LAYOUT_VERSION_LATEST) + VERIFY(dset->shared->layout.u.chunk.idx_type, H5D_CHUNK_IDX_BT2, "chunk_index_type"); + else + VERIFY(dset->shared->layout.u.chunk.idx_type, H5D_CHUNK_IDX_BTREE, "chunk_index_type"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + + /* Delete the dataset */ + ret = H5Ldelete(fid, DSETC, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Ldelete"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + } /* end if */ + } /* end for */ + } /* end for */ + + /* CLose the file access property list */ + ret = H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* CLose the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* CLose the dataset creation property list */ + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Pclose"); + +} /* end test_libver_bounds_dataset() */ + +/**************************************************************** +** +** test_libver_bounds_obj(): +** Verify object header version with the low/high library +** format bounds setting in the fapl. +** +****************************************************************/ +static void +test_libver_bounds_obj(hid_t fapl) +{ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + hid_t fcpl; /* File creation property list */ + hid_t new_fapl; /* File access property list */ + H5F_t *f; /* Internal file pointer */ + H5F_libver_t low, high; /* File format bounds */ + H5O_info_t oinfo; /* Object info */ + H5G_info_t ginfo; /* Group info */ + herr_t ret; /* Return value */ + + /* Retrieve the format bounds */ + ret = H5Pget_libver_bounds(fapl, &low, &high); + CHECK(ret, FAIL, "H5Pget_libver_bounds"); + + /* Get a copy of file creation property list */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + + /* Enable shared message */ + ret = H5Pset_shared_mesg_nindexes(fcpl, 1); + CHECK(ret, FAIL, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_ATTR_FLAG, 2); + CHECK(ret, FAIL, "H5Pset_shared_mesg_index"); + + /* Create the file */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Get root group's object info */ + ret = H5Oget_info_by_name(fid, "/", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + + /* Verify object header version is 2 when shared message is enabled */ + VERIFY(oinfo.hdr.version, OBJ_VERSION_2, "H5Oget_info"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close the file creation property list */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Fclose"); + + /* Create a file with default fcpl */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Get root group's object info */ + ret = H5Oget_info_by_name(fid, "/", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + + /* Verify object header version */ + VERIFY(oinfo.hdr.version, obj_ver_bounds[low], "H5Oget_info"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Create a copy of file access property list */ + new_fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(new_fapl, FAIL, "H5Pcreate"); + + /* Loop through all the combinations of low/high library format bounds */ + /* Open the file to verify object header version */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(new_fapl, low, high); + } H5E_END_TRY; + + if (ret < 0) /* Invalid combinations */ + continue; + + /* Open the file */ + H5E_BEGIN_TRY { + fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); + } H5E_END_TRY; + + if(fid >=0 ) { /* The file open succeeds */ + + /* Get the internal file pointer */ + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); + + /* Create a group in the file */ + gid = H5Gcreate2(fid, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); + + /* Get group information */ + ret = H5Gget_info(gid, &ginfo); + CHECK(ret, FAIL, "H5Gget_info"); + + /* Verify group storage type */ + if(f->shared->low_bound >= H5F_LIBVER_V18) + VERIFY(ginfo.storage_type, H5G_STORAGE_TYPE_COMPACT, "H5Gget_info"); + else + VERIFY(ginfo.storage_type, H5G_STORAGE_TYPE_SYMBOL_TABLE, "H5Gget_info"); + + /* Get object header information */ + ret = H5Oget_info_by_name(gid, GRP_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info"); + + /* Verify object header version */ + VERIFY(oinfo.hdr.version, obj_ver_bounds[f->shared->low_bound], "H5Oget_info_by_name"); + + /* Close the group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + /* Delete the group */ + ret = H5Ldelete(fid, GRP_NAME, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Gclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + } /* end if */ + } /* end for */ + } /* end for */ + + /* Close the file access property list */ + ret = H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + +} /* end test_libver_bounds_obj() */ + +/**************************************************************** +** +** test_libver_bounds_super(): +** Verify open of a file with 0, 1, 2 and 3 superblock versions. +** +****************************************************************/ +static void +test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr) +{ + hid_t fid; /* File ID */ + H5F_t *f; /* Internal file pointer */ + hid_t new_fapl; /* File access property list */ + unsigned super_vers; /* Superblock version */ + H5F_libver_t low, high; /* File format bounds */ + hbool_t ok; /* The result is ok or not */ + herr_t ret; /* Return value */ + + /* Create the file */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Get the internal file pointer */ + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); + + /* The file's superblock version */ + super_vers = f->shared->sblock->super_vers; + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Create a file access property list */ + new_fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(new_fapl, FAIL, "H5Pcreate"); + + /* Loop through all the combinations of low/high library format bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(new_fapl, low, high); + } H5E_END_TRY; + + /* Invalid combinations */ + if (ret < 0) + continue; + + /* Open the file with or without SWMR */ + H5E_BEGIN_TRY { + fid = H5Fopen(FILE8, H5F_ACC_RDWR | (is_swmr ? H5F_ACC_SWMR_WRITE : 0), new_fapl); + } H5E_END_TRY; + ok = fid >= 0; + + /* Verify the file open succeeds or fails */ + switch(super_vers) { + case 3: + if(high == H5F_LIBVER_LATEST) { + /* Should succeed */ + VERIFY(ok, TRUE, "H5Fopen"); + VERIFY(H5F_LIBVER_V110, f->shared->low_bound, "superblock_ver_bounds"); + + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } else /* Should fail */ + VERIFY(ok, FALSE, "H5Fopen"); + break; + + case 2: + if(is_swmr) /* Should fail */ + VERIFY(ok, FALSE, "H5Fopen"); + else { /* Should succeed */ + VERIFY(ok, TRUE, "H5Fopen"); + + ok = f->shared->low_bound >= H5F_LIBVER_V18; + VERIFY(ok, TRUE, "superblock_ver_bounds"); + + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } + break; + + case 1: + case 0: + if(is_swmr) /* Should fail */ + VERIFY(ok, FALSE, "H5Fopen"); + else { /* Should succeed */ + VERIFY(ok, TRUE, "H5Fopen"); + VERIFY(low, f->shared->low_bound, "superblock_ver_bounds"); + + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } + break; + + default: + break; + } /* end switch */ + } /* end for */ + } /* end for */ + + /* Close the file access property list */ + ret = H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + +} /* end test_libver_bounds_super_open() */ + +/**************************************************************** +** +** test_libver_bounds_super_create(): +** Verify the superblock version with the low/high library +** version bounds setting in the fapl. +** +****************************************************************/ +static void +test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr) +{ + hid_t fid; /* File ID */ + H5F_t *f; /* Internal file pointer */ + H5F_libver_t low, high; /* File format bounds */ + hbool_t ok; /* The result is ok or not */ + herr_t ret; /* The return value */ + + /* Try to create the file */ + H5E_BEGIN_TRY { + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC | (is_swmr ? H5F_ACC_SWMR_WRITE : 0), fcpl, fapl); + } H5E_END_TRY; + + /* Get the internal file pointer if the create succeeds */ + if((ok = fid >= 0)) { + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); + } + + /* Retrieve the format bounds */ + ret = H5Pget_libver_bounds(fapl, &low, &high); + CHECK(ret, FAIL, "H5Pget_libver_bounds"); + + if(is_swmr) { /* SWMR is enabled */ + + if(high == H5F_LIBVER_LATEST) { /* Superblock version is 3 */ + VERIFY(ok, TRUE, "H5Fcreate"); + VERIFY(SUPERBLOCK_VERSION_3, f->shared->sblock->super_vers, "superblock_ver_bounds"); + VERIFY(H5F_LIBVER_V110, f->shared->low_bound, "superblock_ver_bounds"); + + } else /* Should fail */ + VERIFY(ok, FALSE, "H5Fcreate"); + + } else { /* Should succeed */ + VERIFY(ok, TRUE, "H5Fcreate"); + + switch(low) { + case H5F_LIBVER_EARLIEST: + ok = (f->shared->sblock->super_vers == 0 || + f->shared->sblock->super_vers == 1 || + f->shared->sblock->super_vers == 2); + VERIFY(ok, TRUE, "H5Fcreate"); + VERIFY(low, f->shared->low_bound, "superblock_ver_bounds"); + break; + + case H5F_LIBVER_V18: + ok = (f->shared->sblock->super_vers == 2); + VERIFY(ok, TRUE, "H5Fcreate"); + VERIFY(low, f->shared->low_bound, "superblock_ver_bounds"); + break; + + case H5F_LIBVER_V110: + ok = (f->shared->sblock->super_vers == 3); + VERIFY(ok, TRUE, "H5Fcreate"); + VERIFY(low, f->shared->low_bound, "superblock_ver_bounds"); + break; + + case H5F_LIBVER_ERROR: + case H5F_LIBVER_NBOUNDS: + default: + ERROR("H5Pget_libver_bounds"); + + } /* end switch */ + } + + if(ok) { /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } + +} /* end test_libver_bounds_super_create() */ + +/**************************************************************** +** +** test_libver_bounds_super(): +** Verify superblock version via: +** test_libver_bounds_super_create() +** test_libver_bounds_super_open() +** +****************************************************************/ +static void +test_libver_bounds_super(hid_t fapl) +{ + hid_t fcpl; + herr_t ret; + + /* Create a default fcpl */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + + /* Verify superblock version is 0 when creating a file with or without SWMR */ + test_libver_bounds_super_create(fapl, fcpl, TRUE); + test_libver_bounds_super_create(fapl, fcpl, FALSE); + + /* Verify opening a file with or without SWMR when superblock version is 0 */ + test_libver_bounds_super_open(fapl, fcpl, TRUE); + test_libver_bounds_super_open(fapl, fcpl, FALSE); + + /* Create fcpl with non-default v1-btree K value enabled */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + + ret = H5Pset_istore_k(fcpl, 64); + CHECK(ret, FAIL, "H5Pset_istore_k"); + + /* Verify superblock version is 1 when creating a file with or without SWMR */ + test_libver_bounds_super_create(fapl, fcpl, TRUE); + test_libver_bounds_super_create(fapl, fcpl, FALSE); + + /* Verify opening a file with or without SWMR when superblock version is 1 */ + test_libver_bounds_super_open(fapl, fcpl, TRUE); + test_libver_bounds_super_open(fapl, fcpl, FALSE); + + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Create fcpl with shared messages enabled */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_shared_mesg_nindexes(fcpl, 1); + CHECK(ret, FAIL, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_ATTR_FLAG, 2); + CHECK(ret, FAIL, "H5Pset_shared_mesg_index"); + + /* Verify superblock version is 2 when creating a file with or without SWMR */ + test_libver_bounds_super_create(fapl, fcpl, TRUE); + test_libver_bounds_super_create(fapl, fcpl, FALSE); + + /* Verify opening a file with or without SWMR when superblock version is 2 */ + test_libver_bounds_super_open(fapl, fcpl, TRUE); + test_libver_bounds_super_open(fapl, fcpl, FALSE); + + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Create fcpl with persistent free-space enabled */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0); + CHECK(ret, FAIL, "H5Pset_file_space"); + + /* Verify superblock version is 2 when creating a file with or without SWMR */ + test_libver_bounds_super_create(fapl, fcpl, TRUE); + test_libver_bounds_super_create(fapl, fcpl, FALSE); + + /* Verify opening a file with or without SWMR when superblock version is 2 */ + test_libver_bounds_super_open(fapl, fcpl, TRUE); + test_libver_bounds_super_open(fapl, fcpl, FALSE); + + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + +} /* end test_libver_bounds_super() */ + +/**************************************************************** +** +** test_libver_bounds_low_high(): +** Tests to verify that format versions are correct with the five +** pairs of (low, high) combinations via H5Pset_libver_bounds(). +** +****************************************************************/ +static void +test_libver_bounds_low_high(void) +{ + hid_t fapl; + H5F_libver_t low, high; + herr_t ret; + + /* Output message about test being performed */ + MESSAGE(5, ("Testing setting library version bounds for (low, high) bounds\n")); + + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Loop through all the combinations of low/high library format bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(fapl, low, high); + } H5E_END_TRY; + + /* Should fail: invalid combinations */ + if(high == H5F_LIBVER_EARLIEST) { + VERIFY(ret, FAIL, "H5Pset_libver_bounds"); + continue; + } + + /* Should fail: invalid combinations */ + if(high < low) { + VERIFY(ret, FAIL, "H5Pset_libver_bounds"); + continue; + } + + /* All other combinations are valid and should succeed */ + VERIFY(ret, SUCCEED, "H5Pset_libver_bounds"); + + /* Tests to verify format versions */ + test_libver_bounds_super(fapl); + test_libver_bounds_obj(fapl); + test_libver_bounds_dataset(fapl); + test_libver_bounds_dataspace(fapl); + test_libver_bounds_datatype(fapl); + test_libver_bounds_attributes(fapl); + } + + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + +} /* end test_libver_bounds_low_high() */ + +/**************************************************************** +** ** test_libver_macros(): ** Verify that H5_VERSION_GE and H5_VERSION_LE work correactly. ** @@ -5333,6 +6862,7 @@ test_file(void) test_filespace_round_compatible(); /* Testing file space compatibility for files from trunk to 1_8 to trunk */ test_filespace_1_10_0_compatible(); /* Testing file space compatibility for files from release 1.10.0 */ test_libver_bounds(); /* Test compatibility for file space management */ + test_libver_bounds_low_high(); test_libver_macros(); /* Test the macros for library version comparison */ test_libver_macros2(); /* Test the macros for library version comparison */ #ifndef H5_NO_DEPRECATED_SYMBOLS -- cgit v0.12 From ea4f752ace88b0a9931d6f806044d86fc652ecf7 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Mon, 27 Nov 2017 12:44:23 -0600 Subject: Adding data file generator Description: Added gen_bounds.c to generate the following files: - bounds_earliest_latest.h5 - bounds_earliest_v18.h5 - bounds_latest_latest.h5 - bounds_v18_latest.h5 - bounds_v18_v18.h5 for testing the version bounds fix in 1.8 and 1.6. --- test/gen_bounds.c | 626 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 626 insertions(+) create mode 100644 test/gen_bounds.c diff --git a/test/gen_bounds.c b/test/gen_bounds.c new file mode 100644 index 0000000..1de78e8 --- /dev/null +++ b/test/gen_bounds.c @@ -0,0 +1,626 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Oct 24, 2017 + * + * Purpose: This program is run to generate HDF5 data files used to test + * version bounds. + * + * Description + * =========== + * gen_bounds.c will generate the following files: + * - bounds_earliest_latest.h5 + * - bounds_earliest_v18.h5 + * - bounds_latest_latest.h5 + * - bounds_v18_latest.h5 + * - bounds_v18_v18.h5 + * + */ + +#include "hdf5.h" + +/*********************************************************************** + * gen_earliest_latest() creates file "bounds_earliest_latest.h5" + * + * File contents: + * - Version 0 superblock (default) + * - A chunked dataset with layout version 3, "DS_chunked_layout_3". (default) + * - A chunked dataset with layout version 4, "DS_chunked_layout_4". (H5Pset_chunk_opts) + * + ***********************************************************************/ +#define FILENAME_E_L "bounds_earliest_latest.h5" + +/* 2-D dataset with fixed dimensions */ +#define RANK 2 +#define DIM1 100 +#define DIM2 200 +#define CHUNK_DIM1 50 +#define CHUNK_DIM2 50 + +int gen_earliest_latest() +{ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CHUNK_DIM1, CHUNK_DIM2}; + float buf[DIM1][DIM2]; /* Buffer for writing data */ + int i, j; + + /* Create file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + goto error; + + /* Create file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + /* Set the "use the earliest/latest version of the format" bounds + for creating objects in the file */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) + goto error; + + /* Create file */ + if((fid = H5Fcreate(FILENAME_E_L, H5F_ACC_TRUNC, fcpl, fapl)) <0) + goto error; + + /* Close file property lists */ + if(H5Pclose(fapl) < 0) + goto error; + if(H5Pclose(fcpl) < 0) + goto error; + + /* + * Add a chunked dataset with layout version 3 (default) + */ + + /* Fill sample data */ + for (i = 0; i < DIM1; i++) + for (j = 0; j < DIM2; j++) + buf[i][j] = 100.0F; + + /* Create the dataspace */ + if((space = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; + + /* Create the dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + + /* Set up for chunked data */ + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + goto error; + + /* Create and write the dataset */ + if((dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + + /* Close property list and dataset, will reuse dataspace */ + if(H5Pclose(dcpl) < 0) + goto error; + if(H5Dclose(dset) < 0) + goto error; + + /* + * Add a chunked dataset with layout version 4 (H5Pset_chunk_opts) + */ + + /* Create the dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + + /* Set up for chunked data */ + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + goto error; + + /* Disable partial chunk filters, triggers layout version 4 */ + if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) + goto error; + + /* Create and write the dataset */ + if((dset = H5Dcreate2(fid, "DS_chunked_layout_4", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + + /* Close everything */ + if(H5Pclose(dcpl) < 0) + goto error; + if(H5Dclose(dset) < 0) + goto error; + if(H5Sclose(space) < 0) + goto error; + if(H5Fclose(fid) < 0) + goto error; + + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(dset); + H5Sclose(space); + H5Pclose(dcpl); + H5Pclose(fcpl); + H5Pclose(fapl); + H5Fclose(fid); + } H5E_END_TRY; + return 1; +} + +/*********************************************************************** + * gen_earliest_v18() creates file "bounds_earliest_v18.h5" + * + * File contents: + * - Version 0 superblock (default) + * - A chunked dataset with layout version 3, "DS_chunked_layout_3". (default) + * + ***********************************************************************/ +#define FILENAME_E_18 "bounds_earliest_v18.h5" + +int gen_earliest_v18() +{ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CHUNK_DIM1, CHUNK_DIM2}; + float buf[DIM1][DIM2]; /* Buffer for writing data */ + int i, j; + + /* Create file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + goto error; + + /* Create file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + /* Set the "use the earliest/v18 version of the format" bounds + for creating objects in the file */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_V18) < 0) + goto error; + + /* Create file */ + if((fid = H5Fcreate(FILENAME_E_18, H5F_ACC_TRUNC, fcpl, fapl)) <0) + goto error; + + /* Close file property lists */ + if(H5Pclose(fapl) < 0) + goto error; + if(H5Pclose(fcpl) < 0) + goto error; + + /* + * Add a chunked dataset with layout version 3 (default) + */ + + /* Fill sample data */ + for (i = 0; i < DIM1; i++) + for (j = 0; j < DIM2; j++) + buf[i][j] = 100.0F; + + /* Create the dataspace */ + if((space = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; + + /* Create the dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + + /* Set up for chunked data */ + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + goto error; + + /* Create and write the dataset */ + if((dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + + /* Close everything */ + if(H5Pclose(dcpl) < 0) + goto error; + if(H5Dclose(dset) < 0) + goto error; + if(H5Sclose(space) < 0) + goto error; + if(H5Fclose(fid) < 0) + goto error; + + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(dset); + H5Sclose(space); + H5Pclose(dcpl); + H5Pclose(fcpl); + H5Pclose(fapl); + H5Fclose(fid); + } H5E_END_TRY; + return 1; +} + +/*********************************************************************** + * gen_latest_latest() creates file "bounds_latest_latest.h5" + * + * File contents: + * - Version 3 superblock (H5Fcreate with H5F_ACC_SWMR_WRITE) + * - A chunked dataset with layout version 4, "DS_chunked_layout_4". (H5Pset_chunk_opts) + * + ***********************************************************************/ +#define FILENAME_L_L "bounds_latest_latest.h5" + +int gen_latest_latest() +{ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CHUNK_DIM1, CHUNK_DIM2}; + float buf[DIM1][DIM2]; /* Buffer for writing data */ + int i, j; + + /* Create file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + goto error; + + /* Create file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + /* Create file with H5F_ACC_SWMR_WRITE, triggers version 3 superblock */ + if((fid = H5Fcreate(FILENAME_L_L, H5F_ACC_SWMR_WRITE, fcpl, fapl)) <0) + goto error; + + /* Close file property lists */ + if(H5Pclose(fapl) < 0) + goto error; + if(H5Pclose(fcpl) < 0) + goto error; + + /* + * Add a chunked dataset with layout version 4 (H5Pset_chunk_opts) + */ + + /* Fill sample data */ + for (i = 0; i < DIM1; i++) + for (j = 0; j < DIM2; j++) + buf[i][j] = 100.0F; + + /* Create the dataspace */ + if((space = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; + + /* Create the dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + + /* Set up for chunked data */ + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + goto error; + + /* Disable partial chunk filters, triggers layout version 4 */ + if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) + goto error; + + /* Create and write the dataset */ + if((dset = H5Dcreate2(fid, "DS_chunked_layout_4", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + + /* Close everything */ + if(H5Pclose(dcpl) < 0) + goto error; + if(H5Dclose(dset) < 0) + goto error; + if(H5Sclose(space) < 0) + goto error; + if(H5Fclose(fid) < 0) + goto error; + + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(dset); + H5Sclose(space); + H5Pclose(dcpl); + H5Pclose(fcpl); + H5Pclose(fapl); + H5Fclose(fid); + } H5E_END_TRY; + return 1; +} + +/*********************************************************************** + * gen_v18_latest() creates file "bounds_v18_latest.h5" + * + * File contents: + * - Version 2 superblock (H5Pset_shared_mesg_index) + * - A chunked dataset with layout version 3, "DS_chunked_layout_3". (default) + * + ***********************************************************************/ +#define FILENAME_18_L "bounds_v18_latest.h5" + +int gen_v18_latest() +{ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CHUNK_DIM1, CHUNK_DIM2}; + float buf[DIM1][DIM2]; /* Buffer for writing data */ + int i, j; + + /* Create file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + goto error; + + /* Create file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + /* Set the "use the v18/latest version of the format" bounds + for creating objects in the file, also trigger version 2 superblock */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) + goto error; + + /* Create file */ + if((fid = H5Fcreate(FILENAME_18_L, H5F_ACC_TRUNC, fcpl, fapl)) <0) + goto error; + + /* Close file property lists */ + if(H5Pclose(fapl) < 0) + goto error; + if(H5Pclose(fcpl) < 0) + goto error; + + /* + * Add a chunked dataset with layout version 3 (default) + */ + + /* Fill sample data */ + for (i = 0; i < DIM1; i++) + for (j = 0; j < DIM2; j++) + buf[i][j] = 100.0F; + + /* Create the dataspace */ + if((space = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; + + /* Create the dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + + /* Set up for chunked data */ + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + goto error; + + /* Create and write the dataset */ + if((dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + + /* Close property list and dataset, will reuse dataspace */ + if(H5Pclose(dcpl) < 0) + goto error; + if(H5Dclose(dset) < 0) + goto error; + if(H5Sclose(space) < 0) + goto error; + if(H5Fclose(fid) < 0) + goto error; + + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(dset); + H5Sclose(space); + H5Pclose(dcpl); + H5Pclose(fcpl); + H5Pclose(fapl); + H5Fclose(fid); + } H5E_END_TRY; + return 1; +} + +/*********************************************************************** + * gen_v18_v18() creates file "bounds_v18_v18.h5" + * + * File contents: + * - Version 2 superblock (H5Pset_libver_bounds(v18, v18) + * - A chunked dataset with layout version 3, "DS_chunked_layout_3". (default) + * - A chunked dataset with layout version 4, "DS_chunked_layout_4". (H5Pset_chunk_opts) + * + ***********************************************************************/ +#define FILENAME_18_18 "bounds_v18_v18.h5" + +int gen_v18_v18() +{ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CHUNK_DIM1, CHUNK_DIM2}; + float buf[DIM1][DIM2]; /* Buffer for writing data */ + int i, j; + + /* Create file creation property list */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + goto error; + + /* Create file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + /* Set the "use the v18 version of the format" bounds + for creating objects in the file */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_V18) < 0) + goto error; + + /* Create file */ + if((fid = H5Fcreate(FILENAME_18_18, H5F_ACC_TRUNC, fcpl, fapl)) <0) + goto error; + + /* Close file property lists */ + if(H5Pclose(fapl) < 0) + goto error; + if(H5Pclose(fcpl) < 0) + goto error; + + /* + * Add a chunked dataset with layout version 3 (default) + */ + + /* Fill sample data */ + for (i = 0; i < DIM1; i++) + for (j = 0; j < DIM2; j++) + buf[i][j] = 100.0F; + + /* Create the dataspace */ + if((space = H5Screate_simple(RANK, dims, NULL)) < 0) + goto error; + + /* Create the dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + + /* Set up for chunked data */ + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + goto error; + + /* Create and write the dataset */ + if((dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + + /* Close property list and dataset, will reuse dataspace */ + if(H5Pclose(dcpl) < 0) + goto error; + if(H5Dclose(dset) < 0) + goto error; + + /* Close the file, then reopen it with the latest version */ + if(H5Fclose(fid) < 0) + goto error; + + /* Create file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + /* Set the "use the latest version of the format" bounds + for creating a layout version 4 object in the file */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) + goto error; + + if((fid = H5Fopen(FILENAME_18_18, H5F_ACC_RDWR, fapl)) < 0) + goto error; + + /* + * Add a chunked dataset with layout version 4 (H5Pset_chunk_opts) + */ + + /* Create the dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + + /* Set up for chunked data */ + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) + goto error; + + /* Disable partial chunk filters */ + if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) + goto error; + + /* Create and write the dataset */ + if((dset = H5Dcreate2(fid, "DS_chunked_layout_4", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto error; + if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto error; + + /* Close everything */ + if(H5Pclose(dcpl) < 0) + goto error; + if(H5Pclose(fapl) < 0) + goto error; + if(H5Dclose(dset) < 0) + goto error; + if(H5Sclose(space) < 0) + goto error; + if(H5Fclose(fid) < 0) + goto error; + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(dset); + H5Sclose(space); + H5Pclose(dcpl); + H5Pclose(fcpl); + H5Pclose(fapl); + H5Fclose(fid); + } H5E_END_TRY; + return 1; +} + +int main(void) +{ + /* Generate file bounds_earliest_latest.h5 */ + if (gen_earliest_latest() < 0) + goto error; + + /* Generate file bounds_earliest_v18.h5 */ + if (gen_earliest_v18() < 0) + goto error; + + /* Generate file bounds_latest_latest.h5 */ + if (gen_latest_latest() < 0) + goto error; + + /* Generate file bounds_v18_latest.h5 */ + if (gen_v18_latest() < 0) + goto error; + + /* Generate file bounds_v18_v18.h5 */ + if (gen_v18_v18() < 0) + goto error; + + return 0; + +error: + return 1; +} + -- cgit v0.12 From 742798b84e59b8ae346edd8d0acd9face7796051 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Mon, 27 Nov 2017 13:41:44 -0600 Subject: Fixed comment. --- test/gen_bounds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gen_bounds.c b/test/gen_bounds.c index 1de78e8..25db7e1 100644 --- a/test/gen_bounds.c +++ b/test/gen_bounds.c @@ -360,7 +360,7 @@ error: * gen_v18_latest() creates file "bounds_v18_latest.h5" * * File contents: - * - Version 2 superblock (H5Pset_shared_mesg_index) + * - Version 2 superblock * - A chunked dataset with layout version 3, "DS_chunked_layout_3". (default) * ***********************************************************************/ -- cgit v0.12 From daa0eb801561dc1831065e4c8c06d6cd68330200 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Mon, 27 Nov 2017 15:09:15 -0600 Subject: Further improvement --- test/gen_bounds.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/test/gen_bounds.c b/test/gen_bounds.c index 25db7e1..50b4acc 100644 --- a/test/gen_bounds.c +++ b/test/gen_bounds.c @@ -161,7 +161,7 @@ error: H5Fclose(fid); } H5E_END_TRY; return 1; -} +} /* gen_earliest_latest */ /*********************************************************************** * gen_earliest_v18() creates file "bounds_earliest_v18.h5" @@ -258,7 +258,7 @@ error: H5Fclose(fid); } H5E_END_TRY; return 1; -} +} /* gen_earliest_v18 */ /*********************************************************************** * gen_latest_latest() creates file "bounds_latest_latest.h5" @@ -273,8 +273,6 @@ error: int gen_latest_latest() { hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t fcpl = -1; /* File creation property list ID */ hid_t dcpl = -1; /* Dataset creation property list ID */ hid_t space = -1; /* Dataspace ID */ hid_t dset = -1; /* Dataset ID */ @@ -283,22 +281,8 @@ int gen_latest_latest() float buf[DIM1][DIM2]; /* Buffer for writing data */ int i, j; - /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - goto error; - - /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; - /* Create file with H5F_ACC_SWMR_WRITE, triggers version 3 superblock */ - if((fid = H5Fcreate(FILENAME_L_L, H5F_ACC_SWMR_WRITE, fcpl, fapl)) <0) - goto error; - - /* Close file property lists */ - if(H5Pclose(fapl) < 0) - goto error; - if(H5Pclose(fcpl) < 0) + if((fid = H5Fcreate(FILENAME_L_L, H5F_ACC_SWMR_WRITE, H5P_DEFAULT, H5P_DEFAULT)) <0) goto error; /* @@ -349,12 +333,10 @@ error: H5Dclose(dset); H5Sclose(space); H5Pclose(dcpl); - H5Pclose(fcpl); - H5Pclose(fapl); H5Fclose(fid); } H5E_END_TRY; return 1; -} +} /* gen_latest_latest */ /*********************************************************************** * gen_v18_latest() creates file "bounds_v18_latest.h5" @@ -451,7 +433,7 @@ error: H5Fclose(fid); } H5E_END_TRY; return 1; -} +} /* gen_v18_latest */ /*********************************************************************** * gen_v18_v18() creates file "bounds_v18_v18.h5" @@ -541,7 +523,7 @@ int gen_v18_v18() if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - /* Set the "use the latest version of the format" bounds + /* Set the "use the v18/latest version of the format" bounds for creating a layout version 4 object in the file */ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) goto error; @@ -594,7 +576,7 @@ error: H5Fclose(fid); } H5E_END_TRY; return 1; -} +} /* gen_v18_v18 */ int main(void) { -- cgit v0.12 From 37318f109a294bb47e5040be5888963967c1badc Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Fri, 12 Jan 2018 14:36:03 -0600 Subject: Changes made based on code reviews. --- src/H5Aint.c | 17 +- src/H5Dint.c | 25 +- src/H5Dlayout.c | 19 +- src/H5F.c | 18 +- src/H5Fdeprec.c | 62 ++ src/H5Fint.c | 36 +- src/H5Fprivate.h | 1 + src/H5Fpublic.h | 3 +- src/H5Fquery.c | 11 +- src/H5Fsuper.c | 87 ++- src/H5Gobj.c | 12 +- src/H5Oattr.c | 2 + src/H5Ocopy.c | 6 + src/H5Odtype.c | 2 + src/H5Ofill.c | 22 +- src/H5Oint.c | 22 +- src/H5Olayout.c | 5 +- src/H5Opkg.h | 8 +- src/H5Opline.c | 19 +- src/H5Oprivate.h | 6 +- src/H5Osdspace.c | 2 + src/H5S.c | 15 +- src/H5T.c | 5 +- src/H5trace.c | 3 +- test/genall5.c | 8 +- test/mf.c | 10 +- test/tfile.c | 2236 +++++++++++++++++++++++++++++------------------------- 27 files changed, 1534 insertions(+), 1128 deletions(-) diff --git a/src/H5Aint.c b/src/H5Aint.c index 5c32e86..666f11d 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -1863,6 +1863,7 @@ herr_t H5A_set_version(const H5F_t *f, H5A_t *attr) { hbool_t type_shared, space_shared; /* Flags to indicate that shared messages are used for this attribute */ + uint8_t version; /* Message version */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1884,18 +1885,22 @@ H5A_set_version(const H5F_t *f, H5A_t *attr) /* Check which version to encode attribute with */ if(attr->shared->encoding != H5T_CSET_ASCII) - attr->shared->version = H5O_ATTR_VERSION_3; /* Write version which includes the character encoding */ + version = H5O_ATTR_VERSION_3; /* Write version which includes the character encoding */ else if(type_shared || space_shared) - attr->shared->version = H5O_ATTR_VERSION_2; /* Write out version with flag for indicating shared datatype or dataspace */ + version = H5O_ATTR_VERSION_2; /* Write out version with flag for indicating shared datatype or dataspace */ else - attr->shared->version = H5O_ATTR_VERSION_1; /* Write out basic version */ + version = H5O_ATTR_VERSION_1; /* Write out basic version */ /* Upgrade to the version indicated by the file's low bound if higher */ - attr->shared->version = MAX(attr->shared->version, (uint8_t)H5O_attr_ver_bounds[H5F_LOW_BOUND(f)]); + version = MAX(version, (uint8_t)H5O_attr_ver_bounds[H5F_LOW_BOUND(f)]); - /* File bound check */ - if(attr->shared->version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(f)]) + /* Version bounds check */ + if(version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_ATTR, H5E_BADRANGE, FAIL, "attribute version out of bounds") + + /* Set the message version */ + attr->shared->version = version; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_set_version() */ diff --git a/src/H5Dint.c b/src/H5Dint.c index c1a66ca..89dff1e 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -623,10 +623,10 @@ done: static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) { - htri_t relocatable; /* Flag whether the type is relocatable */ - htri_t immutable; /* Flag whether the type is immutable */ - hbool_t use_v18_latest_format; /* Flag indicating the 'latest datatype version support' is enabled */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t relocatable; /* Flag whether the type is relocatable */ + htri_t immutable; /* Flag whether the type is immutable */ + hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -643,10 +643,11 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) if((immutable = H5T_is_immutable(type)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't check datatype?") - use_v18_latest_format = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18); + /* To use at least v18 format versions or not */ + use_at_least_v18 = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18); /* Copy the datatype if it's a custom datatype or if it'll change when it's location is changed */ - if(!immutable || relocatable || use_v18_latest_format) { + if(!immutable || relocatable || use_at_least_v18) { /* Copy datatype for dataset */ if((dset->shared->type = H5T_copy(type, H5T_COPY_ALL)) == NULL) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy datatype") @@ -786,6 +787,7 @@ H5D__update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) H5D_fill_value_t fill_status; /* Fill value status */ hbool_t fill_changed = FALSE; /* Flag indicating the fill value was changed */ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ + hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -800,6 +802,9 @@ H5D__update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) type = dset->shared->type; fill_prop = &dset->shared->dcpl_cache.fill; + /* To use at least v18 format versions or not */ + use_at_least_v18 = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18); + /* Retrieve "defined" status of fill value */ if(H5P_is_fill_value_defined(fill_prop, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") @@ -878,8 +883,8 @@ H5D__update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update new fill value header message") /* If there is valid information for the old fill value struct, add it */ - /* (only if we aren't trying to write the 'latest fill message version support') */ - if(fill_prop->buf && (H5F_LOW_BOUND(file) < H5F_LIBVER_V18)) { + /* (only if we aren't using v18 format versions and above */ + if(fill_prop->buf && !use_at_least_v18) { H5O_fill_t old_fill_prop; /* Copy of fill value property, for writing as "old" fill value */ /* Shallow copy the fill value property */ @@ -931,10 +936,10 @@ H5D__update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) #endif /* H5O_ENABLE_BOGUS */ /* Add a modification time message, if using older format. */ - /* (If using the latest 'no modification time message' version support, the modification time is part of the object + /* (If using v18 format versions and above, the the modification time is part of the object * header and doesn't use a separate message -QAK) */ - if(H5F_LOW_BOUND(file) < H5F_LIBVER_V18) + if(!use_at_least_v18) if(H5O_touch_oh(file, dxpl_id, oh, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time message") diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 5a4d537..980b810 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -46,9 +46,10 @@ /* Package Variables */ /*********************/ +/* Format version bounds for layout */ const unsigned H5O_layout_ver_bounds[] = { H5O_LAYOUT_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_LAYOUT_VERSION_3, /* H5F_LIBVER_V18 */ + H5O_LAYOUT_VERSION_3, /* H5F_LIBVER_V18 */ /* H5O_LAYOUT_VERSION_DEFAULT */ H5O_LAYOUT_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; @@ -289,16 +290,15 @@ done: * * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, January 15, 2009 + * Programmer: Vailin Choi; December 2017 * *------------------------------------------------------------------------- */ herr_t H5D__layout_set_version(H5F_t *f, H5O_layout_t *layout) { - unsigned vers; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -307,12 +307,15 @@ H5D__layout_set_version(H5F_t *f, H5O_layout_t *layout) HDassert(f); /* Upgrade to the version indicated by the file's low bound if higher */ - layout->version = MAX(layout->version, H5O_layout_ver_bounds[H5F_LOW_BOUND(f)]); + version = MAX(layout->version, H5O_layout_ver_bounds[H5F_LOW_BOUND(f)]); - /* File bound check */ - if(layout->version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(f)]) + /* Version bounds check */ + if(version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "layout version out of bounds") + /* Set the message version */ + layout->version = version; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_set_version() */ diff --git a/src/H5F.c b/src/H5F.c index c670e17..8e5f65a 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -1478,6 +1478,8 @@ H5Fstart_swmr_write(hid_t file_id) if(file->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file superblock version should be at least 3") + HDassert((file->shared->low_bound == H5F_LIBVER_V110) && (file->shared->high_bound == H5F_LIBVER_V110)); + /* Should not be marked for SWMR writing mode already */ if(file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file already in SWMR writing mode") @@ -1739,9 +1741,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fset_libver_bounds (Internal library use) + * Function: H5Fset_libver_bounds * - * Purpose: Set .... the "latest format" flag while a file is open. + * Purpose: Set to a different low and high bounds while a file is open. + * This public routine is introduced in place of + * H5Fset_latest_format() starting release 1.10.2. + * See explanation for H5Fset_latest_format() in H5Fdeprec.c. * * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- @@ -1759,12 +1764,9 @@ H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high) if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID") - /* Call the flush routine, for this file */ - if(H5F__flush(f, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") - - f->shared->low_bound = low; - f->shared->high_bound = high; + /* Call private set_libver_bounds function */ + if(H5F_set_libver_bounds(f, low, high) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index 03f5df8..a9ffa43 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -143,5 +143,67 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_info1() */ + +/*------------------------------------------------------------------------- + * Function: H5Fset_latest_format + * + * Purpose: Enable switching between latest or non-latest format while + * a file is open. + * This is deprecated starting release 1.10.2 and is modified + * to call the private H5F_set_libver_bounds() to set the + * bounds. + * + * Before release 1.10.2, the library supports only two + * combinations of low/high bounds: + * (earliest, latest) + * (latest, latest) + * Thus, this public routine does the job in switching + * between the two combinations listed above. + * + * Starting release 1.10.2, we add v18 to the enumerated + * define H5F_libver_t and the library supports five combinations + * as below: + * (earliest, v18) + * (earliest, v10) + * (v18, v18) + * (v18, v10) + * (v10, v10) + * So we introduce the new public routine H5Fset_libver_bounds() + * in place of H5Fset_latest_format(). + * See also RFC: Setting Bounds for Object Creation in HDF5 1.10.0. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi; December 2017 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Fset_latest_format(hid_t file_id, hbool_t latest_format) +{ + H5F_t *f; /* File */ + H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ + H5F_libver_t high = H5F_LIBVER_LATEST; /* High bound */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ib", file_id, latest_format); + + /* Check args */ + if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID") + + /* 'low' and 'high' are both initialized to LATEST. + If latest format is not expected, set 'low' to EARLIEST */ + if(!latest_format) + low = H5F_LIBVER_EARLIEST; + + /* Call private set_libver_bounds function to set the bounds */ + if(H5F_set_libver_bounds(f, low, high) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Fset_latest_format() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Fint.c b/src/H5Fint.c index f223195..79f0d06 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -671,9 +671,9 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, &(f->shared->mdc_initCacheImageCfg)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get initial metadata cache resize config") - /* File format version high bound does not allow the generation of metadata cache image */ + /* Format version high bound does not allow the generation of metadata cache image */ if(f->shared->mdc_initCacheImageCfg.generate_image && f->shared->high_bound < H5F_LIBVER_V110) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "file format version out of bound for cache image") + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "format version out of bound for cache image") /* Get the VFD values to cache */ f->shared->maxaddr = H5FD_get_maxaddr(lf); @@ -2313,6 +2313,38 @@ H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_store_msg_crt_idx() */ +/*------------------------------------------------------------------------- + * Function: H5F_set_libver_bounds() + * + * Purpose: Set the file's low and high bound to the input parameters + * 'low' and 'high' respectively. + * This is done only if the existing setting is different + * from the inputs. + * + * Return: SUCCEED on success, and FAIL on failure. + * + * Programmer: Vailin Choi; December 2017 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_set_libver_bounds(H5F_t * f, H5F_libver_t low, H5F_libver_t high) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + + /* Set the bounds only if the existing setting is different from the inputs */ + if(f->shared->low_bound != low || f->shared->high_bound != high) { + f->shared->low_bound = low; + f->shared->high_bound = high; + } + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5F_set_libver_bounds() */ + /*------------------------------------------------------------------------- * Function: H5F_get_file_image diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 50325bb..ec98468 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -769,6 +769,7 @@ H5_DLL unsigned H5F_gc_ref(const H5F_t *f); H5_DLL unsigned H5F_use_latest_flags(const H5F_t *f, unsigned fl); H5_DLL hbool_t H5F_store_msg_crt_idx(const H5F_t *f); H5_DLL herr_t H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag); +H5_DLL herr_t H5F_set_libver_bounds(H5F_t * f, H5F_libver_t low, H5F_libver_t high); H5_DLL struct H5UC_t *H5F_grp_btree_shared(const H5F_t *f); H5_DLL herr_t H5F_set_grp_btree_shared(H5F_t *f, struct H5UC_t *rc); H5_DLL hbool_t H5F_use_tmp_space(const H5F_t *f); diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 9364ee2..d333fa7 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -173,7 +173,7 @@ typedef struct H5F_sect_info_t { hsize_t size; /* Size of free space section */ } H5F_sect_info_t; -/* Library's file format versions */ +/* Library's format versions */ typedef enum H5F_libver_t { H5F_LIBVER_ERROR = -1, H5F_LIBVER_EARLIEST = 0, /* Use the earliest possible format for storing objects */ @@ -300,6 +300,7 @@ typedef struct H5F_info1_t { /* Function prototypes */ H5_DLL herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo); +H5_DLL herr_t H5Fset_latest_format(hid_t file_id, hbool_t latest_format); #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 6b641f1..5d7de9d 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -716,9 +716,14 @@ H5F_sieve_buf_size(const H5F_t *f) * Purpose: Replaced a macro to retrieve the "garbage collect * references flag" now that the generic properties are being used * to store the values. - e - * is returned. - * Failure: (should not happen) + * + * Return: Success: The "garbage collect references flag" is returned. + * Failure: (should not happen) + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Jul 8 2005 + * *------------------------------------------------------------------------- */ unsigned diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 4c12cb9..d30434d 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -457,23 +457,46 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, meta_dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, &udata, rw_flags))) HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "unable to load superblock") - /* Upgrade low bound to at least V18 when encountering version 2 superblock */ + /* + * When opening a file with SWMR-write access, the library will first + * check to ensure that superblock version 3 is used. Otherwise fail + * file open. + * + * Then the library will upgrade the file's low_bound depending on + * superblock version as follows: + * --version 0 or 1: no change to low_bound + * --version 2: upgrade low_bound to at least V18 + * --version 3: upgrade low_bound to at least V110 + * + * Upgrading low_bound will give the best format versions available for + * that superblock version. Due to the possible upgrade, the fapl returned + * from H5Fget_access_plist() might indicate a low_bound higher than what + * the user originally set. + * + * After upgrading low_bound, the library will check to ensure that the + * superblock version does not exceed the version allowed by high_bound. + * Otherise fail file open. + * + * For details, please see RFC:Setting Bounds for Object Creation in HDF5 1.10.0. + */ + + /* Check to ensure that superblock version 3 is used for SWMR-write access */ + if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { + if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version for SWMR is less than 3") + } + + /* Upgrade low_bound to at least V18 when encountering version 2 superblock */ if(sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2) f->shared->low_bound = MAX(H5F_LIBVER_V18, f->shared->low_bound); - /* Upgrade low bound to at least V110 when encountering version 3 superblock or SWMR_WRITE */ - if((sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) || (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE)) + /* Upgrade low_bound to at least V110 when encountering version 3 superblock */ + if(sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) f->shared->low_bound = MAX(H5F_LIBVER_V110, f->shared->low_bound); - /* File bound check */ + /* Version bounds check */ if(sblock->super_vers > HDF5_superblock_ver_bounds[f->shared->high_bound]) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version out of bounds (high bound)") - - /* SWMR requires at least superblock version 3 */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { - if(sblock->super_vers < HDF5_superblock_ver_bounds[f->shared->low_bound]) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version out of bounds (low bound)") - } + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version exceeds high bound") /* Pin the superblock in the cache */ if(H5AC_pin_protected_entry(sblock) < 0) @@ -833,9 +856,9 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial hbool_t rw = ((rw_flags & H5AC__READ_ONLY_FLAG) == 0); H5O_mdci_t mdci_msg; - /* Message exists but file format version high bound does not allow it */ + /* Message exists but version high bound does not allow it */ if(f->shared->high_bound < H5F_LIBVER_V110) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file format version out of bound for metadata cache image") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "format version out of bound for metadata cache image") /* if the metadata cache image superblock extension message exists, * read its contents and pass the data on to the metadata cache. @@ -1037,6 +1060,36 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) non_default_fs_settings = TRUE; + /* + * When creating a file with write access, the library will: + * -- set superblock version to 0, 1 or 2 based on feature enabled + * -- no change to low_bound + * When creating a file with SWMR-write access, the library will: + * (See explanation (#) below.) + * -- set superblock version to 3 + * -- upgrade low_bound to at least V110 + * + * Then the library will finalize superblock version to that allowed by + * low_bound if that is higher. + * Lastly, the library will check to ensure the superblock version does not + * exceed the version allowed by high_bound. Otherwise fail file open. + * + * For details, please see RFC:Setting Bounds for Object Creation in HDF5 1.10.0. + * + * (#) + * Version 3 superblock is introduced in 1.10 for SWMR due to the problem of + * the status_flags field in the superblock. The problem is discussed in + * jira issue SWMR-79 and also in the RFC: File Format Changes in HDF5 1.10.0. + * The file's low_bound is upgraded for SWMR so that the library will + * use the best format versions available in 1.10. + * Due to the possible upgrade, the fapl returned from H5Fget_access_plist() + * might indicate a low_bound higher than what the user originally set. + */ + + /* + * Creating a file with SWMR-write access will + * upgrade superblock version and low_bound + */ if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { super_vers = HDF5_SUPERBLOCK_VERSION_3; f->shared->low_bound = MAX(H5F_LIBVER_V110, f->shared->low_bound); @@ -1060,10 +1113,10 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) else if(sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF) super_vers = HDF5_SUPERBLOCK_VERSION_1; - /* Upgrade to the version indicated by the file's low bound if higher */ + /* Finalize superblock version to that allowed by the file's low bound if higher */ super_vers = MAX(super_vers, HDF5_superblock_ver_bounds[f->shared->low_bound]); - /* File bound check */ + /* Version bounds check */ if(super_vers > HDF5_superblock_ver_bounds[f->shared->high_bound]) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version out of bounds") @@ -1091,8 +1144,8 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) /* Sanity check the userblock size vs. the file's allocation alignment */ if(userblock_size > 0) { - /* Set up the alignment to use for page or aggr fs */ - hsize_t alignment = H5F_PAGED_AGGR(f) ? f->shared->fs_page_size : f->shared->alignment; + /* Set up the alignment to use for page or aggr fs */ + hsize_t alignment = H5F_PAGED_AGGR(f) ? f->shared->fs_page_size : f->shared->alignment; if(userblock_size < alignment) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be > file object alignment") diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 832c9a7..5f9bdc8 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -185,7 +185,7 @@ H5G__obj_create_real(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc/*out*/) { size_t hdr_size; /* Size of object header to request */ - hbool_t use_v18_latest_format; /* Flag indicating the new group format should be used */ + hbool_t use_at_least_v18; /* Flag indicating the new group format should be used */ hid_t gcpl_id = gcrt_info->gcpl_id; /* Group creation property list ID */ herr_t ret_value = SUCCEED; /* Return value */ @@ -204,12 +204,12 @@ H5G__obj_create_real(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file") - /* Check for using the latest version of the group format */ + /* Check for using the latest version of the group format which is introduced in v18 */ /* (add more checks for creating "new format" groups when needed) */ if((H5F_LOW_BOUND(f) >= H5F_LIBVER_V18) || linfo->track_corder || (pline && pline->nused)) - use_v18_latest_format = TRUE; + use_at_least_v18 = TRUE; else - use_v18_latest_format = FALSE; + use_at_least_v18 = FALSE; /* Make certain that the creation order is being tracked if an index is * going to be built on it. @@ -218,7 +218,7 @@ H5G__obj_create_real(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "must track creation order to create index for it") /* Check if we should be using the latest version of the group format */ - if(use_v18_latest_format) { + if(use_at_least_v18) { H5O_link_t lnk; /* Temporary link message info for computing message size */ char null_char = '\0'; /* Character for creating null string */ size_t ginfo_size; /* Size of the group info message */ @@ -264,7 +264,7 @@ H5G__obj_create_real(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header") /* Check for format of group to create */ - if(use_v18_latest_format) { + if(use_at_least_v18) { /* Insert link info message */ /* (Casting away const OK - QAK) */ if(H5O_msg_create(oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, (void *)linfo, dxpl_id) < 0) diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 5c45e82..773a16b 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -635,6 +635,8 @@ H5O_attr_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *native_src, HDassert(cpy_info); HDassert(cpy_info->file_dst); + /* Check to ensure that the version of the message to be copied does not exceed + the message version allowed by the destination file's high bound */ if(attr_src->shared->version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "attribute message version out of bounds") diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index aa26f05..74c02f4 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -416,6 +416,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Initialize header information */ oh_dst->version = oh_src->version; + /* Version bounds check for destination object header */ if(oh_dst->version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(oloc_dst->file)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "destination object header version out of bounds") @@ -494,7 +495,12 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Decode the message if necessary. */ H5O_LOAD_NATIVE(oloc_src->file, dxpl_id, 0, oh_src, mesg_src, FAIL) + /* Save destination file pointer in cpy_info so that it can be used + in the pre_copy_file callback to obtain the destination file's + high bound. The high bound is used to index into the corresponding + message's array of versions for doing version bounds check. */ cpy_info->file_dst = oloc_dst->file; + /* Perform "pre copy" operation on message */ if((copy_type->pre_copy_file)(oloc_src->file, mesg_src->native, &(deleted[mesgno]), cpy_info, cpy_udata) < 0) diff --git a/src/H5Odtype.c b/src/H5Odtype.c index f6331df..c51e31d 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -1531,6 +1531,8 @@ H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, HDassert(cpy_info); HDassert(cpy_info->file_dst); + /* Check to ensure that the version of the message to be copied does not exceed + the message version as indicated by the destination file's high bound */ if(dt_src->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "datatype message version out of bounds") diff --git a/src/H5Ofill.c b/src/H5Ofill.c index cf64594..6dc3064 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -156,7 +156,7 @@ const H5O_msg_class_t H5O_MSG_FILL_NEW[1] = {{ /* Format version bounds for fill value */ const unsigned H5O_fill_ver_bounds[] = { H5O_FILL_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_FILL_VERSION_3, /* H5F_LIBVER_V18 */ + H5O_FILL_VERSION_2, /* H5F_LIBVER_V18 */ H5O_FILL_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; @@ -809,8 +809,7 @@ H5O_fill_free(void *fill) * Return: Success: Non-negative * Failure: Negative * - * Programmer: Quincey Koziol - * Friday, March 9, 2007 + * Programmer: Vailin Choi; Dec 2017 * *------------------------------------------------------------------------- */ @@ -827,6 +826,8 @@ H5O_fill_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, HDassert(cpy_info); HDassert(cpy_info->file_dst); + /* Check to ensure that the version of the message to be copied does not exceed + the message version allowed by the destination file's high bound */ if(fill_src->version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "fill value message version out of bounds") @@ -1047,15 +1048,15 @@ done: * * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Tuesday, July 24, 2007 + * Programmer: Vailin Choi; December 2017 * *------------------------------------------------------------------------- */ herr_t H5O_fill_set_version(H5F_t *f, H5O_fill_t *fill) { - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1064,12 +1065,15 @@ H5O_fill_set_version(H5F_t *f, H5O_fill_t *fill) HDassert(fill); /* Upgrade to the version indicated by the file's low bound if higher */ - fill->version = MAX(fill->version, H5O_fill_ver_bounds[H5F_LOW_BOUND(f)]); + version = MAX(fill->version, H5O_fill_ver_bounds[H5F_LOW_BOUND(f)]); - /* File bound check */ - if(fill->version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(f)]) + /* Version bounds check */ + if(version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "Filter pipeline version out of bounds") + /* Set the message version */ + fill->version = version; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_set_version() */ diff --git a/src/H5Oint.c b/src/H5Oint.c index 0df7467..08eb28d 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -216,18 +216,17 @@ H5O__init_package(void) * Chooses the oldest version possible, unless the file's * low bound indicates otherwise. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Jul 17 2007 + * Programmer: Vailin Choi; December 2017 * *------------------------------------------------------------------------- */ static herr_t H5O_set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx) { + uint8_t version; /* Message version */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -238,17 +237,20 @@ H5O_set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx /* Set the correct version to encode object header with */ if(store_msg_crt_idx || (oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) - oh->version = H5O_VERSION_2; + version = H5O_VERSION_LATEST; else - oh->version = H5O_VERSION_1; + version = H5O_VERSION_1; /* Upgrade to the version indicated by the file's low bound if higher */ - oh->version = MAX(oh->version, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(f)]); + version = MAX(version, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(f)]); - /* File bound check */ - if(oh->version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(f)]) + /* Version bounds check */ + if(version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "object header version out of bounds") + /* Set the message version */ + oh->version = version; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_set_version() */ diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 3745f6d..85d7791 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -1055,8 +1055,7 @@ done: * Return: Success: Non-negative * Failure: Negative * - * Programmer: Quincey Koziol - * Friday, March 9, 2007 + * Programmer: Vailin Choi; Dec 2017 * *------------------------------------------------------------------------- */ @@ -1073,6 +1072,8 @@ H5O__layout_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, HDassert(cpy_info); HDassert(cpy_info->file_dst); + /* Check to ensure that the version of the message to be copied does not exceed + the message version allowed by the destination file's high bound */ if(layout_src->version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "layout message version out of bounds") diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 13e0e3e..498938a 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -63,8 +63,8 @@ ) #define H5O_ALIGN_OH(O, X) \ H5O_ALIGN_VERS((O)->version, X) -#define H5O_ALIGN_F(F, X) \ - H5O_ALIGN_VERS(((H5F_LOW_BOUND(F) >= H5F_LIBVER_V18) ? H5O_VERSION_LATEST : H5O_VERSION_1), X) +#define H5O_ALIGN_F(F, X) \ + H5O_ALIGN_VERS(MAX(H5O_VERSION_1, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(F)]), X) /* Size of checksum (on disk) */ #define H5O_SIZEOF_CHKSUM 4 @@ -136,7 +136,7 @@ #define H5O_SIZEOF_MSGHDR_OH(O) \ H5O_SIZEOF_MSGHDR_VERS((O)->version, (O)->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) #define H5O_SIZEOF_MSGHDR_F(F, C) \ - H5O_SIZEOF_MSGHDR_VERS(((H5F_LOW_BOUND(F) >= H5F_LIBVER_V18) || H5F_STORE_MSG_CRT_IDX(F)) ? H5O_VERSION_LATEST : H5O_VERSION_1, (C)) + H5O_SIZEOF_MSGHDR_VERS(MAX((H5F_STORE_MSG_CRT_IDX(F) ? H5O_VERSION_LATEST : H5O_VERSION_1), (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(F)]), (C)) /* * Size of chunk "header" for each chunk @@ -641,6 +641,8 @@ H5_DLL herr_t H5O_attr_link(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg H5_DLL herr_t H5O_attr_count_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hsize_t *nattrs); +/* Arrays of versions for: + Object header, Layout/Attribute/Datatype/Fill value/Filter pipeline/Dataspace messages */ H5_DLLVAR const unsigned H5O_obj_ver_bounds[H5F_LIBVER_NBOUNDS]; H5_DLLVAR const unsigned H5O_layout_ver_bounds[H5F_LIBVER_NBOUNDS]; H5_DLLVAR const unsigned H5O_attr_ver_bounds[H5F_LIBVER_NBOUNDS]; diff --git a/src/H5Opline.c b/src/H5Opline.c index ea913da..e817f9a 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -576,7 +576,7 @@ H5O_pline_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, { const H5O_pline_t *pline_src = (const H5O_pline_t *)mesg_src; /* Source pline */ H5O_copy_file_ud_common_t *udata = (H5O_copy_file_ud_common_t *)_udata; /* Object copying user data */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -585,6 +585,8 @@ H5O_pline_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, HDassert(cpy_info); HDassert(cpy_info->file_dst); + /* Check to ensure that the version of the message to be copied does not exceed + the message version allowed by the destination file's high bound */ if(pline_src->version > H5O_pline_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "pline message version out of bounds") @@ -681,15 +683,15 @@ H5O_pline_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const voi * * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Tuesday, July 24, 2007 + * Programmer: Vailin Choi; December 2017 * *------------------------------------------------------------------------- */ herr_t H5O_pline_set_version(H5F_t *f, H5O_pline_t *pline) { - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -698,12 +700,15 @@ H5O_pline_set_version(H5F_t *f, H5O_pline_t *pline) HDassert(pline); /* Upgrade to the version indicated by the file's low bound if higher */ - pline->version = MAX(pline->version, H5O_pline_ver_bounds[H5F_LOW_BOUND(f)]); + version = MAX(pline->version, H5O_pline_ver_bounds[H5F_LOW_BOUND(f)]); - /* File bound check */ - if(pline->version > H5O_pline_ver_bounds[H5F_HIGH_BOUND(f)]) + /* Version bounds check */ + if(version > H5O_pline_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_PLINE, H5E_BADRANGE, FAIL, "Filter pipeline version out of bounds") + /* Set the message version */ + pline->version = version; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_pline_set_version() */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 5cf9dce..2253bb2 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -178,7 +178,11 @@ typedef struct H5O_copy_t { hbool_t dst_dt_list_complete; /* Whether the destination datatype list is complete (i.e. not only populated with "suggestions" from H5Padd_merge_committed_dtype_path) */ H5O_t *oh_dst; /* The destination object header */ H5F_t *file_dst; /* The destination file pointer */ - void *shared_fo; /* The shared pointer for the object */ + /* This is used in the pre_copy_file callback to obtain + the destination file's high bound. The high bound + is used to index into the corresponding message's + array of versions for doing version bounds check. */ + void *shared_fo; /* The shared pointer for the src object */ H5O_mcdt_search_cb_t mcdt_cb; /* The callback to invoke before searching the global list of committed datatypes at destination */ void *mcdt_ud; /* User data passed to callback */ } H5O_copy_t; diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 9a9d020..12a9bb6 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -455,6 +455,8 @@ H5O_sdspace_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, HDassert(cpy_info); HDassert(cpy_info->file_dst); + /* Check to ensure that the version of the message to be copied does not exceed + the message version allowed by the destination file's high bound */ if(src_space_extent->version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "dataspace message version out of bounds") diff --git a/src/H5S.c b/src/H5S.c index 8046357..8f3e132 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -2180,15 +2180,15 @@ H5S_extent_nelem(const H5S_extent_t *ext) * * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Tuesday, July 24, 2007 + * Programmer: Vailin Choi; December 2017 * *------------------------------------------------------------------------- */ herr_t H5S_set_version(H5F_t *f, H5S_t *ds) { - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2197,12 +2197,15 @@ H5S_set_version(H5F_t *f, H5S_t *ds) HDassert(ds); /* Upgrade to the version indicated by the file's low bound if higher */ - ds->extent.version = MAX(ds->extent.version, H5O_sdspace_ver_bounds[H5F_LOW_BOUND(f)]); + version = MAX(ds->extent.version, H5O_sdspace_ver_bounds[H5F_LOW_BOUND(f)]); - /* File bound check */ - if(ds->extent.version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(f)]) + /* Version bounds check */ + if(version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "Dataspace version out of bounds") + /* Set the message version */ + ds->extent.version = version; + done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5T.c b/src/H5T.c index aa61358..eca0132 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -5418,8 +5418,7 @@ done: * * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, July 19, 2007 + * Programmer: Vailin Choi; December 2017 * *------------------------------------------------------------------------- */ @@ -5442,7 +5441,7 @@ H5T_set_version(H5F_t *f, H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade datatype encoding") } - /* File bound check */ + /* Version bounds check */ if(dt->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_DATATYPE, H5E_BADRANGE, FAIL, "Datatype version out of bounds") diff --git a/src/H5trace.c b/src/H5trace.c index 5f8ccd1..b1f05ba 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -1021,7 +1021,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) fprintf(out, "H5F_LIBVER_V18"); break; - case H5F_LIBVER_LATEST: + case H5F_LIBVER_V110: + HDassert(H5F_LIBVER_LATEST == H5F_LIBVER_V110); fprintf(out, "H5F_LIBVER_LATEST"); break; diff --git a/test/genall5.c b/test/genall5.c index 0ac1515..e3a9c96 100644 --- a/test/genall5.c +++ b/test/genall5.c @@ -1264,7 +1264,7 @@ os_grp_0(hid_t fid, const char *group_name) HDassert(fapl > 0); } - if ( pass ) { /* get libver_bounds from fapl */ + if ( pass ) { /* get low and high bounds from fapl */ ret = H5Pget_libver_bounds(fapl, &low, &high); if ( ret < 0 ) { @@ -1312,7 +1312,7 @@ os_grp_0(hid_t fid, const char *group_name) HDassert(ret >= 0); } - if ( pass ) { /* restore libver_bounds */ + if ( pass ) { /* restore low and high bounds */ if(low >= H5F_LIBVER_V18) { ret = H5Fset_libver_bounds(fid, low, high); @@ -1504,7 +1504,7 @@ os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) HDassert(fapl > 0); } - if ( pass ) { /* get libver_bounds from fapl */ + if ( pass ) { /* get low and high bounds from fapl */ ret = H5Pget_libver_bounds(fapl, &low, &high); if ( ret < 0 ) { @@ -1590,7 +1590,7 @@ os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) assert(ret >= 0); } - if ( pass ) { /* restore libver_bounds */ + if ( pass ) { /* restore low and high bounds */ if(low >= H5F_LIBVER_V18) { ret = H5Fset_libver_bounds(fid, low, high); diff --git a/test/mf.c b/test/mf.c index 289f04a..35dfab3 100644 --- a/test/mf.c +++ b/test/mf.c @@ -6920,6 +6920,7 @@ test_mf_fs_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) H5FD_mem_t type; /* File allocation type */ H5FS_stat_t fs_stat; /* Information for free-space manager */ haddr_t addr1, addr2, addr3, addr4; /* File address for H5FD_MEM_SUPER */ + haddr_t addrx; H5FD_mem_t fs_type; hbool_t contig_addr_vfd; hbool_t ran_H5MF_tidy_self_referential_fsm_hack = FALSE; @@ -7054,6 +7055,12 @@ test_mf_fs_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) if(H5MF_xfree(f, type, H5AC_ind_read_dxpl_id, addr4, (hsize_t)TBLOCK_SIZE4) < 0) FAIL_STACK_ERROR + if(!new_format) { + /* Need to take up this space so that the free-space manager will go away */ + if(HADDR_UNDEF == (addrx = H5MF_alloc(f, type, H5AC_ind_read_dxpl_id, (hsize_t)103))) + FAIL_STACK_ERROR + } + /* The H5FD_MEM_SUPER free-space manager will go away at H5MF_close() */ if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -7065,7 +7072,6 @@ test_mf_fs_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) /* Get a pointer to the internal file object */ if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR - /* Verify that the H5FD_MEM_SUPER free-space manager is not there */ if(H5F_addr_defined(f->shared->fs_addr[fs_type])) TEST_ERROR @@ -8936,9 +8942,7 @@ main(void) /* Temporary: modify to skip testing for multi/split driver: fail file create when persisting free-space or using paged aggregation strategy */ -#ifdef OUT /* Will take a close look at this later */ nerrors += test_mf_fs_gone(env_h5_drvr, fapl, FALSE); -#endif nerrors += test_mf_fs_gone(env_h5_drvr, fapl, TRUE); /* Temporary: modify to skip testing multi/split driver: diff --git a/test/tfile.c b/test/tfile.c index 653fd12..03a5233 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -44,8 +44,11 @@ #define H5T_FRIEND /*suppress error about including H5Tpkg */ #include "H5Tpkg.h" /* Datatype */ -#define H5A_FRIEND /*suppress error about including H5Apkg */ -#include "H5Apkg.h" /* Attributes */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Apkg.h" /* Attributes */ + +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5Opkg.h" /* Object headers */ #define BAD_USERBLOCK_SIZE1 (hsize_t)1 #define BAD_USERBLOCK_SIZE2 (hsize_t)2 @@ -164,73 +167,19 @@ const char *FILESPACE_NAME[] = { NULL }; -/* - * Declarations for test_libver_bounds_low_high() and its associated functions: - * test_libver_bounds_super(), test_libver_bounds_super_create(), test_libver_bounds_super_open(), - * test_libver_bounds_obj(), - * test_libver_bounds_dataset(), - * test_libver_bounds_dataspace(), - * test_libver_bounds_datatype_check(), test_libver_bounds_datatype() - * test_libver_bounds_attributes() - */ -#define FILE8 "tfile8.h5" /* Test file */ - -/* See HDF5_SUPERBLOCK* versions in H5Fprivate.h */ -#define SUPERBLOCK_VERSION_3 3 - -/* See H5O* versions in H5Opkg.h */ -#define OBJ_VERSION_1 1 -#define OBJ_VERSION_2 2 -#define OBJ_VERSION_LATEST OBJ_VERSION_2 - -/* These should be in sync with H5O_obj_ver_bounds[] in H5O.c */ -const unsigned obj_ver_bounds[] = { - OBJ_VERSION_1, /* H5F_LIBVER_EARLIEST */ - OBJ_VERSION_2, /* H5F_LIBVER_V18 */ - OBJ_VERSION_LATEST /* H5F_LIBVER_LATEST */ -}; - -/* See H5O_LAYOUT* versions in H5Oprivate.h */ -/* The library defines LAYOUT_VERSION_3 as the default--see H5Pdcpl.c */ -#define LAYOUT_VERSION_1 1 -#define LAYOUT_VERSION_3 3 -#define LAYOUT_VERSION_4 4 -#define LAYOUT_VERSION_DEFAULT LAYOUT_VERSION_3 -#define LAYOUT_VERSION_LATEST LAYOUT_VERSION_4 - -/* These should be in sync with H5O_layout_ver_bounds[] in H5Dlayout.c */ -const unsigned layout_ver_bounds[] = { - LAYOUT_VERSION_1, /* H5F_LIBVER_EARLIEST */ - LAYOUT_VERSION_3, /* H5F_LIBVER_V18 */ - LAYOUT_VERSION_LATEST /* H5F_LIBVER_LATEST */ -}; - -/* See H5O_PLINE* versions in H5Oprivate.h */ -#define PLINE_VERSION_1 1 -#define PLINE_VERSION_2 2 -#define PLINE_VERSION_LATEST H5O_PLINE_VERSION_2 - -/* These should be in sync with H5O_pline_ver_bounds[] in H5Opline.c */ -const unsigned pline_ver_bounds[] = { - PLINE_VERSION_1, /* H5F_LIBVER_EARLIEST */ - PLINE_VERSION_2, /* H5F_LIBVER_V18 */ - PLINE_VERSION_LATEST /* H5F_LIBVER_LATEST */ -}; +/* Local test function declarations for version bounds */ +static void test_libver_bounds_low_high(void); +static void test_libver_bounds_super(hid_t fapl); +static void test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr); +static void test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr); +static void test_libver_bounds_obj(hid_t fapl); +static void test_libver_bounds_dataset(hid_t fapl); +static void test_libver_bounds_dataspace(hid_t fapl); +static void test_libver_bounds_datatype(hid_t fapl); +static void test_libver_bounds_datatype_check(hid_t fapl, hid_t tid); +static void test_libver_bounds_attributes(hid_t fapl); -/* See H5O_FILL* versions in H5Oprivate.h */ -/* FILL_VERSION_2 is the default--see H5Pdcpl.c */ -#define FILL_VERSION_1 1 -#define FILL_VERSION_2 2 -#define FILL_VERSION_3 3 -#define FILL_VERSION_DEFAULT FILL_VERSION_2 -#define FILL_VERSION_LATEST H5O_FILL_VERSION_3 - -/* These should be in sync with H5O_fill_ver_bounds[] in H5Ofill.c */ -const unsigned fill_ver_bounds[] = { - FILL_VERSION_1, /* H5F_LIBVER_EARLIEST */ - FILL_VERSION_3, /* H5F_LIBVER_V18 */ - FILL_VERSION_LATEST /* H5F_LIBVER_LATEST */ -}; +#define FILE8 "tfile8.h5" /* Test file */ #define DSET_NULL "DSET_NULL" #define DSET "DSET" @@ -238,44 +187,6 @@ const unsigned fill_ver_bounds[] = { #define DSETB "DSETB" #define DSETC "DSETC" -/* See H5O_SDSPACE* versions in H5Spkg.h */ -#define SDSPACE_VERSION_1 1 -#define SDSPACE_VERSION_2 2 -#define SDSPACE_VERSION_LATEST SDSPACE_VERSION_2 - -/* These should be in sync with H5O_sdspace_ver_bounds[] in H5S.c */ -const unsigned sdspace_ver_bounds[] = { - SDSPACE_VERSION_1, /* H5F_LIBVER_EARLIEST */ - SDSPACE_VERSION_2, /* H5F_LIBVER_V18 */ - SDSPACE_VERSION_LATEST /* H5F_LIBVER_LATEST */ -}; - -/* See H5O_DTYPE* versions in H5Tpkg.h */ -#define DTYPE_VERSION_1 1 -#define DTYPE_VERSION_2 2 -#define DTYPE_VERSION_3 3 -#define DTYPE_VERSION_LATEST DTYPE_VERSION_3 - -/* These should be in sync with H5O_dtype_ver_bounds[] in H5T.c */ -const unsigned dtype_ver_bounds[] = { - DTYPE_VERSION_1, /* H5F_LIBVER_EARLIEST */ - DTYPE_VERSION_3, /* H5F_LIBVER_V18 */ - DTYPE_VERSION_LATEST /* H5F_LIBVER_LATEST */ -}; - -/* See H5O_ATTR* versions in H5Apkg.h */ -#define ATTR_VERSION_1 1 -#define ATTR_VERSION_2 2 -#define ATTR_VERSION_3 3 -#define ATTR_VERSION_LATEST ATTR_VERSION_3 - -/* These should be in sync with H5O_attr_ver_bounds[] in H5Aint.c */ -const unsigned attr_ver_bounds[] = { - ATTR_VERSION_1, /* H5F_LIBVER_EARLIEST */ - ATTR_VERSION_3, /* H5F_LIBVER_V18 */ - ATTR_VERSION_LATEST /* H5F_LIBVER_LATEST */ -}; - static void create_objects(hid_t, hid_t, hid_t *, hid_t *, hid_t *, hid_t *); static void @@ -2259,7 +2170,7 @@ test_file_double_file_dataset_open(hbool_t new_format) /* Create a chunked dataset with fixed array indexing */ sid1 = H5Screate_simple(1, dims, max_dims0); - CHECK(sid1, FAIL, "H5Screate"); + CHECK(sid1, FAIL, "H5Screate_simple"); tid1 = H5Tcopy(H5T_C_S1); CHECK(tid1, FAIL, "H5Tcopy"); ret = H5Tset_size(tid1, H5T_VARIABLE); @@ -2285,7 +2196,7 @@ test_file_double_file_dataset_open(hbool_t new_format) /* Create a chunked dataset with extensible array indexing */ sid1 = H5Screate_simple(1, dims, max_dims1); - CHECK(sid1, FAIL, "H5Screate"); + CHECK(sid1, FAIL, "H5Screate_simple"); tid1 = H5Tcopy(H5T_C_S1); CHECK(tid1, FAIL, "H5Tcopy"); ret = H5Tset_size(tid1, H5T_VARIABLE); @@ -2314,7 +2225,7 @@ test_file_double_file_dataset_open(hbool_t new_format) /* Create a chunked dataset with v2 btree indexing */ sid2 = H5Screate_simple(2, dims2, max_dims2); - CHECK(sid2, FAIL, "H5Screate"); + CHECK(sid2, FAIL, "H5Screate_simple"); dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); @@ -5008,8 +4919,8 @@ test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create, CHECK(group, FAIL, "H5Gcreate"); ret = H5Oget_info(group, &oinfo); - CHECK(ret, FAIL, "H5Oget_info_by_name"); - VERIFY(oinfo.hdr.version, oh_vers_mod, "H5Oget_info_by_name"); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.hdr.version, oh_vers_mod, "H5Oget_info"); ret = H5Gclose(group); CHECK(ret, FAIL, "H5Gclose"); @@ -5061,252 +4972,472 @@ test_libver_bounds(void) test_libver_bounds_real(H5F_LIBVER_LATEST, 2, H5F_LIBVER_EARLIEST, 2); } /* end test_libver_bounds() */ -/**************************************************************** +/************************************************************************************** ** -** test_libver_bounds_attributes(): -** Verify the attribute versions. +** test_libver_bounds_low_high(): +** Tests to verify that format versions are correct with the following five +** pairs of low/high version bounds set in fapl via H5Pset_libver_bounds(): +** (1) (earliest, v18) +** (2) (earliest, v110) +** (3) (v18, v18) +** (4) (v18, v110) +** (5) (v110, v110) ** -****************************************************************/ +** For each pair of setting in fapl, verify format versions with the following +** six tests: +** (1) test_libver_bounds_super(fapl): superblock versions +** (2) test_libver_bounds_obj(fapl): object header versions +** (3) test_libver_bounds_dataset(fapl): message versions associated with dataset +** (4) test_libver_bounds_dataspace(fapl): dataspace message versions +** (5) test_libver_bounds_datatype(fapl): datatype message versions +** (6) test_libver_bounds_attributes(fapl): attribute message versions +** +**************************************************************************************/ static void -test_libver_bounds_attributes(hid_t fapl) +test_libver_bounds_low_high(void) { - hid_t fid; /* File ID */ - hid_t fcpl; /* File creation property list */ - hid_t new_fapl; /* File access property list */ - hid_t did; /* Dataset ID */ - hid_t tid; /* Datatype ID */ - hid_t gid; /* Group ID */ - hid_t sid; /* Dataspace ID */ - hid_t aid; /* Attribute ID */ - hid_t attr_cpl; /* Attribute creation property list */ - H5A_t *attr; /* Internal attribute pointer */ - H5F_t *f; /* Internal file pointer */ - H5F_libver_t low, high; /* File format bounds */ - herr_t ret; /* Return value */ - - /* Retrieve the library format bounds */ - ret = H5Pget_libver_bounds(fapl, &low, &high); - CHECK(ret, FAIL, "H5Pget_libver_bounds"); - - /* Create the file */ - fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - CHECK(fid, FAIL, "H5Fcreate"); - - /* Integer datatpye */ - tid = H5Tcopy(H5T_NATIVE_INT); - CHECK(tid, FAIL, "H5Tcopy"); - - /* Create a committed datatype */ - ret = H5Tcommit2(fid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Tcommit2"); + hid_t fapl = -1; /* File access property list */ + H5F_libver_t low, high; /* Low and high bounds */ + herr_t ret; /* The return value */ - /* Create dataspace */ - sid = H5Screate(H5S_SCALAR); - CHECK(sid, FAIL, "H5Screate"); - - /* Create a group */ - gid = H5Gcreate2(fid, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(gid, FAIL, "H5Gcreate2"); + /* Output message about test being performed */ + MESSAGE(5, ("Testing setting (low, high) format version bounds\n")); - /* Create an attribute to the group with the committed datatype */ - aid = H5Acreate2(gid, "attr1", tid, sid, H5P_DEFAULT, H5P_DEFAULT); - CHECK(aid, FAIL, "H5Acreate2"); + /* Create a file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); - /* Get the internal attribute pointer */ - attr = (H5A_t *)H5I_object(aid); - CHECK(attr, NULL, "H5I_object"); + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + + H5E_BEGIN_TRY { + /* Set the low/high version bounds */ + ret = H5Pset_libver_bounds(fapl, low, high); + } H5E_END_TRY; - /* Verify the attribute version */ - if(low == H5F_LIBVER_EARLIEST) - VERIFY(attr->shared->version, ATTR_VERSION_2, "attr_ver_bounds"); - else - VERIFY(attr->shared->version, attr_ver_bounds[low], "attr_ver_bounds"); + /* Should fail: invalid combinations */ + if(high == H5F_LIBVER_EARLIEST) { + VERIFY(ret, FAIL, "H5Pset_libver_bounds"); + continue; + } - /* Close the attribute */ - ret = H5Aclose(aid); - CHECK(ret, FAIL, "H5Aclose"); + /* Should fail: invalid combinations */ + if(high < low) { + VERIFY(ret, FAIL, "H5Pset_libver_bounds"); + continue; + } - /* Create an attribute to the group with integer type */ - aid = H5Acreate2(gid, "attr2", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT); - CHECK(aid, FAIL, "H5Acreate2"); + /* All other combinations are valid and should succeed */ + VERIFY(ret, SUCCEED, "H5Pset_libver_bounds"); - /* Get the internal attribute pointer */ - attr = (H5A_t *)H5I_object(aid); - CHECK(attr, NULL, "H5I_object"); + /* Tests to verify version bounds */ + test_libver_bounds_super(fapl); + test_libver_bounds_obj(fapl); + test_libver_bounds_dataset(fapl); + test_libver_bounds_dataspace(fapl); + test_libver_bounds_datatype(fapl); + test_libver_bounds_attributes(fapl); + } - /* Verify attribute version */ - VERIFY(attr->shared->version, attr_ver_bounds[low], "attr_ver_bounds"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); - /* Close the attribute */ - ret = H5Aclose(aid); - CHECK(ret, FAIL, "H5Aclose"); +} /* end test_libver_bounds_low_high() */ - /* Enable character encoding in attribute creation property list */ - attr_cpl = H5Pcreate(H5P_ATTRIBUTE_CREATE); - CHECK(attr_cpl, FAIL, "H5Pcreate"); - ret = H5Pset_char_encoding(attr_cpl, H5T_CSET_UTF8); - CHECK(ret, FAIL, "H5Pset_char_encoding"); - /* Create an attribute to the group with character encoding set */ - aid = H5Acreate2(gid, "attr3", H5T_NATIVE_INT, sid, attr_cpl, H5P_DEFAULT); - CHECK(aid, FAIL, "H5Acreate2"); +/*********************************************************************** +** +** test_libver_bounds_super(): +** Verify superblock version with the following two tests: +** (1) test_libver_bounds_super_create(): +** --when creating a file with the input fapl and the fcpl +** that has the following feature enabled: +** (A) default fcpl +** (B) fcpl with v1-btee K value enabled +** (C) fcpl with shared messages enabled +** (D) fcpl with persistent free-space manager enabled +** +** (2) test_libver_bounds_super_open(): +** --when opening a file which is created with the input fapl +** and the fcpl setting as #A to #D above. +** +** These two tests are run with or without SWMR file access. +** +*************************************************************************/ +static void +test_libver_bounds_super(hid_t fapl) +{ + hid_t fcpl = -1; /* File creation property list */ + herr_t ret; /* The return value */ - /* Get internal attribute pointer */ - attr = (H5A_t *)H5I_object(aid); - CHECK(attr, NULL, "H5I_object"); + /* Create a default fcpl: #A */ + /* This will result in superblock version 0 */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); - /* Verify attribute version */ - if(low == H5F_LIBVER_EARLIEST) - VERIFY(attr->shared->version, ATTR_VERSION_3, "attr_ver_bounds"); - else - VERIFY(attr->shared->version, attr_ver_bounds[low], "attr_ver_bounds"); + /* Verify superblock version when creating a file with input fapl, + fcpl #A and with/without SWMR access */ + test_libver_bounds_super_create(fapl, fcpl, TRUE); + test_libver_bounds_super_create(fapl, fcpl, FALSE); - /* Close the attribute */ - ret = H5Aclose(aid); - CHECK(ret, FAIL, "H5Aclose"); + /* Verify superblock version when opening a file which is created + with input fapl, fcpl #A and with/without SWMR access */ + test_libver_bounds_super_open(fapl, fcpl, TRUE); + test_libver_bounds_super_open(fapl, fcpl, FALSE); - /* Close the attribute creation property list */ - ret = H5Pclose(attr_cpl); + /* Close the fcpl */ + ret = H5Pclose(fcpl); CHECK(ret, FAIL, "H5Pclose"); - /* Close the group */ - ret = H5Gclose(gid); - CHECK(ret, FAIL, "H5Gclose"); + /* Create a fcpl with v1-btree K value enabled: #B */ + /* This will result in superblock version 1 */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_istore_k(fcpl, 64); + CHECK(ret, FAIL, "H5Pset_istore_k"); - /* Close the dataspace */ - ret = H5Sclose(sid); - CHECK(ret, FAIL, "H5Sclose"); + /* Verify superblock version when creating a file with input fapl, + fcpl #B and with/without SWMR access */ + test_libver_bounds_super_create(fapl, fcpl, TRUE); + test_libver_bounds_super_create(fapl, fcpl, FALSE); - /* Close the datatype */ - ret = H5Tclose(tid); - CHECK(ret, FAIL, "H5Tclose"); + /* Verify superblock version when opening a file which is created + with input fapl, fcpl #B and with/without SWMR access */ + test_libver_bounds_super_open(fapl, fcpl, TRUE); + test_libver_bounds_super_open(fapl, fcpl, FALSE); - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); + /* Close the fcpl */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); - /* Create a copy of the file creation property list */ + /* Create a fcpl with shared messages enabled: #C */ + /* This will result in superblock version 2 */ fcpl = H5Pcreate(H5P_FILE_CREATE); CHECK(fcpl, FAIL, "H5Pcreate"); - - /* Enable shared datatype message */ ret = H5Pset_shared_mesg_nindexes(fcpl, 1); CHECK(ret, FAIL, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_DTYPE_FLAG, 2); + ret = H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_ATTR_FLAG, 2); CHECK(ret, FAIL, "H5Pset_shared_mesg_index"); - /* Create the file with shared datatype message enabled */ - fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); - CHECK(fid, FAIL, "H5Fcreate"); - - /* Integer datatye */ - tid = H5Tcopy(H5T_NATIVE_INT); - CHECK(tid, FAIL, "H5Tcopy"); + /* Verify superblock version when creating a file with input fapl, + fcpl #C and with/without SWMR access */ + test_libver_bounds_super_create(fapl, fcpl, TRUE); + test_libver_bounds_super_create(fapl, fcpl, FALSE); - /* Create dataspace */ - sid = H5Screate(H5S_SCALAR); - CHECK(sid, FAIL, "H5Screate"); + /* Verify superblock version when opening a file which is created + with input fapl, fcpl #C and with/without SWMR access */ + test_libver_bounds_super_open(fapl, fcpl, TRUE); + test_libver_bounds_super_open(fapl, fcpl, FALSE); - /* Create a group */ - gid = H5Gcreate2(fid, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(gid, FAIL, "H5Gcreate2"); + /* Close the fcpl */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); - /* Create an attribute to the group with integer datatype */ - aid = H5Acreate2(gid, ATTR_NAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT); - CHECK(aid, FAIL, "H5Acreate2"); + /* Create a fcpl with persistent free-space manager enabled: #D */ + /* This will result in superblock version 2 */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0); + CHECK(ret, FAIL, "H5Pset_file_space"); - /* Get the internal attribute pointer */ - attr = (H5A_t *)H5I_object(aid); - CHECK(attr, NULL, "H5I_object"); + /* Verify superblock version when creating a file with input fapl, + fcpl #D and with/without SWMR access */ + test_libver_bounds_super_create(fapl, fcpl, TRUE); + test_libver_bounds_super_create(fapl, fcpl, FALSE); - /* Verify the attribute version */ - if(low == H5F_LIBVER_EARLIEST) - VERIFY(attr->shared->version, ATTR_VERSION_2, "attr_ver_bounds"); - else - VERIFY(attr->shared->version, attr_ver_bounds[low], "attr_ver_bounds"); + /* Verify superblock version when opening a file which is created + with input fapl, fcpl #D and with/without SWMR access */ + test_libver_bounds_super_open(fapl, fcpl, TRUE); + test_libver_bounds_super_open(fapl, fcpl, FALSE); - /* Close the attribute */ - ret = H5Aclose(aid); - CHECK(ret, FAIL, "H5Aclose"); + /* Close the fcpl */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); - /* Close the group */ - ret = H5Gclose(gid); - CHECK(ret, FAIL, "H5Gclose"); +} /* end test_libver_bounds_super() */ - /* Close the dataspace */ - ret = H5Sclose(sid); - CHECK(ret, FAIL, "H5Sclose"); - /* Close the datatype */ - ret = H5Tclose(tid); - CHECK(ret, FAIL, "H5Tclose"); +/************************************************************************************************** +** +** test_libver_bounds_super_create(): +** Verify the following when the file is created with the input fapl, fcpl, and +** with/without SWMR access: +** (a) the superblock version # +** (b) the file's low bound setting +** (c) fail or succeed in creating the file +** +** For file creation, the bounds setting in fapl, the feature enabled in fcpl, +** and with/without SWMR file access will determine the results for #a to #c. +** +** The first row for the following two tables is the 5 pairs of low/high bounds setting +** in the input fapl. The next three rows list the expected results for #a to #c. +** "-->" indicates "upgrade to" +** +** Creating a file with write access +** -------------------------------------------------------------------------------- +** | (earliest, v18) | (earliest, v110) | (v18, v18) | (v18, v110) | (v110, v110) | +** |______________________________________________________________________________| +** Superblock version | vers 0, 1, 2 | vers 0, 1, 2 | vers 2 | vers 2 | vers 3 | +** |------------------------------------------------------------------------------| +** File's low bound | no change | +** |------------------------------------------------------------------------------| +** File creation | succeed | +** |______________________________________________________________________________| +** +** Creating a file with SWMR-write access +** -------------------------------------------------------------------------------- +** | (earliest, v18) | (earliest, v110) | (v18, v18) | (v18, v110) | (v110, v110) | +** |______________________________________________________________________________| +** Superblock version | -- | vers 3 | -- | vers 3 | vers 3 | +** |------------------------------------------------------------------------------| +** File's low bound | -- | ->v110 | -- | ->v110 | no change | +** |------------------------------------------------------------------------------| +** File creation | fail | succeed | fail | succeed | succed | +** |______________________________________________________________________________| +** +******************************************************************************************************/ +static void +test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr) +{ + hid_t fid = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ + hbool_t ok; /* The result is ok or not */ + herr_t ret; /* The return value */ - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); + /* Try to create the file */ + H5E_BEGIN_TRY { + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC | (is_swmr ? H5F_ACC_SWMR_WRITE : 0), fcpl, fapl); + } H5E_END_TRY; - /* Create a copy of the file access property list */ - new_fapl = H5Pcreate(H5P_FILE_ACCESS); - CHECK(new_fapl, FAIL, "H5Pcreate"); + /* Get the internal file pointer if the create succeeds */ + if((ok = fid >= 0)) { + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); + } - /* Create the dataspace */ - sid = H5Screate(H5S_SCALAR); - CHECK(sid, FAIL, "H5Screate"); + /* Retrieve the low/high bounds */ + ret = H5Pget_libver_bounds(fapl, &low, &high); + CHECK(ret, FAIL, "H5Pget_libver_bounds"); - /* Loop through all the combinations of low/high library format bounds */ - /* Open the file and group and attach an attribute to the group */ - /* Verify the attribute version */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - H5E_BEGIN_TRY { - ret = H5Pset_libver_bounds(new_fapl, low, high); - } H5E_END_TRY; + if(is_swmr) { /* SWMR is enabled */ - if(ret < 0) /* Invalid low/high combinations */ - continue; + if(high == H5F_LIBVER_LATEST) { /* Should succeed */ + VERIFY(ok, TRUE, "H5Fcreate"); + VERIFY(HDF5_SUPERBLOCK_VERSION_3, f->shared->sblock->super_vers, "HDF5_superblock_ver_bounds"); + VERIFY(H5F_LIBVER_V110, f->shared->low_bound, "HDF5_superblock_ver_bounds"); - /* Open the file */ + } else /* Should fail */ + VERIFY(ok, FALSE, "H5Fcreate"); + + } else { /* Should succeed */ + VERIFY(ok, TRUE, "H5Fcreate"); + VERIFY(low, f->shared->low_bound, "HDF5_superblock_ver_bounds"); + + switch(low) { + case H5F_LIBVER_EARLIEST: + ok = (f->shared->sblock->super_vers == 0 || + f->shared->sblock->super_vers == 1 || + f->shared->sblock->super_vers == 2); + VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); + break; + + case H5F_LIBVER_V18: + ok = (f->shared->sblock->super_vers == 2); + VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); + break; + + case H5F_LIBVER_V110: + ok = (f->shared->sblock->super_vers == 3); + VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); + break; + + case H5F_LIBVER_ERROR: + case H5F_LIBVER_NBOUNDS: + default: + ERROR("H5Pget_libver_bounds"); + + } /* end switch */ + } + + if(ok) { /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } + +} /* end test_libver_bounds_super_create() */ + +/************************************************************************************************** +** +** test_libver_bounds_super_open(): +** Verify the following when opening a file which is created with the input fapl, fcpl, +** and with/without SWMR access: +** (a) the file's low bound setting +** (b) fail or succeed in opening the file +** +** (1) Create a file with the input fapl, fcpl and with/without SWMR access +** (2) Close the file +** (3) Reopen the file with a new fapl that is set to the 5 pairs of low/high bounds +** in a for loop. For each pair of setting in the new fapl: +** --Verify the expected results for #a and #b above. +** --Close the file. +** +** For file open, the file's superblock version, the low/high bounds setting in fapl, +** and with/without SWMR file access will determine the results for #a and #b. +** +** The first row for the following tables is the 5 pairs of low/high bounds setting +** in the input fapl. The next two rows list the expected results for #a and #b. +** "-->" indicates "upgrade to" +** +** Opening a file with write access +** +** Superblock version 0, 1 +** -------------------------------------------------------------------------------- +** | (earliest, v18) | (earliest, v110) | (v18, v18) | (v18, v110) | (v110, v110) | +** |______________________________________________________________________________| +** File's low bound | no change | +** |------------------------------------------------------------------------------| +** File open | succeed | +** |______________________________________________________________________________| +** +** +** Superblock version 2 +** -------------------------------------------------------------------------------- +** | (earliest, v18) | (earliest, v110) | (v18, v18) | (v18, v110) | (v110, v110) | +** |______________________________________________________________________________| +** File's low bound | -->v18 | no change | +** |------------------------------------------------------------------------------| +** File open | succeed | +** |______________________________________________________________________________| +** +** Superblock version 3 +** -------------------------------------------------------------------------------- +** | (earliest, v18) | (earliest, v110) | (v18, v18) | (v18, v110) | (v110, v110) | +** |______________________________________________________________________________| +** File's low bound | -- | -->v110 | -- | -->v110 | no change | +** |------------------------------------------------------------------------------| +** File open | fail | succeed | fail | succeed | succeed | +** |______________________________________________________________________________| +** +** +** +** Opening a file with SWMR-write access +** +** Superblock version 0, 1, 2 +** ------------------------------------------------------------------------------- +** | (earliest, v18) | (earliest, v10) | (v18, v18) | (v18, v110) | (v110, v110) | +** |_____________________________________________________________________________| +** File's low bound | ---- +** |-----------------------------------------------------------------------------| +** File open | fail +** |_____________________________________________________________________________| +** +** +** Superblock version 3 +** ------------------------------------------------------------------------------- +** | (earliest, v18) | (earliest, v10) | (v18, v18) | (v18, v110) | (v110, v110) | +** |_____________________________________________________________________________| +** File's low bound | -- | -->v110 | -- | -->v110 | no change | +** |-----------------------------------------------------------------------------| +** File open | fail | succeed | fail | succeed | succeed | +** |_____________________________________________________________________________| +** +** +******************************************************************************************************/ +static void +test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr) +{ + hid_t fid = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file pointer */ + hid_t new_fapl = -1; /* File access property list */ + unsigned super_vers; /* Superblock version */ + H5F_libver_t low, high; /* Low and high bounds */ + hbool_t ok; /* The result is ok or not */ + herr_t ret; /* Return value */ + + /* Create the file with the input fcpl and fapl */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Get the internal file pointer */ + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); + + /* The file's superblock version */ + super_vers = f->shared->sblock->super_vers; + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Create a default file access property list */ + new_fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(new_fapl, FAIL, "H5Pcreate"); + + /* Loop through all the combinations of low/high bounds in new_fapl */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { H5E_BEGIN_TRY { - fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); + ret = H5Pset_libver_bounds(new_fapl, low, high); } H5E_END_TRY; - if(fid >=0 ) { /* The file open succeeds */ - - /* Get the internal file pointer */ - f = (H5F_t *)H5I_object(fid); - CHECK(f, NULL, "H5I_object"); + /* Invalid combinations */ + if (ret < 0) + continue; - /* Open the group */ - gid = H5Gopen2(fid, GRP_NAME, H5P_DEFAULT); - CHECK(gid, FAIL, "H5Dcreate2"); + /* Open the file with or without SWMR access */ + H5E_BEGIN_TRY { + fid = H5Fopen(FILE8, H5F_ACC_RDWR | (is_swmr ? H5F_ACC_SWMR_WRITE : 0), new_fapl); + } H5E_END_TRY; + ok = fid >= 0; - /* Create an attribute to the group */ - aid = H5Acreate2(gid, "attr1", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT); - CHECK(aid, FAIL, "H5Acreate2"); + /* Verify the file open succeeds or fails */ + switch(super_vers) { + case 3: + if(high == H5F_LIBVER_LATEST) { + /* Should succeed */ + VERIFY(ok, TRUE, "H5Fopen"); + VERIFY(H5F_LIBVER_V110, f->shared->low_bound, "HDF5_superblock_ver_bounds"); - /* Get the internal attribute pointer */ - attr = (H5A_t *)H5I_object(aid); - CHECK(attr, NULL, "H5I_object"); + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } else /* Should fail */ + VERIFY(ok, FALSE, "H5Fopen"); + break; - VERIFY(attr->shared->version, attr_ver_bounds[f->shared->low_bound], "attr_ver_bounds"); + case 2: + if(is_swmr) /* Should fail */ + VERIFY(ok, FALSE, "H5Fopen"); + else { /* Should succeed */ + VERIFY(ok, TRUE, "H5Fopen"); - /* Close the attribute */ - ret = H5Aclose(aid); - CHECK(ret, FAIL, "H5Aclose"); + ok = f->shared->low_bound >= H5F_LIBVER_V18; + VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); - /* Delete the attribute */ - ret = H5Adelete(gid, "attr1"); - CHECK(ret, FAIL, "H5Ldelete"); + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } + break; - /* Close the group */ - ret = H5Gclose(gid); - CHECK(ret, FAIL, "H5Gclose"); + case 1: + case 0: + if(is_swmr) /* Should fail */ + VERIFY(ok, FALSE, "H5Fopen"); + else { /* Should succeed */ + VERIFY(ok, TRUE, "H5Fopen"); + VERIFY(low, f->shared->low_bound, "HDF5_superblock_ver_bounds"); - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } + break; - } /* end if */ + default: + break; + } /* end switch */ } /* end for */ } /* end for */ @@ -5314,126 +5445,111 @@ test_libver_bounds_attributes(hid_t fapl) ret = H5Pclose(new_fapl); CHECK(ret, FAIL, "H5Pclose"); - /* Close the dataspace */ - ret = H5Sclose(sid); - CHECK(ret, FAIL, "H5Sclose"); - -} /* end test_libver_bounds_attributes() */ +} /* end test_libver_bounds_super_open() */ /**************************************************************** ** -** test_libver_bounds_datatype(): -** Verify the datatype message versions for parameter "tid". +** test_libver_bounds_obj(): +** Verify object header versions: +** +** (a) Create a file with: +** --the input fapl +** --a fcpl that has shared message enabled +** Verify the root group's object header version. +** Close the file. +** +** (b) Create another file with: +** --the input fapl +** --a default fcpl +** Verify the root group's object header version. +** Close the file. +** +** (c) Reopen the same file in (b) with a new fapl. +** The new fapl is set to the 5 pairs of low/high +** bounds in a "for" loop. For each setting in fapl: +** --Create a group in the file +** --Verify the group's object header version +** --Close and delete the group +** --Close the file ** ****************************************************************/ static void -test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) +test_libver_bounds_obj(hid_t fapl) { - hid_t fid; /* File ID */ - hid_t new_fapl; /* File acess property list */ - hid_t dcpl; /* Dataset creation property list */ - hid_t dtid; /* Datatype ID for the dataset */ - hid_t str_tid; /* String datatype ID */ - hid_t did; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hsize_t dims[1] = {1}; /* Dimension sizes */ - hsize_t dims2[2] = {5, 4}; /* Dimension sizes */ - hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunks[2] = {2, 3}; /* Chunk dimension sizes */ - H5T_t *dtype; /* Internal datatype pointer */ - H5T_t *str_dtype; /* Internal datatype pointer for the string datatype */ - H5F_t *f; /* Internal file pointer */ - H5F_libver_t low, high; /* File format bounds */ - herr_t ret; /* Return value */ - - /* Retrieve the library format bounds */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t fcpl = -1; /* File creation property list */ + hid_t new_fapl = -1; /* File access property list */ + H5F_t *f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ + H5O_info_t oinfo; /* Object info */ + H5G_info_t ginfo; /* Group info */ + herr_t ret; /* Return value */ + + /* Retrieve the low/high bounds from the input fapl */ ret = H5Pget_libver_bounds(fapl, &low, &high); CHECK(ret, FAIL, "H5Pget_libver_bounds"); - /* Create the file */ - fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - CHECK(fid, FAIL, "H5Fcreate"); - - /* Create a committed datatype of string */ - str_tid = H5Tcopy(H5T_C_S1); - CHECK(str_tid, FAIL, "H5Tcopy"); - ret = H5Tset_size(str_tid, (size_t)10); - CHECK(ret, FAIL, "H5Tset_size"); - ret = H5Tcommit2(fid, "datatype", str_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Tcommit2"); - ret = H5Tclose(str_tid); - CHECK(ret, FAIL, "H5Tclose"); + /* Create a default file creation property list */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); - /* Create dataspace */ - sid = H5Screate_simple(1, dims, NULL); - CHECK(sid, FAIL, "H5Screate"); + /* Enable shared message in the fcpl */ + /* This will result in a version 2 object header */ + ret = H5Pset_shared_mesg_nindexes(fcpl, 1); + CHECK(ret, FAIL, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_ATTR_FLAG, 2); + CHECK(ret, FAIL, "H5Pset_shared_mesg_index"); - /* Create a dataset */ - did = H5Dcreate2(fid, DSET1, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(did, FAIL, "H5Dcreate2"); + /* Create the file with the fcpl and the input fapl */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(fid, FAIL, "H5Fcreate"); - /* Get the dataset's datatype */ - dtid = H5Dget_type(did); - CHECK(dtid, FAIL, "H5Dget_type"); + /* Get root group's object info */ + ret = H5Oget_info_by_name(fid, "/", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); - /* Get the internal datatype pointer */ - dtype = (H5T_t *)H5I_object(dtid); - CHECK(dtype, NULL, "H5I_object"); + /* Verify object header version is 2 because shared message is enabled */ + VERIFY(oinfo.hdr.version, H5O_VERSION_2, "H5O_obj_ver_bounds"); - /* Verify the datatype versions */ - /* Datatype version is upgraded only for H5T_COMPOUND, H5T_ENUM, H5T_ARRAY */ - /* H5T_VLEN: the version is upgraded if the parent datatype version is greater */ - /* Remaining datatypes use basic version: - H5T_INTEGER H5T_FLOAT H5T_TIME H5T_STRING H5T_BITFIELD H5T_OPAQUE H5T_REFERENCE */ + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); - if(dtype->shared->type == H5T_COMPOUND || - dtype->shared->type == H5T_ENUM || - dtype->shared->type == H5T_ARRAY) { - if(dtype->shared->type == H5T_ARRAY && low == H5F_LIBVER_EARLIEST) - VERIFY(dtype->shared->version, DTYPE_VERSION_2, "dtype_ver_bounds"); - else - VERIFY(dtype->shared->version, dtype_ver_bounds[low], "dtype_ver_bounds"); - } else - VERIFY(dtype->shared->version, dtype_ver_bounds[H5F_LIBVER_EARLIEST], "dtype_ver_bounds"); + /* Close the file creation property list */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); - /* Close the dataset */ - ret = H5Dclose(did); - CHECK(ret, FAIL, "H5Dclose"); + /* Create a file with the default fcpl and input fapl */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(fid, FAIL, "H5Fcreate"); - /* Close the dataspace */ - ret = H5Sclose(sid); - CHECK(ret, FAIL, "H5Dclose"); + /* Get root group's object info */ + ret = H5Oget_info_by_name(fid, "/", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); - /* Close the datatype */ - ret = H5Tclose(dtid); - CHECK(ret, FAIL, "H5Fclose"); + /* Verify object header version is as indicated by low_bound */ + VERIFY(oinfo.hdr.version, H5O_obj_ver_bounds[low], "H5O_obj_ver_bounds"); /* Close the file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Create a copy of file access property list */ + /* Create a new default file access property list which + is used to open the file in the "for" loop */ new_fapl = H5Pcreate(H5P_FILE_ACCESS); CHECK(new_fapl, FAIL, "H5Pcreate"); - /* Prepare to create a chunked dataset with 2 unlimited dimensions */ - sid = H5Screate_simple(2, dims2, max_dims2); - CHECK(sid, FAIL, "H5Screate"); - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); - ret = H5Pset_chunk(dcpl, 2, chunks); - CHECK(ret, FAIL, "H5Pset_chunk"); - - /* Loop through all the combinations of low/high library format bounds */ - /* Open the file and create the chunked dataset */ - /* Verify the dataset's datatype versions */ + /* Loop through all the combinations of low/high bounds in new_fapl */ + /* Open the file with the fapl; create a group and verify the + object header version, then delete the group and close the file.*/ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { H5E_BEGIN_TRY { ret = H5Pset_libver_bounds(new_fapl, low, high); } H5E_END_TRY; - if (ret < 0) /* Invalid low/high combinations */ + if (ret < 0) /* Invalid combinations */ continue; /* Open the file */ @@ -5441,59 +5557,41 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); } H5E_END_TRY; - if(fid >= 0 ) { /* The file open succeeds */ + if(fid >=0 ) { /* The file open succeeds */ /* Get the internal file pointer */ f = (H5F_t *)H5I_object(fid); CHECK(f, NULL, "H5I_object"); - /* Verify the committed datatype's version */ - str_tid = H5Topen2(fid, "datatype", H5P_DEFAULT); - CHECK(str_tid, FAIL, "H5Topen2"); - str_dtype = (H5T_t *)H5I_object(str_tid); - CHECK(str_dtype, NULL, "H5I_object"); + /* Create a group in the file */ + gid = H5Gcreate2(fid, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); - VERIFY(str_dtype->shared->version, dtype_ver_bounds[H5F_LIBVER_EARLIEST], "dtype_ver_bounds"); + /* Get group information */ + ret = H5Gget_info(gid, &ginfo); + CHECK(ret, FAIL, "H5Gget_info"); - ret = H5Tclose(str_tid); - CHECK(ret, FAIL, "H5Tclose"); + /* Verify group storage type */ + if(f->shared->low_bound >= H5F_LIBVER_V18) + /* Links in group are stored in object header */ + VERIFY(ginfo.storage_type, H5G_STORAGE_TYPE_COMPACT, "H5Gget_info"); + else + /* Links in group are stored with a "symbol table" */ + VERIFY(ginfo.storage_type, H5G_STORAGE_TYPE_SYMBOL_TABLE, "H5Gget_info"); + /* Get object header information */ + ret = H5Oget_info_by_name(gid, GRP_NAME, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); - /* Create the chunked dataset */ - did = H5Dcreate2(fid, DSETNAME, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - CHECK(did, FAIL, "H5Dcreate2"); + /* Verify object header version as indicated by low_bound */ + VERIFY(oinfo.hdr.version, H5O_obj_ver_bounds[f->shared->low_bound], "H5O_obj_ver_bounds"); - /* Get the dataset's datatype */ - dtid = H5Dget_type(did); - CHECK(dtid, FAIL, "H5Dget_type"); - - /* Get the internal datatype pointer */ - dtype = (H5T_t *)H5I_object(dtid); - CHECK(dtype, NULL, "H5I_object"); - - if(dtype->shared->type == H5T_COMPOUND || - dtype->shared->type == H5T_ENUM || - dtype->shared->type == H5T_ARRAY) { - - if(dtype->shared->type == H5T_ARRAY && - f->shared->low_bound == H5F_LIBVER_EARLIEST) - VERIFY(dtype->shared->version, DTYPE_VERSION_2, "dtype_ver_bounds"); - else - VERIFY(dtype->shared->version, dtype_ver_bounds[f->shared->low_bound], "dtype_ver_bounds"); - - } else /* not compound/enum/array */ - VERIFY(dtype->shared->version, dtype_ver_bounds[H5F_LIBVER_EARLIEST], "dtype_ver_bounds"); - - /* Close the dataset */ - ret = H5Dclose(did); - CHECK(ret, FAIL, "H5Dclose"); - - /* Close the dataset's datatype */ - ret = H5Tclose(dtid); - CHECK(ret, FAIL, "H5Tclose"); + /* Close the group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); - /* Delete the dataset */ - ret = H5Ldelete(fid, DSETNAME, H5P_DEFAULT); + /* Delete the group */ + ret = H5Ldelete(fid, GRP_NAME, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); /* Close the file */ @@ -5508,118 +5606,282 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) ret = H5Pclose(new_fapl); CHECK(ret, FAIL, "H5Pclose"); +} /* end test_libver_bounds_obj() */ + +/**************************************************************** +** +** test_libver_bounds_dataset(): +** Verify message versions associated with datasets: +** +** (a) Create a file with default fcpl and the input fapl. +** Create the following two datasets: +** --A contiguous dataset +** --A chunked dataset with "no filter edge chunks" +** For both datasets, verify the versions for the layout, +** fill value and filter pipeline messages. +** Close the file. +** +** (b) Create a new fapl that is set to the 5 pairs of low/high +** bounds in a "for" loop. For each pair of setting in the +** new fapl: +** --Open the same file in (a) with the fapl +** --Create a chunked dataset with 2 unlimited +** dimensions +** --Verify the versions for the layout, fill value +** and filter pipeline messages +** --Close and delete the dataset +** --Close the file +** +****************************************************************/ +static void +test_libver_bounds_dataset(hid_t fapl) +{ + hid_t fid = -1; /* File ID */ + hid_t new_fapl = -1; /* File access property list */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* Dataset creation property list */ + H5D_t *dset = NULL; /* Internal dataset pointer */ + H5F_t *f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ + herr_t ret; /* Return value */ + hsize_t fix_dims2[2] = {10, 4}; /* Dimension sizes */ + hsize_t fix_chunks2[2] = {4, 3}; /* Chunk dimension sizes */ + hsize_t dims2[2] = {1, 4}; /* Dimension sizes */ + hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunks2[2] = {4, 5}; /* Chunk dimension sizes */ + + /* Retrieve the low/high bounds from the input fapl */ + ret = H5Pget_libver_bounds(fapl, &low, &high); + CHECK(ret, FAIL, "H5Pget_libver_bounds"); + + /* Create the file with the input fapl */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Create the dataspace */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Create a contiguous dataset */ + did = H5Dcreate2(fid, DSETA, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dcreate"); + + /* Get the internal dataset pointer */ + dset = (H5D_t *)H5I_object(did); + CHECK(dset, NULL, "H5I_object"); + + /* Verify version for layout and fill value messages */ + if(low == H5F_LIBVER_EARLIEST) { + /* For layout message: the earliest version the library will set is 3 */ + /* For fill value message: the earliest version the library will set is 2 */ + VERIFY(dset->shared->layout.version, H5O_LAYOUT_VERSION_DEFAULT, "H5O_layout_ver_bounds"); + VERIFY(dset->shared->dcpl_cache.fill.version, H5O_FILL_VERSION_2, "H5O_fill_ver_bounds"); + } else { + VERIFY(dset->shared->layout.version, H5O_layout_ver_bounds[low], "H5O_layout_ver_bounds"); + VERIFY(dset->shared->dcpl_cache.fill.version, H5O_fill_ver_bounds[low], "H5O_fill_ver_bounds"); + } + + /* Verify filter pipleline message version */ + VERIFY(dset->shared->dcpl_cache.pline.version, H5O_pline_ver_bounds[low], "H5O_pline_ver_bounds"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + /* Close the dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); - /* Close the dataset creation property list */ + /* Set up dataspace and dcpl for creating a chunked dataset + with "no filter edge chunks" enabled. + This will result in a version 4 layout message */ + sid = H5Screate_simple(2, fix_dims2, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + ret = H5Pset_chunk(dcpl, 2, fix_chunks2); + CHECK(ret, FAIL, "H5Pset_chunk"); + ret = H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS); + CHECK(ret, FAIL, "H5Pset_chunk_opts"); + + /* Create the chunked dataset */ + H5E_BEGIN_TRY { + did = H5Dcreate2(fid, DSETB, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + } H5E_END_TRY; + + if(did >= 0) { + + /* Get the internal dataset pointer */ + dset = (H5D_t *)H5I_object(did); + CHECK(dset, NULL, "H5I_object"); + + /* Verify layout message version and chunk indexing type */ + VERIFY(dset->shared->layout.version, H5O_LAYOUT_VERSION_4, "H5O_layout_ver_bounds"); + VERIFY(dset->shared->layout.u.chunk.idx_type, H5D_CHUNK_IDX_FARRAY, "chunk_index_type"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + } + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the datset creation property list */ ret = H5Pclose(dcpl); CHECK(ret, FAIL, "H5Pclose"); -} /* end test_libver_bounds_datatype_check() */ + /* Create a default file access property list which is used + to open the file in the 'for' loop */ + new_fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(new_fapl, FAIL, "H5Pcreate"); -/**************************************************************** -** -** test_libver_bounds_datatype(): -** Verify the datatype versions for various datatypes. -** -****************************************************************/ -static void -test_libver_bounds_datatype(hid_t fapl) -{ - hid_t tid, tid_enum, tid_array, tid_compound, tid_vlen; /* Datatype IDs */ - int enum_value; /* Value for enum datatype */ - typedef struct s1 { /* Data structure for compound datatype */ - char c; - int i; - } s1; - hsize_t dims[1] = {1}; /* Dimension sizes */ - herr_t ret; /* Return value */ + /* Set up dataspace and dcpl for creating a chunked dataset with + 2 unlimited dimensions in the 'for' loop */ + sid = H5Screate_simple(2, dims2, max_dims2); + CHECK(sid, FAIL, "H5Screate_simple"); + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + ret = H5Pset_chunk(dcpl, 2, chunks2); + CHECK(ret, FAIL, "H5Pset_chunk"); - /* Create integer datatype */ - tid = H5Tcopy(H5T_NATIVE_INT); + /* Loop through all the combinations of low/high bounds in new_fapl */ + /* Open the file with the fapl and create the chunked dataset */ + /* Verify the dataset's layout, fill value and filter pipleline message versions */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(new_fapl, low, high); + } H5E_END_TRY; - /* Verify datatype versions */ - test_libver_bounds_datatype_check(fapl, tid); + if (ret < 0) /* Invalid low/high combinations */ + continue; - /* Create enum datatype */ - tid_enum = H5Tenum_create(tid); - enum_value = 0; - H5Tenum_insert(tid_enum, "val1", &enum_value); - enum_value = 1; - H5Tenum_insert(tid_enum, "val2", &enum_value); + /* Open the file */ + H5E_BEGIN_TRY { + fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); + } H5E_END_TRY; - /* Verify datatype versions */ - test_libver_bounds_datatype_check(fapl, tid_enum); + if(fid >=0 ) { /* The file open succeeds */ - /* Create array datatype */ - tid_array = H5Tarray_create2(tid, 1, dims); + /* Get the internal file pointer */ + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); - /* Verify datatype versions */ - test_libver_bounds_datatype_check(fapl, tid_array); + /* Create the chunked dataset */ + did = H5Dcreate2(fid, DSETC, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dcreate2"); - /* Create compound datatype */ - tid_compound = H5Tcreate(H5T_COMPOUND, sizeof(s1)); - H5Tinsert(tid_compound, "c", HOFFSET(s1, c), H5T_STD_U8LE); - H5Tinsert(tid_compound, "i", HOFFSET(s1, i), H5T_NATIVE_INT); + /* Get the internal file pointer */ + dset = (H5D_t *)H5I_object(did); + CHECK(dset, NULL, "H5I_object"); - /* Verify datatype versions */ - test_libver_bounds_datatype_check(fapl, tid_compound); + /* Verify the dataset's layout, fill value and filter pipeline message versions */ + /* Also verify the chunk indexing type */ + if(f->shared->low_bound == H5F_LIBVER_EARLIEST) { + /* For layout message: the earliest version the library will set is 3 */ + /* For fill value message: the earliest version the library will set is 2 */ + VERIFY(dset->shared->layout.version, H5O_LAYOUT_VERSION_DEFAULT, "H5O_layout_ver_bounds"); + VERIFY(dset->shared->dcpl_cache.fill.version, H5O_FILL_VERSION_2, "H5O_fill_ver_bounds"); + } else { + VERIFY(dset->shared->layout.version, H5O_layout_ver_bounds[f->shared->low_bound], "H5O_layout_ver_bounds"); + VERIFY(dset->shared->dcpl_cache.fill.version, H5O_fill_ver_bounds[f->shared->low_bound], "H5O_fill_ver_bounds"); + } - /* Create vlen datatype */ - tid_vlen = H5Tvlen_create(tid); + /* Verify the filter pipeline message version */ + VERIFY(dset->shared->dcpl_cache.pline.version, H5O_pline_ver_bounds[f->shared->low_bound], "H5O_pline_ver_bounds"); - /* Verify datatype versions */ - test_libver_bounds_datatype_check(fapl, tid_vlen); + /* Verify the dataset's chunk indexing type */ + if(dset->shared->layout.version == H5O_LAYOUT_VERSION_LATEST) + VERIFY(dset->shared->layout.u.chunk.idx_type, H5D_CHUNK_IDX_BT2, "chunk_index_type"); + else + VERIFY(dset->shared->layout.u.chunk.idx_type, H5D_CHUNK_IDX_BTREE, "chunk_index_type"); - /* Close datatypes */ - ret = H5Tclose(tid); - CHECK(ret, FAIL, "H5Tclose"); + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); - ret = H5Tclose(tid_enum); - CHECK(ret, FAIL, "H5Tclose"); + /* Delete the dataset */ + ret = H5Ldelete(fid, DSETC, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Ldelete"); - ret = H5Tclose(tid_array); - CHECK(ret, FAIL, "H5Tclose"); + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); - ret = H5Tclose(tid_compound); - CHECK(ret, FAIL, "H5Tclose"); + } /* end if */ + } /* end for */ + } /* end for */ - ret = H5Tclose(tid_vlen); - CHECK(ret, FAIL, "H5Tclose"); + /* Close the file access property list */ + ret = H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); -} /* end test_libver_bounds_datatype() */ + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the dataset creation property list */ + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Pclose"); + +} /* end test_libver_bounds_dataset() */ /**************************************************************** ** ** test_libver_bounds_dataspace(): -** Verify the dataspace message versions. +** Verify dataspace message versions: +** +** (a) Create a file with default fcpl and the input fapl. +** Create the following two datasets: +** --A dataset with scalar dataspace +** --A dataset with null dataspace +** For both datasets, verify the dataspace message versions. +** Close the file. +** +** (b) Create a new fapl that is set to the 5 pairs of low/high +** bounds in a "for" loop. For each pair of setting in the +** new fapl: +** --Open the same file in (a) with the fapl +** --Create a chunked dataset, a compact dataset and +** a contigous dataset +** --Verify the dataspace message version for these +** three datasets +** --Delete the three datasets and the dataspaces +** --Close the file ** ****************************************************************/ static void test_libver_bounds_dataspace(hid_t fapl) { - hid_t fid; /* File ID */ - hid_t new_fapl; /* File access property list */ - hid_t did, did_null, did_compact, did_contig; /* Dataset IDs */ - hid_t sid, sid_null, sid_compact, sid_contig; /* Dataspace IDs */ - hid_t dcpl, dcpl_compact, dcpl_contig; /* Dataset creation property lists */ - H5S_t *space, *space_null; /* Internal dataspace pointers */ - H5F_t *f; /* Internal file pointer */ - H5F_libver_t low, high; /* File format bounds */ - hsize_t dims[1] = {1}; /* Dimension sizes */ - hsize_t dims2[2] = {5, 4}; /* Dimension sizes */ - hsize_t max_dims[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunks[1] = {4}; /* Chunk dimension sizes */ - herr_t ret; /* Return value */ - - /* Create null dataspace, scalar dataspace */ - - /* Retrieve the library format bounds */ + hid_t fid = -1; /* File ID */ + hid_t new_fapl = -1; /* File access property list */ + hid_t did = -1, did_null = -1; /* Dataset IDs */ + hid_t did_compact = -1, did_contig = -1; /* Dataset IDs */ + hid_t sid = -1, sid_null = -1; /* Dataspace IDs */ + hid_t sid_compact = -1, sid_contig = -1; /* Dataspace IDs */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t dcpl_compact = -1, dcpl_contig = -1; /* Dataset creation property lists */ + H5S_t *space = NULL, *space_null = NULL; /* Internal dataspace pointers */ + H5F_t *f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ + hsize_t dims[1] = {1}; /* Dimension sizes */ + hsize_t dims2[2] = {5, 4}; /* Dimension sizes */ + hsize_t max_dims[1] = {H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunks[1] = {4}; /* Chunk dimension sizes */ + herr_t ret; /* Return value */ + + /* Retrieve the low/high bounds from the input fapl */ ret = H5Pget_libver_bounds(fapl, &low, &high); CHECK(ret, FAIL, "H5Pget_libver_bounds"); - /* Create the file */ + /* Create the file with the input fapl */ fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(fid, FAIL, "H5Fcreate"); @@ -5627,7 +5889,7 @@ test_libver_bounds_dataspace(hid_t fapl) sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); - /* Create the dataset with scalar dataspace */ + /* Create a dataset with the scalar dataspace */ did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(did, FAIL, "H5Dcreate"); @@ -5638,13 +5900,13 @@ test_libver_bounds_dataspace(hid_t fapl) CHECK(space, NULL, "H5I_object"); /* Verify the dataspace version */ - VERIFY(space->extent.version, sdspace_ver_bounds[low], "sdspace_ver_bounds"); + VERIFY(space->extent.version, H5O_sdspace_ver_bounds[low], "H5O_sdspace_ver_bounds"); /* Create null dataspace */ sid_null = H5Screate(H5S_NULL); CHECK(sid_null, FAIL, "H5Screate"); - /* Create the dataset with null dataspace */ + /* Create a dataset with the null dataspace */ did_null = H5Dcreate2(fid, DSET_NULL, H5T_NATIVE_INT, sid_null, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(did_null, FAIL, "H5Dcreate"); @@ -5655,7 +5917,7 @@ test_libver_bounds_dataspace(hid_t fapl) CHECK(space_null, NULL, "H5I_object"); /* Verify the dataspace version */ - VERIFY(space_null->extent.version, SDSPACE_VERSION_2, "sdspace_ver_bounds"); + VERIFY(space_null->extent.version, H5O_SDSPACE_VERSION_2, "H5O_sdspace_ver_bounds"); /* Close the datasets */ ret = H5Dclose(did); @@ -5673,38 +5935,38 @@ test_libver_bounds_dataspace(hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - - /* Create a copy of file access property list */ + /* Create a default file access property list which is used + to open the file in the 'for' loop */ new_fapl = H5Pcreate(H5P_FILE_ACCESS); CHECK(new_fapl, FAIL, "H5Pcreate"); - /* Prepare to create a chunked dataset with 1 unlimited dimension */ + /* Set up dataspace and dcpl for creating a chunked dataset */ sid = H5Screate_simple(1, dims, max_dims); - CHECK(sid, FAIL, "H5Screate"); + CHECK(sid, FAIL, "H5Screate_simple"); dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); ret = H5Pset_chunk(dcpl, 1, chunks); CHECK(ret, FAIL, "H5Pset_chunk"); - /* Prepare to create a compact dataset */ + /* Set up dataspace and dcpl for creating a compact dataset */ sid_compact = H5Screate_simple(1, dims, NULL); - CHECK(sid_compact, FAIL, "H5Screate"); + CHECK(sid_compact, FAIL, "H5Screate_simple"); dcpl_compact = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl_compact, FAIL, "H5Pcreate"); ret = H5Pset_layout(dcpl_compact, H5D_COMPACT); CHECK(ret, FAIL, "H5Pset_layout"); - /* Prepare to create a contiguous dataset */ + /* Set up dataspace and dcpl for creating a contiguous dataset */ sid_contig = H5Screate_simple(2, dims2, NULL); - CHECK(sid_contig, FAIL, "H5Screate"); + CHECK(sid_contig, FAIL, "H5Screate_simple"); dcpl_contig = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl_contig, FAIL, "H5Pcreate"); ret = H5Pset_layout(dcpl_contig, H5D_CONTIGUOUS); CHECK(ret, FAIL, "H5Pset_layout"); - /* Loop through all the combinations of low/high library format bounds */ + /* Loop through all the combinations of low/high bounds in new_fapl */ /* Open the file and create the chunked/compact/contiguous datasets */ - /* Verify the dataspace version for the three datasets */ + /* Verify the dataspace message version for the three datasets */ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { hid_t tmp_sid, tmp_sid_compact, tmp_sid_contig; /* Dataspace IDs */ @@ -5758,9 +6020,10 @@ test_libver_bounds_dataspace(hid_t fapl) tmp_space_contig = (H5S_t *)H5I_object(tmp_sid_contig); CHECK(tmp_space_contig, NULL, "H5I_object"); - VERIFY(tmp_space->extent.version, sdspace_ver_bounds[f->shared->low_bound], "sdspace_ver_bounds"); - VERIFY(tmp_space_compact->extent.version, sdspace_ver_bounds[f->shared->low_bound], "sdspace_ver_bounds"); - VERIFY(tmp_space_contig->extent.version, sdspace_ver_bounds[f->shared->low_bound], "sdspace_ver_bounds"); + /* Verify versions for the three dataspaces */ + VERIFY(tmp_space->extent.version, H5O_sdspace_ver_bounds[f->shared->low_bound], "H5O_sdspace_ver_bounds"); + VERIFY(tmp_space_compact->extent.version, H5O_sdspace_ver_bounds[f->shared->low_bound], "H5O_sdspace_ver_bounds"); + VERIFY(tmp_space_contig->extent.version, H5O_sdspace_ver_bounds[f->shared->low_bound], "H5O_sdspace_ver_bounds"); /* Close the three datasets */ ret = H5Dclose(did); @@ -5770,6 +6033,7 @@ test_libver_bounds_dataspace(hid_t fapl) ret = H5Dclose(did_contig); CHECK(ret, FAIL, "H5Dclose"); + /* Close the three dataspaces */ ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(tmp_sid_compact); @@ -5815,127 +6079,218 @@ test_libver_bounds_dataspace(hid_t fapl) } /* end test_libver_bounds_dataspace() */ + /**************************************************************** ** -** test_libver_bounds_dataset(): -** Verify the dataset's layout, fill, and pline message versions -** with the low/high library format bounds setting in the fapl. -** For chunked dataset, also verify the chunked indexing type. +** test_libver_bounds_datatype(): +** Verify the datatype message version: +** +** (a) Create the following datatypes: +** 1) integer +** 2) enum +** 3) array +** 4) compound +** 5) vlen +** (b) Call test_libver_bounds_datatype_check() for each +** datatype in (a) to verify the datatype message version. ** ****************************************************************/ static void -test_libver_bounds_dataset(hid_t fapl) +test_libver_bounds_datatype(hid_t fapl) { - hid_t fid; /* File ID */ - hid_t new_fapl; /* File access property list */ - hid_t did; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t dcpl; /* Dataset creation property list */ - H5D_t *dset; /* Internal dataset pointer */ - H5F_t *f; /* Internal file pointer */ - H5F_libver_t low, high; /* File format bounds */ - herr_t ret; /* Return value */ - hsize_t fix_dims2[2] = {10, 4}; /* Dimension sizes */ - hsize_t fix_chunks2[2] = {4, 3}; /* Chunk dimension sizes */ - hsize_t dims2[2] = {1, 4}; /* Dimension sizes */ - hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunks2[2] = {4, 5}; /* Chunk dimension sizes */ + hid_t tid = -1, tid_enum = -1, tid_array = -1; /* Datatype IDs */ + hid_t tid_compound = -1, tid_vlen = -1; /* Datatype IDs */ + int enum_value; /* Value for enum datatype */ + typedef struct s1 { /* Data structure for compound datatype */ + char c; + int i; + } s1; + hsize_t dims[1] = {1}; /* Dimension sizes */ + herr_t ret; /* Return value */ - /* Retrieve the library format bounds */ - ret = H5Pget_libver_bounds(fapl, &low, &high); - CHECK(ret, FAIL, "H5Pget_libver_bounds"); + /* Create integer datatype */ + tid = H5Tcopy(H5T_NATIVE_INT); - /* Create the file */ - fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + /* Verify datatype message version */ + test_libver_bounds_datatype_check(fapl, tid); - /* Create the dataspace */ - sid = H5Screate(H5S_SCALAR); - CHECK(sid, FAIL, "H5Screate"); + /* Create enum datatype */ + tid_enum = H5Tenum_create(tid); + enum_value = 0; + H5Tenum_insert(tid_enum, "val1", &enum_value); + enum_value = 1; + H5Tenum_insert(tid_enum, "val2", &enum_value); - /* Create a contiguous dataset */ - did = H5Dcreate2(fid, DSETA, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(did, FAIL, "H5Dcreate"); + /* Verify datatype message version */ + test_libver_bounds_datatype_check(fapl, tid_enum); - /* Get the internal dataset pointer */ - dset = (H5D_t *)H5I_object(did); - CHECK(dset, NULL, "H5I_object"); + /* Create array datatype */ + tid_array = H5Tarray_create2(tid, 1, dims); - /* Verify layout and fill messages version */ - if(low == H5F_LIBVER_EARLIEST) { - VERIFY(dset->shared->layout.version, LAYOUT_VERSION_DEFAULT, "layout_ver_bounds"); - VERIFY(dset->shared->dcpl_cache.fill.version, FILL_VERSION_DEFAULT, "fill_ver_bounds"); - } else { - VERIFY(dset->shared->layout.version, layout_ver_bounds[low], "layout_ver_bounds"); - VERIFY(dset->shared->dcpl_cache.fill.version, fill_ver_bounds[low], "fill_ver_bounds"); - } + /* Verify datatype message version */ + test_libver_bounds_datatype_check(fapl, tid_array); - /* Verify pline message version */ - VERIFY(dset->shared->dcpl_cache.pline.version, pline_ver_bounds[low], "pline_ver_bounds"); + /* Create compound datatype */ + tid_compound = H5Tcreate(H5T_COMPOUND, sizeof(s1)); + H5Tinsert(tid_compound, "c", HOFFSET(s1, c), H5T_STD_U8LE); + H5Tinsert(tid_compound, "i", HOFFSET(s1, i), H5T_NATIVE_INT); - /* Close the dataset */ - ret = H5Dclose(did); - CHECK(ret, FAIL, "H5Dclose"); + /* Verify datatype message version */ + test_libver_bounds_datatype_check(fapl, tid_compound); - /* Close the dataspace */ - ret = H5Sclose(sid); - CHECK(ret, FAIL, "H5Sclose"); + /* Create vlen datatype */ + tid_vlen = H5Tvlen_create(tid); - /* Create a chunked dataset with "no filter edge chunks" enabled */ - sid = H5Screate_simple(2, fix_dims2, NULL); - CHECK(sid, FAIL, "H5Screate"); - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); - ret = H5Pset_chunk(dcpl, 2, fix_chunks2); - CHECK(ret, FAIL, "H5Pset_chunk"); - ret = H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS); - CHECK(ret, FAIL, "H5Pset_chunk_opts"); + /* Verify datatype message version */ + test_libver_bounds_datatype_check(fapl, tid_vlen); - H5E_BEGIN_TRY { - did = H5Dcreate2(fid, DSETB, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - } H5E_END_TRY; + /* Close the datatypes */ + ret = H5Tclose(tid); + CHECK(ret, FAIL, "H5Tclose"); - if(did >= 0) { + ret = H5Tclose(tid_enum); + CHECK(ret, FAIL, "H5Tclose"); - /* Get the internal dataset pointer */ - dset = (H5D_t *)H5I_object(did); - CHECK(dset, NULL, "H5I_object"); + ret = H5Tclose(tid_array); + CHECK(ret, FAIL, "H5Tclose"); - VERIFY(dset->shared->layout.version, LAYOUT_VERSION_4, "layout_ver_bounds"); - VERIFY(dset->shared->layout.u.chunk.idx_type, H5D_CHUNK_IDX_FARRAY, "chunk_index_type"); + ret = H5Tclose(tid_compound); + CHECK(ret, FAIL, "H5Tclose"); - /* Close the dataset */ - ret = H5Dclose(did); - CHECK(ret, FAIL, "H5Dclose"); - } + ret = H5Tclose(tid_vlen); + CHECK(ret, FAIL, "H5Tclose"); - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); +} /* end test_libver_bounds_datatype() */ + +/**************************************************************** +** +** test_libver_bounds_datatype_check(): +** Helper routine called by test_libver_bounds_datatype() +** to verify the datatype message version for the input tid: +** +** (a) Create a file with default fcpl and the input fapl. +** Create a contiguous dataset with the input tid. +** Verify the datatype message version. +** Create a committed datatype of string to be +** used later. +** Close the file. +** +** (b) Create a new fapl that is set to the 5 pairs of low/high +** bounds in a "for" loop. For each pair of setting in +** the new fapl: +** --Open the same file in (a) with the fapl +** --Verify the message version for the committed +** datatype created earlier +** --Create a chunked dataset with the input tid +** --Verify the datatype message version +** --Close and delete the dataset +** --Close the file +** +****************************************************************/ +static void +test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) +{ + hid_t fid = -1; /* File ID */ + hid_t new_fapl = -1; /* File acess property list */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t dtid = -1; /* Datatype ID for the dataset */ + hid_t str_tid = -1; /* String datatype ID */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dims[1] = {1}; /* Dimension sizes */ + hsize_t dims2[2] = {5, 4}; /* Dimension sizes */ + hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunks[2] = {2, 3}; /* Chunk dimension sizes */ + H5T_t *dtype = NULL; /* Internal datatype pointer */ + H5T_t *str_dtype = NULL; /* Internal datatype pointer for the string datatype */ + H5F_t *f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ + herr_t ret; /* Return value */ + + /* Retrieve the low/high version bounds from the input fapl */ + ret = H5Pget_libver_bounds(fapl, &low, &high); + CHECK(ret, FAIL, "H5Pget_libver_bounds"); + + /* Create the file with the input fapl */ + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Create a committed datatype of string which will be used + later inside the 'for' loop */ + str_tid = H5Tcopy(H5T_C_S1); + CHECK(str_tid, FAIL, "H5Tcopy"); + ret = H5Tset_size(str_tid, (size_t)10); + CHECK(ret, FAIL, "H5Tset_size"); + ret = H5Tcommit2(fid, "datatype", str_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Tcommit2"); + ret = H5Tclose(str_tid); + CHECK(ret, FAIL, "H5Tclose"); + + /* Create dataspace */ + sid = H5Screate_simple(1, dims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* Create a dataset with the input tid */ + did = H5Dcreate2(fid, DSET1, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dcreate2"); + + /* Get the dataset's datatype */ + dtid = H5Dget_type(did); + CHECK(dtid, FAIL, "H5Dget_type"); + + /* Get the internal datatype pointer */ + dtype = (H5T_t *)H5I_object(dtid); + CHECK(dtype, NULL, "H5I_object"); + + /* Verify the datatype message version */ + /* H5T_COMPOUND, H5T_ENUM, H5T_ARRAY: + * --the library will set version according to low_bound + * --H5T_ARRAY: the earliest version the library will set is 2 + * H5T_INTEGER, H5T_FLOAT, H5T_TIME, H5T_STRING, H5T_BITFIELD, H5T_OPAQUE, H5T_REFERENCE: + * --the library will only use basic version + */ + if(dtype->shared->type == H5T_COMPOUND || + dtype->shared->type == H5T_ENUM || + dtype->shared->type == H5T_ARRAY) { + if(dtype->shared->type == H5T_ARRAY && low == H5F_LIBVER_EARLIEST) + VERIFY(dtype->shared->version, H5O_DTYPE_VERSION_2, "H5O_dtype_ver_bounds"); + else + VERIFY(dtype->shared->version, H5O_dtype_ver_bounds[low], "H5O_dtype_ver_bounds"); + } else + VERIFY(dtype->shared->version, H5O_dtype_ver_bounds[H5F_LIBVER_EARLIEST], "H5O_dtype_ver_bounds"); + + /* Close the dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); /* Close the dataspace */ ret = H5Sclose(sid); - CHECK(ret, FAIL, "H5Sclose"); + CHECK(ret, FAIL, "H5Dclose"); - /* Close the datset creation property list */ - ret = H5Pclose(dcpl); - CHECK(ret, FAIL, "H5Pclose"); + /* Close the datatype */ + ret = H5Tclose(dtid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); - /* Create a copy of file access property list */ + /* Create a default file access property list */ new_fapl = H5Pcreate(H5P_FILE_ACCESS); CHECK(new_fapl, FAIL, "H5Pcreate"); - /* Prepare to create a chunked dataset with 2 unlimited dimensions */ + /* Set up dataspace and dcpl for creating a chunked dataset */ sid = H5Screate_simple(2, dims2, max_dims2); - CHECK(sid, FAIL, "H5Screate"); + CHECK(sid, FAIL, "H5Screate_simple"); dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); - ret = H5Pset_chunk(dcpl, 2, chunks2); + ret = H5Pset_chunk(dcpl, 2, chunks); CHECK(ret, FAIL, "H5Pset_chunk"); - /* Loop through all the combinations of low/high library format bounds */ - /* Open the file and create the chunked dataset */ - /* Verify the dataset's layout, fill, pline message versions and chunked indexing type */ + /* Loop through all the combinations of low/high bounds */ + /* Open the file and create the chunked dataset with the input tid */ + /* Verify the dataset's datatype message version */ + /* Also verify the committed atatype message version */ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { H5E_BEGIN_TRY { @@ -5950,41 +6305,66 @@ test_libver_bounds_dataset(hid_t fapl) fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); } H5E_END_TRY; - if(fid >=0 ) { /* The file open succeeds */ + if(fid >= 0 ) { /* The file open succeeds */ /* Get the internal file pointer */ f = (H5F_t *)H5I_object(fid); CHECK(f, NULL, "H5I_object"); + /* Open the committed datatype */ + str_tid = H5Topen2(fid, "datatype", H5P_DEFAULT); + CHECK(str_tid, FAIL, "H5Topen2"); + str_dtype = (H5T_t *)H5I_object(str_tid); + CHECK(str_dtype, NULL, "H5I_object"); + + /* Verify the committed datatype message version */ + VERIFY(str_dtype->shared->version, H5O_dtype_ver_bounds[H5F_LIBVER_EARLIEST], "H5O_dtype_ver_bounds"); + + /* Close the committed datatype */ + ret = H5Tclose(str_tid); + CHECK(ret, FAIL, "H5Tclose"); + + /* Create the chunked dataset */ - did = H5Dcreate2(fid, DSETC, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + did = H5Dcreate2(fid, DSETNAME, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); CHECK(did, FAIL, "H5Dcreate2"); - /* Get the internal file pointer */ - dset = (H5D_t *)H5I_object(did); - CHECK(dset, NULL, "H5I_object"); + /* Get the dataset's datatype */ + dtid = H5Dget_type(did); + CHECK(dtid, FAIL, "H5Dget_type"); - /* Verify the dataset's layout, fill, pline message versions and chunked indexing type */ - if(f->shared->low_bound == H5F_LIBVER_EARLIEST) { - VERIFY(dset->shared->layout.version, LAYOUT_VERSION_DEFAULT, "layout_ver_bounds"); - VERIFY(dset->shared->dcpl_cache.fill.version, FILL_VERSION_DEFAULT, "fill_ver_bounds"); - } else { - VERIFY(dset->shared->layout.version, layout_ver_bounds[f->shared->low_bound], "layout_ver_bounds"); - VERIFY(dset->shared->dcpl_cache.fill.version, fill_ver_bounds[f->shared->low_bound], "fill_ver_bounds"); - } + /* Get the internal datatype pointer */ + dtype = (H5T_t *)H5I_object(dtid); + CHECK(dtype, NULL, "H5I_object"); - VERIFY(dset->shared->dcpl_cache.pline.version, pline_ver_bounds[f->shared->low_bound], "pline_ver_bounds"); - if(dset->shared->layout.version == LAYOUT_VERSION_LATEST) - VERIFY(dset->shared->layout.u.chunk.idx_type, H5D_CHUNK_IDX_BT2, "chunk_index_type"); - else - VERIFY(dset->shared->layout.u.chunk.idx_type, H5D_CHUNK_IDX_BTREE, "chunk_index_type"); + /* Verify the dataset's datatype message version */ + /* H5T_COMPOUND, H5T_ENUM, H5T_ARRAY: + * --the library will set version according to low_bound + * --H5T_ARRAY: the earliest version the library will set is 2 + * H5T_INTEGER, H5T_FLOAT, H5T_TIME, H5T_STRING, H5T_BITFIELD, H5T_OPAQUE, H5T_REFERENCE: + * --the library will only use basic version + */ + if(dtype->shared->type == H5T_COMPOUND || + dtype->shared->type == H5T_ENUM || + dtype->shared->type == H5T_ARRAY) { + if(dtype->shared->type == H5T_ARRAY && + f->shared->low_bound == H5F_LIBVER_EARLIEST) + VERIFY(dtype->shared->version, H5O_DTYPE_VERSION_2, "H5O_dtype_ver_bounds"); + else + VERIFY(dtype->shared->version, H5O_dtype_ver_bounds[f->shared->low_bound], "H5O_dtype_ver_bounds"); + } else + VERIFY(dtype->shared->version, H5O_dtype_ver_bounds[H5F_LIBVER_EARLIEST], "H5O_dtype_ver_bounds"); /* Close the dataset */ ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); + /* Close the dataset's datatype */ + ret = H5Tclose(dtid); + CHECK(ret, FAIL, "H5Tclose"); + /* Delete the dataset */ - ret = H5Ldelete(fid, DSETC, H5P_DEFAULT); + ret = H5Ldelete(fid, DSETNAME, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); /* Close the file */ @@ -6007,242 +6387,283 @@ test_libver_bounds_dataset(hid_t fapl) ret = H5Pclose(dcpl); CHECK(ret, FAIL, "H5Pclose"); -} /* end test_libver_bounds_dataset() */ +} /* end test_libver_bounds_datatype_check() */ /**************************************************************** ** -** test_libver_bounds_obj(): -** Verify object header version with the low/high library -** format bounds setting in the fapl. +** test_libver_bounds_attributes(): +** Verify the attribute message versions: +** +** (a) Create a file with default fcpl and the input fapl. +** Create a group and attach the following three attributes +** to the group: +** (1) Attribute with a committed datatype +** (2) Attribute with integer type +** (3) Attribute with character encoding set +** Verify the three attributes' message versions. +** Close the file. +** +** (b) Create a fcpl that has shared datatype message enabled. +** Create a file with the fcpl and the input fapl. +** Create a group and attach an attribute with shared +** integer type to the group. +** Verify the attribute message version. +** Close the file +** +** (b) Create a new fapl that is set to the 5 pairs of low/high +** bounds in a "for" loop. For each pair of setting in +** the new fapl: +** --Open the same file in (b) with the fapl +** --Open the group and attach an attribute with integer +** type to the group +** --Verify the attribute message version +** --Delete the attribute +** --Close the group and the file ** ****************************************************************/ static void -test_libver_bounds_obj(hid_t fapl) +test_libver_bounds_attributes(hid_t fapl) { - hid_t fid; /* File ID */ - hid_t gid; /* Group ID */ - hid_t fcpl; /* File creation property list */ - hid_t new_fapl; /* File access property list */ - H5F_t *f; /* Internal file pointer */ - H5F_libver_t low, high; /* File format bounds */ - H5O_info_t oinfo; /* Object info */ - H5G_info_t ginfo; /* Group info */ + hid_t fid = -1; /* File ID */ + hid_t fcpl = -1; /* File creation property list */ + hid_t new_fapl = -1; /* File access property list */ + hid_t tid = -1; /* Datatype ID */ + hid_t gid = -1; /* Group ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t attr_cpl = -1; /* Attribute creation property list */ + H5A_t *attr = NULL; /* Internal attribute pointer */ + H5F_t *f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ herr_t ret; /* Return value */ - /* Retrieve the format bounds */ + /* Retrieve the low/high bounds from the input fapl */ ret = H5Pget_libver_bounds(fapl, &low, &high); CHECK(ret, FAIL, "H5Pget_libver_bounds"); - /* Get a copy of file creation property list */ - fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); - - /* Enable shared message */ - ret = H5Pset_shared_mesg_nindexes(fcpl, 1); - CHECK(ret, FAIL, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_ATTR_FLAG, 2); - CHECK(ret, FAIL, "H5Pset_shared_mesg_index"); - /* Create the file */ - fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(fid, FAIL, "H5Fcreate"); - /* Get root group's object info */ - ret = H5Oget_info_by_name(fid, "/", &oinfo, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_info"); + /* Integer datatpye */ + tid = H5Tcopy(H5T_NATIVE_INT); + CHECK(tid, FAIL, "H5Tcopy"); - /* Verify object header version is 2 when shared message is enabled */ - VERIFY(oinfo.hdr.version, OBJ_VERSION_2, "H5Oget_info"); + /* Create a committed datatype */ + ret = H5Tcommit2(fid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Tcommit2"); - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); + /* Create dataspace */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); - /* Close the file creation property list */ - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Fclose"); + /* Create a group */ + gid = H5Gcreate2(fid, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); - /* Create a file with default fcpl */ - fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + /* Attach an attribute to the group with the committed datatype */ + aid = H5Acreate2(gid, "attr1", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); - /* Get root group's object info */ - ret = H5Oget_info_by_name(fid, "/", &oinfo, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_info"); + /* Get the internal attribute pointer */ + attr = (H5A_t *)H5I_object(aid); + CHECK(attr, NULL, "H5I_object"); - /* Verify object header version */ - VERIFY(oinfo.hdr.version, obj_ver_bounds[low], "obj_ver_bounds"); + /* Verify the attribute version */ + if(low == H5F_LIBVER_EARLIEST) + /* The earliest version the library can set for an attribute with committed datatype is 2 */ + VERIFY(attr->shared->version, H5O_ATTR_VERSION_2, "H5O_attr_ver_bounds"); + else + VERIFY(attr->shared->version, H5O_attr_ver_bounds[low], "H5O_attr_ver_bounds"); - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); + /* Close the attribute */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); - /* Create a copy of file access property list */ - new_fapl = H5Pcreate(H5P_FILE_ACCESS); - CHECK(new_fapl, FAIL, "H5Pcreate"); + /* Create an attribute to the group with integer type */ + aid = H5Acreate2(gid, "attr2", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); - /* Loop through all the combinations of low/high library format bounds */ - /* Open the file to verify object header version */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - H5E_BEGIN_TRY { - ret = H5Pset_libver_bounds(new_fapl, low, high); - } H5E_END_TRY; + /* Get the internal attribute pointer */ + attr = (H5A_t *)H5I_object(aid); + CHECK(attr, NULL, "H5I_object"); - if (ret < 0) /* Invalid combinations */ - continue; + /* Verify attribute version */ + VERIFY(attr->shared->version, H5O_attr_ver_bounds[low], "H5O_attr_ver_bounds"); - /* Open the file */ - H5E_BEGIN_TRY { - fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); - } H5E_END_TRY; + /* Close the attribute */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); - if(fid >=0 ) { /* The file open succeeds */ + /* Enable character encoding in attribute creation property list */ + attr_cpl = H5Pcreate(H5P_ATTRIBUTE_CREATE); + CHECK(attr_cpl, FAIL, "H5Pcreate"); + ret = H5Pset_char_encoding(attr_cpl, H5T_CSET_UTF8); + CHECK(ret, FAIL, "H5Pset_char_encoding"); - /* Get the internal file pointer */ - f = (H5F_t *)H5I_object(fid); - CHECK(f, NULL, "H5I_object"); - - /* Create a group in the file */ - gid = H5Gcreate2(fid, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(gid, FAIL, "H5Gcreate2"); - - /* Get group information */ - ret = H5Gget_info(gid, &ginfo); - CHECK(ret, FAIL, "H5Gget_info"); + /* Attach an attribute to the group with character encoding set */ + aid = H5Acreate2(gid, "attr3", H5T_NATIVE_INT, sid, attr_cpl, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); - /* Verify group storage type */ - if(f->shared->low_bound >= H5F_LIBVER_V18) - VERIFY(ginfo.storage_type, H5G_STORAGE_TYPE_COMPACT, "H5Gget_info"); - else - VERIFY(ginfo.storage_type, H5G_STORAGE_TYPE_SYMBOL_TABLE, "H5Gget_info"); + /* Get internal attribute pointer */ + attr = (H5A_t *)H5I_object(aid); + CHECK(attr, NULL, "H5I_object"); - /* Get object header information */ - ret = H5Oget_info_by_name(gid, GRP_NAME, &oinfo, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_info"); + /* Verify attribute version */ + if(low == H5F_LIBVER_EARLIEST) + /* The earliest version the library can set for an attribute with character encoding is 3 */ + VERIFY(attr->shared->version, H5O_ATTR_VERSION_3, "H5O_attr_ver_bounds"); + else + VERIFY(attr->shared->version, H5O_attr_ver_bounds[low], "H5O_attr_ver_bounds"); - /* Verify object header version */ - VERIFY(oinfo.hdr.version, obj_ver_bounds[f->shared->low_bound], "obj_ver_bounds"); + /* Close the attribute */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); - /* Close the group */ - ret = H5Gclose(gid); - CHECK(ret, FAIL, "H5Gclose"); + /* Close the attribute creation property list */ + ret = H5Pclose(attr_cpl); + CHECK(ret, FAIL, "H5Pclose"); - /* Delete the group */ - ret = H5Ldelete(fid, GRP_NAME, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Gclose"); + /* Close the group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); - } /* end if */ - } /* end for */ - } /* end for */ + /* Close the datatype */ + ret = H5Tclose(tid); + CHECK(ret, FAIL, "H5Tclose"); - /* Close the file access property list */ - ret = H5Pclose(new_fapl); - CHECK(ret, FAIL, "H5Pclose"); + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); -} /* end test_libver_bounds_obj() */ + /* Create a copy of the file creation property list */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); -/**************************************************************** -** -** test_libver_bounds_super(): -** Verify open of a file with 0, 1, 2 and 3 superblock versions. -** -****************************************************************/ -static void -test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr) -{ - hid_t fid; /* File ID */ - H5F_t *f; /* Internal file pointer */ - hid_t new_fapl; /* File access property list */ - unsigned super_vers; /* Superblock version */ - H5F_libver_t low, high; /* File format bounds */ - hbool_t ok; /* The result is ok or not */ - herr_t ret; /* Return value */ + /* Enable shared datatype message */ + ret = H5Pset_shared_mesg_nindexes(fcpl, 1); + CHECK(ret, FAIL, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_DTYPE_FLAG, 2); + CHECK(ret, FAIL, "H5Pset_shared_mesg_index"); - /* Create the file */ + /* Create the file with shared datatype message enabled */ fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); CHECK(fid, FAIL, "H5Fcreate"); - /* Get the internal file pointer */ - f = (H5F_t *)H5I_object(fid); - CHECK(f, NULL, "H5I_object"); + /* Create an integer datatye */ + tid = H5Tcopy(H5T_NATIVE_INT); + CHECK(tid, FAIL, "H5Tcopy"); - /* The file's superblock version */ - super_vers = f->shared->sblock->super_vers; + /* Create dataspace */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Create a group */ + gid = H5Gcreate2(fid, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); + + /* Attach an attribute to the group with shared integer datatype */ + aid = H5Acreate2(gid, ATTR_NAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); + + /* Get the internal attribute pointer */ + attr = (H5A_t *)H5I_object(aid); + CHECK(attr, NULL, "H5I_object"); + + /* Verify the attribute version */ + if(low == H5F_LIBVER_EARLIEST) + /* The earliest version the library can set for an attribute with shared datatype is 2 */ + VERIFY(attr->shared->version, H5O_ATTR_VERSION_2, "H5O_attr_ver_bounds"); + else + VERIFY(attr->shared->version, H5O_attr_ver_bounds[low], "H5O_attr_ver_bounds"); + + /* Close the attribute */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); + + /* Close the group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the datatype */ + ret = H5Tclose(tid); + CHECK(ret, FAIL, "H5Tclose"); /* Close the file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Create a file access property list */ + /* Create a default file access property list */ new_fapl = H5Pcreate(H5P_FILE_ACCESS); CHECK(new_fapl, FAIL, "H5Pcreate"); - /* Loop through all the combinations of low/high library format bounds */ + /* Create a scalar dataspace to be used later for the attribute */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Loop through all the combinations of low/high bounds */ + /* Open the file and group and attach an attribute to the group */ + /* Verify the attribute version */ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { H5E_BEGIN_TRY { ret = H5Pset_libver_bounds(new_fapl, low, high); } H5E_END_TRY; - /* Invalid combinations */ - if (ret < 0) + if(ret < 0) /* Invalid low/high combinations */ continue; - /* Open the file with or without SWMR */ + /* Open the file */ H5E_BEGIN_TRY { - fid = H5Fopen(FILE8, H5F_ACC_RDWR | (is_swmr ? H5F_ACC_SWMR_WRITE : 0), new_fapl); + fid = H5Fopen(FILE8, H5F_ACC_RDWR, new_fapl); } H5E_END_TRY; - ok = fid >= 0; - /* Verify the file open succeeds or fails */ - switch(super_vers) { - case 3: - if(high == H5F_LIBVER_LATEST) { - /* Should succeed */ - VERIFY(ok, TRUE, "H5Fopen"); - VERIFY(H5F_LIBVER_V110, f->shared->low_bound, "superblock_ver_bounds"); + if(fid >=0 ) { /* The file open succeeds */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); - } else /* Should fail */ - VERIFY(ok, FALSE, "H5Fopen"); - break; + /* Get the internal file pointer */ + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); - case 2: - if(is_swmr) /* Should fail */ - VERIFY(ok, FALSE, "H5Fopen"); - else { /* Should succeed */ - VERIFY(ok, TRUE, "H5Fopen"); + /* Open the group */ + gid = H5Gopen2(fid, GRP_NAME, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gopen2"); - ok = f->shared->low_bound >= H5F_LIBVER_V18; - VERIFY(ok, TRUE, "superblock_ver_bounds"); + /* Attach an attribute to the group */ + aid = H5Acreate2(gid, "attr1", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); - } - break; + /* Get the internal attribute pointer */ + attr = (H5A_t *)H5I_object(aid); + CHECK(attr, NULL, "H5I_object"); - case 1: - case 0: - if(is_swmr) /* Should fail */ - VERIFY(ok, FALSE, "H5Fopen"); - else { /* Should succeed */ - VERIFY(ok, TRUE, "H5Fopen"); - VERIFY(low, f->shared->low_bound, "superblock_ver_bounds"); + /* Verify the attribute message version */ + VERIFY(attr->shared->version, H5O_attr_ver_bounds[f->shared->low_bound], "H5O_attr_ver_bounds"); - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); - } - break; + /* Close the attribute */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); - default: - break; - } /* end switch */ + /* Delete the attribute */ + ret = H5Adelete(gid, "attr1"); + CHECK(ret, FAIL, "H5Adelete"); + + /* Close the group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + } /* end if */ } /* end for */ } /* end for */ @@ -6250,232 +6671,11 @@ test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr) ret = H5Pclose(new_fapl); CHECK(ret, FAIL, "H5Pclose"); -} /* end test_libver_bounds_super_open() */ - -/**************************************************************** -** -** test_libver_bounds_super_create(): -** Verify the superblock version with the low/high library -** version bounds setting in the fapl. -** -****************************************************************/ -static void -test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr) -{ - hid_t fid; /* File ID */ - H5F_t *f; /* Internal file pointer */ - H5F_libver_t low, high; /* File format bounds */ - hbool_t ok; /* The result is ok or not */ - herr_t ret; /* The return value */ - - /* Try to create the file */ - H5E_BEGIN_TRY { - fid = H5Fcreate(FILE8, H5F_ACC_TRUNC | (is_swmr ? H5F_ACC_SWMR_WRITE : 0), fcpl, fapl); - } H5E_END_TRY; - - /* Get the internal file pointer if the create succeeds */ - if((ok = fid >= 0)) { - f = (H5F_t *)H5I_object(fid); - CHECK(f, NULL, "H5I_object"); - } - - /* Retrieve the format bounds */ - ret = H5Pget_libver_bounds(fapl, &low, &high); - CHECK(ret, FAIL, "H5Pget_libver_bounds"); - - if(is_swmr) { /* SWMR is enabled */ - - if(high == H5F_LIBVER_LATEST) { /* Superblock version is 3 */ - VERIFY(ok, TRUE, "H5Fcreate"); - VERIFY(SUPERBLOCK_VERSION_3, f->shared->sblock->super_vers, "superblock_ver_bounds"); - VERIFY(H5F_LIBVER_V110, f->shared->low_bound, "superblock_ver_bounds"); - - } else /* Should fail */ - VERIFY(ok, FALSE, "H5Fcreate"); - - } else { /* Should succeed */ - VERIFY(ok, TRUE, "H5Fcreate"); - - switch(low) { - case H5F_LIBVER_EARLIEST: - ok = (f->shared->sblock->super_vers == 0 || - f->shared->sblock->super_vers == 1 || - f->shared->sblock->super_vers == 2); - VERIFY(ok, TRUE, "H5Fcreate"); - VERIFY(low, f->shared->low_bound, "superblock_ver_bounds"); - break; - - case H5F_LIBVER_V18: - ok = (f->shared->sblock->super_vers == 2); - VERIFY(ok, TRUE, "H5Fcreate"); - VERIFY(low, f->shared->low_bound, "superblock_ver_bounds"); - break; - - case H5F_LIBVER_V110: - ok = (f->shared->sblock->super_vers == 3); - VERIFY(ok, TRUE, "H5Fcreate"); - VERIFY(low, f->shared->low_bound, "superblock_ver_bounds"); - break; - - case H5F_LIBVER_ERROR: - case H5F_LIBVER_NBOUNDS: - default: - ERROR("H5Pget_libver_bounds"); - - } /* end switch */ - } - - if(ok) { /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); - } - -} /* end test_libver_bounds_super_create() */ - -/**************************************************************** -** -** test_libver_bounds_super(): -** Verify superblock version via: -** test_libver_bounds_super_create() -** test_libver_bounds_super_open() -** -****************************************************************/ -static void -test_libver_bounds_super(hid_t fapl) -{ - hid_t fcpl; - herr_t ret; - - /* Create a default fcpl */ - fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); - - /* Verify superblock version is 0 when creating a file with or without SWMR */ - test_libver_bounds_super_create(fapl, fcpl, TRUE); - test_libver_bounds_super_create(fapl, fcpl, FALSE); - - /* Verify opening a file with or without SWMR when superblock version is 0 */ - test_libver_bounds_super_open(fapl, fcpl, TRUE); - test_libver_bounds_super_open(fapl, fcpl, FALSE); - - /* Close fcpl */ - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Pclose"); - - /* Create fcpl with non-default v1-btree K value enabled */ - fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); - - ret = H5Pset_istore_k(fcpl, 64); - CHECK(ret, FAIL, "H5Pset_istore_k"); - - /* Verify superblock version is 1 when creating a file with or without SWMR */ - test_libver_bounds_super_create(fapl, fcpl, TRUE); - test_libver_bounds_super_create(fapl, fcpl, FALSE); - - /* Verify opening a file with or without SWMR when superblock version is 1 */ - test_libver_bounds_super_open(fapl, fcpl, TRUE); - test_libver_bounds_super_open(fapl, fcpl, FALSE); - - /* Close fcpl */ - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Pclose"); - - /* Create fcpl with shared messages enabled */ - fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); - ret = H5Pset_shared_mesg_nindexes(fcpl, 1); - CHECK(ret, FAIL, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_ATTR_FLAG, 2); - CHECK(ret, FAIL, "H5Pset_shared_mesg_index"); - - /* Verify superblock version is 2 when creating a file with or without SWMR */ - test_libver_bounds_super_create(fapl, fcpl, TRUE); - test_libver_bounds_super_create(fapl, fcpl, FALSE); - - /* Verify opening a file with or without SWMR when superblock version is 2 */ - test_libver_bounds_super_open(fapl, fcpl, TRUE); - test_libver_bounds_super_open(fapl, fcpl, FALSE); - - /* Close fcpl */ - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Pclose"); - - /* Create fcpl with persistent free-space enabled */ - fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); - ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0); - CHECK(ret, FAIL, "H5Pset_file_space"); - - /* Verify superblock version is 2 when creating a file with or without SWMR */ - test_libver_bounds_super_create(fapl, fcpl, TRUE); - test_libver_bounds_super_create(fapl, fcpl, FALSE); - - /* Verify opening a file with or without SWMR when superblock version is 2 */ - test_libver_bounds_super_open(fapl, fcpl, TRUE); - test_libver_bounds_super_open(fapl, fcpl, FALSE); - - /* Close fcpl */ - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Pclose"); - -} /* end test_libver_bounds_super() */ - -/**************************************************************** -** -** test_libver_bounds_low_high(): -** Tests to verify that format versions are correct with the five -** pairs of (low, high) combinations via H5Pset_libver_bounds(). -** -****************************************************************/ -static void -test_libver_bounds_low_high(void) -{ - hid_t fapl; - H5F_libver_t low, high; - herr_t ret; - - /* Output message about test being performed */ - MESSAGE(5, ("Testing setting library version bounds for (low, high) bounds\n")); - - fapl = H5Pcreate(H5P_FILE_ACCESS); - CHECK(fapl, FAIL, "H5Pcreate"); - - /* Loop through all the combinations of low/high library format bounds */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - H5E_BEGIN_TRY { - ret = H5Pset_libver_bounds(fapl, low, high); - } H5E_END_TRY; - - /* Should fail: invalid combinations */ - if(high == H5F_LIBVER_EARLIEST) { - VERIFY(ret, FAIL, "H5Pset_libver_bounds"); - continue; - } - - /* Should fail: invalid combinations */ - if(high < low) { - VERIFY(ret, FAIL, "H5Pset_libver_bounds"); - continue; - } - - /* All other combinations are valid and should succeed */ - VERIFY(ret, SUCCEED, "H5Pset_libver_bounds"); - - /* Tests to verify format versions */ - test_libver_bounds_super(fapl); - test_libver_bounds_obj(fapl); - test_libver_bounds_dataset(fapl); - test_libver_bounds_dataspace(fapl); - test_libver_bounds_datatype(fapl); - test_libver_bounds_attributes(fapl); - } - - ret = H5Pclose(fapl); - CHECK(ret, FAIL, "H5Pclose"); + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); -} /* end test_libver_bounds_low_high() */ +} /* end test_libver_bounds_attributes() */ /**************************************************************** ** -- cgit v0.12 From d202b3cfa14baf3a32fdf03b1e59759fe2a67c6b Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Tue, 16 Jan 2018 17:35:29 -0600 Subject: Modify h5repack usage so that it is more descriptive. --- tools/src/h5repack/h5repack_main.c | 21 ++++++++++++++++----- tools/test/h5repack/testfiles/h5repack-help.txt | 19 +++++++++++++++---- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 037aa4a..9a24057 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -83,10 +83,13 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " -v, --verbose Verbose mode, print object information\n"); PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n"); + PRINTVALSTREAM(rawoutstream, " -E --enable-error-stack Prints messages from the HDF5 error stack as they occur\n"); PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n"); PRINTVALSTREAM(rawoutstream, " This option will take precedence over the -j and -k options\n"); - PRINTVALSTREAM(rawoutstream, " -j, --low The low bound as in H5Pset_libver_bounds()\n"); - PRINTVALSTREAM(rawoutstream, " -k, --high The high bound as in H5Pset_libver_bounds()\n"); + PRINTVALSTREAM(rawoutstream, " -j BOUND, --low=BOUND The low bound for library release versions to use when creating\n"); + PRINTVALSTREAM(rawoutstream, " objects in the file\n"); + PRINTVALSTREAM(rawoutstream, " -k BOUND, --high=BOUND The high bound for library release versions to use when creating\n"); + PRINTVALSTREAM(rawoutstream, " objects in the file\n"); PRINTVALSTREAM(rawoutstream, " -c L1, --compact=L1 Maximum number of links in header messages\n"); PRINTVALSTREAM(rawoutstream, " -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); PRINTVALSTREAM(rawoutstream, " -s S[:F], --ssize=S[:F] Shared object header message minimum size\n"); @@ -119,8 +122,11 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " F - is the shared object header message type, any of . If F is not specified, S applies to all messages\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n"); - PRINTVALSTREAM(rawoutstream, " occur.\n"); + PRINTVALSTREAM(rawoutstream, " BOUND is an integer indicating the library release versions to use when creating\n"); + PRINTVALSTREAM(rawoutstream, " objects in the file (see H5Pset_libver_bounds()):\n"); + PRINTVALSTREAM(rawoutstream, " 0: This is H5F_LIBVER_EARLIEST in H5F_libver_t struct\n"); + PRINTVALSTREAM(rawoutstream, " 1: This is H5F_LIBVER_V18 in H5F_libver_t struct\n"); + PRINTVALSTREAM(rawoutstream, " 2: This is H5F_LIBVER_V110 in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " FS_STRATEGY is a string indicating the file space strategy used:\n"); PRINTVALSTREAM(rawoutstream, " FSM_AGGR:\n"); @@ -210,6 +216,11 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " Using latest file format with maximum compact group size of 10 and\n"); PRINTVALSTREAM(rawoutstream, " and minimum shared datatype size of 20\n"); PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, "5) h5repack -j 0 -k 1 file1 file2\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " Set low=H5F_LIBVER_EARLIEST and high=H5F_LIBVER_V18 via H5Pset_libver_bounds() when\n"); + PRINTVALSTREAM(rawoutstream, " creating the repacked file: file2\n"); + PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, "5) h5repack -f SHUF -f GZIP=1 file1 file2\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " Add both filters SHUF and GZIP in this order to all datasets\n"); @@ -655,7 +666,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'E': - enable_error_stack = TRUE; + enable_error_stack = TRUE; break; default: diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt index 77e2178..da75e9f 100644 --- a/tools/test/h5repack/testfiles/h5repack-help.txt +++ b/tools/test/h5repack/testfiles/h5repack-help.txt @@ -6,10 +6,13 @@ usage: h5repack [OPTIONS] file1 file2 -v, --verbose Verbose mode, print object information -V, --version Print version number and exit -n, --native Use a native HDF5 type when repacking + -E --enable-error-stack Prints messages from the HDF5 error stack as they occur -L, --latest Use latest version of file format This option will take precedence over the -j and -k options - -j, --low The low bound as in H5Pset_libver_bounds() - -k, --high The high bound as in H5Pset_libver_bounds() + -j BOUND, --low=BOUND The low bound for library release versions to use when creating + objects in the file + -k BOUND, --high=BOUND The high bound for library release versions to use when creating + objects in the file -c L1, --compact=L1 Maximum number of links in header messages -d L2, --indexed=L2 Minimum number of links in the indexed format -s S[:F], --ssize=S[:F] Shared object header message minimum size @@ -42,8 +45,11 @@ usage: h5repack [OPTIONS] file1 file2 F - is the shared object header message type, any of . If F is not specified, S applies to all messages - --enable-error-stack Prints messages from the HDF5 error stack as they - occur. + BOUND is an integer indicating the library release versions to use when creating + objects in the file (see H5Pset_libver_bounds()): + 0: This is H5F_LIBVER_EARLIEST in H5F_libver_t struct + 1: This is H5F_LIBVER_V18 in H5F_libver_t struct + 2: This is H5F_LIBVER_V110 in H5F_libver_t struct FS_STRATEGY is a string indicating the file space strategy used: FSM_AGGR: @@ -133,6 +139,11 @@ Examples of use: Using latest file format with maximum compact group size of 10 and and minimum shared datatype size of 20 +5) h5repack -j 0 -k 1 file1 file2 + + Set low=H5F_LIBVER_EARLIEST and high=H5F_LIBVER_V18 via H5Pset_libver_bounds() when + creating the repacked file: file2 + 5) h5repack -f SHUF -f GZIP=1 file1 file2 Add both filters SHUF and GZIP in this order to all datasets -- cgit v0.12 From f122d6f27f85245f2f559c85064eabf91a631b27 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Thu, 18 Jan 2018 14:26:13 -0600 Subject: Modify usage description for -j and -k options so that it is more informative. --- tools/src/h5repack/h5repack_main.c | 5 +++-- tools/test/h5repack/testfiles/h5repack-help.txt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 9a24057..6121f81 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -87,9 +87,9 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n"); PRINTVALSTREAM(rawoutstream, " This option will take precedence over the -j and -k options\n"); PRINTVALSTREAM(rawoutstream, " -j BOUND, --low=BOUND The low bound for library release versions to use when creating\n"); - PRINTVALSTREAM(rawoutstream, " objects in the file\n"); + PRINTVALSTREAM(rawoutstream, " objects in the file (default is H5F_LIBVER_EARLIEST)\n"); PRINTVALSTREAM(rawoutstream, " -k BOUND, --high=BOUND The high bound for library release versions to use when creating\n"); - PRINTVALSTREAM(rawoutstream, " objects in the file\n"); + PRINTVALSTREAM(rawoutstream, " objects in the file (default is H5F_LIBVER_LATEST)\n"); PRINTVALSTREAM(rawoutstream, " -c L1, --compact=L1 Maximum number of links in header messages\n"); PRINTVALSTREAM(rawoutstream, " -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); PRINTVALSTREAM(rawoutstream, " -s S[:F], --ssize=S[:F] Shared object header message minimum size\n"); @@ -127,6 +127,7 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " 0: This is H5F_LIBVER_EARLIEST in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, " 1: This is H5F_LIBVER_V18 in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, " 2: This is H5F_LIBVER_V110 in H5F_libver_t struct\n"); + PRINTVALSTREAM(rawoutstream, " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V110 for this release\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " FS_STRATEGY is a string indicating the file space strategy used:\n"); PRINTVALSTREAM(rawoutstream, " FSM_AGGR:\n"); diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt index da75e9f..723711d 100644 --- a/tools/test/h5repack/testfiles/h5repack-help.txt +++ b/tools/test/h5repack/testfiles/h5repack-help.txt @@ -10,9 +10,9 @@ usage: h5repack [OPTIONS] file1 file2 -L, --latest Use latest version of file format This option will take precedence over the -j and -k options -j BOUND, --low=BOUND The low bound for library release versions to use when creating - objects in the file + objects in the file (default is H5F_LIBVER_EARLIEST) -k BOUND, --high=BOUND The high bound for library release versions to use when creating - objects in the file + objects in the file (default is H5F_LIBVER_LATEST) -c L1, --compact=L1 Maximum number of links in header messages -d L2, --indexed=L2 Minimum number of links in the indexed format -s S[:F], --ssize=S[:F] Shared object header message minimum size @@ -50,6 +50,7 @@ usage: h5repack [OPTIONS] file1 file2 0: This is H5F_LIBVER_EARLIEST in H5F_libver_t struct 1: This is H5F_LIBVER_V18 in H5F_libver_t struct 2: This is H5F_LIBVER_V110 in H5F_libver_t struct + (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V110 for this release FS_STRATEGY is a string indicating the file space strategy used: FSM_AGGR: -- cgit v0.12 From 8427eefafe7af83dbc133975c3ac2368cf1b08d6 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Mon, 22 Jan 2018 17:40:44 -0600 Subject: Fix bounds check for the generation of cache image. --- src/H5Cimage.c | 5 ++++- src/H5Fint.c | 4 ---- src/H5Fsuper.c | 4 ---- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/H5Cimage.c b/src/H5Cimage.c index 53d1712..be2560f 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -1382,9 +1382,12 @@ H5C__prep_image_for_file_close(H5F_t *f, hid_t dxpl_id, hbool_t *image_generated * Note that under some error conditions, the superblock will be * undefined in this case as well -- if so, assume that the * superblock does not support superblock extension messages. + * Also verify that the file's high_bound is at least release + * 1.10.x, otherwise cancel the request for a cache image */ if((NULL == f->shared->sblock) || - (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2)) { + (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) || + (f->shared->high_bound < H5F_LIBVER_V110)) { H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; cache_ptr->image_ctl = default_image_ctl; diff --git a/src/H5Fint.c b/src/H5Fint.c index 9d79481..86627ea 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -930,10 +930,6 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, &(f->shared->mdc_initCacheImageCfg)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get initial metadata cache resize config") - /* Format version high bound does not allow the generation of metadata cache image */ - if(f->shared->mdc_initCacheImageCfg.generate_image && f->shared->high_bound < H5F_LIBVER_V110) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "format version out of bound for cache image") - /* Get the VFD values to cache */ f->shared->maxaddr = H5FD_get_maxaddr(lf); if(!H5F_addr_defined(f->shared->maxaddr)) diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index d30434d..4250ff0 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -856,10 +856,6 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial hbool_t rw = ((rw_flags & H5AC__READ_ONLY_FLAG) == 0); H5O_mdci_t mdci_msg; - /* Message exists but version high bound does not allow it */ - if(f->shared->high_bound < H5F_LIBVER_V110) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "format version out of bound for metadata cache image") - /* if the metadata cache image superblock extension message exists, * read its contents and pass the data on to the metadata cache. * Given this data, the cache will load and decode the metadata -- cgit v0.12 From 4c0440e61f5bc57f12406b523e9545980e9e6b70 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Thu, 1 Feb 2018 09:49:50 -0600 Subject: Added gen_bounds.c --- MANIFEST | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST b/MANIFEST index 2db6d6b..7f4c377 100644 --- a/MANIFEST +++ b/MANIFEST @@ -981,6 +981,7 @@ ./test/gen_bad_ohdr.c ./test/gen_bad_compound.c ./test/gen_bogus.c +./test/gen_bounds.c ./test/gen_cross.c ./test/gen_deflate.c ./test/gen_file_image.c -- cgit v0.12 From a32b998b824a488c7822b0d607ab7f01ac9ccd23 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Thu, 1 Feb 2018 10:08:34 -0600 Subject: Added gen_bounds.c --- test/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile.am b/test/Makefile.am index efdc1ca..ab81f50 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -95,7 +95,7 @@ endif BUILD_ALL_PROGS=gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_new_array \ gen_new_fill gen_new_group gen_new_mtime gen_new_super gen_noencoder \ gen_nullspace gen_udlinks space_overflow gen_filespace gen_specmetaread \ - gen_sizes_lheap gen_file_image gen_plist gen_bad_offset + gen_sizes_lheap gen_file_image gen_plist gen_bad_offset gen_bounds if BUILD_ALL_CONDITIONAL noinst_PROGRAMS=$(BUILD_ALL_PROGS) -- cgit v0.12 From 2fbdfcc4574a141bc668795db9cb48678ba9e336 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Tue, 6 Feb 2018 21:42:02 -0600 Subject: Modifications made based on comments from pull request. --- src/H5Aint.c | 2 +- src/H5Dint.c | 1 + src/H5Fint.c | 8 +- src/H5Fprivate.h | 10 +- src/H5Fquery.c | 4 +- src/H5Ofill.c | 4 +- src/H5Pfapl.c | 36 +- src/H5Tcommit.c | 1 + src/H5trace.c | 1040 +++++++++++------------ test/testfiles/plist_files/dapl_32be | Bin 186 -> 199 bytes test/testfiles/plist_files/dapl_32le | Bin 186 -> 199 bytes test/testfiles/plist_files/dapl_64be | Bin 186 -> 199 bytes test/testfiles/plist_files/dapl_64le | Bin 186 -> 199 bytes test/testfiles/plist_files/def_dapl_32be | Bin 181 -> 194 bytes test/testfiles/plist_files/def_dapl_32le | Bin 181 -> 194 bytes test/testfiles/plist_files/def_dapl_64be | Bin 181 -> 194 bytes test/testfiles/plist_files/def_dapl_64le | Bin 181 -> 194 bytes test/testfiles/plist_files/def_fapl_32be | Bin 1697 -> 1711 bytes test/testfiles/plist_files/def_fapl_32le | Bin 1697 -> 1711 bytes test/testfiles/plist_files/def_fapl_64be | Bin 1697 -> 1711 bytes test/testfiles/plist_files/def_fapl_64le | Bin 1697 -> 1711 bytes test/testfiles/plist_files/fapl_32be | Bin 1699 -> 1713 bytes test/testfiles/plist_files/fapl_32le | Bin 1699 -> 1713 bytes test/testfiles/plist_files/fapl_64be | Bin 1699 -> 1713 bytes test/testfiles/plist_files/fapl_64le | Bin 1699 -> 1713 bytes test/testfiles/plist_files/lapl_32be | Bin 1802 -> 1816 bytes test/testfiles/plist_files/lapl_32le | Bin 1802 -> 1816 bytes test/testfiles/plist_files/lapl_64be | Bin 1802 -> 1816 bytes test/testfiles/plist_files/lapl_64le | Bin 1802 -> 1816 bytes tools/src/h5repack/h5repack_main.c | 8 +- tools/test/h5repack/testfiles/h5repack-help.txt | 8 +- 31 files changed, 562 insertions(+), 560 deletions(-) diff --git a/src/H5Aint.c b/src/H5Aint.c index 666f11d..55c46f6 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -215,7 +215,7 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, if(H5T_set_loc(attr->shared->dt, loc->oloc->file, H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") - /* Set the latest format for datatype, if requested */ + /* Set the version for datatype */ if(H5T_set_version(loc->oloc->file, attr->shared->dt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set version of datatype") diff --git a/src/H5Dint.c b/src/H5Dint.c index 9af1689..fc191ff 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -661,6 +661,7 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) if(H5T_set_loc(dset->shared->type, file, H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't set datatype location") + /* Set the version for datatype */ if(H5T_set_version(file, dset->shared->type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set version of datatype") diff --git a/src/H5Fint.c b/src/H5Fint.c index 86627ea..c41453a 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -161,9 +161,9 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't sieve buffer size") if(H5P_set(new_plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' cache size") - if(H5P_set(new_plist, H5F_ACS_FORMAT_LOW_BOUND_NAME, &f->shared->low_bound) < 0) + if(H5P_set(new_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &f->shared->low_bound) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'low' bound for library format versions") - if(H5P_set(new_plist, H5F_ACS_FORMAT_HIGH_BOUND_NAME, &f->shared->high_bound) < 0) + if(H5P_set(new_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &f->shared->high_bound) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'high' bound for library format versions") if(H5P_set(new_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &(f->shared->read_attempts)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'read attempts ' flag") @@ -902,9 +902,9 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get garbage collect reference") if(H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get sieve buffer size") - if(H5P_get(plist, H5F_ACS_FORMAT_LOW_BOUND_NAME, &(f->shared->low_bound)) < 0) + if(H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &(f->shared->low_bound)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'low' bound for library format versions") - if(H5P_get(plist, H5F_ACS_FORMAT_HIGH_BOUND_NAME, &(f->shared->high_bound)) < 0) + if(H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &(f->shared->high_bound)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'high' bound for library format versions") if(H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &(f->shared->use_mdc_logging)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'use mdc logging' flag") diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index e426a4b..856e618 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -484,8 +484,8 @@ typedef struct H5F_t H5F_t; #define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ #define H5F_ACS_FAMILY_TO_SEC2_NAME "family_to_sec2" /* Whether to convert family to sec2 driver. (private property only used by h5repart) */ #define H5F_ACS_MULTI_TYPE_NAME "multi_type" /* Data type in multi file driver */ -#define H5F_ACS_FORMAT_LOW_BOUND_NAME "low_bound" /* 'low' bound of library format versions */ -#define H5F_ACS_FORMAT_HIGH_BOUND_NAME "high_bound" /* 'high' bound of library format versions */ +#define H5F_ACS_LIBVER_LOW_BOUND_NAME "libver_low_bound" /* 'low' bound of library format versions */ +#define H5F_ACS_LIBVER_HIGH_BOUND_NAME "libver_high_bound" /* 'high' bound of library format versions */ #define H5F_ACS_WANT_POSIX_FD_NAME "want_posix_fd" /* Internal: query the file descriptor from the core VFD, instead of the memory address */ #define H5F_ACS_METADATA_READ_ATTEMPTS_NAME "metadata_read_attempts" /* # of metadata read attempts */ #define H5F_ACS_OBJECT_FLUSH_CB_NAME "object_flush_cb" /* Object flush callback */ @@ -720,9 +720,9 @@ H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id); H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed/*out*/); -/* Functions than retrieve values from the file struct */ -H5_DLL unsigned H5F_get_low_bound(const H5F_t *f); -H5_DLL unsigned H5F_get_high_bound(const H5F_t *f); +/* Functions that retrieve values from the file struct */ +H5_DLL H5F_libver_t H5F_get_low_bound(const H5F_t *f); +H5_DLL H5F_libver_t H5F_get_high_bound(const H5F_t *f); H5_DLL unsigned H5F_get_intent(const H5F_t *f); H5_DLL char *H5F_get_open_name(const H5F_t *f); H5_DLL char *H5F_get_actual_name(const H5F_t *f); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 32c893e..f7e222e 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -109,7 +109,7 @@ H5F_get_intent(const H5F_t *f) * *------------------------------------------------------------------------- */ -unsigned +H5F_libver_t H5F_get_low_bound(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ @@ -134,7 +134,7 @@ H5F_get_low_bound(const H5F_t *f) * *------------------------------------------------------------------------- */ -unsigned +H5F_libver_t H5F_get_high_bound(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ diff --git a/src/H5Ofill.c b/src/H5Ofill.c index 6dc3064..74f69d1 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -929,10 +929,10 @@ H5O_fill_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Data type:"); if(fill->type) { H5T_debug(fill->type, stream); - fprintf(stream, "\n"); + HDfprintf(stream, "\n"); } /* end if */ else - fprintf(stream, "\n"); + HDfprintf(stream, "\n"); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_fill_debug() */ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 7b358a9..7802535 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -142,16 +142,16 @@ #define H5F_ACS_MULTI_TYPE_DEC H5P__facc_multi_type_dec /* Definition for "low" bound of library format versions */ -#define H5F_ACS_FORMAT_LOW_BOUND_SIZE sizeof(H5F_libver_t) -#define H5F_ACS_FORMAT_LOW_BOUND_DEF H5F_LIBVER_EARLIEST -#define H5F_ACS_FORMAT_LOW_BOUND_ENC H5P__facc_libver_type_enc -#define H5F_ACS_FORMAT_LOW_BOUND_DEC H5P__facc_libver_type_dec +#define H5F_ACS_LIBVER_LOW_BOUND_SIZE sizeof(H5F_libver_t) +#define H5F_ACS_LIBVER_LOW_BOUND_DEF H5F_LIBVER_EARLIEST +#define H5F_ACS_LIBVER_LOW_BOUND_ENC H5P__facc_libver_type_enc +#define H5F_ACS_LIBVER_LOW_BOUND_DEC H5P__facc_libver_type_dec /* Definition for "high" bound of library format versions */ -#define H5F_ACS_FORMAT_HIGH_BOUND_SIZE sizeof(H5F_libver_t) -#define H5F_ACS_FORMAT_HIGH_BOUND_DEF H5F_LIBVER_LATEST -#define H5F_ACS_FORMAT_HIGH_BOUND_ENC H5P__facc_libver_type_enc -#define H5F_ACS_FORMAT_HIGH_BOUND_DEC H5P__facc_libver_type_dec +#define H5F_ACS_LIBVER_HIGH_BOUND_SIZE sizeof(H5F_libver_t) +#define H5F_ACS_LIBVER_HIGH_BOUND_DEF H5F_LIBVER_LATEST +#define H5F_ACS_LIBVER_HIGH_BOUND_ENC H5P__facc_libver_type_enc +#define H5F_ACS_LIBVER_HIGH_BOUND_DEC H5P__facc_libver_type_dec /* Definition for whether to query the file descriptor from the core VFD * instead of the memory address. (Private to library) @@ -363,8 +363,8 @@ static const hsize_t H5F_def_family_newsize_g = H5F_ACS_FAMILY_NEWSIZE_DEF; static const hbool_t H5F_def_family_to_sec2_g = H5F_ACS_FAMILY_TO_SEC2_DEF; /* Default ?? for family VFD */ static const H5FD_mem_t H5F_def_mem_type_g = H5F_ACS_MULTI_TYPE_DEF; /* Default file space type for multi VFD */ -static const H5F_libver_t H5F_def_format_low_bound_g = H5F_ACS_FORMAT_LOW_BOUND_DEF; /* Default setting for "low" bound of format version */ -static const H5F_libver_t H5F_def_format_high_bound_g = H5F_ACS_FORMAT_HIGH_BOUND_DEF; /* Default setting for "high" bound of format version */ +static const H5F_libver_t H5F_def_libver_low_bound_g = H5F_ACS_LIBVER_LOW_BOUND_DEF; /* Default setting for "low" bound of format version */ +static const H5F_libver_t H5F_def_libver_high_bound_g = H5F_ACS_LIBVER_HIGH_BOUND_DEF; /* Default setting for "high" bound of format version */ static const hbool_t H5F_def_want_posix_fd_g = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */ static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */ @@ -505,14 +505,14 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 'low' bound of library format versions */ - if(H5P_register_real(pclass, H5F_ACS_FORMAT_LOW_BOUND_NAME, H5F_ACS_FORMAT_LOW_BOUND_SIZE, &H5F_def_format_low_bound_g, - NULL, NULL, NULL, H5F_ACS_FORMAT_LOW_BOUND_ENC, H5F_ACS_FORMAT_LOW_BOUND_DEC, + if(H5P_register_real(pclass, H5F_ACS_LIBVER_LOW_BOUND_NAME, H5F_ACS_LIBVER_LOW_BOUND_SIZE, &H5F_def_libver_low_bound_g, + NULL, NULL, NULL, H5F_ACS_LIBVER_LOW_BOUND_ENC, H5F_ACS_LIBVER_LOW_BOUND_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 'high' bound of library format versions */ - if(H5P_register_real(pclass, H5F_ACS_FORMAT_HIGH_BOUND_NAME, H5F_ACS_FORMAT_HIGH_BOUND_SIZE, &H5F_def_format_high_bound_g, - NULL, NULL, NULL, H5F_ACS_FORMAT_HIGH_BOUND_ENC, H5F_ACS_FORMAT_HIGH_BOUND_DEC, + if(H5P_register_real(pclass, H5F_ACS_LIBVER_HIGH_BOUND_NAME, H5F_ACS_LIBVER_HIGH_BOUND_SIZE, &H5F_def_libver_high_bound_g, + NULL, NULL, NULL, H5F_ACS_LIBVER_HIGH_BOUND_ENC, H5F_ACS_LIBVER_HIGH_BOUND_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") @@ -2374,9 +2374,9 @@ H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, H5F_libver_t high) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_FORMAT_LOW_BOUND_NAME, &low) < 0) + if(H5P_set(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &low) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set low bound for library format versions") - if(H5P_set(plist, H5F_ACS_FORMAT_HIGH_BOUND_NAME, &high) < 0) + if(H5P_set(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &high) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set high bound for library format versions") done: FUNC_LEAVE_API(ret_value) @@ -2412,12 +2412,12 @@ H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low/*out*/, /* Get values */ if(low) { - if(H5P_get(plist, H5F_ACS_FORMAT_LOW_BOUND_NAME, low) < 0) + if(H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, low) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get low bound for library format versions") } if(high) { - if(H5P_get(plist, H5F_ACS_FORMAT_HIGH_BOUND_NAME, high) < 0) + if(H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, high) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get high bound for library format versions") } diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 02a6add..cd0597c 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -349,6 +349,7 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize path") loc_init = TRUE; + /* Set the version for datatype */ if(H5T_set_version(file, type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set version of datatype") diff --git a/src/H5trace.c b/src/H5trace.c index b1f05ba..32e05a7 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -174,26 +174,26 @@ H5_trace(const double *returning, const char *func, const char *type, ...) if(H5_debug_g.ttimes) { char tmp[128]; - sprintf(tmp, "%.6f", event_time.etime-first_time.etime); - fprintf(out, " %*s ", (int)HDstrlen(tmp), ""); + HDsprintf(tmp, "%.6f", event_time.etime-first_time.etime); + HDfprintf(out, " %*s ", (int)HDstrlen(tmp), ""); } /* end if */ for(i = 0; i < current_depth; i++) HDfputc('+', out); - fprintf(out, "%*s%s = ", 2*current_depth, "", func); + HDfprintf(out, "%*s%s = ", 2*current_depth, "", func); } /* end if */ else { /* Continue current line with return value */ - fprintf(out, " = "); + HDfprintf(out, " = "); } /* end else */ } /* end if */ else { if(current_depth>last_call_depth) HDfputs(" = \n", out); if(H5_debug_g.ttimes) - fprintf(out, "@%.6f ", event_time.etime - first_time.etime); + HDfprintf(out, "@%.6f ", event_time.etime - first_time.etime); for(i = 0; i < current_depth; i++) HDfputc('+', out); - fprintf(out, "%*s%s(", 2*current_depth, "", func); + HDfprintf(out, "%*s%s(", 2*current_depth, "", func); } /* end else */ /* Clear array sizes */ @@ -235,7 +235,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) buf[MIN((int)sizeof(buf) - 1, n)] = '\0'; argname = buf; } /* end if */ - fprintf(out, "%s%s=", argno?", ":"", argname); + HDfprintf(out, "%s%s=", argno?", ":"", argname); } /* end if */ else argname = ""; @@ -247,9 +247,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { haddr_t addr = va_arg(ap, haddr_t); @@ -261,33 +261,33 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'b': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { /* Can't pass hbool_t to va_arg() */ hbool_t bool_var = (hbool_t)va_arg(ap, int); if(TRUE == bool_var) - fprintf(out, "TRUE"); + HDfprintf(out, "TRUE"); else if(!bool_var) - fprintf(out, "FALSE"); + HDfprintf(out, "FALSE"); else - fprintf(out, "TRUE(%u)", (unsigned)bool_var); + HDfprintf(out, "TRUE(%u)", (unsigned)bool_var); } break; case 'd': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { double dbl = va_arg(ap, double); - fprintf(out, "%g", dbl); + HDfprintf(out, "%g", dbl); } /* end else */ break; @@ -296,36 +296,36 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - fprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_alloc_time_t alloc_time = (H5D_alloc_time_t)va_arg(ap, int); switch(alloc_time) { case H5D_ALLOC_TIME_ERROR: - fprintf(out, "H5D_ALLOC_TIME_ERROR"); + HDfprintf(out, "H5D_ALLOC_TIME_ERROR"); break; case H5D_ALLOC_TIME_DEFAULT: - fprintf(out, "H5D_ALLOC_TIME_DEFAULT"); + HDfprintf(out, "H5D_ALLOC_TIME_DEFAULT"); break; case H5D_ALLOC_TIME_EARLY: - fprintf(out, "H5D_ALLOC_TIME_EARLY"); + HDfprintf(out, "H5D_ALLOC_TIME_EARLY"); break; case H5D_ALLOC_TIME_LATE: - fprintf(out, "H5D_ALLOC_TIME_LATE"); + HDfprintf(out, "H5D_ALLOC_TIME_LATE"); break; case H5D_ALLOC_TIME_INCR: - fprintf(out, "H5D_ALLOC_TIME_INCR"); + HDfprintf(out, "H5D_ALLOC_TIME_INCR"); break; default: - fprintf(out, "%ld", (long)alloc_time); + HDfprintf(out, "%ld", (long)alloc_time); break; } /* end switch */ } /* end else */ @@ -334,24 +334,24 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5FD_mpio_collective_opt_t opt = (H5FD_mpio_collective_opt_t)va_arg(ap, int); switch(opt) { case H5FD_MPIO_COLLECTIVE_IO: - fprintf(out, "H5FD_MPIO_COLLECTIVE_IO"); + HDfprintf(out, "H5FD_MPIO_COLLECTIVE_IO"); break; case H5FD_MPIO_INDIVIDUAL_IO: - fprintf(out, "H5FD_MPIO_INDIVIDUAL_IO"); + HDfprintf(out, "H5FD_MPIO_INDIVIDUAL_IO"); break; default: - fprintf(out, "%ld", (long)opt); + HDfprintf(out, "%ld", (long)opt); break; } /* end switch */ } /* end else */ @@ -360,32 +360,32 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_fill_time_t fill_time = (H5D_fill_time_t)va_arg(ap, int); switch(fill_time) { case H5D_FILL_TIME_ERROR: - fprintf(out, "H5D_FILL_TIME_ERROR"); + HDfprintf(out, "H5D_FILL_TIME_ERROR"); break; case H5D_FILL_TIME_ALLOC: - fprintf(out, "H5D_FILL_TIME_ALLOC"); + HDfprintf(out, "H5D_FILL_TIME_ALLOC"); break; case H5D_FILL_TIME_NEVER: - fprintf(out, "H5D_FILL_TIME_NEVER"); + HDfprintf(out, "H5D_FILL_TIME_NEVER"); break; case H5D_FILL_TIME_IFSET: - fprintf(out, "H5D_FILL_TIME_IFSET"); + HDfprintf(out, "H5D_FILL_TIME_IFSET"); break; default: - fprintf(out, "%ld", (long)fill_time); + HDfprintf(out, "%ld", (long)fill_time); break; } /* end switch */ } /* end else */ @@ -394,32 +394,32 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'F': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_fill_value_t fill_value = (H5D_fill_value_t)va_arg(ap, int); switch(fill_value) { case H5D_FILL_VALUE_ERROR: - fprintf(out, "H5D_FILL_VALUE_ERROR"); + HDfprintf(out, "H5D_FILL_VALUE_ERROR"); break; case H5D_FILL_VALUE_UNDEFINED: - fprintf(out, "H5D_FILL_VALUE_UNDEFINED"); + HDfprintf(out, "H5D_FILL_VALUE_UNDEFINED"); break; case H5D_FILL_VALUE_DEFAULT: - fprintf(out, "H5D_FILL_VALUE_DEFAULT"); + HDfprintf(out, "H5D_FILL_VALUE_DEFAULT"); break; case H5D_FILL_VALUE_USER_DEFINED: - fprintf(out, "H5D_FILL_VALUE_USER_DEFINED"); + HDfprintf(out, "H5D_FILL_VALUE_USER_DEFINED"); break; default: - fprintf(out, "%ld", (long)fill_value); + HDfprintf(out, "%ld", (long)fill_value); break; } /* end switch */ } /* end else */ @@ -428,28 +428,28 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'h': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5FD_mpio_chunk_opt_t opt = (H5FD_mpio_chunk_opt_t)va_arg(ap, int); switch(opt) { case H5FD_MPIO_CHUNK_DEFAULT: - fprintf(out, "H5FD_MPIO_CHUNK_DEFAULT"); + HDfprintf(out, "H5FD_MPIO_CHUNK_DEFAULT"); break; case H5FD_MPIO_CHUNK_ONE_IO: - fprintf(out, "H5FD_MPIO_CHUNK_ONE_IO"); + HDfprintf(out, "H5FD_MPIO_CHUNK_ONE_IO"); break; case H5FD_MPIO_CHUNK_MULTI_IO: - fprintf(out, "H5FD_MPIO_CHUNK_MULTI_IO"); + HDfprintf(out, "H5FD_MPIO_CHUNK_MULTI_IO"); break; default: - fprintf(out, "%ld", (long)opt); + HDfprintf(out, "%ld", (long)opt); break; } /* end switch */ } /* end else */ @@ -458,36 +458,36 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_mpio_actual_io_mode_t actual_io_mode = (H5D_mpio_actual_io_mode_t)va_arg(ap, int); switch(actual_io_mode) { case H5D_MPIO_NO_COLLECTIVE: - fprintf(out, "H5D_MPIO_NO_COLLECTIVE"); + HDfprintf(out, "H5D_MPIO_NO_COLLECTIVE"); break; case H5D_MPIO_CHUNK_INDEPENDENT: - fprintf(out, "H5D_MPIO_CHUNK_INDEPENDENT"); + HDfprintf(out, "H5D_MPIO_CHUNK_INDEPENDENT"); break; case H5D_MPIO_CHUNK_COLLECTIVE: - fprintf(out, "H5D_MPIO_CHUNK_COLLECTIVE"); + HDfprintf(out, "H5D_MPIO_CHUNK_COLLECTIVE"); break; case H5D_MPIO_CHUNK_MIXED: - fprintf(out, "H5D_MPIO_CHUNK_MIXED"); + HDfprintf(out, "H5D_MPIO_CHUNK_MIXED"); break; case H5D_MPIO_CONTIGUOUS_COLLECTIVE: - fprintf(out, "H5D_MPIO_CONTIGUOUS_COLLECTIVE"); + HDfprintf(out, "H5D_MPIO_CONTIGUOUS_COLLECTIVE"); break; default: - fprintf(out, "%ld", (long)actual_io_mode); + HDfprintf(out, "%ld", (long)actual_io_mode); break; } /* end switch */ } /* end else */ @@ -496,44 +496,44 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'k': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_chunk_index_t idx = (H5D_chunk_index_t)va_arg(ap, int); switch(idx) { case H5D_CHUNK_IDX_BTREE: - fprintf(out, "H5D_CHUNK_IDX_BTREE"); + HDfprintf(out, "H5D_CHUNK_IDX_BTREE"); break; case H5D_CHUNK_IDX_NONE: - fprintf(out, "H5D_CHUNK_IDX_NONE"); + HDfprintf(out, "H5D_CHUNK_IDX_NONE"); break; case H5D_CHUNK_IDX_FARRAY: - fprintf(out, "H5D_CHUNK_IDX_FARRAY"); + HDfprintf(out, "H5D_CHUNK_IDX_FARRAY"); break; case H5D_CHUNK_IDX_EARRAY: - fprintf(out, "H5D_CHUNK_IDX_EARRAY"); + HDfprintf(out, "H5D_CHUNK_IDX_EARRAY"); break; case H5D_CHUNK_IDX_BT2: - fprintf(out, "H5D_CHUNK_IDX_BT2"); + HDfprintf(out, "H5D_CHUNK_IDX_BT2"); break; case H5D_CHUNK_IDX_SINGLE: - fprintf(out, "H5D_CHUNK_IDX_SINGLE"); + HDfprintf(out, "H5D_CHUNK_IDX_SINGLE"); break; case H5D_CHUNK_IDX_NTYPES: - fprintf(out, "ERROR: H5D_CHUNK_IDX_NTYPES (invalid value)"); + HDfprintf(out, "ERROR: H5D_CHUNK_IDX_NTYPES (invalid value)"); break; default: - fprintf(out, "UNKNOWN VALUE: %ld", (long)idx); + HDfprintf(out, "UNKNOWN VALUE: %ld", (long)idx); break; } /* end switch */ } /* end else */ @@ -542,40 +542,40 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_layout_t layout = (H5D_layout_t)va_arg(ap, int); switch(layout) { case H5D_LAYOUT_ERROR: - fprintf(out, "H5D_LAYOUT_ERROR"); + HDfprintf(out, "H5D_LAYOUT_ERROR"); break; case H5D_COMPACT: - fprintf(out, "H5D_COMPACT"); + HDfprintf(out, "H5D_COMPACT"); break; case H5D_CONTIGUOUS: - fprintf(out, "H5D_CONTIGUOUS"); + HDfprintf(out, "H5D_CONTIGUOUS"); break; case H5D_CHUNKED: - fprintf(out, "H5D_CHUNKED"); + HDfprintf(out, "H5D_CHUNKED"); break; case H5D_VIRTUAL: - fprintf(out, "H5D_VIRTUAL"); + HDfprintf(out, "H5D_VIRTUAL"); break; case H5D_NLAYOUTS: - fprintf(out, "H5D_NLAYOUTS"); + HDfprintf(out, "H5D_NLAYOUTS"); break; default: - fprintf(out, "%ld", (long)layout); + HDfprintf(out, "%ld", (long)layout); break; } /* end switch */ } /* end else */ @@ -584,9 +584,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'n': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_mpio_no_collective_cause_t nocol_cause_mode = (H5D_mpio_no_collective_cause_t)va_arg(ap, int); @@ -594,65 +594,65 @@ H5_trace(const double *returning, const char *func, const char *type, ...) /* Check for all bit-flags which might be set */ if(nocol_cause_mode & H5D_MPIO_COLLECTIVE) { - fprintf(out, "H5D_MPIO_COLLECTIVE"); + HDfprintf(out, "H5D_MPIO_COLLECTIVE"); flag_already_displayed = TRUE; } /* end if */ if(nocol_cause_mode & H5D_MPIO_SET_INDEPENDENT) { - fprintf(out, "%sH5D_MPIO_SET_INDEPENDENT", flag_already_displayed ? " | " : ""); + HDfprintf(out, "%sH5D_MPIO_SET_INDEPENDENT", flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ if(nocol_cause_mode & H5D_MPIO_DATATYPE_CONVERSION) { - fprintf(out, "%sH5D_MPIO_DATATYPE_CONVERSION", flag_already_displayed ? " | " : ""); + HDfprintf(out, "%sH5D_MPIO_DATATYPE_CONVERSION", flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ if(nocol_cause_mode & H5D_MPIO_DATA_TRANSFORMS) { - fprintf(out, "%sH5D_MPIO_DATA_TRANSFORMS", flag_already_displayed ? " | " : ""); + HDfprintf(out, "%sH5D_MPIO_DATA_TRANSFORMS", flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ if(nocol_cause_mode & H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED) { - fprintf(out, "%sH5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED", flag_already_displayed ? " | " : ""); + HDfprintf(out, "%sH5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED", flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ if(nocol_cause_mode & H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES) { - fprintf(out, "%sH5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES", flag_already_displayed ? " | " : ""); + HDfprintf(out, "%sH5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES", flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ if(nocol_cause_mode & H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET) { - fprintf(out, "%sH5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET", flag_already_displayed ? " | " : ""); + HDfprintf(out, "%sH5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET", flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ /* Display '' if there's no flags set */ if(!flag_already_displayed) - fprintf(out, ""); + HDfprintf(out, ""); } /* end else */ break; case 'o': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_mpio_actual_chunk_opt_mode_t chunk_opt_mode = (H5D_mpio_actual_chunk_opt_mode_t)va_arg(ap, int); switch(chunk_opt_mode) { case H5D_MPIO_NO_CHUNK_OPTIMIZATION: - fprintf(out, "H5D_MPIO_NO_CHUNK_OPTIMIZATION"); + HDfprintf(out, "H5D_MPIO_NO_CHUNK_OPTIMIZATION"); break; case H5D_MPIO_LINK_CHUNK: - fprintf(out, "H5D_MPIO_LINK_CHUNK"); + HDfprintf(out, "H5D_MPIO_LINK_CHUNK"); break; case H5D_MPIO_MULTI_CHUNK: - fprintf(out, "H5D_MPIO_MULTI_CHUNK"); + HDfprintf(out, "H5D_MPIO_MULTI_CHUNK"); break; default: - fprintf(out, "%ld", (long)chunk_opt_mode); + HDfprintf(out, "%ld", (long)chunk_opt_mode); break; } /* end switch */ } /* end else */ @@ -661,32 +661,32 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_space_status_t space_status = (H5D_space_status_t)va_arg(ap, int); switch(space_status) { case H5D_SPACE_STATUS_NOT_ALLOCATED: - fprintf(out, "H5D_SPACE_STATUS_NOT_ALLOCATED"); + HDfprintf(out, "H5D_SPACE_STATUS_NOT_ALLOCATED"); break; case H5D_SPACE_STATUS_PART_ALLOCATED: - fprintf(out, "H5D_SPACE_STATUS_PART_ALLOCATED"); + HDfprintf(out, "H5D_SPACE_STATUS_PART_ALLOCATED"); break; case H5D_SPACE_STATUS_ALLOCATED: - fprintf(out, "H5D_SPACE_STATUS_ALLOCATED"); + HDfprintf(out, "H5D_SPACE_STATUS_ALLOCATED"); break; case H5D_SPACE_STATUS_ERROR: - fprintf(out, "H5D_SPACE_STATUS_ERROR"); + HDfprintf(out, "H5D_SPACE_STATUS_ERROR"); break; default: - fprintf(out, "%ld", (long)space_status); + HDfprintf(out, "%ld", (long)space_status); break; } /* end switch */ } /* end else */ @@ -695,24 +695,24 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5FD_mpio_xfer_t transfer = (H5FD_mpio_xfer_t)va_arg(ap, int); switch(transfer) { case H5FD_MPIO_INDEPENDENT: - fprintf(out, "H5FD_MPIO_INDEPENDENT"); + HDfprintf(out, "H5FD_MPIO_INDEPENDENT"); break; case H5FD_MPIO_COLLECTIVE: - fprintf(out, "H5FD_MPIO_COLLECTIVE"); + HDfprintf(out, "H5FD_MPIO_COLLECTIVE"); break; default: - fprintf(out, "%ld", (long)transfer); + HDfprintf(out, "%ld", (long)transfer); break; } /* end switch */ } /* end else */ @@ -721,35 +721,35 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'v': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_vds_view_t view = (H5D_vds_view_t)va_arg(ap, int); switch(view) { case H5D_VDS_ERROR: - fprintf(out, "H5D_VDS_ERROR"); + HDfprintf(out, "H5D_VDS_ERROR"); break; case H5D_VDS_FIRST_MISSING: - fprintf(out, "H5D_VDS_FIRST_MISSING"); + HDfprintf(out, "H5D_VDS_FIRST_MISSING"); break; case H5D_VDS_LAST_AVAILABLE: - fprintf(out, "H5D_VDS_LAST_AVAILABLE"); + HDfprintf(out, "H5D_VDS_LAST_AVAILABLE"); break; default: - fprintf(out, "%ld", (long)view); + HDfprintf(out, "%ld", (long)view); break; } /* end switch */ } /* end else */ break; default: - fprintf (out, "BADTYPE(D%c)", type[1]); + HDfprintf (out, "BADTYPE(D%c)", type[1]); goto error; } /* end switch */ break; @@ -757,17 +757,17 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { herr_t status = va_arg(ap, herr_t); if(status >= 0) - fprintf(out, "SUCCEED"); + HDfprintf(out, "SUCCEED"); else - fprintf(out, "FAIL"); + HDfprintf(out, "FAIL"); } /* end else */ break; @@ -776,24 +776,24 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5E_direction_t direction = (H5E_direction_t)va_arg(ap, int); switch(direction) { case H5E_WALK_UPWARD: - fprintf(out, "H5E_WALK_UPWARD"); + HDfprintf(out, "H5E_WALK_UPWARD"); break; case H5E_WALK_DOWNWARD: - fprintf(out, "H5E_WALK_DOWNWARD"); + HDfprintf(out, "H5E_WALK_DOWNWARD"); break; default: - fprintf(out, "%ld", (long)direction); + HDfprintf(out, "%ld", (long)direction); break; } /* end switch */ } /* end else */ @@ -802,45 +802,45 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5E_error2_t *error = va_arg(ap, H5E_error2_t *); - fprintf(out, "0x%lx", (unsigned long)error); + HDfprintf(out, "0x%lx", (unsigned long)error); } /* end else */ break; case 't': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5E_type_t etype = (H5E_type_t)va_arg(ap, int); switch(etype) { case H5E_MAJOR: - fprintf(out, "H5E_MAJOR"); + HDfprintf(out, "H5E_MAJOR"); break; case H5E_MINOR: - fprintf(out, "H5E_MINOR"); + HDfprintf(out, "H5E_MINOR"); break; default: - fprintf(out, "%ld", (long)etype); + HDfprintf(out, "%ld", (long)etype); break; } /* end switch */ } /* end else */ break; default: - fprintf(out, "BADTYPE(E%c)", type[1]); + HDfprintf(out, "BADTYPE(E%c)", type[1]); goto error; } /* end switch */ break; @@ -850,32 +850,32 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_close_degree_t degree = (H5F_close_degree_t)va_arg(ap, int); switch(degree) { case H5F_CLOSE_DEFAULT: - fprintf(out, "H5F_CLOSE_DEFAULT"); + HDfprintf(out, "H5F_CLOSE_DEFAULT"); break; case H5F_CLOSE_WEAK: - fprintf(out, "H5F_CLOSE_WEAK"); + HDfprintf(out, "H5F_CLOSE_WEAK"); break; case H5F_CLOSE_SEMI: - fprintf(out, "H5F_CLOSE_SEMI"); + HDfprintf(out, "H5F_CLOSE_SEMI"); break; case H5F_CLOSE_STRONG: - fprintf(out, "H5F_CLOSE_STRONG"); + HDfprintf(out, "H5F_CLOSE_STRONG"); break; default: - fprintf(out, "%ld", (long)degree); + HDfprintf(out, "%ld", (long)degree); break; } /* end switch */ } /* end else */ @@ -884,33 +884,33 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_fspace_strategy_t fs_strategy = (H5F_fspace_strategy_t)va_arg(ap, int); switch(fs_strategy) { case H5F_FSPACE_STRATEGY_FSM_AGGR: - fprintf(out, "H5F_FSPACE_STRATEGY_FSM_AGGR"); + HDfprintf(out, "H5F_FSPACE_STRATEGY_FSM_AGGR"); break; case H5F_FSPACE_STRATEGY_PAGE: - fprintf(out, "H5F_FSPACE_STRATEGY_PAGE"); + HDfprintf(out, "H5F_FSPACE_STRATEGY_PAGE"); break; case H5F_FSPACE_STRATEGY_AGGR: - fprintf(out, "H5F_FSPACE_STRATEGY_AGGR"); + HDfprintf(out, "H5F_FSPACE_STRATEGY_AGGR"); break; case H5F_FSPACE_STRATEGY_NONE: - fprintf(out, "H5F_FSPACE_STRATEGY_NONE"); + HDfprintf(out, "H5F_FSPACE_STRATEGY_NONE"); break; case H5F_FSPACE_STRATEGY_NTYPES: default: - fprintf(out, "%ld", (long)fs_strategy); + HDfprintf(out, "%ld", (long)fs_strategy); break; } /* end switch */ } /* end else */ @@ -919,49 +919,49 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'm': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_mem_t mem_type = (H5F_mem_t)va_arg(ap, int); switch(mem_type) { case H5FD_MEM_NOLIST: - fprintf(out, "H5FD_MEM_NOLIST"); + HDfprintf(out, "H5FD_MEM_NOLIST"); break; case H5FD_MEM_DEFAULT: - fprintf(out, "H5FD_MEM_DEFAULT"); + HDfprintf(out, "H5FD_MEM_DEFAULT"); break; case H5FD_MEM_SUPER: - fprintf(out, "H5FD_MEM_SUPER"); + HDfprintf(out, "H5FD_MEM_SUPER"); break; case H5FD_MEM_BTREE: - fprintf(out, "H5FD_MEM_BTREE"); + HDfprintf(out, "H5FD_MEM_BTREE"); break; case H5FD_MEM_DRAW: - fprintf(out, "H5FD_MEM_DRAW"); + HDfprintf(out, "H5FD_MEM_DRAW"); break; case H5FD_MEM_GHEAP: - fprintf(out, "H5FD_MEM_GHEAP"); + HDfprintf(out, "H5FD_MEM_GHEAP"); break; case H5FD_MEM_LHEAP: - fprintf(out, "H5FD_MEM_LHEAP"); + HDfprintf(out, "H5FD_MEM_LHEAP"); break; case H5FD_MEM_OHDR: - fprintf(out, "H5FD_MEM_OHDR"); + HDfprintf(out, "H5FD_MEM_OHDR"); break; case H5FD_MEM_NTYPES: default: - fprintf(out, "%ld", (long)mem_type); + HDfprintf(out, "%ld", (long)mem_type); break; } /* end switch */ } /* end else */ @@ -970,24 +970,24 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_scope_t scope = (H5F_scope_t)va_arg(ap, int); switch(scope) { case H5F_SCOPE_LOCAL: - fprintf(out, "H5F_SCOPE_LOCAL"); + HDfprintf(out, "H5F_SCOPE_LOCAL"); break; case H5F_SCOPE_GLOBAL: - fprintf(out, "H5F_SCOPE_GLOBAL"); + HDfprintf(out, "H5F_SCOPE_GLOBAL"); break; default: - fprintf(out, "%ld", (long)scope); + HDfprintf(out, "%ld", (long)scope); break; } /* end switch */ } /* end else */ @@ -996,47 +996,47 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ break; case 'v': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_libver_t libver_vers = (H5F_libver_t)va_arg(ap, int); switch(libver_vers) { case H5F_LIBVER_EARLIEST: - fprintf(out, "H5F_LIBVER_EARLIEST"); + HDfprintf(out, "H5F_LIBVER_EARLIEST"); break; case H5F_LIBVER_V18: - fprintf(out, "H5F_LIBVER_V18"); + HDfprintf(out, "H5F_LIBVER_V18"); break; case H5F_LIBVER_V110: - HDassert(H5F_LIBVER_LATEST == H5F_LIBVER_V110); - fprintf(out, "H5F_LIBVER_LATEST"); + HDcompile_assert(H5F_LIBVER_LATEST == H5F_LIBVER_V110); + HDfprintf(out, "H5F_LIBVER_LATEST"); break; case H5F_LIBVER_ERROR: case H5F_LIBVER_NBOUNDS: default: - fprintf(out, "%ld", (long)libver_vers); + HDfprintf(out, "%ld", (long)libver_vers); break; } /* end switch */ } /* end else */ break; default: - fprintf(out, "BADTYPE(F%c)", type[1]); + HDfprintf(out, "BADTYPE(F%c)", type[1]); goto error; } /* end switch */ break; @@ -1047,46 +1047,46 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5G_obj_t obj_type = (H5G_obj_t)va_arg(ap, int); switch(obj_type) { case H5G_UNKNOWN: - fprintf(out, "H5G_UNKNOWN"); + HDfprintf(out, "H5G_UNKNOWN"); break; case H5G_GROUP: - fprintf(out, "H5G_GROUP"); + HDfprintf(out, "H5G_GROUP"); break; case H5G_DATASET: - fprintf(out, "H5G_DATASET"); + HDfprintf(out, "H5G_DATASET"); break; case H5G_TYPE: - fprintf(out, "H5G_TYPE"); + HDfprintf(out, "H5G_TYPE"); break; case H5G_LINK: - fprintf(out, "H5G_LINK"); + HDfprintf(out, "H5G_LINK"); break; case H5G_UDLINK: - fprintf(out, "H5G_UDLINK"); + HDfprintf(out, "H5G_UDLINK"); break; case H5G_RESERVED_5: case H5G_RESERVED_6: case H5G_RESERVED_7: - fprintf(out, "H5G_RESERVED(%ld)", (long)obj_type); + HDfprintf(out, "H5G_RESERVED(%ld)", (long)obj_type); break; default: - fprintf(out, "%ld", (long)obj_type); + HDfprintf(out, "%ld", (long)obj_type); break; } /* end switch */ } /* end else */ @@ -1095,20 +1095,20 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - fprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5G_stat_t *statbuf = va_arg(ap, H5G_stat_t*); - fprintf(out, "0x%lx", (unsigned long)statbuf); + HDfprintf(out, "0x%lx", (unsigned long)statbuf); } break; #endif /* H5_NO_DEPRECATED_SYMBOLS */ default: - fprintf(out, "BADTYPE(G%c)", type[1]); + HDfprintf(out, "BADTYPE(G%c)", type[1]); goto error; } break; @@ -1116,22 +1116,22 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'h': if(ptr) { if(vp) { - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { hsize_t *p = (hsize_t *)vp; - fprintf(out, " {"); + HDfprintf(out, " {"); for(i = 0; i < asize[asize_idx]; i++) { if(H5S_UNLIMITED == p[i]) HDfprintf(out, "%sH5S_UNLIMITED", (i ? ", " : "")); else HDfprintf(out, "%s%Hu", (i ? ", " : ""), p[i]); } /* end for */ - fprintf(out, "}"); + HDfprintf(out, "}"); } /* end if */ } /* end if */ else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { hsize_t hsize = va_arg(ap, hsize_t); @@ -1150,18 +1150,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) { - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { hssize_t *p = (hssize_t *)vp; - fprintf(out, " {"); + HDfprintf(out, " {"); for(i = 0; i < asize[asize_idx]; i++) HDfprintf(out, "%s%Hd", (i ? ", " : ""), p[i]); - fprintf(out, "}"); + HDfprintf(out, "}"); } /* end if */ } /* end if */ else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { hssize_t hssize = va_arg(ap, hssize_t); @@ -1172,7 +1172,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; default: - fprintf (out, "BADTYPE(H%c)", type[1]); + HDfprintf (out, "BADTYPE(H%c)", type[1]); goto error; } /* end switch */ break; @@ -1180,130 +1180,130 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { hid_t obj = va_arg(ap, hid_t); if(H5P_DEFAULT == obj) - fprintf(out, "H5P_DEFAULT"); + HDfprintf(out, "H5P_DEFAULT"); else if(obj < 0) - fprintf(out, "FAIL"); + HDfprintf(out, "FAIL"); else { switch(H5I_TYPE(obj)) { /* Use internal H5I macro instead of function call */ case H5I_UNINIT: - fprintf(out, "%ld (uninit - error)", (long)obj); + HDfprintf(out, "%ld (uninit - error)", (long)obj); break; case H5I_BADID: - fprintf(out, "%ld (error)", (long)obj); + HDfprintf(out, "%ld (error)", (long)obj); break; case H5I_FILE: - fprintf(out, "%ld (file)", (long)obj); + HDfprintf(out, "%ld (file)", (long)obj); break; case H5I_GROUP: - fprintf(out, "%ld (group)", (long)obj); + HDfprintf(out, "%ld (group)", (long)obj); break; case H5I_DATATYPE: if(obj == H5T_NATIVE_SCHAR_g) - fprintf(out, "H5T_NATIVE_SCHAR"); + HDfprintf(out, "H5T_NATIVE_SCHAR"); else if(obj == H5T_NATIVE_UCHAR_g) - fprintf(out, "H5T_NATIVE_UCHAR"); + HDfprintf(out, "H5T_NATIVE_UCHAR"); else if(obj == H5T_NATIVE_SHORT_g) - fprintf(out, "H5T_NATIVE_SHORT"); + HDfprintf(out, "H5T_NATIVE_SHORT"); else if(obj == H5T_NATIVE_USHORT_g) - fprintf(out, "H5T_NATIVE_USHORT"); + HDfprintf(out, "H5T_NATIVE_USHORT"); else if(obj == H5T_NATIVE_INT_g) - fprintf(out, "H5T_NATIVE_INT"); + HDfprintf(out, "H5T_NATIVE_INT"); else if(obj == H5T_NATIVE_UINT_g) - fprintf(out, "H5T_NATIVE_UINT"); + HDfprintf(out, "H5T_NATIVE_UINT"); else if(obj == H5T_NATIVE_LONG_g) - fprintf(out, "H5T_NATIVE_LONG"); + HDfprintf(out, "H5T_NATIVE_LONG"); else if(obj == H5T_NATIVE_ULONG_g) - fprintf(out, "H5T_NATIVE_ULONG"); + HDfprintf(out, "H5T_NATIVE_ULONG"); else if(obj == H5T_NATIVE_LLONG_g) - fprintf(out, "H5T_NATIVE_LLONG"); + HDfprintf(out, "H5T_NATIVE_LLONG"); else if(obj == H5T_NATIVE_ULLONG_g) - fprintf(out, "H5T_NATIVE_ULLONG"); + HDfprintf(out, "H5T_NATIVE_ULLONG"); else if(obj == H5T_NATIVE_FLOAT_g) - fprintf(out, "H5T_NATIVE_FLOAT"); + HDfprintf(out, "H5T_NATIVE_FLOAT"); else if(obj == H5T_NATIVE_DOUBLE_g) - fprintf(out, "H5T_NATIVE_DOUBLE"); + HDfprintf(out, "H5T_NATIVE_DOUBLE"); #if H5_SIZEOF_LONG_DOUBLE !=0 else if(obj == H5T_NATIVE_LDOUBLE_g) - fprintf(out, "H5T_NATIVE_LDOUBLE"); + HDfprintf(out, "H5T_NATIVE_LDOUBLE"); #endif else if(obj == H5T_IEEE_F32BE_g) - fprintf(out, "H5T_IEEE_F32BE"); + HDfprintf(out, "H5T_IEEE_F32BE"); else if(obj == H5T_IEEE_F32LE_g) - fprintf(out, "H5T_IEEE_F32LE"); + HDfprintf(out, "H5T_IEEE_F32LE"); else if(obj == H5T_IEEE_F64BE_g) - fprintf(out, "H5T_IEEE_F64BE"); + HDfprintf(out, "H5T_IEEE_F64BE"); else if(obj == H5T_IEEE_F64LE_g) - fprintf(out, "H5T_IEEE_F64LE"); + HDfprintf(out, "H5T_IEEE_F64LE"); else if(obj == H5T_STD_I8BE_g) - fprintf(out, "H5T_STD_I8BE"); + HDfprintf(out, "H5T_STD_I8BE"); else if(obj == H5T_STD_I8LE_g) - fprintf(out, "H5T_STD_I8LE"); + HDfprintf(out, "H5T_STD_I8LE"); else if(obj == H5T_STD_I16BE_g) - fprintf(out, "H5T_STD_I16BE"); + HDfprintf(out, "H5T_STD_I16BE"); else if(obj == H5T_STD_I16LE_g) - fprintf(out, "H5T_STD_I16LE"); + HDfprintf(out, "H5T_STD_I16LE"); else if(obj == H5T_STD_I32BE_g) - fprintf(out, "H5T_STD_I32BE"); + HDfprintf(out, "H5T_STD_I32BE"); else if(obj == H5T_STD_I32LE_g) - fprintf(out, "H5T_STD_I32LE"); + HDfprintf(out, "H5T_STD_I32LE"); else if(obj == H5T_STD_I64BE_g) - fprintf(out, "H5T_STD_I64BE"); + HDfprintf(out, "H5T_STD_I64BE"); else if(obj == H5T_STD_I64LE_g) - fprintf(out, "H5T_STD_I64LE"); + HDfprintf(out, "H5T_STD_I64LE"); else if(obj == H5T_STD_U8BE_g) - fprintf(out, "H5T_STD_U8BE"); + HDfprintf(out, "H5T_STD_U8BE"); else if(obj == H5T_STD_U8LE_g) - fprintf(out, "H5T_STD_U8LE"); + HDfprintf(out, "H5T_STD_U8LE"); else if(obj == H5T_STD_U16BE_g) - fprintf(out, "H5T_STD_U16BE"); + HDfprintf(out, "H5T_STD_U16BE"); else if(obj == H5T_STD_U16LE_g) - fprintf(out, "H5T_STD_U16LE"); + HDfprintf(out, "H5T_STD_U16LE"); else if(obj == H5T_STD_U32BE_g) - fprintf(out, "H5T_STD_U32BE"); + HDfprintf(out, "H5T_STD_U32BE"); else if(obj == H5T_STD_U32LE_g) - fprintf(out, "H5T_STD_U32LE"); + HDfprintf(out, "H5T_STD_U32LE"); else if(obj == H5T_STD_U64BE_g) - fprintf(out, "H5T_STD_U64BE"); + HDfprintf(out, "H5T_STD_U64BE"); else if(obj == H5T_STD_U64LE_g) - fprintf(out, "H5T_STD_U64LE"); + HDfprintf(out, "H5T_STD_U64LE"); else if(obj == H5T_STD_B8BE_g) - fprintf(out, "H5T_STD_B8BE"); + HDfprintf(out, "H5T_STD_B8BE"); else if(obj == H5T_STD_B8LE_g) - fprintf(out, "H5T_STD_B8LE"); + HDfprintf(out, "H5T_STD_B8LE"); else if(obj == H5T_STD_B16BE_g) - fprintf(out, "H5T_STD_B16BE"); + HDfprintf(out, "H5T_STD_B16BE"); else if(obj == H5T_STD_B16LE_g) - fprintf(out, "H5T_STD_B16LE"); + HDfprintf(out, "H5T_STD_B16LE"); else if(obj == H5T_STD_B32BE_g) - fprintf(out, "H5T_STD_B32BE"); + HDfprintf(out, "H5T_STD_B32BE"); else if(obj == H5T_STD_B32LE_g) - fprintf(out, "H5T_STD_B32LE"); + HDfprintf(out, "H5T_STD_B32LE"); else if(obj == H5T_STD_B64BE_g) - fprintf(out, "H5T_STD_B64BE"); + HDfprintf(out, "H5T_STD_B64BE"); else if(obj == H5T_STD_B64LE_g) - fprintf(out, "H5T_STD_B64LE"); + HDfprintf(out, "H5T_STD_B64LE"); else if(obj == H5T_C_S1_g) - fprintf(out, "H5T_C_S1"); + HDfprintf(out, "H5T_C_S1"); else if(obj == H5T_FORTRAN_S1_g) - fprintf(out, "H5T_FORTRAN_S1"); + HDfprintf(out, "H5T_FORTRAN_S1"); else - fprintf(out, "%ld (dtype)", (long)obj); + HDfprintf(out, "%ld (dtype)", (long)obj); break; case H5I_DATASPACE: - fprintf(out, "%ld (dspace)", (long)obj); + HDfprintf(out, "%ld (dspace)", (long)obj); /* Save the rank of simple data spaces for arrays */ /* This may generate recursive call to the library... -QAK */ { @@ -1316,47 +1316,47 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case H5I_DATASET: - fprintf(out, "%ld (dset)", (long)obj); + HDfprintf(out, "%ld (dset)", (long)obj); break; case H5I_ATTR: - fprintf(out, "%ld (attr)", (long)obj); + HDfprintf(out, "%ld (attr)", (long)obj); break; case H5I_REFERENCE: - fprintf(out, "%ld (reference)", (long)obj); + HDfprintf(out, "%ld (reference)", (long)obj); break; case H5I_VFL: - fprintf(out, "%ld (file driver)", (long)obj); + HDfprintf(out, "%ld (file driver)", (long)obj); break; case H5I_GENPROP_CLS: - fprintf(out, "%ld (genprop class)", (long)obj); + HDfprintf(out, "%ld (genprop class)", (long)obj); break; case H5I_GENPROP_LST: - fprintf(out, "%ld (genprop list)", (long)obj); + HDfprintf(out, "%ld (genprop list)", (long)obj); break; case H5I_ERROR_CLASS: - fprintf(out, "%ld (err class)", (long)obj); + HDfprintf(out, "%ld (err class)", (long)obj); break; case H5I_ERROR_MSG: - fprintf(out, "%ld (err msg)", (long)obj); + HDfprintf(out, "%ld (err msg)", (long)obj); break; case H5I_ERROR_STACK: - fprintf(out, "%ld (err stack)", (long)obj); + HDfprintf(out, "%ld (err stack)", (long)obj); break; case H5I_NTYPES: - fprintf (out, "%ld (ntypes - error)", (long)obj); + HDfprintf (out, "%ld (ntypes - error)", (long)obj); break; default: - fprintf(out, "%ld (unknown class)", (long)obj); + HDfprintf(out, "%ld (unknown class)", (long)obj); break; } /* end switch */ } /* end else */ @@ -1368,32 +1368,32 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5_index_t idx_type = (H5_index_t)va_arg(ap, int); switch(idx_type) { case H5_INDEX_UNKNOWN: - fprintf(out, "H5_INDEX_UNKNOWN"); + HDfprintf(out, "H5_INDEX_UNKNOWN"); break; case H5_INDEX_NAME: - fprintf(out, "H5_INDEX_NAME"); + HDfprintf(out, "H5_INDEX_NAME"); break; case H5_INDEX_CRT_ORDER: - fprintf(out, "H5_INDEX_CRT_ORDER"); + HDfprintf(out, "H5_INDEX_CRT_ORDER"); break; case H5_INDEX_N: - fprintf(out, "H5_INDEX_N"); + HDfprintf(out, "H5_INDEX_N"); break; default: - fprintf(out, "%ld", (long)idx_type); + HDfprintf(out, "%ld", (long)idx_type); break; } /* end switch */ } /* end else */ @@ -1402,36 +1402,36 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5_iter_order_t order = (H5_iter_order_t)va_arg(ap, int); switch(order) { case H5_ITER_UNKNOWN: - fprintf(out, "H5_ITER_UNKNOWN"); + HDfprintf(out, "H5_ITER_UNKNOWN"); break; case H5_ITER_INC: - fprintf(out, "H5_ITER_INC"); + HDfprintf(out, "H5_ITER_INC"); break; case H5_ITER_DEC: - fprintf(out, "H5_ITER_DEC"); + HDfprintf(out, "H5_ITER_DEC"); break; case H5_ITER_NATIVE: - fprintf(out, "H5_ITER_NATIVE"); + HDfprintf(out, "H5_ITER_NATIVE"); break; case H5_ITER_N: - fprintf(out, "H5_ITER_N"); + HDfprintf(out, "H5_ITER_N"); break; default: - fprintf(out, "%ld", (long)order); + HDfprintf(out, "%ld", (long)order); break; } /* end switch */ } /* end else */ @@ -1440,23 +1440,23 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) { - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { int *p = (int*)vp; - fprintf(out, " {"); + HDfprintf(out, " {"); for(i = 0; i < asize[asize_idx]; i++) - fprintf(out, "%s%d", (i ? ", " : ""), p[i]); - fprintf(out, "}"); + HDfprintf(out, "%s%d", (i ? ", " : ""), p[i]); + HDfprintf(out, "}"); } /* end if */ } /* end if */ else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { int is = va_arg(ap, int); - fprintf (out, "%d", is); + HDfprintf (out, "%d", is); asize[argno] = is; } /* end else */ break; @@ -1464,80 +1464,80 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5I_type_t id_type = (H5I_type_t)va_arg(ap, int); switch (id_type) { case H5I_UNINIT: - fprintf(out, "H5I_UNINIT"); + HDfprintf(out, "H5I_UNINIT"); break; case H5I_BADID: - fprintf(out, "H5I_BADID"); + HDfprintf(out, "H5I_BADID"); break; case H5I_FILE: - fprintf(out, "H5I_FILE"); + HDfprintf(out, "H5I_FILE"); break; case H5I_GROUP: - fprintf(out, "H5I_GROUP"); + HDfprintf(out, "H5I_GROUP"); break; case H5I_DATATYPE: - fprintf(out, "H5I_DATATYPE"); + HDfprintf(out, "H5I_DATATYPE"); break; case H5I_DATASPACE: - fprintf(out, "H5I_DATASPACE"); + HDfprintf(out, "H5I_DATASPACE"); break; case H5I_DATASET: - fprintf(out, "H5I_DATASET"); + HDfprintf(out, "H5I_DATASET"); break; case H5I_ATTR: - fprintf(out, "H5I_ATTR"); + HDfprintf(out, "H5I_ATTR"); break; case H5I_REFERENCE: - fprintf(out, "H5I_REFERENCE"); + HDfprintf(out, "H5I_REFERENCE"); break; case H5I_VFL: - fprintf(out, "H5I_VFL"); + HDfprintf(out, "H5I_VFL"); break; case H5I_GENPROP_CLS: - fprintf(out, "H5I_GENPROP_CLS"); + HDfprintf(out, "H5I_GENPROP_CLS"); break; case H5I_GENPROP_LST: - fprintf(out, "H5I_GENPROP_LST"); + HDfprintf(out, "H5I_GENPROP_LST"); break; case H5I_ERROR_CLASS: - fprintf(out, "H5I_ERROR_CLASS"); + HDfprintf(out, "H5I_ERROR_CLASS"); break; case H5I_ERROR_MSG: - fprintf(out, "H5I_ERROR_MSG"); + HDfprintf(out, "H5I_ERROR_MSG"); break; case H5I_ERROR_STACK: - fprintf(out, "H5I_ERROR_STACK"); + HDfprintf(out, "H5I_ERROR_STACK"); break; case H5I_NTYPES: - fprintf(out, "H5I_NTYPES"); + HDfprintf(out, "H5I_NTYPES"); break; default: - fprintf(out, "%ld", (long)id_type); + HDfprintf(out, "%ld", (long)id_type); break; } /* end switch */ } /* end else */ @@ -1546,29 +1546,29 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'u': if(ptr) { if(vp) { - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned *p = (unsigned*)vp; - fprintf(out, " {"); + HDfprintf(out, " {"); for(i = 0; i < asize[asize_idx]; i++) HDfprintf(out, "%s%u", i?", ":"", p[i]); - fprintf(out, "}"); + HDfprintf(out, "}"); } /* end if */ } /* end if */ else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { unsigned iu = va_arg(ap, unsigned); - fprintf(out, "%u", iu); + HDfprintf(out, "%u", iu); asize[argno] = iu; } /* end else */ break; default: - fprintf (out, "BADTYPE(I%c)", type[1]); + HDfprintf (out, "BADTYPE(I%c)", type[1]); goto error; } /* end switch */ break; @@ -1578,43 +1578,43 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) - fprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5L_type_t link_type = (H5L_type_t)va_arg(ap, int); switch(link_type) { case H5L_TYPE_ERROR: - fprintf(out, "H5L_TYPE_ERROR"); + HDfprintf(out, "H5L_TYPE_ERROR"); break; case H5L_TYPE_HARD: - fprintf(out, "H5L_TYPE_HARD"); + HDfprintf(out, "H5L_TYPE_HARD"); break; case H5L_TYPE_SOFT: - fprintf(out, "H5L_TYPE_SOFT"); + HDfprintf(out, "H5L_TYPE_SOFT"); break; case H5L_TYPE_EXTERNAL: - fprintf(out, "H5L_TYPE_EXTERNAL"); + HDfprintf(out, "H5L_TYPE_EXTERNAL"); break; case H5L_TYPE_MAX: - fprintf(out, "H5L_TYPE_MAX"); + HDfprintf(out, "H5L_TYPE_MAX"); break; default: - fprintf(out, "%ld", (long)link_type); + HDfprintf(out, "%ld", (long)link_type); break; } /* end switch */ } /* end else */ break; default: - fprintf(out, "BADTYPE(G%c)", type[1]); + HDfprintf(out, "BADTYPE(G%c)", type[1]); goto error; } /* end switch */ break; @@ -1624,15 +1624,15 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ #ifdef H5_HAVE_PARALLEL else { MPI_Comm comm = va_arg(ap, MPI_Comm); - fprintf(out, "%ld", (long)comm); + HDfprintf(out, "%ld", (long)comm); } /* end else */ #endif /* H5_HAVE_PARALLEL */ break; @@ -1640,15 +1640,15 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ #ifdef H5_HAVE_PARALLEL else { MPI_Info info = va_arg(ap, MPI_Info); - fprintf(out, "%ld", (long)info); + HDfprintf(out, "%ld", (long)info); } /* end else */ #endif /* H5_HAVE_PARALLEL */ break; @@ -1656,52 +1656,52 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5FD_mem_t mt = (H5FD_mem_t)va_arg(ap, int); switch(mt) { case H5FD_MEM_NOLIST: - fprintf(out, "H5FD_MEM_NOLIST"); + HDfprintf(out, "H5FD_MEM_NOLIST"); break; case H5FD_MEM_DEFAULT: - fprintf(out, "H5FD_MEM_DEFAULT"); + HDfprintf(out, "H5FD_MEM_DEFAULT"); break; case H5FD_MEM_SUPER: - fprintf(out, "H5FD_MEM_SUPER"); + HDfprintf(out, "H5FD_MEM_SUPER"); break; case H5FD_MEM_BTREE: - fprintf(out, "H5FD_MEM_BTREE"); + HDfprintf(out, "H5FD_MEM_BTREE"); break; case H5FD_MEM_DRAW: - fprintf(out, "H5FD_MEM_DRAW"); + HDfprintf(out, "H5FD_MEM_DRAW"); break; case H5FD_MEM_GHEAP: - fprintf(out, "H5FD_MEM_GHEAP"); + HDfprintf(out, "H5FD_MEM_GHEAP"); break; case H5FD_MEM_LHEAP: - fprintf(out, "H5FD_MEM_LHEAP"); + HDfprintf(out, "H5FD_MEM_LHEAP"); break; case H5FD_MEM_OHDR: - fprintf(out, "H5FD_MEM_OHDR"); + HDfprintf(out, "H5FD_MEM_OHDR"); break; case H5FD_MEM_NTYPES: - fprintf(out, "H5FD_MEM_NTYPES"); + HDfprintf(out, "H5FD_MEM_NTYPES"); break; default: - fprintf(out, "%ld", (long)mt); + HDfprintf(out, "%ld", (long)mt); break; } /* end switch */ } /* end else */ @@ -1715,14 +1715,14 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { off_t offset = va_arg(ap, off_t); - fprintf (out, "%ld", (long)offset); + HDfprintf (out, "%ld", (long)offset); } /* end else */ break; @@ -1731,43 +1731,43 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5O_type_t objtype = (H5O_type_t)va_arg(ap, int); switch(objtype) { case H5O_TYPE_UNKNOWN: - fprintf(out, "H5O_TYPE_UNKNOWN"); + HDfprintf(out, "H5O_TYPE_UNKNOWN"); break; case H5O_TYPE_GROUP: - fprintf(out, "H5O_TYPE_GROUP"); + HDfprintf(out, "H5O_TYPE_GROUP"); break; case H5O_TYPE_DATASET: - fprintf(out, "H5O_TYPE_DATASET"); + HDfprintf(out, "H5O_TYPE_DATASET"); break; case H5O_TYPE_NAMED_DATATYPE: - fprintf(out, "H5O_TYPE_NAMED_DATATYPE"); + HDfprintf(out, "H5O_TYPE_NAMED_DATATYPE"); break; case H5O_TYPE_NTYPES: - fprintf(out, "H5O_TYPE_TYPES"); + HDfprintf(out, "H5O_TYPE_TYPES"); break; default: - fprintf(out, "BADTYPE(%ld)", (long)objtype); + HDfprintf(out, "BADTYPE(%ld)", (long)objtype); break; } /* end switch */ } /* end else */ break; default: - fprintf(out, "BADTYPE(S%c)", type[1]); + HDfprintf(out, "BADTYPE(S%c)", type[1]); goto error; } /* end switch */ break; @@ -1775,9 +1775,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'p': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { hid_t pclass_id = va_arg(ap, hid_t); @@ -1788,20 +1788,20 @@ H5_trace(const double *returning, const char *func, const char *type, ...) /* (This may generate recursive call to the library... -QAK) */ if(NULL != (pclass = (H5P_genclass_t *)H5I_object(pclass_id)) && NULL != (class_name = H5P_get_class_name(pclass))) { - fprintf(out, "%s", class_name); + HDfprintf(out, "%s", class_name); H5MM_xfree(class_name); } /* end if */ else - fprintf(out, "%ld", (long)pclass_id); + HDfprintf(out, "%ld", (long)pclass_id); } /* end else */ break; case 'r': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { hobj_ref_t ref = va_arg(ap, hobj_ref_t); @@ -1815,39 +1815,39 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5R_type_t reftype = (H5R_type_t)va_arg(ap, int); switch(reftype) { case H5R_BADTYPE: - fprintf(out, "H5R_BADTYPE"); + HDfprintf(out, "H5R_BADTYPE"); break; case H5R_OBJECT: - fprintf(out, "H5R_OBJECT"); + HDfprintf(out, "H5R_OBJECT"); break; case H5R_DATASET_REGION: - fprintf(out, "H5R_DATASET_REGION"); + HDfprintf(out, "H5R_DATASET_REGION"); break; case H5R_MAXTYPE: - fprintf(out, "H5R_MAXTYPE"); + HDfprintf(out, "H5R_MAXTYPE"); break; default: - fprintf(out, "BADTYPE(%ld)", (long)reftype); + HDfprintf(out, "BADTYPE(%ld)", (long)reftype); break; } /* end switch */ } /* end else */ break; default: - fprintf(out, "BADTYPE(S%c)", type[1]); + HDfprintf(out, "BADTYPE(S%c)", type[1]); goto error; } break; @@ -1857,32 +1857,32 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5S_class_t cls = (H5S_class_t)va_arg(ap, int); switch(cls) { case H5S_NO_CLASS: - fprintf(out, "H5S_NO_CLASS"); + HDfprintf(out, "H5S_NO_CLASS"); break; case H5S_SCALAR: - fprintf(out, "H5S_SCALAR"); + HDfprintf(out, "H5S_SCALAR"); break; case H5S_SIMPLE: - fprintf(out, "H5S_SIMPLE"); + HDfprintf(out, "H5S_SIMPLE"); break; case H5S_NULL: - fprintf(out, "H5S_NULL"); + HDfprintf(out, "H5S_NULL"); break; default: - fprintf(out, "%ld", (long)cls); + HDfprintf(out, "%ld", (long)cls); break; } /* end switch */ } /* end else */ @@ -1891,56 +1891,56 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5S_seloper_t so = (H5S_seloper_t)va_arg(ap, int); switch(so) { case H5S_SELECT_NOOP: - fprintf(out, "H5S_NOOP"); + HDfprintf(out, "H5S_NOOP"); break; case H5S_SELECT_SET: - fprintf(out, "H5S_SELECT_SET"); + HDfprintf(out, "H5S_SELECT_SET"); break; case H5S_SELECT_OR: - fprintf(out, "H5S_SELECT_OR"); + HDfprintf(out, "H5S_SELECT_OR"); break; case H5S_SELECT_AND: - fprintf(out, "H5S_SELECT_AND"); + HDfprintf(out, "H5S_SELECT_AND"); break; case H5S_SELECT_XOR: - fprintf(out, "H5S_SELECT_XOR"); + HDfprintf(out, "H5S_SELECT_XOR"); break; case H5S_SELECT_NOTB: - fprintf(out, "H5S_SELECT_NOTB"); + HDfprintf(out, "H5S_SELECT_NOTB"); break; case H5S_SELECT_NOTA: - fprintf(out, "H5S_SELECT_NOTA"); + HDfprintf(out, "H5S_SELECT_NOTA"); break; case H5S_SELECT_APPEND: - fprintf(out, "H5S_SELECT_APPEND"); + HDfprintf(out, "H5S_SELECT_APPEND"); break; case H5S_SELECT_PREPEND: - fprintf(out, "H5S_SELECT_PREPEND"); + HDfprintf(out, "H5S_SELECT_PREPEND"); break; case H5S_SELECT_INVALID: - fprintf(out, "H5S_SELECT_INVALID"); + HDfprintf(out, "H5S_SELECT_INVALID"); break; default: - fprintf(out, "%ld", (long)so); + HDfprintf(out, "%ld", (long)so); break; } /* end switch */ } /* end else */ @@ -1949,47 +1949,47 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5S_sel_type st = (H5S_sel_type)va_arg(ap, int); switch(st) { case H5S_SEL_ERROR: - fprintf(out, "H5S_SEL_ERROR"); + HDfprintf(out, "H5S_SEL_ERROR"); break; case H5S_SEL_NONE: - fprintf(out, "H5S_SEL_NONE"); + HDfprintf(out, "H5S_SEL_NONE"); break; case H5S_SEL_POINTS: - fprintf(out, "H5S_SEL_POINTS"); + HDfprintf(out, "H5S_SEL_POINTS"); break; case H5S_SEL_HYPERSLABS: - fprintf(out, "H5S_SEL_HYPERSLABS"); + HDfprintf(out, "H5S_SEL_HYPERSLABS"); break; case H5S_SEL_ALL: - fprintf(out, "H5S_SEL_ALL"); + HDfprintf(out, "H5S_SEL_ALL"); break; case H5S_SEL_N: - fprintf(out, "H5S_SEL_N"); + HDfprintf(out, "H5S_SEL_N"); break; default: - fprintf(out, "%ld", (long)st); + HDfprintf(out, "%ld", (long)st); break; } /* end switch */ } /* end else */ break; default: - fprintf(out, "BADTYPE(S%c)", type[1]); + HDfprintf(out, "BADTYPE(S%c)", type[1]); goto error; } /* end switch */ break; @@ -1997,14 +1997,14 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { const char *str = va_arg(ap, const char *); - fprintf(out, "\"%s\"", str); + HDfprintf(out, "\"%s\"", str); } /* end else */ break; @@ -2013,24 +2013,24 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5T_cset_t cset = (H5T_cset_t)va_arg(ap, int); switch(cset) { case H5T_CSET_ERROR: - fprintf(out, "H5T_CSET_ERROR"); + HDfprintf(out, "H5T_CSET_ERROR"); break; case H5T_CSET_ASCII: - fprintf(out, "H5T_CSET_ASCII"); + HDfprintf(out, "H5T_CSET_ASCII"); break; case H5T_CSET_UTF8: - fprintf(out, "H5T_CSET_UTF8"); + HDfprintf(out, "H5T_CSET_UTF8"); break; case H5T_CSET_RESERVED_2: @@ -2047,11 +2047,11 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5T_CSET_RESERVED_13: case H5T_CSET_RESERVED_14: case H5T_CSET_RESERVED_15: - fprintf(out, "H5T_CSET_RESERVED_%ld", (long)cset); + HDfprintf(out, "H5T_CSET_RESERVED_%ld", (long)cset); break; default: - fprintf(out, "%ld", (long)cset); + HDfprintf(out, "%ld", (long)cset); break; } /* end switch */ } /* end else */ @@ -2060,28 +2060,28 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5T_direction_t direct = (H5T_direction_t)va_arg(ap, int); switch(direct) { case H5T_DIR_DEFAULT: - fprintf(out, "H5T_DIR_DEFAULT"); + HDfprintf(out, "H5T_DIR_DEFAULT"); break; case H5T_DIR_ASCEND: - fprintf(out, "H5T_DIR_ASCEND"); + HDfprintf(out, "H5T_DIR_ASCEND"); break; case H5T_DIR_DESCEND: - fprintf(out, "H5T_DIR_DESCEND"); + HDfprintf(out, "H5T_DIR_DESCEND"); break; default: - fprintf(out, "%ld", (long)direct); + HDfprintf(out, "%ld", (long)direct); break; } /* end switch */ } /* end else */ @@ -2090,28 +2090,28 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5T_pers_t pers = (H5T_pers_t)va_arg(ap, int); switch(pers) { case H5T_PERS_DONTCARE: - fprintf(out, "H5T_PERS_DONTCARE"); + HDfprintf(out, "H5T_PERS_DONTCARE"); break; case H5T_PERS_SOFT: - fprintf(out, "H5T_PERS_SOFT"); + HDfprintf(out, "H5T_PERS_SOFT"); break; case H5T_PERS_HARD: - fprintf(out, "H5T_PERS_HARD"); + HDfprintf(out, "H5T_PERS_HARD"); break; default: - fprintf(out, "%ld", (long)pers); + HDfprintf(out, "%ld", (long)pers); break; } /* end switch */ } /* end else */ @@ -2120,32 +2120,32 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'n': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5T_norm_t norm = (H5T_norm_t)va_arg(ap, int); switch(norm) { case H5T_NORM_ERROR: - fprintf(out, "H5T_NORM_ERROR"); + HDfprintf(out, "H5T_NORM_ERROR"); break; case H5T_NORM_IMPLIED: - fprintf(out, "H5T_NORM_IMPLIED"); + HDfprintf(out, "H5T_NORM_IMPLIED"); break; case H5T_NORM_MSBSET: - fprintf(out, "H5T_NORM_MSBSET"); + HDfprintf(out, "H5T_NORM_MSBSET"); break; case H5T_NORM_NONE: - fprintf(out, "H5T_NORM_NONE"); + HDfprintf(out, "H5T_NORM_NONE"); break; default: - fprintf(out, "%ld", (long)norm); + HDfprintf(out, "%ld", (long)norm); break; } /* end switch */ } /* end else */ @@ -2154,40 +2154,40 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5T_order_t order = (H5T_order_t)va_arg(ap, int); switch(order) { case H5T_ORDER_ERROR: - fprintf(out, "H5T_ORDER_ERROR"); + HDfprintf(out, "H5T_ORDER_ERROR"); break; case H5T_ORDER_LE: - fprintf(out, "H5T_ORDER_LE"); + HDfprintf(out, "H5T_ORDER_LE"); break; case H5T_ORDER_BE: - fprintf(out, "H5T_ORDER_BE"); + HDfprintf(out, "H5T_ORDER_BE"); break; case H5T_ORDER_VAX: - fprintf(out, "H5T_ORDER_VAX"); + HDfprintf(out, "H5T_ORDER_VAX"); break; case H5T_ORDER_MIXED: - fprintf(out, "H5T_ORDER_MIXED"); + HDfprintf(out, "H5T_ORDER_MIXED"); break; case H5T_ORDER_NONE: - fprintf(out, "H5T_ORDER_NONE"); + HDfprintf(out, "H5T_ORDER_NONE"); break; default: - fprintf(out, "%ld", (long)order); + HDfprintf(out, "%ld", (long)order); break; } /* end switch */ } /* end else */ @@ -2196,36 +2196,36 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'p': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5T_pad_t pad = (H5T_pad_t)va_arg(ap, int); switch(pad) { case H5T_PAD_ERROR: - fprintf(out, "H5T_PAD_ERROR"); + HDfprintf(out, "H5T_PAD_ERROR"); break; case H5T_PAD_ZERO: - fprintf(out, "H5T_PAD_ZERO"); + HDfprintf(out, "H5T_PAD_ZERO"); break; case H5T_PAD_ONE: - fprintf(out, "H5T_PAD_ONE"); + HDfprintf(out, "H5T_PAD_ONE"); break; case H5T_PAD_BACKGROUND: - fprintf(out, "H5T_PAD_BACKGROUND"); + HDfprintf(out, "H5T_PAD_BACKGROUND"); break; case H5T_NPAD: - fprintf(out, "H5T_NPAD"); + HDfprintf(out, "H5T_NPAD"); break; default: - fprintf(out, "%ld", (long)pad); + HDfprintf(out, "%ld", (long)pad); break; } /* end switch */ } /* end else */ @@ -2234,32 +2234,32 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5T_sign_t sign = (H5T_sign_t)va_arg(ap, int); switch(sign) { case H5T_SGN_ERROR: - fprintf(out, "H5T_SGN_ERROR"); + HDfprintf(out, "H5T_SGN_ERROR"); break; case H5T_SGN_NONE: - fprintf(out, "H5T_SGN_NONE"); + HDfprintf(out, "H5T_SGN_NONE"); break; case H5T_SGN_2: - fprintf(out, "H5T_SGN_2"); + HDfprintf(out, "H5T_SGN_2"); break; case H5T_NSGN: - fprintf(out, "H5T_NSGN"); + HDfprintf(out, "H5T_NSGN"); break; default: - fprintf(out, "%ld", (long)sign); + HDfprintf(out, "%ld", (long)sign); break; } /* end switch */ } /* end else */ @@ -2268,68 +2268,68 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5T_class_t type_class = (H5T_class_t)va_arg(ap, int); switch(type_class) { case H5T_NO_CLASS: - fprintf(out, "H5T_NO_CLASS"); + HDfprintf(out, "H5T_NO_CLASS"); break; case H5T_INTEGER: - fprintf(out, "H5T_INTEGER"); + HDfprintf(out, "H5T_INTEGER"); break; case H5T_FLOAT: - fprintf(out, "H5T_FLOAT"); + HDfprintf(out, "H5T_FLOAT"); break; case H5T_TIME: - fprintf(out, "H5T_TIME"); + HDfprintf(out, "H5T_TIME"); break; case H5T_STRING: - fprintf(out, "H5T_STRING"); + HDfprintf(out, "H5T_STRING"); break; case H5T_BITFIELD: - fprintf(out, "H5T_BITFIELD"); + HDfprintf(out, "H5T_BITFIELD"); break; case H5T_OPAQUE: - fprintf(out, "H5T_OPAQUE"); + HDfprintf(out, "H5T_OPAQUE"); break; case H5T_COMPOUND: - fprintf(out, "H5T_COMPOUND"); + HDfprintf(out, "H5T_COMPOUND"); break; case H5T_REFERENCE: - fprintf(out, "H5T_REFERENCE"); + HDfprintf(out, "H5T_REFERENCE"); break; case H5T_ENUM: - fprintf(out, "H5T_ENUM"); + HDfprintf(out, "H5T_ENUM"); break; case H5T_VLEN: - fprintf(out, "H5T_VLEN"); + HDfprintf(out, "H5T_VLEN"); break; case H5T_ARRAY: - fprintf(out, "H5T_ARRAY"); + HDfprintf(out, "H5T_ARRAY"); break; case H5T_NCLASSES: - fprintf(out, "H5T_NCLASSES"); + HDfprintf(out, "H5T_NCLASSES"); break; default: - fprintf(out, "%ld", (long)type_class); + HDfprintf(out, "%ld", (long)type_class); break; } /* end switch */ } /* end else */ @@ -2338,28 +2338,28 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'z': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5T_str_t str = (H5T_str_t)va_arg(ap, int); switch(str) { case H5T_STR_ERROR: - fprintf(out, "H5T_STR_ERROR"); + HDfprintf(out, "H5T_STR_ERROR"); break; case H5T_STR_NULLTERM: - fprintf(out, "H5T_STR_NULLTERM"); + HDfprintf(out, "H5T_STR_NULLTERM"); break; case H5T_STR_NULLPAD: - fprintf(out, "H5T_STR_NULLPAD"); + HDfprintf(out, "H5T_STR_NULLPAD"); break; case H5T_STR_SPACEPAD: - fprintf(out, "H5T_STR_SPACEPAD"); + HDfprintf(out, "H5T_STR_SPACEPAD"); break; case H5T_STR_RESERVED_3: @@ -2375,18 +2375,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5T_STR_RESERVED_13: case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: - fprintf(out, "H5T_STR_RESERVED(%ld)",(long)str); + HDfprintf(out, "H5T_STR_RESERVED(%ld)",(long)str); break; default: - fprintf(out, "%ld", (long)str); + HDfprintf(out, "%ld", (long)str); break; } /* end switch */ } /* end else */ break; default: - fprintf (out, "BADTYPE(T%c)", type[1]); + HDfprintf (out, "BADTYPE(T%c)", type[1]); goto error; } /* end switch */ break; @@ -2394,19 +2394,19 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { htri_t tri_var = va_arg (ap, htri_t); if(tri_var>0) - fprintf (out, "TRUE"); + HDfprintf (out, "TRUE"); else if(!tri_var) - fprintf (out, "FALSE"); + HDfprintf (out, "FALSE"); else - fprintf(out, "FAIL(%d)", (int)tri_var); + HDfprintf(out, "FAIL(%d)", (int)tri_var); } /* end else */ break; @@ -2415,23 +2415,23 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) { - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned long *p = (unsigned long *)vp; - fprintf(out, " {"); + HDfprintf(out, " {"); for(i = 0; i < asize[asize_idx]; i++) HDfprintf(out, "%s%lu", i?", ":"", p[i]); - fprintf(out, "}"); + HDfprintf(out, "}"); } /* end if */ } /* end if */ else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { unsigned long iul = va_arg(ap, unsigned long); - fprintf(out, "%lu", iul); + HDfprintf(out, "%lu", iul); asize[argno] = (hssize_t)iul; } /* end else */ break; @@ -2439,29 +2439,29 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'L': if(ptr) { if(vp) { - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned long long *p = (unsigned long long *)vp; - fprintf(out, " {"); + HDfprintf(out, " {"); for(i = 0; i < asize[asize_idx]; i++) HDfprintf(out, "%s%llu", i?", ":"", p[i]); - fprintf(out, "}"); + HDfprintf(out, "}"); } /* end if */ } /* end if */ else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { unsigned long long iull = va_arg(ap, unsigned long long); - fprintf(out, "%llu", iull); + HDfprintf(out, "%llu", iull); asize[argno] = (hssize_t)iull; } /* end else */ break; default: - fprintf (out, "BADTYPE(U%c)", type[1]); + HDfprintf (out, "BADTYPE(U%c)", type[1]); goto error; } /* end switch */ break; @@ -2469,48 +2469,48 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'x': if(ptr) { if(vp) { - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { void **p = (void**)vp; - fprintf(out, " {"); + HDfprintf(out, " {"); for(i = 0; i < asize[asize_idx]; i++) { if(p[i]) - fprintf(out, "%s0x%lx", (i ? ", " : ""), (unsigned long)(p[i])); + HDfprintf(out, "%s0x%lx", (i ? ", " : ""), (unsigned long)(p[i])); else - fprintf(out, "%sNULL", (i ? ", " : "")); + HDfprintf(out, "%sNULL", (i ? ", " : "")); } /* end for */ - fprintf(out, "}"); + HDfprintf(out, "}"); } /* end if */ } /* end if */ else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { vp = va_arg (ap, void *); if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end else */ break; case 'z': if(ptr) { if(vp) { - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { size_t *p = (size_t *)vp; - fprintf(out, " {"); + HDfprintf(out, " {"); for(i = 0; i < asize[asize_idx]; i++) HDfprintf(out, "%s%Zu", (i ? ", " : ""), p[i]); - fprintf(out, "}"); + HDfprintf(out, "}"); } /* end if */ } /* end if */ else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { size_t size = va_arg(ap, size_t); @@ -2525,28 +2525,28 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5Z_SO_scale_type_t scale_type = (H5Z_SO_scale_type_t)va_arg(ap, int); switch(scale_type) { case H5Z_SO_FLOAT_DSCALE: - fprintf(out, "H5Z_SO_FLOAT_DSCALE"); + HDfprintf(out, "H5Z_SO_FLOAT_DSCALE"); break; case H5Z_SO_FLOAT_ESCALE: - fprintf(out, "H5Z_SO_FLOAT_ESCALE"); + HDfprintf(out, "H5Z_SO_FLOAT_ESCALE"); break; case H5Z_SO_INT: - fprintf(out, "H5Z_SO_INT"); + HDfprintf(out, "H5Z_SO_INT"); break; default: - fprintf(out, "%ld", (long)scale_type); + HDfprintf(out, "%ld", (long)scale_type); break; } /* end switch */ } /* end else */ @@ -2555,68 +2555,68 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5Z_class2_t *filter = va_arg(ap, H5Z_class2_t*); - fprintf(out, "0x%lx", (unsigned long)filter); + HDfprintf(out, "0x%lx", (unsigned long)filter); } /* end else */ break; case 'e': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5Z_EDC_t edc = (H5Z_EDC_t)va_arg(ap, int); if(H5Z_DISABLE_EDC == edc) - fprintf(out, "H5Z_DISABLE_EDC"); + HDfprintf(out, "H5Z_DISABLE_EDC"); else if (H5Z_ENABLE_EDC == edc) - fprintf(out, "H5Z_ENABLE_EDC"); + HDfprintf(out, "H5Z_ENABLE_EDC"); else - fprintf(out, "%ld", (long)edc); + HDfprintf(out, "%ld", (long)edc); } /* end else */ break; case 'f': if(ptr) { if(vp) - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5Z_filter_t id = va_arg(ap, H5Z_filter_t); if(H5Z_FILTER_DEFLATE == id) - fprintf(out, "H5Z_FILTER_DEFLATE"); + HDfprintf(out, "H5Z_FILTER_DEFLATE"); else - fprintf(out, "%ld", (long)id); + HDfprintf(out, "%ld", (long)id); } /* end else */ break; case 's': if(ptr) { if(vp) { - fprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%lx", (unsigned long)vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { ssize_t *p = (ssize_t *)vp; - fprintf(out, " {"); + HDfprintf(out, " {"); for(i = 0; i < asize[asize_idx]; i++) HDfprintf(out, "%s%Zd", (i ? ", " : ""), p[i]); - fprintf(out, "}"); + HDfprintf(out, "}"); } /* end if */ } /* end if */ else - fprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { ssize_t ssize = va_arg(ap, ssize_t); @@ -2627,32 +2627,32 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; default: - fprintf(out, "BADTYPE(Z%c)", type[1]); + HDfprintf(out, "BADTYPE(Z%c)", type[1]); goto error; } /* end switch */ break; default: if(HDisupper(type[0])) - fprintf(out, "BADTYPE(%c%c)", type[0], type[1]); + HDfprintf(out, "BADTYPE(%c%c)", type[0], type[1]); else - fprintf(out, "BADTYPE(%c)", type[0]); + HDfprintf(out, "BADTYPE(%c)", type[0]); goto error; } /* end switch */ } /* end for */ /* Display event time for return */ if(returning && H5_debug_g.ttimes) - fprintf(out, " @%.6f [dt=%.6f]", (event_time.etime - first_time.etime), + HDfprintf(out, " @%.6f [dt=%.6f]", (event_time.etime - first_time.etime), (event_time.etime - *returning)); error: va_end(ap); if(returning) - fprintf(out, ";\n"); + HDfprintf(out, ";\n"); else { last_call_depth = current_depth++; - fprintf (out, ")"); + HDfprintf (out, ")"); } /* end else */ HDfflush(out); diff --git a/test/testfiles/plist_files/dapl_32be b/test/testfiles/plist_files/dapl_32be index 4dedda2..8dcf239 100644 Binary files a/test/testfiles/plist_files/dapl_32be and b/test/testfiles/plist_files/dapl_32be differ diff --git a/test/testfiles/plist_files/dapl_32le b/test/testfiles/plist_files/dapl_32le index 4dedda2..8dcf239 100644 Binary files a/test/testfiles/plist_files/dapl_32le and b/test/testfiles/plist_files/dapl_32le differ diff --git a/test/testfiles/plist_files/dapl_64be b/test/testfiles/plist_files/dapl_64be index 4dedda2..8dcf239 100644 Binary files a/test/testfiles/plist_files/dapl_64be and b/test/testfiles/plist_files/dapl_64be differ diff --git a/test/testfiles/plist_files/dapl_64le b/test/testfiles/plist_files/dapl_64le index 4dedda2..8dcf239 100644 Binary files a/test/testfiles/plist_files/dapl_64le and b/test/testfiles/plist_files/dapl_64le differ diff --git a/test/testfiles/plist_files/def_dapl_32be b/test/testfiles/plist_files/def_dapl_32be index 3df7289..880eae5 100644 Binary files a/test/testfiles/plist_files/def_dapl_32be and b/test/testfiles/plist_files/def_dapl_32be differ diff --git a/test/testfiles/plist_files/def_dapl_32le b/test/testfiles/plist_files/def_dapl_32le index 3df7289..880eae5 100644 Binary files a/test/testfiles/plist_files/def_dapl_32le and b/test/testfiles/plist_files/def_dapl_32le differ diff --git a/test/testfiles/plist_files/def_dapl_64be b/test/testfiles/plist_files/def_dapl_64be index 3df7289..880eae5 100644 Binary files a/test/testfiles/plist_files/def_dapl_64be and b/test/testfiles/plist_files/def_dapl_64be differ diff --git a/test/testfiles/plist_files/def_dapl_64le b/test/testfiles/plist_files/def_dapl_64le index 3df7289..880eae5 100644 Binary files a/test/testfiles/plist_files/def_dapl_64le and b/test/testfiles/plist_files/def_dapl_64le differ diff --git a/test/testfiles/plist_files/def_fapl_32be b/test/testfiles/plist_files/def_fapl_32be index 199f5c2..6e94011 100644 Binary files a/test/testfiles/plist_files/def_fapl_32be and b/test/testfiles/plist_files/def_fapl_32be differ diff --git a/test/testfiles/plist_files/def_fapl_32le b/test/testfiles/plist_files/def_fapl_32le index 199f5c2..6e94011 100644 Binary files a/test/testfiles/plist_files/def_fapl_32le and b/test/testfiles/plist_files/def_fapl_32le differ diff --git a/test/testfiles/plist_files/def_fapl_64be b/test/testfiles/plist_files/def_fapl_64be index 199f5c2..6e94011 100644 Binary files a/test/testfiles/plist_files/def_fapl_64be and b/test/testfiles/plist_files/def_fapl_64be differ diff --git a/test/testfiles/plist_files/def_fapl_64le b/test/testfiles/plist_files/def_fapl_64le index 199f5c2..6e94011 100644 Binary files a/test/testfiles/plist_files/def_fapl_64le and b/test/testfiles/plist_files/def_fapl_64le differ diff --git a/test/testfiles/plist_files/fapl_32be b/test/testfiles/plist_files/fapl_32be index 108d63f..237b291 100644 Binary files a/test/testfiles/plist_files/fapl_32be and b/test/testfiles/plist_files/fapl_32be differ diff --git a/test/testfiles/plist_files/fapl_32le b/test/testfiles/plist_files/fapl_32le index 108d63f..237b291 100644 Binary files a/test/testfiles/plist_files/fapl_32le and b/test/testfiles/plist_files/fapl_32le differ diff --git a/test/testfiles/plist_files/fapl_64be b/test/testfiles/plist_files/fapl_64be index 108d63f..237b291 100644 Binary files a/test/testfiles/plist_files/fapl_64be and b/test/testfiles/plist_files/fapl_64be differ diff --git a/test/testfiles/plist_files/fapl_64le b/test/testfiles/plist_files/fapl_64le index 108d63f..237b291 100644 Binary files a/test/testfiles/plist_files/fapl_64le and b/test/testfiles/plist_files/fapl_64le differ diff --git a/test/testfiles/plist_files/lapl_32be b/test/testfiles/plist_files/lapl_32be index 6423d30..9d81759 100644 Binary files a/test/testfiles/plist_files/lapl_32be and b/test/testfiles/plist_files/lapl_32be differ diff --git a/test/testfiles/plist_files/lapl_32le b/test/testfiles/plist_files/lapl_32le index 6423d30..9d81759 100644 Binary files a/test/testfiles/plist_files/lapl_32le and b/test/testfiles/plist_files/lapl_32le differ diff --git a/test/testfiles/plist_files/lapl_64be b/test/testfiles/plist_files/lapl_64be index 6423d30..9d81759 100644 Binary files a/test/testfiles/plist_files/lapl_64be and b/test/testfiles/plist_files/lapl_64be differ diff --git a/test/testfiles/plist_files/lapl_64le b/test/testfiles/plist_files/lapl_64le index 6423d30..9d81759 100644 Binary files a/test/testfiles/plist_files/lapl_64le and b/test/testfiles/plist_files/lapl_64le differ diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 6121f81..0fa268e 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -83,12 +83,12 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " -v, --verbose Verbose mode, print object information\n"); PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n"); - PRINTVALSTREAM(rawoutstream, " -E --enable-error-stack Prints messages from the HDF5 error stack as they occur\n"); + PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they occur\n"); PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n"); PRINTVALSTREAM(rawoutstream, " This option will take precedence over the -j and -k options\n"); - PRINTVALSTREAM(rawoutstream, " -j BOUND, --low=BOUND The low bound for library release versions to use when creating\n"); + PRINTVALSTREAM(rawoutstream, " --low=BOUND The low bound for library release versions to use when creating\n"); PRINTVALSTREAM(rawoutstream, " objects in the file (default is H5F_LIBVER_EARLIEST)\n"); - PRINTVALSTREAM(rawoutstream, " -k BOUND, --high=BOUND The high bound for library release versions to use when creating\n"); + PRINTVALSTREAM(rawoutstream, " --high=BOUND The high bound for library release versions to use when creating\n"); PRINTVALSTREAM(rawoutstream, " objects in the file (default is H5F_LIBVER_LATEST)\n"); PRINTVALSTREAM(rawoutstream, " -c L1, --compact=L1 Maximum number of links in header messages\n"); PRINTVALSTREAM(rawoutstream, " -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); @@ -217,7 +217,7 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " Using latest file format with maximum compact group size of 10 and\n"); PRINTVALSTREAM(rawoutstream, " and minimum shared datatype size of 20\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, "5) h5repack -j 0 -k 1 file1 file2\n"); + PRINTVALSTREAM(rawoutstream, "5) h5repack --low=0 --high=1 file1 file2\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " Set low=H5F_LIBVER_EARLIEST and high=H5F_LIBVER_V18 via H5Pset_libver_bounds() when\n"); PRINTVALSTREAM(rawoutstream, " creating the repacked file: file2\n"); diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt index 723711d..0eef0f5 100644 --- a/tools/test/h5repack/testfiles/h5repack-help.txt +++ b/tools/test/h5repack/testfiles/h5repack-help.txt @@ -6,12 +6,12 @@ usage: h5repack [OPTIONS] file1 file2 -v, --verbose Verbose mode, print object information -V, --version Print version number and exit -n, --native Use a native HDF5 type when repacking - -E --enable-error-stack Prints messages from the HDF5 error stack as they occur + --enable-error-stack Prints messages from the HDF5 error stack as they occur -L, --latest Use latest version of file format This option will take precedence over the -j and -k options - -j BOUND, --low=BOUND The low bound for library release versions to use when creating + --low=BOUND The low bound for library release versions to use when creating objects in the file (default is H5F_LIBVER_EARLIEST) - -k BOUND, --high=BOUND The high bound for library release versions to use when creating + --high=BOUND The high bound for library release versions to use when creating objects in the file (default is H5F_LIBVER_LATEST) -c L1, --compact=L1 Maximum number of links in header messages -d L2, --indexed=L2 Minimum number of links in the indexed format @@ -140,7 +140,7 @@ Examples of use: Using latest file format with maximum compact group size of 10 and and minimum shared datatype size of 20 -5) h5repack -j 0 -k 1 file1 file2 +5) h5repack --low=0 --high=1 file1 file2 Set low=H5F_LIBVER_EARLIEST and high=H5F_LIBVER_V18 via H5Pset_libver_bounds() when creating the repacked file: file2 -- cgit v0.12 From 74f74f60bb92cc614616d8ae3d91ecc2921aade1 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Wed, 7 Feb 2018 11:33:31 -0600 Subject: Cleaned up per comments in PR# 876 Platforms tested: Linux/64 (jelly) Darwin (osx1010test) --- test/gen_bounds.c | 528 +++++++++++++++++++++++++++--------------------------- 1 file changed, 262 insertions(+), 266 deletions(-) diff --git a/test/gen_bounds.c b/test/gen_bounds.c index 50b4acc..b3ef0e3 100644 --- a/test/gen_bounds.c +++ b/test/gen_bounds.c @@ -12,9 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Oct 24, 2017 - * - * Purpose: This program is run to generate HDF5 data files used to test + * Purpose: This program is to generate HDF5 data files used to test * version bounds. * * Description @@ -25,10 +23,11 @@ * - bounds_latest_latest.h5 * - bounds_v18_latest.h5 * - bounds_v18_v18.h5 - * + * These files are copied to 1.6 and 1.8 libraries for verifying + * that they can or cannot read particular file format. */ -#include "hdf5.h" +#include "h5test.h" /*********************************************************************** * gen_earliest_latest() creates file "bounds_earliest_latest.h5" @@ -38,118 +37,121 @@ * - A chunked dataset with layout version 3, "DS_chunked_layout_3". (default) * - A chunked dataset with layout version 4, "DS_chunked_layout_4". (H5Pset_chunk_opts) * + * Return: SUCCEED/FAIL + * ***********************************************************************/ -#define FILENAME_E_L "bounds_earliest_latest.h5" + +/* File names for different file format */ +#define FILENAME_E_L "bounds_earliest_latest.h5" +#define FILENAME_E_18 "bounds_earliest_v18.h5" +#define FILENAME_L_L "bounds_latest_latest.h5" +#define FILENAME_18_L "bounds_v18_latest.h5" +#define FILENAME_18_18 "bounds_v18_v18.h5" /* 2-D dataset with fixed dimensions */ -#define RANK 2 -#define DIM1 100 -#define DIM2 200 -#define CHUNK_DIM1 50 -#define CHUNK_DIM2 50 +#define RANK 2 +#define DIM1 100 +#define DIM2 200 +#define CHK_DIM1 50 +#define CHK_DIM2 50 -int gen_earliest_latest() +static herr_t gen_earliest_latest(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - hsize_t dims[RANK] = {DIM1, DIM2}; - hsize_t chunk_dims[RANK] = {CHUNK_DIM1, CHUNK_DIM2}; - float buf[DIM1][DIM2]; /* Buffer for writing data */ - int i, j; + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + float *buf = NULL; /* Buffer for writing data */ + float *bufp = NULL; /* Pointer to data buffer */ + hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ + hsize_t chunk_dims[RANK] = {CHK_DIM1, CHK_DIM2}; /* Dimensions of chunk */ + int i, j; + herr_t ret = SUCCEED; /* Generic return value */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - goto error; + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Set the "use the earliest/latest version of the format" bounds for creating objects in the file */ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) - goto error; + TEST_ERROR; /* Create file */ if((fid = H5Fcreate(FILENAME_E_L, H5F_ACC_TRUNC, fcpl, fapl)) <0) - goto error; + TEST_ERROR; /* Close file property lists */ - if(H5Pclose(fapl) < 0) - goto error; - if(H5Pclose(fcpl) < 0) - goto error; + if(H5Pclose(fapl) < 0) TEST_ERROR; + if(H5Pclose(fcpl) < 0) TEST_ERROR; /* * Add a chunked dataset with layout version 3 (default) */ + buf = (float *)HDmalloc((size_t)DIM1 * (size_t)DIM2 * sizeof(float)); + if (buf == NULL) TEST_ERROR; /* Fill sample data */ + bufp = buf; for (i = 0; i < DIM1; i++) for (j = 0; j < DIM2; j++) - buf[i][j] = 100.0F; + *bufp = 100.0F; /* Create the dataspace */ - if((space = H5Screate_simple(RANK, dims, NULL)) < 0) - goto error; + if((space = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - goto error; + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; /* Create and write the dataset */ - if((dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; - if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; + dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (dset < 0) TEST_ERROR; + + ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + if (ret < 0) TEST_ERROR; /* Close property list and dataset, will reuse dataspace */ - if(H5Pclose(dcpl) < 0) - goto error; - if(H5Dclose(dset) < 0) - goto error; + if(H5Pclose(dcpl) < 0) TEST_ERROR; + if(H5Dclose(dset) < 0) TEST_ERROR; /* * Add a chunked dataset with layout version 4 (H5Pset_chunk_opts) */ /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - goto error; + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; /* Disable partial chunk filters, triggers layout version 4 */ if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) - goto error; + TEST_ERROR; /* Create and write the dataset */ - if((dset = H5Dcreate2(fid, "DS_chunked_layout_4", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; - if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; + dset = H5Dcreate2(fid, "DS_chunked_layout_4", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (dset < 0) TEST_ERROR; + ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + if (ret < 0) TEST_ERROR; + + /* Release allocated buffer */ + HDfree(buf); + bufp = buf = NULL; /* Close everything */ - if(H5Pclose(dcpl) < 0) - goto error; - if(H5Dclose(dset) < 0) - goto error; - if(H5Sclose(space) < 0) - goto error; - if(H5Fclose(fid) < 0) - goto error; + if(H5Pclose(dcpl) < 0) TEST_ERROR; + if(H5Dclose(dset) < 0) TEST_ERROR; + if(H5Sclose(space) < 0) TEST_ERROR; + if(H5Fclose(fid) < 0) TEST_ERROR; - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -159,8 +161,9 @@ error: H5Pclose(fcpl); H5Pclose(fapl); H5Fclose(fid); + HDfree(buf); } H5E_END_TRY; - return 1; + return FAIL; } /* gen_earliest_latest */ /*********************************************************************** @@ -170,83 +173,83 @@ error: * - Version 0 superblock (default) * - A chunked dataset with layout version 3, "DS_chunked_layout_3". (default) * + * Return: SUCCEED/FAIL + * ***********************************************************************/ -#define FILENAME_E_18 "bounds_earliest_v18.h5" - -int gen_earliest_v18() +static herr_t gen_earliest_v18(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - hsize_t dims[RANK] = {DIM1, DIM2}; - hsize_t chunk_dims[RANK] = {CHUNK_DIM1, CHUNK_DIM2}; - float buf[DIM1][DIM2]; /* Buffer for writing data */ - int i, j; + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + float *buf = NULL; /* Buffer for writing data */ + float *bufp = NULL; /* Pointer to data buffer */ + hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ + hsize_t chunk_dims[RANK] = {CHK_DIM1, CHK_DIM2}; /* Dimensions of chunk */ + int i, j; + herr_t ret = SUCCEED; /* Generic return value */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - goto error; + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Set the "use the earliest/v18 version of the format" bounds for creating objects in the file */ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_V18) < 0) - goto error; + TEST_ERROR; /* Create file */ if((fid = H5Fcreate(FILENAME_E_18, H5F_ACC_TRUNC, fcpl, fapl)) <0) - goto error; + TEST_ERROR; /* Close file property lists */ - if(H5Pclose(fapl) < 0) - goto error; - if(H5Pclose(fcpl) < 0) - goto error; + if(H5Pclose(fapl) < 0) TEST_ERROR; + if(H5Pclose(fcpl) < 0) TEST_ERROR; /* * Add a chunked dataset with layout version 3 (default) */ + buf = (float *)HDmalloc((size_t)DIM1 * (size_t)DIM2 * sizeof(float)); + if (buf == NULL) TEST_ERROR; + /* Fill sample data */ + bufp = buf; for (i = 0; i < DIM1; i++) for (j = 0; j < DIM2; j++) - buf[i][j] = 100.0F; + *bufp = 100.0F; /* Create the dataspace */ - if((space = H5Screate_simple(RANK, dims, NULL)) < 0) - goto error; + if((space = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - goto error; + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; /* Create and write the dataset */ - if((dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; - if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; + dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (dset < 0) TEST_ERROR; + + ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + if (ret < 0) TEST_ERROR; + + /* Release allocated buffer */ + HDfree(buf); + bufp = buf = NULL; /* Close everything */ - if(H5Pclose(dcpl) < 0) - goto error; - if(H5Dclose(dset) < 0) - goto error; - if(H5Sclose(space) < 0) - goto error; - if(H5Fclose(fid) < 0) - goto error; + if(H5Pclose(dcpl) < 0) TEST_ERROR; + if(H5Dclose(dset) < 0) TEST_ERROR; + if(H5Sclose(space) < 0) TEST_ERROR; + if(H5Fclose(fid) < 0) TEST_ERROR; - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -256,8 +259,9 @@ error: H5Pclose(fcpl); H5Pclose(fapl); H5Fclose(fid); + HDfree(buf); } H5E_END_TRY; - return 1; + return FAIL; } /* gen_earliest_v18 */ /*********************************************************************** @@ -267,66 +271,69 @@ error: * - Version 3 superblock (H5Fcreate with H5F_ACC_SWMR_WRITE) * - A chunked dataset with layout version 4, "DS_chunked_layout_4". (H5Pset_chunk_opts) * + * Return: SUCCEED/FAIL + * ***********************************************************************/ -#define FILENAME_L_L "bounds_latest_latest.h5" - -int gen_latest_latest() +static herr_t gen_latest_latest(void) { - hid_t fid = -1; /* File ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - hsize_t dims[RANK] = {DIM1, DIM2}; - hsize_t chunk_dims[RANK] = {CHUNK_DIM1, CHUNK_DIM2}; - float buf[DIM1][DIM2]; /* Buffer for writing data */ - int i, j; + hid_t fid = -1; /* File ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + float *buf = NULL; /* Buffer for writing data */ + float *bufp = NULL; /* Pointer to data buffer */ + hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ + hsize_t chunk_dims[RANK] = {CHK_DIM1, CHK_DIM2}; /* Dimensions of chunk */ + int i, j; + herr_t ret = SUCCEED; /* Generic return value */ /* Create file with H5F_ACC_SWMR_WRITE, triggers version 3 superblock */ - if((fid = H5Fcreate(FILENAME_L_L, H5F_ACC_SWMR_WRITE, H5P_DEFAULT, H5P_DEFAULT)) <0) - goto error; + fid = H5Fcreate(FILENAME_L_L, H5F_ACC_SWMR_WRITE, H5P_DEFAULT, H5P_DEFAULT); + if (fid < 0) TEST_ERROR; /* * Add a chunked dataset with layout version 4 (H5Pset_chunk_opts) */ + buf = (float *)HDmalloc((size_t)DIM1 * (size_t)DIM2 * sizeof(float)); + if (buf == NULL) TEST_ERROR; + /* Fill sample data */ + bufp = buf; for (i = 0; i < DIM1; i++) for (j = 0; j < DIM2; j++) - buf[i][j] = 100.0F; + *bufp = 100.0F; /* Create the dataspace */ - if((space = H5Screate_simple(RANK, dims, NULL)) < 0) - goto error; + if((space = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - goto error; + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; /* Disable partial chunk filters, triggers layout version 4 */ if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) - goto error; + TEST_ERROR; /* Create and write the dataset */ - if((dset = H5Dcreate2(fid, "DS_chunked_layout_4", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; - if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; + dset = H5Dcreate2(fid, "DS_chunked_layout_4", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (dset < 0) TEST_ERROR; + ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + if (ret < 0) TEST_ERROR; + + /* Release allocated buffer */ + HDfree(buf); + bufp = buf = NULL; /* Close everything */ - if(H5Pclose(dcpl) < 0) - goto error; - if(H5Dclose(dset) < 0) - goto error; - if(H5Sclose(space) < 0) - goto error; - if(H5Fclose(fid) < 0) - goto error; + if(H5Pclose(dcpl) < 0) TEST_ERROR; + if(H5Dclose(dset) < 0) TEST_ERROR; + if(H5Sclose(space) < 0) TEST_ERROR; + if(H5Fclose(fid) < 0) TEST_ERROR; - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -334,8 +341,9 @@ error: H5Sclose(space); H5Pclose(dcpl); H5Fclose(fid); + HDfree(buf); } H5E_END_TRY; - return 1; + return FAIL; } /* gen_latest_latest */ /*********************************************************************** @@ -345,83 +353,82 @@ error: * - Version 2 superblock * - A chunked dataset with layout version 3, "DS_chunked_layout_3". (default) * + * Return: SUCCEED/FAIL + * ***********************************************************************/ -#define FILENAME_18_L "bounds_v18_latest.h5" - -int gen_v18_latest() +static herr_t gen_v18_latest(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - hsize_t dims[RANK] = {DIM1, DIM2}; - hsize_t chunk_dims[RANK] = {CHUNK_DIM1, CHUNK_DIM2}; - float buf[DIM1][DIM2]; /* Buffer for writing data */ - int i, j; + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + float *buf = NULL; /* Buffer for writing data */ + float *bufp = NULL; /* Pointer to data buffer */ + hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ + hsize_t chunk_dims[RANK] = {CHK_DIM1, CHK_DIM2}; /* Dimensions of chunk */ + int i, j; + herr_t ret = SUCCEED; /* Generic return value */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - goto error; + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Set the "use the v18/latest version of the format" bounds for creating objects in the file, also trigger version 2 superblock */ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) - goto error; + TEST_ERROR; /* Create file */ if((fid = H5Fcreate(FILENAME_18_L, H5F_ACC_TRUNC, fcpl, fapl)) <0) - goto error; + TEST_ERROR; /* Close file property lists */ - if(H5Pclose(fapl) < 0) - goto error; - if(H5Pclose(fcpl) < 0) - goto error; + if(H5Pclose(fapl) < 0) TEST_ERROR; + if(H5Pclose(fcpl) < 0) TEST_ERROR; /* * Add a chunked dataset with layout version 3 (default) */ + buf = (float *)HDmalloc((size_t)DIM1 * (size_t)DIM2 * sizeof(float)); + if (buf == NULL) TEST_ERROR; + /* Fill sample data */ + bufp = buf; for (i = 0; i < DIM1; i++) for (j = 0; j < DIM2; j++) - buf[i][j] = 100.0F; + *bufp = 100.0F; /* Create the dataspace */ - if((space = H5Screate_simple(RANK, dims, NULL)) < 0) - goto error; + if((space = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - goto error; + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; /* Create and write the dataset */ - if((dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; - if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; + dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (dset < 0) TEST_ERROR; + ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + if (ret < 0) TEST_ERROR; + + /* Release allocated buffer */ + HDfree(buf); + bufp = buf = NULL; /* Close property list and dataset, will reuse dataspace */ - if(H5Pclose(dcpl) < 0) - goto error; - if(H5Dclose(dset) < 0) - goto error; - if(H5Sclose(space) < 0) - goto error; - if(H5Fclose(fid) < 0) - goto error; + if(H5Pclose(dcpl) < 0) TEST_ERROR; + if(H5Dclose(dset) < 0) TEST_ERROR; + if(H5Sclose(space) < 0) TEST_ERROR; + if(H5Fclose(fid) < 0) TEST_ERROR; - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -431,8 +438,9 @@ error: H5Pclose(fcpl); H5Pclose(fapl); H5Fclose(fid); + HDfree(buf); } H5E_END_TRY; - return 1; + return FAIL; } /* gen_v18_latest */ /*********************************************************************** @@ -443,128 +451,120 @@ error: * - A chunked dataset with layout version 3, "DS_chunked_layout_3". (default) * - A chunked dataset with layout version 4, "DS_chunked_layout_4". (H5Pset_chunk_opts) * + * Return: SUCCEED/FAIL + * ***********************************************************************/ -#define FILENAME_18_18 "bounds_v18_v18.h5" - -int gen_v18_v18() +static herr_t gen_v18_v18(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list ID */ - hid_t fcpl = -1; /* File creation property list ID */ - hid_t dcpl = -1; /* Dataset creation property list ID */ - hid_t space = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - hsize_t dims[RANK] = {DIM1, DIM2}; - hsize_t chunk_dims[RANK] = {CHUNK_DIM1, CHUNK_DIM2}; - float buf[DIM1][DIM2]; /* Buffer for writing data */ - int i, j; + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + float *buf = NULL; /* Buffer for writing data */ + float *bufp = NULL; /* Pointer to data buffer */ + hsize_t dims[RANK] = {DIM1, DIM2}; /* Dimensions */ + hsize_t chunk_dims[RANK] = {CHK_DIM1, CHK_DIM2}; /* Dimensions of chunk */ + int i, j; + herr_t ret = SUCCEED; /* Generic return value */ /* Create file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - goto error; + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Set the "use the v18 version of the format" bounds for creating objects in the file */ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_V18) < 0) - goto error; + TEST_ERROR; /* Create file */ if((fid = H5Fcreate(FILENAME_18_18, H5F_ACC_TRUNC, fcpl, fapl)) <0) - goto error; + TEST_ERROR; /* Close file property lists */ - if(H5Pclose(fapl) < 0) - goto error; - if(H5Pclose(fcpl) < 0) - goto error; + if(H5Pclose(fapl) < 0) TEST_ERROR; + if(H5Pclose(fcpl) < 0) TEST_ERROR; /* * Add a chunked dataset with layout version 3 (default) */ + buf = (float *)HDmalloc((size_t)DIM1 * (size_t)DIM2 * sizeof(float)); + if (buf == NULL) TEST_ERROR; + /* Fill sample data */ + bufp = buf; for (i = 0; i < DIM1; i++) for (j = 0; j < DIM2; j++) - buf[i][j] = 100.0F; + *bufp = 100.0F; /* Create the dataspace */ - if((space = H5Screate_simple(RANK, dims, NULL)) < 0) - goto error; + if((space = H5Screate_simple(RANK, dims, NULL)) < 0) TEST_ERROR; /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - goto error; + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; /* Create and write the dataset */ - if((dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; - if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; + dset = H5Dcreate2(fid, "DS_chunked_layout_3", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (dset < 0) TEST_ERROR; + ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + if (ret < 0) TEST_ERROR; /* Close property list and dataset, will reuse dataspace */ - if(H5Pclose(dcpl) < 0) - goto error; - if(H5Dclose(dset) < 0) - goto error; + if(H5Pclose(dcpl) < 0) TEST_ERROR; + if(H5Dclose(dset) < 0) TEST_ERROR; /* Close the file, then reopen it with the latest version */ - if(H5Fclose(fid) < 0) - goto error; + if(H5Fclose(fid) < 0) TEST_ERROR; /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; /* Set the "use the v18/latest version of the format" bounds for creating a layout version 4 object in the file */ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) - goto error; + TEST_ERROR; if((fid = H5Fopen(FILENAME_18_18, H5F_ACC_RDWR, fapl)) < 0) - goto error; + TEST_ERROR; /* * Add a chunked dataset with layout version 4 (H5Pset_chunk_opts) */ /* Create the dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; /* Set up for chunked data */ - if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - goto error; + if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) TEST_ERROR; /* Disable partial chunk filters */ if(H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) < 0) - goto error; + TEST_ERROR; /* Create and write the dataset */ - if((dset = H5Dcreate2(fid, "DS_chunked_layout_4", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; - if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; + dset = H5Dcreate2(fid, "DS_chunked_layout_4", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (dset < 0) TEST_ERROR; + ret = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + if (ret < 0) TEST_ERROR; + + /* Release allocated buffer */ + HDfree(buf); + bufp = buf = NULL; /* Close everything */ - if(H5Pclose(dcpl) < 0) - goto error; - if(H5Pclose(fapl) < 0) - goto error; - if(H5Dclose(dset) < 0) - goto error; - if(H5Sclose(space) < 0) - goto error; - if(H5Fclose(fid) < 0) - goto error; - return 0; + if(H5Pclose(dcpl) < 0) TEST_ERROR; + if(H5Pclose(fapl) < 0) TEST_ERROR; + if(H5Dclose(dset) < 0) TEST_ERROR; + if(H5Sclose(space) < 0) TEST_ERROR; + if(H5Fclose(fid) < 0) TEST_ERROR; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -574,35 +574,31 @@ error: H5Pclose(fcpl); H5Pclose(fapl); H5Fclose(fid); + HDfree(buf); } H5E_END_TRY; - return 1; + return FAIL; } /* gen_v18_v18 */ int main(void) { /* Generate file bounds_earliest_latest.h5 */ - if (gen_earliest_latest() < 0) - goto error; + if (gen_earliest_latest() < 0) TEST_ERROR; /* Generate file bounds_earliest_v18.h5 */ - if (gen_earliest_v18() < 0) - goto error; + if (gen_earliest_v18() < 0) TEST_ERROR; /* Generate file bounds_latest_latest.h5 */ - if (gen_latest_latest() < 0) - goto error; + if (gen_latest_latest() < 0) TEST_ERROR; /* Generate file bounds_v18_latest.h5 */ - if (gen_v18_latest() < 0) - goto error; + if (gen_v18_latest() < 0) TEST_ERROR; /* Generate file bounds_v18_v18.h5 */ - if (gen_v18_v18() < 0) - goto error; + if (gen_v18_v18() < 0) TEST_ERROR; - return 0; + return EXIT_SUCCESS; error: - return 1; + return EXIT_FAILURE; } -- cgit v0.12 From ae2577ff5e1b985a498bb57fc69ab7e85347ec7f Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Thu, 8 Feb 2018 12:59:23 -0600 Subject: Added gen_bounds --- test/CMakeTests.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index e6b364c..06bbd06 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -1355,6 +1355,7 @@ if (HDF5_BUILD_GENERATORS) gen_bad_offset gen_bad_ohdr gen_bogus + gen_bounds gen_cross gen_deflate gen_filters -- cgit v0.12 From 0a61befddc6f93cec1aa669e3c348e40e83ff0e7 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Tue, 13 Feb 2018 11:05:08 -0600 Subject: Additional tests Description: - Revised and add more variety to version bound tests per review - Revised gen_bounds.c per review Platforms tested: Linux/64 (jelly) Linux/32 (jam) Darwin (osx1010test) --- test/dsets.c | 419 ++++++++++++++++++++++++++++++++++++++++++++++-------- test/objcopy.c | 199 ++++++++++++++++++++++++++ test/ohdr.c | 86 ++++++++--- test/set_extent.c | 31 +++- test/tfile.c | 130 +++++++++++++++++ test/th5o.c | 191 +++++++++++++------------ test/th5s.c | 149 +++++++++++++++++++ 7 files changed, 1026 insertions(+), 179 deletions(-) diff --git a/test/dsets.c b/test/dsets.c index 0fff2d1..09f553e 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -24,8 +24,31 @@ #define H5Z_FRIEND /*suppress error about including H5Zpkg */ -#include "h5test.h" +#include "hdf5.h" +#include "testhdf5.h" #include "H5srcdir.h" + +#include "H5Bprivate.h" +#include "H5Iprivate.h" +#include "H5Pprivate.h" + +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_TESTING +#include "H5Fpkg.h" /* File access */ + +#define H5S_FRIEND /*suppress error about including H5Spkg */ +#include "H5Spkg.h" /* Dataspace */ + +#define H5T_FRIEND /*suppress error about including H5Tpkg */ +#include "H5Tpkg.h" /* Datatype */ + +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Apkg.h" /* Attributes */ + +/* Use in version bound test */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5Opkg.h" /* Object headers */ + #include "H5Dpkg.h" #include "H5FDpkg.h" #include "H5VMprivate.h" @@ -60,8 +83,10 @@ const char *FILENAME[] = { "storage_size", /* 22 */ "dls_01_strings", /* 23 */ "power2up", /* 24 */ + "version_bounds", /* 25 */ NULL }; + #define FILENAME_BUF_SIZE 1024 #define KB 1024 @@ -722,10 +747,15 @@ static herr_t test_compact_io(hid_t fapl) { hid_t file, dataset, space, plist; + hid_t verfile = -1, new_fapl = -1; hsize_t dims[2]; int wbuf[16][8], rbuf[16][8]; char filename[FILENAME_BUF_SIZE]; + H5F_libver_t low, high; /* File format bounds */ + H5F_t *fp; /* Internal file pointer */ + H5D_t *dsetp; /* Internal dataset pointer */ int i, j, n; + herr_t ret; /* Generic return value */ TESTING("compact dataset I/O"); @@ -764,8 +794,6 @@ test_compact_io(hid_t fapl) if(H5Dget_offset(dataset)!=HADDR_UNDEF) TEST_ERROR /* Close file */ - if(H5Sclose(space) < 0) TEST_ERROR - if(H5Pclose(plist) < 0) TEST_ERROR if(H5Dclose(dataset) < 0) TEST_ERROR if(H5Fclose(file) < 0) TEST_ERROR @@ -789,16 +817,110 @@ test_compact_io(hid_t fapl) printf(" wbuf[%d][%d]=%d\n", i, j, wbuf[i][j]); printf(" rbuf[%d][%d]=%d\n", i, j, rbuf[i][j]); goto error; - } /* end if */ + } /* end */ if(H5Dclose(dataset) < 0) TEST_ERROR if(H5Fclose(file) < 0) TEST_ERROR - PASSED(); - return 0; + /************************************** + * Additional test for version bounds * + **************************************/ + + /* Create a copy of file access property list */ + if((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR + + /* Loop through all the combinations of low/high library format bounds, + skipping invalid combinations. + - Create a file, create and write a compact dataset, and verify its data + - Verify the dataset's layout and fill message versions */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + + /* Set version bounds */ + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(new_fapl, low, high); + } H5E_END_TRY; + + if (ret < 0) /* Invalid low/high combinations */ + continue; + + /* Create a file */ + h5_fixname(FILENAME[25], new_fapl, filename, sizeof filename); + if((verfile = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, new_fapl)) < 0) + TEST_ERROR + + /* Create the compact dataset */ + dataset = H5Dcreate2(verfile, DSET_DEFAULT_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, plist, H5P_DEFAULT); + if(dataset < 0) TEST_ERROR + + /* Write the same data as of DSET_COMPACT_IO_NAME */ + if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) + TEST_ERROR + + /* Close DSET_DEFAULT_NAME, then reopen it to read and verify + the data */ + if(H5Dclose(dataset) < 0) TEST_ERROR + if((dataset = H5Dopen2(verfile, DSET_DEFAULT_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR + + /* Check that the values read are the same as the values written */ + for(i = 0; i < 16; i++) + for(j = 0; j < 8; j++) + if(rbuf[i][j] != wbuf[i][j]) { + H5_FAILED(); + printf(" Read different values than written.\n"); + printf(" At index %d,%d\n", i, j); + printf(" wbuf[%d][%d]=%d\n", i, j, wbuf[i][j]); + printf(" rbuf[%d][%d]=%d\n", i, j, rbuf[i][j]); + goto error; + } /* end */ + + /* Get the internal file pointer */ + if((fp = (H5F_t *)H5I_object(verfile)) == NULL) TEST_ERROR + + /* Get the internal dataset pointer */ + if((dsetp = (H5D_t *)H5I_object(dataset)) == NULL) TEST_ERROR + + /* Verify the dataset's layout and fill message versions */ + if(fp->shared->low_bound == H5F_LIBVER_EARLIEST) { + VERIFY(dsetp->shared->layout.version, H5O_LAYOUT_VERSION_DEFAULT, "layout_ver_bounds"); + VERIFY(dsetp->shared->dcpl_cache.fill.version, H5O_FILL_VERSION_2, "fill_ver_bounds"); + } else { + VERIFY(dsetp->shared->layout.version, H5O_layout_ver_bounds[fp->shared->low_bound], "layout_ver_bounds"); + VERIFY(dsetp->shared->dcpl_cache.fill.version, H5O_fill_ver_bounds[fp->shared->low_bound], "fill_ver_bounds"); + } + + /* Close the dataset and delete from the file */ + if(H5Dclose(dataset) < 0) TEST_ERROR + if(H5Ldelete(verfile, DSET_DEFAULT_NAME, H5P_DEFAULT) < 0) + TEST_ERROR + + /* Close the file */ + if(H5Fclose(verfile) < 0) TEST_ERROR + + } /* end for high */ + } /* end for low */ + + if(H5Pclose(new_fapl) < 0) TEST_ERROR + if(H5Sclose(space) < 0) TEST_ERROR + if(H5Pclose(plist) < 0) TEST_ERROR + + PASSED(); + return 0; error: - return -1; + H5E_BEGIN_TRY { + H5Sclose(space); + H5Pclose(plist); + H5Pclose(new_fapl); + H5Dclose(dataset); + H5Fclose(file); + H5Fclose(verfile); + } H5E_END_TRY; + + return -1; } @@ -5045,16 +5167,16 @@ error: /*------------------------------------------------------------------------- * Function: test_multiopen * - * Purpose: Tests that a bug no longer exists. If a dataset is opened - * twice and one of the handles is used to extend the dataset, - * then the other handle should return the new size when - * queried. + * Purpose: Tests that a bug no longer exists. If a dataset is opened + * twice and one of the handles is used to extend the dataset, + * then the other handle should return the new size when + * queried. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, June 9, 1998 * *------------------------------------------------------------------------- @@ -5062,10 +5184,10 @@ error: static herr_t test_multiopen (hid_t file) { - hid_t dcpl = -1, space = -1, dset1 = -1, dset2 = -1; - hsize_t cur_size[1] = {10}; - static hsize_t max_size[1] = {H5S_UNLIMITED}; - hsize_t tmp_size[1]; + hid_t dcpl = -1, space = -1, dset1 = -1, dset2 = -1; + hsize_t cur_size[1] = {10}; + hsize_t tmp_size[1]; + static hsize_t max_size[1] = {H5S_UNLIMITED}; TESTING("multi-open with extending"); @@ -5085,9 +5207,9 @@ test_multiopen (hid_t file) if((space = H5Dget_space(dset2)) < 0) goto error; if(H5Sget_simple_extent_dims(space, tmp_size, NULL) < 0) goto error; if(cur_size[0] != tmp_size[0]) { - H5_FAILED(); - printf(" Got %d instead of %d!\n", (int)tmp_size[0], (int)cur_size[0]); - goto error; + H5_FAILED(); + printf(" Got %d instead of %d!\n", (int)tmp_size[0], (int)cur_size[0]); + goto error; } /* end if */ if(H5Dclose(dset1) < 0) goto error; @@ -9790,6 +9912,7 @@ test_single_chunk(hid_t fapl) } /* end for */ #endif /* H5_HAVE_FILTER_DEFLATE */ + /* Release buffers */ HDfree(wbuf); HDfree(rbuf); @@ -10152,7 +10275,7 @@ error: /*------------------------------------------------------------------------- * Function: test_zero_dim_dset * - * Purpose: Tests support for reading a 1D chunled dataset with + * Purpose: Tests support for reading a 1D chunked dataset with * dimension size = 0. * * Return: Success: 0 @@ -10173,40 +10296,59 @@ test_zero_dim_dset(hid_t fapl) hid_t dsid = -1; /* Dataset ID */ hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */ int data[1]; + H5F_libver_t low, high; /* File format bounds */ + herr_t ret; /* Generic return value */ - TESTING("shrinking large chunk"); + TESTING("chunked dataset with zero dimension"); - h5_fixname(FILENAME[16], fapl, filename, sizeof filename); + /* Loop through all the combinations of low/high library format bounds, + skipping invalid combination, and verify support for reading a 1D + chunked dataset with dimension size = 0 */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - /* Create file */ - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + /* Set version bounds before opening the file */ + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(fapl, low, high); + } H5E_END_TRY; - /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + if (ret < 0) /* Invalid low/high combinations */ + continue; - /* Set 1 chunk size */ - chunk_dim = 1; - if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR + h5_fixname(FILENAME[16], fapl, filename, sizeof filename); - /* Create 1D dataspace with 0 dim size */ - dim = 0; - if((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR + /* Create file */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR - /* Create chunked dataset */ - if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + /* Create dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR - /* write 0 elements from dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR + /* Set 1 chunk size */ + chunk_dim = 1; + if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR - /* Read 0 elements from dataset */ - if(H5Dread(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR + /* Create 1D dataspace with 0 dim size */ + dim = 0; + if((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR - /* Close everything */ - if(H5Sclose(sid) < 0) FAIL_STACK_ERROR - if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + /* Create chunked dataset */ + if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* write 0 elements from dataset */ + if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR + + /* Read 0 elements from dataset */ + if(H5Dread(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR + + /* Close everything */ + if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + + } /* end for high */ + } /* end for low */ PASSED(); @@ -12728,34 +12870,186 @@ error: /*------------------------------------------------------------------------- - * Function: main + * Function: test_versionbounds * - * Purpose: Tests the dataset interface (H5D) + * Purpose: Tests various format versions. + * (Currently, only virtual dataset feature) + * + * Return: Success: 0 + * Failure: -1 + * Description: + * This function attempts to create a virtual dataset in all + * valid combinations of low/high library format bounds. Creation + * of virtual dataset should only succeed in H5F_LIBVER_V110. + * -BMR, January 2018 + * + *------------------------------------------------------------------------- + */ +#define VDS_FNAME1 "virtual_file1" +#define VDS_FNAME2 "virtual_file2" +#define SRC_FNAME "source_file" +#define SRC_DSET "src_dset" +#define V_DSET "v_dset" +static herr_t +test_versionbounds() +{ + hid_t fapl = -1; + hid_t srcfile = -1; /* Files with source dsets */ + hid_t vfile = -1; /* File with virtual dset */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t srcspace = -1; /* Source dataspaces */ + hid_t vspace = -1; /* Virtual dset dataspaces */ + hid_t srcdset = -1; /* Source datset */ + hid_t vdset = -1; /* Virtual dataset */ + hid_t null_dspace = -1; /* Data space of H5S_NULL */ + hsize_t dims[1] = {3}; /* Data space current size */ + char srcfilename[FILENAME_BUF_SIZE]; + char vfilename1[FILENAME_BUF_SIZE]; + char vfilename2[FILENAME_BUF_SIZE]; + H5F_libver_t low, high; /* File format bounds */ + herr_t ret; /* Generic return value */ + + TESTING("version bounds of datasets"); + + /* Create a copy of file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR + + h5_fixname(VDS_FNAME1, fapl, vfilename1, sizeof vfilename1); + h5_fixname(VDS_FNAME2, fapl, vfilename2, sizeof vfilename2); + h5_fixname(SRC_FNAME, fapl, srcfilename, sizeof srcfilename); + + /* Create DCPL */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + + /* Clear virtual layout in DCPL */ + if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + TEST_ERROR + + /* Create source dataspace */ + if((srcspace = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR + + /* Create virtual dataspace */ + if((vspace = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR + + /* Add virtual layout mapping */ + if(H5Pset_virtual(dcpl, vspace, srcfilename, SRC_DSET, srcspace) < 0) + TEST_ERROR + + /* Loop through all the combinations of low/high library format bounds */ + /* Create a source file and a dataset in it. Create a virtual file and + virtual dataset. Creation of virtual dataset should only succeed in + H5F_LIBVER_V110 */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + + /* Set version bounds, skip for invalid low/high combination */ + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(fapl, low, high); + } H5E_END_TRY; + + if (ret < 0) /* Invalid low/high combinations */ + continue; + + /* Create a source file and dataset */ + if((srcfile = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if((srcdset = H5Dcreate2(srcfile, SRC_DSET, H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Create a virtual file */ + if((vfile = H5Fcreate(vfilename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Create the virtual dataset */ + H5E_BEGIN_TRY { + vdset = H5Dcreate2(vfile, V_DSET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); + } H5E_END_TRY; + + if (vdset > 0) /* dataset created successfully */ + { + /* Virtual dataset is only available starting in V110 */ + VERIFY(high, H5F_LIBVER_V110, "virtual dataset"); + + if(H5Dclose(vdset) < 0) TEST_ERROR + vdset = -1; + } + + /* Close virtual file */ + if(H5Fclose(vfile) < 0) TEST_ERROR + vfile = -1; + + /* Close srcdset and srcfile */ + if(H5Dclose(srcdset) < 0) TEST_ERROR + srcdset = -1; + + if(H5Fclose(srcfile) < 0) TEST_ERROR + srcfile = -1; + + } /* for high */ + } /* for low */ + + /* Close dataspaces and properties */ + if(H5Sclose(srcspace) < 0) + TEST_ERROR + srcspace = -1; + if(H5Sclose(vspace) < 0) + TEST_ERROR + vspace = -1; + if(H5Pclose(fapl) < 0) + TEST_ERROR + fapl = -1; + if(H5Pclose(dcpl) < 0) + TEST_ERROR + dcpl = -1; + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Sclose(srcspace); + H5Sclose(vspace); + H5Pclose(dcpl); + H5Pclose(fapl); + H5Dclose(srcdset); + H5Dclose(vdset); + H5Fclose(srcfile); + H5Fclose(vfile); + } H5E_END_TRY; + return -1; +} /* test_versionbounds() */ + + +/*------------------------------------------------------------------------- + * Function: main * - * Return: Success: exit(EXIT_SUCCESS) + * Purpose: Tests the dataset interface (H5D) * - * Failure: exit(EXIT_FAILURE) + * Return: Success: exit(EXIT_SUCCESS) + * Failure: exit(EXIT_FAILURE) * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ int main(void) { - char filename[FILENAME_BUF_SIZE]; - hid_t file, grp, fapl, fapl2; - hid_t fcpl = -1, fcpl2 = -1; + char filename[FILENAME_BUF_SIZE]; + hid_t file, grp, fapl, fapl2; + hid_t fcpl = -1, fcpl2 = -1; unsigned new_format; unsigned paged; - int mdc_nelmts; - size_t rdcc_nelmts; - size_t rdcc_nbytes; - double rdcc_w0; - int nerrors = 0; + int mdc_nelmts; + size_t rdcc_nelmts; + size_t rdcc_nbytes; + double rdcc_w0; + int nerrors = 0; const char *envval; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ /* Don't run this test using certain file drivers */ envval = HDgetenv("HDF5_DRIVER"); @@ -12924,6 +13218,9 @@ main(void) nerrors += (test_scatter_error() < 0 ? 1 : 0); nerrors += (test_gather_error() < 0 ? 1 : 0); + /* Tests version bounds using its own file */ + nerrors += (test_versionbounds() < 0 ? 1 : 0); + /* Run misc tests */ nerrors += dls_01_main(); diff --git a/test/objcopy.c b/test/objcopy.c index 216d111..c4bcbf3 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -18,9 +18,18 @@ * Purpose: Test H5Ocopy(). */ +#include "hdf5.h" #include "testhdf5.h" #include "H5srcdir.h" +#include "H5Bprivate.h" +#include "H5Iprivate.h" +#include "H5Pprivate.h" + +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_TESTING +#include "H5Fpkg.h" /* File access */ + /* * This file needs to access private information from the H5S package. * This file also needs to access the dataspace testing code. @@ -45,12 +54,22 @@ #define H5D_TESTING #include "H5Dpkg.h" /* Datasets */ +/* + * This file needs to access private information from the H5O package. + * This file also needs to access the dataspace testing code. + */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#define H5O_TESTING +#include "H5Opkg.h" /* Object header */ + const char *FILENAME[] = { "objcopy_src", "objcopy_dst", "objcopy_ext", "objcopy_src2", + "verbound_src", + "verbound_dst", NULL }; @@ -127,6 +146,7 @@ const char *FILENAME[] = { #define NAME_LINK_EXTERN_DANGLE "/g_links/external_link_to_nowhere" #define NAME_LINK_EXTERN_DANGLE2 "/g_links2/external_link_to_nowhere" #define NAME_OLD_FORMAT "/dset1" +#define NAME_DSET_NULL "DSET_NULL" #define NAME_BUF_SIZE 1024 #define ATTR_NAME_LEN 80 @@ -2089,6 +2109,184 @@ error: /*------------------------------------------------------------------------- + * Function: test_copy_dataset_versionbounds + * + * Purpose: Verify copying dataset works as expected in various version + * bound combination. + * + * Description: + * Create a simple dataset in SRC file using default versions. + * For each valid version bound combination, create a DST file, + * and attempt to copy the SRC dataset to the DST file. + * When copying fails, verify that the failure is a result of + * the invalid bounds, that is, DST has lower bounds than SRC. + * + * Return: Success: 0 + * Failure: 1 + * + *------------------------------------------------------------------------- + */ +static int +test_copy_dataset_versionbounds(hid_t fcpl_src, hid_t fapl_src) +{ + hid_t fid_src = -1, fid_dst = -1; /* Source and destination file IDs */ + hid_t fapl_dst = -1; /* File access plist for dest file */ + hid_t sid = -1; /* Dataspace ID */ + hid_t did_src = -1, did_dst = -1; /* Source and destination dataset IDs */ + int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ + hsize_t dim2d[2]; /* Dataset dimensions */ + char src_fname[NAME_BUF_SIZE]; /* Name of source file */ + char dst_fname[NAME_BUF_SIZE]; /* Name of destination file */ + H5F_libver_t low, high; /* File format bounds */ + H5F_libver_t low_src, high_src; /* Source file format bounds */ + unsigned srcdset_fillversion; /* Fill version of source dataset */ + hbool_t valid_high = FALSE; /* TRUE if high bound is valid */ + int i, j; /* Local index variables */ + H5D_t *dsetp = NULL; /* Pointer to internal dset structure */ + herr_t ret; /* Generic return value */ + + TESTING("H5Ocopy(): simple dataset with version bounds"); + + /* Initialize write buffer */ + for (i=0; ishared->dcpl_cache.fill.version; + + /* Close dataspace */ + if(H5Sclose(sid) < 0) TEST_ERROR + + /* Close the dataset */ + if(H5Dclose(did_src) < 0) TEST_ERROR + + /* Close the SRC file */ + if(H5Fclose(fid_src) < 0) TEST_ERROR + + /* Open the source file with read-only */ + fid_src = H5Fopen(src_fname, H5F_ACC_RDONLY, fapl_src); + if (fid_src < 0) TEST_ERROR + + /* Loop through all the combinations of low/high library format bounds, + skipping invalid combinations. Create a destination file and copy the + source dataset to it, then verify */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + + /* Set version bounds */ + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(fapl_dst, low, high); + } H5E_END_TRY; + + if (ret < 0) /* Invalid low/high combinations */ + continue; + + /* Create destination file */ + fid_dst = H5Fcreate(dst_fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_dst); + if (fid_dst < 0) TEST_ERROR + + /* Create an uncopied object in destination file so that addresses + in source and destination files aren't the same */ + if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Try to copy the dataset */ + H5E_BEGIN_TRY { + ret = H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT); + } H5E_END_TRY; + + /* If copy failed, check if the failure is expected */ + if (ret < 0) + { + /* Failure is valid if fill version of source dataset is + greater than destination */ + if (srcdset_fillversion <= H5O_fill_ver_bounds[high]) + TEST_ERROR + + /* Close the DST file before continue */ + if(H5Fclose(fid_dst) < 0) TEST_ERROR + continue; + } + + /* Close the DST file */ + if(H5Fclose(fid_dst) < 0) TEST_ERROR + + /* Open destination file */ + fid_dst = H5Fopen(dst_fname, H5F_ACC_RDWR, fapl_dst); + if (fid_dst < 0) TEST_ERROR + + /* Open the datasets to compare */ + did_src = H5Dopen2(fid_src, NAME_DATASET_SIMPLE, H5P_DEFAULT); + if (did_src < 0) TEST_ERROR + did_dst = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT); + if (did_dst < 0) TEST_ERROR + + /* Check if the datasets are equal */ + if (compare_datasets(did_src, did_dst, H5P_DEFAULT, buf) != TRUE) + TEST_ERROR + + /* Close the datasets */ + if(H5Dclose(did_dst) < 0) TEST_ERROR + if(H5Dclose(did_src) < 0) TEST_ERROR + + /* Close the DST file */ + if(H5Fclose(fid_dst) < 0) TEST_ERROR + + } /* for high */ + } /* for low */ + + /* Close property list and source file */ + if (H5Pclose(fapl_dst) < 0) TEST_ERROR + if (H5Fclose(fid_src) < 0) TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(did_dst); + H5Dclose(did_src); + H5Sclose(sid); + H5Pclose(fapl_dst); + H5Fclose(fid_dst); + H5Fclose(fid_src); + } H5E_END_TRY; + + return 1; +} /* end test_copy_dataset_versionbounds */ + + +/*------------------------------------------------------------------------- * Function: test_copy_dataset_simple_samefile * * Purpose: Create a simple dataset in SRC file and copy it to SRC file @@ -14017,6 +14215,7 @@ main(void) /* The tests... */ nerrors += test_copy_dataset_simple(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_versionbounds(fcpl_src, src_fapl); nerrors += test_copy_dataset_simple_samefile(fcpl_src, src_fapl); /* Test with dataset opened in the file or not */ diff --git a/test/ohdr.c b/test/ohdr.c index 3915b38..43346a5 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -738,6 +738,42 @@ error: return FAIL; } /* test_unknown() */ +#define STR_EARLIEST "earliest" +#define STR_V18 "v18" +#define STR_LATEST "latest" +char *version_string(H5F_libver_t libver) +{ + char *str = NULL; + + str = (char *) malloc(20 * sizeof(char)); + if (str == NULL) + { + fprintf(stderr, "Allocation failed\n"); + exit(1); + } + + switch(libver) { + case H5F_LIBVER_EARLIEST: + strcpy(str, STR_EARLIEST); + break; + + case H5F_LIBVER_V18: + strcpy(str, STR_V18); + break; + + case H5F_LIBVER_V110: + HDassert(H5F_LIBVER_LATEST == H5F_LIBVER_V110); + strcpy(str, STR_LATEST); + break; + + case H5F_LIBVER_ERROR: + case H5F_LIBVER_NBOUNDS: + default: + sprintf(str, "%ld", (long)libver); + break; + } /* end switch */ +} /* end of version_string */ + /*------------------------------------------------------------------------- * Function: main @@ -755,32 +791,40 @@ error: int main(void) { - hid_t fapl = -1, file = -1; - H5F_t *f = NULL; - char filename[1024]; - H5O_hdr_info_t hdr_info; /* Object info */ - H5O_loc_t oh_loc; /* Object header locations */ - time_t time_new, ro; - int i; /* Local index variable */ - unsigned b; /* Index for "new format" loop */ - herr_t ret; /* Generic return value */ + hid_t fapl = -1; + hid_t file = -1; + H5F_t *f = NULL; + char filename[1024]; + H5O_hdr_info_t hdr_info; /* Object info */ + H5O_loc_t oh_loc; /* Object header locations */ + H5F_libver_t low, high; /* File format bounds */ + time_t time_new, ro; + unsigned b; /* Index for "new format" loop */ + char msg[80]; /* Message for file format version */ + int i; /* Local index variable */ + herr_t ret; /* Generic return value */ /* Reset library */ h5_reset(); fapl = h5_fileaccess(); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - /* Loop over old & new formats */ - for(b = FALSE; b <= TRUE; b++) { - /* Display info about testing */ - if(b) - HDputs("Using new file format:"); - else - HDputs("Using default file format:"); + /* Loop through all the combinations of low/high library format bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - /* Set the format to use for the file */ - if(H5Pset_libver_bounds(fapl, (b ? H5F_LIBVER_LATEST : H5F_LIBVER_EARLIEST), H5F_LIBVER_LATEST) < 0) - FAIL_STACK_ERROR + /* Set version bounds before opening the file */ + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(fapl, low, high); + } H5E_END_TRY; + + if (ret < 0) /* Invalid low/high combinations */ + continue; + + /* Display info about testing */ + sprintf(msg, "Using file format version: (%s, %s)", version_string(low), + version_string(high)); + HDputs(msg); /* test on object continuation block */ if(test_cont(filename, fapl) < 0) @@ -977,7 +1021,9 @@ main(void) /* Test object header creation metadata cache issues */ if(test_ohdr_cache(filename, fapl) < 0) TEST_ERROR - } /* end for */ + + } /* high */ + } /* low */ /* Verify symbol table messages are cached */ if(h5_verify_cached_stabs(FILENAME, fapl) < 0) TEST_ERROR diff --git a/test/set_extent.c b/test/set_extent.c index b9536e5..0467073 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -427,14 +427,35 @@ error: */ static int do_layouts( hid_t fapl ) { + H5F_libver_t low, high; /* Low and high bounds */ + herr_t ret; /* Generic return value */ - TESTING("storage layout use"); + TESTING("storage layout use - tested with all low/high library format bounds"); + /* Loop through all the combinations of low/high library format bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - if (test_layouts( H5D_COMPACT, fapl ) < 0) - goto error; + hid_t new_fapl; - if (test_layouts( H5D_CONTIGUOUS, fapl ) < 0) - goto error; + /* Copy plist to use locally to avoid modifying the original */ + new_fapl = H5Pcopy(fapl); + + /* Set version bounds */ + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(new_fapl, low, high); + } H5E_END_TRY; + + if (ret < 0) /* Invalid low/high combinations */ + continue; + + if (test_layouts( H5D_COMPACT, new_fapl ) < 0) + goto error; + + if (test_layouts( H5D_CONTIGUOUS, new_fapl ) < 0) + goto error; + + } /* end for high */ + } /* end for low */ PASSED(); diff --git a/test/tfile.c b/test/tfile.c index 03a5233..8b66603 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -4953,6 +4953,134 @@ test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create, CHECK(ret, FAIL, "H5Pclose"); } /* end test_libver_bounds_real() */ + +/*------------------------------------------------------------------------- + * Function: test_libver_bounds_open + * + * Purpose: Tests opening latest file with various low/high bounds. + * + * Return: Success: 0 + * Failure: number of errors + * + *------------------------------------------------------------------------- + */ +#define VERBFNAME "tverbounds_dspace.h5" +#define VERBDSNAME "dataset 1" +#define SPACE1_DIM1 3 +static int +test_libver_bounds_open(void) +{ + hid_t file = -1; /* File ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t new_fapl = -1;/* File access property list ID for reopened file */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hsize_t dim[1] = {SPACE1_DIM1}; /* Dataset dimensions */ + H5F_libver_t low, high; /* File format bounds */ + hsize_t chunk_dim[1] = {SPACE1_DIM1}; /* Chunk dimensions */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Opening File in Various Version Bounds\n")); + + /* Create a file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Create dataspace */ + space = H5Screate_simple(1, dim, NULL); + CHECK(space, FAIL, "H5Screate_simple"); + + /* Create a dataset creation property list */ + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + + /* Create and set chunk plist */ + ret = H5Pset_chunk(dcpl, 1, chunk_dim); + CHECK(ret, FAIL, "H5Pset_chunk"); + ret = H5Pset_deflate(dcpl, 9); + CHECK(ret, FAIL, "H5Pset_deflate"); + ret = H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS); + CHECK(ret, FAIL, "H5Pset_chunk_opts"); + + /* Create a file with (LATEST, LATEST) bounds, create a layout version 4 + dataset, then close the file */ + + /* Set version bounds to (LATEST, LATEST) */ + low = H5F_LIBVER_LATEST; + high = H5F_LIBVER_LATEST; + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the file */ + file = H5Fcreate(VERBFNAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(file, FAIL, "H5Fcreate"); + + /* Create dataset */ + dset = H5Dcreate2(file, VERBDSNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + CHECK(dset, FAIL, "H5Dcreate2"); + + /* Close dataset and file */ + ret = H5Dclose(dset); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + + /* Attempt to open latest file with (earliest, v18), should fail */ + ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_V18); + H5E_BEGIN_TRY { + file = H5Fopen(VERBFNAME, H5F_ACC_RDONLY, fapl); + } H5E_END_TRY; + VERIFY(file, FAIL, "Attempted to open latest file with earliest version"); + + /* Attempt to open latest file with (v18, v18), should fail */ + ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_V18); + H5E_BEGIN_TRY { + file = H5Fopen(VERBFNAME, H5F_ACC_RDONLY, fapl); + } H5E_END_TRY; + VERIFY(file, FAIL, "Attempted to open latest file with v18 bounds"); + + /* Opening VERBFNAME in these combination should succeed. + For each low bound, verify that it is upgraded properly */ + high = H5F_LIBVER_LATEST; + for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) + { + H5F_libver_t new_low = H5F_LIBVER_EARLIEST; + + /* Set version bounds for opening file */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Open the file */ + file = H5Fopen(VERBFNAME, H5F_ACC_RDONLY, fapl); + CHECK(file, FAIL, "H5Fopen"); + + /* Get the new file access property */ + new_fapl = H5Fget_access_plist(file); + CHECK(new_fapl, FAIL, "H5Fget_access_plist"); + + /* Get new low bound and verify that it has been upgraded properly */ + ret = H5Pget_libver_bounds(new_fapl, &new_low, NULL); + CHECK(ret, FAIL, "H5Pget_libver_bounds"); + VERIFY(new_low, H5F_LIBVER_LATEST, "Low bound should be upgraded to H5F_LIBVER_LATEST"); + + ret = H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + } /* for low */ + + /* Close dataspace and property lists */ + ret = H5Sclose(space); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); +} /* end test_libver_bounds_open() */ + + /**************************************************************** ** ** test_libver_bounds(): @@ -4970,6 +5098,7 @@ test_libver_bounds(void) /* Run the tests */ test_libver_bounds_real(H5F_LIBVER_EARLIEST, 1, H5F_LIBVER_LATEST, 2); test_libver_bounds_real(H5F_LIBVER_LATEST, 2, H5F_LIBVER_EARLIEST, 2); + test_libver_bounds_open(); } /* end test_libver_bounds() */ /************************************************************************************** @@ -6249,6 +6378,7 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) * H5T_INTEGER, H5T_FLOAT, H5T_TIME, H5T_STRING, H5T_BITFIELD, H5T_OPAQUE, H5T_REFERENCE: * --the library will only use basic version */ + if(dtype->shared->type == H5T_COMPOUND || dtype->shared->type == H5T_ENUM || dtype->shared->type == H5T_ARRAY) { diff --git a/test/th5o.c b/test/th5o.c index 144ea4c..00d706c 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -774,7 +774,7 @@ test_h5o_link(void) hid_t lcpl_id=-1; hsize_t dims[2] = {TEST6_DIM1, TEST6_DIM2}; htri_t committed; /* Whether the named datatype is committed */ - unsigned new_format; /* Whether to use the new format or not */ + H5F_libver_t low, high; /* File format bounds */ int *wdata; int *rdata; int i, n; @@ -801,98 +801,103 @@ test_h5o_link(void) ret = H5Pset_create_intermediate_group(lcpl_id, TRUE); CHECK(ret, FAIL, "H5Pset_create_intermediate_group"); - /* Loop over using new group format */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { - - /* Make a FAPL that uses the "use the latest version of the format" bounds */ - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - CHECK(fapl_id, FAIL, "H5Pcreate"); - - /* Set the "use the latest version of the format" bounds for creating objects in the file */ - ret = H5Pset_libver_bounds(fapl_id, (new_format ? H5F_LIBVER_LATEST : H5F_LIBVER_EARLIEST), H5F_LIBVER_LATEST); - CHECK(ret, FAIL, "H5Pset_libver_bounds"); - - /* Create a new HDF5 file */ - file_id = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - CHECK(file_id, FAIL, "H5Fcreate"); - - /* Close the FAPL */ - ret = H5Pclose(fapl_id); - CHECK(ret, FAIL, "H5Pclose"); - - - /* Create and commit a datatype with no name */ - type_id = H5Tcopy(H5T_NATIVE_INT); - CHECK(type_id, FAIL, "H5Fcreate"); - ret = H5Tcommit_anon(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Tcommit_anon"); - committed = H5Tcommitted(type_id); - VERIFY(committed, TRUE, "H5Tcommitted"); - - /* Create a dataset with no name using the committed datatype*/ - dset_id = H5Dcreate_anon(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dset_id, FAIL, "H5Dcreate_anon"); - - /* Verify that we can write to and read from the dataset */ - - /* Write the data to the dataset */ - ret = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - CHECK(ret, FAIL, "H5Dwrite"); - - /* Read the data back */ - ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); - CHECK(ret, FAIL, "H5Dread"); - - /* Verify the data */ - for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) - VERIFY(wdata[i], rdata[i], "H5Dread"); - - /* Create a group with no name*/ - group_id = H5Gcreate_anon(file_id, H5P_DEFAULT, H5P_DEFAULT); - CHECK(group_id, FAIL, "H5Gcreate_anon"); - - /* Link nameless datatype into nameless group */ - ret = H5Olink(type_id, group_id, "datatype", H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Olink"); - - /* Link nameless dataset into nameless group with intermediate group */ - ret = H5Olink(dset_id, group_id, "inter_group/dataset", lcpl_id, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Olink"); - - /* Close IDs for dataset and datatype */ - ret = H5Dclose(dset_id); - CHECK(ret, FAIL, "H5Dclose"); - ret = H5Tclose(type_id); - CHECK(ret, FAIL, "H5Tclose"); - - /* Re-open datatype using new link */ - type_id = H5Topen2(group_id, "datatype", H5P_DEFAULT); - CHECK(type_id, FAIL, "H5Topen2"); - - /* Link nameless group to root group and close the group ID*/ - ret = H5Olink(group_id, file_id, "/group", H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Olink"); - ret = H5Gclose(group_id); - CHECK(ret, FAIL, "H5Gclose"); - - /* Open dataset through root group and verify its data */ - dset_id = H5Dopen2(file_id, "/group/inter_group/dataset", H5P_DEFAULT); - CHECK(dset_id, FAIL, "H5Dopen2"); - - /* Read data from dataset */ - ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); - CHECK(ret, FAIL, "H5Dread"); - for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) - VERIFY(wdata[i], rdata[i], "H5Dread"); - - /* Close open IDs */ - ret = H5Dclose(dset_id); - CHECK(ret, FAIL, "H5Dclose"); - ret = H5Tclose(type_id); - CHECK(ret, FAIL, "H5Tclose"); - ret = H5Fclose(file_id); - CHECK(ret, FAIL, "H5Fclose"); - } /* end for */ + /* Create a file access property list */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl_id, FAIL, "H5Pcreate"); + + /* Loop through all the combinations of low/high library format bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + + /* Set version bounds */ + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(fapl_id, low, high); + } H5E_END_TRY; + + if (ret < 0) /* Invalid low/high combinations */ + continue; + + /* Create a new HDF5 file */ + file_id = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + CHECK(file_id, FAIL, "H5Fcreate"); + + /* Close the FAPL */ + ret = H5Pclose(fapl_id); + CHECK(ret, FAIL, "H5Pclose"); + + /* Create and commit a datatype with no name */ + type_id = H5Tcopy(H5T_NATIVE_INT); + CHECK(type_id, FAIL, "H5Fcreate"); + ret = H5Tcommit_anon(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Tcommit_anon"); + committed = H5Tcommitted(type_id); + VERIFY(committed, TRUE, "H5Tcommitted"); + + /* Create a dataset with no name using the committed datatype*/ + dset_id = H5Dcreate_anon(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset_id, FAIL, "H5Dcreate_anon"); + + /* Verify that we can write to and read from the dataset */ + + /* Write the data to the dataset */ + ret = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Read the data back */ + ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); + CHECK(ret, FAIL, "H5Dread"); + + /* Verify the data */ + for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) + VERIFY(wdata[i], rdata[i], "H5Dread"); + + /* Create a group with no name*/ + group_id = H5Gcreate_anon(file_id, H5P_DEFAULT, H5P_DEFAULT); + CHECK(group_id, FAIL, "H5Gcreate_anon"); + + /* Link nameless datatype into nameless group */ + ret = H5Olink(type_id, group_id, "datatype", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); + + /* Link nameless dataset into nameless group with intermediate group */ + ret = H5Olink(dset_id, group_id, "inter_group/dataset", lcpl_id, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); + + /* Close IDs for dataset and datatype */ + ret = H5Dclose(dset_id); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Tclose(type_id); + CHECK(ret, FAIL, "H5Tclose"); + + /* Re-open datatype using new link */ + type_id = H5Topen2(group_id, "datatype", H5P_DEFAULT); + CHECK(type_id, FAIL, "H5Topen2"); + + /* Link nameless group to root group and close the group ID*/ + ret = H5Olink(group_id, file_id, "/group", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); + ret = H5Gclose(group_id); + CHECK(ret, FAIL, "H5Gclose"); + + /* Open dataset through root group and verify its data */ + dset_id = H5Dopen2(file_id, "/group/inter_group/dataset", H5P_DEFAULT); + CHECK(dset_id, FAIL, "H5Dopen2"); + + /* Read data from dataset */ + ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); + CHECK(ret, FAIL, "H5Dread"); + for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) + VERIFY(wdata[i], rdata[i], "H5Dread"); + + /* Close open IDs */ + ret = H5Dclose(dset_id); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Tclose(type_id); + CHECK(ret, FAIL, "H5Tclose"); + ret = H5Fclose(file_id); + CHECK(ret, FAIL, "H5Fclose"); + } /* for high */ + } /* for low */ /* Close remaining IDs */ ret = H5Sclose(space_id); diff --git a/test/th5s.c b/test/th5s.c index c63320a..81ac2ac 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -19,9 +19,29 @@ * *************************************************************/ +#include "hdf5.h" #include "testhdf5.h" #include "H5srcdir.h" +#include "H5Bprivate.h" +#include "H5Iprivate.h" +#include "H5Pprivate.h" + +/* + * This file needs to access private information from the H5S package. + * This file also needs to access the dataspace testing code. + */ +#define H5S_FRIEND /*suppress error about including H5Spkg */ +#include "H5Spkg.h" /* Dataspaces */ + +/* + * This file needs to access private information from the H5O package. + * This file also needs to access the dataspace testing code. + */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#define H5O_TESTING +#include "H5Opkg.h" /* Object header */ + #include "H5private.h" #include "H5Bprivate.h" #include "H5Sprivate.h" @@ -2364,6 +2384,133 @@ test_h5s_bug1(void) CHECK(ret, FAIL, "H5Sclose"); } /* test_h5s_bug1() */ + +/*------------------------------------------------------------------------- + * Function: test_versionbounds + * + * Purpose: Tests version bounds with dataspace. + * + * Description: + * This function creates a file with lower bounds then later + * reopens it with higher bounds to show that the dataspace + * version is upgraded appropriately. + * + * Return: Success: 0 + * Failure: number of errors + * + *------------------------------------------------------------------------- + */ +#define VERBFNAME "tverbounds_dspace.h5" +#define BASIC_DSET "Basic Dataset" +#define LATEST_DSET "Latest Dataset" +static void +test_versionbounds(void) +{ + hid_t file = -1; /* File ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + hid_t fapl = -1; /* File access property list ID */ + hid_t dset_space = -1; /* Retrieved dataset's dataspace ID */ + hsize_t dim[1]; /* Dataset dimensions */ + H5F_libver_t low, high; /* File format bounds */ + H5S_t *spacep = NULL; /* Pointer to internal dataspace */ + herr_t ret = 0; /* Generic return value */ +hid_t sid = -1; +H5S_t *spaceptr = NULL; + + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Version Bounds\n")); + + /* Create a file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Create dataspace */ + dim[0] = 10; + space = H5Screate_simple(1, dim, NULL); + CHECK(space, FAIL, "H5Screate"); + + /* Its version should be H5O_SDSPACE_VERSION_1 */ + spacep = (H5S_t *)H5I_object(space); + CHECK(spacep, NULL, "H5I_object"); + VERIFY(spacep->extent.version, H5O_SDSPACE_VERSION_1, "basic dataspace version bound"); + + /* Set high bound to V18 */ + low = H5F_LIBVER_EARLIEST; + high = H5F_LIBVER_V18; + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the file */ + file = H5Fcreate(VERBFNAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(file, FAIL, "H5Fcreate"); + + /* Create a basic dataset */ + dset = H5Dcreate2(file, BASIC_DSET, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dset > 0) /* dataset created successfully */ + { + /* Get the internal dataspace pointer */ + dset_space = H5Dget_space(dset); + CHECK(dset_space, FAIL, "H5Dget_space"); + spacep = (H5S_t *)H5I_object(dset_space); + CHECK(spacep, NULL, "H5I_object"); + + /* Dataspace version should remain as H5O_SDSPACE_VERSION_1 */ + VERIFY(spacep->extent.version, H5O_SDSPACE_VERSION_1, "basic dataspace version bound"); + + /* Close dataspace */ + ret = H5Sclose(dset_space); + CHECK(ret, FAIL, "H5Sclose"); + } + + /* Close basic dataset and the file */ + ret = H5Dclose(dset); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + + /* Set low and high bounds to latest to trigger the increment of the + dataspace version */ + low = H5F_LIBVER_LATEST; + high = H5F_LIBVER_LATEST; + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Reopen the file with new version bounds, LATEST/LATEST */ + file = H5Fopen(VERBFNAME, H5F_ACC_RDWR, fapl); + + /* Create another dataset using the same dspace as the previous dataset */ + dset = H5Dcreate2(file, LATEST_DSET, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset, FAIL, "H5Dcreate2"); + + /* Dataset created successfully. Verify that dataspace version has been + upgraded per the low bound */ + + /* Get the internal dataspace pointer */ + dset_space = H5Dget_space(dset); + CHECK(dset_space, FAIL, "H5Dget_space"); + spacep = (H5S_t *)H5I_object(dset_space); + CHECK(spacep, NULL, "H5I_object"); + + /* Verify the dataspace version */ + VERIFY(spacep->extent.version, H5O_sdspace_ver_bounds[low], "upgraded dataspace version"); + + /* Close everything */ + ret = H5Sclose(dset_space); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Dclose(dset); + CHECK(ret, FAIL, "H5Dclose"); + + ret = H5Sclose(space); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); +} /* end test_versionbounds() */ + + /**************************************************************** ** ** test_h5s(): Main H5S (dataspace) testing routine. @@ -2391,6 +2538,7 @@ test_h5s(void) test_h5s_extent_equal(); /* Test extent comparison code */ test_h5s_extent_copy(); /* Test extent copy code */ test_h5s_bug1(); /* Test bug in offset initialization */ + test_versionbounds(); /* Test version bounds with dataspace */ } /* test_h5s() */ @@ -2415,4 +2563,5 @@ cleanup_h5s(void) remove(NULLFILE); remove(BASICFILE); remove(ZEROFILE); + remove(VERBFNAME); } -- cgit v0.12 From 551e58e683e76af4aca68998aa718e7e03d8f4f1 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Tue, 13 Feb 2018 12:29:51 -0600 Subject: Fixed typos Platforms tested: Linux/32 (jam) --- test/th5s.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/th5s.c b/test/th5s.c index 81ac2ac..4154c5f 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -2400,7 +2400,7 @@ test_h5s_bug1(void) * *------------------------------------------------------------------------- */ -#define VERBFNAME "tverbounds_dspace.h5" +#define VERBFNAME "tverbounds_dspace.h5" #define BASIC_DSET "Basic Dataset" #define LATEST_DSET "Latest Dataset" static void @@ -2415,9 +2415,6 @@ test_versionbounds(void) H5F_libver_t low, high; /* File format bounds */ H5S_t *spacep = NULL; /* Pointer to internal dataspace */ herr_t ret = 0; /* Generic return value */ -hid_t sid = -1; -H5S_t *spaceptr = NULL; - /* Output message about test being performed */ MESSAGE(5, ("Testing Version Bounds\n")); -- cgit v0.12 From 9a480c34e5ea3df0c1f12df465fc96e5d9e092af Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Tue, 13 Feb 2018 15:24:41 -0600 Subject: Added comment for clarification about latest as 1.10. Platforms tested: Linux/64 (jelly) Linux/32 (jam) --- test/gen_bounds.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/gen_bounds.c b/test/gen_bounds.c index b3ef0e3..9702176 100644 --- a/test/gen_bounds.c +++ b/test/gen_bounds.c @@ -268,9 +268,11 @@ error: * gen_latest_latest() creates file "bounds_latest_latest.h5" * * File contents: - * - Version 3 superblock (H5Fcreate with H5F_ACC_SWMR_WRITE) + * - Version 3 superblock (triggered by H5Fcreate with H5F_ACC_SWMR_WRITE) * - A chunked dataset with layout version 4, "DS_chunked_layout_4". (H5Pset_chunk_opts) * + * NOTE: As of Feb 2018, latest is 1.10. + * * Return: SUCCEED/FAIL * ***********************************************************************/ -- cgit v0.12