diff options
Diffstat (limited to 'src')
48 files changed, 1952 insertions, 1909 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9ff70f9..9a1f545 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -450,6 +450,7 @@ set (H5O_SOURCES ${HDF5_SRC_DIR}/H5Ocont.c ${HDF5_SRC_DIR}/H5Ocopy.c ${HDF5_SRC_DIR}/H5Odbg.c + ${HDF5_SRC_DIR}/H5Odeprec.c ${HDF5_SRC_DIR}/H5Odrvinfo.c ${HDF5_SRC_DIR}/H5Odtype.c ${HDF5_SRC_DIR}/H5Oefl.c @@ -245,7 +245,7 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p/*out* NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node") if(HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)shared->sizeof_rnode))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "file allocation failed for B-tree root node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "file allocation failed for B-tree root node") /* * Cache the new B-tree node. @@ -320,7 +320,7 @@ H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) /* Get shared info for B-tree */ if(NULL == (rc_shared = (type->get_shared)(f, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); @@ -332,7 +332,7 @@ H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) cache_udata.type = type; cache_udata.rc_shared = rc_shared; if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") rt = bt->nchildren; while(lt < rt && cmp) { @@ -1300,7 +1300,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, if((int)(ret_value = H5B__remove_helper(f, bt->child[idx], type, level + 1, H5B_NKEY(bt, shared, idx)/*out*/, lt_key_changed/*out*/, udata, H5B_NKEY(bt, shared, idx + 1)/*out*/, - rt_key_changed/*out*/)) < 0) + rt_key_changed/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in subtree") } else if(type->remove) { /* diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index c4f56e5..0e3ebd5 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -109,7 +109,7 @@ H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, /* Load the B-tree header */ if(NULL == (hdr = H5B2__hdr_protect(f, addr, f, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ hdr->f = f; @@ -208,7 +208,7 @@ H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, /* Load the B-tree header */ if(NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, f, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") /* Set file pointer for this B-tree operation */ hdr->f = f; @@ -220,7 +220,7 @@ H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, node_ptr.addr = addr; H5_CHECKED_ASSIGN(node_ptr.node_nrec, uint16_t, nrec, unsigned) if(NULL == (internal = H5B2__protect_internal(hdr, NULL, &node_ptr, (uint16_t)depth, FALSE, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree internal node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree internal node") /* Print opening message */ HDfprintf(stream, "%*sv2 B-tree Internal Node...\n", indent, ""); @@ -320,7 +320,7 @@ H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, /* Load the B-tree header */ if(NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, f, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set file pointer for this B-tree operation */ hdr->f = f; @@ -332,7 +332,7 @@ H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, node_ptr.addr = addr; H5_CHECKED_ASSIGN(node_ptr.node_nrec, uint16_t, nrec, unsigned) if(NULL == (leaf = H5B2__protect_leaf(hdr, NULL, &node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Print opening message */ HDfprintf(stream, "%*sv2 B-tree Leaf Node...\n", indent, ""); diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 552cebb..27229f1 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -467,7 +467,7 @@ H5_DLL herr_t H5B2__assert_leaf2(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf, /* Testing routines */ #ifdef H5B2_TESTING -H5_DLL herr_t H5B2_get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr); +H5_DLL herr_t H5B2__get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr); H5_DLL int H5B2__get_node_depth_test(H5B2_t *bt2, void *udata); H5_DLL herr_t H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo); diff --git a/src/H5B2test.c b/src/H5B2test.c index 49fe3af..0f4a39c 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -469,12 +469,11 @@ H5B2__test2_debug(FILE *stream, int indent, int fwidth, const void *record, /*------------------------------------------------------------------------- - * Function: H5B2_get_root_addr_test + * Function: H5B2__get_root_addr_test * - * Purpose: Retrieve the root node's address + * Purpose: Retrieve the root node's address * - * Return: Success: non-negative - * Failure: negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Saturday, February 26, 2005 @@ -482,7 +481,7 @@ H5B2__test2_debug(FILE *stream, int indent, int fwidth, const void *record, *------------------------------------------------------------------------- */ herr_t -H5B2_get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr) +H5B2__get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -494,16 +493,15 @@ H5B2_get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr) *root_addr = bt2->hdr->root.addr; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5B2_get_root_addr_test() */ +} /* H5B2__get_root_addr_test() */ /*------------------------------------------------------------------------- - * Function: H5B2__get_node_info_test + * Function: H5B2__get_node_info_test * - * Purpose: Determine information about a node holding a record in the B-tree + * Purpose: Determine information about a node holding a record in the B-tree * - * Return: Success: non-negative - * Failure: negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Thursday, August 31, 2006 @@ -647,15 +645,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5B2__get_node_depth_test + * Function: H5B2__get_node_depth_test * - * Purpose: Determine the depth of a node holding a record in the B-tree + * Purpose: Determine the depth of a node holding a record in the B-tree * - * Note: Just a simple wrapper around the H5B2__get_node_info_test() routine + * Note: Just a simple wrapper around the H5B2__get_node_info_test() routine * - * Return: Success: non-negative depth of the node where the record - * was found - * Failure: negative + * Return: Success: Non-negative depth of the node where the record + * was found + * + * Failure: -1 * * Programmer: Quincey Koziol * Saturday, August 26, 2006 @@ -675,7 +674,7 @@ H5B2__get_node_depth_test(H5B2_t *bt2, void *udata) /* Get information abou the node */ if(H5B2__get_node_info_test(bt2, udata, &ninfo) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "error looking up node info") + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, (-1), "error looking up node info") /* Set return value */ ret_value = (int)ninfo.depth; @@ -233,24 +233,10 @@ typedef struct H5CX_t { hbool_t data_transform_valid; /* Whether data transform info is valid */ H5T_vlen_alloc_info_t vl_alloc_info; /* VL datatype alloc info (H5D_XFER_VLEN_*_NAME) */ hbool_t vl_alloc_info_valid; /* Whether VL datatype alloc info is valid */ - hbool_t dcr_flag; /* Direct chunk read flag (H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME) */ - hbool_t dcr_flag_valid; /* Whether direct chunk read flag is valid */ - hsize_t *dcr_offset; /* Direct chunk read offset (H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME) */ - hbool_t dcr_offset_valid; /* Whether direct chunk read offset is valid */ - hbool_t dcw_flag; /* Direct chunk write flag (H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME) */ - hbool_t dcw_flag_valid; /* Whether direct chunk write flag is valid */ - uint32_t dcw_filters; /* Direct chunk write filter flags (H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME) */ - hbool_t dcw_filters_valid; /* Whether direct chunk write filter flags is valid */ - hsize_t *dcw_offset; /* Direct chunk write offset (H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_NAME) */ - hbool_t dcw_offset_valid; /* Whether direct chunk write offset is valid */ - uint32_t dcw_datasize; /* Direct chunk write data size (H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME) */ - hbool_t dcw_datasize_valid; /* Whether direct chunk write data size is valid */ H5T_conv_cb_t dt_conv_cb; /* Datatype conversion struct (H5D_XFER_CONV_CB_NAME) */ hbool_t dt_conv_cb_valid; /* Whether datatype conversion struct is valid */ /* Return-only DXPL properties to return to application */ - uint32_t dcr_filters; /* Direct chunk read filter flags (H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME) */ - hbool_t dcr_filters_set; /* Whether direct chunk read filter flags are set */ #ifdef H5_HAVE_PARALLEL H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chunk_opt; /* Chunk optimization mode used for parallel I/O (H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME) */ hbool_t mpio_actual_chunk_opt_set; /* Whether chunk optimization mode used for parallel I/O is set */ @@ -321,12 +307,6 @@ typedef struct H5CX_dxpl_cache_t { H5Z_cb_t filter_cb; /* Filter callback function (H5D_XFER_FILTER_CB_NAME) */ H5Z_data_xform_t *data_transform; /* Data transform info (H5D_XFER_XFORM_NAME) */ H5T_vlen_alloc_info_t vl_alloc_info; /* VL datatype alloc info (H5D_XFER_VLEN_*_NAME) */ - hbool_t dcr_flag; /* Direct chunk read flag (H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME) */ - hsize_t *dcr_offset; /* Direct chunk read offset (H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME) */ - hbool_t dcw_flag; /* Direct chunk write flag (H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME) */ - uint32_t dcw_datasize; /* Direct chunk write data size (H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME) */ - hsize_t *dcw_offset; /* Direct chunk write offset (H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_NAME) */ - uint32_t dcw_filters; /* Direct chunk write filter flags (H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME) */ H5T_conv_cb_t dt_conv_cb; /* Datatype conversion struct (H5D_XFER_CONV_CB_NAME) */ } H5CX_dxpl_cache_t; @@ -469,27 +449,10 @@ H5CX__init_package(void) if(H5P_get(dx_plist, H5D_XFER_VLEN_FREE_INFO_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.free_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - /* Get direct chunk read info */ - if(H5P_get(dx_plist, H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME, &H5CX_def_dxpl_cache.dcr_flag) < 0) - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve direct chunk read flag") - if(H5P_get(dx_plist, H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME, &H5CX_def_dxpl_cache.dcr_offset) < 0) - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve direct chunk read offset") - - /* Get direct chunk write info */ - if(H5P_get(dx_plist, H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME, &H5CX_def_dxpl_cache.dcw_flag) < 0) - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve direct chunk write flag") - if(H5P_get(dx_plist, H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME, &H5CX_def_dxpl_cache.dcw_filters) < 0) - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve direct chunk write filter mask") - if(H5P_get(dx_plist, H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_NAME, &H5CX_def_dxpl_cache.dcw_offset) < 0) - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve direct chunk write offset") - if(H5P_get(dx_plist, H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME, &H5CX_def_dxpl_cache.dcw_datasize) < 0) - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve direct chunk write data size") - /* Get datatype conversion struct */ if(H5P_get(dx_plist, H5D_XFER_CONV_CB_NAME, &H5CX_def_dxpl_cache.dt_conv_cb) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve datatype conversion exception callback") - /* Reset the "default LAPL cache" information */ HDmemset(&H5CX_def_lapl_cache, 0, sizeof(H5CX_lapl_cache_t)); @@ -1791,216 +1754,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5CX_get_dcr_flag - * - * Purpose: Retrieves the direct chunk read flag for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Quincey Koziol - * March 6, 2018 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_dcr_flag(hbool_t *dcr_flag) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dcr_flag); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME, dcr_flag) - - /* Get the value */ - *dcr_flag = (*head)->ctx.dcr_flag; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_dcr_flag() */ - - -/*------------------------------------------------------------------------- - * Function: H5CX_get_dcr_offset - * - * Purpose: Retrieves the direct chunk read offset for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Quincey Koziol - * March 6, 2018 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_dcr_offset(hsize_t **dcr_offset) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dcr_offset); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME, dcr_offset) - - /* Get the value */ - *dcr_offset = (*head)->ctx.dcr_offset; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_dcr_offset() */ - - -/*------------------------------------------------------------------------- - * Function: H5CX_get_dcw_flag - * - * Purpose: Retrieves the direct chunk write flag for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Quincey Koziol - * March 6, 2018 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_dcw_flag(hbool_t *dcw_flag) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dcw_flag); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME, dcw_flag) - - /* Get the value */ - *dcw_flag = (*head)->ctx.dcw_flag; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_dcw_flag() */ - - -/*------------------------------------------------------------------------- - * Function: H5CX_get_dcw_filters - * - * Purpose: Retrieves the direct chunk write filter mask for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Quincey Koziol - * March 6, 2018 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_dcw_filters(uint32_t *dcw_filters) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dcw_filters); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME, dcw_filters) - - /* Get the value */ - *dcw_filters = (*head)->ctx.dcw_filters; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_dcw_filters() */ - - -/*------------------------------------------------------------------------- - * Function: H5CX_get_dcw_offset - * - * Purpose: Retrieves the direct chunk write offset for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Quincey Koziol - * March 6, 2018 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_dcw_offset(hsize_t **dcw_offset) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dcw_offset); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_NAME, dcw_offset) - - /* Get the value */ - *dcw_offset = (*head)->ctx.dcw_offset; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_dcw_offset() */ - - -/*------------------------------------------------------------------------- - * Function: H5CX_get_dcw_datasize - * - * Purpose: Retrieves the direct chunk write data size for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Quincey Koziol - * March 6, 2018 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_dcw_datasize(uint32_t *dcw_datasize) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dcw_datasize); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME, dcw_datasize) - - /* Get the value */ - *dcw_datasize = (*head)->ctx.dcw_datasize; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_dcw_datasize() */ - - -/*------------------------------------------------------------------------- * Function: H5CX_get_dt_conv_cb * * Purpose: Retrieves the datatype conversion exception callback for the current API call context. @@ -2358,38 +2111,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_nlinks() */ - -/*------------------------------------------------------------------------- - * Function: H5CX_set_dcr_filters - * - * Purpose: Sets the direct chunk read filter flags for the current API call context. - * - * Return: <none> - * - * Programmer: Quincey Koziol - * March 6, 2018 - * - *------------------------------------------------------------------------- - */ -void -H5CX_set_dcr_filters(uint32_t direct_filters) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Sanity checks */ - HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); - - /* Cache the filter mask for later, marking it to set in DXPL when context popped */ - (*head)->ctx.dcr_filters = direct_filters; - (*head)->ctx.dcr_filters_set = TRUE; - - FUNC_LEAVE_NOAPI_VOID -} /* end H5CX_set_dcr_filters() */ - #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- @@ -2755,7 +2476,6 @@ H5CX__pop_common(void) HDassert(head && *head); /* Check for cached DXPL properties to return to application */ - H5CX_SET_PROP(H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME, dcr_filters) #ifdef H5_HAVE_PARALLEL H5CX_SET_PROP(H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, mpio_actual_chunk_opt) H5CX_SET_PROP(H5D_MPIO_ACTUAL_IO_MODE_NAME, mpio_actual_io_mode) diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index 3566f11..44a4067 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -95,12 +95,6 @@ H5_DLL herr_t H5CX_get_err_detect(H5Z_EDC_t *err_detect); H5_DLL herr_t H5CX_get_filter_cb(H5Z_cb_t *filter_cb); H5_DLL herr_t H5CX_get_data_transform(H5Z_data_xform_t **data_transform); H5_DLL herr_t H5CX_get_vlen_alloc_info(H5T_vlen_alloc_info_t *vl_alloc_info); -H5_DLL herr_t H5CX_get_dcr_flag(hbool_t *direct_read); -H5_DLL herr_t H5CX_get_dcr_offset(hsize_t **direct_offset); -H5_DLL herr_t H5CX_get_dcw_flag(hbool_t *direct_write); -H5_DLL herr_t H5CX_get_dcw_filters(uint32_t *direct_filters); -H5_DLL herr_t H5CX_get_dcw_offset(hsize_t **direct_offset); -H5_DLL herr_t H5CX_get_dcw_datasize(uint32_t *direct_datasize); H5_DLL herr_t H5CX_get_dt_conv_cb(H5T_conv_cb_t *cb_struct); /* "Getter" routines for LAPL properties cached in API context */ @@ -127,7 +121,6 @@ H5_DLL herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, H5_DLL herr_t H5CX_set_nlinks(size_t nlinks); /* "Setter" routines for cached DXPL properties that must be returned to application */ -H5_DLL void H5CX_set_dcr_filters(uint32_t direct_filters); #ifdef H5_HAVE_PARALLEL H5_DLL void H5CX_set_mpio_actual_chunk_opt(H5D_mpio_actual_chunk_opt_mode_t chunk_opt); H5_DLL void H5CX_set_mpio_actual_io_mode(H5D_mpio_actual_io_mode_t actual_io_mode); diff --git a/src/H5Dio.c b/src/H5Dio.c index 1566b5e..452105e 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -50,7 +50,8 @@ /* Local Prototypes */ /********************/ -/* Setup/teardown routines */ +static herr_t H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, + hsize_t *offset_copy/*out*/); static herr_t H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, H5D_storage_t *store, H5D_io_info_t *io_info); static herr_t H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, @@ -80,32 +81,81 @@ H5FL_DEFINE(H5D_chunk_map_t); /*------------------------------------------------------------------------- + * Function: H5D__get_offset_copy + * + * Purpose: Gets a copy of the user's offset array that is guaraneteed + * to be suitable for use by the library. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_copy) +{ + unsigned u; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(dset); + HDassert(offset); + HDassert(offset_copy); + + + /* The library's chunking code requires the offset to terminate with a zero. + * So transfer the offset array to an internal offset array that we + * can properly terminate (handled via the calloc call). + */ + + HDmemset(offset_copy, 0, H5O_LAYOUT_NDIMS * sizeof(hsize_t)); + + for (u = 0; u < dset->shared->ndims; u++) { + /* Make sure the offset doesn't exceed the dataset's dimensions */ + if (offset[u] > dset->shared->curr_dims[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset") + + /* Make sure the offset fall right on a chunk's boundary */ + if (offset[u] % dset->shared->layout.u.chunk.dim[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary") + + offset_copy[u] = offset[u]; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5D__get_offset_copy() */ + + + +/*------------------------------------------------------------------------- * Function: H5Dread * - * Purpose: Reads (part of) a DSET from the file into application - * memory BUF. The part of the dataset to read is defined with - * MEM_SPACE_ID and FILE_SPACE_ID. The data points are - * converted from their file type to the MEM_TYPE_ID specified. - * Additional miscellaneous data transfer properties can be - * passed to this function with the PLIST_ID argument. + * Purpose: Reads (part of) a DSET from the file into application + * memory BUF. The part of the dataset to read is defined with + * MEM_SPACE_ID and FILE_SPACE_ID. The data points are + * converted from their file type to the MEM_TYPE_ID specified. + * Additional miscellaneous data transfer properties can be + * passed to this function with the PLIST_ID argument. * - * The FILE_SPACE_ID can be the constant H5S_ALL which indicates - * that the entire file dataspace is to be referenced. + * The FILE_SPACE_ID can be the constant H5S_ALL which indicates + * that the entire file dataspace is to be referenced. * - * The MEM_SPACE_ID can be the constant H5S_ALL in which case - * the memory dataspace is the same as the file dataspace - * defined when the dataset was created. + * The MEM_SPACE_ID can be the constant H5S_ALL in which case + * the memory dataspace is the same as the file dataspace + * defined when the dataset was created. * - * The number of elements in the memory dataspace must match - * the number of elements in the file dataspace. + * The number of elements in the memory dataspace must match + * the number of elements in the file dataspace. * - * The PLIST_ID can be the constant H5P_DEFAULT in which - * case the default data transfer properties are used. + * The PLIST_ID can be the constant H5P_DEFAULT in which + * case the default data transfer properties are used. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 + * Programmer: Robb Matzke + * Thursday, December 4, 1997 * *------------------------------------------------------------------------- */ @@ -113,135 +163,136 @@ herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, void *buf/*out*/) { - H5D_t *dset = NULL; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - hbool_t direct_read = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset = NULL; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiiiix", dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf); - /* check arguments */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + /* Get dataset pointer */ + if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID") + if (NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if(mem_space_id < 0 || file_space_id < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + /* Get validated dataspace pointers */ + if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") + if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") - if(H5S_ALL != mem_space_id) { - if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else + if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") - /* Check for valid selection */ - if(H5S_SELECT_VALID(mem_space) != TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") - } /* end if */ + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); - if(H5S_ALL != file_space_id) { - if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + /* Read raw data */ + if (H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") - /* Check for valid selection */ - if(H5S_SELECT_VALID(file_space) != TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") - } /* end if */ +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Dread() */ + + +/*------------------------------------------------------------------------- + * Function: H5Dread_chunk + * + * Purpose: Reads an entire chunk from the file directly. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Matthew Strong (GE Healthcare) + * 14 February 2016 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, + void *buf) +{ + H5D_t *dset = NULL; + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "ii*h*Iu*x", dset_id, dxpl_id, offset, filters, buf); + + /* Check arguments */ + if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID") + if (NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + if (!buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf cannot be NULL") + if (!offset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset cannot be NULL") + if (!filters) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "filters cannot be NULL") /* Get the default dataset transfer property list if the user didn't provide one */ - if(H5P_DEFAULT == dxpl_id) + if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; else - if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); - /* Retrieve the 'direct read' flag */ - if(H5CX_get_dcr_flag(&direct_read) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error getting flag for direct chunk read") - - /* Set up for direct read of chunk, bypassing filters, etc. */ - if(direct_read) { - hsize_t *direct_offset; /* Chunk offset from calling routine */ - hsize_t internal_offset[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - uint32_t direct_filters = 0; /* Filters for chunk */ - unsigned u; /* Local index variable */ - - /* Sanity check */ - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Get the direct chunk offset */ - if(H5CX_get_dcr_offset(&direct_offset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error getting offset for direct chunk read") - HDassert(direct_offset); - - /* The library's chunking code requires the offset terminates with a zero. So transfer the - * offset array to an internal offset array */ - for(u = 0; u < dset->shared->ndims; u++) { - /* Make sure the offset doesn't exceed the dataset's dimensions */ - if(direct_offset[u] > dset->shared->curr_dims[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset") - - /* Make sure the offset fall right on a chunk's boundary */ - if(direct_offset[u] % dset->shared->layout.u.chunk.dim[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary") - - internal_offset[u] = direct_offset[u]; - } /* end for */ - - /* Terminate the offset with a zero */ - internal_offset[dset->shared->ndims] = 0; - - /* Read the raw chunk */ - if(H5D__chunk_direct_read(dset, internal_offset, &direct_filters, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read chunk directly") - - /* Set the chunk filter mask for application */ - H5CX_set_dcr_filters(direct_filters); - } /* end if */ - else - /* Read raw data */ - if(H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if (H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Read the raw chunk */ + if (H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") done: FUNC_LEAVE_API(ret_value) -} /* end H5Dread() */ +} /* end H5Dread_chunk() */ /*------------------------------------------------------------------------- - * Function: H5Dwrite + * Function: H5Dwrite * - * Purpose: Writes (part of) a DSET from application memory BUF to the - * file. The part of the dataset to write is defined with the - * MEM_SPACE_ID and FILE_SPACE_ID arguments. The data points - * are converted from their current type (MEM_TYPE_ID) to their - * file datatype. Additional miscellaneous data transfer - * properties can be passed to this function with the - * PLIST_ID argument. + * Purpose: Writes (part of) a DSET from application memory BUF to the + * file. The part of the dataset to write is defined with the + * MEM_SPACE_ID and FILE_SPACE_ID arguments. The data points + * are converted from their current type (MEM_TYPE_ID) to their + * file datatype. Additional miscellaneous data transfer + * properties can be passed to this function with the + * PLIST_ID argument. * - * The FILE_SPACE_ID can be the constant H5S_ALL which indicates - * that the entire file dataspace is to be referenced. + * The FILE_SPACE_ID can be the constant H5S_ALL which indicates + * that the entire file dataspace is to be referenced. * - * The MEM_SPACE_ID can be the constant H5S_ALL in which case - * the memory dataspace is the same as the file dataspace - * defined when the dataset was created. + * The MEM_SPACE_ID can be the constant H5S_ALL in which case + * the memory dataspace is the same as the file dataspace + * defined when the dataset was created. * - * The number of elements in the memory dataspace must match - * the number of elements in the file dataspace. + * The number of elements in the memory dataspace must match + * the number of elements in the file dataspace. * - * The PLIST_ID can be the constant H5P_DEFAULT in which - * case the default data transfer properties are used. + * The PLIST_ID can be the constant H5P_DEFAULT in which + * case the default data transfer properties are used. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 + * Programmer: Robb Matzke + * Thursday, December 4, 1997 * *------------------------------------------------------------------------- */ @@ -249,61 +300,40 @@ herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, const void *buf) { - H5D_t *dset = NULL; + H5D_t *dset = NULL; const H5S_t *mem_space = NULL; const H5S_t *file_space = NULL; - hbool_t direct_write = FALSE; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiiii*x", dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf); - /* check arguments */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + /* Get dataset pointer and ensure it's associated with a file */ + if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID") + if (NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + + /* Get validated dataspace pointers */ + if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") + if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") /* Get the default dataset transfer property list if the user didn't provide one */ - if(H5P_DEFAULT == dxpl_id) + if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; else - if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); - /* Retrieve the 'direct write' flag */ - if(H5CX_get_dcw_flag(&direct_write) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error getting flag for direct chunk read") - - /* Check dataspace selections if this is not a direct write */ - if(!direct_write) { - if(mem_space_id < 0 || file_space_id < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - - if(H5S_ALL != mem_space_id) { - if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - - /* Check for valid selection */ - if(H5S_SELECT_VALID(mem_space) != TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "memory selection+offset not within extent") - } /* end if */ - if(H5S_ALL != file_space_id) { - if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - - /* Check for valid selection */ - if(H5S_SELECT_VALID(file_space) != TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "file selection+offset not within extent") - } /* end if */ - } /* end if */ - - if(H5D__pre_write(dset, direct_write, mem_type_id, mem_space, file_space, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't prepare for writing data") + /* Write the data */ + if (H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") done: FUNC_LEAVE_API(ret_value) @@ -311,70 +341,71 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__pre_write + * Function: H5Dwrite_chunk * - * Purpose: Preparation for writing data. + * Purpose: Writes an entire chunk to the file directly. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * 30 July 2012 * *------------------------------------------------------------------------- */ herr_t -H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id, - const H5S_t *mem_space, const H5S_t *file_space, const void *buf) +H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, + size_t data_size, const void *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset = NULL; + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + uint32_t data_size_32; /* Chunk data size (limited to 32-bits currently) */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "iiIu*hz*x", dset_id, dxpl_id, filters, offset, data_size, buf); + + /* Check arguments */ + if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset ID") + if (NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + if (!buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf cannot be NULL") + if (!offset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset cannot be NULL") + if (0 == data_size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "data_size cannot be zero") + + /* Make sure data size is less than 4 GiB */ + data_size_32 = (uint32_t)data_size; + if (data_size != (size_t)data_size_32) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid data_size - chunks cannot be > 4 GiB") - FUNC_ENTER_PACKAGE_VOL - - /* Direct chunk write */ - if(direct_write) { - uint32_t direct_filters; - hsize_t *direct_offset; - uint32_t direct_datasize; - hsize_t internal_offset[H5O_LAYOUT_NDIMS]; - unsigned u; /* Local index variable */ - - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Retrieve parameters for direct chunk write */ - if(H5CX_get_dcw_filters(&direct_filters) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error getting filter info for direct chunk write") - if(H5CX_get_dcw_offset(&direct_offset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error getting offset info for direct chunk write") - if(H5CX_get_dcw_datasize(&direct_datasize) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error getting data size for direct chunk write") - - /* The library's chunking code requires the offset terminates with a zero. So transfer the - * offset array to an internal offset array */ - for(u = 0; u < dset->shared->ndims; u++) { - /* Make sure the offset doesn't exceed the dataset's dimensions */ - if(direct_offset[u] > dset->shared->curr_dims[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset") - - /* Make sure the offset fall right on a chunk's boundary */ - if(direct_offset[u] % dset->shared->layout.u.chunk.dim[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary") - - internal_offset[u] = direct_offset[u]; - } /* end for */ - - /* Terminate the offset with a zero */ - internal_offset[dset->shared->ndims] = 0; - - /* write raw data */ - if(H5D__chunk_direct_write(dset, direct_filters, internal_offset, direct_datasize, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write chunk directly") - } /* end if */ + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; else - /* Normal write of raw data */ - if(H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") + if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if (H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Write chunk */ + if (H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") done: - FUNC_LEAVE_NOAPI_VOL(ret_value) -} /* end H5D__pre_write() */ + FUNC_LEAVE_API(ret_value) +} /* end H5Dwrite_chunk() */ /*------------------------------------------------------------------------- @@ -400,7 +431,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, hbool_t type_info_init = FALSE; /* Whether the datatype info has been initialized */ H5S_t * projected_mem_space = NULL; /* If not NULL, ptr to dataspace containing a */ /* projection of the supplied mem_space to a new */ - /* dataspace with rank equal to that of */ + /* dataspace with rank equal to that of */ /* file_space. */ /* */ /* This field is only used if */ @@ -428,7 +459,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, if(!mem_space) mem_space = file_space; if((snelmts = H5S_GET_SELECT_NPOINTS(mem_space)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dst dataspace has invalid selection") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dst dataspace has invalid selection") H5_CHECKED_ASSIGN(nelmts, hsize_t, snelmts, hssize_t); /* Set up datatype info for operation */ @@ -612,7 +643,7 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, hbool_t type_info_init = FALSE; /* Whether the datatype info has been initialized */ H5S_t * projected_mem_space = NULL; /* If not NULL, ptr to dataspace containing a */ /* projection of the supplied mem_space to a new */ - /* dataspace with rank equal to that of */ + /* dataspace with rank equal to that of */ /* file_space. */ /* */ /* This field is only used if */ @@ -645,7 +676,7 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* Check if we are allowed to write to this file */ if(0 == (H5F_INTENT(dataset->oloc.file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "no write intent on file") + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "no write intent on file") /* Set up datatype info for operation */ if(H5D__typeinfo_init(dataset, mem_type_id, TRUE, &type_info) < 0) @@ -691,12 +722,12 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, mem_space = file_space; if((snelmts = H5S_GET_SELECT_NPOINTS(mem_space)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") H5_CHECKED_ASSIGN(nelmts, hsize_t, snelmts, hssize_t); /* Make certain that the number of elements in each selection is the same */ if(nelmts != (hsize_t)H5S_GET_SELECT_NPOINTS(file_space)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest dataspaces have different number of elements selected") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest dataspaces have different number of elements selected") /* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */ if(NULL == buf) { @@ -934,7 +965,7 @@ H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, /* Get the memory & dataset datatypes */ if(NULL == (type_info->mem_type = (const H5T_t *)H5I_object_verify(mem_type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") type_info->dset_type = dset->shared->type; if(do_write) { @@ -959,11 +990,11 @@ H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, * turns off background preservation. */ if(NULL == (type_info->tpath = H5T_path_find(src_type, dst_type))) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatype") + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatype") /* Retrieve info from API context */ if(H5CX_get_data_transform(&data_transform) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data transform info") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data transform info") /* Precompute some useful information */ type_info->src_type_size = H5T_get_size(src_type); diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 126a3c0..b887b87 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -583,8 +583,6 @@ H5_DLL herr_t H5D__refresh(hid_t dset_id, H5D_t *dataset); H5_DLL herr_t H5D__format_convert(H5D_t *dataset); /* Internal I/O routines */ -H5_DLL herr_t H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id, - const H5S_t *mem_space, const H5S_t *file_space, const void *buf); H5_DLL herr_t H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, void *buf/*out*/); H5_DLL herr_t H5D__write(H5D_t *dataset, hid_t mem_type_id, diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 790674a..a1ccda0 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -35,17 +35,6 @@ /* Bit flags for the H5Pset_chunk_opts() and H5Pget_chunk_opts() */ #define H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS (0x0002u) -/* Property names for H5DOwrite_chunk */ -#define H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME "direct_chunk_flag" -#define H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME "direct_chunk_filters" -#define H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_NAME "direct_chunk_offset" -#define H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME "direct_chunk_datasize" - -/* Property names for H5DOread_chunk */ -#define H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME "direct_chunk_read_flag" -#define H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME "direct_chunk_read_offset" -#define H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME "direct_chunk_read_filters" - /*******************/ /* Public Typedefs */ /*******************/ @@ -157,6 +146,10 @@ H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf/*out*/); H5_DLL herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf); +H5_DLL herr_t H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, + const hsize_t *offset, size_t data_size, const void *buf); +H5_DLL herr_t H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, + const hsize_t *offset, uint32_t *filters, void *buf); H5_DLL herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op, void *operator_data); H5_DLL herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf); @@ -185,7 +178,19 @@ H5_DLL herr_t H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type); /* Macros */ #define H5D_CHUNK_BTREE H5D_CHUNK_IDX_BTREE - +/* Formerly used to support the H5DOread/write_chunk() API calls. + * These symbols are no longer used in the library. + */ +/* Property names for H5DOwrite_chunk */ +#define H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME "direct_chunk_flag" +#define H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME "direct_chunk_filters" +#define H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_NAME "direct_chunk_offset" +#define H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME "direct_chunk_datasize" +/* Property names for H5DOread_chunk */ +#define H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME "direct_chunk_read_flag" +#define H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME "direct_chunk_read_offset" +#define H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME "direct_chunk_read_filters" + /* Typedefs */ @@ -700,7 +700,7 @@ H5Freopen(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Get a new "top level" file struct, sharing the same "low level" file struct */ - if(NULL == (new_file = H5F_new(old_file->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) + if(NULL == (new_file = H5F__new(old_file->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") /* Duplicate old file's names */ @@ -1195,14 +1195,14 @@ H5FS_get_sect_count(const H5FS_t *frsp, hsize_t *tot_sect_count) * * Purpose: Verify that the free space manager is mostly sane * - * Return: SUCCEED (Can't fail) + * Return: void * * Programmer: Quincey Koziol * Jul 17 2006 * *------------------------------------------------------------------------- */ -herr_t +void H5FS__assert(const H5FS_t *fspace) { FUNC_ENTER_PACKAGE_NOERR @@ -1228,7 +1228,7 @@ HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", "H5FS__assert", fspace-> HDassert(fspace->serial_sect_count > 0 || fspace->ghost_sect_count == 0); #endif /* QAK */ - FUNC_LEAVE_NOAPI(SUCCEED) + FUNC_LEAVE_NOAPI_VOID } /* end H5FS__assert() */ #endif /* H5FS_DEBUG_ASSERT */ diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h index 23e1212..a5896ee 100644 --- a/src/H5FSpkg.h +++ b/src/H5FSpkg.h @@ -235,10 +235,10 @@ H5_DLL herr_t H5FS__hdr_dest(H5FS_t *hdr); H5_DLL herr_t H5FS_sinfo_dest(H5FS_sinfo_t *sinfo); /* Sanity check routines */ -#ifdef H5FS_DEBUG -H5_DLL herr_t H5FS__assert(const H5FS_t *fspace); -H5_DLL herr_t H5FS__sect_assert(const H5FS_t *fspace); -#endif /* H5FS_DEBUG */ +#ifdef H5FS_DEBUG_ASSERT +H5_DLL void H5FS__assert(const H5FS_t *fspace); +H5_DLL void H5FS__sect_assert(const H5FS_t *fspace); +#endif /* H5FS_DEBUG_ASSERT */ /* Testing routines */ #ifdef H5FS_TESTING diff --git a/src/H5FSsection.c b/src/H5FSsection.c index f0d9f47..11cd722 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -2197,14 +2197,14 @@ done: * * Purpose: Verify that the sections managed are mostly sane * - * Return: SUCCEED/FAIL + * Return: void * * Programmer: Quincey Koziol * Jul 17 2006 * *------------------------------------------------------------------------- */ -herr_t +void H5FS__sect_assert(const H5FS_t *fspace) { hsize_t separate_obj; /* The number of separate objects managed */ @@ -2256,7 +2256,7 @@ HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", "H5FS__sect_assert", fsp size_t size_ghost_count; /* # of ghost sections of this size */ /* Get section size node */ - fspace_node = H5SL_item(curr_size_node); + fspace_node = (H5FS_node_t *)H5SL_item(curr_size_node); /* Check sections on list */ curr_sect_node = H5SL_first(fspace_node->sect_list); @@ -2267,7 +2267,7 @@ HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", "H5FS__sect_assert", fsp H5FS_section_info_t *sect; /* Section */ /* Get section node & it's class */ - sect = H5SL_item(curr_sect_node); + sect = (H5FS_section_info_t *)H5SL_item(curr_sect_node); cls = &fspace->sect_cls[sect->type]; #ifdef QAK HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H5FS__sect_assert", sect->size, sect->addr, sect->type); @@ -2337,7 +2337,7 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a, sect->type = %u\n", "H if(fspace->sinfo->merge_list) HDassert(fspace->tot_sect_count == (separate_obj + H5SL_count(fspace->sinfo->merge_list))); - FUNC_LEAVE_NOAPI(SUCCEED) + FUNC_LEAVE_NOAPI_VOID } /* end H5FS__sect_assert() */ #endif /* H5FS_DEBUG_ASSERT */ diff --git a/src/H5Fefc.c b/src/H5Fefc.c index 487ed2f..07bb644 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -73,7 +73,7 @@ H5FL_DEFINE_STATIC(H5F_efc_t); /*------------------------------------------------------------------------- - * Function: H5F_efc_create + * Function: H5F__efc_create * * Purpose: Allocate and initialize a new external file cache object, * which can the be used to cache open external files. @@ -88,12 +88,12 @@ H5FL_DEFINE_STATIC(H5F_efc_t); *------------------------------------------------------------------------- */ H5F_efc_t * -H5F_efc_create(unsigned max_nfiles) +H5F__efc_create(unsigned max_nfiles) { H5F_efc_t *efc = NULL; /* EFC object */ H5F_efc_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_PACKAGE /* Sanity checks */ HDassert(max_nfiles > 0); @@ -116,7 +116,7 @@ done: efc = H5FL_FREE(H5F_efc_t, efc); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_efc_create() */ +} /* end H5F__efc_create() */ /*------------------------------------------------------------------------- @@ -139,8 +139,7 @@ done: *------------------------------------------------------------------------- */ H5F_t * -H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id) +H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { H5F_efc_t *efc = NULL; /* External file cache for parent file */ H5F_efc_ent_t *ent = NULL; /* Entry for target file in efc */ @@ -376,7 +375,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_efc_max_nfiles + * Function: H5F__efc_max_nfiles * * Purpose: Returns the maximum number of files in the provided * external file cache. @@ -389,15 +388,15 @@ done: *------------------------------------------------------------------------- */ unsigned -H5F_efc_max_nfiles(H5F_efc_t *efc) +H5F__efc_max_nfiles(H5F_efc_t *efc) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR HDassert(efc); HDassert(efc->max_nfiles > 0); FUNC_LEAVE_NOAPI(efc->max_nfiles) -} /* end H5F_efc_max_nfiles */ +} /* end H5F__efc_max_nfiles */ /*------------------------------------------------------------------------- @@ -793,7 +792,7 @@ H5F__efc_try_close_tag2(H5F_file_t *sf, H5F_file_t **tail) * uncloseable file would be closed. * * The final pass exploits the H5F__efc_release_real()-> - * H5F_efc_remove_ent()->H5F_try_close()->H5F__efc_try_close() + * H5F__efc_remove_ent()->H5F_try_close()->H5F__efc_try_close() * calling chain to recursively close the tree, but only the * files that are still marked as closeable. All files * marked as closeable have their EFCs released, and will @@ -819,7 +818,7 @@ H5F__efc_try_close(H5F_t *f) H5F_file_t *next; /* Temporary file pointer */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Sanity checks */ HDassert(f); @@ -852,7 +851,7 @@ H5F__efc_try_close(H5F_t *f) /* If there are references that are not from an EFC or f, it will never * be possible to close the file. Just return. Note that this holds true * for the case that this file is being closed through H5F__efc_release_real() - * because that function (through H5F_efc_remove_ent()) decrements the EFC + * because that function (through H5F__efc_remove_ent()) decrements the EFC * reference count before it calls H5F_try_close(). This may occur if this * function is reentered. */ /* If the tag is H5F_EFC_TAG_DONTCLOSE, then we have definitely reentered diff --git a/src/H5Fint.c b/src/H5Fint.c index 49538f4..abc638a 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -21,22 +21,22 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tprivate.h" /* Datatypes */ /****************/ @@ -74,11 +74,9 @@ typedef struct H5F_olist_t { /********************/ static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); -static herr_t H5F__build_name(const char *prefix, const char *file_name, - char **full_name/*out*/); +static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/); static char *H5F__getenv_prefix_name(char **env_prefix/*in,out*/); -static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, - const char *name, char ** /*out*/ actual_name);/* Declare a free list to manage the H5F_t struct */ +static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char ** /*out*/ actual_name); static herr_t H5F__flush_phase1(H5F_t *f); static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing); @@ -175,7 +173,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object flush callback") if(f->shared->efc) - efc_size = H5F_efc_max_nfiles(f->shared->efc); + efc_size = H5F__efc_max_nfiles(f->shared->efc); if(H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set elink file cache size") if(f->shared->page_buf != NULL) { @@ -486,11 +484,12 @@ done: /*-------------------------------------------------------------------------- - * Function: H5F__build_name + * Function: H5F__build_name * - * Purpose: Prepend PREFIX to FILE_NAME and store in FULL_NAME + * Purpose: Prepend PREFIX to FILE_NAME and store in FULL_NAME + * + * Return: SUCCEED/FAIL * - * Return: Non-negative on success/Negative on failure *--------------------------------------------------------------------------*/ static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/) @@ -510,7 +509,7 @@ H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out /* Compose the full file name */ HDsnprintf(*full_name, (prefix_len + fname_len + 2), "%s%s%s", prefix, - (H5_CHECK_DELIMITER(prefix[prefix_len - 1]) ? "" : H5_DIR_SEPS), file_name); + ((prefix_len == 0 || H5_CHECK_DELIMITER(prefix[prefix_len - 1])) ? "" : H5_DIR_SEPS), file_name); done: FUNC_LEAVE_NOAPI(ret_value) @@ -818,34 +817,37 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_new + * Function: H5F__new * - * Purpose: Creates a new file object and initializes it. The - * H5Fopen and H5Fcreate functions then fill in various fields. - * If SHARED is a non-null pointer then the shared info - * to which it points has the reference count incremented. - * Otherwise a new, empty shared info struct is created and - * initialized with the specified file access property list. + * Purpose: Creates a new file object and initializes it. The + * H5Fopen and H5Fcreate functions then fill in various fields. + * If SHARED is a non-null pointer then the shared info + * to which it points has the reference count incremented. + * Otherwise a new, empty shared info struct is created and + * initialized with the specified file access property list. + * + * Return: Success: Pointer to a new file struct + * + * Failure: NULL * - * Return: Success: Ptr to a new file struct. - * Failure: NULL *------------------------------------------------------------------------- */ H5F_t * -H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) +H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) { - H5F_t *f = NULL, *ret_value = NULL; + H5F_t *f = NULL; + H5F_t *ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE if(NULL == (f = H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") - f->file_id = -1; + f->file_id = H5I_INVALID_HID; if(shared) { HDassert(lf == NULL); f->shared = shared; - } /* end if */ + } else { H5P_genplist_t *plist; /* Property list */ unsigned efc_size; /* External file cache size */ @@ -866,7 +868,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t f->shared->fs_state[u] = H5F_FS_STATE_CLOSED; f->shared->fs_addr[u] = HADDR_UNDEF; f->shared->fs_man[u] = NULL; - } /* end for */ + } f->shared->first_alloc_dealloc = FALSE; f->shared->eoa_pre_fsm_fsalloc = HADDR_UNDEF; f->shared->eoa_post_fsm_fsalloc = HADDR_UNDEF; @@ -878,9 +880,8 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t /* intialize point of no return */ f->shared->point_of_no_return = FALSE; - /* - * Copy the file creation and file access property lists into the - * new file handle. We do this early because some values might need + /* Copy the file creation and file access property lists into the + * new file handle. We do this early because some values might need * to change as the file is being opened. */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fcpl_id))) @@ -906,7 +907,8 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); /* Temporary for multi/split drivers: fail file creation - when persisting free-space or using paged aggregation strategy */ + * when persisting free-space or using paged aggregation strategy. + */ if(H5F_HAS_FEATURE(f, H5FD_FEAT_PAGED_AGGR)) if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE || f->shared->fs_persist) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't open with this strategy or persistent fs") @@ -947,7 +949,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t if(H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get elink file cache size") if(efc_size > 0) - if(NULL == (f->shared->efc = H5F_efc_create(efc_size))) + if(NULL == (f->shared->efc = H5F__efc_create(efc_size))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't create external file cache") #ifdef H5_HAVE_PARALLEL if(H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &(f->coll_md_read)) < 0) @@ -1000,12 +1002,12 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t f->shared->feature_flags &= ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA; if(H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set feature_flags in VFD") - } /* end if */ + } else { /* If no value for read attempts has been set, use the default */ if(!f->shared->read_attempts) f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS; - } /* end else */ + } /* Determine the # of bins for metdata read retries */ if(H5F_set_retries(f) < 0) @@ -1031,8 +1033,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t if(H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get object flush cb info") - /* - * Create a metadata cache with the specified number of elements. + /* Create a metadata cache with the specified number of elements. * The cache might be created with a different number of elements and * the access property list should be updated to reflect that. */ @@ -1069,12 +1070,12 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list") f->shared = H5FL_FREE(H5F_file_t, f->shared); - } /* end if */ + } f = H5FL_FREE(H5F_t, f); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_new() */ +} /* end H5F__new() */ /*------------------------------------------------------------------------- @@ -1343,8 +1344,8 @@ H5F__dest(H5F_t *f, hbool_t flush) * Return: Success: Non-NULL, pointer to new file object. * Failure: NULL * - * Programmer: Quincey Koziol - * December 13, 2017 + * Programmer: Quincey Koziol + * December 13, 2017 * *------------------------------------------------------------------------- */ @@ -1379,8 +1380,8 @@ done: * Return: Success: Non-NULL, pointer to new file object. * Failure: NULL * - * Programmer: Quincey Koziol - * December 13, 2017 + * Programmer: Quincey Koziol + * December 13, 2017 * *------------------------------------------------------------------------- */ @@ -1587,7 +1588,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "SWMR read access flag not the same for file that is already open") /* Allocate new "high-level" file struct */ - if((file = H5F_new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) + if((file = H5F__new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") } /* end if */ else { @@ -1615,7 +1616,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) } /* end if */ /* Create the 'top' file structure */ - if(NULL == (file = H5F_new(NULL, flags, fcpl_id, fapl_id, lf))) { + if(NULL == (file = H5F__new(NULL, flags, fcpl_id, fapl_id, lf))) { /* If this is the only time the file has been opened and the struct * returned is NULL, H5FD_close() will never be called via H5F_dest() * so we have to close lf here before heading to the error handling. @@ -1881,8 +1882,8 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing) #ifdef H5_HAVE_PARALLEL if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) - /* Since we just returned from a call to H5AC_flush(), we just - * passed through a barrier. Hence we can skip the barrier on + /* Since we just returned from a call to H5AC_flush(), we just + * passed through a barrier. Hence we can skip the barrier on * entry to the mpio file driver truncate call below, and the first * barrier in the following call to flush the cache again. */ @@ -1967,8 +1968,8 @@ H5F__flush_real(H5F_t *f) * * Return: Non-negative on success / Negative on failure * - * Programmer: Quincey Koziol - * December 13, 2017 + * Programmer: Quincey Koziol + * December 13, 2017 * *------------------------------------------------------------------------- */ @@ -2085,7 +2086,7 @@ H5F__close_cb(H5F_t *f) unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F_mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* If there are no other file IDs open on this file/mount hier., but @@ -2150,7 +2151,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) } /* end if */ /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F_mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* @@ -2792,19 +2793,19 @@ H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high) * metadata entry class changes when the file format low / high * bounds are changed and an unwritten entry of that class is * sitting in the metadata cache. - * + * * If that happens, it's possible that the entry's size could * become larger, potentially corrupting the file (if the larger * entry is fully written, overwriting data outside its allocated * space), or corrupting the entry (if the entry is truncated to * fit into the allocated space). - * + * * Although I'm not aware of any metadata with this behavior * currently, it would be very difficult to guard against and / or * detect, but if we flush everything here, the format version * for metadata entries in the cache will be finalized and these * sorts of problems can be avoided. - * + * * QAK - April, 2018 */ if(H5F__flush_real(f) < 0) @@ -3635,7 +3636,7 @@ done: herr_t H5F__format_convert(H5F_t *f) { - hbool_t mark_dirty = FALSE; /* Whether to mark the file's superblock dirty */ + hbool_t mark_dirty = FALSE; /* Whether to mark the file's superblock dirty */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_VOL @@ -3646,39 +3647,39 @@ H5F__format_convert(H5F_t *f) /* Check if the superblock should be downgraded */ if(f->shared->sblock->super_vers > HDF5_SUPERBLOCK_VERSION_V18_LATEST) { - f->shared->sblock->super_vers = HDF5_SUPERBLOCK_VERSION_V18_LATEST; - mark_dirty = TRUE; + f->shared->sblock->super_vers = HDF5_SUPERBLOCK_VERSION_V18_LATEST; + mark_dirty = TRUE; } /* end if */ /* Check for persistent freespace manager, which needs to be downgraded */ if(!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && - f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && - f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && - f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) { - /* Check to remove free-space manager info message from superblock extension */ - if(H5F_addr_defined(f->shared->sblock->ext_addr)) - if(H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in removing message from superblock extension") - - /* Close freespace manager */ - if(H5MF_try_close(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to free free-space address") - - /* Set non-persistent freespace manager */ - f->shared->fs_strategy = H5F_FILE_SPACE_STRATEGY_DEF; - f->shared->fs_persist = H5F_FREE_SPACE_PERSIST_DEF; - f->shared->fs_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; - f->shared->fs_page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; - - /* Indicate that the superblock should be marked dirty */ - mark_dirty = TRUE; + f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && + f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && + f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) { + /* Check to remove free-space manager info message from superblock extension */ + if(H5F_addr_defined(f->shared->sblock->ext_addr)) + if(H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in removing message from superblock extension") + + /* Close freespace manager */ + if(H5MF_try_close(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to free free-space address") + + /* Set non-persistent freespace manager */ + f->shared->fs_strategy = H5F_FILE_SPACE_STRATEGY_DEF; + f->shared->fs_persist = H5F_FREE_SPACE_PERSIST_DEF; + f->shared->fs_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; + f->shared->fs_page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; + + /* Indicate that the superblock should be marked dirty */ + mark_dirty = TRUE; } /* end if */ /* Check if we should mark the superblock dirty */ if(mark_dirty) - /* Mark superblock as dirty */ - if(H5F_super_dirty(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") + /* Mark superblock as dirty */ + if(H5F_super_dirty(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") done: FUNC_LEAVE_NOAPI_VOL(ret_value) diff --git a/src/H5Fmount.c b/src/H5Fmount.c index e3a92fd..4cd1edf 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -15,21 +15,18 @@ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* PRIVATE PROTOTYPES */ -static herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, - hid_t plist_id); -static herr_t H5F__unmount(H5G_loc_t *loc, const char *name); -static void H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); +static void H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); /*------------------------------------------------------------------------- @@ -47,16 +44,17 @@ static void H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigne herr_t H5F__close_mounts(H5F_t *f) { - unsigned u; /* Local index */ - herr_t ret_value=SUCCEED; /* Return value */ + unsigned u; /* Local index */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE HDassert(f); /* Unmount all child files. Loop backwards to avoid having to adjust u when * a file is unmounted. Note that we rely on unsigned u "wrapping around" - * to terminate the loop. */ + * to terminate the loop. + */ for (u = f->shared->mtab.nmounts - 1; u < f->shared->mtab.nmounts; u--) { /* Only unmount children mounted to this top level file structure */ if(f->shared->mtab.child[u].file->parent == f) { @@ -77,7 +75,7 @@ H5F__close_mounts(H5F_t *f) f->shared->mtab.nmounts--; f->nmounts--; } - } /* end if */ + } HDassert(f->nmounts == 0); @@ -100,7 +98,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED plist_id) { H5G_t *mount_point = NULL; /*mount point group */ @@ -112,9 +110,9 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED H5G_name_t mp_path; /* Mount point group hier. path */ H5O_loc_t mp_oloc; /* Mount point object location */ H5G_loc_t root_loc; /* Group location of root of file to mount */ - herr_t ret_value = SUCCEED; /*return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_VOL + FUNC_ENTER_PACKAGE_VOL HDassert(loc); HDassert(name && *name); @@ -162,9 +160,9 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED mp_loc.path = H5G_nameof(mount_point); HDassert(mp_loc.path); for(ancestor = parent; ancestor; ancestor = ancestor->parent) { - if(ancestor->shared == child->shared) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") - } /* end for */ + if(ancestor->shared == child->shared) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") + } /* Make certain that the parent & child files have the same "file close degree" */ if(parent->shared->fc_degree != child->shared->fc_degree) @@ -181,29 +179,29 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED while(lt < rt && cmp) { H5O_loc_t *oloc; /*temporary symbol table entry */ - md = (lt + rt) / 2; - oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(mp_loc.oloc->addr, oloc->addr); - if(cmp < 0) - rt = md; - else if(cmp > 0) - lt = md + 1; - } /* end while */ + md = (lt + rt) / 2; + oloc = H5G_oloc(parent->shared->mtab.child[md].group); + cmp = H5F_addr_cmp(mp_loc.oloc->addr, oloc->addr); + if(cmp < 0) + rt = md; + else if(cmp > 0) + lt = md + 1; + } if(cmp > 0) md++; if(!cmp) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") /* Make room in the table */ if(parent->shared->mtab.nmounts >= parent->shared->mtab.nalloc) { - unsigned n = MAX(16, 2 * parent->shared->mtab.nalloc); - H5F_mount_t *x = (H5F_mount_t *)H5MM_realloc(parent->shared->mtab.child, n * sizeof(parent->shared->mtab.child[0])); + unsigned n = MAX(16, 2 * parent->shared->mtab.nalloc); + H5F_mount_t *x = (H5F_mount_t *)H5MM_realloc(parent->shared->mtab.child, n * sizeof(parent->shared->mtab.child[0])); - if(!x) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") - parent->shared->mtab.child = x; - parent->shared->mtab.nalloc = n; - } /* end if */ + if(!x) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") + parent->shared->mtab.child = x; + parent->shared->mtab.nalloc = n; + } /* Insert into table */ HDmemmove(parent->shared->mtab.child + md + 1, parent->shared->mtab.child + md, @@ -228,19 +226,19 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED /* We pass H5G_UNKNOWN as object type; search all IDs */ if(H5G_name_replace(NULL, H5G_NAME_MOUNT, mp_loc.oloc->file, mp_loc.path->full_path_r, root_loc.oloc->file, root_loc.path->full_path_r) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") done: if(ret_value < 0) { if(mount_point) { if(H5G_close(mount_point) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close mounted group") - } /* end if */ + } else { if(H5G_loc_free(&mp_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free mount location") - } /* end else */ - } /* end if */ + } + } FUNC_LEAVE_NOAPI_VOL(ret_value) } /* end H5F__mount() */ @@ -264,7 +262,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F__unmount(H5G_loc_t *loc, const char *name) { H5G_t *child_group = NULL; /* Child's group in parent mtab */ @@ -279,7 +277,7 @@ H5F__unmount(H5G_loc_t *loc, const char *name) int child_idx; /* Index of child in parent's mtab */ herr_t ret_value = SUCCEED; /*return value */ - FUNC_ENTER_STATIC_VOL + FUNC_ENTER_PACKAGE_VOL HDassert(loc); HDassert(name && *name); @@ -304,41 +302,43 @@ H5F__unmount(H5G_loc_t *loc, const char *name) if(child->parent && H5F_addr_eq(mp_oloc.addr, mnt_oloc->addr)) { unsigned u; /*counters */ - /* - * We've been given the root group of the child. We do a reverse - * lookup in the parent's mount table to find the correct entry. - */ - parent = child->parent; - for(u = 0; u < parent->shared->mtab.nmounts; u++) { - if(parent->shared->mtab.child[u].file->shared == child->shared) { + /* + * We've been given the root group of the child. We do a reverse + * lookup in the parent's mount table to find the correct entry. + */ + parent = child->parent; + for(u = 0; u < parent->shared->mtab.nmounts; u++) { + if(parent->shared->mtab.child[u].file->shared == child->shared) { /* Found the correct index */ child_idx = (int)u; break; - } /* end if */ - } /* end for */ - } else { + } + } + } + else { unsigned lt, rt, md = 0; /*binary search indices */ int cmp; /*binary search comparison value*/ - /* - * We've been given the mount point in the parent. We use a binary - * search in the parent to locate the mounted file, if any. - */ - parent = child; /*we guessed wrong*/ - lt = 0; - rt = parent->shared->mtab.nmounts; - cmp = -1; - while(lt < rt && cmp) { - md = (lt + rt) / 2; - mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(mp_oloc.addr, mnt_oloc->addr); - if (cmp<0) - rt = md; - else - lt = md + 1; - } /* end while */ - if(cmp) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") + /* We've been given the mount point in the parent. We use a binary + * search in the parent to locate the mounted file, if any. + */ + parent = child; /*we guessed wrong*/ + lt = 0; + rt = parent->shared->mtab.nmounts; + cmp = -1; + + while(lt < rt && cmp) { + md = (lt + rt) / 2; + mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); + cmp = H5F_addr_cmp(mp_oloc.addr, mnt_oloc->addr); + if (cmp<0) + rt = md; + else + lt = md + 1; + } + + if(cmp) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") /* Found the correct index, set the info about the child */ child_idx = (int)md; @@ -426,48 +426,59 @@ H5F_is_mount(const H5F_t *file) /*------------------------------------------------------------------------- - * Function: H5Fmount + * Function: H5Fmount * - * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and - * NAME using mount properties PLIST_ID. + * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and + * NAME using mount properties PLIST_ID. * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Tuesday, October 6, 1998 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) { - H5G_loc_t loc; - H5F_t *child = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Parent location */ + H5F_t *child = NULL; /* Child object */ + H5I_type_t loc_type; /* ID type of location */ + H5I_type_t child_type; /* ID type of child */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + loc_type = H5I_get_type(loc_id); + if(H5I_FILE != loc_type && H5I_GROUP != loc_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") + if(!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if(!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") + child_type = H5I_get_type(child_id); + if(H5I_FILE != child_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "child_id parameter not a file ID") if(H5P_DEFAULT == plist_id) plist_id = H5P_FILE_MOUNT_DEFAULT; else if(TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "plist_id is not a property list ID") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Do the mount */ + /* Get the location object */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") + + /* Get the child object */ + if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get child object") + + /* Perform the mount operation */ if(H5F__mount(&loc, name, child, plist_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: FUNC_LEAVE_API(ret_value) @@ -475,46 +486,51 @@ done: /*------------------------------------------------------------------------- - * Function: H5Funmount - * - * Purpose: Given a mount point, dissassociate the mount point's file - * from the file mounted there. Do not close either file. + * Function: H5Funmount * - * The mount point can either be the group in the parent or the - * root group of the mounted file (both groups have the same - * name). If the mount point was opened before the mount then - * it's the group in the parent, but if it was opened after the - * mount then it's the root group of the child. + * Purpose: Given a mount point, dissassociate the mount point's file + * from the file mounted there. Do not close either file. * - * Return: Non-negative on success/Negative on failure + * The mount point can either be the group in the parent or the + * root group of the mounted file (both groups have the same + * name). If the mount point was opened before the mount then + * it's the group in the parent, but if it was opened after the + * mount then it's the root group of the child. * - * Programmer: Robb Matzke - * Tuesday, October 6, 1998 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t H5Funmount(hid_t loc_id, const char *name) { - H5G_loc_t loc; - herr_t ret_value=SUCCEED; /* Return value */ + H5G_loc_t loc; /* Parent location */ + H5I_type_t loc_type; /* ID type of location */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + /* Check arguments */ + loc_type = H5I_get_type(loc_id); + if(H5I_FILE != loc_type && H5I_GROUP != loc_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") + if(!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if(!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Unmount */ + /* Get the location object */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") + + /* Perform the unmount operation */ if(H5F__unmount(&loc, name) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: FUNC_LEAVE_API(ret_value) @@ -522,12 +538,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_mount_count_ids_recurse + * Function: H5F__mount_count_ids_recurse * - * Purpose: Helper routine for counting number of open IDs in mount + * Purpose: Helper routine for counting number of open IDs in mount * hierarchy. * - * Return: <none> + * Return: void * * Programmer: Quincey Koziol * Tuesday, July 19, 2005 @@ -535,11 +551,11 @@ done: *------------------------------------------------------------------------- */ static void -H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) +H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) { unsigned u; /* Local index value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(f); @@ -564,20 +580,20 @@ H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_obj if(H5G_get_shared_count(f->shared->mtab.child[u].group) > 1) *nopen_objs += 1; - H5F_mount_count_ids_recurse(f->shared->mtab.child[u].file, nopen_files, nopen_objs); + H5F__mount_count_ids_recurse(f->shared->mtab.child[u].file, nopen_files, nopen_objs); } - } /* end for */ + } FUNC_LEAVE_NOAPI_VOID -} /* end H5F_mount_count_ids_recurse() */ +} /* end H5F__mount_count_ids_recurse() */ /*------------------------------------------------------------------------- - * Function: H5F_mount_count_ids + * Function: H5F__mount_count_ids * - * Purpose: Count the number of open file & object IDs in a mount hierarchy + * Purpose: Count the number of open file & object IDs in a mount hierarchy * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Tues, July 19, 2005 @@ -585,9 +601,9 @@ H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_obj *------------------------------------------------------------------------- */ herr_t -H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) +H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(f); @@ -599,10 +615,10 @@ H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) f = f->parent; /* Count open IDs in the hierarchy */ - H5F_mount_count_ids_recurse(f, nopen_files, nopen_objs); + H5F__mount_count_ids_recurse(f, nopen_files, nopen_objs); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5F_mount_count_ids() */ +} /* end H5F__mount_count_ids() */ /*------------------------------------------------------------------------- @@ -648,11 +664,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_flush_mounts + * Function: H5F_flush_mounts * - * Purpose: Flush a mount hierarchy + * Purpose: Flush a mount hierarchy * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Fri, August 21, 2009 @@ -715,22 +731,22 @@ H5F_traverse_mount(H5O_loc_t *oloc/*in,out*/) * of file2, which is mounted somewhere in file3. */ do { - /* - * Use a binary search to find the potential mount point in the mount - * table for the parent - */ - lt = 0; - rt = parent->shared->mtab.nmounts; - cmp = -1; - while(lt < rt && cmp) { - md = (lt + rt) / 2; - mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(oloc->addr, mnt_oloc->addr); - if(cmp < 0) - rt = md; - else - lt = md + 1; - } /* end while */ + /* + * Use a binary search to find the potential mount point in the mount + * table for the parent + */ + lt = 0; + rt = parent->shared->mtab.nmounts; + cmp = -1; + while(lt < rt && cmp) { + md = (lt + rt) / 2; + mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); + cmp = H5F_addr_cmp(oloc->addr, mnt_oloc->addr); + if(cmp < 0) + rt = md; + else + lt = md + 1; + } /* Copy root info over to ENT */ if(0 == cmp) { diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 050e426..f815005 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -30,18 +30,18 @@ #include "H5Fprivate.h" /* Other public headers needed by this file */ -#include "H5Bpublic.h" /* B-tree header, for H5B_NUM_BTREE_ID */ +#include "H5Bpublic.h" /* B-tree header, for H5B_NUM_BTREE_ID */ /* Other private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5FSprivate.h" /* File free space */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object header messages */ -#include "H5PBprivate.h" /* Page buffer */ -#include "H5UCprivate.h" /* Reference counted object functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5FSprivate.h" /* File free space */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object header messages */ +#include "H5PBprivate.h" /* Page buffer */ +#include "H5UCprivate.h" /* Reference counted object functions */ /* @@ -394,13 +394,10 @@ H5FL_EXTERN(H5F_file_t); /******************************/ /* General routines */ -H5F_t *H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, - hid_t fapl_id, H5FD_t *lf); +H5_DLL H5F_t *H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); H5_DLL herr_t H5F__dest(H5F_t *f, hbool_t flush); -H5_DLL H5F_t *H5F__create(const char *filename, unsigned flags, hid_t fcpl_id, - hid_t fapl_id); -H5_DLL H5F_t * H5F__open(const char *filename, unsigned flags, hid_t fcpl_id, - hid_t fapl_id); +H5_DLL H5F_t *H5F__create(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +H5_DLL H5F_t *H5F__open(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5F__flush(H5F_t *f, H5F_scope_t scope); H5_DLL herr_t H5F__flush_real(H5F_t *f); H5_DLL htri_t H5F__is_hdf5(const char *name); @@ -408,8 +405,7 @@ H5_DLL herr_t H5F_get_objects(const H5F_t *f, unsigned types, size_t max_index, H5_DLL herr_t H5F__get_freespace(H5F_t *f, hsize_t *tot_space); H5_DLL ssize_t H5F__get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len); H5_DLL herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo); -H5_DLL ssize_t H5F__get_free_sections(H5F_t *f, H5FD_mem_t type, - size_t nsects, H5F_sect_info_t *sect_info); +H5_DLL ssize_t H5F__get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info); H5_DLL herr_t H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info); H5_DLL herr_t H5F__format_convert(H5F_t *f); H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); @@ -418,9 +414,10 @@ H5_DLL herr_t H5F__close_cb(H5F_t *f); H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); /* File mount related routines */ +H5_DLL herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id); +H5_DLL herr_t H5F__unmount(H5G_loc_t *loc, const char *name); H5_DLL herr_t H5F__close_mounts(H5F_t *f); -H5_DLL int H5F_term_unmount_cb(void *obj_ptr, hid_t obj_id, void *key); -H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); +H5_DLL herr_t H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); /* Superblock related routines */ H5_DLL herr_t H5F__super_init(H5F_t *f); @@ -430,18 +427,14 @@ H5_DLL herr_t H5F__super_free(H5F_super_t *sblock); /* Superblock extension related routines */ H5_DLL herr_t H5F_super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr); -H5_DLL herr_t H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, - hbool_t may_create, unsigned mesg_flags); +H5_DLL herr_t H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, hbool_t may_create, unsigned mesg_flags); H5_DLL herr_t H5F__super_ext_remove_msg(H5F_t *f, unsigned id); H5_DLL herr_t H5F__super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hbool_t was_created); /* Metadata accumulator routines */ -H5_DLL herr_t H5F__accum_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, - size_t size, void *buf); -H5_DLL herr_t H5F__accum_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, - size_t size, const void *buf); -H5_DLL herr_t H5F__accum_free(H5F_t *f, H5FD_mem_t type, haddr_t addr, - hsize_t size); +H5_DLL herr_t H5F__accum_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf); +H5_DLL herr_t H5F__accum_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); +H5_DLL herr_t H5F__accum_free(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size); H5_DLL herr_t H5F__accum_flush(H5F_t *f); H5_DLL herr_t H5F__accum_reset(H5F_t *f, hbool_t flush); @@ -451,10 +444,9 @@ H5_DLL H5F_file_t * H5F_sfile_search(H5FD_t *lf); H5_DLL herr_t H5F_sfile_remove(H5F_file_t *shared); /* External file cache routines */ -H5_DLL H5F_efc_t *H5F_efc_create(unsigned max_nfiles); -H5_DLL H5F_t *H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, - hid_t fcpl_id, hid_t fapl_id); -H5_DLL unsigned H5F_efc_max_nfiles(H5F_efc_t *efc); +H5_DLL H5F_efc_t *H5F__efc_create(unsigned max_nfiles); +H5_DLL H5F_t *H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +H5_DLL unsigned H5F__efc_max_nfiles(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_release(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_destroy(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_try_close(H5F_t *f); @@ -462,8 +454,7 @@ H5_DLL herr_t H5F__efc_try_close(H5F_t *f); /* Space allocation routines */ H5_DLL haddr_t H5F__alloc(H5F_t *f, H5F_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size); H5_DLL herr_t H5F__free(H5F_t *f, H5F_mem_t type, haddr_t addr, hsize_t size); -H5_DLL htri_t H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, - hsize_t extra_requested); +H5_DLL htri_t H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested); /* Functions that get/retrieve values from VFD layer */ H5_DLL herr_t H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr); @@ -476,8 +467,7 @@ H5_DLL herr_t H5F__evict_cache_entries(H5F_t *f); /* Testing functions */ #ifdef H5F_TESTING -H5_DLL herr_t H5F_get_sohm_mesg_count_test(hid_t fid, unsigned type_id, - size_t *mesg_count); +H5_DLL herr_t H5F_get_sohm_mesg_count_test(hid_t fid, unsigned type_id, size_t *mesg_count); H5_DLL herr_t H5F_check_cached_stab_test(hid_t file_id); H5_DLL herr_t H5F_get_maxaddr_test(hid_t file_id, haddr_t *maxaddr); H5_DLL herr_t H5F_get_sbe_addr_test(hid_t file_id, haddr_t *sbe_addr); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 3e77700..f06d4d0 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -296,7 +296,7 @@ typedef struct H5F_t H5F_t; #define H5F_BASE_ADDR(F) ((F)->shared->sblock->base_addr) #define H5F_SYM_LEAF_K(F) ((F)->shared->sblock->sym_leaf_k) #define H5F_KVALUE(F,T) ((F)->shared->sblock->btree_k[(T)->id]) -#define H5F_NREFS(F) ((F)->shared->nrefs) +#define H5F_NREFS(F) ((F)->shared->nrefs) #define H5F_SIZEOF_ADDR(F) ((F)->shared->sizeof_addr) #define H5F_SIZEOF_SIZE(F) ((F)->shared->sizeof_size) #define H5F_SOHM_ADDR(F) ((F)->shared->sohm_addr) @@ -713,8 +713,7 @@ typedef enum H5F_prefix_open_t { /***************************************/ /* Private functions */ -H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id); +H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed/*out*/); H5_DLL herr_t H5F_start_swmr_write(H5F_t *file); @@ -795,10 +794,8 @@ H5_DLL herr_t H5F_traverse_mount(struct H5O_loc_t *oloc/*in,out*/); H5_DLL herr_t H5F_flush_mounts(H5F_t *f); /* Functions that operate on blocks of bytes wrt super block */ -H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, - size_t size, void *buf/*out*/); -H5_DLL herr_t H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, - size_t size, const void *buf); +H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/); +H5_DLL herr_t H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); /* Functions that flush or evict */ H5_DLL herr_t H5F_flush_tagged_metadata(H5F_t *f, haddr_t tag); @@ -851,8 +848,7 @@ H5_DLL H5F_t *H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix /* Global heap CWFS routines */ H5_DLL herr_t H5F_cwfs_add(H5F_t *f, struct H5HG_heap_t *heap); H5_DLL herr_t H5F_cwfs_find_free_heap(H5F_t *f, size_t need, haddr_t *addr); -H5_DLL herr_t H5F_cwfs_advance_heap(H5F_t *f, struct H5HG_heap_t *heap, - hbool_t add_heap); +H5_DLL herr_t H5F_cwfs_advance_heap(H5F_t *f, struct H5HG_heap_t *heap, hbool_t add_heap); H5_DLL herr_t H5F_cwfs_remove_heap(H5F_file_t *shared, struct H5HG_heap_t *heap); /* Debugging functions */ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index fc346f8..f6c6d8f 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -1118,7 +1118,7 @@ H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, c /* Go retrieve the object information */ /* (don't need index & heap info) */ HDassert(obj_loc); - if(H5O_get_info(obj_loc->oloc, FALSE, &oinfo) < 0) + if(H5O_get_info(obj_loc->oloc, &oinfo, H5O_INFO_BASIC|H5O_INFO_TIME|H5O_INFO_HDR) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info") /* Get mapped object type */ diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 7273a89..f5a14a1 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -76,7 +76,7 @@ typedef struct { /* User data for getting an object's info in a group */ typedef struct { /* downward */ - hbool_t want_ih_info; /* Whether to retrieve the index & heap info */ + unsigned fields; /* which fields in H5O_info_t struct to fill in */ /* upward */ H5O_info_t *oinfo; /* Object information to retrieve */ @@ -684,7 +684,7 @@ H5G_loc_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUS HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Query object information */ - if(H5O_get_info(obj_loc->oloc, udata->want_ih_info, udata->oinfo) < 0) + if(H5O_get_info(obj_loc->oloc, udata->oinfo, udata->fields) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object info") done: @@ -710,7 +710,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_loc_info(const H5G_loc_t *loc, const char *name, hbool_t want_ih_info, H5O_info_t *oinfo/*out*/) +H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info_t *oinfo/*out*/, unsigned fields) { H5G_loc_info_t udata; /* User data for traversal callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -723,7 +723,7 @@ H5G_loc_info(const H5G_loc_t *loc, const char *name, hbool_t want_ih_info, H5O_i HDassert(oinfo); /* Set up user data for locating object */ - udata.want_ih_info = want_ih_info; + udata.fields = fields; udata.oinfo = oinfo; /* Traverse group hierarchy to locate object */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 2ae3d538..72b3633 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -1274,7 +1274,8 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get link name") /* Check if the object pointed by the soft link exists in the source file */ - if(H5G_loc_info(&grp_loc, link_name, FALSE, &oinfo) >= 0) { + /* Only basic information is needed */ + if(H5G_loc_info(&grp_loc, link_name, &oinfo, H5O_INFO_BASIC) >= 0) { tmp_src_ent.header = oinfo.addr; src_ent = &tmp_src_ent; } /* end if */ diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 427f14b..95dfef5 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -277,7 +277,7 @@ H5_DLL herr_t H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, H5G_loc_t *obj_loc/*out*/); H5_DLL htri_t H5G_loc_exists(const H5G_loc_t *loc, const char *name); H5_DLL herr_t H5G_loc_info(const H5G_loc_t *loc, const char *name, - hbool_t want_ih_info, H5O_info_t *oinfo/*out*/); + H5O_info_t *oinfo/*out*/, unsigned fields); H5_DLL herr_t H5G_loc_set_comment(const H5G_loc_t *loc, const char *name, const char *comment); H5_DLL ssize_t H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, @@ -31,8 +31,8 @@ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ #include "H5Ipkg.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ @@ -75,16 +75,16 @@ typedef struct { } H5I_id_type_t; typedef struct { - H5I_search_func_t app_cb; /* Application's callback routine */ - void *app_key; /* Application's "key" (user data) */ - void *ret_obj; /* Object to return */ + H5I_search_func_t app_cb; /* Application's callback routine */ + void *app_key; /* Application's "key" (user data) */ + void *ret_obj; /* Object to return */ } H5I_search_ud_t; /* User data for iterator callback for ID iteration */ typedef struct { - H5I_search_func_t user_func; /* 'User' function to invoke */ - void *user_udata; /* User data to pass to 'user' function */ - hbool_t app_ref; /* Whether this is an appl. ref. call */ + H5I_search_func_t user_func; /* 'User' function to invoke */ + void *user_udata; /* User data to pass to 'user' function */ + hbool_t app_ref; /* Whether this is an appl. ref. call */ } H5I_iterate_ud_t; /* User data for H5I__clear_type_cb */ @@ -126,26 +126,26 @@ static void *H5I__remove_verify(hid_t id, H5I_type_t id_type); static void *H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id); static int H5I__inc_type_ref(H5I_type_t type); static int H5I__get_type_ref(H5I_type_t type); +static int H5I__search_cb(void *obj, hid_t id, void *_udata); static H5I_id_info_t *H5I__find_id(hid_t id); static ssize_t H5I__get_name(const H5G_loc_t *loc, char *name, size_t size); #ifdef H5I_DEBUG_OUTPUT +static int H5I__debug_cb(void *_item, void *_key, void *_udata); static herr_t H5I__debug(H5I_type_t type); #endif /* H5I_DEBUG_OUTPUT */ /*------------------------------------------------------------------------- - * Function: H5I_term_package + * Function: H5I_term_package * - * Purpose: Terminate the H5I interface: release all memory, reset all - * global variables to initial values. This only happens if all - * types have been destroyed from other interfaces. + * Purpose: Terminate the H5I interface: release all memory, reset all + * global variables to initial values. This only happens if all + * types have been destroyed from other interfaces. * - * Return: Success: Positive if any action was taken that might - * affect some other interface; zero otherwise. + * Return: Success: Positive if any action was taken that might + * affect some other interface; zero otherwise. * - * Failure: Negative. - * - * Programmer: Unknown + * Failure: Negative. * *------------------------------------------------------------------------- */ @@ -241,7 +241,7 @@ H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func) } /* end else */ /* Allocate new ID class */ - if(NULL == (cls = H5FL_MALLOC(H5I_class_t))) + if(NULL == (cls = H5FL_CALLOC(H5I_class_t))) HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, H5I_BADID, "ID class allocation failed") /* Initialize class fields */ @@ -333,8 +333,7 @@ done: * Purpose: Query function to inform the user if a given type is * currently registered with the library. * - * Return: Success: 1 if the type is registered, 0 if it is not - * Failure: Negative + * Return: TRUE/FALSE/FAIL * *------------------------------------------------------------------------- */ @@ -358,15 +357,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5Inmembers + * Function: H5Inmembers * - * Purpose: Returns the number of members in a type. Public interface to - * H5I_nmembers. The public interface throws an error if the + * Purpose: Returns the number of members in a type. Public interface to + * H5I_nmembers. The public interface throws an error if the * supplied type does not exist. This is different than the * private interface, which will just return 0. * - * Return: Success: Zero - * Failure: Negative + * Return: SUCCEED/FAIL * * Programmer: James Laird * Nathaniel Furrer @@ -409,14 +407,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_nmembers + * Function: H5I_nmembers * - * Purpose: Returns the number of members in a type. + * Purpose: Returns the number of members in a type. * - * Return: Success: Number of members; zero if the type is empty - * or has been deleted. + * Return: Success: Number of members; zero if the type is empty + * or has been deleted. * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Wednesday, March 24, 1999 @@ -445,14 +443,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iclear_type + * Function: H5Iclear_type * - * Purpose: Removes all objects from the type, calling the free - * function for each object regardless of the reference count. - * Public interface to H5I_clear_type. + * Purpose: Removes all objects from the type, calling the free + * function for each object regardless of the reference count. + * Public interface to H5I_clear_type. * - * Return: Success: Non-negative - * Failure: negative + * Return: SUCCEED/FAIL * * Programmer: James Laird * Nathaniel Furrer @@ -479,13 +476,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_clear_type + * Function: H5I_clear_type * - * Purpose: Removes all objects from the type, calling the free - * function for each object regardless of the reference count. + * Purpose: Removes all objects from the type, calling the free + * function for each object regardless of the reference count. * - * Return: Success: Non-negative - * Failure: negative + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Wednesday, March 24, 1999 @@ -523,11 +519,10 @@ done: /*------------------------------------------------------------------------- * Function: H5I__clear_type_cb * - * Purpose: Attempts to free the specified ID , calling the free + * Purpose: Attempts to free the specified ID, calling the free * function for the object. * - * Return: Success: Non-negative - * Failure: negative + * Return: TRUE/FALSE/FAIL * * Programmer: Neil Fortner * Friday, July 10, 2015 @@ -547,8 +542,7 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) HDassert(udata); HDassert(udata->type_ptr); - /* - * Do nothing to the object if the reference count is larger than + /* Do nothing to the object if the reference count is larger than * one and forcing is off. */ if(udata->force || (id->count - (!udata->app_ref * id->app_count)) <= 1) { @@ -589,15 +583,15 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) /*------------------------------------------------------------------------- - * Function: H5Idestroy_type + * Function: H5Idestroy_type * - * Purpose: Destroys a type along with all atoms in that type - * regardless of their reference counts. Destroying IDs - * involves calling the free-func for each ID's object and - * then adding the ID struct to the ID free list. Public - * interface to H5I__destroy_type. + * Purpose: Destroys a type along with all atoms in that type + * regardless of their reference counts. Destroying IDs + * involves calling the free-func for each ID's object and + * then adding the ID struct to the ID free list. Public + * interface to H5I__destroy_type. * - * Return: Zero on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Nathaniel Furrer * James Laird @@ -623,14 +617,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5I__destroy_type + * Function: H5I__destroy_type * - * Purpose: Destroys a type along with all atoms in that type - * regardless of their reference counts. Destroying IDs - * involves calling the free-func for each ID's object and - * then adding the ID struct to the ID free list. + * Purpose: Destroys a type along with all atoms in that type + * regardless of their reference counts. Destroying IDs + * involves calling the free-func for each ID's object and + * then adding the ID struct to the ID free list. * - * Return: Zero on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Nathaniel Furrer * James Laird @@ -678,8 +672,8 @@ done: * * Purpose: Public interface to H5I_register. * - * Return: Success: New object id. - * Failure: Negative + * Return: Success: New object ID + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -712,7 +706,7 @@ done: * for the type the ID is in and incorporating the type into * the ID which is returned to the user. * - * Return: Success: New object id + * Return: Success: New object ID * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- @@ -738,10 +732,10 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) /* Create the struct & its ID */ new_id = H5I_MAKE(type, type_ptr->nextid); - id_ptr->id = new_id; - id_ptr->count = 1; /* initial reference count */ - id_ptr->app_count = !!app_ref; - id_ptr->obj_ptr = object; + id_ptr->id = new_id; + id_ptr->count = 1; /* initial reference count */ + id_ptr->app_count = !!app_ref; + id_ptr->obj_ptr = object; /* Insert into the type */ if (H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) @@ -777,17 +771,18 @@ done: herr_t H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t id) { - H5I_id_type_t *type_ptr; /* ptr to the type */ - H5I_id_info_t *id_ptr; /* ptr to the new ID information */ + H5I_id_type_t *type_ptr; /* ptr to the type */ + H5I_id_info_t *id_ptr; /* ptr to the new ID information */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) /* Check arguments */ + HDassert(object); /* Make sure ID is not already in use */ if(NULL != (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use?!") + HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use") /* Make sure type number is valid */ if(type <= H5I_BADID || type >= H5I_next_type) @@ -808,10 +803,10 @@ H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed") /* Create the struct & insert requested ID */ - id_ptr->id = id; - id_ptr->count = 1; /*initial reference count*/ - id_ptr->app_count = !!app_ref; - id_ptr->obj_ptr = object; + id_ptr->id = id; + id_ptr->count = 1; /* initial reference count*/ + id_ptr->app_count = !!app_ref; + id_ptr->obj_ptr = object; /* Insert into the type */ if(H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) @@ -824,13 +819,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_subst + * Function: H5I_subst * - * Purpose: Substitute a new object pointer for the specified ID. + * Purpose: Substitute a new object pointer for the specified ID. * - * Return: Success: Non-null previous object pointer associated - * with the specified ID. - * Failure: NULL + * Return: Success: Non-NULL previous object pointer associated + * with the specified ID. + * Failure: NULL * * Programmer: Quincey Koziol * Saturday, February 27, 2010 @@ -862,51 +857,45 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_object + * Function: H5I_object * - * Purpose: Find an object pointer for the specified ID. + * Purpose: Find an object pointer for the specified ID. * - * Return: Success: Non-null object pointer associated with the - * specified ID. - * Failure: NULL + * Return: Success: Non-NULL object pointer associated with the + * specified ID * - * Programmer: Unknown + * Failure: NULL * *------------------------------------------------------------------------- */ void * H5I_object(hid_t id) { - H5I_id_info_t *id_ptr; /*ptr to the new atom */ - void *ret_value = NULL; /*return value */ + H5I_id_info_t *id_ptr; /* Pointer to the new atom */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOERR /* General lookup of the ID */ if(NULL != (id_ptr = H5I__find_id(id))) { /* Get the object pointer to return */ - /* (Casting away const OK -QAK) */ - ret_value = (void *)id_ptr->obj_ptr; - } /* end if */ + ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_object() */ /*------------------------------------------------------------------------- - * Function: H5Iobject_verify + * Function: H5Iobject_verify * - * Purpose: Find an object pointer for the specified ID, verifying that - * its in a particular type. Public interface to - * H5I_object_verify. + * Purpose: Find an object pointer for the specified ID, verifying that + * its in a particular type. Public interface to + * H5I_object_verify. * - * Return: Success: Non-null object pointer associated with the - * specified ID. - * Failure: NULL - * - * Programmer: Nathaniel Furrer - * James Laird - * Friday, April 23, 2004 + * Return: Success: Non-NULL object pointer associated with the + * specified ID. + * Failure: NULL * *------------------------------------------------------------------------- */ @@ -932,14 +921,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_object_verify + * Function: H5I_object_verify * - * Purpose: Find an object pointer for the specified ID, verifying that - * its in a particular type. + * Purpose: Find an object pointer for the specified ID, verifying that + * its in a particular type. * - * Return: Success: Non-null object pointer associated with the - * specified ID. - * Failure: NULL + * Return: Success: Non-NULL object pointer associated with the + * specified ID. + * Failure: NULL * * Programmer: Quincey Koziol * Wednesday, July 31, 2002 @@ -949,8 +938,8 @@ done: void * H5I_object_verify(hid_t id, H5I_type_t id_type) { - H5I_id_info_t *id_ptr = NULL; /*ptr to the new atom */ - void *ret_value = NULL; /*return value */ + H5I_id_info_t *id_ptr = NULL; /* Pointer to the new atom */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -959,24 +948,25 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) /* Verify that the type of the ID is correct & lookup the ID */ if(id_type == H5I_TYPE(id) && NULL != (id_ptr = H5I__find_id(id))) { /* Get the object pointer to return */ - /* (Casting away const OK -QAK) */ - ret_value = (void *)id_ptr->obj_ptr; - } /* end if */ + ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ + } FUNC_LEAVE_NOAPI(ret_value) } /* H5I_object_verify() */ /*------------------------------------------------------------------------- - * Function: H5I_get_type + * Function: H5I_get_type * - * Purpose: Given an object ID return the type to which it - * belongs. The ID need not be the ID of an object which - * currently exists because the type number is encoded - * in the object ID. + * Purpose: Given an object ID return the type to which it + * belongs. The ID need not be the ID of an object which + * currently exists because the type number is encoded + * in the object ID. * - * Return: Success: A valid type number - * Failure: H5I_BADID, a negative value. + * Return: Success: A positive integer (corresponding to an H5I_type_t + * enum value for library ID types, but not for user + * ID types). + * Failure: H5I_BADID * * Programmer: Robb Matzke * Friday, February 19, 1999 @@ -1000,17 +990,17 @@ H5I_get_type(hid_t id) /*------------------------------------------------------------------------- - * Function: H5Iget_type + * Function: H5Iget_type * - * Purpose: The public version of H5I_get_type(), obtains a type number - * when given an ID. The ID need not be the ID of an - * object which currently exists because the type number is - * encoded as part of the ID. + * Purpose: The public version of H5I_get_type(), obtains a type number + * when given an ID. The ID need not be the ID of an + * object which currently exists because the type number is + * encoded as part of the ID. * - * Return: Success: Type number - * Failure: H5I_BADID, a negative value - * - * Programmer: Unknown + * Return: Success: A positive integer (corresponding to an H5I_type_t + * enum value for library ID types, but not for user + * ID types). + * Failure: H5I_BADID * *------------------------------------------------------------------------- */ @@ -1033,16 +1023,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iremove_verify + * Function: H5Iremove_verify * - * Purpose: Removes the specified ID from its type, first checking that the - * type of the ID and the type type are the same. Public interface to - * H5I__remove_verify. + * Purpose: Removes the specified ID from its type, first checking that the + * type of the ID and the type type are the same. Public interface to + * H5I__remove_verify. * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL * * Programmer: James Laird * Nathaniel Furrer @@ -1069,15 +1059,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5I__remove_verify + * Function: H5I__remove_verify * - * Purpose: Removes the specified ID from its type, first checking that - * the ID's type is the same as the ID type supplied as an argument + * Purpose: Removes the specified ID from its type, first checking that + * the ID's type is the same as the ID type supplied as an argument * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL * * Programmer: James Laird * Nat Furrer @@ -1102,14 +1092,14 @@ H5I__remove_verify(hid_t id, H5I_type_t id_type) /*------------------------------------------------------------------------- - * Function: H5I__remove_common + * Function: H5I__remove_common * - * Purpose: Common code to remove a specified ID from its type. + * Purpose: Common code to remove a specified ID from its type. * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL * * Programmer: Quincey Koziol * October 3, 2013 @@ -1144,14 +1134,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_remove + * Function: H5I_remove * - * Purpose: Removes the specified ID from its type. + * Purpose: Removes the specified ID from its type. * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL * * Programmer: Unknown * @@ -1184,14 +1174,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5Idec_ref + * Function: H5Idec_ref * - * Purpose: Decrements the number of references outstanding for an ID. + * Purpose: Decrements the number of references outstanding for an ID. * If the reference count for an ID reaches zero, the object * will be closed. * - * Return: Success: New reference count - * Failure: Negative + * Return: Success: New reference count + * Failure: -1 * * Programmer: Quincey Koziol * Dec 7, 2003 @@ -1203,16 +1193,16 @@ H5Idec_ref(hid_t id) { int ret_value = 0; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); /* Check arguments */ if(id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID") /* Do actual decrement operation */ if((ret_value = H5I_dec_app_ref(id)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") done: FUNC_LEAVE_API(ret_value) @@ -1220,19 +1210,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_dec_ref - * - * Purpose: Decrements the number of references outstanding for an ID. - * This will fail if the type is not a reference counted type. - * The ID type's 'free' function will be called for the ID - * if the reference count for the ID reaches 0 and a free - * function has been defined at type creation time. + * Function: H5I_dec_ref * - * Return: Success: New reference count. + * Purpose: Decrements the number of references outstanding for an ID. + * This will fail if the type is not a reference counted type. + * The ID type's 'free' function will be called for the ID + * if the reference count for the ID reaches 0 and a free + * function has been defined at type creation time. * - * Failure: Negative + * Return: Success: New reference count * - * Programmer: Unknown + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1242,17 +1230,16 @@ H5I_dec_ref(hid_t id) H5I_id_info_t *id_ptr; /* Pointer to the new ID */ int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); /* General lookup of the ID */ if(NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") - /* - * If this is the last reference to the object then invoke the type's + /* If this is the last reference to the object then invoke the type's * free method on the object. If the free method is undefined or * successful then remove the object from the type; otherwise leave * the object in the type without decrementing the reference @@ -1276,11 +1263,11 @@ H5I_dec_ref(hid_t id) if(!type_ptr->cls->free_func || (type_ptr->cls->free_func)((void *)id_ptr->obj_ptr) >= 0) { /* Remove the node from the type */ if(NULL == H5I__remove_common(type_ptr, id)) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, FAIL, "can't remove ID node") + HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, (-1), "can't remove ID node") ret_value = 0; } /* end if */ else - ret_value = FAIL; + ret_value = -1; } /* end if */ else { --(id_ptr->count); @@ -1293,13 +1280,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_dec_app_ref + * Function: H5I_dec_app_ref * - * Purpose: H5I_dec_ref wrapper for case of modifying the application ref. - * count for an ID as well as normal reference count. + * Purpose: H5I_dec_ref wrapper for case of modifying the application ref. + * count for an ID as well as normal reference count. * - * Return: Success: New app. reference count. - * Failure: Negative + * Return: Success: New app. reference count + * Failure: -1 * * Programmer: Quincey Koziol * Sept 16, 2010 @@ -1312,20 +1299,20 @@ H5I_dec_app_ref(hid_t id) H5I_id_info_t *id_ptr; /* Pointer to the new ID */ int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); /* Call regular decrement reference count routine */ if((ret_value = H5I_dec_ref(id)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") /* Check if the ID still exists */ if(ret_value > 0) { /* General lookup of the ID */ if(NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* Adjust app_ref */ --(id_ptr->app_count); @@ -1346,8 +1333,8 @@ done: * Purpose: H5I_dec_app_ref wrapper for case of always closing the ID, * even when the free routine fails * - * Return: Success: New app. reference count. - * Failure: Negative + * Return: Success: New app. reference count + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1356,7 +1343,7 @@ H5I_dec_app_ref_always_close(hid_t id) { int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); @@ -1374,7 +1361,7 @@ H5I_dec_app_ref_always_close(hid_t id) */ H5I_remove(id); - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") } done: @@ -1388,7 +1375,7 @@ done: * Purpose: Increments the number of references outstanding for an ID. * * Return: Success: New reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1397,16 +1384,16 @@ H5Iinc_ref(hid_t id) { int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); /* Check arguments */ if (id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID") /* Do actual increment operation */ if ((ret_value = H5I_inc_ref(id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, (-1), "can't increment ID ref count") done: FUNC_LEAVE_API(ret_value) @@ -1418,8 +1405,8 @@ done: * * Purpose: Increment the reference count for an object. * - * Return: Success: The new reference count. - * Failure: Negative + * Return: Success: The new reference count + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1429,14 +1416,14 @@ H5I_inc_ref(hid_t id, hbool_t app_ref) H5I_id_info_t *id_ptr; /* Pointer to the ID */ int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); /* General lookup of the ID */ if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* Adjust reference counts */ ++(id_ptr->count); @@ -1457,7 +1444,7 @@ done: * Purpose: Retrieves the number of references outstanding for an ID. * * Return: Success: Reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1466,16 +1453,16 @@ H5Iget_ref(hid_t id) { int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); /* Check arguments */ if (id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID") /* Do actual retrieve operation */ if ((ret_value = H5I_get_ref(id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get ID ref count") done: FUNC_LEAVE_API(ret_value) @@ -1487,8 +1474,8 @@ done: * * Purpose: Retrieve the reference count for an object. * - * Return: Success: The reference count. - * Failure: Negative + * Return: Success: The reference count + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1498,14 +1485,14 @@ H5I_get_ref(hid_t id, hbool_t app_ref) H5I_id_info_t *id_ptr; /* Pointer to the ID */ int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); /* General lookup of the ID */ if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* Set return value */ ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count); @@ -1521,7 +1508,7 @@ done: * Purpose: Increments the number of references outstanding for an ID type. * * Return: Success: New reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1530,19 +1517,19 @@ H5Iinc_type_ref(H5I_type_t type) { int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "It", type); /* Check arguments */ if (type <= 0 || type >= H5I_next_type) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID type") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") if (H5I_IS_LIB_TYPE(type)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") /* Do actual increment operation */ if ((ret_value = H5I__inc_type_ref(type)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID type ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, (-1), "can't increment ID type ref count") done: FUNC_LEAVE_API(ret_value) @@ -1555,7 +1542,7 @@ done: * Purpose: Increment the reference count for an ID type. * * Return: Success: The new reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1573,7 +1560,7 @@ H5I__inc_type_ref(H5I_type_t type) /* Check arguments */ type_ptr = H5I_id_type_list_g[type]; if (!type_ptr) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") /* Set return value */ ret_value = (int)(++(type_ptr->init_count)); @@ -1603,20 +1590,20 @@ done: * release (DER). * * Return: Success: Number of references to type - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ herr_t H5Idec_type_ref(H5I_type_t type) { - herr_t ret_value; /* Return value */ + herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("e", "It", type); if (H5I_IS_LIB_TYPE(type)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") ret_value = H5I_dec_type_ref(type); @@ -1640,24 +1627,24 @@ done: * be set to H5I_UNINIT). * * Return: Success: Number of references to type - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ -herr_t +int H5I_dec_type_ref(H5I_type_t type) { H5I_id_type_t *type_ptr; /* Pointer to the ID type */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) if (type <= H5I_BADID || type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "invalid type number") type_ptr = H5I_id_type_list_g[type]; if (type_ptr == NULL || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") /* Decrement the number of users of the atomic type. If this is the * last user of the type then release all atoms from the type and @@ -1684,7 +1671,7 @@ done: * Purpose: Retrieves the number of references outstanding for a type. * * Return: Success: Reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1693,19 +1680,19 @@ H5Iget_type_ref(H5I_type_t type) { int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "It", type); /* Check arguments */ if (type <= 0 || type >= H5I_next_type) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID type") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") if (H5I_IS_LIB_TYPE(type)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") /* Do actual retrieve operation */ if ((ret_value = H5I__get_type_ref(type)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID type ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get ID type ref count") done: FUNC_LEAVE_API(ret_value) @@ -1717,9 +1704,9 @@ done: * * Purpose: Retrieve the reference count for an ID type. * - * Return: Success: The reference count. + * Return: Success: The reference count * - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1753,9 +1740,7 @@ done: * Purpose: Check if the given id is valid. An id is valid if it is in * use and has an application reference count of at least 1. * - * Return: Success: TRUE if the id is valid, FALSE otherwise. - * - * Failure: Negative (never fails currently) + * Return: TRUE/FALSE/FAIL * *------------------------------------------------------------------------- */ @@ -1786,24 +1771,29 @@ done: * Calls "user" callback search function, and then sets return * value, based on the result of that callback. * - * Return: Success: The first object in the type for which FUNC - * returns non-zero. NULL if FUNC returned zero - * for every object in the type. - * Failure: NULL + * Return: Success: H5_ITER_CONT (0) or H5_ITER_STOP (1) + * Failure: H5_ITER_ERROR (-1) * *------------------------------------------------------------------------- */ static int H5I__search_cb(void *obj, hid_t id, void *_udata) { - H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ - int ret_value = -1; /* Callback return value */ + H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ + herr_t cb_ret_val; /* User callback return value */ + int ret_value = H5_ITER_ERROR; /* Callback return value */ FUNC_ENTER_STATIC_NOERR - ret_value = (*udata->app_cb)(obj, id, udata->app_key); - if (ret_value > 0) - udata->ret_obj = obj; + cb_ret_val = (*udata->app_cb)(obj, id, udata->app_key); + + /* Set the return value based on the callback's return value */ + if(cb_ret_val > 0) { + ret_value = H5_ITER_STOP; /* terminate iteration early */ + udata->ret_obj = obj; /* also set out parameter */ + } + else if(cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__search_cb() */ @@ -1867,8 +1857,8 @@ done: * function, and then sets return value, based on the result of * that callback. * - * Return: Success: Non-negative on success - * Failure: Negative + * Return: Success: H5_ITER_CONT (0) or H5_ITER_STOP (1) + * Failure: H5_ITER_ERROR (-1) * *------------------------------------------------------------------------- */ @@ -1881,17 +1871,21 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) FUNC_ENTER_STATIC_NOERR - /* Don't make callback if app_ref is set and the appl. ref count is 0 */ + /* Only invoke the callback function if this ID is visible externally and + * its reference count is positive. + */ if((!udata->app_ref) || (item->app_count > 0)) { - herr_t cb_ret_val; + herr_t cb_ret_val; - /* (Casting away const OK) */ - cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, udata->user_udata); + /* Invoke callback function */ + cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, udata->user_udata); /* (Casting away const OK) */ + + /* Set the return value based on the callback's return value */ if(cb_ret_val > 0) ret_value = H5_ITER_STOP; /* terminate iteration early */ else if(cb_ret_val < 0) ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__iterate_cb() */ @@ -1925,8 +1919,8 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref) { - H5I_id_type_t *type_ptr; /*ptr to the type */ - herr_t ret_value = SUCCEED; /*return value */ + H5I_id_type_t *type_ptr; /* Pointer to the type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1941,9 +1935,9 @@ H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_re herr_t iter_status; /* Iteration status */ /* Set up iterator user data */ - iter_udata.user_func = func; - iter_udata.user_udata = udata; - iter_udata.app_ref = app_ref; + iter_udata.user_func = func; + iter_udata.user_udata = udata; + iter_udata.app_ref = app_ref; /* Iterate over IDs */ if ((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) @@ -2003,11 +1997,11 @@ done: * Failure: -1 * * Comments: Public function - * If `name' is non-NULL then write up to `size' bytes into that + * If 'name' is non-NULL then write up to 'size' bytes into that * buffer and always return the length of the entry name. - * Otherwise `size' is ignored and the function does not store the name, + * Otherwise 'size' is ignored and the function does not store the name, * just returning the number of characters required to store the name. - * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL) + * If an error occurs then the buffer pointed to by 'name' (NULL or non-NULL) * is unchanged and the function returns a negative value. * If a zero is returned for the name's length, then there is no name * associated with the ID. @@ -2020,16 +2014,16 @@ H5Iget_name(hid_t id, char *name/*out*/, size_t size) H5G_loc_t loc; /* Object location */ ssize_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", id, name, size); /* Get object location */ if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object location") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object location") /* Call internal routine to retrieve object's name */ if((ret_value = H5I__get_name(&loc, name, size)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") done: FUNC_LEAVE_API(ret_value) @@ -2047,15 +2041,15 @@ done: * Return: Success: The length of the name * Failure: -1 * - * Programmer: Quincey Koziol - * January 9, 2018 + * Programmer: Quincey Koziol + * January 9, 2018 * *------------------------------------------------------------------------- */ static ssize_t H5I__get_name(const H5G_loc_t *loc, char *name, size_t size) { - ssize_t ret_value = FAIL; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_VOL @@ -2064,7 +2058,7 @@ H5I__get_name(const H5G_loc_t *loc, char *name, size_t size) /* Retrieve object's name */ if((ret_value = H5G_get_name(loc, name, size, NULL)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") done: FUNC_LEAVE_NOAPI_VOL(ret_value) @@ -2086,13 +2080,22 @@ done: hid_t H5Iget_file_id(hid_t obj_id) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5I_type_t type; /* ID type */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", obj_id); - if ((ret_value = H5I_get_file_id(obj_id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") + /* Get object type */ + type = H5I_TYPE(obj_id); + + /* Call internal function */ + if (H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { + if ((ret_value = H5I_get_file_id(obj_id, type)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") + } + else + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "not an ID of a file object") done: FUNC_LEAVE_API(ret_value) @@ -2106,30 +2109,27 @@ done: * ID given an object ID. * * Return: Success: The file ID associated with the object - * * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t -H5I_get_file_id(hid_t obj_id, hbool_t app_ref) +H5I_get_file_id(hid_t obj_id, H5I_type_t type) { - H5I_type_t type; /* ID type */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - /* Get object type */ - type = H5I_TYPE(obj_id); + /* Process based on object type */ if (type == H5I_FILE) { /* Increment reference count on file ID */ - if(H5I_inc_ref(obj_id, app_ref) < 0) + if(H5I_inc_ref(obj_id, TRUE) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") /* Set return value */ ret_value = obj_id; } - else if (type == H5I_DATATYPE || type == H5I_GROUP || type == H5I_DATASET || type == H5I_ATTR) { + else { H5G_loc_t loc; /* Location of object */ /* Get the object location information */ @@ -2137,11 +2137,9 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get object location") /* Get the file ID for the object */ - if((ret_value = H5F_get_id(loc.oloc->file, app_ref)) < 0) + if((ret_value = H5F_get_id(loc.oloc->file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get file ID") } - else - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "invalid object ID") done: FUNC_LEAVE_NOAPI(ret_value) @@ -2154,16 +2152,16 @@ done: * * Purpose: Dump the contents of an ID to stderr for debugging. * - * Return: SUCCEED/FAIL + * Return: H5_ITER_CONT (always) * *------------------------------------------------------------------------- */ -static herr_t +static int H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ - H5G_name_t *path = NULL; + H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ + H5G_name_t *path = NULL; /* Path to file object */ FUNC_ENTER_STATIC_NOERR @@ -2174,17 +2172,20 @@ H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) /* Get the group location, so we get get the name */ switch (type) { case H5I_GROUP: + { path = H5G_nameof((H5G_t*)item->obj_ptr); break; - + } case H5I_DATASET: + { path = H5D_nameof((H5D_t*)item->obj_ptr); break; - + } case H5I_DATATYPE: + { path = H5T_nameof((H5T_t*)item->obj_ptr); break; - + } case H5I_UNINIT: case H5I_BADID: case H5I_FILE: @@ -2209,7 +2210,7 @@ H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) HDfprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r)); } - FUNC_LEAVE_NOAPI(SUCCEED) + FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* end H5I__debug_cb() */ diff --git a/src/H5Ipkg.h b/src/H5Ipkg.h index 16d7d67..2c1d81f 100644 --- a/src/H5Ipkg.h +++ b/src/H5Ipkg.h @@ -67,7 +67,7 @@ /* Testing functions */ #ifdef H5I_TESTING -H5_DLL ssize_t H5I_get_name_test(hid_t id, char *name/*out*/, size_t size, +H5_DLL ssize_t H5I__get_name_test(hid_t id, char *name/*out*/, size_t size, hbool_t *cached); #endif /* H5I_TESTING */ diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 25cea4f..3bfde93 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -72,7 +72,7 @@ H5_DLL void *H5I_subst(hid_t id, const void *new_object); H5_DLL void *H5I_object(hid_t id); H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type); H5_DLL H5I_type_t H5I_get_type(hid_t id); -H5_DLL hid_t H5I_get_file_id(hid_t obj_id, hbool_t app_ref); +H5_DLL hid_t H5I_get_file_id(hid_t obj_id, H5I_type_t id_type); H5_DLL void *H5I_remove(hid_t id); H5_DLL herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref); H5_DLL int H5I_get_ref(hid_t id, hbool_t app_ref); @@ -80,7 +80,7 @@ H5_DLL int H5I_inc_ref(hid_t id, hbool_t app_ref); H5_DLL int H5I_dec_ref(hid_t id); H5_DLL int H5I_dec_app_ref(hid_t id); H5_DLL int H5I_dec_app_ref_always_close(hid_t id); -H5_DLL herr_t H5I_dec_type_ref(H5I_type_t type); +H5_DLL int H5I_dec_type_ref(H5I_type_t type); #endif /* _H5Iprivate_H */ diff --git a/src/H5Itest.c b/src/H5Itest.c index 426c026..4b54835 100644 --- a/src/H5Itest.c +++ b/src/H5Itest.c @@ -28,12 +28,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Ipkg.h" /* IDs */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Ipkg.h" /* IDs */ /****************/ @@ -63,44 +63,44 @@ /*------------------------------------------------------------------------- - * Function: H5I_get_name_test + * Function: H5I__get_name_test * - * Purpose: Testing version of H5Iget_name() + * Purpose: Testing version of H5Iget_name() * - * Return: Success: The length of name. - * Failure: -1 + * Return: Success: The length of name. + * Failure: -1 * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, July 27, 2010 * *------------------------------------------------------------------------- */ ssize_t -H5I_get_name_test(hid_t id, char *name/*out*/, size_t size, hbool_t *cached) +H5I__get_name_test(hid_t id, char *name/*out*/, size_t size, hbool_t *cached) { - H5G_loc_t loc; /* Object location */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - ssize_t ret_value = -1; /* Return value */ + H5G_loc_t loc; /* Object location */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + ssize_t ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* Get object location */ if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object location") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object location") /* Set API context */ if(H5CX_push() < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, (-1), "can't set API context") api_ctx_pushed = TRUE; /* Call internal group routine to retrieve object's name */ if((ret_value = H5G_get_name(&loc, name, size, cached)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") done: if(api_ctx_pushed && H5CX_pop() < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_SYM, H5E_CANTRESET, (-1), "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_get_name_test() */ +} /* end H5I__get_name_test() */ @@ -97,6 +97,9 @@ static herr_t H5MF__close_fstype(H5F_t *f, H5F_mem_page_t type); static herr_t H5MF__delete_fstype(H5F_t *f, H5F_mem_page_t type); static herr_t H5MF__close_delete_fstype(H5F_t *f, H5F_mem_page_t type); +/* Callbacks */ +static herr_t H5MF__sects_cb(H5FS_section_info_t *_sect, void *_udata); + /*********************/ /* Package Variables */ @@ -232,7 +235,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5MF_alloc_to_fs_type + * Function: H5MF__alloc_to_fs_type * * Purpose: Map "alloc_type" to the free-space manager type * @@ -244,9 +247,9 @@ done: *------------------------------------------------------------------------- */ void -H5MF_alloc_to_fs_type(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5F_mem_page_t *fs_type) +H5MF__alloc_to_fs_type(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5F_mem_page_t *fs_type) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR HDassert(f); HDassert(fs_type); @@ -271,7 +274,7 @@ H5MF_alloc_to_fs_type(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5F_mem_pag *fs_type = (H5F_mem_page_t)H5MF_ALLOC_TO_FS_AGGR_TYPE(f, alloc_type); FUNC_LEAVE_NOAPI_VOID -} /* end H5MF_alloc_to_fs_type() */ +} /* end H5MF__alloc_to_fs_type() */ /*------------------------------------------------------------------------- @@ -379,10 +382,10 @@ H5MF__create_fstype(H5F_t *f, H5F_mem_page_t type) H5MF_FSPACE_SECT_CLS_LARGE }; H5FS_create_t fs_create; /* Free space creation parameters */ hsize_t alignment; /* Alignment to use */ - hsize_t threshold; /* Threshold to use */ + hsize_t threshold; /* Threshold to use */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t fsm_ring; /* Ring of FSM */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) @@ -509,7 +512,7 @@ static herr_t H5MF__delete_fstype(H5F_t *f, H5F_mem_page_t type) { H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ haddr_t tmp_fs_addr; /* Temporary holder for free space manager address */ herr_t ret_value = SUCCEED; /* Return value */ @@ -628,10 +631,10 @@ herr_t H5MF__add_sect(H5F_t *f, H5FD_mem_t alloc_type, H5FS_t *fspace, H5MF_free_section_t *node) { H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ - H5MF_sect_ud_t udata; /* User data for callback */ - H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ + H5MF_sect_ud_t udata; /* User data for callback */ + H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) @@ -639,7 +642,7 @@ H5MF__add_sect(H5F_t *f, H5FD_mem_t alloc_type, H5FS_t *fspace, H5MF_free_sectio HDassert(fspace); HDassert(node); - H5MF_alloc_to_fs_type(f, alloc_type, node->sect_info.size, &fs_type); + H5MF__alloc_to_fs_type(f, alloc_type, node->sect_info.size, &fs_type); /* Construct user data for callbacks */ udata.f = f; @@ -688,7 +691,7 @@ H5MF__find_sect(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5FS_t *fspace, haddr_t *addr) { H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ H5MF_free_section_t *node; /* Free space section pointer */ htri_t ret_value = FAIL; /* Whether an existing free list node was found */ @@ -728,7 +731,7 @@ HDfprintf(stderr, "%s: freeing node\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Free section node */ - if(H5MF_sect_free((H5FS_section_info_t *)node) < 0) + if(H5MF__sect_free((H5FS_section_info_t *)node) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") } /* end if */ else { @@ -776,7 +779,7 @@ haddr_t H5MF_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) { H5AC_ring_t fsm_ring = H5AC_RING_INV; /* free space manager ring */ - H5AC_ring_t orig_ring; /* Original ring value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ haddr_t ret_value = HADDR_UNDEF; /* Return value */ @@ -797,7 +800,7 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "tidy of self referential fsm hack failed") } /* end if */ - H5MF_alloc_to_fs_type(f, alloc_type, size, &fs_type); + H5MF__alloc_to_fs_type(f, alloc_type, size, &fs_type); #ifdef H5MF_ALLOC_DEBUG_MORE HDfprintf(stderr, "%s: Check 1.0\n", FUNC); @@ -862,7 +865,7 @@ done: HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); #endif /* H5MF_ALLOC_DEBUG */ #ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF_sects_dump(f, stderr); +H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ FUNC_LEAVE_NOAPI_TAG(ret_value) @@ -903,7 +906,7 @@ H5MF__alloc_pagefs(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_type, size); #endif /* H5MF_ALLOC_DEBUG */ - H5MF_alloc_to_fs_type(f, alloc_type, size, &ptype); + H5MF__alloc_to_fs_type(f, alloc_type, size, &ptype); switch(ptype) { case H5F_MEM_PAGE_GENERIC: @@ -936,7 +939,7 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize file free space") /* Create free space section for the fragment */ - if(NULL == (node = H5MF_sect_new(H5MF_FSPACE_SECT_LARGE, ret_value + size, frag_size))) + if(NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_LARGE, ret_value + size, frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize free space section") /* Add the fragment to the large free-space manager */ @@ -967,7 +970,7 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize file free space") HDassert(f->shared->fs_man[ptype]); - if(NULL == (node = H5MF_sect_new(H5MF_FSPACE_SECT_SMALL, (new_page + size), (f->shared->fs_page_size - size)))) + if(NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_SMALL, (new_page + size), (f->shared->fs_page_size - size)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize free space section") /* Add the remaining space in the page to the manager */ @@ -997,12 +1000,12 @@ done: HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); #endif /* H5MF_ALLOC_DEBUG */ #ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF_sects_dump(f, stderr); +H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ /* Release section node, if allocated and not added to section list or merged */ if(node) - if(H5MF_sect_free((H5FS_section_info_t *)node) < 0) + if(H5MF__sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, HADDR_UNDEF, "can't free section node") FUNC_LEAVE_NOAPI_TAG(ret_value) @@ -1110,7 +1113,7 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "tidy of self referential fsm hack failed") } /* end if */ - H5MF_alloc_to_fs_type(f, alloc_type, size, &fs_type); + H5MF__alloc_to_fs_type(f, alloc_type, size, &fs_type); /* Set the ring type in the API context */ if(H5MF__fsm_type_is_self_referential(f, fs_type)) @@ -1197,7 +1200,7 @@ HDfprintf(stderr, "%s: dropping addr = %a, size = %Hu, on the floor!\n", FUNC, a /* Create the free-space section for the freed section */ ctype = H5MF_SECT_CLASS_TYPE(f, size); - if(NULL == (node = H5MF_sect_new(ctype, addr, size))) + if(NULL == (node = H5MF__sect_new(ctype, addr, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") /* If size of the freed section is larger than threshold, add it to the free space manager */ @@ -1242,14 +1245,14 @@ done: /* Release section node, if allocated and not added to section list or merged */ if(node) - if(H5MF_sect_free((H5FS_section_info_t *)node) < 0) + if(H5MF__sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG */ #ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF_sects_dump(f, stderr); +H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_xfree() */ @@ -1334,7 +1337,7 @@ HDfprintf(stderr, "%s: Entering: alloc_type = %u, addr = %a, size = %Hu, extra_r } /* end if */ /* Get free space type from allocation type */ - H5MF_alloc_to_fs_type(f, alloc_type, size, &fs_type); + H5MF__alloc_to_fs_type(f, alloc_type, size, &fs_type); /* Set the ring type in the API context */ if(H5MF__fsm_type_is_self_referential(f, fs_type)) @@ -1365,7 +1368,7 @@ HDfprintf(stderr, "%s: extended = %t\n", FUNC, ret_value); HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") /* Create free space section for the fragment */ - if(NULL == (node = H5MF_sect_new(H5MF_FSPACE_SECT_LARGE, end + extra_requested, frag_size))) + if(NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_LARGE, end + extra_requested, frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") /* Add the fragment to the large-sized free-space manager */ @@ -1436,7 +1439,7 @@ done: HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG */ #ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF_sects_dump(f, stderr); +H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ FUNC_LEAVE_NOAPI_TAG(ret_value) @@ -1464,9 +1467,9 @@ H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) H5MF_sect_ud_t udata; /* User data for callback */ H5FS_section_class_t *sect_cls; /* Section class */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ - H5F_mem_page_t fs_type; /* Free space type */ - htri_t ret_value = FALSE; /* Return value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ + H5F_mem_page_t fs_type; /* Free space type */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) #ifdef H5MF_ALLOC_DEBUG @@ -1485,7 +1488,7 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN HDassert(sect_cls); /* Get free space type from allocation type */ - H5MF_alloc_to_fs_type(f, alloc_type, size, &fs_type); + H5MF__alloc_to_fs_type(f, alloc_type, size, &fs_type); /* Set the ring type in the API context */ if(H5MF__fsm_type_is_self_referential(f, fs_type)) @@ -1495,7 +1498,7 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN H5AC_set_ring(fsm_ring, &orig_ring); /* Create free-space section for block */ - if(NULL == (node = H5MF_sect_new(sect_cls->type, addr, size))) + if(NULL == (node = H5MF__sect_new(sect_cls->type, addr, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") /* Construct user data for callbacks */ @@ -1522,7 +1525,7 @@ done: H5AC_set_ring(orig_ring, NULL); /* Free section node allocated */ - if(node && H5MF_sect_free((H5FS_section_info_t *)node) < 0) + if(node && H5MF__sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") #ifdef H5MF_ALLOC_DEBUG @@ -1561,10 +1564,11 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); if(H5F_PAGED_AGGR(f)) { if((ret_value = H5MF__close_pagefs(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close free-space managers for 'page' file space") - } /* end if */ - else + } + else { if((ret_value = H5MF__close_aggrfs(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close free-space managers for 'aggr' file space") + } done: #ifdef H5MF_ALLOC_DEBUG @@ -1650,8 +1654,8 @@ herr_t H5MF_try_close(H5F_t *f) { H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring; /* Current ring value */ - H5AC_ring_t needed_ring; /* Ring value needed for this iteration */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -1689,7 +1693,7 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Set the ring type in the API context. In most cases, we will * need H5AC_RING_RDFSM, so initialy set the ring in - * the DXPL to that value. We will alter this later if needed. + * the context to that value. We will alter this later if needed. */ H5AC_set_ring(H5AC_RING_RDFSM, &orig_ring); curr_ring = H5AC_RING_RDFSM; @@ -1706,6 +1710,7 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; + if(needed_ring != curr_ring ) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; @@ -1727,6 +1732,7 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; + if(needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; @@ -1765,10 +1771,10 @@ static herr_t H5MF__close_aggrfs(H5F_t *f) { H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring; /* Current ring value */ - H5AC_ring_t needed_ring; /* Ring value needed for this iteration. */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ H5FD_mem_t type; /* Memory type for iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) #ifdef H5MF_ALLOC_DEBUG @@ -1783,7 +1789,7 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Set the ring type in the API context. In most cases, we will * need H5AC_RING_RDFSM, so initialy set the ring in - * the DXPL to that value. We will alter this later if needed. + * the context to that value. We will alter this later if needed. */ H5AC_set_ring(H5AC_RING_RDFSM, &orig_ring); curr_ring = H5AC_RING_RDFSM; @@ -1842,6 +1848,7 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; + if(needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; @@ -1929,8 +1936,8 @@ static herr_t H5MF__close_pagefs(H5F_t *f) { H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring; /* Current ring value */ - H5AC_ring_t needed_ring; /* Ring value needed for this iteration. */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ H5F_mem_page_t ptype; /* Memory type for iteration */ H5O_fsinfo_t fsinfo; /* File space info message */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1950,7 +1957,7 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Set the ring type in the API context. In most cases, we will * need H5AC_RING_RDFSM, so initialy set the ring in - * the DXPL to that value. We will alter this later if needed. + * the context to that value. We will alter this later if needed. */ H5AC_set_ring(H5AC_RING_RDFSM, &orig_ring); curr_ring = H5AC_RING_RDFSM; @@ -2005,6 +2012,7 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; + if(needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; @@ -2102,8 +2110,8 @@ static herr_t H5MF__close_shrink_eoa(H5F_t *f) { H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring; /* Current ring value */ - H5AC_ring_t needed_ring; /* Ring value needed for this iteration. */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ H5F_mem_t type; H5F_mem_page_t ptype; /* Memory type for iteration */ hbool_t eoa_shrank; /* Whether an EOA shrink occurs */ @@ -2139,6 +2147,7 @@ H5MF__close_shrink_eoa(H5F_t *f) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; + if(needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; @@ -2162,6 +2171,7 @@ H5MF__close_shrink_eoa(H5F_t *f) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; + if(needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; @@ -2222,9 +2232,9 @@ H5MF_get_freespace(H5F_t *f, hsize_t *tot_space, hsize_t *meta_size) htri_t fs_started[H5F_MEM_PAGE_NTYPES]; /* Indicate whether the free-space manager has been started */ haddr_t fs_eoa[H5FD_MEM_NTYPES]; /* EAO for each free-space manager */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring; /* Current ring value */ - H5AC_ring_t needed_ring; /* Ring value needed for this iteration. */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -2235,7 +2245,7 @@ H5MF_get_freespace(H5F_t *f, hsize_t *tot_space, hsize_t *meta_size) /* Set the ring type in the API context. In most cases, we will * need H5AC_RING_RDFSM, so initialy set the ring in - * the DXPL to that value. We will alter this later if needed. + * the context to that value. We will alter this later if needed. */ H5AC_set_ring(H5AC_RING_RDFSM, &orig_ring); curr_ring = H5AC_RING_RDFSM; @@ -2256,11 +2266,11 @@ H5MF_get_freespace(H5F_t *f, hsize_t *tot_space, hsize_t *meta_size) if(!H5F_PAGED_AGGR(f)) { /* Retrieve metadata aggregator info, if available */ - if(H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) + if(H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") /* Retrieve 'small data' aggregator info, if available */ - if(H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) + if(H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") } /* end if */ @@ -2342,7 +2352,8 @@ done: * Purpose: To retrieve free-space section information for * paged or non-paged aggregation * - * Return: SUCCEED/FAIL + * Return: Success: Number of free sections + * Failure: -1 * * Programmer: Vailin Choi; Dec 2012 * @@ -2352,15 +2363,15 @@ ssize_t H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info) { H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring; /* Current ring value */ - H5AC_ring_t needed_ring; /* Ring value needed for this iteration. */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ size_t total_sects = 0; /* Total number of sections */ H5MF_sect_iter_ud_t sect_udata; /* User data for callback */ H5F_mem_page_t start_type, end_type; /* Memory types to iterate over */ H5F_mem_page_t ty; /* Memory type for iteration */ ssize_t ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) + FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, (-1)) /* check args */ HDassert(f); @@ -2382,11 +2393,11 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t if(f->shared->first_alloc_dealloc) { if(H5AC_cache_image_pending(f)) { if(H5AC_force_cache_image_load(f) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "forced cache image load failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, (-1), "forced cache image load failed") } /* end if */ else { if(H5MF_tidy_self_referential_fsm_hack(f) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "tidy of self referential fsm hack failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, (-1), "tidy of self referential fsm hack failed") } /* end else */ } /* end if */ @@ -2409,7 +2420,7 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t /* Set the ring type in the API context. In most cases, we will * need H5AC_RING_RDFSM, so initialy set the ring in - * the DXPL to that value. We will alter this later if needed. + * the context to that value. We will alter this later if needed. */ H5AC_set_ring(H5AC_RING_RDFSM, &orig_ring); curr_ring = H5AC_RING_RDFSM; @@ -2431,7 +2442,7 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t if(!f->shared->fs_man[ty] && H5F_addr_defined(f->shared->fs_addr[ty])) { if(H5MF__open_fstype(f, ty) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't open the free space manager") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, (-1), "can't open the free space manager") HDassert(f->shared->fs_man[ty]); fs_started = TRUE; } /* end if */ @@ -2439,7 +2450,7 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t /* Check if there's free space sections of this type */ if(f->shared->fs_man[ty]) if(H5MF__get_free_sects(f, f->shared->fs_man[ty], §_udata, &nums) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get section info for the free space manager") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, (-1), "can't get section info for the free space manager") /* Increment total # of sections */ total_sects += nums; @@ -2447,7 +2458,7 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t /* Close the free space manager of this type, if we started it here */ if(fs_started) if(H5MF__close_fstype(f, ty) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCLOSEOBJ, FAIL, "can't close file free space") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCLOSEOBJ, (-1), "can't close file free space") if((H5F_PAGED_AGGR(f)) && (type != H5FD_MEM_DEFAULT)) ty = (H5F_mem_page_t)(ty + H5FD_MEM_NTYPES - 2); } /* end for */ @@ -2465,7 +2476,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5MF_sects_cb() + * Function: H5MF__sects_cb() * * Purpose: Iterator callback for each free-space section * Retrieve address and size into user data @@ -2478,12 +2489,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5MF_sects_cb(H5FS_section_info_t *_sect, void *_udata) +H5MF__sects_cb(H5FS_section_info_t *_sect, void *_udata) { H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; H5MF_sect_iter_ud_t *udata = (H5MF_sect_iter_ud_t *)_udata; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR if(udata->sect_idx < udata->sect_count) { udata->sects[udata->sect_idx].addr = sect->sect_info.addr; @@ -2492,7 +2503,7 @@ H5MF_sects_cb(H5FS_section_info_t *_sect, void *_udata) } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MF_sects_cb() */ +} /* H5MF__sects_cb() */ /*------------------------------------------------------------------------- @@ -2513,7 +2524,7 @@ H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, hsize_t hnums = 0; /* # of sections */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* check args */ HDassert(f); @@ -2529,7 +2540,7 @@ H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, /* Check if we should retrieve the section info */ if(sect_udata->sects && *nums > 0) /* Iterate over all the free space sections of this type, adding them to the user's section info */ - if(H5FS_sect_iterate(f, fspace, H5MF_sects_cb, sect_udata) < 0) + if(H5FS_sect_iterate(f, fspace, H5MF__sects_cb, sect_udata) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_BADITER, FAIL, "can't iterate over sections") done: @@ -2648,8 +2659,8 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) H5O_fsinfo_t fsinfo; /* Free space manager info message */ H5FS_stat_t fs_stat; /* Information for free-space manager */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring; /* Current ring value */ - H5AC_ring_t needed_ring; /* Ring value needed for this iteration. */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -2744,7 +2755,7 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) break; for(mem_type = H5FD_MEM_SUPER; mem_type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5F_mem_t, mem_type)) { - H5MF_alloc_to_fs_type(f, mem_type, alloc_size, &fsm_type); + H5MF__alloc_to_fs_type(f, mem_type, alloc_size, &fsm_type); if(pass_count == 0) { /* this is the first pass */ HDassert(fsm_type > H5F_MEM_PAGE_DEFAULT); @@ -2781,6 +2792,7 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; + if(needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; @@ -2888,7 +2900,7 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) break; for(mem_type = H5FD_MEM_SUPER; mem_type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5F_mem_t, mem_type)) { - H5MF_alloc_to_fs_type(f, mem_type, alloc_size, &fsm_type); + H5MF__alloc_to_fs_type(f, mem_type, alloc_size, &fsm_type); if(pass_count == 0) { /* this is the first pass */ HDassert(fsm_type > H5F_MEM_PAGE_DEFAULT); @@ -2906,6 +2918,7 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; + if(needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; @@ -3136,8 +3149,8 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) /* should only be called if file is opened R/W */ HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fs_type); - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fs_type); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fs_type); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fs_type); HDassert(sm_fshdr_fs_type > H5F_MEM_PAGE_DEFAULT); HDassert(sm_fshdr_fs_type < H5F_MEM_PAGE_LARGE_SUPER); @@ -3153,8 +3166,8 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) sm_sinfo_fspace = f->shared->fs_man[sm_fssinfo_fs_type]; if(H5F_PAGED_AGGR(f)) { - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fs_type); - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fs_type); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fs_type); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fs_type); HDassert(lg_fshdr_fs_type >= H5F_MEM_PAGE_LARGE_SUPER); HDassert(lg_fshdr_fs_type < H5F_MEM_PAGE_NTYPES); @@ -3398,7 +3411,7 @@ H5MF__fsm_type_is_self_referential(H5F_t *f, H5F_mem_page_t fsm_type) H5F_mem_page_t lg_fssinfo_fsm; hbool_t result = FALSE; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(f); @@ -3406,12 +3419,12 @@ H5MF__fsm_type_is_self_referential(H5F_t *f, H5F_mem_page_t fsm_type) HDassert(fsm_type >= H5F_MEM_PAGE_DEFAULT); HDassert(fsm_type < H5F_MEM_PAGE_NTYPES); - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fsm); - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fsm); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fsm); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fsm); if(H5F_PAGED_AGGR(f)) { - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fsm); - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fsm); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fsm); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fsm); result = (fsm_type == sm_fshdr_fsm) || (fsm_type == sm_fssinfo_fsm) || (fsm_type == lg_fshdr_fsm) || (fsm_type == lg_fssinfo_fsm); @@ -3460,15 +3473,15 @@ H5MF__fsm_is_self_referential(H5F_t *f, H5FS_t *fspace) HDassert(f->shared); HDassert(fspace); - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fsm); - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fsm); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fsm); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fsm); if(H5F_PAGED_AGGR(f)) { H5F_mem_page_t lg_fshdr_fsm; H5F_mem_page_t lg_fssinfo_fsm; - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fsm); - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fsm); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fsm); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fsm); result = (fspace == f->shared->fs_man[sm_fshdr_fsm]) || (fspace == f->shared->fs_man[sm_fssinfo_fsm]) || @@ -3609,8 +3622,8 @@ H5MF_tidy_self_referential_fsm_hack(H5F_t *f) * this -- we can use the regular I/O methods even if * paged aggregation and page buffering is enabled. */ - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fs_type); - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fs_type); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fs_type); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fs_type); HDassert(sm_fshdr_fs_type > H5F_MEM_PAGE_DEFAULT); HDassert(sm_fshdr_fs_type < H5F_MEM_PAGE_LARGE_SUPER); @@ -3648,8 +3661,8 @@ H5MF_tidy_self_referential_fsm_hack(H5F_t *f) } /* end if */ if(H5F_PAGED_AGGR(f)) { - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fs_type); - H5MF_alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fs_type); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fs_type); + H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fs_type); HDassert(lg_fshdr_fs_type >= H5F_MEM_PAGE_LARGE_SUPER); HDassert(lg_fshdr_fs_type < H5F_MEM_PAGE_NTYPES); diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index cd80a10..5ab1834 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -59,6 +59,8 @@ static herr_t H5MF__aggr_free(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr); static haddr_t H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, hsize_t size); +static herr_t H5MF__aggr_reset(H5F_t *f, H5F_blk_aggr_t *aggr); +static htri_t H5MF__aggr_can_shrink_eoa(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr); /*********************/ @@ -179,7 +181,7 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); /* * If the aggregation feature is enabled for this file and strategy is not H5F_FILE_SPACE_NONE, * allocate "generic" space and sub-allocate out of that, if possible. - * Otherwise just allocate through H5F_alloc(). + * Otherwise just allocate through H5F__alloc(). */ if((f->shared->feature_flags & aggr->feature_flag) && f->shared->fs_strategy != H5F_FSPACE_STRATEGY_NONE) { haddr_t aggr_frag_addr = HADDR_UNDEF; /* Address of aggregrator fragment */ @@ -193,18 +195,18 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz #endif /* H5MF_AGGR_DEBUG */ /* Turn off alignment if allocation < threshold */ - alignment = H5F_ALIGNMENT(f); - if(!((alignment > 1) && (size >= H5F_THRESHOLD(f)))) - alignment = 0; /* no alignment */ + alignment = H5F_ALIGNMENT(f); + if(!((alignment > 1) && (size >= H5F_THRESHOLD(f)))) + alignment = 0; /* no alignment */ /* Generate fragment if aggregator is mis-aligned */ - if(alignment && H5F_addr_gt(aggr->addr, 0) && (aggr_mis_align = (aggr->addr + H5F_BASE_ADDR(f)) % alignment)) { - aggr_frag_addr = aggr->addr; - aggr_frag_size = alignment - aggr_mis_align; - } /* end if */ + if(alignment && H5F_addr_gt(aggr->addr, 0) && (aggr_mis_align = (aggr->addr + H5F_BASE_ADDR(f)) % alignment)) { + aggr_frag_addr = aggr->addr; + aggr_frag_size = alignment - aggr_mis_align; + } /* end if */ - alloc_type = aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; - other_alloc_type = other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; + alloc_type = aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; + other_alloc_type = other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; /* Check if the space requested is larger than the space left in the block */ if((size + aggr_frag_size) > aggr->size) { @@ -212,73 +214,74 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz /* Check if the block asked for is too large for 'normal' aggregator block */ if(size >= aggr->alloc_size) { - hsize_t ext_size = size + aggr_frag_size; + hsize_t ext_size = size + aggr_frag_size; /* Check for overlapping into file's temporary allocation space */ if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - if((aggr->addr > 0) && (extended = H5F__try_extend(f, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") - else if (extended) { - /* aggr->size is unchanged */ - ret_value = aggr->addr + aggr_frag_size; - aggr->addr += ext_size; - aggr->tot_size += ext_size; - } else { + if((aggr->addr > 0) && (extended = H5F__try_extend(f, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") + else if(extended) { + /* aggr->size is unchanged */ + ret_value = aggr->addr + aggr_frag_size; + aggr->addr += ext_size; + aggr->tot_size += ext_size; + } + else { /* Release "other" aggregator, if it exists, is at the end of the allocated space, * has allocated more than one block and the unallocated space is greater than its * allocation block size. */ - if((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && - (other_aggr->tot_size > other_aggr->size) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { + if((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && + (other_aggr->tot_size > other_aggr->size) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { if(H5MF__aggr_free(f, other_alloc_type, other_aggr) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation block") - } /* end if */ + } /* end if */ /* Allocate space from the VFD (i.e. at the end of the file) */ - if(HADDR_UNDEF == (ret_value = H5F__alloc(f, alloc_type, size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") + if(HADDR_UNDEF == (ret_value = H5F__alloc(f, alloc_type, size, &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") } /* end else */ } /* end if */ - else { - hsize_t ext_size = aggr->alloc_size; + else { + hsize_t ext_size = aggr->alloc_size; /* Allocate another block */ #ifdef H5MF_AGGR_DEBUG HDfprintf(stderr, "%s: Allocating block\n", FUNC); #endif /* H5MF_AGGR_DEBUG */ - if(aggr_frag_size > (ext_size - size)) - ext_size += (aggr_frag_size - (ext_size - size)); + if(aggr_frag_size > (ext_size - size)) + ext_size += (aggr_frag_size - (ext_size - size)); /* Check for overlapping into file's temporary allocation space */ if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - if((aggr->addr > 0) && (extended = H5F__try_extend(f, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") - else if(extended) { - aggr->addr += aggr_frag_size; - aggr->size += (ext_size - aggr_frag_size); - aggr->tot_size += ext_size; - } /* end else-if */ - else { + if((aggr->addr > 0) && (extended = H5F__try_extend(f, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") + else if(extended) { + aggr->addr += aggr_frag_size; + aggr->size += (ext_size - aggr_frag_size); + aggr->tot_size += ext_size; + } /* end else-if */ + else { haddr_t new_space; /* Address of new space allocated */ /* Release "other" aggregator, if it exists, is at the end of the allocated space, * has allocated more than one block and the unallocated space is greater than its * allocation block size. */ - if((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && - (other_aggr->tot_size > other_aggr->size) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { + if((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && + (other_aggr->tot_size > other_aggr->size) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { if(H5MF__aggr_free(f, other_alloc_type, other_aggr) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation block") - } /* end if */ + } /* end if */ /* Allocate space from the VFD (i.e. at the end of the file) */ - if(HADDR_UNDEF == (new_space = H5F__alloc(f, alloc_type, aggr->alloc_size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") + if(HADDR_UNDEF == (new_space = H5F__alloc(f, alloc_type, aggr->alloc_size, &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") /* Return the unused portion of the block to a free list */ if(aggr->size > 0) @@ -307,32 +310,32 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); } /* end else */ } /* end else */ - /* Allocate space out of the metadata block */ - ret_value = aggr->addr; - aggr->size -= size; - aggr->addr += size; + /* Allocate space out of the metadata block */ + ret_value = aggr->addr; + aggr->size -= size; + aggr->addr += size; } /* end else */ - /* Freeing any possible fragment due to file allocation */ - if(eoa_frag_size) - if(H5MF_xfree(f, alloc_type, eoa_frag_addr, eoa_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") + /* Freeing any possible fragment due to file allocation */ + if(eoa_frag_size) + if(H5MF_xfree(f, alloc_type, eoa_frag_addr, eoa_frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") - /* Freeing any possible fragment due to alignment in the block after extension */ + /* Freeing any possible fragment due to alignment in the block after extension */ if(extended && aggr_frag_size) - if(H5MF_xfree(f, alloc_type, aggr_frag_addr, aggr_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") + if(H5MF_xfree(f, alloc_type, aggr_frag_addr, aggr_frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") } /* end if */ else { /* Allocate space out of the block */ - ret_value = aggr->addr + aggr_frag_size; - aggr->size -= (size + aggr_frag_size); - aggr->addr += (size + aggr_frag_size); - - /* free any possible fragment */ - if(aggr_frag_size) - if(H5MF_xfree(f, alloc_type, aggr_frag_addr, aggr_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") + ret_value = aggr->addr + aggr_frag_size; + aggr->size -= (size + aggr_frag_size); + aggr->addr += (size + aggr_frag_size); + + /* free any possible fragment */ + if(aggr_frag_size) + if(H5MF_xfree(f, alloc_type, aggr_frag_addr, aggr_frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") } /* end else */ } /* end if */ else { @@ -341,10 +344,10 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") /* Check if fragment was generated */ - if(eoa_frag_size) + if(eoa_frag_size) /* Put fragment on the free list */ - if(H5MF_xfree(f, type, eoa_frag_addr, eoa_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") + if(H5MF_xfree(f, type, eoa_frag_addr, eoa_frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") } /* end else */ /* Sanity check for overlapping into file's temporary allocation space */ @@ -403,53 +406,53 @@ H5MF__aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, /* Check if this aggregator is active */ if(f->shared->feature_flags & aggr->feature_flag) { /* - * If the block being tested adjoins the beginning of the aggregator + * If the block being tested adjoins the beginning of the aggregator * block, check if the aggregator can accomodate the extension. */ if(H5F_addr_eq(blk_end, aggr->addr)) { - haddr_t eoa; /* EOA for the file */ - - /* Get the EOA for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") - - /* If the aggregator is at the end of file: */ - if(H5F_addr_eq(eoa, aggr->addr + aggr->size)) { - /* If extra_requested is below percentage threshold, extend block into the aggregator. */ - if(extra_requested <= (hsize_t)(EXTEND_THRESHOLD * (float)aggr->size)) { - aggr->size -= extra_requested; - aggr->addr += extra_requested; - - /* Indicate success */ - HGOTO_DONE(TRUE); - } /* end if */ - /* - * If extra_requested is above percentage threshold: - * 1) "bubble" up the aggregator by aggr->alloc_size or extra_requested - * 2) extend the block into the aggregator - */ - else { - hsize_t extra = (extra_requested < aggr->alloc_size) ? aggr->alloc_size : extra_requested; + haddr_t eoa; /* EOA for the file */ + + /* Get the EOA for the file */ + if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") + + /* If the aggregator is at the end of file: */ + if(H5F_addr_eq(eoa, aggr->addr + aggr->size)) { + /* If extra_requested is below percentage threshold, extend block into the aggregator. */ + if(extra_requested <= (hsize_t)(EXTEND_THRESHOLD * (float)aggr->size)) { + aggr->size -= extra_requested; + aggr->addr += extra_requested; + + /* Indicate success */ + HGOTO_DONE(TRUE); + } /* end if */ + /* + * If extra_requested is above percentage threshold: + * 1) "bubble" up the aggregator by aggr->alloc_size or extra_requested + * 2) extend the block into the aggregator + */ + else { + hsize_t extra = (extra_requested < aggr->alloc_size) ? aggr->alloc_size : extra_requested; if((ret_value = H5F__try_extend(f, type, (aggr->addr + aggr->size), extra)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") - else if(ret_value == TRUE) { - /* Shift the aggregator block by the extra requested */ + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") + else if(ret_value == TRUE) { + /* Shift the aggregator block by the extra requested */ /* (allocates the space for the extra_requested) */ - aggr->addr += extra_requested; + aggr->addr += extra_requested; - /* Add extra to the aggregator's total allocated amount */ - aggr->tot_size += extra; + /* Add extra to the aggregator's total allocated amount */ + aggr->tot_size += extra; /* Account for any space added to the aggregator */ /* (either 0 (if extra_requested > aggr->alloc_size) or * (aggr->alloc_size - extra_requested) -QAK */ - aggr->size += extra; - aggr->size -= extra_requested; - } /* end else-if */ - } /* end else */ - } /* end if */ + aggr->size += extra; + aggr->size -= extra_requested; + } /* end else-if */ + } /* end else */ + } /* end if */ else { /* The aggreator is not at end of file */ /* Check if aggregator has enough internal space to satisfy the extension. */ @@ -461,8 +464,8 @@ H5MF__aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, /* Indicate success */ HGOTO_DONE(TRUE); } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ } /* end if */ done: @@ -471,7 +474,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5MF_aggr_can_absorb + * Function: H5MF__aggr_can_absorb * * Purpose: Check if a section adjoins an aggregator block and one can * absorb the other. @@ -486,12 +489,12 @@ done: *------------------------------------------------------------------------- */ htri_t -H5MF_aggr_can_absorb(const H5F_t *f, const H5F_blk_aggr_t *aggr, +H5MF__aggr_can_absorb(const H5F_t *f, const H5F_blk_aggr_t *aggr, const H5MF_free_section_t *sect, H5MF_shrink_type_t *shrink) { htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Check args */ HDassert(f); @@ -506,7 +509,7 @@ H5MF_aggr_can_absorb(const H5F_t *f, const H5F_blk_aggr_t *aggr, if(H5F_addr_eq((sect->sect_info.addr + sect->sect_info.size), aggr->addr) || H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)) { #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: section {%a, %Hu} adjoins aggr = {%a, %Hu}\n", "H5MF_aggr_can_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); +HDfprintf(stderr, "%s: section {%a, %Hu} adjoins aggr = {%a, %Hu}\n", "H5MF__aggr_can_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); #endif /* H5MF_AGGR_DEBUG */ /* Check if aggregator would get too large and should be absorbed into section */ if((aggr->size + sect->sect_info.size) >= aggr->alloc_size) @@ -521,11 +524,11 @@ HDfprintf(stderr, "%s: section {%a, %Hu} adjoins aggr = {%a, %Hu}\n", "H5MF_aggr done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF_aggr_can_absorb() */ +} /* end H5MF__aggr_can_absorb() */ /*------------------------------------------------------------------------- - * Function: H5MF_aggr_absorb + * Function: H5MF__aggr_absorb * * Purpose: Absorb a free space section into an aggregator block or * vice versa. @@ -539,10 +542,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5MF_aggr_absorb(const H5F_t H5_ATTR_UNUSED *f, H5F_blk_aggr_t *aggr, H5MF_free_section_t *sect, +H5MF__aggr_absorb(const H5F_t H5_ATTR_UNUSED *f, H5F_blk_aggr_t *aggr, H5MF_free_section_t *sect, hbool_t allow_sect_absorb) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Check args */ HDassert(f); @@ -556,7 +559,7 @@ H5MF_aggr_absorb(const H5F_t H5_ATTR_UNUSED *f, H5F_blk_aggr_t *aggr, H5MF_free_ /* Check if the section adjoins the beginning or end of the aggregator */ if(H5F_addr_eq((sect->sect_info.addr + sect->sect_info.size), aggr->addr)) { #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins front of section = {%a, %Hu}\n", "H5MF_aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, sect->sect_info.size); +HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins front of section = {%a, %Hu}\n", "H5MF__aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, sect->sect_info.size); #endif /* H5MF_AGGR_DEBUG */ /* Absorb aggregator onto end of section */ sect->sect_info.size += aggr->size; @@ -566,7 +569,7 @@ HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins front of section = {%a, %Hu}\n", " HDassert(H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)); #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins end of section = {%a, %Hu}\n", "H5MF_aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, sect->sect_info.size); +HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins end of section = {%a, %Hu}\n", "H5MF__aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, sect->sect_info.size); #endif /* H5MF_AGGR_DEBUG */ /* Absorb aggregator onto beginning of section */ sect->sect_info.addr -= aggr->size; @@ -582,7 +585,7 @@ HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins end of section = {%a, %Hu}\n", "H5 /* Check if the section adjoins the beginning or end of the aggregator */ if(H5F_addr_eq((sect->sect_info.addr + sect->sect_info.size), aggr->addr)) { #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: section {%a, %Hu} adjoins front of aggr = {%a, %Hu}\n", "H5MF_aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); +HDfprintf(stderr, "%s: section {%a, %Hu} adjoins front of aggr = {%a, %Hu}\n", "H5MF__aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); #endif /* H5MF_AGGR_DEBUG */ /* Absorb section onto front of aggregator */ aggr->addr -= sect->sect_info.size; @@ -598,7 +601,7 @@ HDfprintf(stderr, "%s: section {%a, %Hu} adjoins front of aggr = {%a, %Hu}\n", " HDassert(H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)); #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: section {%a, %Hu} adjoins end of aggr = {%a, %Hu}\n", "H5MF_aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); +HDfprintf(stderr, "%s: section {%a, %Hu} adjoins end of aggr = {%a, %Hu}\n", "H5MF__aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); #endif /* H5MF_AGGR_DEBUG */ /* Absorb section onto end of aggregator */ aggr->size += sect->sect_info.size; @@ -608,11 +611,11 @@ HDfprintf(stderr, "%s: section {%a, %Hu} adjoins end of aggr = {%a, %Hu}\n", "H5 } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5MF_aggr_absorb() */ +} /* end H5MF__aggr_absorb() */ /*------------------------------------------------------------------------- - * Function: H5MF_aggr_query + * Function: H5MF__aggr_query * * Purpose: Query a block aggregator's current address & size info * @@ -625,10 +628,10 @@ HDfprintf(stderr, "%s: section {%a, %Hu} adjoins end of aggr = {%a, %Hu}\n", "H5 *------------------------------------------------------------------------- */ herr_t -H5MF_aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, haddr_t *addr, +H5MF__aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, haddr_t *addr, hsize_t *size) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Check args */ HDassert(f); @@ -644,7 +647,7 @@ H5MF_aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, haddr_t *addr, } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5MF_aggr_query() */ +} /* end H5MF__aggr_query() */ /*------------------------------------------------------------------------- @@ -737,11 +740,11 @@ H5MF_free_aggrs(H5F_t *f) HDassert(f->shared->lf); /* Retrieve metadata aggregator info, if available */ - if(H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) + if(H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") /* Retrieve 'small data' aggregator info, if available */ - if(H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) + if(H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") /* Make certain we release the aggregator that's later in the file first */ @@ -774,7 +777,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5MF_aggr_can_shrink_eoa + * Function: H5MF__aggr_can_shrink_eoa * * Purpose: Check if the remaining space in the aggregator is at EOA * @@ -786,12 +789,12 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5MF_aggr_can_shrink_eoa(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr) +H5MF__aggr_can_shrink_eoa(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr) { haddr_t eoa = HADDR_UNDEF; /* EOA for the file */ htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Sanity check */ HDassert(f); @@ -808,7 +811,7 @@ H5MF_aggr_can_shrink_eoa(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_aggr_can_shrink_eoa() */ +} /* H5MF__aggr_can_shrink_eoa() */ /*------------------------------------------------------------------------- @@ -882,17 +885,17 @@ H5MF_aggrs_try_shrink_eoa(H5F_t *f) HDassert(f); HDassert(f->shared); - if((ma_status = H5MF_aggr_can_shrink_eoa(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr))) < 0) + if((ma_status = H5MF__aggr_can_shrink_eoa(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr))) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") if(ma_status > 0) - if(H5MF__aggr_free(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") + if(H5MF__aggr_free(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") - if((sda_status = H5MF_aggr_can_shrink_eoa(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr))) < 0) + if((sda_status = H5MF__aggr_can_shrink_eoa(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr))) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") if(sda_status > 0) - if(H5MF__aggr_free(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") + if(H5MF__aggr_free(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") ret_value = (ma_status || sda_status); diff --git a/src/H5MFdbg.c b/src/H5MFdbg.c index 592ca87..eedb72e 100644 --- a/src/H5MFdbg.c +++ b/src/H5MFdbg.c @@ -67,6 +67,7 @@ typedef struct { /* Local Prototypes */ /********************/ +static herr_t H5MF__sects_debug_cb(H5FS_section_info_t *_sect, void *_udata); /*********************/ /* Package Variables */ @@ -84,7 +85,7 @@ typedef struct { /*------------------------------------------------------------------------- - * Function: H5MF_sects_debug_cb + * Function: H5MF__sects_debug_cb * * Purpose: Prints debugging info about a free space section for a file * @@ -97,13 +98,13 @@ typedef struct { *------------------------------------------------------------------------- */ static herr_t -H5MF_sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) +H5MF__sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) { H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; /* Section to dump info */ H5MF_debug_iter_ud_t *udata = (H5MF_debug_iter_ud_t *)_udata; /* User data for callbacks */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* * Check arguments. @@ -136,7 +137,7 @@ H5MF_sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF_sects_debug_cb() */ +} /* end H5MF__sects_debug_cb() */ /*------------------------------------------------------------------------- @@ -184,7 +185,7 @@ H5MF_sects_debug(H5F_t *f, haddr_t fs_addr, FILE *stream, int indent, int fwidth udata.fwidth = fwidth; /* Iterate over all the free space sections */ - if(H5FS_sect_iterate(f, f->shared->fs_man[type], H5MF_sects_debug_cb, &udata) < 0) + if(H5FS_sect_iterate(f, f->shared->fs_man[type], H5MF__sects_debug_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") /* Close the free space information */ @@ -201,7 +202,7 @@ done: #ifdef H5MF_ALLOC_DEBUG_DUMP /*------------------------------------------------------------------------- - * Function: H5MF_sects_dump + * Function: H5MF__sects_dump * * Purpose: Prints debugging info about free space sections for a file. * @@ -221,7 +222,7 @@ H5MF_sects_dump(H5F_t *f, FILE *stream) int fwidth = 50; /* Field width */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) + FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG, FAIL) #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: Dumping file free space sections\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ @@ -234,7 +235,7 @@ HDfprintf(stderr, "%s: Dumping file free space sections\n", FUNC); /* Retrieve the 'eoa' for the file */ if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: for type = H5FD_MEM_DEFAULT, eoa = %a\n", FUNC, eoa); #endif /* H5MF_ALLOC_DEBUG */ @@ -276,13 +277,13 @@ HDfprintf(stderr, "%s: for type = H5FD_MEM_DEFAULT, eoa = %a\n", FUNC, eoa); hsize_t sda_size = 0; /* Size of "small data aggregator" */ /* Retrieve metadata aggregator info, if available */ - H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); + H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: ma_addr = %a, ma_size = %Hu, end of ma = %a\n", FUNC, ma_addr, ma_size, (haddr_t)((ma_addr + ma_size) - 1)); #endif /* H5MF_ALLOC_DEBUG */ /* Retrieve 'small data' aggregator info, if available */ - H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size); + H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size); #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: sda_addr = %a, sda_size = %Hu, end of sda = %a\n", FUNC, sda_addr, sda_size, (haddr_t)((sda_addr + sda_size) - 1)); #endif /* H5MF_ALLOC_DEBUG */ @@ -303,7 +304,7 @@ HDfprintf(stderr, "%s: sda_addr = %a, sda_size = %Hu, end of sda = %a\n", FUNC, HDfprintf(stream, "%*sSections:\n", indent + 3, ""); /* If there is a free space manager for this type, iterate over them */ - if(f->shared->fs.aggr.fs_man[atype]) { + if(f->shared->fs_man[atype]) { H5MF_debug_iter_ud_t udata; /* User data for callbacks */ /* Prepare user data for section iteration callback */ @@ -327,6 +328,6 @@ HDfprintf(stderr, "%s: sda_addr = %a, sda_size = %Hu, end of sda = %a\n", FUNC, done: HDfprintf(stderr, "%s: Done dumping file free space sections\n", FUNC); FUNC_LEAVE_NOAPI_TAG(ret_value) -} /* end H5MF_sects_dump() */ +} /* end H5MF__sects_dump() */ #endif /* H5MF_ALLOC_DEBUG_DUMP */ diff --git a/src/H5MFpkg.h b/src/H5MFpkg.h index fbf9ee8..ec4aab4 100644 --- a/src/H5MFpkg.h +++ b/src/H5MFpkg.h @@ -12,12 +12,12 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol <koziol@hdfgroup.org> - * Tuesday, January 8, 2008 + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Tuesday, January 8, 2008 * - * Purpose: This file contains declarations which are visible only within - * the H5MF package. Source files outside the H5MF package should - * include H5MFprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5MF package. Source files outside the H5MF package should + * include H5MFprivate.h instead. */ #if !(defined H5MF_FRIEND || defined H5MF_MODULE) #error "Do not include this file outside the H5MF package!" @@ -186,24 +186,24 @@ H5_DLL herr_t H5MF__start_fstype(H5F_t *f, H5F_mem_page_t type); H5_DLL htri_t H5MF__find_sect(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5FS_t *fspace, haddr_t *addr); H5_DLL herr_t H5MF__add_sect(H5F_t *f, H5FD_mem_t alloc_type, H5FS_t *fspace, H5MF_free_section_t *node); -H5_DLL herr_t H5MF_sects_dump(H5F_t *f, FILE *stream); +H5_DLL herr_t H5MF__sects_dump(H5F_t *f, FILE *stream); -H5_DLL void H5MF_alloc_to_fs_type(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5F_mem_page_t *fs_type); +H5_DLL void H5MF__alloc_to_fs_type(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5F_mem_page_t *fs_type); /* 'simple/small/large' section routines */ -H5_DLL H5MF_free_section_t *H5MF_sect_new(unsigned ctype, haddr_t sect_off, +H5_DLL H5MF_free_section_t *H5MF__sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size); -H5_DLL herr_t H5MF_sect_free(H5FS_section_info_t *sect); +H5_DLL herr_t H5MF__sect_free(H5FS_section_info_t *sect); /* Block aggregator routines */ H5_DLL htri_t H5MF__aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, H5FD_mem_t type, haddr_t abs_blk_end, hsize_t extra_requested); -H5_DLL htri_t H5MF_aggr_can_absorb(const H5F_t *f, const H5F_blk_aggr_t *aggr, +H5_DLL htri_t H5MF__aggr_can_absorb(const H5F_t *f, const H5F_blk_aggr_t *aggr, const H5MF_free_section_t *sect, H5MF_shrink_type_t *shrink); -H5_DLL herr_t H5MF_aggr_absorb(const H5F_t *f, H5F_blk_aggr_t *aggr, +H5_DLL herr_t H5MF__aggr_absorb(const H5F_t *f, H5F_blk_aggr_t *aggr, H5MF_free_section_t *sect, hbool_t allow_sect_absorb); -H5_DLL herr_t H5MF_aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, +H5_DLL herr_t H5MF__aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, haddr_t *addr, hsize_t *size); /* Testing routines */ diff --git a/src/H5MFsection.c b/src/H5MFsection.c index fe140a7..3ebc5c8 100644 --- a/src/H5MFsection.c +++ b/src/H5MFsection.c @@ -56,44 +56,40 @@ /********************/ /* 'simple/small/large' section callbacks */ -static H5FS_section_info_t *H5MF_sect_deserialize(const H5FS_section_class_t *cls, +static H5FS_section_info_t *H5MF__sect_deserialize(const H5FS_section_class_t *cls, const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags); -static herr_t H5MF_sect_valid(const H5FS_section_class_t *cls, +static herr_t H5MF__sect_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t *sect); -static H5FS_section_info_t *H5MF_sect_split(H5FS_section_info_t *sect, +static H5FS_section_info_t *H5MF__sect_split(H5FS_section_info_t *sect, hsize_t frag_size); /* 'simple' section callbacks */ -static htri_t H5MF_sect_simple_can_merge(const H5FS_section_info_t *sect1, +static htri_t H5MF__sect_simple_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, void *udata); -static herr_t H5MF_sect_simple_merge(H5FS_section_info_t **sect1, +static herr_t H5MF__sect_simple_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); -static htri_t H5MF_sect_simple_can_shrink(const H5FS_section_info_t *_sect, +static htri_t H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *udata); -static herr_t H5MF_sect_simple_shrink(H5FS_section_info_t **_sect, +static herr_t H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, void *udata); /* 'small' section callbacks */ -static herr_t H5MF_sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata); -static htri_t H5MF_sect_small_can_merge(const H5FS_section_info_t *sect1, +static herr_t H5MF__sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata); +static htri_t H5MF__sect_small_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, void *udata); -static herr_t H5MF_sect_small_merge(H5FS_section_info_t **sect1, +static herr_t H5MF__sect_small_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); -static htri_t H5MF_sect_small_can_shrink(const H5FS_section_info_t *_sect, - void *udata); -static herr_t H5MF_sect_small_shrink(H5FS_section_info_t **_sect, - void *udata); /* 'large' section callbacks */ -static htri_t H5MF_sect_large_can_merge(const H5FS_section_info_t *sect1, +static htri_t H5MF__sect_large_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, void *udata); -static herr_t H5MF_sect_large_merge(H5FS_section_info_t **sect1, +static herr_t H5MF__sect_large_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); -static htri_t H5MF_sect_large_can_shrink(const H5FS_section_info_t *_sect, +static htri_t H5MF__sect_large_can_shrink(const H5FS_section_info_t *_sect, void *udata); -static herr_t H5MF_sect_large_shrink(H5FS_section_info_t **_sect, +static herr_t H5MF__sect_large_shrink(H5FS_section_info_t **_sect, void *udata); /*********************/ @@ -115,14 +111,14 @@ H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1] = {{ /* Object methods */ NULL, /* Add section */ NULL, /* Serialize section */ - H5MF_sect_deserialize, /* Deserialize section */ - H5MF_sect_simple_can_merge, /* Can sections merge? */ - H5MF_sect_simple_merge, /* Merge sections */ - H5MF_sect_simple_can_shrink, /* Can section shrink container?*/ - H5MF_sect_simple_shrink, /* Shrink container w/section */ - H5MF_sect_free, /* Free section */ - H5MF_sect_valid, /* Check validity of section */ - H5MF_sect_split, /* Split section node for alignment */ + H5MF__sect_deserialize, /* Deserialize section */ + H5MF__sect_simple_can_merge, /* Can sections merge? */ + H5MF__sect_simple_merge, /* Merge sections */ + H5MF__sect_simple_can_shrink, /* Can section shrink container?*/ + H5MF__sect_simple_shrink, /* Shrink container w/section */ + H5MF__sect_free, /* Free section */ + H5MF__sect_valid, /* Check validity of section */ + H5MF__sect_split, /* Split section node for alignment */ NULL, /* Dump debugging for section */ }}; @@ -139,16 +135,16 @@ H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1] = {{ NULL, /* Terminate section class */ /* Object methods */ - H5MF_sect_small_add, /* Add section */ + H5MF__sect_small_add, /* Add section */ NULL, /* Serialize section */ - H5MF_sect_deserialize, /* Deserialize section */ - H5MF_sect_small_can_merge, /* Can sections merge? */ - H5MF_sect_small_merge, /* Merge sections */ - NULL, /* Can section shrink container?*/ - NULL, /* Shrink container w/section */ - H5MF_sect_free, /* Free section */ - H5MF_sect_valid, /* Check validity of section */ - H5MF_sect_split, /* Split section node for alignment */ + H5MF__sect_deserialize, /* Deserialize section */ + H5MF__sect_small_can_merge, /* Can sections merge? */ + H5MF__sect_small_merge, /* Merge sections */ + NULL, /* Can section shrink container?*/ + NULL, /* Shrink container w/section */ + H5MF__sect_free, /* Free section */ + H5MF__sect_valid, /* Check validity of section */ + H5MF__sect_split, /* Split section node for alignment */ NULL, /* Dump debugging for section */ }}; @@ -167,14 +163,14 @@ H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1] = {{ /* Object methods */ NULL, /* Add section */ NULL, /* Serialize section */ - H5MF_sect_deserialize, /* Deserialize section */ - H5MF_sect_large_can_merge, /* Can sections merge? */ - H5MF_sect_large_merge, /* Merge sections */ - H5MF_sect_large_can_shrink, /* Can section shrink container?*/ - H5MF_sect_large_shrink, /* Shrink container w/section */ - H5MF_sect_free, /* Free section */ - H5MF_sect_valid, /* Check validity of section */ - H5MF_sect_split, /* Split section node for alignment */ + H5MF__sect_deserialize, /* Deserialize section */ + H5MF__sect_large_can_merge, /* Can sections merge? */ + H5MF__sect_large_merge, /* Merge sections */ + H5MF__sect_large_can_shrink, /* Can section shrink container?*/ + H5MF__sect_large_shrink, /* Shrink container w/section */ + H5MF__sect_free, /* Free section */ + H5MF__sect_valid, /* Check validity of section */ + H5MF__sect_split, /* Split section node for alignment */ NULL, /* Dump debugging for section */ }}; @@ -196,7 +192,7 @@ H5FL_DEFINE(H5MF_free_section_t); /*------------------------------------------------------------------------- - * Function: H5MF_sect_new + * Function: H5MF__sect_new * * Purpose: Create a new section of "ctype" and return it to the caller * @@ -209,12 +205,12 @@ H5FL_DEFINE(H5MF_free_section_t); *------------------------------------------------------------------------- */ H5MF_free_section_t * -H5MF_sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size) +H5MF__sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size) { H5MF_free_section_t *sect; /* 'Simple' free space section to add */ H5MF_free_section_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Check arguments. */ HDassert(sect_size); @@ -236,11 +232,11 @@ H5MF_sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF_sect_new() */ +} /* end H5MF__sect_new() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_free + * Function: H5MF__sect_free * * Purpose: Free a 'simple/small/large' section node * @@ -253,11 +249,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5MF_sect_free(H5FS_section_info_t *_sect) +H5MF__sect_free(H5FS_section_info_t *_sect) { H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; /* File free section */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Check arguments. */ HDassert(sect); @@ -266,11 +262,11 @@ H5MF_sect_free(H5FS_section_info_t *_sect) sect = H5FL_FREE(H5MF_free_section_t, sect); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MF_sect_free() */ +} /* H5MF__sect_free() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_deserialize + * Function: H5MF__sect_deserialize * * Purpose: Deserialize a buffer into a "live" section * @@ -283,14 +279,14 @@ H5MF_sect_free(H5FS_section_info_t *_sect) *------------------------------------------------------------------------- */ static H5FS_section_info_t * -H5MF_sect_deserialize(const H5FS_section_class_t *cls, +H5MF__sect_deserialize(const H5FS_section_class_t *cls, const uint8_t H5_ATTR_UNUSED *buf, haddr_t sect_addr, hsize_t sect_size, unsigned H5_ATTR_UNUSED *des_flags) { H5MF_free_section_t *sect; /* New section */ H5FS_section_info_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(cls); @@ -298,7 +294,7 @@ H5MF_sect_deserialize(const H5FS_section_class_t *cls, HDassert(sect_size); /* Create free space section for block */ - if(NULL == (sect = H5MF_sect_new(cls->type, sect_addr, sect_size))) + if(NULL == (sect = H5MF__sect_new(cls->type, sect_addr, sect_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't initialize free space section") /* Set return value */ @@ -306,11 +302,11 @@ H5MF_sect_deserialize(const H5FS_section_class_t *cls, done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_deserialize() */ +} /* H5MF__sect_deserialize() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_valid + * Function: H5MF__sect_valid * * Purpose: Check the validity of a section * @@ -323,7 +319,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5MF_sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, +H5MF__sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5FS_section_info_t #ifdef NDEBUG H5_ATTR_UNUSED @@ -334,17 +330,17 @@ H5MF_sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ #endif /* NDEBUG */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MF_sect_valid() */ +} /* H5MF__sect_valid() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_split + * Function: H5MF__sect_split * * Purpose: Split SECT into 2 sections: fragment for alignment & the aligned section * SECT's addr and size are updated to point to the aligned section @@ -357,14 +353,14 @@ H5MF_sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, *------------------------------------------------------------------------- */ static H5FS_section_info_t * -H5MF_sect_split(H5FS_section_info_t *sect, hsize_t frag_size) +H5MF__sect_split(H5FS_section_info_t *sect, hsize_t frag_size) { H5MF_free_section_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Allocate space for new section */ - if(NULL == (ret_value = H5MF_sect_new(sect->type, sect->addr, frag_size))) + if(NULL == (ret_value = H5MF__sect_new(sect->type, sect->addr, frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't initialize free space section") /* Set new section's info */ @@ -373,14 +369,14 @@ H5MF_sect_split(H5FS_section_info_t *sect, hsize_t frag_size) done: FUNC_LEAVE_NOAPI((H5FS_section_info_t *)ret_value) -} /* end H5MF_sect_split() */ +} /* end H5MF__sect_split() */ /* * "simple" section callbacks */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_simple_can_merge + * Function: H5MF__sect_simple_can_merge * * Purpose: Can two sections of this type merge? * @@ -395,14 +391,14 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5MF_sect_simple_can_merge(const H5FS_section_info_t *_sect1, +H5MF__sect_simple_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) { const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ const H5MF_free_section_t *sect2 = (const H5MF_free_section_t *)_sect2; /* File free section */ htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect1); @@ -414,11 +410,11 @@ H5MF_sect_simple_can_merge(const H5FS_section_info_t *_sect1, ret_value = H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr); FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_simple_can_merge() */ +} /* H5MF__sect_simple_can_merge() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_simple_merge + * Function: H5MF__sect_simple_merge * * Purpose: Merge two sections of this type * @@ -433,14 +429,14 @@ H5MF_sect_simple_can_merge(const H5FS_section_info_t *_sect1, *------------------------------------------------------------------------- */ static herr_t -H5MF_sect_simple_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, +H5MF__sect_simple_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) { H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ H5MF_free_section_t *sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(sect1); @@ -453,16 +449,16 @@ H5MF_sect_simple_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2 (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ - if(H5MF_sect_free((H5FS_section_info_t *)sect2) < 0) + if(H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_simple_merge() */ +} /* H5MF__sect_simple_merge() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_simple_can_shrink + * Function: H5MF__sect_simple_can_shrink * * Purpose: Can this section shrink the container? * @@ -475,7 +471,7 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5MF_sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) +H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) { const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ @@ -483,7 +479,7 @@ H5MF_sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) haddr_t end; /* End of section to extend */ htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(sect); @@ -518,7 +514,7 @@ HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect- htri_t status; /* Status from aggregator adjoin */ /* See if section can absorb the aggregator & vice versa */ - if((status = H5MF_aggr_can_absorb(udata->f, &(udata->f->shared->meta_aggr), sect, &(udata->shrink))) < 0) + if((status = H5MF__aggr_can_absorb(udata->f, &(udata->f->shared->meta_aggr), sect, &(udata->shrink))) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "error merging section with aggregation block") else if(status > 0) { /* Set the aggregator to operate on */ @@ -537,7 +533,7 @@ HDfprintf(stderr, "%s: section {%a, %Hu}, adjoins metadata aggregator\n", FUNC, htri_t status; /* Status from aggregator adjoin */ /* See if section can absorb the aggregator & vice versa */ - if((status = H5MF_aggr_can_absorb(udata->f, &(udata->f->shared->sdata_aggr), sect, &(udata->shrink))) < 0) + if((status = H5MF__aggr_can_absorb(udata->f, &(udata->f->shared->sdata_aggr), sect, &(udata->shrink))) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "error merging section with aggregation block") else if(status > 0) { /* Set the aggregator to operate on */ @@ -557,11 +553,11 @@ HDfprintf(stderr, "%s: section {%a, %Hu}, adjoins small data aggregator\n", FUNC done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_simple_can_shrink() */ +} /* H5MF__sect_simple_can_shrink() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_simple_shrink + * Function: H5MF__sect_simple_shrink * * Purpose: Shrink container with section * @@ -574,13 +570,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5MF_sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) +H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) { H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* File free section */ H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(sect); @@ -601,14 +597,14 @@ H5MF_sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) HDassert(udata->aggr); /* Absorb the section into the aggregator or vice versa */ - if(H5MF_aggr_absorb(udata->f, udata->aggr, *sect, udata->allow_sect_absorb) < 0) + if(H5MF__aggr_absorb(udata->f, udata->aggr, *sect, udata->allow_sect_absorb) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't absorb section into aggregator or vice versa") } /* end else */ /* Check for freeing section */ if(udata->shrink != H5MF_SHRINK_SECT_ABSORB_AGGR) { /* Free section */ - if(H5MF_sect_free((H5FS_section_info_t *)*sect) < 0) + if(H5MF__sect_free((H5FS_section_info_t *)*sect) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") /* Mark section as freed, for free space manager */ @@ -617,7 +613,7 @@ H5MF_sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_simple_shrink() */ +} /* H5MF__sect_simple_shrink() */ /* * "small" section callbacks @@ -625,7 +621,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5MF_sect_small_add + * Function: H5MF__sect_small_add * * Purpose: Perform actions on a small "meta" action before adding it to the free space manager: * 1) Drop the section if it is at page end and its size <= page end threshold @@ -640,7 +636,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5MF_sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata) +H5MF__sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata) { H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* Fractal heap free section */ H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ @@ -648,7 +644,7 @@ H5MF_sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata) hsize_t rem, prem; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #ifdef H5MF_ALLOC_DEBUG_MORE HDfprintf(stderr, "%s: Entering, section {%a, %Hu}\n", FUNC, (*sect)->sect_info.addr, (*sect)->sect_info.size); @@ -664,7 +660,7 @@ HDfprintf(stderr, "%s: Entering, section {%a, %Hu}\n", FUNC, (*sect)->sect_info. /* Drop the section if it is at page end and its size is <= pgend threshold */ if(!rem && (*sect)->sect_info.size <= H5F_PGEND_META_THRES(udata->f) && (*flags & H5FS_ADD_RETURNED_SPACE)) { - if(H5MF_sect_free((H5FS_section_info_t *)(*sect)) < 0) + if(H5MF__sect_free((H5FS_section_info_t *)(*sect)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") *sect = NULL; *flags &= (unsigned)~H5FS_ADD_RETURNED_SPACE; @@ -684,122 +680,11 @@ HDfprintf(stderr, "%s: section is adjusted {%a, %Hu}\n", FUNC, (*sect)->sect_inf done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_small_add() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF_sect_small_can_shrink - * - * Purpose: Can this section shrink the container? - * - * Note: A small section is allowed to shrink only at closing. - * - * Note: This is unused currently, to maintain the invariant that the - * file size is always a multiple of the page size. - * - * (This function should probably be deleted, or the invariant - * relaxed) - * - * Return: Success: non-negative (TRUE/FALSE) - * Failure: negative - * - * Programmer: Vailin Choi; Dec 2012 - * - *------------------------------------------------------------------------- - */ -static htri_t -H5MF_sect_small_can_shrink(const H5FS_section_info_t *_sect, void *_udata) -{ - const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ - H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ - haddr_t eoa; /* End of address space in the file */ - haddr_t end; /* End of section to extend */ - htri_t ret_value = FALSE; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Check arguments. */ - HDassert(sect); - HDassert(udata); - HDassert(udata->f); - - /* Retrieve the end of the file's address space */ - if(HADDR_UNDEF == (eoa = H5FD_get_eoa(udata->f->shared->lf, udata->alloc_type))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") - - /* Compute address of end of section to check */ - end = sect->sect_info.addr + sect->sect_info.size; - - /* Check if the section is exactly at the end of the allocated space in the file */ - if(H5F_addr_eq(end, eoa) && sect->sect_info.size == udata->f->shared->fs_page_size) { - udata->shrink = H5MF_SHRINK_EOA; - -#ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect->sect_info.addr, sect->sect_info.size, eoa); -#endif /* H5MF_ALLOC_DEBUG_MORE */ - - /* Indicate shrinking can occur */ - HGOTO_DONE(TRUE) - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_small_can_shrink() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF_sect_small_shrink - * - * Purpose: Shrink container with section - * - * Note: This is unused currently, to maintain the invariant that the - * file size is always a multiple of the page size. - * - * (This function should probably be deleted, or the invariant - * relaxed) - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Vailin Choi; Dec 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5MF_sect_small_shrink(H5FS_section_info_t **_sect, void *_udata) -{ - H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* File free section */ - H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Check arguments. */ - HDassert(sect); - HDassert((*sect)->sect_info.type == H5MF_FSPACE_SECT_SMALL); - HDassert(udata); - HDassert(udata->f); - HDassert(udata->shrink == H5MF_SHRINK_EOA); - HDassert(H5F_INTENT(udata->f) & H5F_ACC_RDWR); - - /* Release section's space at EOA */ - if(H5F__free(udata->f, udata->alloc_type, (*sect)->sect_info.addr, (*sect)->sect_info.size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "driver free request failed") - - /* Free section */ - if(H5MF_sect_free((H5FS_section_info_t *)*sect) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") - - /* Mark section as freed, for free space manager */ - *sect = NULL; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_small_shrink() */ +} /* H5MF__sect_small_add() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_small_can_merge + * Function: H5MF__sect_small_can_merge * * Purpose: Can two sections of this type merge? * @@ -814,7 +699,7 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5MF_sect_small_can_merge(const H5FS_section_info_t *_sect1, +H5MF__sect_small_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, void *_udata) { const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ @@ -822,7 +707,7 @@ H5MF_sect_small_can_merge(const H5FS_section_info_t *_sect1, H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect1); @@ -842,11 +727,11 @@ HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_small_can_merge() */ +} /* H5MF__sect_small_can_merge() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_small_merge + * Function: H5MF__sect_small_merge * * Purpose: Merge two sections of this type * @@ -862,7 +747,7 @@ HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); *------------------------------------------------------------------------- */ static herr_t -H5MF_sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, +H5MF__sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void *_udata) { H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ @@ -870,7 +755,7 @@ H5MF_sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(sect1); @@ -894,18 +779,18 @@ H5MF_sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, if(H5PB_remove_entry(udata->f, (*sect1)->sect_info.addr) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free merged section") - if(H5MF_sect_free((H5FS_section_info_t *)(*sect1)) < 0) + if(H5MF__sect_free((H5FS_section_info_t *)(*sect1)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") *sect1 = NULL; } /* end if */ /* Get rid of second section */ - if(H5MF_sect_free((H5FS_section_info_t *)sect2) < 0) + if(H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_small_merge() */ +} /* H5MF__sect_small_merge() */ /* * "Large" section callbacks @@ -913,7 +798,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5MF_sect_large_can_merge (same as H5MF_sect_simple_can_merge) + * Function: H5MF__sect_large_can_merge (same as H5MF__sect_simple_can_merge) * * Purpose: Can two sections of this type merge? * @@ -927,14 +812,14 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5MF_sect_large_can_merge(const H5FS_section_info_t *_sect1, +H5MF__sect_large_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) { const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ const H5MF_free_section_t *sect2 = (const H5MF_free_section_t *)_sect2; /* File free section */ htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect1); @@ -949,11 +834,11 @@ HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_large_can_merge() */ +} /* H5MF__sect_large_can_merge() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_large_merge (same as H5MF_sect_simple_merge) + * Function: H5MF__sect_large_merge (same as H5MF__sect_simple_merge) * * Purpose: Merge two sections of this type * @@ -967,14 +852,14 @@ HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); *------------------------------------------------------------------------- */ static herr_t -H5MF_sect_large_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, +H5MF__sect_large_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) { H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ H5MF_free_section_t *sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(sect1); @@ -987,16 +872,16 @@ H5MF_sect_large_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ - if(H5MF_sect_free((H5FS_section_info_t *)sect2) < 0) + if(H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_large_merge() */ +} /* H5MF__sect_large_merge() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_large_can_shrink + * Function: H5MF__sect_large_can_shrink * * Purpose: Can this section shrink the container? * @@ -1008,7 +893,7 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5MF_sect_large_can_shrink(const H5FS_section_info_t *_sect, void *_udata) +H5MF__sect_large_can_shrink(const H5FS_section_info_t *_sect, void *_udata) { const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ @@ -1016,7 +901,7 @@ H5MF_sect_large_can_shrink(const H5FS_section_info_t *_sect, void *_udata) haddr_t end; /* End of section to extend */ htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(sect); @@ -1045,11 +930,11 @@ HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect- done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_large_can_shrink() */ +} /* H5MF__sect_large_can_shrink() */ /*------------------------------------------------------------------------- - * Function: H5MF_sect_large_shrink + * Function: H5MF__sect_large_shrink * * Purpose: Shrink a large-sized section * @@ -1061,14 +946,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5MF_sect_large_shrink(H5FS_section_info_t **_sect, void *_udata) +H5MF__sect_large_shrink(H5FS_section_info_t **_sect, void *_udata) { H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* File free section */ H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ hsize_t frag_size = 0; /* Fragment size */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(sect); @@ -1091,7 +976,7 @@ H5MF_sect_large_shrink(H5FS_section_info_t **_sect, void *_udata) (*sect)->sect_info.size = frag_size; else { /* Free section */ - if(H5MF_sect_free((H5FS_section_info_t *)*sect) < 0) + if(H5MF__sect_free((H5FS_section_info_t *)*sect) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") /* Mark section as freed, for free space manager */ @@ -1100,5 +985,5 @@ H5MF_sect_large_shrink(H5FS_section_info_t **_sect, void *_udata) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF_sect_large_shrink() */ +} /* H5MF__sect_large_shrink() */ @@ -435,63 +435,70 @@ done: /*------------------------------------------------------------------------- - * Function: H5Oget_info + * Function: H5Oget_info2 * - * Purpose: Retrieve information about an object. + * Purpose: Retrieve information about an object. * - * Return: Success: Non-negative - * Failure: Negative + * NOTE: Add a parameter "fields" to indicate selection of object info. * - * Programmer: Quincey Koziol - * November 21 2006 + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * July 7 2010 * *------------------------------------------------------------------------- */ herr_t -H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) +H5Oget_info2(hid_t loc_id, H5O_info_t *oinfo, unsigned fields) { - H5G_loc_t loc; /* Location of group */ + H5G_loc_t loc; /* Location of group */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", loc_id, oinfo); + H5TRACE3("e", "i*xIu", loc_id, oinfo, fields); /* Check args */ if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if(fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Retrieve the object's information */ - if(H5O__get_info_by_name(&loc, ".", oinfo/*out*/) < 0) + if(H5O__get_info_by_name(&loc, ".", oinfo/*out*/, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: FUNC_LEAVE_API(ret_value) -} /* end H5Oget_info() */ +} /* end H5Oget_info2() */ -/*------------------------------------------------------------------------- - * Function: H5Oget_info_by_name - * - * Purpose: Retrieve information about an object. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * November 21 2006 - * - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Function: H5Oget_info_by_name2 + * + * Purpose: Retrieve information about an object. + * + * NOTE: Add a parameter "fields" to indicate selection of object info. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * July 7 2010 + * + *------------------------------------------------------------------------- + */ herr_t -H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) +H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info_t *oinfo, + unsigned fields, hid_t lapl_id) { H5G_loc_t loc; /* Location of group */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE4("e", "i*s*xi", loc_id, name, oinfo, lapl_id); + H5TRACE5("e", "i*s*xIui", loc_id, name, oinfo, fields, lapl_id); /* Check args */ if(H5G_loc(loc_id, &loc) < 0) @@ -500,44 +507,48 @@ H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lap HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if(fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Retrieve the object's information */ - if(H5O__get_info_by_name(&loc, name, oinfo/*out*/) < 0) + if(H5O__get_info_by_name(&loc, name, oinfo/*out*/, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) done: FUNC_LEAVE_API(ret_value) -} /* end H5Oget_info_by_name() */ +} /* end H5Oget_info_by_name2() */ /*------------------------------------------------------------------------- - * Function: H5Oget_info_by_idx + * Function: H5Oget_info_by_idx2 * - * Purpose: Retrieve information about an object, according to the order + * Purpose: Retrieve information about an object, according to the order * of an index. * - * Return: Success: Non-negative - * Failure: Negative + * NOTE: Add a parameter "fields" to indicate selection of object info. + * + * Return: Success: Non-negative + * Failure: Negative * * Programmer: Quincey Koziol - * November 26 2006 + * November 26 2006 * *------------------------------------------------------------------------- */ herr_t -H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, hid_t lapl_id) +H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, unsigned fields, hid_t lapl_id) { H5G_loc_t loc; /* Location of group */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*sIiIoh*xi", loc_id, group_name, idx_type, order, n, oinfo, - lapl_id); + H5TRACE8("e", "i*sIiIoh*xIui", loc_id, group_name, idx_type, order, n, oinfo, + fields, lapl_id); /* Check args */ if(H5G_loc(loc_id, &loc) < 0) @@ -550,18 +561,20 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if(fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Retrieve the object's information */ - if(H5O__get_info_by_idx(&loc, group_name, idx_type, order, n, oinfo) < 0) + if(H5O__get_info_by_idx(&loc, group_name, idx_type, order, n, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: FUNC_LEAVE_API(ret_value) -} /* end H5Oget_info_by_idx() */ +} /* end H5Oget_info_by_idx2() */ /*------------------------------------------------------------------------- @@ -737,9 +750,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5Ovisit + * Function: H5Ovisit2 * - * Purpose: Recursively visit an object and all the objects reachable + * Purpose: Recursively visit an object and all the objects reachable * from it. If the starting object is a group, all the objects * linked to from that group will be visited. Links within * each group are visited according to the order within the @@ -755,27 +768,30 @@ done: * iteration index and iteration order given) will be used to in * the callback about the object. * - * Return: Success: The return value of the first operator that + * NOTE: Add a a parameter "fields" to indicate selection of + * object info to be retrieved to the callback "op". + * + * Return: Success: The return value of the first operator that * returns non-zero, or zero if all members were * processed with no operator returning non-zero. * - * Failure: Negative if something goes wrong within the + * Failure: Negative if something goes wrong within the * library, or the negative value returned by one * of the operators. * * Programmer: Quincey Koziol - * November 25 2007 + * November 25 2007 * *------------------------------------------------------------------------- */ herr_t -H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate_t op, void *op_data) +H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate_t op, void *op_data, unsigned fields) { herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "iIiIox*x", obj_id, idx_type, order, op, op_data); + H5TRACE6("e", "iIiIox*xIu", obj_id, idx_type, order, op, op_data, fields); /* Check args */ if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -784,20 +800,22 @@ H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + if(fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Call internal object visitation routine */ - if((ret_value = H5O__visit(obj_id, ".", idx_type, order, op, op_data)) < 0) + if((ret_value = H5O__visit(obj_id, ".", idx_type, order, op, op_data, fields)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: FUNC_LEAVE_API(ret_value) -} /* end H5Ovisit() */ +} /* end H5Ovisit2() */ /*------------------------------------------------------------------------- - * Function: H5Ovisit_by_name + * Function: H5Ovisit_by_name2 * - * Purpose: Recursively visit an object and all the objects reachable + * Purpose: Recursively visit an object and all the objects reachable * from it. If the starting object is a group, all the objects * linked to from that group will be visited. Links within * each group are visited according to the order within the @@ -813,28 +831,31 @@ done: * iteration index and iteration order given) will be used to in * the callback about the object. * - * Return: Success: The return value of the first operator that + * NOTE: Add a a parameter "fields" to indicate selection of + * object info to be retrieved to the callback "op". + * + * Return: Success: The return value of the first operator that * returns non-zero, or zero if all members were * processed with no operator returning non-zero. * - * Failure: Negative if something goes wrong within the + * Failure: Negative if something goes wrong within the * library, or the negative value returned by one * of the operators. * * Programmer: Quincey Koziol - * November 24 2007 + * November 24 2007 * *------------------------------------------------------------------------- */ herr_t -H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id) +H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields, hid_t lapl_id) { herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*sIiIox*xi", loc_id, obj_name, idx_type, order, op, op_data, - lapl_id); + H5TRACE8("e", "i*sIiIox*xIui", loc_id, obj_name, idx_type, order, op, op_data, + fields, lapl_id); /* Check args */ if(!obj_name || !*obj_name) @@ -845,18 +866,20 @@ H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + if(fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Call internal object visitation routine */ - if((ret_value = H5O__visit(loc_id, obj_name, idx_type, order, op, op_data)) < 0) + if((ret_value = H5O__visit(loc_id, obj_name, idx_type, order, op, op_data, fields)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: FUNC_LEAVE_API(ret_value) -} /* end H5Ovisit_by_name() */ +} /* end H5Ovisit_by_name2() */ /*------------------------------------------------------------------------- diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c new file mode 100644 index 0000000..876579d --- /dev/null +++ b/src/H5Odeprec.c @@ -0,0 +1,332 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Purpose: Deprecated functions from the H5O interface. These + * functions are here for compatibility purposes and may be + * removed in the future. Applications should switch to the + * newer APIs. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Opkg.h" /* Object headers */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + +#ifndef H5_NO_DEPRECATED_SYMBOLS + + +/*------------------------------------------------------------------------- + * Function: H5Oget_info1 + * + * Purpose: Retrieve information about an object. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5Oget_info1(hid_t loc_id, H5O_info_t *oinfo) +{ + H5G_loc_t loc; /* Location of group */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*x", loc_id, oinfo); + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + + /* Retrieve the object's information */ + if(H5O__get_info_by_name(&loc, ".", oinfo/*out*/, H5O_INFO_ALL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_info1() */ + + +/*------------------------------------------------------------------------- + * Function: H5Oget_info_by_name1 + * + * Purpose: Retrieve information about an object. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) +{ + H5G_loc_t loc; /* Location of group */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "i*s*xi", loc_id, name, oinfo, lapl_id); + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + if(!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + + /* Verify access property list and set up collective metadata if appropriate */ + if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Retrieve the object's information */ + if(H5O__get_info_by_name(&loc, name, oinfo/*out*/, H5O_INFO_ALL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_info_by_name1() */ + + +/*------------------------------------------------------------------------- + * Function: H5Oget_info_by_idx1 + * + * Purpose: Retrieve information about an object, according to the order + * of an index. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 26 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, hid_t lapl_id) +{ + H5G_loc_t loc; /* Location of group */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "i*sIiIoh*xi", loc_id, group_name, idx_type, order, n, oinfo, + lapl_id); + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!group_name || !*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if(!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + + /* Verify access property list and set up collective metadata if appropriate */ + if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Retrieve the object's information */ + if(H5O__get_info_by_idx(&loc, group_name, idx_type, order, n, oinfo, H5O_INFO_ALL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") + +done: + /* Release the object location */ + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_info_by_idx1() */ + + +/*------------------------------------------------------------------------- + * Function: H5Ovisit1 + * + * Purpose: Recursively visit an object and all the objects reachable + * from it. If the starting object is a group, all the objects + * linked to from that group will be visited. Links within + * each group are visited according to the order within the + * specified index (unless the specified index does not exist for + * a particular group, then the "name" index is used). + * + * NOTE: Soft links and user-defined links are ignored during + * this operation. + * + * NOTE: Each _object_ reachable from the initial group will only + * be visited once. If multiple hard links point to the same + * object, the first link to the object's path (according to the + * iteration index and iteration order given) will be used to in + * the callback about the object. + * + * Return: Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + * Programmer: Quincey Koziol + * November 25 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate_t op, void *op_data) +{ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "iIiIox*x", obj_id, idx_type, order, op, op_data); + + /* Check args */ + if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if(!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + + /* Call internal object visitation routine */ + if((ret_value = H5O__visit(obj_id, ".", idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Ovisit1() */ + + +/*------------------------------------------------------------------------- + * Function: H5Ovisit_by_name1 + * + * Purpose: Recursively visit an object and all the objects reachable + * from it. If the starting object is a group, all the objects + * linked to from that group will be visited. Links within + * each group are visited according to the order within the + * specified index (unless the specified index does not exist for + * a particular group, then the "name" index is used). + * + * NOTE: Soft links and user-defined links are ignored during + * this operation. + * + * NOTE: Each _object_ reachable from the initial group will only + * be visited once. If multiple hard links point to the same + * object, the first link to the object's path (according to the + * iteration index and iteration order given) will be used to in + * the callback about the object. + * + * Return: Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + * Programmer: Quincey Koziol + * November 24 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id) +{ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "i*sIiIox*xi", loc_id, obj_name, idx_type, order, op, op_data, + lapl_id); + + /* Check args */ + if(!obj_name || !*obj_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if(!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + + /* Verify access property list and set up collective metadata if appropriate */ + if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Call internal object visitation routine */ + if((ret_value = H5O__visit(loc_id, obj_name, idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Ovisit_by_name1() */ + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + diff --git a/src/H5Oint.c b/src/H5Oint.c index c9e82c0..2752a25 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -61,6 +61,7 @@ typedef struct { H5SL_t *visited; /* Skip list for tracking visited nodes */ H5O_iterate_t op; /* Application callback */ void *op_data; /* Application's op data */ + unsigned fields; /* Selection of object info */ } H5O_iter_visit_ud_t; @@ -2211,20 +2212,22 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) /*------------------------------------------------------------------------- - * Function: H5O_get_info + * Function: H5O_get_info * - * Purpose: Retrieve the information for an object + * Purpose: Retrieve the information for an object * - * Return: Success: Non-negative - * Failure: Negative + * Note: Add a parameter "fields" to indicate selection of object info. + * + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Quincey Koziol - * November 21 2006 + * Programmer: Quincey Koziol + * November 21 2006 * *------------------------------------------------------------------------- */ herr_t -H5O_get_info(const H5O_loc_t *loc, hbool_t want_ih_info, H5O_info_t *oinfo) +H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields) { const H5O_obj_class_t *obj_class; /* Class of object for header */ H5O_t *oh = NULL; /* Object header */ @@ -2240,76 +2243,83 @@ H5O_get_info(const H5O_loc_t *loc, hbool_t want_ih_info, H5O_info_t *oinfo) if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") - /* Reset the object info structure */ - HDmemset(oinfo, 0, sizeof(*oinfo)); - - /* Retrieve the file's fileno */ - H5F_GET_FILENO(loc->file, oinfo->fileno); - - /* Set the object's address */ - oinfo->addr = loc->addr; - /* Get class for object */ if(NULL == (obj_class = H5O__obj_class_real(oh))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class") - /* Retrieve the type of the object */ - oinfo->type = obj_class->type; + /* Reset the object info structure */ + HDmemset(oinfo, 0, sizeof(*oinfo)); - /* Set the object's reference count */ - oinfo->rc = oh->nlink; + /* Get basic information, if requested */ + if(fields & H5O_INFO_BASIC) { + /* Retrieve the file's fileno */ + H5F_GET_FILENO(loc->file, oinfo->fileno); - /* Get modification time for object */ - if(oh->version > H5O_VERSION_1) { - oinfo->atime = oh->atime; - oinfo->mtime = oh->mtime; - oinfo->ctime = oh->ctime; - oinfo->btime = oh->btime; - } /* end if */ - else { - htri_t exists; /* Flag if header message of interest exists */ + /* Set the object's address */ + oinfo->addr = loc->addr; - /* No information for access & modification fields */ - /* (we stopped updating the "modification time" header message for - * raw data changes, so the "modification time" header message - * is closest to the 'change time', in POSIX terms - QAK) - */ - oinfo->atime = 0; - oinfo->mtime = 0; - oinfo->btime = 0; - - /* Might be information for modification time */ - if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_ID)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME message") - if(exists > 0) { - /* Get "old style" modification time info */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_MTIME_ID, &oinfo->ctime)) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME message") + /* Retrieve the type of the object */ + oinfo->type = obj_class->type; + + /* Set the object's reference count */ + oinfo->rc = oh->nlink; + } + + /* Get time information, if requested */ + if(fields & H5O_INFO_TIME) { + if(oh->version > H5O_VERSION_1) { + oinfo->atime = oh->atime; + oinfo->mtime = oh->mtime; + oinfo->ctime = oh->ctime; + oinfo->btime = oh->btime; } /* end if */ else { - /* Check for "new style" modification time info */ - if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_NEW_ID)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME_NEW message") - if(exists > 0) { - /* Get "new style" modification time info */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_MTIME_NEW_ID, &oinfo->ctime)) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME_NEW message") + htri_t exists; /* Flag if header message of interest exists */ + + /* No information for access & modification fields */ + /* (we stopped updating the "modification time" header message for + * raw data changes, so the "modification time" header message + * is closest to the 'change time', in POSIX terms - QAK) + */ + oinfo->atime = 0; + oinfo->mtime = 0; + oinfo->btime = 0; + + /* Might be information for modification time */ + if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_ID)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME message") + if(exists > 0) { + /* Get "old style" modification time info */ + if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_MTIME_ID, &oinfo->ctime)) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME message") } /* end if */ - else - oinfo->ctime = 0; - } /* end else */ - } /* end else */ + else { + /* Check for "new style" modification time info */ + if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_NEW_ID)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME_NEW message") + if(exists > 0) { + /* Get "new style" modification time info */ + if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_MTIME_NEW_ID, &oinfo->ctime)) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME_NEW message") + } /* end if */ + else + oinfo->ctime = 0; + } /* end else */ + } /* end else */ + } /* end if */ - /* Get the information for the object header */ - if(H5O__get_hdr_info_real(oh, &oinfo->hdr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info") + /* Get the information for the object header, if requested */ + if(fields & H5O_INFO_HDR) + if(H5O__get_hdr_info_real(oh, &oinfo->hdr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info") /* Retrieve # of attributes */ - if(H5O_attr_count_real(loc->file, oh, &oinfo->num_attrs) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute count") + if(fields & H5O_INFO_NUM_ATTRS) + if(H5O_attr_count_real(loc->file, oh, &oinfo->num_attrs) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute count") /* Get B-tree & heap metadata storage size, if requested */ - if(want_ih_info) { + if(fields & H5O_INFO_META_SIZE) { /* Check for 'bh_info' callback for this type of object */ if(obj_class->bh_info) /* Call the object's class 'bh_info' routine */ @@ -2317,9 +2327,10 @@ H5O_get_info(const H5O_loc_t *loc, hbool_t want_ih_info, H5O_info_t *oinfo) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info") /* Get B-tree & heap info for any attributes */ - if(oinfo->num_attrs > 0) + if(!(fields & H5O_INFO_NUM_ATTRS) || oinfo->num_attrs > 0) { if(H5O__attr_bh_info(loc->file, oh, &oinfo->meta_size.attr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info") + } /* end if */ } /* end if */ done: @@ -2338,16 +2349,18 @@ done: * Note: This routine is needed so that there's a non-API routine * that can set up VOL / SWMR info (which need a DXPL). * - * Return: Success: Non-negative - * Failure: Negative + * Note: Add a parameter "fields" to indicate selection of object info. + * + * Return: Success: Non-negative + * Failure: Negative * * Programmer: Quincey Koziol - * December 28, 2017 + * December 28, 2017 * *------------------------------------------------------------------------- */ herr_t -H5O__get_info_by_name(const H5G_loc_t *loc, const char *name, H5O_info_t *oinfo) +H5O__get_info_by_name(const H5G_loc_t *loc, const char *name, H5O_info_t *oinfo, unsigned fields) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2359,7 +2372,7 @@ H5O__get_info_by_name(const H5G_loc_t *loc, const char *name, H5O_info_t *oinfo) HDassert(oinfo); /* Retrieve the object's information */ - if(H5G_loc_info(loc, name, TRUE, oinfo/*out*/) < 0) + if(H5G_loc_info(loc, name, oinfo/*out*/, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") done: @@ -2376,17 +2389,19 @@ done: * Note: This routine is needed so that there's a non-API routine * that can set up VOL / SWMR info (which need a DXPL). * - * Return: Success: Non-negative - * Failure: Negative + * Note: Add a parameter "fields" to indicate selection of object info. * - * Programmer: Quincey Koziol - * December 28, 2017 + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * December 28, 2017 * *------------------------------------------------------------------------- */ herr_t H5O__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo) + H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, unsigned fields) { H5G_loc_t obj_loc; /* Location used to open group */ H5G_name_t obj_path; /* Opened object group hier. path */ @@ -2412,7 +2427,7 @@ H5O__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t id loc_found = TRUE; /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, TRUE, oinfo) < 0) + if(H5O_get_info(obj_loc.oloc, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") done: @@ -2793,7 +2808,7 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *li H5O_info_t oinfo; /* Object info */ /* Get the object's info */ - if(H5O_get_info(&obj_oloc, TRUE, &oinfo) < 0) + if(H5O_get_info(&obj_oloc, &oinfo, udata->fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get object info") /* Make the application callback */ @@ -2833,7 +2848,7 @@ done: /*------------------------------------------------------------------------- * Function: H5O__visit * - * Purpose: Recursively visit an object and all the objects reachable + * Purpose: Recursively visit an object and all the objects reachable * from it. If the starting object is a group, all the objects * linked to from that group will be visited. Links within * each group are visited according to the order within the @@ -2849,22 +2864,24 @@ done: * iteration index and iteration order given) will be used to in * the callback about the object. * - * Return: Success: The return value of the first operator that + * Note: Add a parameter "fields" to indicate selection of object info. + * + * Return: Success: The return value of the first operator that * returns non-zero, or zero if all members were * processed with no operator returning non-zero. * - * Failure: Negative if something goes wrong within the + * Failure: Negative if something goes wrong within the * library, or the negative value returned by one * of the operators. * * Programmer: Quincey Koziol - * November 24 2007 + * November 24 2007 * *------------------------------------------------------------------------- */ herr_t H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data) + H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields) { H5O_iter_visit_ud_t udata; /* User data for callback */ H5G_loc_t loc; /* Location of reference object */ @@ -2896,7 +2913,7 @@ H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_found = TRUE; /* Get the object's info */ - if(H5O_get_info(&obj_oloc, TRUE, &oinfo) < 0) + if(H5O_get_info(&obj_oloc, &oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info") /* Open the object */ @@ -2925,6 +2942,7 @@ H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, udata.start_loc = &start_loc; udata.op = op; udata.op_data = op_data; + udata.fields = fields; /* Create skip list to store visited object information */ if((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL) diff --git a/src/H5Opkg.h b/src/H5Opkg.h index f535e50..616f96b 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -567,15 +567,15 @@ H5_DLL int H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted); H5_DLL herr_t H5O__link(const H5O_loc_t *loc, int adjust); H5_DLL htri_t H5O__exists_by_name(const H5G_loc_t *loc, const char *name); H5_DLL herr_t H5O__get_info_by_name(const H5G_loc_t *loc, const char *name, - H5O_info_t *oinfo); + H5O_info_t *oinfo, unsigned fields); H5_DLL herr_t H5O__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo); + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, unsigned fields); H5_DLL herr_t H5O__set_comment_by_name(const H5G_loc_t *loc, const char *name, const char *comment); H5_DLL ssize_t H5O__get_comment_by_name(const H5G_loc_t *loc, const char *name, char *comment, size_t bufsize); H5_DLL herr_t H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data); + H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields); H5_DLL herr_t H5O__inc_rc(H5O_t *oh); H5_DLL herr_t H5O__dec_rc(H5O_t *oh); H5_DLL herr_t H5O__free(H5O_t *oh); diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 696fd38..10063d5 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -881,8 +881,7 @@ H5_DLL herr_t H5O_bogus_oh(H5F_t *f, H5O_t *oh, unsigned mesg_id, unsigned mesg_ #endif /* H5O_ENABLE_BOGUS */ H5_DLL herr_t H5O_delete(H5F_t *f, haddr_t addr); H5_DLL herr_t H5O_get_hdr_info(const H5O_loc_t *oloc, H5O_hdr_info_t *hdr); -H5_DLL herr_t H5O_get_info(const H5O_loc_t *oloc, hbool_t want_ih_info, - H5O_info_t *oinfo); +H5_DLL herr_t H5O_get_info(const H5O_loc_t *oloc, H5O_info_t *oinfo, unsigned fields); H5_DLL herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type); H5_DLL herr_t H5O_get_create_plist(const H5O_loc_t *loc, struct H5P_genplist_t *oc_plist); H5_DLL hid_t H5O_open_name(const H5G_loc_t *loc, const char *name, hbool_t app_ref); diff --git a/src/H5Opublic.h b/src/H5Opublic.h index 8d6dda4..da2910d 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -73,6 +73,17 @@ #define H5O_SHMESG_MAX_NINDEXES 8 #define H5O_SHMESG_MAX_LIST_SIZE 5000 +/* Flags for H5Oget_info. + * Theses flags determine which fields will be filled in in the H5O_info_t + * struct. + */ +#define H5O_INFO_BASIC 0x0001u /* Fill in the fileno, addr, type, and rc fields */ +#define H5O_INFO_TIME 0x0002u /* Fill in the atime, mtime, ctime, and btime fields */ +#define H5O_INFO_NUM_ATTRS 0x0004u /* Fill in the num_attrs field */ +#define H5O_INFO_HDR 0x0008u /* Fill in the hdr field */ +#define H5O_INFO_META_SIZE 0x0010u /* Fill in the meta_size field */ +#define H5O_INFO_ALL (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS | H5O_INFO_HDR | H5O_INFO_META_SIZE) + /*******************/ /* Public Typedefs */ /*******************/ @@ -156,12 +167,12 @@ H5_DLL hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr); H5_DLL hid_t H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id); H5_DLL htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id); -H5_DLL herr_t H5Oget_info(hid_t loc_id, H5O_info_t *oinfo); -H5_DLL herr_t H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, - hid_t lapl_id); -H5_DLL herr_t H5Oget_info_by_idx(hid_t loc_id, const char *group_name, +H5_DLL herr_t H5Oget_info2(hid_t loc_id, H5O_info_t *oinfo, unsigned fields); +H5_DLL herr_t H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info_t *oinfo, + unsigned fields, hid_t lapl_id); +H5_DLL herr_t H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, - hid_t lapl_id); + unsigned fields, hid_t lapl_id); H5_DLL herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id); H5_DLL herr_t H5Oincr_refcount(hid_t object_id); @@ -174,11 +185,11 @@ H5_DLL herr_t H5Oset_comment_by_name(hid_t loc_id, const char *name, H5_DLL ssize_t H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize); H5_DLL ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, hid_t lapl_id); -H5_DLL herr_t H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate_t op, void *op_data); -H5_DLL herr_t H5Ovisit_by_name(hid_t loc_id, const char *obj_name, +H5_DLL herr_t H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate_t op, void *op_data, unsigned fields); +H5_DLL herr_t H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, - void *op_data, hid_t lapl_id); + void *op_data, unsigned fields, hid_t lapl_id); H5_DLL herr_t H5Oclose(hid_t object_id); H5_DLL herr_t H5Oflush(hid_t obj_id); H5_DLL herr_t H5Orefresh(hid_t oid); @@ -205,7 +216,18 @@ typedef struct H5O_stat_t { } H5O_stat_t; /* Function prototypes */ +H5_DLL herr_t H5Oget_info1(hid_t loc_id, H5O_info_t *oinfo); +H5_DLL herr_t H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info_t *oinfo, + hid_t lapl_id); +H5_DLL herr_t H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, + hid_t lapl_id); +H5_DLL herr_t H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate_t op, void *op_data); +H5_DLL herr_t H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, + H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, + void *op_data, hid_t lapl_id); #endif /* H5_NO_DEPRECATED_SYMBOLS */ #ifdef __cplusplus @@ -254,23 +254,23 @@ H5PB_print_stats(const H5PB_t *page_buf) printf("PAGE BUFFER STATISTICS:\n"); - printf("******* METADATA\n"); - printf("\t Total Accesses: %u\n", page_buf->accesses[0]); - printf("\t Hits: %u\n", page_buf->hits[0]); - printf("\t Misses: %u\n", page_buf->misses[0]); - printf("\t Evictions: %u\n", page_buf->evictions[0]); - printf("\t Bypasses: %u\n", page_buf->bypasses[0]); - printf("\t Hit Rate = %f%%\n", ((double)page_buf->hits[0]/(page_buf->accesses[0] - page_buf->bypasses[0]))*100); - printf("*****************\n\n"); - - printf("******* RAWDATA\n"); - printf("\t Total Accesses: %u\n", page_buf->accesses[1]); - printf("\t Hits: %u\n", page_buf->hits[1]); - printf("\t Misses: %u\n", page_buf->misses[1]); - printf("\t Evictions: %u\n", page_buf->evictions[1]); - printf("\t Bypasses: %u\n", page_buf->bypasses[1]); - printf("\t Hit Rate = %f%%\n", ((double)page_buf->hits[1]/(page_buf->accesses[1]-page_buf->bypasses[0]))*100); - printf("*****************\n\n"); + HDprintf("******* METADATA\n"); + HDprintf("\t Total Accesses: %u\n", page_buf->accesses[0]); + HDprintf("\t Hits: %u\n", page_buf->hits[0]); + HDprintf("\t Misses: %u\n", page_buf->misses[0]); + HDprintf("\t Evictions: %u\n", page_buf->evictions[0]); + HDprintf("\t Bypasses: %u\n", page_buf->bypasses[0]); + HDprintf("\t Hit Rate = %f%%\n", ((double)page_buf->hits[0]/(page_buf->accesses[0] - page_buf->bypasses[0]))*100); + HDprintf("*****************\n\n"); + + HDprintf("******* RAWDATA\n"); + HDprintf("\t Total Accesses: %u\n", page_buf->accesses[1]); + HDprintf("\t Hits: %u\n", page_buf->hits[1]); + HDprintf("\t Misses: %u\n", page_buf->misses[1]); + HDprintf("\t Evictions: %u\n", page_buf->evictions[1]); + HDprintf("\t Bypasses: %u\n", page_buf->bypasses[1]); + HDprintf("\t Hit Rate = %f%%\n", ((double)page_buf->hits[1]/(page_buf->accesses[1]-page_buf->bypasses[0]))*100); + HDprintf("*****************\n\n"); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5PB_print_stats */ diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index e33e762..b56c137 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -152,22 +152,6 @@ #define H5D_XFER_XFORM_COPY H5P__dxfr_xform_copy #define H5D_XFER_XFORM_CMP H5P__dxfr_xform_cmp #define H5D_XFER_XFORM_CLOSE H5P__dxfr_xform_close -/* Definitions for properties of direct chunk write */ -#define H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_SIZE sizeof(hbool_t) -#define H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_DEF FALSE -#define H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_SIZE sizeof(uint32_t) -#define H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_DEF 0 -#define H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_SIZE sizeof(hsize_t *) -#define H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_DEF NULL -#define H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_SIZE sizeof(uint32_t) -#define H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_DEF 0 -/* Definitions for properties of direct chunk read */ -#define H5D_XFER_DIRECT_CHUNK_READ_FLAG_SIZE sizeof(hbool_t) -#define H5D_XFER_DIRECT_CHUNK_READ_FLAG_DEF FALSE -#define H5D_XFER_DIRECT_CHUNK_READ_FILTERS_SIZE sizeof(uint32_t) -#define H5D_XFER_DIRECT_CHUNK_READ_FILTERS_DEF 0 -#define H5D_XFER_DIRECT_CHUNK_READ_OFFSET_SIZE sizeof(hsize_t *) -#define H5D_XFER_DIRECT_CHUNK_READ_OFFSET_DEF NULL /******************/ @@ -266,13 +250,6 @@ static const H5Z_EDC_t H5D_def_enable_edc_g = H5D_XFER_EDC_DEF; /* De static const H5Z_cb_t H5D_def_filter_cb_g = H5D_XFER_FILTER_CB_DEF; /* Default value for filter callback */ static const H5T_conv_cb_t H5D_def_conv_cb_g = H5D_XFER_CONV_CB_DEF; /* Default value for datatype conversion callback */ static const void *H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Default value for data transform */ -static const hbool_t H5D_def_direct_chunk_flag_g = H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_DEF; /* Default value for the flag of direct chunk write */ -static const uint32_t H5D_def_direct_chunk_filters_g = H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_DEF; /* Default value for the filters of direct chunk write */ -static const hsize_t *H5D_def_direct_chunk_offset_g = H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_DEF; /* Default value for the offset of direct chunk write */ -static const uint32_t H5D_def_direct_chunk_datasize_g = H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_DEF; /* Default value for the datasize of direct chunk write */ -static const hbool_t direct_chunk_read_flag = H5D_XFER_DIRECT_CHUNK_READ_FLAG_DEF; /* Default value for the flag of direct chunk read */ -static const hsize_t *direct_chunk_read_offset = H5D_XFER_DIRECT_CHUNK_READ_OFFSET_DEF; /* Default value for the offset of direct chunk read */ -static const uint32_t direct_chunk_read_filters = H5D_XFER_DIRECT_CHUNK_READ_FILTERS_DEF; /* Default value for the filters of direct chunk read */ /*------------------------------------------------------------------------- @@ -423,48 +400,6 @@ H5P__dxfr_reg_prop(H5P_genclass_t *pclass) H5D_XFER_XFORM_DEL, H5D_XFER_XFORM_COPY, H5D_XFER_XFORM_CMP, H5D_XFER_XFORM_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the property of flag for direct chunk write */ - /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P_register_real(pclass, H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME, H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_SIZE, &H5D_def_direct_chunk_flag_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the property of filter for direct chunk write */ - /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P_register_real(pclass, H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME, H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_SIZE, &H5D_def_direct_chunk_filters_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the property of offset for direct chunk write */ - /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P_register_real(pclass, H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_NAME, H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_SIZE, &H5D_def_direct_chunk_offset_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the property of datasize for direct chunk write */ - /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P_register_real(pclass, H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME, H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_SIZE, &H5D_def_direct_chunk_datasize_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the property of flag for direct chunk read */ - /* (Note: this property should not have an encode/decode callback) */ - if(H5P_register_real(pclass, H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME, H5D_XFER_DIRECT_CHUNK_READ_FLAG_SIZE, &direct_chunk_read_flag, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the property of filter for direct chunk read */ - /* (Note: this property should not have an encode/decode callback) */ - if(H5P_register_real(pclass, H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME, H5D_XFER_DIRECT_CHUNK_READ_FILTERS_SIZE, &direct_chunk_read_filters, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the property of offset for direct chunk read */ - /* (Note: this property should not have an encode/decode callback) */ - if(H5P_register_real(pclass, H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME, H5D_XFER_DIRECT_CHUNK_READ_OFFSET_SIZE, &direct_chunk_read_offset, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_reg_prop() */ @@ -141,7 +141,7 @@ done: void *ref; IN: Reference to open. RETURNS - Valid ID on success, Negative on failure + Valid ID on success, H5I_INVALID_HID on failure DESCRIPTION Given a reference to some object, open that object and return an ID for that object. @@ -203,7 +203,7 @@ done: void *ref; IN: Reference to open. RETURNS - Valid ID on success, Negative on failure + Valid ID on success, H5I_INVALID_HID on failure DESCRIPTION Given a reference to some object, creates a copy of the dataset pointed to's dataspace and defines a selection in the copy which is the region @@ -311,7 +311,7 @@ done: when passing in the size) RETURNS - Non-negative length of the path on success, Negative on failure + Non-negative length of the path on success, -1 on failure DESCRIPTION Given a reference to some object, determine a path to the object referenced in the file. @@ -335,23 +335,23 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name, H5F_t *file; /* File object */ ssize_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE5("Zs", "iRt*x*sz", id, ref_type, _ref, name, size); /* Check args */ if (H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a location") if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type") if (_ref == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference pointer") /* Get the file pointer from the entry */ file = loc.oloc->file; /* Get name */ if((ret_value = H5R__get_name(file, id, ref_type, _ref, name, size)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object path") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to determine object path") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index 2f41f7d..fb62430 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -141,7 +141,7 @@ done: * ref IN: Reference to open * * Return: Success: Valid HDF5 ID - * Failure: Negative + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ diff --git a/src/H5Rint.c b/src/H5Rint.c index 02f7778..acf6b56 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -587,7 +587,7 @@ done: H5F_t *file; IN: File the object being dereferenced is within H5R_type_t ref_type; IN: Type of reference to query void *ref; IN: Reference to query. - H5O_type_t *obj_type; OUT: The type of the object, set on success + H5O_type_t *obj_type; OUT: The type of the object, set on success RETURNS Non-negative on success/Negative on failure @@ -678,12 +678,12 @@ done: hid_t lapl_id; IN: LAPL to use for operation hid_t id; IN: Location ID given for reference H5R_type_t ref_type; IN: Type of reference - void *ref; IN: Reference to query. + void *_ref; IN: Reference to query. char *name; OUT: Buffer to place name of object referenced size_t size; IN: Size of name buffer RETURNS - Non-negative length of the path on success, Negative on failure + Non-negative length of the path on success, -1 on failure DESCRIPTION Given a reference to some object, determine a path to the object referenced in the file. @@ -732,7 +732,7 @@ H5R__get_name(H5F_t *f, hid_t id, H5R_type_t ref_type, const void *_ref, /* Get the dataset region from the heap (allocate inside routine) */ if ((buf = (uint8_t *)H5HG_read(oloc.file, &hobjid, NULL, NULL)) == NULL) - HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") + HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, (-1), "Unable to read dataset region information") /* Get the object oid for the dataset */ p = buf; @@ -747,22 +747,21 @@ H5R__get_name(H5F_t *f, hid_t id, H5R_type_t ref_type, const void *_ref, case H5R_BADTYPE: case H5R_MAXTYPE: default: - HDassert("unknown reference type" && 0); - HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, (-1), "internal error (unknown reference type)") } /* end switch */ /* Retrieve file ID for name search */ - if ((file_id = H5I_get_file_id(id, FALSE)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve file ID") + if ((file_id = H5F_get_id(f, FALSE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get file ID") /* Get name, length, etc. */ if ((ret_value = H5G_get_name_by_addr(file_id, &oloc, name, size)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't determine name") + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't determine name") done: /* Close file ID used for search */ if (file_id > 0 && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID") + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, (-1), "can't decrement ref count of temp ID") FUNC_LEAVE_NOAPI_VOL(ret_value) } /* end H5R__get_name() */ diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h index 49261eb..fbbff50 100644 --- a/src/H5Rpkg.h +++ b/src/H5Rpkg.h @@ -26,6 +26,11 @@ #include "H5Rprivate.h" /* Other private headers needed by this file */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ + /**************************/ /* Package Private Macros */ @@ -26,7 +26,6 @@ #include "H5Fprivate.h" /* Files */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ #include "H5Spkg.h" /* Dataspaces */ @@ -208,6 +207,58 @@ H5S_term_package(void) FUNC_LEAVE_NOAPI(n) } /* end H5S_term_package() */ + + +/*-------------------------------------------------------------------------- + NAME + H5S_get_validiated_dataspace + PURPOSE + Get a pointer to a validated H5S_t pointer + USAGE + H5S_t *H5S_get_validated_space(dataspace_id, space) + hid_t space_id; IN: The ID of the dataspace + const H5S_t * space; OUT: A pointer to the dataspace + RETURNS + SUCCEED/FAIL + DESCRIPTION + Gets a pointer to a dataspace struct after validating it. The pointer + can be NULL (if the ID is H5S_ALL, for example). + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(space); + + if (space_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid space_id (ID cannot be a negative number)") + + if (H5S_ALL == space_id) { + /* No special dataspace struct for H5S_ALL */ + *space = NULL; + } + else { + /* Get the dataspace pointer */ + if (NULL == (*space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "space_id is not a dataspace ID") + + /* Check for valid selection */ + if (H5S_SELECT_VALID(*space) != TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection + offset not within extent") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5S_get_validated_dataspace() */ + /*-------------------------------------------------------------------------- NAME diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index b4ae1ff..15ce75d 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -215,6 +215,7 @@ H5_DLL herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size); H5_DLL herr_t H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, const hsize_t *max); H5_DLL H5S_t *H5S_create(H5S_class_t type); +H5_DLL herr_t H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space/*out*/); 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_version(H5F_t *f, H5S_t *ds); diff --git a/src/H5vers.txt b/src/H5vers.txt index 0303bf5..914c30e 100644 --- a/src/H5vers.txt +++ b/src/H5vers.txt @@ -56,6 +56,11 @@ FUNCTION: H5Ewalk; H5E_walk, H5E_error; v10, v18 FUNCTION: H5Fget_info; H5F_info; v18, v110 FUNCTION: H5Gcreate; ; v10, v18 FUNCTION: H5Gopen; ; v10, v18 +FUNCTION: H5Oget_info; ; v18, v112 +FUNCTION: H5Oget_info_by_name; ; v18, v112 +FUNCTION: H5Oget_info_by_idx; ; v18, v112 +FUNCTION: H5Ovisit; ; v18, v112 +FUNCTION: H5Ovisit_by_name; ; v18, v112 FUNCTION: H5Pget_filter; ; v10, v18 FUNCTION: H5Pget_filter_by_id; ; v16, v18 FUNCTION: H5Pinsert; ; v14, v18 diff --git a/src/Makefile.am b/src/Makefile.am index 21f3966..a0defad 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -80,7 +80,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5HP.c H5I.c H5Itest.c H5L.c H5Lexternal.c H5lib_settings.c \ H5MF.c H5MFaggr.c H5MFdbg.c H5MFsection.c \ H5MM.c H5MP.c H5MPtest.c \ - H5O.c H5Oainfo.c H5Oalloc.c H5Oattr.c \ + H5O.c H5Odeprec.c H5Oainfo.c H5Oalloc.c H5Oattr.c \ H5Oattribute.c H5Obogus.c H5Obtreek.c H5Ocache.c H5Ocache_image.c \ H5Ochunk.c \ H5Ocont.c H5Ocopy.c H5Odbg.c H5Odrvinfo.c H5Odtype.c H5Oefl.c \ |