diff options
Diffstat (limited to 'src')
118 files changed, 4387 insertions, 1294 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4b020fa..070cf62 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -386,6 +386,7 @@ IDE_GENERATED_PROPERTIES ("H5I" "${H5I_HDRS}" "${H5I_SOURCES}" ) set (H5L_SOURCES ${HDF5_SRC_DIR}/H5L.c + ${HDF5_SRC_DIR}/H5Ldeprec.c ${HDF5_SRC_DIR}/H5Lexternal.c ) set (H5L_HDRS @@ -659,6 +660,7 @@ set (H5VL_SOURCES ${HDF5_SRC_DIR}/H5VLnative_link.c ${HDF5_SRC_DIR}/H5VLnative_introspect.c ${HDF5_SRC_DIR}/H5VLnative_object.c + ${HDF5_SRC_DIR}/H5VLnative_token.c ${HDF5_SRC_DIR}/H5VLpassthru.c ) set (H5VL_HDRS @@ -276,7 +276,7 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id) { void *attr = NULL; /* Attribute created */ - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -360,8 +360,8 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t lapl_id) { - void *attr = NULL; /* attr token from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *attr = NULL; /* attr object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -437,8 +437,8 @@ done: hid_t H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) { - void *attr = NULL; /* attr token from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *attr = NULL; /* attr object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; @@ -508,8 +508,8 @@ hid_t H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t aapl_id, hid_t lapl_id) { - void *attr = NULL; /* attr token from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *attr = NULL; /* attr object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; @@ -587,7 +587,7 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t aapl_id, hid_t lapl_id) { void *attr = NULL; /* Attribute opened */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -1328,7 +1328,7 @@ herr_t H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ @@ -1407,7 +1407,7 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5ACmpio.c b/src/H5ACmpio.c index e4b81fa..fadde28 100644 --- a/src/H5ACmpio.c +++ b/src/H5ACmpio.c @@ -498,7 +498,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5AC__construct_candidate_list(H5AC_t *cache_ptr, H5AC_aux_t *aux_ptr, +H5AC__construct_candidate_list(H5AC_t *cache_ptr, H5AC_aux_t H5_ATTR_NDEBUG_UNUSED *aux_ptr, int sync_point_op) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 5fc2823..e0a0f55 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -116,8 +116,8 @@ hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id) { - void *attr = NULL; /* attr token from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + void *attr = NULL; /* attr object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -190,8 +190,8 @@ done: hid_t H5Aopen_name(hid_t loc_id, const char *name) { - void *attr = NULL; /* attr token from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + void *attr = NULL; /* attr object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -256,8 +256,8 @@ done: hid_t H5Aopen_idx(hid_t loc_id, unsigned idx) { - void *attr = NULL; /* attr token from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + void *attr = NULL; /* attr object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -321,9 +321,9 @@ done: int H5Aget_num_attrs(hid_t loc_id) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; - H5O_info_t oinfo; + H5O_info2_t oinfo; int ret_value = -1; FUNC_ENTER_API((-1)) @@ -337,7 +337,7 @@ H5Aget_num_attrs(hid_t loc_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Get the number of attributes for the object */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, &oinfo, H5O_INFO_ALL) < 0) + if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &oinfo, H5O_INFO_NUM_ATTRS) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute count for object") H5_CHECKED_ASSIGN(ret_value, int, oinfo.num_attrs, hsize_t); @@ -387,7 +387,7 @@ done: herr_t H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(H5_ITER_ERROR) diff --git a/src/H5Aint.c b/src/H5Aint.c index 90fb5c8..fc5ea34 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -2063,7 +2063,7 @@ done: */ H5A_t * H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_size, - H5O_copy_t *cpy_info) + H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info) { H5A_t *attr_dst = NULL; /* Destination attribute */ hid_t tid_src = -1; /* Datatype ID for source datatype */ @@ -2020,7 +2020,6 @@ H5B_valid(H5F_t *f, const H5B_class_t *type, haddr_t addr) { H5B_t *bt = NULL; /* The B-tree */ H5UC_t *rc_shared; /* Ref-counted shared info */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ htri_t ret_value = SUCCEED; /* Return value */ @@ -2038,8 +2037,7 @@ H5B_valid(H5F_t *f, const H5B_class_t *type, haddr_t addr) /* Get shared info for B-tree */ if(NULL == (rc_shared = (type->get_shared)(f, NULL))) 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); + HDassert((H5B_shared_t *)H5UC_GET_OBJ(rc_shared)); /* * Load the tree node. diff --git a/src/H5B2cache.c b/src/H5B2cache.c index 65286e6..80cb6c5 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -654,6 +654,7 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, uint32_t stored_chksum; /* Stored metadata checksum value */ unsigned u; /* Local index variable */ H5B2_internal_t *ret_value = NULL; /* Return value */ + int node_nrec = 0; FUNC_ENTER_STATIC @@ -716,7 +717,8 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, for(u = 0; u < (unsigned)(internal->nrec + 1); u++) { /* Decode node pointer */ H5F_addr_decode(udata->f, (const uint8_t **)&image, &(int_node_ptr->addr)); - UINT64DECODE_VAR(image, int_node_ptr->node_nrec, udata->hdr->max_nrec_size); + UINT64DECODE_VAR(image, node_nrec, udata->hdr->max_nrec_size); + H5_CHECKED_ASSIGN(int_node_ptr->node_nrec, uint16_t, node_nrec, int); if(udata->depth > 1) UINT64DECODE_VAR(image, int_node_ptr->all_nrec, udata->hdr->node_info[udata->depth - 1].cum_max_nrec_size) else diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index 0e3ebd5..b5b1c03 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -87,7 +87,7 @@ */ herr_t H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5B2_class_t *type, haddr_t obj_addr) + const H5B2_class_t H5_ATTR_NDEBUG_UNUSED *type, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) { H5B2_hdr_t *hdr = NULL; /* B-tree header info */ unsigned u; /* Local index variable */ @@ -182,7 +182,7 @@ done: */ herr_t H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5B2_class_t *type, haddr_t hdr_addr, unsigned nrec, unsigned depth, haddr_t obj_addr) + const H5B2_class_t *type, haddr_t hdr_addr, unsigned nrec, unsigned depth, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_internal_t *internal = NULL; /* B-tree internal node */ @@ -294,7 +294,7 @@ done: */ herr_t H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5B2_class_t *type, haddr_t hdr_addr, unsigned nrec, haddr_t obj_addr) + const H5B2_class_t *type, haddr_t hdr_addr, unsigned nrec, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_leaf_t *leaf = NULL; /* B-tree leaf node */ diff --git a/src/H5B2internal.c b/src/H5B2internal.c index 7f6b80a..92c802e 100644 --- a/src/H5B2internal.c +++ b/src/H5B2internal.c @@ -1355,7 +1355,7 @@ done: *------------------------------------------------------------------------- */ H5_ATTR_PURE herr_t -H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, const H5B2_internal_t *internal) +H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_internal_t *internal) { hsize_t tot_all_nrec; /* Total number of records at or below this node */ uint16_t u, v; /* Local index variables */ @@ -1396,7 +1396,7 @@ H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, const H5B2 *------------------------------------------------------------------------- */ H5_ATTR_PURE herr_t -H5B2__assert_internal2(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, const H5B2_internal_t *internal, const H5B2_internal_t *internal2) +H5B2__assert_internal2(hsize_t parent_all_nrec, const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_internal_t *internal, const H5B2_internal_t *internal2) { hsize_t tot_all_nrec; /* Total number of records at or below this node */ uint16_t u, v; /* Local index variables */ diff --git a/src/H5B2leaf.c b/src/H5B2leaf.c index beca40c..7ed0468 100644 --- a/src/H5B2leaf.c +++ b/src/H5B2leaf.c @@ -1027,7 +1027,8 @@ done: *------------------------------------------------------------------------- */ H5_ATTR_PURE herr_t -H5B2__assert_leaf(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf) +H5B2__assert_leaf(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, + const H5B2_leaf_t H5_ATTR_NDEBUG_UNUSED *leaf) { /* General sanity checking on node */ HDassert(leaf->nrec <= hdr->node_info->split_nrec); @@ -1056,7 +1056,6 @@ H5C_flush_cache(H5F_t *f, unsigned flags) H5C_ring_t ring; H5C_t * cache_ptr; hbool_t destroy; - hbool_t ignore_protected; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -1101,9 +1100,8 @@ H5C_flush_cache(H5F_t *f, unsigned flags) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - ignore_protected = ( (flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0 ); destroy = ( (flags & H5C__FLUSH_INVALIDATE_FLAG) != 0 ); - HDassert( ! ( destroy && ignore_protected ) ); + HDassert( ! ( destroy && ( (flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0 )) ); HDassert( ! ( cache_ptr->flush_in_progress ) ); cache_ptr->flush_in_progress = TRUE; @@ -3856,7 +3854,11 @@ H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, { herr_t ret_value = SUCCEED; /* Return value */ +#if H5C_DO_SANITY_CHECKS FUNC_ENTER_STATIC +#else + FUNC_ENTER_STATIC_NOERR +#endif /* Sanity checking */ HDassert(cache_ptr); @@ -3873,7 +3875,9 @@ H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, /* Update the stats for an unpin operation */ H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) +#if H5C_DO_SANITY_CHECKS done: +#endif FUNC_LEAVE_NOAPI(ret_value) } /* H5C__unpin_entry_real() */ @@ -105,7 +105,7 @@ } /* end if */ #endif /* H5_HAVE_PARALLEL */ -#ifdef H5_HAVE_PARALLEL +#if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_INSTRUMENTED_LIBRARY) /* Macro for the duplicated code to test and set properties for a property list */ #define H5CX_TEST_SET_PROP(PROP_NAME, PROP_FIELD) \ { \ @@ -127,7 +127,9 @@ (*head)->ctx.H5_GLUE(PROP_FIELD,_set) = TRUE; \ } /* end if */ \ } +#endif /* defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_INSTRUMENTED_LIBRARY) */ +#ifdef H5_HAVE_PARALLEL /* Macro for the duplicated code to test and set properties for a property list */ #define H5CX_SET_PROP(PROP_NAME, PROP_FIELD) \ if((*head)->ctx.H5_GLUE(PROP_FIELD,_set)) { \ diff --git a/src/H5Clog_json.c b/src/H5Clog_json.c index dd9e9b2..5ac354d 100644 --- a/src/H5Clog_json.c +++ b/src/H5Clog_json.c @@ -1281,7 +1281,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, +H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t H5_ATTR_NDEBUG_UNUSED *config, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index e784487..2c176e4 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -174,13 +174,13 @@ H5C_apply_candidate_list(H5F_t * f, int mpi_size) { int i; - int m; - int n; - unsigned first_entry_to_flush; - unsigned last_entry_to_flush; - unsigned total_entries_to_clear = 0; - unsigned total_entries_to_flush = 0; - int * candidate_assignment_table = NULL; + int m; + unsigned n; + unsigned first_entry_to_flush; + unsigned last_entry_to_flush; + unsigned total_entries_to_clear = 0; + unsigned total_entries_to_flush = 0; + unsigned * candidate_assignment_table = NULL; unsigned entries_to_flush[H5C_RING_NTYPES]; unsigned entries_to_clear[H5C_RING_NTYPES]; haddr_t addr; @@ -231,17 +231,18 @@ H5C_apply_candidate_list(H5F_t * f, HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create skip list for entries") } /* end if */ - n = num_candidates / mpi_size; - m = num_candidates % mpi_size; - HDassert(n >= 0); - if(NULL == (candidate_assignment_table = (int *)H5MM_malloc(sizeof(int) * (size_t)(mpi_size + 1)))) + n = num_candidates / (unsigned)mpi_size; + if(num_candidates % (unsigned)mpi_size > INT_MAX) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "m overflow") + m = (int)(num_candidates % (unsigned)mpi_size); + + if(NULL == (candidate_assignment_table = (unsigned *)H5MM_malloc(sizeof(unsigned) * (size_t)(mpi_size + 1)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for candidate assignment table") candidate_assignment_table[0] = 0; candidate_assignment_table[mpi_size] = num_candidates; if(m == 0) { /* mpi_size is an even divisor of num_candidates */ - HDassert(n > 0); for(i = 1; i < mpi_size; i++) candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n; } /* end if */ @@ -249,7 +250,7 @@ H5C_apply_candidate_list(H5F_t * f, for(i = 1; i <= m; i++) candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n + 1; - if(num_candidates < mpi_size) { + if(num_candidates < (unsigned)mpi_size) { for(i = m + 1; i < mpi_size; i++) candidate_assignment_table[i] = num_candidates; } /* end if */ @@ -263,7 +264,7 @@ H5C_apply_candidate_list(H5F_t * f, #if H5C_DO_SANITY_CHECKS /* Verify that the candidate assignment table has the expected form */ for(i = 1; i < mpi_size - 1; i++) { - int a, b; + unsigned a, b; a = candidate_assignment_table[i] - candidate_assignment_table[i - 1]; b = candidate_assignment_table[i + 1] - candidate_assignment_table[i]; @@ -282,7 +283,7 @@ H5C_apply_candidate_list(H5F_t * f, tbl_buf[i] = '\0'; HDsprintf(&(tbl_buf[0]), "candidate assignment table = "); for(i = 0; i <= mpi_size; i++) - HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " %d", candidate_assignment_table[i]); + HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " %u", candidate_assignment_table[i]); HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n"); HDfprintf(stdout, "%s", tbl_buf); @@ -359,11 +360,11 @@ H5C_apply_candidate_list(H5F_t * f, n = 0; for(i = 0; i < H5C_RING_NTYPES; i++) { m += (int)entries_to_flush[i]; - n += (int)entries_to_clear[i]; + n += entries_to_clear[i]; } /* end if */ HDassert((unsigned)m == total_entries_to_flush); - HDassert((unsigned)n == total_entries_to_clear); + HDassert(n == total_entries_to_clear); #endif /* H5C_DO_SANITY_CHECKS */ #if H5C_APPLY_CANDIDATE_LIST__DEBUG @@ -397,7 +398,7 @@ H5C_apply_candidate_list(H5F_t * f, done: if(candidate_assignment_table != NULL) - candidate_assignment_table = (int *)H5MM_xfree((void *)candidate_assignment_table); + candidate_assignment_table = (unsigned *)H5MM_xfree((void *)candidate_assignment_table); if(cache_ptr->coll_write_list) { if(H5SL_close(cache_ptr->coll_write_list) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "failed to destroy skip list") diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 9156c0d..cafc6d5 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -4923,7 +4923,7 @@ H5_DLL herr_t H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry); /* Testing functions */ #ifdef H5C_TESTING -H5_DLL herr_t H5C__verify_cork_tag_test(hid_t fid, haddr_t tag, hbool_t status); +H5_DLL herr_t H5C__verify_cork_tag_test(hid_t fid, H5O_token_t tag_token, hbool_t status); #endif /* H5C_TESTING */ #endif /* _H5Cpkg_H */ diff --git a/src/H5Ctest.c b/src/H5Ctest.c index 340071a..7f24302 100644 --- a/src/H5Ctest.c +++ b/src/H5Ctest.c @@ -35,12 +35,13 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ #include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ @@ -132,11 +133,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C__verify_cork_tag_test(hid_t fid, haddr_t tag, hbool_t status) +H5C__verify_cork_tag_test(hid_t fid, H5O_token_t tag_token, hbool_t status) { H5F_t * f; /* File Pointer */ H5C_t * cache; /* Cache Pointer */ H5C_tag_iter_vct_ctx_t ctx; /* Context for iterator callback */ + haddr_t tag; /* Tagged address */ herr_t ret_value = SUCCEED; /* Return value */ /* Function enter macro */ @@ -146,6 +148,11 @@ H5C__verify_cork_tag_test(hid_t fid, haddr_t tag, hbool_t status) if(NULL == (f = (H5F_t *)H5VL_object_verify(fid, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + /* Convert token to address */ + tag = HADDR_UNDEF; + if(H5VL_native_token_to_addr(f, H5I_FILE, tag_token, &tag) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't get address for token") + /* Get cache pointer */ cache = f->shared->cache; @@ -100,7 +100,7 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) { void *dset = NULL; /* New dataset's info */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -199,8 +199,8 @@ hid_t H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id) { - void *dset = NULL; /* dset token from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *dset = NULL; /* dset object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -265,8 +265,8 @@ done: hid_t H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) { - void *dset = NULL; /* dset token from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *dset = NULL; /* dset object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index c13c36a..098e01b 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -253,7 +253,7 @@ H5D__btree_get_shared(const H5F_t H5_ATTR_UNUSED *f, const void *_udata) *------------------------------------------------------------------------- */ static herr_t -H5D__btree_new_node(H5F_t *f, H5B_ins_t op, void *_lt_key, void *_udata, +H5D__btree_new_node(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5B_ins_t op, void *_lt_key, void *_udata, void *_rt_key, haddr_t *addr_p/*out*/) { H5D_btree_key_t *lt_key = (H5D_btree_key_t *) _lt_key; @@ -536,7 +536,7 @@ done: *------------------------------------------------------------------------- */ static H5B_ins_t -H5D__btree_insert(H5F_t *f, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, +H5D__btree_insert(H5F_t H5_ATTR_NDEBUG_UNUSED *f, haddr_t H5_ATTR_NDEBUG_UNUSED addr, void *_lt_key, hbool_t *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, hbool_t H5_ATTR_UNUSED *rt_key_changed, haddr_t *new_node_p/*out*/) { diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 17b0d16..33950a4 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1683,7 +1683,7 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t /* Iterate through each chunk in the dataset */ while(sel_points) { H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ - hssize_t schunk_points; /* Number of elements in chunk selection */ + hsize_t chunk_points; /* Number of elements in chunk selection */ /* Add temporary chunk to the list of chunks */ @@ -1727,12 +1727,11 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t } /* end if */ /* Get number of elements selected in chunk */ - if((schunk_points = H5S_GET_SELECT_NPOINTS(new_chunk_info->fspace)) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements") - H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, schunk_points, hssize_t); + chunk_points = H5S_GET_SELECT_NPOINTS(new_chunk_info->fspace); + H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, chunk_points, hsize_t); /* Decrement # of points left in file selection */ - sel_points -= (hsize_t)schunk_points; + sel_points -= chunk_points; /* Advance to next chunk if we are not done */ if(sel_points > 0) { @@ -1870,7 +1869,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t /* (Casting away const OK - QAK) */ if(TRUE == H5S_SELECT_INTERSECT_BLOCK(fm->file_space, coords, end)) { H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ - hssize_t schunk_points; /* Number of elements in chunk selection */ + hsize_t chunk_points; /* Number of elements in chunk selection */ /* Create dataspace for chunk, 'AND'ing the overall selection with * the current chunk. @@ -1923,12 +1922,11 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t } /* end if */ /* Get number of elements selected in chunk */ - if((schunk_points = H5S_GET_SELECT_NPOINTS(new_chunk_info->fspace)) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements") - H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, schunk_points, hssize_t); + chunk_points = H5S_GET_SELECT_NPOINTS(new_chunk_info->fspace); + H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, chunk_points, hsize_t); /* Decrement # of points left in file selection */ - sel_points -= (hsize_t)schunk_points; + sel_points -= chunk_points; /* Leave if we are done */ if(sel_points == 0) @@ -2131,7 +2129,7 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) { H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ H5SL_node_t *curr_node; /* Current node in skip list */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4983,12 +4981,12 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, /* Distribute evenly the number of blocks between processes. */ if(mpi_size == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Resulted in division by zero") - num_blocks = chunk_info->num_io / mpi_size; /* value should be the same on all procs */ + num_blocks = (size_t)(chunk_info->num_io / (size_t)mpi_size); /* value should be the same on all procs */ /* after evenly distributing the blocks between processes, are there any leftover blocks for each individual process (round-robin) */ - leftover_blocks = chunk_info->num_io % mpi_size; + leftover_blocks = (size_t)(chunk_info->num_io % (size_t)mpi_size); /* Cast values to types needed by MPI */ H5_CHECKED_ASSIGN(blocks, int, num_blocks, size_t); @@ -4997,9 +4995,9 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, /* Allocate buffers */ /* (MSC - should not need block_lens if MPI_type_create_hindexed_block is working) */ - if(NULL == (block_lens = (int *)H5MM_malloc((blocks + 1) * sizeof(int)))) + if(NULL == (block_lens = (int *)H5MM_malloc((size_t)(blocks + 1) * sizeof(int)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk lengths buffer") - if(NULL == (chunk_disp_array = (MPI_Aint *)H5MM_malloc((blocks + 1) * sizeof(MPI_Aint)))) + if(NULL == (chunk_disp_array = (MPI_Aint *)H5MM_malloc((size_t)(blocks + 1) * sizeof(MPI_Aint)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file displacement buffer") for(i = 0 ; i < blocks ; i++) { @@ -5104,7 +5102,7 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk) const hsize_t *scaled = udata->common.scaled; /* Scaled chunk offset */ H5S_sel_iter_t *chunk_iter = NULL; /* Memory selection iteration info */ hbool_t chunk_iter_init = FALSE; /* Whether the chunk iterator has been initialized */ - hssize_t sel_nelmts; /* Number of elements in selection */ + hsize_t sel_nelmts; /* Number of elements in selection */ hsize_t count[H5O_LAYOUT_NDIMS]; /* Element count of hyperslab */ size_t chunk_size; /*size of a chunk */ void *chunk; /* The file chunk */ @@ -5165,8 +5163,7 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk) /* Get the number of elements in the selection */ sel_nelmts = H5S_GET_SELECT_NPOINTS(udata->chunk_space); - HDassert(sel_nelmts >= 0); - H5_CHECK_OVERFLOW(sel_nelmts, hssize_t, size_t); + H5_CHECK_OVERFLOW(sel_nelmts, hsize_t, size_t); /* Check for VL datatype & non-default fill value */ if(udata->fb_info.has_vlen_fill_type) diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 2b50559..f4f4223 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -113,8 +113,8 @@ hid_t H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id) { - void *dset = NULL; /* dset token from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *dset = NULL; /* dset object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -186,8 +186,8 @@ done: hid_t H5Dopen1(hid_t loc_id, const char *name) { - void *dset = NULL; /* dset token from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *dset = NULL; /* dset object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ diff --git a/src/H5Dfill.c b/src/H5Dfill.c index 3ccee90..f5a5238 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -249,12 +249,11 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, * of the VL data. */ if(TRUE == H5T_detect_class(fill_type, H5T_VLEN, FALSE)) { - hssize_t nelmts; /* Number of data elements */ + hsize_t nelmts; /* Number of data elements */ /* Get the number of elements in the selection */ nelmts = H5S_GET_SELECT_NPOINTS(space); - HDassert(nelmts >= 0); - H5_CHECK_OVERFLOW(nelmts, hssize_t, size_t); + H5_CHECK_OVERFLOW(nelmts, hsize_t, size_t); /* Allocate a temporary buffer */ if(NULL == (tmp_buf = H5FL_BLK_MALLOC(type_conv, (size_t)nelmts * buf_size))) diff --git a/src/H5Dint.c b/src/H5Dint.c index c3e0c0d..436a507 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -89,7 +89,7 @@ static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overw hsize_t old_dim[]); static herr_t H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id); static herr_t H5D__close_cb(H5VL_object_t *dset_vol_obj); -static herr_t H5D__use_minimized_dset_headers(H5F_t *file, H5D_t *dset, hbool_t *minimize); +static herr_t H5D__use_minimized_dset_headers(H5F_t *file, hbool_t *minimize); static herr_t H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc); static size_t H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr); static void *H5D__vlen_get_buf_size_alloc(size_t size, void *info); @@ -737,14 +737,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__use_minimized_dset_headers(H5F_t *file, H5D_t *dset, hbool_t *minimize) +H5D__use_minimized_dset_headers(H5F_t *file, hbool_t *minimize) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT; HDassert(file); - HDassert(dset); HDassert(minimize); /* Get the dataset object header minimize flag for this call */ @@ -1015,7 +1014,7 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value info") } /* end if */ - if(H5D__use_minimized_dset_headers(file, dset, &minimize_header) == FAIL) + if(H5D__use_minimized_dset_headers(file, &minimize_header) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get minimize settings") if(TRUE == minimize_header) { diff --git a/src/H5Dio.c b/src/H5Dio.c index 6b02b68..0f4e703 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -409,9 +409,8 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* Note that if this variable is used, the */ /* projected mem space must be discarded at the */ /* end of the function to avoid a memory leak. */ - H5D_storage_t store; /*union of EFL and chunk pointer in file space */ - hssize_t snelmts; /*total number of elmts (signed) */ - hsize_t nelmts; /*total number of elmts */ + H5D_storage_t store; /* union of EFL and chunk pointer in file space */ + hsize_t nelmts; /* total number of elmts */ hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ char fake_char; /* Temporary variable for NULL buffer pointers */ herr_t ret_value = SUCCEED; /* Return value */ @@ -425,9 +424,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, file_space = dataset->shared->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") - H5_CHECKED_ASSIGN(nelmts, hsize_t, snelmts, hssize_t); + nelmts = H5S_GET_SELECT_NPOINTS(mem_space); /* Set up datatype info for operation */ if(H5D__typeinfo_init(dataset, mem_type_id, FALSE, &type_info) < 0) @@ -450,7 +447,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, #endif /*H5_HAVE_PARALLEL*/ /* Make certain that the number of elements in each selection is the same */ - if(nelmts != (hsize_t)H5S_GET_SELECT_NPOINTS(file_space)) + if(nelmts != H5S_GET_SELECT_NPOINTS(file_space)) 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 */ @@ -623,9 +620,8 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* Note that if this variable is used, the */ /* projected mem space must be discarded at the */ /* end of the function to avoid a memory leak. */ - H5D_storage_t store; /*union of EFL and chunk pointer in file space */ - hssize_t snelmts; /*total number of elmts (signed) */ - hsize_t nelmts; /*total number of elmts */ + H5D_storage_t store; /* union of EFL and chunk pointer in file space */ + hsize_t nelmts; /* total number of elmts */ hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ char fake_char; /* Temporary variable for NULL buffer pointers */ herr_t ret_value = SUCCEED; /* Return value */ @@ -680,12 +676,10 @@ H5D__write(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, "src dataspace has invalid selection") - H5_CHECKED_ASSIGN(nelmts, hsize_t, snelmts, hssize_t); + nelmts = H5S_GET_SELECT_NPOINTS(mem_space); /* Make certain that the number of elements in each selection is the same */ - if(nelmts != (hsize_t)H5S_GET_SELECT_NPOINTS(file_space)) + if(nelmts != H5S_GET_SELECT_NPOINTS(file_space)) 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 */ diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 0dbbe9f..91557c3 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -2524,7 +2524,9 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, } /* end if */ /* Broadcasting the MPI_IO option info. and chunk address info. */ - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(mergebuf, ((sizeof(haddr_t) + 1) * total_chunks), MPI_BYTE, root, comm))) + if((sizeof(haddr_t) + 1) * total_chunks > INT_MAX) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "result overflow") + if(MPI_SUCCESS != (mpi_code = MPI_Bcast(mergebuf, (int)((sizeof(haddr_t) + 1) * total_chunks), MPI_BYTE, root, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_BCast failed", mpi_code) H5MM_memcpy(assign_io_mode, mergebuf, total_chunks); @@ -2606,7 +2608,7 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ H5D_chunk_info_t *chunk_info; H5D_chunk_ud_t udata; H5SL_node_t *chunk_node; - hssize_t select_npoints; + hsize_t select_npoints; hssize_t chunk_npoints; if(NULL == (local_info_array = (H5D_filtered_collective_io_info_t *) H5MM_malloc(num_chunks_selected * sizeof(H5D_filtered_collective_io_info_t)))) @@ -2632,8 +2634,7 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ H5MM_memcpy(local_info_array[i].scaled, chunk_info->scaled, sizeof(chunk_info->scaled)); - if ((select_npoints = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") + select_npoints = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); local_info_array[i].io_size = (size_t) select_npoints * type_info->src_type_size; /* Currently the full overwrite status of a chunk is only obtained on a per-process @@ -2841,7 +2842,7 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty if (mpi_rank != chunk_entry->owners.new_owner) { H5D_chunk_info_t *chunk_info = NULL; unsigned char *mod_data_p = NULL; - hssize_t iter_nelmts; + hsize_t iter_nelmts; size_t mod_data_size; /* Look up the chunk and get its file and memory dataspaces */ @@ -2854,9 +2855,9 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty if(H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "unable to get encoded dataspace size") - if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") + iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); + H5_CHECK_OVERFLOW(iter_nelmts, hsize_t, size_t); mod_data_size += (size_t) iter_nelmts * type_info->src_type_size; if(NULL == (mod_data[num_send_requests] = (unsigned char *) H5MM_malloc(mod_data_size))) @@ -3088,7 +3089,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk H5Z_EDC_t err_detect; /* Error detection info */ H5Z_cb_t filter_cb; /* I/O filter callback function */ unsigned filter_mask = 0; - hssize_t iter_nelmts; /* Number of points to iterate over for the chunk IO operation */ + hsize_t iter_nelmts; /* Number of points to iterate over for the chunk IO operation */ hssize_t extent_npoints; hsize_t true_chunk_size; hbool_t mem_iter_init = FALSE; @@ -3193,17 +3194,15 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") file_iter_init = TRUE; - if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") + iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); - if(NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) iter_nelmts * type_info->src_type_size))) + if(NULL == (tmp_gath_buf = H5MM_malloc(iter_nelmts * type_info->src_type_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer") if(!H5D__gather_mem(chunk_entry->buf, file_iter, (size_t) iter_nelmts, tmp_gath_buf)) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't gather from chunk buffer") - if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") + iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); if(H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t) iter_nelmts, io_info->u.rbuf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to read buffer") @@ -3211,10 +3210,9 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk break; case H5D_IO_OP_WRITE: - if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") + iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); - if(NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) iter_nelmts * type_info->src_type_size))) + if(NULL == (tmp_gath_buf = H5MM_malloc(iter_nelmts * type_info->src_type_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer") /* Gather modification data from the application write buffer into a temporary buffer */ @@ -3230,8 +3228,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") mem_iter_init = TRUE; - if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") + iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); /* Scatter the owner's modification data into the chunk data buffer according to * the file space. @@ -3262,8 +3259,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init = TRUE; - if((iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") + iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace); /* Update the chunk data with the received modification data */ if(H5D__scatter_mem(mod_data_p, mem_iter, (size_t) iter_nelmts, chunk_entry->buf) < 0) diff --git a/src/H5Dnone.c b/src/H5Dnone.c index 9346220..2093512 100644 --- a/src/H5Dnone.c +++ b/src/H5Dnone.c @@ -378,7 +378,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__none_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, +H5D__none_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Dsingle.c b/src/H5Dsingle.c index 4510a03..8efa771 100644 --- a/src/H5Dsingle.c +++ b/src/H5Dsingle.c @@ -437,7 +437,7 @@ H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info) *------------------------------------------------------------------------- */ static herr_t -H5D__single_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, +H5D__single_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5EAcache.c b/src/H5EAcache.c index 1fd9c44..1d182a4 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -1543,7 +1543,7 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ */ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, -H5EA__cache_dblock_deserialize(const void *_image, size_t len, +H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty)) /* Local variables */ @@ -2080,7 +2080,7 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_image_len() */ */ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, -H5EA__cache_dblk_page_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, +H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing)) /* Local variables */ diff --git a/src/H5EAtest.c b/src/H5EAtest.c index 814e64f..58e255a 100644 --- a/src/H5EAtest.c +++ b/src/H5EAtest.c @@ -279,7 +279,7 @@ END_FUNC(STATIC) /* end H5EA__test_encode() */ */ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, -H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx)) +H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDEBUG_UNUSED *_ctx)) /* Local variables */ #ifndef NDEBUG diff --git a/src/H5Epkg.h b/src/H5Epkg.h index ac98496..86b5b73 100644 --- a/src/H5Epkg.h +++ b/src/H5Epkg.h @@ -77,7 +77,7 @@ typedef struct { } H5E_auto_op_t; #else /* H5_NO_DEPRECATED_SYMBOLS */ typedef struct { - H5E_auto_t func2; /* Only the new style callback function is available. */ + H5E_auto2_t func2; /* Only the new style callback function is available. */ } H5E_auto_op_t; #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Epublic.h b/src/H5Epublic.h index 3eae2da..ed14217 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -100,14 +100,14 @@ H5_DLLVAR hid_t H5E_ERR_CLS_g; } #else /* H5_NO_DEPRECATED_SYMBOLS */ #define H5E_BEGIN_TRY { \ - H5E_auto_t saved_efunc; \ + H5E_auto2_t saved_efunc; \ void *H5E_saved_edata; \ \ - (void)H5Eget_auto(H5E_DEFAULT, &saved_efunc, &H5E_saved_edata); \ - (void)H5Eset_auto(H5E_DEFAULT, NULL, NULL); + (void)H5Eget_auto2(H5E_DEFAULT, &saved_efunc, &H5E_saved_edata); \ + (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); #define H5E_END_TRY \ - (void)H5Eset_auto(H5E_DEFAULT, saved_efunc, H5E_saved_edata); \ + (void)H5Eset_auto2(H5E_DEFAULT, saved_efunc, H5E_saved_edata); \ } #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5FAcache.c b/src/H5FAcache.c index 2f0d1b4..922153c 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -253,7 +253,7 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ */ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, -H5FA__cache_hdr_deserialize(const void *_image, size_t len, +H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty)) /* Local variables */ @@ -651,7 +651,7 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ */ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, -H5FA__cache_dblock_deserialize(const void *_image, size_t len, +H5FA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty)) /* Local variables */ @@ -1178,7 +1178,7 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ */ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, -H5FA__cache_dblk_page_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, +H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing)) /* Local variables */ @@ -665,14 +665,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FS_size(const H5F_t *f, const H5FS_t *fspace, hsize_t *meta_size) +H5FS_size(const H5FS_t *fspace, hsize_t *meta_size) { FUNC_ENTER_NOAPI_NOINIT_NOERR /* * Check arguments. */ - HDassert(f); HDassert(fspace); HDassert(meta_size); diff --git a/src/H5FScache.c b/src/H5FScache.c index cb0abe9..d5f2817 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -241,7 +241,7 @@ H5FS__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static void * -H5FS__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, +H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { H5FS_t *fspace = NULL; /* Free space header info */ @@ -404,8 +404,8 @@ H5FS__cache_hdr_image_len(const void *_thing, size_t *image_len) */ static herr_t H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, - haddr_t addr, size_t H5_ATTR_UNUSED len, haddr_t *new_addr, size_t *new_len, - unsigned *flags) + haddr_t addr, size_t H5_ATTR_UNUSED len, haddr_t H5_ATTR_NDEBUG_UNUSED *new_addr, + size_t H5_ATTR_NDEBUG_UNUSED *new_len, unsigned *flags) { H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ @@ -694,7 +694,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t len, +H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ @@ -979,8 +979,8 @@ H5FS__cache_sinfo_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNU *------------------------------------------------------------------------- */ static void * -H5FS__cache_sinfo_deserialize(const void *_image, size_t len, void *_udata, - hbool_t *dirty) +H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_NDEBUG_UNUSED *dirty) { H5FS_sinfo_cache_ud_t *udata = (H5FS_sinfo_cache_ud_t *)_udata; /* User data for callback */ H5FS_t *fspace; /* free space manager */ @@ -1025,11 +1025,11 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t len, void *_udata, /* Check for any serialized sections */ if(fspace->serial_sect_count > 0) { - hsize_t old_tot_sect_count; /* Total section count from header */ - hsize_t old_serial_sect_count; /* Total serializable section count from header */ - hsize_t old_ghost_sect_count; /* Total ghost section count from header */ - hsize_t old_tot_space; /* Total space managed from header */ - unsigned sect_cnt_size; /* The size of the section size counts */ + hsize_t old_tot_sect_count; /* Total section count from header */ + hsize_t H5_ATTR_NDEBUG_UNUSED old_serial_sect_count; /* Total serializable section count from header */ + hsize_t H5_ATTR_NDEBUG_UNUSED old_ghost_sect_count; /* Total ghost section count from header */ + hsize_t H5_ATTR_NDEBUG_UNUSED old_tot_space; /* Total space managed from header */ + unsigned sect_cnt_size; /* The size of the section size counts */ /* Compute the size of the section counts */ sect_cnt_size = H5VM_limit_enc_size((uint64_t)fspace->serial_sect_count); @@ -1141,7 +1141,6 @@ static herr_t H5FS__cache_sinfo_image_len(const void *_thing, size_t *image_len) { const H5FS_sinfo_t *sinfo = (const H5FS_sinfo_t *)_thing; /* Pointer to the object */ - const H5FS_t *fspace; /* Free space header */ FUNC_ENTER_STATIC_NOERR @@ -1149,10 +1148,9 @@ H5FS__cache_sinfo_image_len(const void *_thing, size_t *image_len) HDassert(sinfo); HDassert(sinfo->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(sinfo->cache_info.type == H5AC_FSPACE_SINFO); - fspace = sinfo->fspace; - HDassert(fspace); - HDassert(fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(fspace->cache_info.type == H5AC_FSPACE_HDR); + HDassert(sinfo->fspace); + HDassert(sinfo->fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(sinfo->fspace->cache_info.type == H5AC_FSPACE_HDR); HDassert(image_len); /* Set the image length size */ @@ -1180,7 +1178,8 @@ H5FS__cache_sinfo_image_len(const void *_thing, size_t *image_len) */ static herr_t H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, - size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags) + size_t H5_ATTR_NDEBUG_UNUSED len, haddr_t *new_addr, size_t H5_ATTR_NDEBUG_UNUSED *new_len, + unsigned *flags) { H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ H5FS_t *fspace; /* Free space header */ @@ -1267,7 +1266,6 @@ H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len, void *_thing) { H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ - H5FS_t *fspace; /* Free space header */ H5FS_iter_ud_t udata; /* User data for callbacks */ uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint8_t *chksum_image = NULL; /* Points to chksum location */ @@ -1283,12 +1281,11 @@ H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len, HDassert(sinfo); HDassert(sinfo->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(sinfo->cache_info.type == H5AC_FSPACE_SINFO); - fspace = sinfo->fspace; - HDassert(fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(fspace->cache_info.type == H5AC_FSPACE_HDR); - HDassert(fspace->cache_info.is_pinned); - HDassert(fspace->sect_size == len); - HDassert(fspace->sect_cls); + HDassert(sinfo->fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(sinfo->fspace->cache_info.type == H5AC_FSPACE_HDR); + HDassert(sinfo->fspace->cache_info.is_pinned); + HDassert(sinfo->fspace->sect_size == len); + HDassert(sinfo->fspace->sect_cls); /* Magic number */ H5MM_memcpy(image, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC); @@ -1418,7 +1415,6 @@ static herr_t H5FS__cache_sinfo_free_icr(void *_thing) { H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ - H5FS_t *fspace; /* Free space header */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1427,10 +1423,9 @@ H5FS__cache_sinfo_free_icr(void *_thing) HDassert(sinfo); HDassert(sinfo->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); HDassert(sinfo->cache_info.type == H5AC_FSPACE_SINFO); - fspace = sinfo->fspace; - HDassert(fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(fspace->cache_info.type == H5AC_FSPACE_HDR); - HDassert(fspace->cache_info.is_pinned); + HDassert(sinfo->fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(sinfo->fspace->cache_info.type == H5AC_FSPACE_HDR); + HDassert(sinfo->fspace->cache_info.is_pinned); /* Destroy free space info */ if(H5FS__sinfo_dest(sinfo) < 0) diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h index 31fc63c..d2e1f90 100644 --- a/src/H5FSprivate.h +++ b/src/H5FSprivate.h @@ -182,7 +182,7 @@ H5_DLL H5FS_t *H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_c H5_DLL H5FS_t *H5FS_open(H5F_t *f, haddr_t fs_addr, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold); -H5_DLL herr_t H5FS_size(const H5F_t *f, const H5FS_t *fspace, hsize_t *meta_size); +H5_DLL herr_t H5FS_size(const H5FS_t *fspace, hsize_t *meta_size); H5_DLL herr_t H5FS_delete(H5F_t *f, haddr_t fs_addr); H5_DLL herr_t H5FS_close(H5F_t *f, H5FS_t *fspace); H5_DLL herr_t H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr); diff --git a/src/H5Fint.c b/src/H5Fint.c index 8b3d927..74189c1 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -1509,8 +1509,8 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) H5P_genplist_t *a_plist; /*file access property list */ H5F_close_degree_t fc_degree; /*file close degree */ size_t page_buf_size; - unsigned page_buf_min_meta_perc; - unsigned page_buf_min_raw_perc; + unsigned page_buf_min_meta_perc = 0; + unsigned page_buf_min_raw_perc = 0; hbool_t set_flag = FALSE; /*set the status_flags in the superblock */ hbool_t clear = FALSE; /*clear the status_flags */ hbool_t evict_on_close; /* evict on close value from plist */ @@ -3581,78 +3581,6 @@ done: } /* H5F__format_convert() */ -/*--------------------------------------------------------------------------- - * Function: H5F__get_file - * - * Purpose: Utility routine to get file struct for an object - * - * Returns: SUCCESS: A pointer to the H5F_t struct for the file - * associated with the object. - * FAILURE: NULL - * - *--------------------------------------------------------------------------- - */ -H5F_t * -H5F__get_file(void *obj, H5I_type_t type) -{ - H5F_t *ret_value = NULL; /* File pointer */ - H5O_loc_t *oloc = NULL; /* Object location for ID */ - - FUNC_ENTER_PACKAGE - - switch(type) { - case H5I_FILE: - ret_value = (H5F_t *)obj; - break; - - case H5I_GROUP: - oloc = H5G_oloc((H5G_t *)obj); - break; - - case H5I_DATATYPE: - oloc = H5T_oloc((H5T_t *)obj); - break; - - case H5I_DATASET: - oloc = H5D_oloc((H5D_t *)obj); - break; - - case H5I_ATTR: - oloc = H5A_oloc((H5A_t *)obj); - break; - - case H5I_MAP: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "maps not supported in native VOL connector") - - case H5I_UNINIT: - case H5I_BADID: - case H5I_DATASPACE: - case H5I_VFL: - case H5I_VOL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_SPACE_SEL_ITER: - case H5I_NTYPES: - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - } /* end switch */ - - /* Set return value for objects (not files) */ - if(oloc) - ret_value = oloc->file; - - /* Couldn't find a file struct */ - if(!ret_value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "object is not associated with a file") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5F__get_file */ - - /*------------------------------------------------------------------------- * Function: H5F_get_file_id * diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 6e2c994..b85305e 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -411,7 +411,6 @@ H5_DLL herr_t H5F__format_convert(H5F_t *f); H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); H5_DLL herr_t H5F__close(H5F_t *f); H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); -H5_DLL H5F_t *H5F__get_file(void *obj, H5I_type_t type); H5_DLL herr_t H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info); /* File mount related routines */ diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 125d6cf..f95f13d 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -344,7 +344,7 @@ H5F__cache_superblock_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *------------------------------------------------------------------------- */ static herr_t -H5F__cache_superblock_get_final_load_size(const void *_image, size_t image_len, +H5F__cache_superblock_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *_udata, size_t *actual_len) { const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ @@ -434,7 +434,7 @@ H5F__cache_superblock_verify_chksum(const void *_image, size_t len, void *_udata *------------------------------------------------------------------------- */ static void * -H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata, +H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { H5F_super_t *sblock = NULL; /* File's superblock */ @@ -867,7 +867,7 @@ H5F__cache_drvrinfo_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *i *------------------------------------------------------------------------- */ static herr_t -H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t image_len, +H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *_udata, size_t *actual_len) { const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ @@ -911,7 +911,7 @@ done: *------------------------------------------------------------------------- */ static void * -H5F__cache_drvrinfo_deserialize(const void *_image, size_t len, void *_udata, +H5F__cache_drvrinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { H5O_drvinfo_t *drvinfo = NULL; /* Driver info */ @@ -1006,7 +1006,7 @@ H5F__cache_drvrinfo_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5F__cache_drvrinfo_serialize(const H5F_t *f, void *_image, size_t len, +H5F__cache_drvrinfo_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5O_drvinfo_t *drvinfo = (H5O_drvinfo_t *)_thing; /* Pointer to the object */ @@ -341,7 +341,7 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) { void *grp = NULL; /* Structure for new group */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -436,7 +436,7 @@ hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) { void *grp = NULL; /* Structure for new group */ - H5VL_object_t *vol_obj = NULL; /* Object token for loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -498,8 +498,8 @@ done: hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) { - void *grp = NULL; /* Group opened */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *grp = NULL; /* Group opened */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 830b0eb..126456b 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -173,7 +173,7 @@ hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) { void *grp = NULL; /* New group created */ - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t tmp_gcpl = H5I_INVALID_HID; /* Temporary group creation property list */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -269,7 +269,7 @@ hid_t H5Gopen1(hid_t loc_id, const char *name) { void *grp = NULL; /* Group opened */ - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -334,10 +334,10 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new /* Create link */ if(type == H5L_TYPE_HARD) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; - H5VL_object_t tmp_vol_obj; /* Temporary object token of */ + H5VL_object_t tmp_vol_obj; /* Temporary object */ loc_params1.type = H5VL_OBJECT_BY_NAME; loc_params1.obj_type = H5I_get_type(cur_loc_id); @@ -362,7 +362,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ else if(type == H5L_TYPE_SOFT) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; loc_params.type = H5VL_OBJECT_BY_NAME; @@ -416,8 +416,8 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, /* Create the appropriate kind of link */ if(type == H5L_TYPE_HARD) { - H5VL_object_t *vol_obj1; /* Object token of loc_id */ - H5VL_object_t *vol_obj2; /* Object token of loc_id */ + H5VL_object_t *vol_obj1; /* Object of loc_id */ + H5VL_object_t *vol_obj2; /* Object of loc_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; @@ -443,7 +443,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ else if(type == H5L_TYPE_SOFT) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Soft links only need one location, the new_loc_id, but it's possible that @@ -483,7 +483,7 @@ done: herr_t H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ @@ -529,9 +529,9 @@ herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name) { - H5VL_object_t *vol_obj1 = NULL; /* Object token of src_id */ + H5VL_object_t *vol_obj1 = NULL; /* Object of src_id */ H5VL_loc_params_t loc_params1; - H5VL_object_t *vol_obj2 = NULL; /* Object token of dst_id */ + H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */ H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ @@ -583,7 +583,7 @@ done: herr_t H5Gunlink(hid_t loc_id, const char *name) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -627,7 +627,7 @@ done: herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -680,7 +680,7 @@ done: herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -739,7 +739,7 @@ done: int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; ssize_t op_ret; /* Return value from operation */ int ret_value; /* Return value */ @@ -806,7 +806,7 @@ herr_t H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, void *op_data) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5G_link_iterate_t lnk_op; /* Link operator */ hsize_t last_obj; /* Index of last object looked at */ @@ -874,7 +874,7 @@ done: herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5I_type_t id_type; /* Type of ID */ H5VL_loc_params_t loc_params; H5G_info_t grp_info; /* Group information */ @@ -931,7 +931,7 @@ herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -1003,38 +1003,45 @@ H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, c /* Info for soft and UD links is gotten by H5L_get_info. If we have * a hard link, follow it and get info on the object */ - if (udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) { - H5O_info_t oinfo; /* Object information */ + if(udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) { + H5O_info2_t dm_info; /* Data model information */ + H5O_native_info_t nat_info; /* Native information */ + haddr_t obj_addr; /* Address of object */ - /* Go retrieve the object information */ + /* Go retrieve the data model & native object information */ /* (don't need index & heap info) */ HDassert(obj_loc); - 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"); + if(H5O_get_info(obj_loc->oloc, &dm_info, H5O_INFO_BASIC | H5O_INFO_TIME) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get data model object info") + if(H5O_get_native_info(obj_loc->oloc, &nat_info, H5O_INFO_HDR) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get native object info") /* Get mapped object type */ - statbuf->type = H5G_map_obj_type(oinfo.type); + statbuf->type = H5G_map_obj_type(dm_info.type); /* Get object number (i.e. address) for object */ - statbuf->objno[0] = (unsigned long)(oinfo.addr); + if(H5VL_native_token_to_addr(obj_loc->oloc->file, H5I_FILE, dm_info.token, &obj_addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + + statbuf->objno[0] = (unsigned long)(obj_addr); #if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - statbuf->objno[1] = (unsigned long)(oinfo.addr >> 8 * sizeof(long)); + statbuf->objno[1] = (unsigned long)(obj_addr >> 8 * sizeof(long)); #else statbuf->objno[1] = 0; #endif /* Get # of hard links pointing to object */ - statbuf->nlink = oinfo.rc; + statbuf->nlink = dm_info.rc; /* Get modification time for object */ - statbuf->mtime = oinfo.ctime; + statbuf->mtime = dm_info.ctime; /* Retrieve the object header information */ - statbuf->ohdr.size = oinfo.hdr.space.total; - statbuf->ohdr.free = oinfo.hdr.space.free; - statbuf->ohdr.nmesgs = oinfo.hdr.nmesgs; - statbuf->ohdr.nchunks = oinfo.hdr.nchunks; - } - } + statbuf->ohdr.size = nat_info.hdr.space.total; + statbuf->ohdr.free = nat_info.hdr.space.free; + statbuf->ohdr.nmesgs = nat_info.hdr.nmesgs; + statbuf->ohdr.nchunks = nat_info.hdr.nchunks; + } /* end if */ + } /* end if */ done: /* Indicate that this callback didn't take ownership of the group * @@ -1089,7 +1096,7 @@ H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, /* If we're pointing at a soft or UD link, get the real link length and type */ if (statbuf && follow_link == 0) { - H5L_info_t linfo; /* Link information buffer */ + H5L_info2_t linfo; /* Link information buffer */ herr_t ret; /* Get information about link to the object. If this fails, e.g. @@ -1142,7 +1149,7 @@ done: ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; ssize_t ret_value; /* Return value */ @@ -1193,10 +1200,9 @@ done: H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - H5O_info_t oinfo; /* Object info (contains object type) */ - unsigned fields; /* Which fields in object info to populate */ + H5O_info2_t oinfo; /* Object info (contains object type) */ H5G_obj_t ret_value; /* Return value */ FUNC_ENTER_API(H5G_UNKNOWN) @@ -1216,8 +1222,7 @@ H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier") /* Retrieve the object's basic information (which includes its type) */ - fields = H5O_INFO_BASIC; - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, &oinfo, fields) < 0) + if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &oinfo, H5O_INFO_BASIC) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't get object info") /* Map to group object type */ diff --git a/src/H5Gint.c b/src/H5Gint.c index 049c696..e0b8bd7 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -58,6 +58,7 @@ typedef struct { /* User data for application-style iteration over links in a group */ typedef struct { hid_t gid; /* The group ID for the application callback */ + H5O_loc_t *link_loc; /* The object location for the link */ H5G_link_iterate_t lnk_op; /* Application callback */ void *op_data; /* Application's op data */ } H5G_iter_appcall_ud_t; @@ -72,7 +73,7 @@ typedef struct { char *path; /* Path name of the link */ size_t curr_path_len; /* Current length of the path in the buffer */ size_t path_buf_size; /* Size of path buffer */ - H5L_iterate_t op; /* Application callback */ + H5L_iterate2_t op; /* Application callback */ void *op_data; /* Application's op data */ } H5G_iter_visit_ud_t; @@ -752,10 +753,10 @@ H5G_iterate_cb(const H5O_link_t *lnk, void *_udata) case H5G_LINK_OP_NEW: { - H5L_info_t info; /* Link info */ + H5L_info2_t info; /* Link info */ /* Retrieve the info for the link */ - if(H5G_link_to_info(lnk, &info) < 0) + if(H5G_link_to_info(udata->link_loc, lnk, &info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get info for link") /* Make the application callback */ @@ -812,6 +813,7 @@ H5G_iterate(H5G_loc_t *loc, const char *group_name, /* Set up user data for callback */ udata.gid = gid; + udata.link_loc = &grp->oloc; udata.lnk_op = *lnk_op; udata.op_data = op_data; @@ -872,7 +874,7 @@ static herr_t H5G_visit_cb(const H5O_link_t *lnk, void *_udata) { H5G_iter_visit_ud_t *udata = (H5G_iter_visit_ud_t *)_udata; /* User data for callback */ - H5L_info_t info; /* Link info */ + H5L_info2_t info; /* Link info */ H5G_loc_t obj_loc; /* Location of object */ H5G_name_t obj_path; /* Object's group hier. path */ H5O_loc_t obj_oloc; /* Object's object location */ @@ -908,7 +910,7 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) udata->curr_path_len += link_name_len; /* Construct the link info from the link message */ - if(H5G_link_to_info(lnk, &info) < 0) + if(H5G_link_to_info(udata->curr_loc->oloc, lnk, &info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get info for link") /* Make the application callback */ @@ -1044,7 +1046,7 @@ done: */ herr_t H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, H5L_iterate_t op, void *op_data) + H5_iter_order_t order, H5L_iterate2_t op, void *op_data) { H5G_iter_visit_ud_t udata; /* User data for callback */ H5O_linfo_t linfo; /* Link info message */ diff --git a/src/H5Glink.c b/src/H5Glink.c index 04ccbc5..6c42f1d 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -41,6 +41,8 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Ppublic.h" /* Property Lists */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -290,13 +292,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_link_to_info(const H5O_link_t *lnk, H5L_info_t *info) +H5G_link_to_info(const H5O_loc_t *link_loc, const H5O_link_t *lnk, H5L_info2_t *info) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + HDassert(link_loc); HDassert(lnk); /* Get information from the link */ @@ -308,7 +311,9 @@ H5G_link_to_info(const H5O_link_t *lnk, H5L_info_t *info) switch(lnk->type) { case H5L_TYPE_HARD: - info->u.address = lnk->u.hard.addr; + /* Serialize the address into a VOL token */ + if(H5VL_native_addr_to_token(link_loc->file, H5I_FILE, lnk->u.hard.addr, &info->u.token) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") break; case H5L_TYPE_SOFT: diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 56608e2..4d89abb 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -73,15 +73,24 @@ typedef struct { H5G_loc_t *loc; /* Group location to set */ } H5G_loc_fbi_t; -/* User data for getting an object's info in a group */ +/* User data for getting an object's data model info in a group */ typedef struct { /* downward */ - unsigned fields; /* which fields in H5O_info_t struct to fill in */ + unsigned fields; /* which fields in H5O_info2_t struct to fill in */ /* upward */ - H5O_info_t *oinfo; /* Object information to retrieve */ + H5O_info2_t *oinfo; /* Object information to retrieve */ } H5G_loc_info_t; +/* User data for getting an object's native info in a group */ +typedef struct { + /* downward */ + unsigned fields; /* which fields in H5O_native_info_t struct to fill in */ + + /* upward */ + H5O_native_info_t *oinfo; /* Object information to retrieve */ +} H5G_loc_native_info_t; + /* User data for setting an object's comment in a group */ typedef struct { /* downward */ @@ -116,6 +125,8 @@ static herr_t H5G__loc_addr_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); static herr_t H5G__loc_info_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_native_info_cb(H5G_loc_t *grp_loc, const char *name, + const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); static herr_t H5G__loc_set_comment_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); @@ -762,7 +773,7 @@ done: /*------------------------------------------------------------------------- * Function: H5G__loc_info_cb * - * Purpose: Callback for retrieving object info for an object in a group + * Purpose: Callback for retrieving data model info for an object in a group * * Return: Non-negative on success/Negative on failure * @@ -800,7 +811,7 @@ done: /*------------------------------------------------------------------------- * Function: H5G_loc_info * - * Purpose: Retrieve the information for an object from a group location + * Purpose: Retrieve the data model information for an object from a group location * and path to that object * * Return: Non-negative on success/Negative on failure @@ -811,7 +822,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info_t *oinfo/*out*/, unsigned fields) +H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info2_t *oinfo/*out*/, unsigned fields) { H5G_loc_info_t udata; /* User data for traversal callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -837,6 +848,84 @@ done: /*------------------------------------------------------------------------- + * Function: H5G__loc_native_info_cb + * + * Purpose: Callback for retrieving native info for an object in a group + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, November 23, 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5G__loc_native_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t H5_ATTR_UNUSED *lnk, + H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +{ + H5G_loc_native_info_t *udata = (H5G_loc_native_info_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name in this group resolved to a valid link */ + if(obj_loc == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") + + /* Query object information */ + if(H5O_get_native_info(obj_loc->oloc, udata->oinfo, udata->fields) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object info") + +done: + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G__loc_native_info_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_loc_native_info + * + * Purpose: Retrieve the native information for an object from a group location + * and path to that object + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, November 23, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_loc_native_info(const H5G_loc_t *loc, const char *name, H5O_native_info_t *oinfo/*out*/, + unsigned fields) +{ + H5G_loc_native_info_t udata; /* User data for traversal callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args. */ + HDassert(loc); + HDassert(name && *name); + HDassert(oinfo); + + /* Set up user data for locating object */ + udata.fields = fields; + udata.oinfo = oinfo; + + /* Traverse group hierarchy to locate object */ + if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_native_info_cb, &udata) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_loc_native_info() */ + + +/*------------------------------------------------------------------------- * Function: H5G__loc_set_comment_cb * * Purpose: Callback for (re)setting object comment for an object in a group diff --git a/src/H5Gname.c b/src/H5Gname.c index ab8ddf4..4b0f04c 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -42,6 +42,8 @@ #include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory wrappers */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -1204,7 +1206,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info_t *linfo, +H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info2_t *linfo, void *_udata) { H5G_gnba_iter_t *udata = (H5G_gnba_iter_t *)_udata; /* User data for iteration */ @@ -1212,7 +1214,7 @@ H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info_t *linfo, H5G_name_t obj_path; /* Object's group hier. path */ H5O_loc_t obj_oloc; /* Object's object location */ hbool_t obj_found = FALSE; /* Object at 'path' found */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1223,31 +1225,39 @@ H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info_t *linfo, HDassert(udata->path == NULL); /* Check for hard link with correct address */ - if(linfo->type == H5L_TYPE_HARD && udata->loc->addr == linfo->u.address) { - H5G_loc_t grp_loc; /* Location of group */ - - /* Get group's location */ - if(H5G_loc(gid, &grp_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "bad group location") - - /* Set up opened object location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object */ - if(H5G_loc_find(&grp_loc, path, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") - obj_found = TRUE; - - /* Check for object in same file (handles mounted files) */ - /* (re-verify address, in case we traversed a file mount) */ - if(udata->loc->addr == obj_loc.oloc->addr && udata->loc->file == obj_loc.oloc->file) { - if(NULL == (udata->path = H5MM_strdup(path))) - HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, H5_ITER_ERROR, "can't duplicate path string") - - /* We found a match so we return immediately */ - HGOTO_DONE(H5_ITER_STOP) + if(linfo->type == H5L_TYPE_HARD) { + haddr_t link_addr; + + /* Retrieve hard link address from VOL token */ + if(H5VL_native_token_to_addr(udata->loc->file, H5I_FILE, linfo->u.token, &link_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + + if(udata->loc->addr == link_addr) { + H5G_loc_t grp_loc; /* Location of group */ + + /* Get group's location */ + if(H5G_loc(gid, &grp_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "bad group location") + + /* Set up opened object location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object */ + if(H5G_loc_find(&grp_loc, path, &obj_loc/*out*/) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") + obj_found = TRUE; + + /* Check for object in same file (handles mounted files) */ + /* (re-verify address, in case we traversed a file mount) */ + if(udata->loc->addr == obj_loc.oloc->addr && udata->loc->file == obj_loc.oloc->file) { + if(NULL == (udata->path = H5MM_strdup(path))) + HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, H5_ITER_ERROR, "can't duplicate path string") + + /* We found a match so we return immediately */ + HGOTO_DONE(H5_ITER_STOP) + } /* end if */ } /* end if */ } /* end if */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index d11d7a0..35b90f3 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -762,12 +762,11 @@ done: *------------------------------------------------------------------------- */ static H5B_ins_t -H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/, +H5G_node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key/*in,out*/, hbool_t H5_ATTR_UNUSED *lt_key_changed/*out*/, void *_udata/*in,out*/, void *_rt_key/*in,out*/, hbool_t *rt_key_changed/*out*/) { - H5G_node_key_t *lt_key = (H5G_node_key_t *)_lt_key; H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; H5G_bt_rm_t *udata = (H5G_bt_rm_t *)_udata; H5G_node_t *sn = NULL; @@ -781,7 +780,7 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/, /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); - HDassert(lt_key); + HDassert((H5G_node_key_t *)_lt_key); HDassert(rt_key); HDassert(udata && udata->common.heap); diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index b735dbd..19b120c 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -174,7 +174,7 @@ typedef struct { #ifndef H5_NO_DEPRECATED_SYMBOLS H5G_iterate_t op_old; /* "Old" application callback for each link */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5L_iterate_t op_new; /* "New" application callback for each link */ + H5L_iterate2_t op_new; /* "New" application callback for each link */ } op_func; } H5G_link_iterate_t; @@ -214,12 +214,12 @@ H5_DLL herr_t H5G_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, const H5G_link_iterate_t *lnk_op, void *op_data); H5_DLL herr_t H5G_visit(H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data); + H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, void *op_data); /* * Functions that understand links in groups */ -H5_DLL herr_t H5G_link_to_info(const struct H5O_link_t *lnk, H5L_info_t *linfo); +H5_DLL herr_t H5G_link_to_info(const struct H5O_loc_t *link_loc, const struct H5O_link_t *lnk, H5L_info2_t *linfo); /* * Functions that understand group objects @@ -279,7 +279,9 @@ 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, - H5O_info_t *oinfo/*out*/, unsigned fields); + H5O_info2_t *oinfo/*out*/, unsigned fields); +H5_DLL herr_t H5G_loc_native_info(const H5G_loc_t *loc, const char *name, + H5O_native_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, diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 492b5b9..7482e27 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -201,11 +201,15 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "unable to register group") /* User-defined callback function */ +#ifndef H5_NO_DEPRECATED_SYMBOLS /* (Backwardly compatible with v0 H5L_class_t traverssal callback) */ if(link_class->version == H5L_LINK_CLASS_T_VERS_0) cb_return = (((const H5L_class_0_t *)link_class)->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, lnk->u.ud.size, H5CX_get_lapl()); else cb_return = (link_class->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, lnk->u.ud.size, H5CX_get_lapl(), H5CX_get_dxpl()); +#else /* H5_NO_DEPRECATED_SYMBOLS */ + cb_return = (link_class->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, lnk->u.ud.size, H5CX_get_lapl(), H5CX_get_dxpl()); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Check for failing to locate the object */ if(cb_return < 0) { diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 2d1c1f2..4a2ff91 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -403,7 +403,7 @@ H5HF__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5HF__cache_hdr_get_final_load_size(const void *_image, size_t image_len, +H5HF__cache_hdr_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *_udata, size_t *actual_len) { H5HF_hdr_t hdr; /* Temporary fractal heap header */ @@ -749,7 +749,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t len, +H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ @@ -979,8 +979,8 @@ H5HF__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN *------------------------------------------------------------------------- */ static void * -H5HF__cache_iblock_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) +H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, + void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { H5HF_hdr_t *hdr; /* Shared fractal heap information */ H5HF_iblock_cache_ud_t *udata = (H5HF_iblock_cache_ud_t *)_udata; /* User data for callback */ @@ -1326,7 +1326,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t len, +H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5HF_hdr_t *hdr; /* Shared fractal heap information */ @@ -1471,8 +1471,8 @@ H5HF__cache_iblock_notify(H5AC_notify_action_t action, void *_thing) else { /* if this is a child iblock, verify that the pointers are */ /* either uninitialized or set up correctly. */ - H5HF_indirect_t *par_iblock = iblock->parent; - unsigned indir_idx; /* Index in parent's child iblock pointer array */ + H5HF_indirect_t H5_ATTR_NDEBUG_UNUSED *par_iblock = iblock->parent; + unsigned H5_ATTR_NDEBUG_UNUSED indir_idx; /* Index in parent's child iblock pointer array */ /* Sanity check */ HDassert(par_iblock->child_iblocks); @@ -2438,8 +2438,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HF__cache_dblock_serialize(const H5F_t *f, void *image, size_t len, - void *_thing) +H5HF__cache_dblock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, + size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Direct block info */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5HFsection.c b/src/H5HFsection.c index f5ac8e5..c11bc34 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -1185,9 +1185,9 @@ H5HF__sect_single_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5 H5HF_indirect_t *iblock; /* Indirect block that section's direct block resides in */ haddr_t dblock_addr; /* Direct block address */ size_t dblock_size; /* Direct block size */ - size_t dblock_overhead; /* Direct block's overhead */ unsigned dblock_status = 0; /* Direct block's status in the metadata cache */ - herr_t status; /* Generic status value */ + size_t H5_ATTR_NDEBUG_UNUSED dblock_overhead; /* Direct block's overhead */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Generic status value */ /* Sanity check settings for section's direct block's parent */ iblock = sect->u.single.parent; @@ -2038,7 +2038,7 @@ H5HF__sect_row_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t const H5HF_hdr_t *hdr; /* Fractal heap header */ const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Pointer to section to check */ const H5HF_free_section_t *indir_sect; /* Pointer to underlying indirect section */ - unsigned indir_idx; /* Index of row in underlying indirect section's row array */ + unsigned H5_ATTR_NDEBUG_UNUSED indir_idx; /* Index of row in underlying indirect section's row array */ FUNC_ENTER_STATIC_NOERR @@ -4125,7 +4125,7 @@ H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect) dir_nrows = (max_dir_row - start_row) + 1; HDassert(dir_nrows == sect->u.indirect.dir_nrows); for(u = 0; u < dir_nrows; u++) { - const H5HF_free_section_t *tmp_row_sect; /* Pointer to row section */ + const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED *tmp_row_sect; /* Pointer to row section */ tmp_row_sect = sect->u.indirect.dir_rows[u]; HDassert(tmp_row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW @@ -4133,7 +4133,7 @@ H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect) HDassert(tmp_row_sect->u.row.under == sect); HDassert(tmp_row_sect->u.row.row == (start_row + u)); if(u > 0) { - const H5HF_free_section_t *tmp_row_sect2; /* Pointer to row section */ + const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED *tmp_row_sect2; /* Pointer to row section */ tmp_row_sect2 = sect->u.indirect.dir_rows[u - 1]; HDassert(tmp_row_sect2->u.row.row < tmp_row_sect->u.row.row); @@ -4160,7 +4160,7 @@ H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect) HDassert(tmp_child_sect->sect_info.type == H5HF_FSPACE_SECT_INDIRECT); HDassert(tmp_child_sect->u.indirect.parent == sect); if(u > 0) { - const H5HF_free_section_t *tmp_child_sect2; /* Pointer to child indirect section */ + const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED *tmp_child_sect2; /* Pointer to child indirect section */ tmp_child_sect2 = sect->u.indirect.indir_ents[u - 1]; HDassert(H5F_addr_lt(tmp_child_sect2->sect_info.addr, tmp_child_sect->sect_info.addr)); diff --git a/src/H5HFspace.c b/src/H5HFspace.c index 37a0502..ad5ff0f 100644 --- a/src/H5HFspace.c +++ b/src/H5HFspace.c @@ -447,7 +447,7 @@ H5HF__space_size(H5HF_hdr_t *hdr, hsize_t *fs_size) /* Get free space metadata size */ if(hdr->fspace) { - if(H5FS_size(hdr->f, hdr->fspace, fs_size) < 0) + if(H5FS_size(hdr->fspace, fs_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info") } /* end if */ else diff --git a/src/H5HGcache.c b/src/H5HGcache.c index 29e88df..18625cc 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -202,7 +202,7 @@ H5HG__cache_heap_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *imag *------------------------------------------------------------------------- */ static herr_t -H5HG__cache_heap_get_final_load_size(const void *image, size_t image_len, +H5HG__cache_heap_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *udata, size_t *actual_len) { H5HG_heap_t heap; /* Global heap */ @@ -432,7 +432,7 @@ H5HG__cache_heap_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5HG__cache_heap_serialize(const H5F_t *f, void *image, size_t len, +H5HG__cache_heap_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, size_t len, void *_thing) { H5HG_heap_t *heap = (H5HG_heap_t *)_thing; diff --git a/src/H5HLcache.c b/src/H5HLcache.c index 8b04b47..b0ac05f 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -364,7 +364,7 @@ H5HL__cache_prefix_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *im *------------------------------------------------------------------------- */ static herr_t -H5HL__cache_prefix_get_final_load_size(const void *_image, size_t image_len, +H5HL__cache_prefix_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *_udata, size_t *actual_len) { const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ @@ -415,8 +415,8 @@ done: *------------------------------------------------------------------------- */ static void * -H5HL__cache_prefix_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) +H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, + void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { H5HL_t *heap = NULL; /* Local heap */ H5HL_prfx_t *prfx = NULL; /* Heap prefix deserialized */ @@ -555,7 +555,7 @@ H5HL__cache_prefix_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5HL__cache_prefix_serialize(const H5F_t *f, void *_image, size_t len, +H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5HL_prfx_t *prfx = (H5HL_prfx_t *)_thing; /* Pointer to local heap prefix to query */ @@ -826,8 +826,8 @@ H5HL__cache_datablock_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5HL__cache_datablock_serialize(const H5F_t *f, void *image, size_t len, - void *_thing) +H5HL__cache_datablock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, + size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5HL_t *heap; /* Pointer to the local heap */ H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ @@ -2219,7 +2219,7 @@ done: ssize_t H5Iget_name(hid_t id, char *name/*out*/, size_t size) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; ssize_t ret_value; /* Return value */ @@ -2269,7 +2269,7 @@ H5Iget_file_id(hid_t obj_id) /* Call internal function */ if(H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { - H5VL_object_t *vol_obj; /* Object token of obj_id */ + H5VL_object_t *vol_obj; /* Object of obj_id */ /* Get the VOL object */ if(NULL == (vol_obj = H5VL_vol_object(obj_id))) diff --git a/src/H5Itest.c b/src/H5Itest.c index 7415303..07c1965 100644 --- a/src/H5Itest.c +++ b/src/H5Itest.c @@ -78,7 +78,7 @@ ssize_t H5I__get_name_test(hid_t id, char *name/*out*/, size_t size, hbool_t *cached) { - H5VL_object_t *vol_obj; /* Object token of id */ + H5VL_object_t *vol_obj; /* Object of id */ H5G_loc_t loc; /* Object location */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ hbool_t vol_wrapper_set = FALSE;/* Whether the VOL object wrapping context was set up */ @@ -34,7 +34,7 @@ #include "H5Oprivate.h" /* File objects */ #include "H5Pprivate.h" /* Property lists */ #include "H5VLprivate.h" /* Virtual Object Layer */ - +#include "H5VLnative_private.h" /* Native VOL */ /****************/ /* Local Macros */ @@ -49,7 +49,7 @@ /* User data for path traversal routine for getting link info by name */ typedef struct { - H5L_info_t *linfo; /* Buffer to return to user */ + H5L_info2_t *linfo; /* Buffer to return to user */ } H5L_trav_gi_t; /* User data for path traversal callback to creating a link */ @@ -93,6 +93,7 @@ typedef struct { void *buf; /* User buffer */ } H5L_trav_gv_t; + /********************/ /* Local Prototypes */ /********************/ @@ -274,11 +275,11 @@ herr_t H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj1 = NULL; /* Object token of src_id */ + H5VL_object_t *vol_obj1 = NULL; /* Object of src_id */ H5VL_loc_params_t loc_params1; - H5VL_object_t *vol_obj2 = NULL; /* Object token of dst_id */ + H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */ H5VL_loc_params_t loc_params2; - H5VL_object_t tmp_vol_obj; /* Temporary object token */ + H5VL_object_t tmp_vol_obj; /* Temporary object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -364,11 +365,11 @@ herr_t H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj1 = NULL; /* Object token of src_id */ + H5VL_object_t *vol_obj1 = NULL; /* Object of src_id */ H5VL_loc_params_t loc_params1; - H5VL_object_t *vol_obj2 = NULL; /* Object token of dst_id */ + H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */ H5VL_loc_params_t loc_params2; - H5VL_object_t tmp_vol_obj; /* Temporary object token */ + H5VL_object_t tmp_vol_obj; /* Temporary object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -458,7 +459,7 @@ herr_t H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -529,9 +530,9 @@ herr_t H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj1 = NULL; /* Object token of cur_loc_id */ - H5VL_object_t *vol_obj2 = NULL; /* Object token of new_loc_id */ - H5VL_object_t tmp_vol_obj; /* Temporary object token of */ + H5VL_object_t *vol_obj1 = NULL; /* Object of cur_loc_id */ + H5VL_object_t *vol_obj2 = NULL; /* Object of new_loc_id */ + H5VL_object_t tmp_vol_obj; /* Temporary object */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ @@ -631,7 +632,7 @@ herr_t H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, const void *udata, size_t udata_size, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -696,7 +697,7 @@ done: herr_t H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -753,7 +754,7 @@ herr_t H5Ldelete_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) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -816,7 +817,7 @@ herr_t H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -872,7 +873,7 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, void *buf/*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -928,7 +929,7 @@ done: htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; htri_t ret_value = FAIL; /* Return value */ @@ -965,13 +966,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5Lget_info - * - * Purpose: Gets metadata for a link. + * Function: H5Lget_info2 * - * Return: Success: Non-negative with information in LINFO + * Purpose: Gets metadata for a link. * - * Failure: Negative + * Return: Success: Non-negative with information in LINFO + * Failure: Negative * * Programmer: James Laird * Wednesday, June 21, 2006 @@ -979,10 +979,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, +H5Lget_info2(hid_t loc_id, const char *name, H5L_info2_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -1012,11 +1012,11 @@ H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, done: FUNC_LEAVE_API(ret_value) -} /* end H5Lget_info() */ +} /* end H5Lget_info2() */ /*------------------------------------------------------------------------- - * Function: H5Lget_info_by_idx + * Function: H5Lget_info_by_idx2 * * Purpose: Gets metadata for a link, according to the order within an * index. @@ -1030,11 +1030,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lget_info_by_idx(hid_t loc_id, const char *group_name, +H5Lget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5L_info_t *linfo /*out*/, hid_t lapl_id) + H5L_info2_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -1072,7 +1072,7 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, done: FUNC_LEAVE_API(ret_value) -} /* end H5Lget_info_by_idx() */ +} /* end H5Lget_info_by_idx2() */ /*------------------------------------------------------------------------- @@ -1115,6 +1115,10 @@ H5Lregister(const H5L_class_t *cls) */ if(cls->version > H5L_LINK_CLASS_T_VERS) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5L_class_t version number") +#ifdef H5_NO_DEPRECATED_SYMBOLS + if(cls->version < H5L_LINK_CLASS_T_VERS) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "deprecated H5L_class_t version number (%d) and library built without deprecated symbol support", cls->version) +#endif /* H5_NO_DEPRECATED_SYMBOLS */ if(cls->id < H5L_TYPE_UD_MIN || cls->id > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link identification number") @@ -1229,7 +1233,7 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; ssize_t ret_value = -1; /* Return value */ @@ -1272,7 +1276,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5Literate + * Function: H5Literate2 * * Purpose: Iterates over links in a group, with user callback routine, * according to the order within an index. @@ -1290,10 +1294,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Literate(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx_p, H5L_iterate_t op, void *op_data) +H5Literate2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, + hsize_t *idx_p, H5L_iterate2_t op, void *op_data) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5I_type_t id_type; /* Type of ID */ herr_t ret_value; /* Return value */ @@ -1321,16 +1325,17 @@ H5Literate(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, loc_params.obj_type = H5I_get_type(group_id); /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, + op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) -} /* end H5Literate() */ +} /* end H5Literate2() */ /*------------------------------------------------------------------------- - * Function: H5Literate_by_name + * Function: H5Literate_by_name2 * * Purpose: Iterates over links in a group, with user callback routine, * according to the order within an index. @@ -1352,11 +1357,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Literate_by_name(hid_t loc_id, const char *group_name, +H5Literate_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, - H5L_iterate_t op, void *op_data, hid_t lapl_id) + H5L_iterate2_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ @@ -1391,7 +1396,8 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, + op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: @@ -1400,7 +1406,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5Lvisit + * Function: H5Lvisit2 * * Purpose: Recursively visit all the links in a group and all * the groups that are linked to from that group. Links within @@ -1423,15 +1429,15 @@ done: * of the operators. * * Programmer: Quincey Koziol - * November 24 2007 + * November 24 2007 * *------------------------------------------------------------------------- */ herr_t -H5Lvisit(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, - H5L_iterate_t op, void *op_data) +H5Lvisit2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, + H5L_iterate2_t op, void *op_data) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5I_type_t id_type; /* Type of ID */ herr_t ret_value; /* Return value */ @@ -1459,16 +1465,17 @@ H5Lvisit(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, TRUE, idx_type, order, NULL, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, TRUE, idx_type, order, NULL, + op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: FUNC_LEAVE_API(ret_value) -} /* end H5Lvisit() */ +} /* end H5Lvisit2() */ /*------------------------------------------------------------------------- - * Function: H5Lvisit_by_name + * Function: H5Lvisit_by_name2 * * Purpose: Recursively visit all the links in a group and all * the groups that are linked to from that group. Links within @@ -1496,10 +1503,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, H5L_iterate_t op, void *op_data, hid_t lapl_id) +H5Lvisit_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, H5L_iterate2_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ @@ -1534,12 +1541,13 @@ H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Visit the links */ - if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, TRUE, idx_type, order, NULL, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, TRUE, idx_type, order, NULL, + op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: FUNC_LEAVE_API(ret_value) -} /* end H5Lvisit_by_name() */ +} /* end H5Lvisit_by_name2() */ /* *------------------------------------------------------------------------- @@ -3143,7 +3151,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L__get_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, +H5L__get_info_cb(H5G_loc_t *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t *lnk, H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) { @@ -3157,7 +3165,7 @@ H5L__get_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNU HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Get information from the link */ - if(H5G_link_to_info(lnk, udata->linfo) < 0) + if(H5G_link_to_info(grp_loc->oloc, lnk, udata->linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info") done: @@ -3172,7 +3180,7 @@ done: /*------------------------------------------------------------------------- * Function: H5L_get_info * - * Purpose: Returns metadata about a link. + * Purpose: Returns metadata about a link. * * Return: Non-negative on success/Negative on failure * @@ -3182,7 +3190,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info_t *linfo/*out*/) +H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info2_t *linfo/*out*/) { H5L_trav_gi_t udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3235,7 +3243,7 @@ H5L__get_info_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_A lnk_copied = TRUE; /* Get information from the link */ - if(H5G_link_to_info(&fnd_lnk, udata->linfo) < 0) + if(H5G_link_to_info(obj_loc->oloc, &fnd_lnk, udata->linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info") done: @@ -3263,7 +3271,7 @@ done: */ herr_t H5L_get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5L_info_t *linfo /*out*/) + H5_iter_order_t order, hsize_t n, H5L_info2_t *linfo /*out*/) { H5L_trav_gibi_t udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3516,7 +3524,7 @@ done: */ herr_t H5L_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t *idx_p, H5L_iterate_t op, void *op_data) + H5_iter_order_t order, hsize_t *idx_p, H5L_iterate2_t op, void *op_data) { H5G_link_iterate_t lnk_op; /* Link operator */ hsize_t last_lnk; /* Index of last object looked at */ diff --git a/src/H5Ldeprec.c b/src/H5Ldeprec.c new file mode 100644 index 0000000..8b83230 --- /dev/null +++ b/src/H5Ldeprec.c @@ -0,0 +1,628 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 H5L 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 "H5Lmodule.h" /* This source code file is part of the H5L module */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ + +#include "H5VLnative_private.h" + +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + +/* Shim data for using native H5Literate/visit callbacks with the VOL */ +typedef struct H5L_shim_data_t { + H5L_iterate1_t real_op; + void *real_op_data; +} H5L_shim_data_t; + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5L__iterate2_shim + * + * Purpose: Shim function for translating between H5L_info2_t and + * H5L_info1_t structures, as used by H5Literate2/H5Lvisit2 + * and H5Literate1/H5Lvisit1, respectively. + * + * Return: Success: H5_ITER_CONT or H5_ITER_STOP + * Failure: H5_ITER_ERROR + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__iterate2_shim(hid_t group_id, const char *name, const H5L_info2_t *linfo2, void *op_data) +{ + H5L_shim_data_t *shim_data = (H5L_shim_data_t *)op_data; + H5L_info1_t linfo; + herr_t ret_value = H5_ITER_CONT; + + FUNC_ENTER_STATIC + + /* Copy the new-style members into the old-style struct */ + if (linfo2) { + linfo.type = linfo2->type; + linfo.corder_valid = linfo2->corder_valid; + linfo.corder = linfo2->corder; + linfo.cset = linfo2->cset; + if (H5L_TYPE_HARD == linfo2->type) { + if(H5VLnative_token_to_addr(group_id, linfo2->u.token, &linfo.u.address) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTUNSERIALIZE, H5_ITER_ERROR, "can't deserialize object token into address") + } + else + linfo.u.val_size = linfo2->u.val_size; + } + + /* Invoke the real callback */ + ret_value = shim_data->real_op(group_id, name, &linfo, shim_data->real_op_data); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__iterate2_shim() */ + + +/*------------------------------------------------------------------------- + * Function: H5Literate1 + * + * Purpose: Iterates over links in a group, with user callback routine, + * according to the order within an index. + * + * Same pattern of behavior as H5Giterate. + * + * Note: Deprecated in favor of H5Literate2 + * + * 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. + * + *------------------------------------------------------------------------- + */ +herr_t +H5Literate1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, + hsize_t *idx_p, H5L_iterate1_t op, void *op_data) +{ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5I_type_t id_type; /* Type of ID */ + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "iIiIo*hx*x", group_id, idx_type, order, idx_p, op, op_data); + + /* Check arguments */ + id_type = H5I_get_type(group_id); + if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") + 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 operator specified") + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if(!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Literate1 is only meant to be used with the native VOL connector") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(group_id); + + /* Set up shim */ + shim_data.real_op = op; + shim_data.real_op_data = op_data; + + /* Iterate over the links */ + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, + H5L__iterate2_shim, (void *)&shim_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Literate1() */ + + +/*------------------------------------------------------------------------- + * Function: H5Literate_by_name1 + * + * Purpose: Iterates over links in a group, with user callback routine, + * according to the order within an index. + * + * Same pattern of behavior as H5Giterate. + * + * Note: Deprecated in favor of H5Literate_by_name2 + * + * 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 + * Thursday, November 16, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Literate_by_name1(hid_t loc_id, const char *group_name, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, + H5L_iterate1_t op, void *op_data, hid_t lapl_id) +{ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, group_name, idx_type, order, idx_p, op, + op_data, lapl_id); + + /* Check arguments */ + if(!group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") + if(!*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") + 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 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_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if(!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Literate_by_name1 is only meant to be used with the native VOL connector") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = group_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* Set up shim */ + shim_data.real_op = op; + shim_data.real_op_data = op_data; + + /* Iterate over the links */ + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, + H5L__iterate2_shim, (void *)&shim_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Literate_by_name1() */ + + +/*------------------------------------------------------------------------- + * Function: H5Lget_info1 + * + * Purpose: Gets metadata for a link. + * + * Note: Deprecated in favor of H5Lget_info2 + * + * Return: Success: Non-negative with information in LINFO + * Failure: Negative + * + * Programmer: James Laird + * Wednesday, June 21, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Lget_info1(hid_t loc_id, const char *name, H5L_info1_t *linfo /*out*/, + hid_t lapl_id) +{ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + H5L_info2_t linfo2; /* New-style link info */ + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "i*sxi", loc_id, name, linfo, lapl_id); + + /* Check arguments */ + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + + /* Verify access property list and set up collective metadata if appropriate */ + if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if(!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Lget_info1 is only meant to be used with the native VOL connector") + + /* Get the link information */ + if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &linfo2) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") + + /* Copy the new-style members into the old-style struct */ + if(linfo) { + linfo->type = linfo2.type; + linfo->corder_valid = linfo2.corder_valid; + linfo->corder = linfo2.corder; + linfo->cset = linfo2.cset; + if(H5L_TYPE_HARD == linfo2.type) { + void *vol_obj_data; + + if(NULL == (vol_obj_data = H5VL_object_data(vol_obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") + + if(H5VL_native_token_to_addr(vol_obj_data, loc_params.obj_type, linfo2.u.token, &linfo->u.address) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + } /* end if */ + else + linfo->u.val_size = linfo2.u.val_size; + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Lget_info1() */ + + +/*------------------------------------------------------------------------- + * Function: H5Lget_info_by_idx1 + * + * Purpose: Gets metadata for a link, according to the order within an + * index. + * + * Note: Deprecated in favor of H5Lget_info_by_idx2 + * + * Return: Success: Non-negative with information in LINFO + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, November 6, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5L_info1_t *linfo /*out*/, hid_t lapl_id) +{ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + H5L_info2_t linfo2; /* New-style link info */ + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "i*sIiIohxi", loc_id, group_name, idx_type, order, n, linfo, + lapl_id); + + /* Check arguments */ + 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") + + /* 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_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if(!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Lget_info_by_idx1 is only meant to be used with the native VOL connector") + + /* Get the link information */ + if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &linfo2) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") + + /* Copy the new-style members into the old-style struct */ + if(linfo) { + linfo->type = linfo2.type; + linfo->corder_valid = linfo2.corder_valid; + linfo->corder = linfo2.corder; + linfo->cset = linfo2.cset; + if(H5L_TYPE_HARD == linfo2.type) { + void *vol_obj_data; + + if(NULL == (vol_obj_data = H5VL_object_data(vol_obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") + + if(H5VL_native_token_to_addr(vol_obj_data, loc_params.obj_type, linfo2.u.token, &linfo->u.address) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + } /* end if */ + else + linfo->u.val_size = linfo2.u.val_size; + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Lget_info_by_idx1() */ + + +/*------------------------------------------------------------------------- + * Function: H5Lvisit1 + * + * Purpose: Recursively visit all the links in a group and all + * the groups that are linked to from that group. 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: Each _link_ reachable from the initial group will only be + * visited once. However, because an object may be reached from + * more than one link, the visitation may call the application's + * callback with more than one link that points to a particular + * _object_. + * + * Note: Deprecated in favor of H5Lvisit2 + * + * 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 +H5Lvisit1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, + H5L_iterate1_t op, void *op_data) +{ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5I_type_t id_type; /* Type of ID */ + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "iIiIox*x", group_id, idx_type, order, op, op_data); + + /* Check args */ + id_type = H5I_get_type(group_id); + if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") + 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") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(group_id); + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if(!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Lvisit1 is only meant to be used with the native VOL connector") + + /* Set up shim */ + shim_data.real_op = op; + shim_data.real_op_data = op_data; + + /* Iterate over the links */ + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, TRUE, idx_type, order, NULL, H5L__iterate2_shim, (void *)&shim_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Lvisit1() */ + + +/*------------------------------------------------------------------------- + * Function: H5Lvisit_by_name1 + * + * Purpose: Recursively visit all the links in a group and all + * the groups that are linked to from that group. 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: Each _link_ reachable from the initial group will only be + * visited once. However, because an object may be reached from + * more than one link, the visitation may call the application's + * callback with more than one link that points to a particular + * _object_. + * + * Note: Deprecated in favor of H5Lvisit_by_name2 + * + * 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 3 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Lvisit_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, H5L_iterate1_t op, void *op_data, hid_t lapl_id) +{ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "i*sIiIox*xi", loc_id, group_name, idx_type, order, op, op_data, + lapl_id); + + /* Check args */ + if(!group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") + if(!*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") + 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_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if(!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "H5Lvisit_by_name1 is only meant to be used with the native VOL connector") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = group_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* Set up shim */ + shim_data.real_op = op; + shim_data.real_op_data = op_data; + + /* Visit the links */ + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, TRUE, idx_type, order, NULL, H5L__iterate2_shim, (void *)&shim_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Lvisit_by_name1() */ + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index dc104d7..1b007b6 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -341,7 +341,7 @@ herr_t H5Lcreate_external(const char *file_name, const char *obj_name, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; char *norm_obj_name = NULL; /* Pointer to normalized current name */ void *ext_link_buf = NULL; /* Buffer to contain external link */ diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index 6652352..ab68b84 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -68,7 +68,7 @@ typedef struct { hsize_t n; /* Offset of link within index */ /* Out */ - H5L_info_t *linfo; /* Buffer to return to user */ + H5L_info2_t *linfo; /* Buffer to return to user */ } H5L_trav_gibi_t; /* User data for path traversal routine for getting name by index */ @@ -98,7 +98,6 @@ typedef struct H5L_elink_cb_t { void *user_data; } H5L_elink_cb_t; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -124,13 +123,13 @@ H5_DLL herr_t H5L_move(const H5G_loc_t *src_loc, const char *src_name, H5_DLL htri_t H5L_exists_tolerant(const H5G_loc_t *loc, const char *name); H5_DLL htri_t H5L_exists(const H5G_loc_t *loc, const char *name); H5_DLL herr_t H5L_get_info(const H5G_loc_t *loc, const char *name, - H5L_info_t *linkbuf/*out*/); + H5L_info2_t *linkbuf/*out*/); H5_DLL herr_t H5L_delete(const H5G_loc_t *loc, const char *name); H5_DLL herr_t H5L_delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n); H5_DLL herr_t H5L_get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5L_info_t *linfo /*out*/); + H5L_info2_t *linfo /*out*/); H5_DLL ssize_t H5L_get_name_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size); @@ -142,7 +141,7 @@ H5_DLL herr_t H5L_get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_DLL herr_t H5L_register_external(void); H5_DLL herr_t H5L_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, - H5L_iterate_t op, void *op_data); + H5L_iterate2_t op, void *op_data); /* User-defined link functions */ H5_DLL herr_t H5L_register(const H5L_class_t *cls); diff --git a/src/H5Lpublic.h b/src/H5Lpublic.h index 7bdb001..3bac5ac 100644 --- a/src/H5Lpublic.h +++ b/src/H5Lpublic.h @@ -27,6 +27,7 @@ /* Public headers needed by this file */ #include "H5public.h" /* Generic Functions */ #include "H5Ipublic.h" /* IDs */ +#include "H5Opublic.h" /* Object Headers */ #include "H5Tpublic.h" /* Datatypes */ /*****************/ @@ -43,9 +44,6 @@ /* Current version of the H5L_class_t struct */ #define H5L_LINK_CLASS_T_VERS 1 -/* Previous versions of the H5L_class_t struct */ -#define H5L_LINK_CLASS_T_VERS_0 0 - #ifdef __cplusplus extern "C" { #endif @@ -72,17 +70,19 @@ typedef enum { #define H5L_TYPE_BUILTIN_MAX H5L_TYPE_SOFT /* Maximum value link value for "built-in" link types */ #define H5L_TYPE_UD_MIN H5L_TYPE_EXTERNAL /* Link ids at or above this value are "user-defined" link types. */ -/* Information struct for link (for H5Lget_info/H5Lget_info_by_idx) */ +/* Information struct for link (for H5Lget_info2/H5Lget_info_by_idx2) + * H5O_token_t version used in VOL layer and future public API calls + */ typedef struct { H5L_type_t type; /* Type of link */ hbool_t corder_valid; /* Indicate if creation order is valid */ int64_t corder; /* Creation order */ H5T_cset_t cset; /* Character set of link name */ union { - haddr_t address; /* Address hard link points to */ + H5O_token_t token; /* Token of location that hard link points to */ size_t val_size; /* Size of a soft link or UD link value */ } u; -} H5L_info_t; +} H5L_info2_t; /* The H5L_class_t struct can be used to override the behavior of a * "user-defined" link class. Users should populate the struct with callback @@ -102,8 +102,6 @@ typedef herr_t (*H5L_copy_func_t)(const char *new_name, hid_t new_loc, const void *lnkdata, size_t lnkdata_size); /* Callback during link traversal */ -typedef hid_t (*H5L_traverse_0_func_t)(const char *link_name, hid_t cur_group, - const void *lnkdata, size_t lnkdata_size, hid_t lapl_id); typedef hid_t (*H5L_traverse_func_t)(const char *link_name, hid_t cur_group, const void *lnkdata, size_t lnkdata_size, hid_t lapl_id, hid_t dxpl_id); @@ -116,19 +114,6 @@ typedef herr_t (*H5L_delete_func_t)(const char *link_name, hid_t file, typedef ssize_t (*H5L_query_func_t)(const char *link_name, const void *lnkdata, size_t lnkdata_size, void *buf /*out*/, size_t buf_size); -/* User-defined link types */ -typedef struct { - int version; /* Version number of this struct */ - H5L_type_t id; /* Link type ID */ - const char *comment; /* Comment for debugging */ - H5L_create_func_t create_func; /* Callback during link creation */ - H5L_move_func_t move_func; /* Callback after moving link */ - H5L_copy_func_t copy_func; /* Callback after copying link */ - H5L_traverse_0_func_t trav_func; /* Callback during link traversal */ - H5L_delete_func_t del_func; /* Callback for link deletion */ - H5L_query_func_t query_func; /* Callback for queries */ -} H5L_class_0_t; - typedef struct { int version; /* Version number of this struct */ H5L_type_t id; /* Link type ID */ @@ -141,8 +126,10 @@ typedef struct { H5L_query_func_t query_func; /* Callback for queries */ } H5L_class_t; -/* Prototype for H5Literate/H5Literate_by_name() operator */ -typedef herr_t (*H5L_iterate_t)(hid_t group, const char *name, const H5L_info_t *info, +/* Prototype for H5Literate2/H5Literate_by_name2() operator + * H5O_token_t version used in VOL layer and future public API calls + */ +typedef herr_t (*H5L_iterate2_t)(hid_t group, const char *name, const H5L_info2_t *info, void *op_data); /* Callback for external link traversal */ @@ -177,23 +164,23 @@ H5_DLL herr_t H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, void *buf/*out*/, size_t size, hid_t lapl_id); H5_DLL htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id); -H5_DLL herr_t H5Lget_info(hid_t loc_id, const char *name, - H5L_info_t *linfo /*out*/, hid_t lapl_id); -H5_DLL herr_t H5Lget_info_by_idx(hid_t loc_id, const char *group_name, +H5_DLL herr_t H5Lget_info2(hid_t loc_id, const char *name, + H5L_info2_t *linfo /*out*/, hid_t lapl_id); +H5_DLL herr_t H5Lget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5L_info_t *linfo /*out*/, hid_t lapl_id); + H5L_info2_t *linfo /*out*/, hid_t lapl_id); H5_DLL ssize_t H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id); -H5_DLL herr_t H5Literate(hid_t grp_id, H5_index_t idx_type, - H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data); -H5_DLL herr_t H5Literate_by_name(hid_t loc_id, const char *group_name, +H5_DLL herr_t H5Literate2(hid_t grp_id, H5_index_t idx_type, + H5_iter_order_t order, hsize_t *idx, H5L_iterate2_t op, void *op_data); +H5_DLL herr_t H5Literate_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, - H5L_iterate_t op, void *op_data, hid_t lapl_id); -H5_DLL herr_t H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, - H5L_iterate_t op, void *op_data); -H5_DLL herr_t H5Lvisit_by_name(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, + H5L_iterate2_t op, void *op_data, hid_t lapl_id); +H5_DLL herr_t H5Lvisit2(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, + H5L_iterate2_t op, void *op_data); +H5_DLL herr_t H5Lvisit_by_name2(hid_t loc_id, const char *group_name, + H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, void *op_data, hid_t lapl_id); /* UD link functions */ @@ -210,6 +197,73 @@ H5_DLL herr_t H5Lunpack_elink_val(const void *ext_linkval/*in*/, size_t link_siz H5_DLL herr_t H5Lcreate_external(const char *file_name, const char *obj_name, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id); +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/* Macros */ + +/* Previous versions of the H5L_class_t struct */ +#define H5L_LINK_CLASS_T_VERS_0 0 + + +/* Typedefs */ + +/* Information struct for link (for H5Lget_info1/H5Lget_info_by_idx1) */ +typedef struct { + H5L_type_t type; /* Type of link */ + hbool_t corder_valid; /* Indicate if creation order is valid */ + int64_t corder; /* Creation order */ + H5T_cset_t cset; /* Character set of link name */ + union { + haddr_t address; /* Address hard link points to */ + size_t val_size; /* Size of a soft link or UD link value */ + } u; +} H5L_info1_t; + +/* Callback during link traversal */ +typedef hid_t (*H5L_traverse_0_func_t)(const char *link_name, hid_t cur_group, + const void *lnkdata, size_t lnkdata_size, hid_t lapl_id); + +/* User-defined link types */ +typedef struct { + int version; /* Version number of this struct */ + H5L_type_t id; /* Link type ID */ + const char *comment; /* Comment for debugging */ + H5L_create_func_t create_func; /* Callback during link creation */ + H5L_move_func_t move_func; /* Callback after moving link */ + H5L_copy_func_t copy_func; /* Callback after copying link */ + H5L_traverse_0_func_t trav_func; /* Callback during link traversal */ + H5L_delete_func_t del_func; /* Callback for link deletion */ + H5L_query_func_t query_func; /* Callback for queries */ +} H5L_class_0_t; + +/* Prototype for H5Literate1/H5Literate_by_name1() operator */ +typedef herr_t (*H5L_iterate1_t)(hid_t group, const char *name, const H5L_info1_t *info, + void *op_data); + + +/* Function prototypes */ +H5_DLL herr_t H5Lget_info1(hid_t loc_id, const char *name, + H5L_info1_t *linfo /*out*/, hid_t lapl_id); +H5_DLL herr_t H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5L_info1_t *linfo /*out*/, hid_t lapl_id); +H5_DLL herr_t H5Literate1(hid_t grp_id, H5_index_t idx_type, + H5_iter_order_t order, hsize_t *idx, H5L_iterate1_t op, void *op_data); +H5_DLL herr_t H5Literate_by_name1(hid_t loc_id, const char *group_name, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5L_iterate1_t op, void *op_data, hid_t lapl_id); +H5_DLL herr_t H5Lvisit1(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, + H5L_iterate1_t op, void *op_data); +H5_DLL herr_t H5Lvisit_by_name1(hid_t loc_id, const char *group_name, + H5_index_t idx_type, H5_iter_order_t order, H5L_iterate1_t op, + void *op_data, hid_t lapl_id); + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + #ifdef __cplusplus } #endif @@ -256,7 +256,7 @@ H5Mcreate(hid_t loc_id, const char *name, hid_t key_type_id, hid_t val_type_id, hid_t lcpl_id, hid_t mcpl_id, hid_t mapl_id) { void *map = NULL; /* New map's info */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -343,8 +343,8 @@ hid_t H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id, hid_t mapl_id) { - void *map = NULL; /* map token from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *map = NULL; /* map object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -407,8 +407,8 @@ done: hid_t H5Mopen(hid_t loc_id, const char *name, hid_t mapl_id) { - void *map = NULL; /* map token from VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *map = NULL; /* map object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -2290,7 +2290,7 @@ H5MF_get_freespace(H5F_t *f, hsize_t *tot_space, hsize_t *meta_size) /* Retrieve free space size from free space manager */ if(H5FS_sect_stats(f->shared->fs_man[type], &type_fs_size, NULL) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space stats") - if(H5FS_size(f, f->shared->fs_man[type], &type_meta_size) < 0) + if(H5FS_size(f->shared->fs_man[type], &type_meta_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space metadata stats") /* Increment total free space for types */ @@ -102,7 +102,7 @@ hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5I_type_t opened_type; void *opened_obj = NULL; H5VL_loc_params_t loc_params; @@ -171,7 +171,7 @@ 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) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5I_type_t opened_type; void *opened_obj = NULL; H5VL_loc_params_t loc_params; @@ -217,57 +217,34 @@ done: /*------------------------------------------------------------------------- - * Function: H5Oopen_by_addr + * Function: H5Oopen_by_token * - * Purpose: Warning! This function is EXTREMELY DANGEROUS! - * Improper use can lead to FILE CORRUPTION, INACCESSIBLE DATA, - * and other VERY BAD THINGS! - * - * This function opens an object using its address within the - * HDF5 file, similar to an HDF5 hard link. The open object - * is identical to an object opened with H5Oopen() and should - * be closed with H5Oclose() or a type-specific closing - * function (such as H5Gclose() ). - * - * This function is very dangerous if called on an invalid - * address. For this reason, H5Oincr_refcount() should be - * used to prevent HDF5 from deleting any object that is - * referenced by address (e.g. by a user-defined link). - * H5Odecr_refcount() should be used when the object is - * no longer being referenced by address (e.g. when the UD link - * is deleted). - * - * The address of the HDF5 file on disk has no effect on - * H5Oopen_by_addr(), nor does the use of any unusual file - * drivers. The "address" is really the offset within the - * HDF5 file, and HDF5's file drivers will transparently - * map this to an address on disk for the filesystem. + * Purpose: Same as H5Oopen_by_addr, but uses VOL-independent tokens. * - * Return: Success: An open object identifier - * Failure: H5I_INVALID_HID + * Return: Success: An open object identifier + * Failure: H5I_INVALID_HID * - * Programmer: James Laird - * July 14 2006 + * Programmer: Dana Robinson + * Winter 2019 * *------------------------------------------------------------------------- */ hid_t -H5Oopen_by_addr(hid_t loc_id, haddr_t addr) +H5Oopen_by_token(hid_t loc_id, H5O_token_t token) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ H5I_type_t opened_type; /* Opened object type */ void *opened_obj = NULL; /* Opened object */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ - hid_t file_id = H5I_INVALID_HID; /* File ID */ - void *vol_obj_file = NULL; /* Object token of file_id */ - H5F_t *f = NULL; - uint8_t *p = NULL; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) - H5TRACE2("i", "ia", loc_id, addr); + H5TRACE2("i", "ik", loc_id, token); + + /* Check args */ + if(H5O_IS_TOKEN_UNDEF(token)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "can't open H5O_TOKEN_UNDEF") /* Get the location object */ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) @@ -277,39 +254,21 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) if((vol_obj_type = H5I_get_type(loc_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") - /* Get the file for the object */ - if((file_id = H5F_get_file_id(vol_obj, vol_obj_type, FALSE)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file or file object") - - /* Retrieve VOL object */ - if(NULL == (vol_obj_file = H5VL_vol_object(file_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") - - /* Retrieve file from VOL object */ - if(NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid VOL object") - - /* This is a native specific routine that requires serialization of the token */ - p = (uint8_t *)&obj_token; - H5F_addr_encode(f, &p, addr); - loc_params.type = H5VL_OBJECT_BY_TOKEN; - loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.loc_data.loc_by_token.token = &token; loc_params.obj_type = vol_obj_type; /* Open the object */ if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") - /* Register the dataset ID */ + /* Register the object's ID */ if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") done: - if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on file") FUNC_LEAVE_API(ret_value) -} /* end H5Oopen_by_addr() */ +} /* end H5Oopen_by_token() */ /*------------------------------------------------------------------------- @@ -337,9 +296,9 @@ herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj1 = NULL; /* object token of obj_id */ - H5VL_object_t *vol_obj2 = NULL; /* object token of new_loc_id */ - H5VL_object_t tmp_vol_obj; /* Temporary object token of */ + H5VL_object_t *vol_obj1 = NULL; /* object of obj_id */ + H5VL_object_t *vol_obj2 = NULL; /* object of new_loc_id */ + H5VL_object_t tmp_vol_obj; /* Temporary object */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ @@ -429,7 +388,7 @@ done: herr_t H5Oincr_refcount(hid_t object_id) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; @@ -479,7 +438,7 @@ done: herr_t H5Odecr_refcount(hid_t object_id) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -522,7 +481,7 @@ done: htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; htri_t ret_value = FAIL; /* Return value */ @@ -559,23 +518,21 @@ done: /*------------------------------------------------------------------------- - * Function: H5Oget_info2 + * Function: H5Oget_info3 * * Purpose: Retrieve information about an object. * - * NOTE: Add a parameter "fields" to indicate selection of object info. - * * Return: SUCCEED/FAIL * - * Programmer: Neil Fortner - * July 7 2010 + * Programmer: Dana Robinson + * Fall 2019 * *------------------------------------------------------------------------- */ herr_t -H5Oget_info2(hid_t loc_id, H5O_info_t *oinfo, unsigned fields) +H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo, unsigned fields) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -597,33 +554,31 @@ H5Oget_info2(hid_t loc_id, H5O_info_t *oinfo, unsigned fields) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") + if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") done: FUNC_LEAVE_API(ret_value) -} /* end H5Oget_info2() */ +} /* end H5Oget_info3() */ /*------------------------------------------------------------------------- - * Function: H5Oget_info_by_name2 + * Function: H5Oget_info_by_name3 * * Purpose: Retrieve information about an object * - * NOTE: Add a parameter "fields" to indicate selection of object info. - * * Return: SUCCEED/FAIL * - * Programmer: Neil Fortner - * July 7 2010 + * Programmer: Dana Robinson + * Fall 2019 * *------------------------------------------------------------------------- */ herr_t -H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info_t *oinfo, - unsigned fields, hid_t lapl_id) +H5Oget_info_by_name3(hid_t loc_id, const char *name, + H5O_info2_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -655,35 +610,33 @@ H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info_t *oinfo, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) + if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") done: FUNC_LEAVE_API(ret_value) -} /* end H5Oget_info_by_name2() */ +} /* end H5Oget_info_by_name3() */ /*------------------------------------------------------------------------- - * Function: H5Oget_info_by_idx2 - * - * Purpose: Retrieve information about an object, according to the order - * of an index. + * Function: H5Oget_info_by_idx3 * - * NOTE: Add a parameter "fields" to indicate selection of object info. + * 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 + * Programmer: Dana Robinson + * Fall 2019 * *------------------------------------------------------------------------- */ 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, unsigned fields, hid_t lapl_id) +H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_info2_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -720,12 +673,176 @@ H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") + if(H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") done: FUNC_LEAVE_API(ret_value) -} /* end H5Oget_info_by_idx2() */ +} /* end H5Oget_info_by_idx3() */ + + +/*------------------------------------------------------------------------- + * Function: H5Oget_native_info + * + * Purpose: Retrieve native file format information about an object. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Oget_native_info(hid_t loc_id, H5O_native_info_t *oinfo, unsigned fields) +{ + H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*xIu", loc_id, oinfo, fields); + + /* Check args */ + if(!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") + if(fields & ~H5O_NATIVE_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve the object's information */ + if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_native_info() */ + + +/*------------------------------------------------------------------------- + * Function: H5Oget_native_info_by_name + * + * Purpose: Retrieve native file format information about an object + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Oget_native_info_by_name(hid_t loc_id, const char *name, H5O_native_info_t *oinfo, + unsigned fields, hid_t lapl_id) +{ + H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "i*s*xIui", loc_id, name, oinfo, fields, lapl_id); + + /* Check args */ + 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 an empty string") + if(!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") + if(fields & ~H5O_NATIVE_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") + + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve the object's information */ + if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object: '%s'", name) + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_native_info_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5Oget_native_info_by_idx + * + * Purpose: Retrieve native file format information about an object, + * according to the order of an index. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Dana Robinson + * Fall 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Oget_native_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_native_info_t *oinfo, unsigned fields, hid_t lapl_id) +{ + H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "i*sIiIoh*xIui", loc_id, group_name, idx_type, order, n, oinfo, + fields, lapl_id); + + /* Check args */ + 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") + if(fields & ~H5O_NATIVE_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") + + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve the object's information */ + if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_native_info_by_idx() */ /*------------------------------------------------------------------------- @@ -748,7 +865,7 @@ done: herr_t H5Oset_comment(hid_t obj_id, const char *comment) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -797,7 +914,7 @@ herr_t H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -850,9 +967,9 @@ done: ssize_t H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - ssize_t ret_value = -1; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "i*sz", obj_id, comment, bufsize); @@ -894,9 +1011,9 @@ ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - ssize_t ret_value = -1; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE5("Zs", "i*s*szi", loc_id, name, comment, bufsize, lapl_id); @@ -929,7 +1046,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5Ovisit2 + * Function: H5Ovisit3 * * Purpose: Recursively visit an object and all the objects reachable * from it. If the starting object is a group, all the objects @@ -964,12 +1081,12 @@ done: *------------------------------------------------------------------------- */ 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) +H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate2_t op, void *op_data, unsigned fields) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; - herr_t ret_value; /* Return value */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIox*xIu", obj_id, idx_type, order, op, op_data, fields); @@ -998,11 +1115,11 @@ H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, done: FUNC_LEAVE_API(ret_value) -} /* end H5Ovisit2() */ +} /* end H5Ovisit3() */ /*------------------------------------------------------------------------- - * Function: H5Ovisit_by_name2 + * Function: H5Ovisit_by_name3 * * Purpose: Recursively visit an object and all the objects reachable * from it. If the starting object is a group, all the objects @@ -1037,12 +1154,12 @@ done: *------------------------------------------------------------------------- */ 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, unsigned fields, hid_t lapl_id) +H5Ovisit_by_name3(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ - H5VL_loc_params_t loc_params; - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIox*xIui", loc_id, obj_name, idx_type, order, op, op_data, @@ -1082,7 +1199,7 @@ H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, done: FUNC_LEAVE_API(ret_value) -} /* end H5Ovisit_by_name2() */ +} /* end H5Ovisit_by_name3() */ /*------------------------------------------------------------------------- @@ -1187,7 +1304,7 @@ done: herr_t H5Odisable_mdc_flushes(hid_t object_id) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1256,7 +1373,7 @@ done: herr_t H5Oenable_mdc_flushes(hid_t object_id) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1330,7 +1447,7 @@ done: herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1361,3 +1478,125 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Oare_mdc_flushes_disabled() */ + +/*--------------------------------------------------------------------------- + * Function: H5Otoken_cmp + * + * Purpose: Compares two VOL connector object tokens + * + * Note: Both object tokens must be from the same VOL connector class + * + * Return: Success: Non-negative, with *cmp_value set to positive if + * token1 is greater than token2, negative if token2 + * is greater than token1 and zero if token1 and + * token2 are equal. + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5Otoken_cmp(hid_t loc_id, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value) +{ + H5VL_object_t *vol_obj; /* VOL object for ID */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "i*k*k*Is", loc_id, token1, token2, cmp_value); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if(NULL == cmp_value) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid cmp_value pointer") + + /* Compare the two tokens */ + if(H5VL_token_cmp(vol_obj, token1, token2, cmp_value) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "object token comparison failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Otoken_cmp() */ + + +/*--------------------------------------------------------------------------- + * Function: H5Otoken_to_str + * + * Purpose: Serialize a connector's object token into a string + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5Otoken_to_str(hid_t loc_id, const H5O_token_t *token, char **token_str) +{ + H5VL_object_t *vol_obj; /* VOL object for ID */ + H5I_type_t vol_obj_type; /* VOL object's type */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*k**s", loc_id, token, token_str); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if(NULL == token) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer") + if(NULL == token_str) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token string pointer") + + /* Get object type */ + if((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object type") + + /* Serialize the token */ + if(H5VL_token_to_str(vol_obj, vol_obj_type, token, token_str) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "object token serialization failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Otoken_to_str() */ + + +/*--------------------------------------------------------------------------- + * Function: H5Otoken_from_str + * + * Purpose: Deserialize a string into a connector object token + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5Otoken_from_str(hid_t loc_id, const char *token_str, H5O_token_t *token) +{ + H5VL_object_t *vol_obj; /* VOL object for ID */ + H5I_type_t vol_obj_type; /* VOL object's type */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*s*k", loc_id, token_str, token); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if(NULL == token) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer") + if(NULL == token_str) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token string pointer") + + /* Get object type */ + if((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object type") + + /* Deserialize the token */ + if(H5VL_token_from_str(vol_obj, vol_obj_type, token_str, token) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "object token deserialization failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Otoken_from_str() */ + diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index 23aba09..2d95ee9 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -334,7 +334,7 @@ H5O__ainfo_free(void *mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__ainfo_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) +H5O__ainfo_delete(H5F_t *f, H5O_t H5_ATTR_NDEBUG_UNUSED *open_oh, void *_mesg) { H5O_ainfo_t *ainfo = (H5O_ainfo_t *)_mesg; herr_t ret_value = SUCCEED; /* Return value */ @@ -405,9 +405,9 @@ H5O_ainfo_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static void * -H5O__ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, +H5O__ainfo_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, void *mesg_src, H5F_t *file_dst, hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) + H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) { H5O_ainfo_t *ainfo_src = (H5O_ainfo_t *)mesg_src; H5O_ainfo_t *ainfo_dst = NULL; diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index c1f90cb..8850ef6 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -111,7 +111,7 @@ H5FL_EXTERN(H5O_cont_t); *------------------------------------------------------------------------- */ static herr_t -H5O__add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied, +H5O__add_gap(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied, size_t idx, uint8_t *new_gap_loc, size_t new_gap_size) { hbool_t merged_with_null; /* Whether the gap was merged with a null message */ diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index 71cbc1d..a4a746e 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -86,19 +86,6 @@ typedef struct { hbool_t found; /* Whether the attribute was found */ } H5O_iter_ren_t; -/* User data for iteration when iterating over attributes */ -typedef struct { - /* down */ - H5F_t *f; /* Pointer to file attribute is in */ - hid_t loc_id; /* ID of object being iterated over */ - unsigned skip; /* # of attributes to skip over */ - H5A_operator_t op; /* Callback routine for each attribute */ - void *op_data; /* User data for callback */ - - /* up */ - unsigned count; /* Count of attributes examined */ -} H5O_iter_itr_t; - /* User data for iteration when removing an attribute */ typedef struct { /* down */ @@ -109,15 +96,6 @@ typedef struct { hbool_t found; /* Found attribute to delete */ } H5O_iter_rm_t; -/* User data for iteration when checking if an attribute exists */ -typedef struct { - /* down */ - const char *name; /* Name of attribute to open */ - - /* up */ - hbool_t found; /* Found attribute */ -} H5O_iter_xst_t; - /********************/ /* Package Typedefs */ diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 683d155..8bad181 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -201,7 +201,7 @@ H5O__cache_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5O__cache_get_final_load_size(const void *image, size_t image_len, +H5O__cache_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *_udata, size_t *actual_len) { H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */ @@ -306,7 +306,7 @@ H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata) *------------------------------------------------------------------------- */ static void * -H5O__cache_deserialize(const void *image, size_t len, void *_udata, +H5O__cache_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t *dirty) { H5O_t *oh = NULL; /* Object header read in */ @@ -763,7 +763,7 @@ H5O__cache_chk_verify_chksum(const void *_image, size_t len, void *_udata) *------------------------------------------------------------------------- */ static void * -H5O__cache_chk_deserialize(const void *image, size_t len, void *_udata, +H5O__cache_chk_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t *dirty) { H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk proxy object */ diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 55013c9..469a9e0 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -88,7 +88,7 @@ static herr_t H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, static herr_t H5O__copy_free_comm_dt_cb(void *item, void *key, void *op_data); static int H5O__copy_comm_dt_cmp(const void *dt1, const void *dt2); static herr_t H5O__copy_search_comm_dt_cb(hid_t group, const char *name, - const H5L_info_t *linfo, void *udata); + const H5L_info2_t *linfo, void *udata); static htri_t H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst/*in, out*/, H5O_copy_t *cpy_info); static herr_t H5O__copy_insert_comm_dt(H5F_t *file_src, H5O_t *oh_src, @@ -197,9 +197,9 @@ herr_t H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id) { - H5VL_object_t *vol_obj1 = NULL; /* object token of src_id */ + H5VL_object_t *vol_obj1 = NULL; /* object of src_id */ H5VL_loc_params_t loc_params1; - H5VL_object_t *vol_obj2 = NULL; /* object token of dst_id */ + H5VL_object_t *vol_obj2 = NULL; /* object of dst_id */ H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ @@ -1523,7 +1523,7 @@ done: */ static herr_t H5O__copy_search_comm_dt_cb(hid_t H5_ATTR_UNUSED group, const char *name, - const H5L_info_t *linfo, void *_udata) + const H5L_info2_t *linfo, void *_udata) { H5O_copy_search_comm_dt_ud_t *udata = (H5O_copy_search_comm_dt_ud_t *)_udata; /* Skip list of dtypes in dest file */ H5G_loc_t obj_loc; /* Location of object */ diff --git a/src/H5Ocopy_ref.c b/src/H5Ocopy_ref.c index b835f8e..0de661f 100644 --- a/src/H5Ocopy_ref.c +++ b/src/H5Ocopy_ref.c @@ -38,6 +38,8 @@ #include "H5Opkg.h" /* Object headers */ #include "H5Rpkg.h" /* References */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -165,7 +167,7 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src, size_t buf_size = H5R_OBJ_REF_BUF_SIZE; size_t i; /* Local index variable */ size_t token_size = H5F_SIZEOF_ADDR(src_oloc->file); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -173,8 +175,7 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src, for(i = 0; i < ref_count; i++) { const unsigned char *src_buf = (const unsigned char *)&src_ref[i]; unsigned char *dst_buf = (unsigned char *)&dst_ref[i]; - H5VL_token_t tmp_token = { 0 }; - uint8_t *p; + H5O_token_t tmp_token = { 0 }; /* If data is not initialized, copy zeros and skip */ if(0 == HDmemcmp(src_buf, zeros, buf_size)) { @@ -185,8 +186,9 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src, /* Set up for the object copy for the reference */ if(H5R__decode_token_obj_compat(src_buf, &buf_size, &tmp_token, token_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode src object address") - p = (uint8_t *)&tmp_token; - H5F_addr_decode(src_oloc->file, (const uint8_t **)&p, &src_oloc->addr); + if(H5VL_native_token_to_addr(src_oloc->file, H5I_FILE, tmp_token, &src_oloc->addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + if(!H5F_addr_defined(src_oloc->addr) || src_oloc->addr == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "undefined reference pointer") dst_oloc->addr = HADDR_UNDEF; @@ -196,9 +198,9 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src, HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Set the object reference info for the destination file */ - p = (uint8_t *)&tmp_token; - H5F_addr_encode(dst_oloc->file, &p, dst_oloc->addr); - if(H5R__encode_token_obj_compat((const H5VL_token_t *)&tmp_token, token_size, dst_buf, &buf_size) < 0) + if(H5VL_native_addr_to_token(dst_oloc->file, H5I_FILE, dst_oloc->addr, &tmp_token) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") + if(H5R__encode_token_obj_compat((const H5O_token_t *)&tmp_token, token_size, dst_buf, &buf_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to encode dst object address") } /* end for */ @@ -365,25 +367,25 @@ H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src, for(i = 0; i < ref_count; i++) { H5R_ref_t *ref_ptr = (H5R_ref_t *)conv_buf; H5R_ref_priv_t *ref = (H5R_ref_priv_t *)&ref_ptr[i]; - H5VL_token_t tmp_token = { 0 }; - uint8_t *p; + H5O_token_t tmp_token = { 0 }; /* Get src object address */ if(H5R__get_obj_token(ref, &tmp_token, &token_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object token") - p = (uint8_t *)&tmp_token; - H5F_addr_decode(src_oloc->file, (const uint8_t **)&p, &src_oloc->addr); + if(H5VL_native_token_to_addr(src_oloc->file, H5I_FILE, tmp_token, &src_oloc->addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") /* Attempt to copy object from source to destination file */ if(H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Set dst object address */ - p = (uint8_t *)&tmp_token; - H5F_addr_encode(dst_oloc->file, &p, dst_oloc->addr); - if(H5R__set_obj_token(ref, (const H5VL_token_t *)&tmp_token, token_size) < 0) + if(H5VL_native_addr_to_token(dst_oloc->file, H5I_FILE, dst_oloc->addr, &tmp_token) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") + if(H5R__set_obj_token(ref, (const H5O_token_t *)&tmp_token, token_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set object token") - if(H5R__set_loc_id(ref, dst_loc_id, TRUE) < 0) + /* Do not set app_ref since references are released once the copy is done */ + if(H5R__set_loc_id(ref, dst_loc_id, TRUE, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set destination loc id") } /* end for */ diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index e4e8f96..e43213d 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -39,6 +39,7 @@ #include "H5VLnative_private.h" /* Native VOL connector */ +#ifndef H5_NO_DEPRECATED_SYMBOLS /****************/ /* Local Macros */ @@ -49,6 +50,13 @@ /* Local Typedefs */ /******************/ +/* Adapter for using deprecated H5Ovisit1 callbacks with the VOL */ +typedef struct H5O_visit1_adapter_t { + H5O_iterate1_t real_op; /* Application callback to invoke */ + unsigned fields; /* Original fields passed to H5Ovisit */ + void *real_op_data; /* Application op_data */ +} H5O_visit1_adapter_t; + /********************/ /* Package Typedefs */ @@ -58,7 +66,10 @@ /********************/ /* Local Prototypes */ /********************/ - +static herr_t H5O__reset_info1(H5O_info1_t *oinfo); +static herr_t H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, void *op_data); +static herr_t H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, + H5O_info1_t *oinfo, unsigned fields); /*********************/ /* Package Variables */ @@ -75,7 +86,295 @@ /*******************/ -#ifndef H5_NO_DEPRECATED_SYMBOLS +/*------------------------------------------------------------------------- + * Function: H5O__reset_info1 + * + * Purpose: Resets/initializes an H5O_info1_t struct. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O__reset_info1(H5O_info1_t *oinfo) +{ + FUNC_ENTER_STATIC_NOERR; + + /* Reset the passed-in info struct */ + HDmemset(oinfo, 0, sizeof(H5O_info1_t)); + oinfo->type = H5O_TYPE_UNKNOWN; + oinfo->addr = HADDR_UNDEF; + + FUNC_LEAVE_NOAPI(SUCCEED); +} /* end H5O__reset_info1() */ + + +/*------------------------------------------------------------------------- + * Function: H5O__iterate1_adapter + * + * 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 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, + void *op_data) +{ + H5O_visit1_adapter_t *shim_data = (H5O_visit1_adapter_t *)op_data; + H5O_info1_t oinfo; /* Deprecated object info struct */ + unsigned dm_fields; /* Fields for data model query */ + unsigned nat_fields; /* Fields for native query */ + H5VL_object_t *vol_obj; /* Object of obj_id */ + H5VL_loc_params_t loc_params; /* Location parameters for VOL callback */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(oinfo2); + HDassert(op_data); + + /* Reset the legacy info struct */ + if(H5O__reset_info1(&oinfo) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct") + + /* Check for retrieving data model information */ + dm_fields = shim_data->fields & (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS); + if(dm_fields) { + /* Set the data model fields */ + if(shim_data->fields & H5O_INFO_BASIC) { + oinfo.fileno = oinfo2->fileno; + oinfo.type = oinfo2->type; + oinfo.rc = oinfo2->rc; + + /* Deserialize VOL object token into object address */ + if(H5VLnative_token_to_addr(obj_id, oinfo2->token, &oinfo.addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + } + if(shim_data->fields & H5O_INFO_TIME) { + oinfo.atime = oinfo2->atime; + oinfo.mtime = oinfo2->mtime; + oinfo.ctime = oinfo2->ctime; + oinfo.btime = oinfo2->btime; + } + if(shim_data->fields & H5O_INFO_NUM_ATTRS) + oinfo.num_attrs = oinfo2->num_attrs; + } + + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(obj_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, H5_ITER_ERROR, "invalid location identifier") + + /* Check for retrieving native information */ + nat_fields = shim_data->fields & (H5O_INFO_HDR | H5O_INFO_META_SIZE); + if(nat_fields) { + H5O_native_info_t nat_info; /* Native object info */ + + /* Retrieve the object's native information */ + if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, &nat_info, nat_fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native info for object") + + /* Set the native fields */ + if(shim_data->fields & H5O_INFO_HDR) + HDmemcpy(&(oinfo.hdr), &(nat_info.hdr), sizeof(H5O_hdr_info_t)); + if(shim_data->fields & H5O_INFO_META_SIZE) { + HDmemcpy(&(oinfo.meta_size.obj), &(nat_info.meta_size.obj), sizeof(H5_ih_info_t)); + HDmemcpy(&(oinfo.meta_size.attr), &(nat_info.meta_size.attr), sizeof(H5_ih_info_t)); + } + } + + /* Invoke the application callback */ + ret_value = (shim_data->real_op)(obj_id, name, &oinfo, shim_data->real_op_data); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5O__iterate1_adapter() */ + + +/*------------------------------------------------------------------------- + * Function: H5O__get_info_old + * + * Purpose: Retrieve deprecated info about an object. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * December 21 2019 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, + H5O_info1_t *oinfo, unsigned fields) +{ + unsigned dm_fields; /* Fields for data model query */ + unsigned nat_fields; /* Fields for native query */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(vol_obj); + HDassert(loc_params); + + /* Reset the passed-in info struct */ + if(H5O__reset_info1(oinfo) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct") + + /* Check for retrieving data model information */ + dm_fields = fields & (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS); + if(dm_fields) { + H5O_info2_t dm_info; /* Data model object info */ + + /* Retrieve the object's data model information */ + if(H5VL_object_get(vol_obj, loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &dm_info, dm_fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") + + /* Set the data model fields */ + if(fields & H5O_INFO_BASIC) { + void *vol_obj_data; + + if(NULL == (vol_obj_data = H5VL_object_data(vol_obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") + + oinfo->fileno = dm_info.fileno; + oinfo->type = dm_info.type; + oinfo->rc = dm_info.rc; + + /* Deserialize VOL object token into object address */ + if(H5VL_native_token_to_addr(vol_obj_data, loc_params->obj_type, dm_info.token, &oinfo->addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + } /* end if */ + if(fields & H5O_INFO_TIME) { + oinfo->atime = dm_info.atime; + oinfo->mtime = dm_info.mtime; + oinfo->ctime = dm_info.ctime; + oinfo->btime = dm_info.btime; + } /* end if */ + if(fields & H5O_INFO_NUM_ATTRS) + oinfo->num_attrs = dm_info.num_attrs; + } /* end if */ + + /* Check for retrieving native information */ + nat_fields = fields & (H5O_INFO_HDR | H5O_INFO_META_SIZE); + if(nat_fields) { + H5O_native_info_t nat_info; /* Native object info */ + + /* Retrieve the object's native information */ + if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, &nat_info, nat_fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native info for object") + + /* Set the native fields */ + if(fields & H5O_INFO_HDR) + HDmemcpy(&(oinfo->hdr), &(nat_info.hdr), sizeof(H5O_hdr_info_t)); + if(fields & H5O_INFO_META_SIZE) { + HDmemcpy(&(oinfo->meta_size.obj), &(nat_info.meta_size.obj), sizeof(H5_ih_info_t)); + HDmemcpy(&(oinfo->meta_size.attr), &(nat_info.meta_size.attr), sizeof(H5_ih_info_t)); + } /* end if */ + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O__get_info_old() */ + + +/*------------------------------------------------------------------------- + * Function: H5Oopen_by_addr + * + * Purpose: Warning! This function is EXTREMELY DANGEROUS! + * Improper use can lead to FILE CORRUPTION, INACCESSIBLE DATA, + * and other VERY BAD THINGS! + * + * This function opens an object using its address within the + * HDF5 file, similar to an HDF5 hard link. The open object + * is identical to an object opened with H5Oopen() and should + * be closed with H5Oclose() or a type-specific closing + * function (such as H5Gclose() ). + * + * This function is very dangerous if called on an invalid + * address. For this reason, H5Oincr_refcount() should be + * used to prevent HDF5 from deleting any object that is + * referenced by address (e.g. by a user-defined link). + * H5Odecr_refcount() should be used when the object is + * no longer being referenced by address (e.g. when the UD link + * is deleted). + * + * The address of the HDF5 file on disk has no effect on + * H5Oopen_by_addr(), nor does the use of any unusual file + * drivers. The "address" is really the offset within the + * HDF5 file, and HDF5's file drivers will transparently + * map this to an address on disk for the filesystem. + * + * Return: Success: An open object identifier + * Failure: H5I_INVALID_HID + * + * Programmer: James Laird + * July 14 2006 + * + *------------------------------------------------------------------------- + */ +hid_t +H5Oopen_by_addr(hid_t loc_id, haddr_t addr) +{ + H5VL_object_t *vol_obj; /* Object of loc_id */ + H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ + H5I_type_t opened_type; /* Opened object type */ + void *opened_obj = NULL; /* Opened object */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + hbool_t is_native_vol_obj; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE2("i", "ia", loc_id, addr); + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Get object type */ + if((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") + if(is_native_vol_obj) { + /* This is a native-specific routine that requires serialization of the token */ + if(H5VLnative_addr_to_token(loc_id, addr, &obj_token) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, H5I_INVALID_HID, "can't serialize address into object token") + } /* end if */ + else + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, "H5Oopen_by_addr is only meant to be used with the native VOL connector") + + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.obj_type = vol_obj_type; + + /* Open the object */ + if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + + /* Register the object's ID */ + if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oopen_by_addr() */ /*------------------------------------------------------------------------- @@ -89,9 +388,9 @@ *------------------------------------------------------------------------- */ herr_t -H5Oget_info1(hid_t loc_id, H5O_info_t *oinfo) +H5Oget_info1(hid_t loc_id, H5O_info1_t *oinfo) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -111,8 +410,8 @@ H5Oget_info1(hid_t loc_id, H5O_info_t *oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, oinfo, H5O_INFO_ALL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") + if(H5O__get_info_old(vol_obj, &loc_params, oinfo, H5O_INFO_ALL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") done: FUNC_LEAVE_API(ret_value) @@ -130,9 +429,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) +H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info1_t *oinfo, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -162,8 +461,8 @@ H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t la HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, oinfo, H5O_INFO_ALL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) + if(H5O__get_info_old(vol_obj, &loc_params, oinfo, H5O_INFO_ALL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") done: FUNC_LEAVE_API(ret_value) @@ -186,9 +485,9 @@ done: */ 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_iter_order_t order, hsize_t n, H5O_info1_t *oinfo, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -223,8 +522,8 @@ H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, oinfo, H5O_INFO_ALL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") + if(H5O__get_info_old(vol_obj, &loc_params, oinfo, H5O_INFO_ALL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") done: FUNC_LEAVE_API(ret_value) @@ -232,6 +531,197 @@ done: /*------------------------------------------------------------------------- + * Function: H5Oget_info2 + * + * Purpose: Retrieve information about an object. + * + * NOTE: Add a parameter "fields" to indicate selection of object info. + * + * Return: SUCCEED/FAIL + * + * Programmer: Neil Fortner + * July 7 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Oget_info2(hid_t loc_id, H5O_info1_t *oinfo, unsigned fields) +{ + H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*xIu", loc_id, oinfo, fields); + + /* Check args */ + if(!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") + if(fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") + if(!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, "H5Oget_info2 is only meant to be used with the native VOL connector") + + /* Retrieve deprecated info struct */ + if(H5O__get_info_old(vol_obj, &loc_params, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_info2() */ + + +/*------------------------------------------------------------------------- + * Function: H5Oget_info_by_name2 + * + * Purpose: Retrieve information about an object + * + * NOTE: Add a parameter "fields" to indicate selection of object info. + * + * Return: SUCCEED/FAIL + * + * Programmer: Neil Fortner + * July 7 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info1_t *oinfo, + unsigned fields, hid_t lapl_id) +{ + H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "i*s*xIui", loc_id, name, oinfo, fields, lapl_id); + + /* Check args */ + 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 an empty string") + if(!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") + 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") + + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") + if(!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, "H5Oget_info_by_name2 is only meant to be used with the native VOL connector") + + /* Retrieve deprecated info struct */ + if(H5O__get_info_old(vol_obj, &loc_params, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_info_by_name2() */ + + +/*------------------------------------------------------------------------- + * Function: H5Oget_info_by_idx2 + * + * Purpose: Retrieve information about an object, according to the order + * of an index. + * + * NOTE: Add a parameter "fields" to indicate selection of object info. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 26 2006 + * + *------------------------------------------------------------------------- + */ +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_info1_t *oinfo, unsigned fields, hid_t lapl_id) +{ + H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "i*sIiIoh*xIui", loc_id, group_name, idx_type, order, n, oinfo, + fields, lapl_id); + + /* Check args */ + 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") + 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") + + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") + if(!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, "H5Oget_info_by_idx2 is only meant to be used with the native VOL connector") + + /* Retrieve deprecated info struct */ + if(H5O__get_info_old(vol_obj, &loc_params, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_info_by_idx2() */ + + +/*------------------------------------------------------------------------- * Function: H5Ovisit1 * * Purpose: Recursively visit an object and all the objects reachable @@ -265,10 +755,11 @@ done: */ herr_t H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate_t op, void *op_data) + H5O_iterate1_t op, void *op_data) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -290,8 +781,13 @@ H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(obj_id); + /* Set up adapter */ + shim_data.real_op = op; + shim_data.fields = H5O_INFO_ALL; + shim_data.real_op_data = op_data; + /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, H5O_INFO_ALL)) < 0) + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, (void *)&shim_data, H5O_INFO_ALL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: @@ -333,10 +829,11 @@ done: */ 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) + H5_iter_order_t order, H5O_iterate1_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ - H5VL_loc_params_t loc_params; + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -369,13 +866,203 @@ H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.loc_data.loc_by_name.lapl_id = lapl_id; loc_params.obj_type = H5I_get_type(loc_id); + /* Set up adapter */ + shim_data.real_op = op; + shim_data.fields = H5O_INFO_ALL; + shim_data.real_op_data = op_data; + /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, H5O_INFO_ALL)) < 0) + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, (void *)&shim_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() */ + +/*------------------------------------------------------------------------- + * Function: H5Ovisit2 + * + * 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. + * + * 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 + * library, or the negative value returned by one + * of the operators. + * + * Programmer: Quincey Koziol + * November 25 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate1_t op, void *op_data, unsigned fields) +{ + H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + 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) + 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") + if(fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") + if(!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, "H5Ovisit2 is only meant to be used with the native VOL connector") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + + /* Set up adapter */ + shim_data.real_op = op; + shim_data.fields = fields; + shim_data.real_op_data = op_data; + + /* Visit the objects */ + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, (void *)&shim_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Ovisit2() */ + + +/*------------------------------------------------------------------------- + * Function: H5Ovisit_by_name2 + * + * 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. + * + * 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 + * library, or the negative value returned by one + * of the operators. + * + * Programmer: Quincey Koziol + * November 24 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate1_t op, void *op_data, unsigned fields, hid_t lapl_id) +{ + H5VL_object_t *vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "i*sIiIox*xIui", loc_id, obj_name, idx_type, order, op, op_data, + fields, lapl_id); + + /* Check args */ + if(!obj_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be NULL") + if(!*obj_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be an empty string") + 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") + 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") + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if(H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") + if(!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, "H5Ovisit_by_name2 is only meant to be used with the native VOL connector") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Set up adapter */ + shim_data.real_op = op; + shim_data.fields = fields; + shim_data.real_op_data = op_data; + + /* Visit the objects */ + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, (void *)&shim_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Ovisit_by_name2() */ + #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Oflush.c b/src/H5Oflush.c index a03cfa1..b441840 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -72,7 +72,7 @@ static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, herr_t H5Oflush(hid_t obj_id) { - H5VL_object_t *vol_obj = NULL; /* Object token */ + H5VL_object_t *vol_obj = NULL; /* Object of obj_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -236,7 +236,7 @@ done: herr_t H5Orefresh(hid_t oid) { - H5VL_object_t *vol_obj = NULL; /* Object token */ + H5VL_object_t *vol_obj = NULL; /* Object of oid */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Oint.c b/src/H5Oint.c index a16102a..d5a3a71 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -43,6 +43,8 @@ #include "H5Opkg.h" /* Object headers */ #include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -58,7 +60,7 @@ typedef struct { hid_t obj_id; /* The ID for the starting group */ H5G_loc_t *start_loc; /* Location of starting group */ H5SL_t *visited; /* Skip list for tracking visited nodes */ - H5O_iterate_t op; /* Application callback */ + H5O_iterate2_t op; /* Application callback */ void *op_data; /* Application's op data */ unsigned fields; /* Selection of object info */ } H5O_iter_visit_ud_t; @@ -78,9 +80,11 @@ static herr_t H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type); static herr_t H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr); static herr_t H5O__free_visit_visited(void *item, void *key, void *operator_data/*in,out*/); -static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info_t *linfo, +static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void *_udata); static const H5O_obj_class_t *H5O__obj_class_real(const H5O_t *oh); +static herr_t H5O__reset_info2(H5O_info2_t *oinfo); + /*********************/ /* Package Variables */ @@ -151,6 +155,13 @@ H5FL_BLK_DEFINE(chunk_image); /* Declare external the free list for H5O_cont_t sequences */ H5FL_SEQ_EXTERN(H5O_cont_t); +/* The canonical 'undefined' token */ +const H5O_token_t H5O_TOKEN_UNDEF_g = {{ + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255}}; + /*****************************/ /* Library Private Variables */ @@ -2155,9 +2166,7 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) /*------------------------------------------------------------------------- * Function: H5O_get_info * - * Purpose: Retrieve the information for an object - * - * Note: Add a parameter "fields" to indicate selection of object info. + * Purpose: Retrieve the data model information for an object * * Return: Success: Non-negative * Failure: Negative @@ -2168,7 +2177,7 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) *------------------------------------------------------------------------- */ herr_t -H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields) +H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields) { const H5O_obj_class_t *obj_class; /* Class of object for header */ H5O_t *oh = NULL; /* Object header */ @@ -2189,15 +2198,17 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class") /* Reset the object info structure */ - HDmemset(oinfo, 0, sizeof(*oinfo)); + if(H5O__reset_info2(oinfo) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct") /* Get basic information, if requested */ if(fields & H5O_INFO_BASIC) { /* Retrieve the file's fileno */ H5F_GET_FILENO(loc->file, oinfo->fileno); - /* Set the object's address */ - oinfo->addr = loc->addr; + /* Set the object's address into the token */ + if(H5VL_native_addr_to_token(loc->file, H5I_FILE, loc->addr, &oinfo->token) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") /* Retrieve the type of the object */ oinfo->type = obj_class->type; @@ -2249,18 +2260,63 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields) } /* end else */ } /* end if */ - /* 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(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") +done: + if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI_TAG(ret_value) +} /* end H5O_get_info() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_native_info + * + * Purpose: Retrieve the native file-format information for an object + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 21 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fields) +{ + const H5O_obj_class_t *obj_class; /* Class of object for header */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) + + /* Check args */ + HDassert(loc); + HDassert(oinfo); + + /* Get the object header */ + if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") + + /* 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") + + /* Reset the object info structure */ + HDmemset(oinfo, 0, sizeof(*oinfo)); + + /* Get the information for the object header, if requested */ + if(fields & H5O_NATIVE_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") + /* Get B-tree & heap metadata storage size, if requested */ - if(fields & H5O_INFO_META_SIZE) { + if(fields & H5O_NATIVE_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 */ @@ -2268,10 +2324,8 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info") /* Get B-tree & heap info for any attributes */ - 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 */ + 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 */ done: @@ -2279,7 +2333,7 @@ done: HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) -} /* end H5O_get_info() */ +} /* end H5O_get_native_info() */ /*------------------------------------------------------------------------- @@ -2593,7 +2647,7 @@ H5O__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static herr_t -H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *linfo, +H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *linfo, void *_udata) { H5O_iter_visit_ud_t *udata = (H5O_iter_visit_ud_t *)_udata; /* User data for callback */ @@ -2631,7 +2685,7 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *li /* Check if we've seen the object the link references before */ if(NULL == H5SL_search(udata->visited, &obj_pos)) { - H5O_info_t oinfo; /* Object info */ + H5O_info2_t oinfo; /* Object info */ /* Get the object's info */ if(H5O_get_info(&obj_oloc, &oinfo, udata->fields) < 0) @@ -2707,14 +2761,14 @@ done: */ herr_t H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields) + H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields) { H5O_iter_visit_ud_t udata; /* User data for callback */ H5G_loc_t obj_loc; /* Location used to open object */ 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 */ - H5O_info_t oinfo; /* Object info struct */ + H5O_info2_t oinfo; /* Object info struct */ void *obj = NULL; /* Object */ H5I_type_t opened_type; /* ID type of object */ hid_t obj_id = H5I_INVALID_HID; /* ID of object */ @@ -2790,7 +2844,10 @@ H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, /* Construct unique "position" for this object */ obj_pos->fileno = oinfo.fileno; - obj_pos->addr = oinfo.addr; + + /* De-serialize object token into an object address */ + if(H5VL_native_token_to_addr(loc->oloc->file, H5I_FILE, oinfo.token, &(obj_pos->addr)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") /* Add to list of visited objects */ if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0) @@ -3027,3 +3084,25 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__free() */ +/*------------------------------------------------------------------------- + * Function: H5O__reset_info2 + * + * Purpose: Resets/initializes an H5O_info2_t struct. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O__reset_info2(H5O_info2_t *oinfo) +{ + FUNC_ENTER_STATIC_NOERR; + + /* Reset the passed-in info struct */ + HDmemset(oinfo, 0, sizeof(H5O_info2_t)); + oinfo->type = H5O_TYPE_UNKNOWN; + oinfo->token = H5O_TOKEN_UNDEF; + + FUNC_LEAVE_NOAPI(SUCCEED); +} /* end H5O__reset_info2() */ + diff --git a/src/H5Omessage.c b/src/H5Omessage.c index 18f3706..d66ea69 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -1686,17 +1686,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_msg_reset_share(unsigned type_id, void *mesg) +H5O_msg_reset_share(unsigned H5_ATTR_NDEBUG_UNUSED type_id, void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ - HDassert(type); - HDassert(type->share_flags & H5O_SHARE_IS_SHARABLE); + HDassert(H5O_msg_class_g[type_id]); /* map the type ID to the actual type object */ + HDassert(H5O_msg_class_g[type_id]->share_flags & H5O_SHARE_IS_SHARABLE); HDassert(mesg); /* Reset the shared component in the message to zero. */ diff --git a/src/H5Opkg.h b/src/H5Opkg.h index c7167c7..fb08f7d 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -557,7 +557,7 @@ H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATATYPE[1]; H5_DLL const H5O_obj_class_t *H5O__obj_class(const H5O_loc_t *loc); H5_DLL int H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted); H5_DLL herr_t H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields); + H5_iter_order_t order, H5O_iterate2_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 5965fc6..52a72b2 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -907,7 +907,8 @@ 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, H5O_info_t *oinfo, unsigned fields); +H5_DLL herr_t H5O_get_info(const H5O_loc_t *oloc, H5O_info2_t *oinfo, unsigned fields); +H5_DLL herr_t H5O_get_native_info(const H5O_loc_t *oloc, H5O_native_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 void *H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *opened_type/*out*/); diff --git a/src/H5Opublic.h b/src/H5Opublic.h index cda446b..d0f8ab3 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -80,9 +80,19 @@ #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) +#define H5O_INFO_ALL (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS) + +/* Flags for H5Oget_native_info. + * Theses flags determine which fields will be filled in in the H5O_native_info_t + * struct. + */ +#define H5O_NATIVE_INFO_HDR 0x0008u /* Fill in the hdr field */ +#define H5O_NATIVE_INFO_META_SIZE 0x0010u /* Fill in the meta_size field */ +#define H5O_NATIVE_INFO_ALL (H5O_NATIVE_INFO_HDR | H5O_NATIVE_INFO_META_SIZE) + +/* Convenience macro to check if the token is the 'undefined' token value */ +#define H5O_IS_TOKEN_UNDEF(token) (!HDmemcmp(&(token), &(H5O_TOKEN_UNDEF), sizeof(H5O_token_t))) + /*******************/ /* Public Typedefs */ @@ -116,30 +126,36 @@ typedef struct H5O_hdr_info_t { } mesg; } H5O_hdr_info_t; -/* Information struct for object (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx) */ -typedef struct H5O_info_t { - unsigned long fileno; /* File number that object is located in */ - haddr_t addr; /* Object address in file */ - H5O_type_t type; /* Basic object type (group, dataset, etc.) */ - unsigned rc; /* Reference count of object */ - time_t atime; /* Access time */ - time_t mtime; /* Modification time */ - time_t ctime; /* Change time */ - time_t btime; /* Birth time */ - hsize_t num_attrs; /* # of attributes attached to object */ +/* Data model information struct for objects */ +/* (For H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx version 3) */ +typedef struct H5O_info2_t { + unsigned long fileno; /* File number that object is located in */ + H5O_token_t token; /* Token representing the object */ + H5O_type_t type; /* Basic object type (group, dataset, etc.) */ + unsigned rc; /* Reference count of object */ + time_t atime; /* Access time */ + time_t mtime; /* Modification time */ + time_t ctime; /* Change time */ + time_t btime; /* Birth time */ + hsize_t num_attrs; /* # of attributes attached to object */ +} H5O_info2_t; + +/* Native file format information struct for objects */ +/* (For H5Oget_native_info / H5Oget_native_info_by_name / H5Oget_native_info_by_idx) */ +typedef struct H5O_native_info_t { H5O_hdr_info_t hdr; /* Object header information */ /* Extra metadata storage for obj & attributes */ struct { H5_ih_info_t obj; /* v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */ H5_ih_info_t attr; /* v2 B-tree & heap for attributes */ } meta_size; -} H5O_info_t; +} H5O_native_info_t; /* Typedef for message creation indexes */ typedef uint32_t H5O_msg_crt_idx_t; -/* Prototype for H5Ovisit/H5Ovisit_by_name() operator */ -typedef herr_t (*H5O_iterate_t)(hid_t obj, const char *name, const H5O_info_t *info, +/* Prototype for H5Ovisit/H5Ovisit_by_name() operator (version 3) */ +typedef herr_t (*H5O_iterate2_t)(hid_t obj, const char *name, const H5O_info2_t *info, void *op_data); typedef enum H5O_mcdt_search_ret_t { @@ -165,15 +181,21 @@ extern "C" { #endif H5_DLL hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id); -H5_DLL hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr); +H5_DLL hid_t H5Oopen_by_token(hid_t loc_id, H5O_token_t token); 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_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, +H5_DLL herr_t H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo, unsigned fields); +H5_DLL herr_t H5Oget_info_by_name3(hid_t loc_id, const char *name, H5O_info2_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, +H5_DLL herr_t H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info2_t *oinfo, + unsigned fields, hid_t lapl_id); +H5_DLL herr_t H5Oget_native_info(hid_t loc_id, H5O_native_info_t *oinfo, unsigned fields); +H5_DLL herr_t H5Oget_native_info_by_name(hid_t loc_id, const char *name, H5O_native_info_t *oinfo, + unsigned fields, hid_t lapl_id); +H5_DLL herr_t H5Oget_native_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_native_info_t *oinfo, 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); @@ -187,10 +209,10 @@ 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 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, +H5_DLL herr_t H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate2_t op, void *op_data, unsigned fields); +H5_DLL herr_t H5Ovisit_by_name3(hid_t loc_id, const char *obj_name, + H5_index_t idx_type, H5_iter_order_t order, H5O_iterate2_t op, 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); @@ -198,6 +220,14 @@ H5_DLL herr_t H5Orefresh(hid_t oid); H5_DLL herr_t H5Odisable_mdc_flushes(hid_t object_id); H5_DLL herr_t H5Oenable_mdc_flushes(hid_t object_id); H5_DLL herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled); +H5_DLL herr_t H5Otoken_cmp(hid_t loc_id, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value); +H5_DLL herr_t H5Otoken_to_str(hid_t loc_id, const H5O_token_t *token, char **token_str); +H5_DLL herr_t H5Otoken_from_str(hid_t loc_id, const char *token_str, H5O_token_t *token); + +/* The canonical 'undefined' token value */ +#define H5O_TOKEN_UNDEF (H5OPEN H5O_TOKEN_UNDEF_g) +H5_DLLVAR const H5O_token_t H5O_TOKEN_UNDEF_g; /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -207,6 +237,12 @@ H5_DLL herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled /* Macros */ +/* Deprecated flags for earlier versions of H5Oget_info* */ +#define H5O_INFO_HDR 0x0008u /* Fill in the hdr field */ +#define H5O_INFO_META_SIZE 0x0010u /* Fill in the meta_size field */ +#undef H5O_INFO_ALL +#define H5O_INFO_ALL (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS | H5O_INFO_HDR | H5O_INFO_META_SIZE) + /* Typedefs */ /* A struct that's part of the H5G_stat_t structure (deprecated) */ @@ -217,19 +253,56 @@ typedef struct H5O_stat_t { unsigned nchunks; /* Number of object header chunks */ } H5O_stat_t; +/* Information struct for object */ +/* (For H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx versions 1 & 2) */ +typedef struct H5O_info1_t { + unsigned long fileno; /* File number that object is located in */ + haddr_t addr; /* Object address in file */ + H5O_type_t type; /* Basic object type (group, dataset, etc.) */ + unsigned rc; /* Reference count of object */ + time_t atime; /* Access time */ + time_t mtime; /* Modification time */ + time_t ctime; /* Change time */ + time_t btime; /* Birth time */ + hsize_t num_attrs; /* # of attributes attached to object */ + H5O_hdr_info_t hdr; /* Object header information */ + /* Extra metadata storage for obj & attributes */ + struct { + H5_ih_info_t obj; /* v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */ + H5_ih_info_t attr; /* v2 B-tree & heap for attributes */ + } meta_size; +} H5O_info1_t; + +/* Prototype for H5Ovisit/H5Ovisit_by_name() operator (versions 1 & 2) */ +typedef herr_t (*H5O_iterate1_t)(hid_t obj, const char *name, const H5O_info1_t *info, + void *op_data); + + /* 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, +H5_DLL hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr); +H5_DLL herr_t H5Oget_info1(hid_t loc_id, H5O_info1_t *oinfo); +H5_DLL herr_t H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info1_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, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info1_t *oinfo, hid_t lapl_id); - +H5_DLL herr_t H5Oget_info2(hid_t loc_id, H5O_info1_t *oinfo, unsigned fields); +H5_DLL herr_t H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info1_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_info1_t *oinfo, + unsigned fields, 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); + H5O_iterate1_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, + H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, void *op_data, hid_t lapl_id); +H5_DLL herr_t H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate1_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_iterate1_t op, + void *op_data, unsigned fields, hid_t lapl_id); + #endif /* H5_NO_DEPRECATED_SYMBOLS */ #ifdef __cplusplus diff --git a/src/H5Oshared.c b/src/H5Oshared.c index 67ca76f..b49e501 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -589,9 +589,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__shared_copy_file(H5F_t *file_src, H5F_t *file_dst, +H5O__shared_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, H5F_t *file_dst, const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst, - hbool_t H5_ATTR_UNUSED *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned *mesg_flags, H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) { const H5O_shared_t *shared_src = (const H5O_shared_t *)_native_src; /* Alias to shared info in native source */ diff --git a/src/H5Oshared.h b/src/H5Oshared.h index 8040a6a..e4ad980 100644 --- a/src/H5Oshared.h +++ b/src/H5Oshared.h @@ -381,7 +381,7 @@ done: *------------------------------------------------------------------------- */ static H5_INLINE herr_t -H5O_SHARED_POST_COPY_FILE(const H5O_loc_t *oloc_src, const void *mesg_src, +H5O_SHARED_POST_COPY_FILE(const H5O_loc_t H5_ATTR_NDEBUG_UNUSED *oloc_src, const void *mesg_src, H5O_loc_t *oloc_dst, void *mesg_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info) { diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 22252d3..3668229 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -5753,10 +5753,10 @@ H5P__facc_vol_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED { const H5VL_connector_prop_t *info1 = (const H5VL_connector_prop_t *)_info1; /* Create local aliases for values */ const H5VL_connector_prop_t *info2 = (const H5VL_connector_prop_t *)_info2; - H5VL_class_t *cls1, *cls2; /* connector class for each property */ - int cmp_value = 0; /* Value from comparison */ - herr_t status; /* Status from info comparison */ - int ret_value = 0; /* Return value */ + H5VL_class_t *cls1, *cls2; /* connector class for each property */ + int cmp_value = 0; /* Value from comparison */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Status from info comparison */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Pint.c b/src/H5Pint.c index 2911eef..0810427 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -2780,8 +2780,8 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__poke_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void *_udata) +H5P__poke_plist_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_ATTR_NDEBUG_UNUSED *name, + H5P_genprop_t *prop, void *_udata) { H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2827,7 +2827,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__poke_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, +H5P__poke_pclass_cb(H5P_genplist_t *plist, const char H5_ATTR_NDEBUG_UNUSED *name, H5P_genprop_t *prop, void *_udata) { H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ @@ -4260,10 +4260,9 @@ property list class. REVISION LOG --------------------------------------------------------------------------*/ static int -H5P__iterate_pclass_cb(void *_item, void *_key, void *_udata) +H5P__iterate_pclass_cb(void *_item, void H5_ATTR_NDEBUG_UNUSED *_key, void *_udata) { H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ - char *key = (char *)_key; /* Pointer to the property's name */ H5P_iter_pclass_ud_t *udata = (H5P_iter_pclass_ud_t *)_udata; /* Pointer to user data */ int ret_value = 0; /* Return value */ @@ -4271,7 +4270,7 @@ H5P__iterate_pclass_cb(void *_item, void *_key, void *_udata) /* Sanity check */ HDassert(item); - HDassert(key); + HDassert((char *)_key); /* Check if we've found the correctly indexed property */ if(*udata->curr_idx_ptr >= udata->prev_idx) { @@ -4397,8 +4396,8 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__peek_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void *_udata) +H5P__peek_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_ATTR_NDEBUG_UNUSED *name, + H5P_genprop_t *prop, void *_udata) { H5P_prop_get_ud_t *udata = (H5P_prop_get_ud_t *)_udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Plapl.c b/src/H5Plapl.c index d899fa9..6e582fb 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -567,7 +567,7 @@ H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t H5_ATTR_ if(obj1 == NULL && obj2 != NULL) HGOTO_DONE(1); if(obj1 != NULL && obj2 == NULL) HGOTO_DONE(-1); if(obj1 && obj2) { - herr_t status; + herr_t H5_ATTR_NDEBUG_UNUSED status; status = H5P__cmp_plist(obj1, obj2, &ret_value); HDassert(status >= 0); diff --git a/src/H5Pmapl.c b/src/H5Pmapl.c index fe5be0f..3a3f619 100644 --- a/src/H5Pmapl.c +++ b/src/H5Pmapl.c @@ -137,6 +137,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__macc_reg_prop() */ +#ifdef H5_HAVE_MAP_API /*------------------------------------------------------------------------- * Function: H5Pset_map_iterate_hints @@ -214,4 +215,4 @@ H5Pget_map_iterate_hints(hid_t mapl_id, size_t *key_prefetch_size, size_t *key_a done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_map_iterate_hints() */ - +#endif @@ -66,22 +66,22 @@ /*------------------------------------------------------------------------- * Function: H5Rcreate_object * - * Purpose: Creates an object reference. The LOC_ID and NAME are used to locate - * the object pointed to. + * Purpose: Creates an object reference. The LOC_ID and NAME are used + * to locate the object pointed to. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success / Negative on failure * *------------------------------------------------------------------------- */ herr_t H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t obj_type; /* Object type of loc_id */ hid_t file_id = H5I_INVALID_HID;/* File ID */ - H5VL_object_t *vol_obj_file = NULL; /* Object token of file_id */ + H5VL_object_t *vol_obj_file = NULL; /* Object of file_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; herr_t ret_value = SUCCEED; /* Return value */ @@ -135,11 +135,11 @@ H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_p /* Create the reference (do not pass filename, since file_id is attached) */ HDmemset(ref_ptr, 0, H5R_REF_BUF_SIZE); - if(H5R__create_object((const H5VL_token_t *)&obj_token, cont_info.token_size, (H5R_ref_priv_t *)ref_ptr) < 0) + if(H5R__create_object((const H5O_token_t *)&obj_token, cont_info.token_size, (H5R_ref_priv_t *)ref_ptr) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create object reference") /* Attach loc_id to reference and hold reference to it */ - if(H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE) < 0) + if(H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference") done: @@ -152,11 +152,11 @@ done: /*------------------------------------------------------------------------- * Function: H5Rcreate_region * - * Purpose: Creates a region reference. The LOC_ID and NAME are used to locate - * the object pointed to and the SPACE_ID is used to choose the region pointed - * to. + * Purpose: Creates a region reference. The LOC_ID and NAME are used to + * locate the object pointed to and the SPACE_ID is used to + * choose the region pointed to. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success / Negative on failure * *------------------------------------------------------------------------- */ @@ -164,12 +164,12 @@ herr_t H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t obj_type; /* Object type of loc_id */ hid_t file_id = H5I_INVALID_HID;/* File ID */ - H5VL_object_t *vol_obj_file = NULL; /* Object token of file_id */ + H5VL_object_t *vol_obj_file = NULL; /* Object of file_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; struct H5S_t *space = NULL; /* Pointer to dataspace containing region */ herr_t ret_value = SUCCEED; /* Return value */ @@ -228,11 +228,11 @@ H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, /* Create the reference (do not pass filename, since file_id is attached) */ HDmemset(ref_ptr, 0, H5R_REF_BUF_SIZE); - if(H5R__create_region((const H5VL_token_t *)&obj_token, cont_info.token_size, space, (H5R_ref_priv_t *)ref_ptr) < 0) + if(H5R__create_region((const H5O_token_t *)&obj_token, cont_info.token_size, space, (H5R_ref_priv_t *)ref_ptr) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create region reference") /* Attach loc_id to reference and hold reference to it */ - if(H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE) < 0) + if(H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference") done: @@ -245,10 +245,10 @@ done: /*------------------------------------------------------------------------- * Function: H5Rcreate_attr * - * Purpose: Creates an attribute reference. The LOC_ID, NAME and ATTR_NAME are - * used to locate the attribute pointed to. + * Purpose: Creates an attribute reference. The LOC_ID, NAME and + * ATTR_NAME are used to locate the attribute pointed to. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success / Negative on failure * *------------------------------------------------------------------------- */ @@ -256,12 +256,12 @@ herr_t H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t obj_type; /* Object type of loc_id */ hid_t file_id = H5I_INVALID_HID;/* File ID */ - H5VL_object_t *vol_obj_file = NULL; /* Object token of file_id */ + H5VL_object_t *vol_obj_file = NULL; /* Object of file_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; herr_t ret_value = SUCCEED; /* Return value */ @@ -317,11 +317,11 @@ H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, /* Create the reference (do not pass filename, since file_id is attached) */ HDmemset(ref_ptr, 0, H5R_REF_BUF_SIZE); - if(H5R__create_attr((const H5VL_token_t *)&obj_token, cont_info.token_size, attr_name, (H5R_ref_priv_t *)ref_ptr) < 0) + if(H5R__create_attr((const H5O_token_t *)&obj_token, cont_info.token_size, attr_name, (H5R_ref_priv_t *)ref_ptr) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create attribute reference") /* Attach loc_id to reference and hold reference to it */ - if(H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE) < 0) + if(H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference") done: @@ -334,9 +334,10 @@ done: /*------------------------------------------------------------------------- * Function: H5Rdestroy * - * Purpose: Destroy reference and free resources allocated during H5Rcreate. + * Purpose: Destroy reference and free resources allocated during + * H5Rcreate. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success / Negative on failure * *------------------------------------------------------------------------- */ @@ -367,9 +368,10 @@ done: /*------------------------------------------------------------------------- * Function: H5Rget_type * - * Purpose: Given a reference to some object, return the type of that reference. + * Purpose: Given a reference to some object, return the type of that + * reference. * - * Return: Reference type/H5R_BADTYPE on failure + * Return: Reference type / H5R_BADTYPE on failure * *------------------------------------------------------------------------- */ @@ -398,9 +400,9 @@ done: /*------------------------------------------------------------------------- * Function: H5Requal * - * Purpose: Compare two references + * Purpose: Compare two references * - * Return: TRUE if equal, FALSE if unequal, FAIL if error + * Return: TRUE if equal, FALSE if unequal, FAIL if error * *------------------------------------------------------------------------- */ @@ -428,9 +430,9 @@ done: /*------------------------------------------------------------------------- * Function: H5Rcopy * - * Purpose: Copy a reference + * Purpose: Copy a reference * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success / Negative on failure * *------------------------------------------------------------------------- */ @@ -458,20 +460,20 @@ done: /*------------------------------------------------------------------------- * Function: H5Ropen_object * - * Purpose: Given a reference to some object, open that object and return an - * ID for that object. + * Purpose: Given a reference to some object, open that object and + * return an ID for that object. * - * Return: Valid ID on success/Negative on failure + * Return: Valid ID on success / H5I_INVALID_HID on failure * *------------------------------------------------------------------------- */ hid_t -H5Ropen_object(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id) +H5Ropen_object(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id) { hid_t loc_id; /* Reference location ID */ - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ H5I_type_t opened_type; /* Opened object type */ void *opened_obj = NULL; /* Opened object */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -530,21 +532,21 @@ done: /*------------------------------------------------------------------------- * Function: H5Ropen_region * - * Purpose: 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 pointed to. + * Purpose: 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 pointed to. * - * Return: Valid ID on success/Negative on failure + * Return: Valid ID on success / H5I_INVALID_HID on failure * *------------------------------------------------------------------------- */ hid_t -H5Ropen_region(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id) +H5Ropen_region(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id) { hid_t loc_id; /* Reference location ID */ - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ H5I_type_t opened_type; /* Opened object type */ void *opened_obj = NULL; /* Opened object */ hid_t opened_obj_id = H5I_INVALID_HID; /* Opened object ID */ @@ -625,20 +627,20 @@ done: /*------------------------------------------------------------------------- * Function: H5Ropen_attr * - * Purpose: Given a reference to some attribute, open that attribute and - * return an ID for that attribute. + * Purpose: Given a reference to some attribute, open that attribute and + * return an ID for that attribute. * - * Return: Valid ID on success/Negative on failure + * Return: Valid ID on success / H5I_INVALID_HID on failure * *------------------------------------------------------------------------- */ hid_t -H5Ropen_attr(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id) +H5Ropen_attr(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id) { hid_t loc_id; /* Reference location ID */ - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ H5I_type_t opened_type; /* Opened object type */ void *opened_obj = NULL; /* Opened object */ hid_t opened_obj_id = H5I_INVALID_HID; /* Opened object ID */ @@ -720,20 +722,20 @@ done: /*------------------------------------------------------------------------- * Function: H5Rget_obj_type3 * - * Purpose: Given a reference to some object, this function returns the type - * of object pointed to. + * Purpose: Given a reference to some object, this function returns the + * type of object pointed to. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success / Negative on failure * *------------------------------------------------------------------------- */ herr_t -H5Rget_obj_type3(const H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type) +H5Rget_obj_type3(H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type) { hid_t loc_id; /* Reference location ID */ - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -780,10 +782,10 @@ done: /*------------------------------------------------------------------------- * Function: H5Rget_file_name * - * Purpose: Given a reference to some object, determine a file name of the - * object located into. + * Purpose: Given a reference to some object, determine a file name of the + * object located into. * - * Return: Non-negative length of the path on success/Negative on failure + * Return: Non-negative length of the path on success / -1 on failure * *------------------------------------------------------------------------- */ @@ -809,8 +811,9 @@ H5Rget_file_name(const H5R_ref_t *ref_ptr, char *buf, size_t size) * copy of the filename */ if((ret_value = H5R__get_file_name((const H5R_ref_priv_t *)ref_ptr, buf, size)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to retrieve file name") - } else { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + } + else { + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ /* Retrieve VOL file object */ if(NULL == (vol_obj = H5VL_vol_object(loc_id))) @@ -828,21 +831,21 @@ done: /*------------------------------------------------------------------------- * Function: H5Rget_obj_name * - * Purpose: Given a reference to some object, determine a path to the object - * referenced in the file. + * Purpose: Given a reference to some object, determine a path to the + * object referenced in the file. * - * Return: Non-negative length of the path on success/Negative on failure + * Return: Non-negative length of the path on success / -1 on failure * *------------------------------------------------------------------------- */ ssize_t -H5Rget_obj_name(const H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size) +H5Rget_obj_name(H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size) { hid_t loc_id; /* Reference location ID */ - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ - ssize_t ret_value; /* Return value */ + H5O_token_t obj_token = {0}; /* Object token */ + ssize_t ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE4("Zs", "*Rri*sz", ref_ptr, rapl_id, buf, size); @@ -864,7 +867,7 @@ H5Rget_obj_name(const H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size) } /* Get object token */ - if((ret_value = H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL)) < 0) + if(H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to get object token") /* Get the VOL object */ @@ -888,9 +891,9 @@ done: /*------------------------------------------------------------------------- * Function: H5Rget_attr_name * - * Purpose: Given a reference to some attribute, determine its name. + * Purpose: Given a reference to some attribute, determine its name. * - * Return: Non-negative length of the path on success/Negative on failure + * Return: Non-negative length of the path on success / -1 on failure * *------------------------------------------------------------------------- */ diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index 256c930..4e44683 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -87,20 +87,20 @@ /*------------------------------------------------------------------------- * Function: H5Rget_obj_type1 * - * Purpose: Retrieves the type of the object that a reference points to. + * Purpose: Retrieves the type of the object that a reference points to. * - * Return: Object type (as defined in H5Gpublic.h) on success - * H5G_UNKNOWN on failure + * Return: Success: Object type (as defined in H5Gpublic.h) + * Failure: H5G_UNKNOWN * *------------------------------------------------------------------------- */ H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ H5O_type_t obj_type; /* Object type */ const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */ H5G_obj_t ret_value; /* Return value */ @@ -146,20 +146,21 @@ done: /*------------------------------------------------------------------------- * Function: H5Rdereference1 * - * Purpose: Given a reference to some object, open that object and return an - * ID for that object. + * Purpose: Given a reference to some object, open that object and return + * an ID for that object. * - * Return: Valid ID on success/Negative on failure + * Return: Success: Valid ID + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ H5I_type_t opened_type; /* Opened object type */ void *opened_obj = NULL; /* Opened object */ const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */ @@ -209,12 +210,12 @@ done: /*------------------------------------------------------------------------- * Function: H5Rcreate * - * Purpose: Creates a particular type of reference specified with REF_TYPE, - * in the space pointed to by REF. The LOC_ID and NAME are used to locate the - * object pointed to and the SPACE_ID is used to choose the region pointed to - * (for Dataset Region references). + * Purpose: Creates a particular type of reference specified with REF_TYPE, + * in the space pointed to by REF. The LOC_ID and NAME are used to + * locate the object pointed to and the SPACE_ID is used to choose + * the region pointed to (for Dataset Region references). * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success / negative on failure * *------------------------------------------------------------------------- */ @@ -222,10 +223,10 @@ herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ void *vol_obj_file = NULL; @@ -294,7 +295,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, if(ref_type == H5R_OBJECT1) { size_t buf_size = H5R_OBJ_REF_BUF_SIZE; - if((ret_value = H5R__encode_token_obj_compat((const H5VL_token_t *)&obj_token, cont_info.token_size, buf, &buf_size)) < 0) + if((ret_value = H5R__encode_token_obj_compat((const H5O_token_t *)&obj_token, cont_info.token_size, buf, &buf_size)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to encode object reference") } /* end if */ else { @@ -313,7 +314,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Encode dataset region */ - if((ret_value = H5R__encode_token_region_compat(f, (const H5VL_token_t *)&obj_token, cont_info.token_size, space, buf, &buf_size)) < 0) + if((ret_value = H5R__encode_token_region_compat(f, (const H5O_token_t *)&obj_token, cont_info.token_size, space, buf, &buf_size)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to encode region reference") } /* end else */ @@ -327,10 +328,10 @@ done: /*------------------------------------------------------------------------- * Function: H5Rget_obj_type2 * - * Purpose: Given a reference to some object, this function returns the type - * of object pointed to. + * Purpose: Given a reference to some object, this function returns the + * type of object pointed to. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success / negative on failure * *------------------------------------------------------------------------- */ @@ -338,10 +339,10 @@ herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ herr_t ret_value = SUCCEED; /* Return value */ @@ -383,10 +384,11 @@ done: /*------------------------------------------------------------------------- * Function: H5Rdereference2 * - * Purpose: Given a reference to some object, open that object and return an - * ID for that object. + * Purpose: Given a reference to some object, open that object and return + * an ID for that object. * - * Return: Valid ID on success/Negative on failure + * Return: Success: Valid ID + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -394,10 +396,10 @@ hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ H5I_type_t opened_type; /* Opened object type */ void *opened_obj = NULL; /* Opened object */ const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ @@ -451,18 +453,19 @@ done: /*------------------------------------------------------------------------- * Function: H5Rget_region * - * Purpose: 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 pointed to. + * Purpose: 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 pointed to. * - * Return: Valid ID on success/Negative on failure + * Return: Success: Valid ID + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ void *vol_obj_file = NULL; /* VOL file */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; @@ -537,10 +540,11 @@ done: /*------------------------------------------------------------------------- * Function: H5Rget_name * - * Purpose: Given a reference to some object, determine a path to the object - * referenced in the file. + * Purpose: Given a reference to some object, determine a path to the + * object referenced in the file. * - * Return: Non-negative length of the path on success/Negative on failure + * Return: Success: Non-negative length of the path + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -548,10 +552,10 @@ ssize_t H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name, size_t size) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ - H5VL_token_t obj_token = {0}; /* Object token */ + H5O_token_t obj_token = {0}; /* Object token */ const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ ssize_t ret_value = -1; /* Return value */ @@ -588,3 +592,4 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name, done: FUNC_LEAVE_API(ret_value) } /* end H5Rget_name() */ + diff --git a/src/H5Rint.c b/src/H5Rint.c index 46e4c0c..1df8a20 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -35,6 +35,8 @@ #include "H5Sprivate.h" /* Dataspaces */ #include "H5Tprivate.h" /* Datatypes */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ /****************/ @@ -93,9 +95,29 @@ HDfflush(stdout); \ } while (0) static const char * -H5R__print_token(const H5VL_token_t token) { +H5R__print_token(const H5O_token_t token) { static char string[64]; - HDsnprintf(string, 64, "%zu", *(haddr_t *)token); + + /* Print the raw token. */ + HDsnprintf(string, 64, "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + (unsigned char)token.__data[15], + (unsigned char)token.__data[14], + (unsigned char)token.__data[13], + (unsigned char)token.__data[12], + (unsigned char)token.__data[11], + (unsigned char)token.__data[10], + (unsigned char)token.__data[9], + (unsigned char)token.__data[8], + (unsigned char)token.__data[7], + (unsigned char)token.__data[6], + (unsigned char)token.__data[5], + (unsigned char)token.__data[4], + (unsigned char)token.__data[3], + (unsigned char)token.__data[2], + (unsigned char)token.__data[1], + (unsigned char)token.__data[0] + ); + return string; } #else @@ -110,8 +132,8 @@ H5R__print_token(const H5VL_token_t token) { /* Local Prototypes */ /********************/ -static herr_t H5R__encode_obj_token(const H5VL_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc); -static herr_t H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, H5VL_token_t *obj_token, uint8_t *token_size); +static herr_t H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc); +static herr_t H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, uint8_t *token_size); static herr_t H5R__encode_region(H5S_t *space, unsigned char *buf, size_t *nalloc); static herr_t H5R__decode_region(const unsigned char *buf, size_t *nbytes, H5S_t **space_ptr); static herr_t H5R__encode_string(const char *string, unsigned char *buf, size_t *nalloc); @@ -240,14 +262,14 @@ H5R_term_package(void) /*------------------------------------------------------------------------- * Function: H5R__create_object * - * Purpose: Creates an object reference. + * Purpose: Creates an object reference * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5R__create_object(const H5VL_token_t *obj_token, size_t token_size, +H5R__create_object(const H5O_token_t *obj_token, size_t token_size, H5R_ref_priv_t *ref) { size_t encode_size; @@ -258,11 +280,11 @@ H5R__create_object(const H5VL_token_t *obj_token, size_t token_size, HDassert(ref); /* Create new reference */ - H5MM_memcpy(&ref->ref.obj.token, obj_token, token_size); - ref->ref.obj.filename = NULL; + ref->info.obj.filename = NULL; ref->loc_id = H5I_INVALID_HID; ref->type = (uint8_t)H5R_OBJECT2; - ref->token_size = (uint8_t)token_size; + if(H5R__set_obj_token(ref, obj_token, token_size) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to set object token") /* Cache encoding size (assume no external reference) */ if(H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0) @@ -270,7 +292,7 @@ H5R__create_object(const H5VL_token_t *obj_token, size_t token_size, ref->encode_size = (uint32_t)encode_size; H5R_LOG_DEBUG("Created object reference, %d, filename=%s, obj_addr=%s, encode size=%u", - (int)sizeof(H5R_ref_priv_t), ref->ref.obj.filename, H5R__print_token(ref->ref.obj.token), + (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token), ref->encode_size); done: @@ -281,14 +303,14 @@ done: /*------------------------------------------------------------------------- * Function: H5R__create_region * - * Purpose: Creates a region reference. + * Purpose: Creates a region reference * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5R__create_region(const H5VL_token_t *obj_token, size_t token_size, +H5R__create_region(const H5O_token_t *obj_token, size_t token_size, H5S_t *space, H5R_ref_priv_t *ref) { size_t encode_size; @@ -300,14 +322,14 @@ H5R__create_region(const H5VL_token_t *obj_token, size_t token_size, HDassert(ref); /* Create new reference */ - H5MM_memcpy(&ref->ref.obj.token, obj_token, token_size); - ref->ref.obj.filename = NULL; - if(NULL == (ref->ref.reg.space = H5S_copy(space, FALSE, TRUE))) + ref->info.obj.filename = NULL; + if(NULL == (ref->info.reg.space = H5S_copy(space, FALSE, TRUE))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy dataspace") ref->loc_id = H5I_INVALID_HID; ref->type = (uint8_t)H5R_DATASET_REGION2; - ref->token_size = (uint8_t)token_size; + if(H5R__set_obj_token(ref, obj_token, token_size) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to set object token") /* Cache encoding size (assume no external reference) */ if(H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0) @@ -315,14 +337,14 @@ H5R__create_region(const H5VL_token_t *obj_token, size_t token_size, ref->encode_size = (uint32_t)encode_size; H5R_LOG_DEBUG("Created region reference, %d, filename=%s, obj_addr=%s, encode size=%u", - (int)sizeof(H5R_ref_priv_t), ref->ref.obj.filename, H5R__print_token(ref->ref.obj.token), + (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token), ref->encode_size); done: if(ret_value < 0) - if(ref->ref.reg.space) { - H5S_close(ref->ref.reg.space); - ref->ref.reg.space = NULL; + if(ref->info.reg.space) { + H5S_close(ref->info.reg.space); + ref->info.reg.space = NULL; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -332,14 +354,14 @@ done: /*------------------------------------------------------------------------- * Function: H5R__create_attr * - * Purpose: Creates an attribute reference. + * Purpose: Creates an attribute reference * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5R__create_attr(const H5VL_token_t *obj_token, size_t token_size, +H5R__create_attr(const H5O_token_t *obj_token, size_t token_size, const char *attr_name, H5R_ref_priv_t *ref) { size_t encode_size; @@ -355,14 +377,14 @@ H5R__create_attr(const H5VL_token_t *obj_token, size_t token_size, HGOTO_ERROR(H5E_REFERENCE, H5E_ARGS, FAIL, "attribute name too long (%d > %d)", (int)HDstrlen(attr_name), H5R_MAX_STRING_LEN) /* Create new reference */ - H5MM_memcpy(&ref->ref.obj.token, obj_token, token_size); - ref->ref.obj.filename = NULL; - if(NULL == (ref->ref.attr.name = HDstrdup(attr_name))) + ref->info.obj.filename = NULL; + if(NULL == (ref->info.attr.name = HDstrdup(attr_name))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy attribute name") ref->loc_id = H5I_INVALID_HID; ref->type = (uint8_t)H5R_ATTR; - ref->token_size = (uint8_t)token_size; + if(H5R__set_obj_token(ref, obj_token, token_size) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to set object token") /* Cache encoding size (assume no external reference) */ if(H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0) @@ -370,13 +392,13 @@ H5R__create_attr(const H5VL_token_t *obj_token, size_t token_size, ref->encode_size = (uint32_t)encode_size; H5R_LOG_DEBUG("Created attribute reference, %d, filename=%s, obj_addr=%s, attr name=%s, encode size=%u", - (int)sizeof(H5R_ref_priv_t), ref->ref.obj.filename, H5R__print_token(ref->ref.obj.token), - ref->ref.attr.name, ref->encode_size); + (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token), + ref->info.attr.name, ref->encode_size); done: if(ret_value < 0) { - H5MM_xfree(ref->ref.attr.name); - ref->ref.attr.name = NULL; + H5MM_xfree(ref->info.attr.name); + ref->info.attr.name = NULL; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -386,9 +408,9 @@ done: /*------------------------------------------------------------------------- * Function: H5R__destroy * - * Purpose: Destroy reference. + * Purpose: Destroy a reference * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -401,22 +423,22 @@ H5R__destroy(H5R_ref_priv_t *ref) HDassert(ref != NULL); - H5MM_xfree(ref->ref.obj.filename); - ref->ref.obj.filename = NULL; + H5MM_xfree(ref->info.obj.filename); + ref->info.obj.filename = NULL; switch(ref->type) { case H5R_OBJECT2: break; case H5R_DATASET_REGION2: - if(H5S_close(ref->ref.reg.space) < 0) + if(H5S_close(ref->info.reg.space) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "Cannot close dataspace") - ref->ref.reg.space = NULL; + ref->info.reg.space = NULL; break; case H5R_ATTR: - H5MM_xfree(ref->ref.attr.name); - ref->ref.attr.name = NULL; + H5MM_xfree(ref->info.attr.name); + ref->info.attr.name = NULL; break; case H5R_OBJECT1: @@ -433,8 +455,15 @@ H5R__destroy(H5R_ref_priv_t *ref) } /* end switch */ /* Decrement refcount of attached loc_id */ - if(ref->type && (ref->loc_id != H5I_INVALID_HID) && (H5I_dec_ref(ref->loc_id) < 0)) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") + if(ref->type && (ref->loc_id != H5I_INVALID_HID)) { + if(ref->app_ref) { + if(H5I_dec_app_ref(ref->loc_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") + } else { + if(H5I_dec_ref(ref->loc_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") + } + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -444,14 +473,14 @@ done: /*------------------------------------------------------------------------- * Function: H5R__set_loc_id * - * Purpose: Attach location ID to reference and increment location refcount. + * Purpose: Attach location ID to reference and increment location refcount. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref) +H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref, hbool_t app_ref) { herr_t ret_value = SUCCEED; /* Return value */ @@ -460,14 +489,26 @@ H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref) HDassert(ref != NULL); HDassert(id != H5I_INVALID_HID); - /* If a location ID was previously assigned, decrement refcount and assign new one */ - if((ref->loc_id != H5I_INVALID_HID) && (H5I_dec_ref(ref->loc_id) < 0)) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") + /* If a location ID was previously assigned, decrement refcount and + * assign new one */ + if((ref->loc_id != H5I_INVALID_HID)) { + if(ref->app_ref) { + if(H5I_dec_app_ref(ref->loc_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") + } else { + if(H5I_dec_ref(ref->loc_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") + } + } ref->loc_id = id; - /* Prevent location ID from being freed until reference is destroyed */ - if(inc_ref && H5I_inc_ref(ref->loc_id, FALSE) < 0) + /* Prevent location ID from being freed until reference is destroyed, + * set app_ref if necessary as references are exposed to users and are + * expected to be destroyed, this allows the loc_id to be cleanly released + * on shutdown if users fail to call H5Rdestroy(). */ + if(inc_ref && H5I_inc_ref(ref->loc_id, app_ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINC, FAIL, "incrementing location ID failed") + ref->app_ref = app_ref; done: FUNC_LEAVE_NOAPI(ret_value) @@ -477,9 +518,9 @@ done: /*------------------------------------------------------------------------- * Function: H5R__get_loc_id * - * Purpose: Retrieve location ID attached to existing reference. + * Purpose: Retrieve location ID attached to existing reference. * - * Return: Valid ID on success/Negative on failure + * Return: Valid ID on success / H5I_INVALID_HID on failure * *------------------------------------------------------------------------- */ @@ -501,9 +542,9 @@ H5R__get_loc_id(const H5R_ref_priv_t *ref) /*------------------------------------------------------------------------- * Function: H5R__reopen_file * - * Purpose: Re-open referenced file using file access property list. + * Purpose: Re-open referenced file using file access property list. * - * Return: Valid ID on success/Negative on failure + * Return: Valid ID on success / H5I_INVALID_HID on failure * *------------------------------------------------------------------------- */ @@ -559,7 +600,7 @@ H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5I_INVALID_HID, "unable to make file 'post open' callback") /* Attach loc_id to reference */ - if(H5R__set_loc_id((H5R_ref_priv_t *)ref, ret_value, FALSE) < 0) + if(H5R__set_loc_id((H5R_ref_priv_t *)ref, ret_value, FALSE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "unable to attach location id to reference") done: @@ -570,9 +611,10 @@ done: /*------------------------------------------------------------------------- * Function: H5R__get_type * - * Purpose: Given a reference to some object, return the type of that reference. + * Purpose: Given a reference to some object, return the type of that + * reference. * - * Return: Type of the reference + * Return: Type of the reference * *------------------------------------------------------------------------- */ @@ -593,9 +635,9 @@ H5R__get_type(const H5R_ref_priv_t *ref) /*------------------------------------------------------------------------- * Function: H5R__equal * - * Purpose: Compare two references + * Purpose: Compare two references * - * Return: TRUE if equal, FALSE if unequal, FAIL if error + * Return: TRUE if equal, FALSE if unequal, FAIL if error * *------------------------------------------------------------------------- */ @@ -616,27 +658,27 @@ H5R__equal(const H5R_ref_priv_t *ref1, const H5R_ref_priv_t *ref2) /* Compare object addresses */ if(ref1->token_size != ref2->token_size) HGOTO_DONE(FALSE); - if(0 != HDmemcmp(&ref1->ref.obj.token, &ref2->ref.obj.token, ref1->token_size)) + if(0 != HDmemcmp(&ref1->info.obj.token, &ref2->info.obj.token, ref1->token_size)) HGOTO_DONE(FALSE); /* Compare filenames */ - if((ref1->ref.obj.filename && (NULL == ref2->ref.obj.filename)) - || ((NULL == ref1->ref.obj.filename) && ref2->ref.obj.filename)) + if((ref1->info.obj.filename && (NULL == ref2->info.obj.filename)) + || ((NULL == ref1->info.obj.filename) && ref2->info.obj.filename)) HGOTO_DONE(FALSE); - if(ref1->ref.obj.filename && ref1->ref.obj.filename - && (0 != HDstrcmp(ref1->ref.obj.filename, ref2->ref.obj.filename))) + if(ref1->info.obj.filename && ref1->info.obj.filename + && (0 != HDstrcmp(ref1->info.obj.filename, ref2->info.obj.filename))) HGOTO_DONE(FALSE); switch(ref1->type) { case H5R_OBJECT2: break; case H5R_DATASET_REGION2: - if((ret_value = H5S_extent_equal(ref1->ref.reg.space, ref2->ref.reg.space)) < 0) + if((ret_value = H5S_extent_equal(ref1->info.reg.space, ref2->info.reg.space)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, FAIL, "cannot compare dataspace extents") break; case H5R_ATTR: - HDassert(ref1->ref.attr.name && ref2->ref.attr.name); - if(0 != HDstrcmp(ref1->ref.attr.name, ref2->ref.attr.name)) + HDassert(ref1->info.attr.name && ref2->info.attr.name); + if(0 != HDstrcmp(ref1->info.attr.name, ref2->info.attr.name)) HGOTO_DONE(FALSE); break; case H5R_OBJECT1: @@ -658,9 +700,9 @@ done: /*------------------------------------------------------------------------- * Function: H5R__copy * - * Purpose: Copy a reference + * Purpose: Copy a reference * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -673,7 +715,7 @@ H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref) HDassert((src_ref != NULL) && (dst_ref != NULL)); - H5MM_memcpy(&dst_ref->ref.obj.token, &src_ref->ref.obj.token, src_ref->token_size); + H5MM_memcpy(&dst_ref->info.obj.token, &src_ref->info.obj.token, sizeof(H5O_token_t)); dst_ref->encode_size = src_ref->encode_size; dst_ref->type = src_ref->type; dst_ref->token_size = src_ref->token_size; @@ -682,11 +724,11 @@ H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref) case H5R_OBJECT2: break; case H5R_DATASET_REGION2: - if(NULL == (dst_ref->ref.reg.space = H5S_copy(src_ref->ref.reg.space, FALSE, TRUE))) + if(NULL == (dst_ref->info.reg.space = H5S_copy(src_ref->info.reg.space, FALSE, TRUE))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy dataspace") break; case H5R_ATTR: - if(NULL == (dst_ref->ref.attr.name = HDstrdup(src_ref->ref.attr.name))) + if(NULL == (dst_ref->info.attr.name = HDstrdup(src_ref->info.attr.name))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy attribute name") break; case H5R_OBJECT1: @@ -702,16 +744,17 @@ H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref) /* We only need to keep a copy of the filename if we don't have the loc_id */ if(src_ref->loc_id == H5I_INVALID_HID) { - HDassert(src_ref->ref.obj.filename); + HDassert(src_ref->info.obj.filename); - if(NULL == (dst_ref->ref.obj.filename = HDstrdup(src_ref->ref.obj.filename))) + if(NULL == (dst_ref->info.obj.filename = HDstrdup(src_ref->info.obj.filename))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy filename") dst_ref->loc_id = H5I_INVALID_HID; - } else { - dst_ref->ref.obj.filename = NULL; + } + else { + dst_ref->info.obj.filename = NULL; /* Set location ID and hold reference to it */ - if(H5R__set_loc_id(dst_ref, src_ref->loc_id, TRUE) < 0) + if(H5R__set_loc_id(dst_ref, src_ref->loc_id, TRUE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "cannot set reference location ID") } @@ -723,14 +766,14 @@ done: /*------------------------------------------------------------------------- * Function: H5R__get_obj_token * - * Purpose: Given a reference to some object, get the encoded object addr. + * Purpose: Given a reference to some object, get the encoded token. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5R__get_obj_token(const H5R_ref_priv_t *ref, H5VL_token_t *obj_token, +H5R__get_obj_token(const H5R_ref_priv_t *ref, H5O_token_t *obj_token, size_t *token_size) { herr_t ret_value = SUCCEED; /* Return value */ @@ -738,12 +781,12 @@ H5R__get_obj_token(const H5R_ref_priv_t *ref, H5VL_token_t *obj_token, FUNC_ENTER_PACKAGE HDassert(ref != NULL); - HDassert(ref->token_size <= H5VL_MAX_TOKEN_SIZE); + HDassert(ref->token_size <= H5O_MAX_TOKEN_SIZE); if(obj_token) { if(0 == ref->token_size) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "NULL token size") - H5MM_memcpy(obj_token, &ref->ref.obj.token, ref->token_size); + H5MM_memcpy(obj_token, &ref->info.obj.token, sizeof(H5O_token_t)); } if(token_size) *token_size = ref->token_size; @@ -756,14 +799,14 @@ done: /*------------------------------------------------------------------------- * Function: H5R__set_obj_token * - * Purpose: Given a reference to some object, set the encoded object addr. + * Purpose: Given a reference to some object, set the encoded token. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5R__set_obj_token(H5R_ref_priv_t *ref, const H5VL_token_t *obj_token, +H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token, size_t token_size) { herr_t ret_value = SUCCEED; /* Return value */ @@ -773,9 +816,10 @@ H5R__set_obj_token(H5R_ref_priv_t *ref, const H5VL_token_t *obj_token, HDassert(ref != NULL); HDassert(obj_token); HDassert(token_size); - HDassert(token_size <= H5VL_MAX_TOKEN_SIZE); + HDassert(token_size <= H5O_MAX_TOKEN_SIZE); - H5MM_memcpy(&ref->ref.obj.token, obj_token, ref->token_size); + H5MM_memcpy(&ref->info.obj.token, obj_token, sizeof(H5O_token_t)); + HDassert(token_size <= 255); ref->token_size = (uint8_t)token_size; FUNC_LEAVE_NOAPI(ret_value) @@ -785,11 +829,11 @@ H5R__set_obj_token(H5R_ref_priv_t *ref, const H5VL_token_t *obj_token, /*------------------------------------------------------------------------- * Function: H5R__get_region * - * Purpose: 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 pointed to. + * Purpose: 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 pointed to. * - * Return: Pointer to the dataspace on success/NULL on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -805,7 +849,7 @@ H5R__get_region(const H5R_ref_priv_t *ref, H5S_t *space) HDassert(space); /* Copy reference selection to destination */ - if(H5S_select_copy(space, ref->ref.reg.space, FALSE) < 0) + if(H5S_select_copy(space, ref->info.reg.space, FALSE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy selection") done: @@ -816,10 +860,10 @@ done: /*------------------------------------------------------------------------- * Function: H5R__get_file_name * - * Purpose: Given a reference to some object, determine a file name of the - * object located into. + * Purpose: Given a reference to some object, determine a file name of + * the object located into. * - * Return: Non-negative length of the path on success/Negative on failure + * Return: Non-negative length of the path on success / -1 on failure * *------------------------------------------------------------------------- */ @@ -835,17 +879,17 @@ H5R__get_file_name(const H5R_ref_priv_t *ref, char *buf, size_t size) HDassert(ref != NULL); /* Return if that reference has no filename set */ - if(!ref->ref.obj.filename) + if(!ref->info.obj.filename) HGOTO_ERROR(H5E_REFERENCE, H5E_ARGS, (-1), "no filename available for that reference") /* Get the file name length */ - copy_len = HDstrlen(ref->ref.obj.filename); + copy_len = HDstrlen(ref->info.obj.filename); HDassert(copy_len <= H5R_MAX_STRING_LEN); /* Copy the file name */ if(buf) { copy_len = MIN(copy_len, size - 1); - H5MM_memcpy(buf, ref->ref.obj.filename, copy_len); + H5MM_memcpy(buf, ref->info.obj.filename, copy_len); buf[copy_len] = '\0'; } ret_value = (ssize_t)(copy_len + 1); @@ -858,9 +902,9 @@ done: /*------------------------------------------------------------------------- * Function: H5R__get_attr_name * - * Purpose: Given a reference to some attribute, determine its name. + * Purpose: Given a reference to some attribute, determine its name. * - * Return: Non-negative length of the path on success/Negative on failure + * Return: Non-negative length of the path on success / -1 on failure * *------------------------------------------------------------------------- */ @@ -877,13 +921,13 @@ H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size) HDassert(ref->type == H5R_ATTR); /* Get the attribute name length */ - attr_name_len = HDstrlen(ref->ref.attr.name); + attr_name_len = HDstrlen(ref->info.attr.name); HDassert(attr_name_len <= H5R_MAX_STRING_LEN); /* Get the attribute name */ if(buf) { size_t copy_len = MIN(attr_name_len, size - 1); - H5MM_memcpy(buf, ref->ref.attr.name, copy_len); + H5MM_memcpy(buf, ref->info.attr.name, copy_len); buf[copy_len] = '\0'; } @@ -896,9 +940,9 @@ H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size) /*------------------------------------------------------------------------- * Function: H5R__encode * - * Purpose: Private function for H5Rencode. + * Purpose: Private function for H5Rencode * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -940,7 +984,7 @@ H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, encode_size += H5R_ENCODE_HEADER_SIZE; /* Encode object token */ - H5R_ENCODE_VAR(H5R__encode_obj_token, &ref->ref.obj.token, ref->token_size, + H5R_ENCODE_VAR(H5R__encode_obj_token, &ref->info.obj.token, ref->token_size, p, buf_size, encode_size, "Cannot encode object address"); /** @@ -962,13 +1006,13 @@ H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, case H5R_DATASET_REGION2: /* Encode dataspace */ - H5R_ENCODE(H5R__encode_region, ref->ref.reg.space, p, buf_size, + H5R_ENCODE(H5R__encode_region, ref->info.reg.space, p, buf_size, encode_size, "Cannot encode region"); break; case H5R_ATTR: /* Encode attribute name */ - H5R_ENCODE(H5R__encode_string, ref->ref.attr.name, p, buf_size, + H5R_ENCODE(H5R__encode_string, ref->info.attr.name, p, buf_size, encode_size, "Cannot encode attribute name"); break; @@ -994,9 +1038,9 @@ done: /*------------------------------------------------------------------------- * Function: H5R__decode * - * Purpose: Private function for H5Rdecode. + * Purpose: Private function for H5Rdecode * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1031,28 +1075,29 @@ H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref) decode_size += H5R_ENCODE_HEADER_SIZE; /* Decode object token */ - H5R_DECODE_VAR(H5R__decode_obj_token, &ref->ref.obj.token, &ref->token_size, + H5R_DECODE_VAR(H5R__decode_obj_token, &ref->info.obj.token, &ref->token_size, p, buf_size, decode_size, "Cannot decode object address"); /* We do not need to store the filename if the reference is internal */ if(flags & H5R_IS_EXTERNAL) { /* Decode file name */ - H5R_DECODE(H5R__decode_string, &ref->ref.obj.filename, p, buf_size, + H5R_DECODE(H5R__decode_string, &ref->info.obj.filename, p, buf_size, decode_size, "Cannot decode filename"); - } else - ref->ref.obj.filename = NULL; + } + else + ref->info.obj.filename = NULL; switch(ref->type) { case H5R_OBJECT2: break; case H5R_DATASET_REGION2: /* Decode dataspace */ - H5R_DECODE(H5R__decode_region, &ref->ref.reg.space, p, buf_size, + H5R_DECODE(H5R__decode_region, &ref->info.reg.space, p, buf_size, decode_size, "Cannot decode region"); break; case H5R_ATTR: /* Decode attribute name */ - H5R_DECODE(H5R__decode_string, &ref->ref.attr.name, p, buf_size, + H5R_DECODE(H5R__decode_string, &ref->info.attr.name, p, buf_size, decode_size, "Cannot decode attribute name"); break; case H5R_OBJECT1: @@ -1073,7 +1118,7 @@ H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref) ref->encode_size = (uint32_t)decode_size; H5R_LOG_DEBUG("Decoded reference, filename=%s, obj_addr=%s, encode size=%u", - ref->ref.obj.filename, H5R__print_token(ref->ref.obj.token), + ref->info.obj.filename, H5R__print_token(ref->info.obj.token), ref->encode_size); *nbytes = decode_size; @@ -1086,14 +1131,14 @@ done: /*------------------------------------------------------------------------- * Function: H5R__encode_obj_token * - * Purpose: Encode an object address. + * Purpose: Encode an object address. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ static herr_t -H5R__encode_obj_token(const H5VL_token_t *obj_token, size_t token_size, +H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc) { herr_t ret_value = SUCCEED; @@ -1121,15 +1166,15 @@ H5R__encode_obj_token(const H5VL_token_t *obj_token, size_t token_size, /*------------------------------------------------------------------------- * Function: H5R__decode_obj_token * - * Purpose: Decode an object address. + * Purpose: Decode an object address. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ static herr_t H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, - H5VL_token_t *obj_token, uint8_t *token_size) + H5O_token_t *obj_token, uint8_t *token_size) { const uint8_t *p = (const uint8_t *)buf; herr_t ret_value = SUCCEED; @@ -1147,13 +1192,16 @@ H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, /* Get token size */ *token_size = *p++; - if(*token_size > sizeof(H5VL_token_t)) + if(*token_size > sizeof(H5O_token_t)) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Invalid token size (%u)", *token_size) + /* Make sure that token is initialized */ + HDmemset(obj_token, 0, sizeof(H5O_token_t)); + /* Decode token */ H5MM_memcpy(obj_token, p, *token_size); - *nbytes = (size_t)*token_size + H5_SIZEOF_UINT8_T; + *nbytes = (size_t)(*token_size + H5_SIZEOF_UINT8_T); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1163,9 +1211,9 @@ done: /*------------------------------------------------------------------------- * Function: H5R__encode_region * - * Purpose: Encode a selection. + * Purpose: Encode a selection. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1212,9 +1260,9 @@ done: /*------------------------------------------------------------------------- * Function: H5R__decode_region * - * Purpose: Decode a selection. + * Purpose: Decode a selection. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1268,9 +1316,9 @@ done: /*------------------------------------------------------------------------- * Function: H5R__encode_string * - * Purpose: Encode a string. + * Purpose: Encode a string. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1310,9 +1358,9 @@ done: /*------------------------------------------------------------------------- * Function: H5R__decode_string * - * Purpose: Decode a string. + * Purpose: Decode a string. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1357,9 +1405,9 @@ done: /*------------------------------------------------------------------------- * Function: H5R__encode_heap * - * Purpose: Encode data and insert into heap (native only). + * Purpose: Encode data and insert into heap (native only). * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1398,9 +1446,9 @@ done: /*------------------------------------------------------------------------- * Function: H5R__decode_heap * - * Purpose: Decode data inserted into heap (native only). + * Purpose: Decode data inserted into heap (native only). * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1445,9 +1493,9 @@ done: /*------------------------------------------------------------------------- * Function: H5R__free_heap * - * Purpose: Remove data previously inserted into heap (native only). + * Purpose: Remove data previously inserted into heap (native only). * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1490,15 +1538,15 @@ done: /*------------------------------------------------------------------------- * Function: H5R__decode_token_compat * - * Purpose: Decode an object token. (native only) + * Purpose: Decode an object token. (native only) * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref_type, - const unsigned char *buf, H5VL_token_t *obj_token) + const unsigned char *buf, H5O_token_t *obj_token) { hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ H5VL_object_t *vol_obj_file = NULL; @@ -1562,14 +1610,14 @@ done: /*------------------------------------------------------------------------- * Function: H5R__encode_token_obj_compat * - * Purpose: Encode an object token. (native only) + * Purpose: Encode an object token. (native only) * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5R__encode_token_obj_compat(const H5VL_token_t *obj_token, size_t token_size, +H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc) { herr_t ret_value = SUCCEED; @@ -1593,15 +1641,15 @@ H5R__encode_token_obj_compat(const H5VL_token_t *obj_token, size_t token_size, /*------------------------------------------------------------------------- * Function: H5R__decode_token_obj_compat * - * Purpose: Decode an object token. (native only) + * Purpose: Decode an object token. (native only) * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes, - H5VL_token_t *obj_token, size_t token_size) + H5O_token_t *obj_token, size_t token_size) { herr_t ret_value = SUCCEED; @@ -1628,14 +1676,15 @@ done: /*------------------------------------------------------------------------- * Function: H5R__encode_token_region_compat * - * Purpose: Encode dataset selection and insert data into heap (native only). + * Purpose: Encode dataset selection and insert data into heap + * (native only). * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5R__encode_token_region_compat(H5F_t *f, const H5VL_token_t *obj_token, +H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, size_t token_size, H5S_t *space, unsigned char *buf, size_t *nalloc) { size_t buf_size; @@ -1703,19 +1752,20 @@ done: /*------------------------------------------------------------------------- * Function: H5R__decode_token_region_compat * - * Purpose: Decode dataset selection from data inserted into heap (native only). + * Purpose: Decode dataset selection from data inserted into heap + * (native only). * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, - size_t *nbytes, H5VL_token_t *obj_token, size_t token_size, + size_t *nbytes, H5O_token_t *obj_token, size_t token_size, H5S_t **space_ptr) { unsigned char *data = NULL; - H5VL_token_t token = { 0 }; + H5O_token_t token = { 0 }; size_t data_size; const uint8_t *p; herr_t ret_value = SUCCEED; @@ -1739,12 +1789,13 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, if(space_ptr) { H5O_loc_t oloc; /* Object location */ H5S_t *space = NULL; - const uint8_t *q = (const uint8_t *)&token; /* Initialize the object location */ H5O_loc_reset(&oloc); oloc.file = f; - H5F_addr_decode(f, &q, &oloc.addr); + + if(H5VL_native_token_to_addr(f, H5I_FILE, token, &oloc.addr) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") /* Open and copy the dataset's dataspace */ if(NULL == (space = H5S_read(&oloc))) @@ -1757,9 +1808,10 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, *space_ptr = space; } if(obj_token) - H5MM_memcpy(obj_token, &token, token_size); + H5MM_memcpy(obj_token, &token, sizeof(H5O_token_t)); done: H5MM_free(data); FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__decode_token_region_compat() */ + diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h index 7471487..36cf805 100644 --- a/src/H5Rpkg.h +++ b/src/H5Rpkg.h @@ -40,8 +40,8 @@ #define H5R_IS_EXTERNAL 0x1 /* Set when encoding reference to external file */ /* Macros for convenience */ -#define H5R_REF_FILENAME(x) ((x)->ref.obj.filename) -#define H5R_REF_ATTRNAME(x) ((x)->ref.attr.name) +#define H5R_REF_FILENAME(x) ((x)->info.obj.filename) +#define H5R_REF_ATTRNAME(x) ((x)->info.attr.name) /* Header size */ #define H5R_ENCODE_HEADER_SIZE (2 * H5_SIZEOF_UINT8_T) @@ -52,7 +52,7 @@ /* Object reference */ typedef struct H5R_ref_priv_obj_t { - H5VL_token_t token; /* Object token */ + H5O_token_t token; /* Object token */ char *filename; /* File name */ } H5R_ref_priv_obj_t; @@ -74,12 +74,12 @@ typedef struct H5R_ref_priv_t { H5R_ref_priv_obj_t obj;/* Object reference */ H5R_ref_priv_reg_t reg;/* Region reference */ H5R_ref_priv_attr_t attr;/* Attribute Reference */ - } ref; + } info; hid_t loc_id; /* Cached location identifier */ uint32_t encode_size; /* Cached encoding size */ int8_t type; /* Reference type */ uint8_t token_size; /* Cached token size */ - char unused[18]; /* Unused */ + hbool_t app_ref; /* App ref on loc_id */ } H5R_ref_priv_t; /*****************************/ @@ -90,12 +90,12 @@ typedef struct H5R_ref_priv_t { /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5R__create_object(const H5VL_token_t *obj_token, size_t token_size, H5R_ref_priv_t *ref); -H5_DLL herr_t H5R__create_region(const H5VL_token_t *obj_token, size_t token_size, H5S_t *space, H5R_ref_priv_t *ref); -H5_DLL herr_t H5R__create_attr(const H5VL_token_t *obj_token, size_t token_size, const char *attr_name, H5R_ref_priv_t *ref); +H5_DLL herr_t H5R__create_object(const H5O_token_t *obj_token, size_t token_size, H5R_ref_priv_t *ref); +H5_DLL herr_t H5R__create_region(const H5O_token_t *obj_token, size_t token_size, H5S_t *space, H5R_ref_priv_t *ref); +H5_DLL herr_t H5R__create_attr(const H5O_token_t *obj_token, size_t token_size, const char *attr_name, H5R_ref_priv_t *ref); H5_DLL herr_t H5R__destroy(H5R_ref_priv_t *ref); -H5_DLL herr_t H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref); +H5_DLL herr_t H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref, hbool_t app_ref); H5_DLL hid_t H5R__get_loc_id(const H5R_ref_priv_t *ref); H5_DLL hid_t H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id); @@ -103,8 +103,8 @@ H5_DLL H5R_type_t H5R__get_type(const H5R_ref_priv_t *ref); H5_DLL htri_t H5R__equal(const H5R_ref_priv_t *ref1, const H5R_ref_priv_t *ref2); H5_DLL herr_t H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref); -H5_DLL herr_t H5R__get_obj_token(const H5R_ref_priv_t *ref, H5VL_token_t *obj_token, size_t *token_size); -H5_DLL herr_t H5R__set_obj_token(H5R_ref_priv_t *ref, const H5VL_token_t *obj_token, size_t token_size); +H5_DLL herr_t H5R__get_obj_token(const H5R_ref_priv_t *ref, H5O_token_t *obj_token, size_t *token_size); +H5_DLL herr_t H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token, size_t token_size); H5_DLL herr_t H5R__get_region(const H5R_ref_priv_t *ref, H5S_t *space); H5_DLL ssize_t H5R__get_file_name(const H5R_ref_priv_t *ref, char *buf, size_t size); @@ -118,13 +118,13 @@ H5_DLL herr_t H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, c H5_DLL herr_t H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, unsigned char **data_ptr, size_t *data_size); H5_DLL herr_t H5R__free_heap(H5F_t *f, const unsigned char *buf, size_t nbytes); -H5_DLL herr_t H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref_type, const unsigned char *buf, H5VL_token_t *obj_token); +H5_DLL herr_t H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref_type, const unsigned char *buf, H5O_token_t *obj_token); -H5_DLL herr_t H5R__encode_token_obj_compat(const H5VL_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc); -H5_DLL herr_t H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes, H5VL_token_t *obj_token, size_t token_size); +H5_DLL herr_t H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc); +H5_DLL herr_t H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, size_t token_size); -H5_DLL herr_t H5R__encode_token_region_compat(H5F_t *f, const H5VL_token_t *obj_token, size_t token_size, H5S_t *space, unsigned char *buf, size_t *nalloc); -H5_DLL herr_t H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbytes, H5VL_token_t *obj_token, size_t token_size, H5S_t **space_ptr); +H5_DLL herr_t H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, size_t token_size, H5S_t *space, unsigned char *buf, size_t *nalloc); +H5_DLL herr_t H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, size_t token_size, H5S_t **space_ptr); #endif /* _H5Rpkg_H */ diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h index cfbf3c8..13d82d7 100644 --- a/src/H5Rpublic.h +++ b/src/H5Rpublic.h @@ -80,7 +80,10 @@ typedef struct { * should always be used with the current reference API. */ typedef struct { - uint8_t __data[H5R_REF_BUF_SIZE]; + union { + uint8_t __data[H5R_REF_BUF_SIZE]; /* opaque data */ + int64_t align; /* ensures alignment */ + } u; } H5R_ref_t; /********************/ @@ -108,16 +111,16 @@ H5_DLL htri_t H5Requal(const H5R_ref_t *ref1_ptr, const H5R_ref_t *ref2_ptr); H5_DLL herr_t H5Rcopy(const H5R_ref_t *src_ref_ptr, H5R_ref_t *dst_ref_ptr); /* Dereference */ -H5_DLL hid_t H5Ropen_object(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id); -H5_DLL hid_t H5Ropen_region(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id); -H5_DLL hid_t H5Ropen_attr(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id); +H5_DLL hid_t H5Ropen_object(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id); +H5_DLL hid_t H5Ropen_region(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id); +H5_DLL hid_t H5Ropen_attr(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id); /* Get type */ -H5_DLL herr_t H5Rget_obj_type3(const H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type); +H5_DLL herr_t H5Rget_obj_type3(H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type); /* Get name */ H5_DLL ssize_t H5Rget_file_name(const H5R_ref_t *ref_ptr, char *buf, size_t size); -H5_DLL ssize_t H5Rget_obj_name(const H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size); +H5_DLL ssize_t H5Rget_obj_name(H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size); H5_DLL ssize_t H5Rget_attr_name(const H5R_ref_t *ref_ptr, char *buf, size_t size); /* Symbols defined for compatibility with previous versions of the HDF5 API. @@ -652,7 +652,7 @@ int H5SL_term_package(void) /* Terminate all the factories */ if(H5SL_fac_nused_g > 0) { size_t i; - herr_t ret; + herr_t H5_ATTR_NDEBUG_UNUSED ret; for(i = 0; i < H5SL_fac_nused_g; i++) { ret = H5FL_fac_term(H5SL_fac_g[i]); diff --git a/src/H5SMcache.c b/src/H5SMcache.c index ee28fa4..6d0f2b0 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -212,8 +212,8 @@ H5SM__cache_table_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNU *------------------------------------------------------------------------- */ static void * -H5SM__cache_table_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) +H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, + void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { H5F_t *f; /* File pointer -- from user data */ H5SM_master_table_t *table = NULL; /* Shared message table that we deserializing */ @@ -364,7 +364,7 @@ H5SM__cache_table_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t len, +H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5SM_master_table_t *table = (H5SM_master_table_t *)_thing; /* Shared message table to encode */ @@ -568,8 +568,8 @@ H5SM__cache_list_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, vo *------------------------------------------------------------------------- */ static void * -H5SM__cache_list_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) +H5SM__cache_list_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, + void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { H5SM_list_t *list = NULL; /* The SOHM list being read in */ H5SM_list_cache_ud_t *udata = (H5SM_list_cache_ud_t *)_udata; /* User data for callback */ @@ -687,7 +687,7 @@ H5SM__cache_list_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t len, +H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5SM_list_t *list = (H5SM_list_t *)_thing ; /* Instance being serialized */ diff --git a/src/H5Smpio.c b/src/H5Smpio.c index 800913f..6397f4b 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -293,8 +293,8 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, for(i = 0; i < num_big_types; i++) { #if MPI_VERSION >= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(bigio_count, - 1, &disp[i*bigio_count], elmt_type, &inner_types[i]))) + if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block((int)bigio_count, + 1, &disp[(hsize_t)i*bigio_count], elmt_type, &inner_types[i]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code) #else if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)bigio_count, @@ -308,7 +308,7 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, if(remaining_points) { #if MPI_VERSION >= 3 if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(remaining_points, - 1, &disp[num_big_types*bigio_count], elmt_type, &inner_types[num_big_types]))) + 1, &disp[(hsize_t)num_big_types*bigio_count], elmt_type, &inner_types[num_big_types]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code) #else if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)remaining_points, @@ -403,8 +403,11 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ curr = space->select.sel_info.pnt_lst->head; for(u = 0 ; u < num_points ; u++) { /* Calculate the displacement of the current point */ - disp[u] = H5VM_array_offset(space->extent.rank, space->extent.size, curr->pnt); - disp[u] *= elmt_size; + hsize_t disp_tmp = H5VM_array_offset(space->extent.rank, space->extent.size, curr->pnt); + if(disp_tmp > LONG_MAX) /* Maximum value of type long */ + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "disp overflow") + disp[u] = (MPI_Aint)disp_tmp; + disp[u] *= (MPI_Aint)elmt_size; /* This is a File Space used to set the file view, so adjust the displacements * to have them monotonically non-decreasing. @@ -423,7 +426,7 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ */ if(do_permute) { if(u > 0 && disp[u] < disp[u - 1]) { - unsigned s = 0, l = u, m = u / 2; + hsize_t s = 0, l = u, m = u / 2; *is_permuted = TRUE; do { @@ -565,7 +568,9 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, /* Loop, while bytes left in sequence */ while(curr_len > 0) { /* Set the displacement of the current point */ - disp[u] = curr_off; + if(curr_off > LONG_MAX) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "curr_off overflow") + disp[u] = (MPI_Aint)curr_off; /* This is a memory displacement, so for each point selected, * apply the map that was generated by the file selection */ @@ -893,8 +898,14 @@ if(H5DEBUG(S)) ****************************************/ /* Calculate start and extent values of this dimension */ - start_disp = d[i].start * offset[i] * elmt_size; - new_extent = (MPI_Aint)elmt_size * max_xtent[i]; + /* Check if value overflow to cast to type MPI_Aint */ + if(d[i].start > LONG_MAX || offset[i] > LONG_MAX || elmt_size > LONG_MAX) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "result overflow") + start_disp = (MPI_Aint)d[i].start * (MPI_Aint)offset[i] * (MPI_Aint)elmt_size; + + if(max_xtent[i] > LONG_MAX) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "max_xtent overflow") + new_extent = (MPI_Aint)elmt_size * (MPI_Aint)max_xtent[i]; if(MPI_SUCCESS != (mpi_code = MPI_Type_get_extent(outer_type, &lb, &extent_len))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_get_extent failed", mpi_code) @@ -1161,7 +1172,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, nelmts = (span->high - span->low) + 1; /* Store displacement & block length */ - disp[outercount] = (MPI_Aint)elmt_size * span->low; + disp[outercount] = (MPI_Aint)elmt_size * (MPI_Aint)span->low; H5_CHECK_OVERFLOW(nelmts, hsize_t, int) blocklen[outercount] = (int)nelmts; @@ -1183,7 +1194,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, /* create the block type from elmt_type while checking the 32 bit int limit */ if((hsize_t)(blocklen[u]) > bigio_count) { - if(H5_mpio_create_large_type(blocklen[u], 0, *elmt_type, &temp_type) < 0) + if(H5_mpio_create_large_type((hsize_t)blocklen[u], 0, *elmt_type, &temp_type) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection") } /* end if */ else @@ -1219,7 +1230,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes") /* Calculate the total bytes of the lower dimension */ - stride = (*down) * elmt_size; + stride = (MPI_Aint)(*down) * (MPI_Aint)elmt_size; /* Loop over span nodes */ outercount = 0; @@ -1251,7 +1262,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, /* Displacement should be in byte and should have dimension information */ /* First using MPI Type vector to build derived data type for this span only */ /* Need to calculate the disp in byte for this dimension. */ - disp[outercount] = span->low * stride; + disp[outercount] = (MPI_Aint)span->low * stride; blocklen[outercount] = 1; /* Generate MPI datatype for next dimension down */ diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 9814e38..13233ce 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -2601,9 +2601,9 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, { H5S_t *new_space = NULL; /* New dataspace constructed */ H5S_t *tmp_src_intersect_space = NULL; /* Temporary SIS converted from points->hyperslabs */ - H5S_sel_iter_t ss_iter; /* Selection iterator for src_space */ + H5S_sel_iter_t *ss_iter = NULL; /* Selection iterator for src_space */ hbool_t ss_iter_init = FALSE; /* Whether ss_iter has been initialized */ - H5S_sel_iter_t ds_iter; /* Selection iterator for dst_space */ + H5S_sel_iter_t *ds_iter = NULL; /* Selection iterator for dst_space */ hbool_t ds_iter_init = FALSE; /* Whether ds_iter has been initialized */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2617,6 +2617,11 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HDassert(H5S_GET_SELECT_NPOINTS(src_space) == H5S_GET_SELECT_NPOINTS(dst_space)); HDassert(H5S_GET_EXTENT_NDIMS(src_space) == H5S_GET_EXTENT_NDIMS(src_intersect_space)); + if(NULL == (ss_iter = H5FL_CALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") + if(NULL == (ds_iter = H5FL_CALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") + /* Create new space, using dst extent. Start with "all" selection. */ if(NULL == (new_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create output dataspace") @@ -2717,20 +2722,20 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Initialize iterators */ - if(H5S_select_iter_init(&ss_iter, src_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + if(H5S_select_iter_init(ss_iter, src_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't initialize source space selection iterator") ss_iter_init = TRUE; - if(H5S_select_iter_init(&ds_iter, dst_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + if(H5S_select_iter_init(ds_iter, dst_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't initialize destination space selection iterator") ds_iter_init = TRUE; /* Iterate over points */ do { - HDassert(ss_iter.elmt_left > 0); - HDassert(ss_iter.elmt_left > 0); + HDassert(ss_iter->elmt_left > 0); + HDassert(ss_iter->elmt_left > 0); /* Get SS coords */ - if(H5S_SELECT_ITER_COORDS(&ss_iter, coords) < 0) + if(H5S_SELECT_ITER_COORDS(ss_iter, coords) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get source selection coordinates") /* Check for intersection */ @@ -2740,7 +2745,7 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Add point if it intersects */ if(intersect) { /* Get DS coords */ - if(H5S_SELECT_ITER_COORDS(&ds_iter, coords) < 0) + if(H5S_SELECT_ITER_COORDS(ds_iter, coords) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get destination selection coordinates") /* Add point to new_space */ @@ -2749,14 +2754,14 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, } /* end if */ /* Advance iterators */ - if(H5S_SELECT_ITER_NEXT(&ss_iter, 1) < 0) + if(H5S_SELECT_ITER_NEXT(ss_iter, 1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "can't advacne source selection iterator") - ss_iter.elmt_left--; - if(H5S_SELECT_ITER_NEXT(&ds_iter, 1) < 0) + ss_iter->elmt_left--; + if(H5S_SELECT_ITER_NEXT(ds_iter, 1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "can't advacne destination selection iterator") - ds_iter.elmt_left--; - } while(ss_iter.elmt_left > 0); - HDassert(H5S_SELECT_ITER_NELMTS(&ds_iter) == 0); + ds_iter->elmt_left--; + } while(ss_iter->elmt_left > 0); + HDassert(H5S_SELECT_ITER_NELMTS(ds_iter) == 0); } /* end if */ else { HDassert(H5S_GET_SELECT_TYPE(src_space) != H5S_SEL_NONE); @@ -2783,11 +2788,14 @@ done: /* General cleanup */ if(tmp_src_intersect_space && H5S_close(tmp_src_intersect_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release temporary dataspace") - if(ss_iter_init && H5S_SELECT_ITER_RELEASE(&ss_iter) < 0) + if(ss_iter_init && H5S_SELECT_ITER_RELEASE(ss_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release source selection iterator") - if(ds_iter_init && H5S_SELECT_ITER_RELEASE(&ds_iter) < 0) + if(ds_iter_init && H5S_SELECT_ITER_RELEASE(ds_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release destination selection iterator") + ss_iter = H5FL_FREE(H5S_sel_iter_t, ss_iter); + ds_iter = H5FL_FREE(H5S_sel_iter_t, ds_iter); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_project_intersection() */ diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 5c848c2..1b922d5 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -106,7 +106,7 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, void *data = NULL; /* VOL-managed datatype data */ H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -273,7 +273,7 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) void *dt = NULL; /* datatype object created by VOL connector */ H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ H5T_t *type = NULL; /* Datatype created */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -568,8 +568,8 @@ done: hid_t H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) { - void *dt = NULL; /* datatype token created by VOL connector */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *dt = NULL; /* datatype object created by VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -1096,7 +1096,7 @@ H5T_construct_datatype(H5VL_object_t *vol_obj) { ssize_t nalloc; void *buf = NULL; - H5T_t *dt = NULL; /* datatype token from VOL connector */ + H5T_t *dt = NULL; /* datatype object from VOL connector */ H5T_t *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 8a0c562..29fd582 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -1848,7 +1848,7 @@ H5T_conv_struct_free(H5T_conv_struct_t *priv) for(i = 0; i < priv->src_nmembs; i++) if(src2dst[i] >= 0) { - int status; + int H5_ATTR_NDEBUG_UNUSED status; status = H5I_dec_ref(src_memb_id[i]); HDassert(status >= 0); diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index 9998317..2c98dc0 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -110,7 +110,7 @@ H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) void *data = NULL; /* VOL-managed datatype data */ H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -175,8 +175,8 @@ done: hid_t H5Topen1(hid_t loc_id, const char *name) { - void *dt = NULL; /* Datatype token created by VOL connector */ - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + void *dt = NULL; /* Datatype object created by VOL connector */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ diff --git a/src/H5Tref.c b/src/H5Tref.c index f31fecf..f97b78a 100644 --- a/src/H5Tref.c +++ b/src/H5Tref.c @@ -46,7 +46,7 @@ /* For region compatibility support */ struct H5Tref_dsetreg { - H5VL_token_t token; /* Object token */ + H5O_token_t token; /* Object token */ H5S_t *space; /* Dataspace */ }; @@ -578,7 +578,7 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size { size_t token_size = H5F_SIZEOF_ADDR(src_f); - if(H5R__create_object((const H5VL_token_t *)src_buf, token_size, dst_ref) < 0) + if(H5R__create_object((const H5O_token_t *)src_buf, token_size, dst_ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create object reference") } break; @@ -622,8 +622,9 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size if((file_id = H5F_get_file_id(src_file, H5I_FILE, FALSE)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - /* Attach loc ID to reference and hold reference to it */ - if(H5R__set_loc_id(dst_ref, file_id, TRUE) < 0) + /* Attach loc ID to reference and hold reference to it, this is a + * user exposed reference so set app_ref to TRUE. */ + if(H5R__set_loc_id(dst_ref, file_id, TRUE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference") } /* end if */ @@ -783,7 +784,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, +H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t H5_ATTR_NDEBUG_UNUSED src_size, H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t dst_size) { const uint8_t *p = (const uint8_t *)src_buf; @@ -1023,7 +1024,7 @@ H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_ /* Get object address */ if(H5R__decode_token_obj_compat((const unsigned char *)src_buf, &src_size, - (H5VL_token_t *)dst_buf, H5F_SIZEOF_ADDR(src_f)) < 0) + (H5O_token_t *)dst_buf, H5F_SIZEOF_ADDR(src_f)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address") done: @@ -1100,7 +1101,11 @@ H5T__ref_dsetreg_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, { size_t ret_value = sizeof(struct H5Tref_dsetreg); +#ifndef NDEBUG FUNC_ENTER_STATIC +#else + FUNC_ENTER_STATIC_NOERR +#endif HDassert(src_buf); @@ -1124,7 +1129,9 @@ H5T__ref_dsetreg_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, } #endif /* NDEBUG */ +#ifndef NDEBUG done: +#endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__ref_dsetreg_disk_getsize() */ @@ -249,6 +249,38 @@ done: /*------------------------------------------------------------------------- * Function: H5VLget_connector_id * + * Purpose: Retrieves the VOL connector ID for a given object ID. + * + * Return: A valid VOL connector ID. This ID will need to be closed + * using H5VLclose(). + * + * H5I_INVALID_HID on error. + * + * Programmer: Dana Robinson + * June 17, 2017 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLget_connector_id(hid_t obj_id) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "i", obj_id); + + /* Get connector ID */ + if((ret_value = H5VL__get_connector_id(obj_id, TRUE)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLget_connector_id() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLget_connector_id_by_name + * * Purpose: Retrieves the ID for a registered VOL connector. * * Return: A valid VOL connector ID if a connector by that name has @@ -264,7 +296,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VLget_connector_id(const char *name) +H5VLget_connector_id_by_name(const char *name) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -272,12 +304,12 @@ H5VLget_connector_id(const char *name) H5TRACE1("i", "*s", name); /* Get connector ID with this name */ - if((ret_value = H5VL__get_connector_id(name, TRUE)) < 0) + if((ret_value = H5VL__get_connector_id_by_name(name, TRUE)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") done: FUNC_LEAVE_API(ret_value) -} /* end H5VLget_connector_id() */ +} /* end H5VLget_connector_id_by_name() */ /*------------------------------------------------------------------------- @@ -411,7 +443,7 @@ H5VLunregister_connector(hid_t vol_id) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* For the time being, we disallow unregistering the native VOL connector */ - if(H5I_INVALID_HID == (native_id = H5VL__get_connector_id(H5VL_NATIVE_NAME, FALSE))) + if(H5I_INVALID_HID == (native_id = H5VL__get_connector_id_by_name(H5VL_NATIVE_NAME, FALSE))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to find the native VOL connector ID") if(vol_id == native_id) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "unregistering the native VOL connector is not allowed") diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index 30cbae1..e4ebb95 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -189,6 +189,12 @@ static herr_t H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments); static herr_t H5VL__blob_optional(void *obj, const H5VL_class_t *cls, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments); +static herr_t H5VL__token_cmp(void *obj, const H5VL_class_t *cls, + const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value); +static herr_t H5VL__token_to_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, + const H5O_token_t *token, char **token_str); +static herr_t H5VL__token_from_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, + const char *token_str, H5O_token_t *token); static herr_t H5VL__optional(void *obj, const H5VL_class_t *cls, int op_type, hid_t dxpl_id, void **req, va_list arguments); @@ -4713,7 +4719,7 @@ H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_o const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, ...) { - H5VL_object_t tmp_vol_obj; /* Temporary object token of */ + H5VL_object_t tmp_vol_obj; /* Temporary object */ va_list arguments; /* Argument list passed from the API call */ hbool_t arg_started = FALSE; /* Whether the va_list has been started */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ @@ -7280,6 +7286,383 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL__token_cmp + * + * Purpose: Compares two VOL connector object tokens. Sets *cmp_value + * to positive if token1 is greater than token2, negative if + * token2 is greater than token1 and zero if token1 and + * token2 are equal. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__token_cmp(void *obj, const H5VL_class_t *cls, + const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(obj); + HDassert(cls); + HDassert(cmp_value); + + /* Take care of cases where one or both pointers is NULL */ + if(token1 == NULL && token2 != NULL) + *cmp_value = -1; + else if(token1 != NULL && token2 == NULL) + *cmp_value = 1; + else if(token1 == NULL && token2 == NULL) + *cmp_value = 0; + else { + /* Use the class's token comparison routine to compare the tokens, + * if there is a callback, otherwise just compare the tokens as + * memory buffers. + */ + if(cls->token_cls.cmp) { + if((cls->token_cls.cmp)(obj, token1, token2, cmp_value) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare object tokens") + } /* end if */ + else + *cmp_value = HDmemcmp(token1, token2, sizeof(H5O_token_t)); + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__token_cmp() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_token_cmp + * + * Purpose: Compares two VOL connector object tokens. Sets *cmp_value + * to positive if token1 is greater than token2, negative if + * token2 is greater than token1 and zero if token1 and + * token2 are equal. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_token_cmp(const H5VL_object_t *vol_obj, const H5O_token_t *token1, + const H5O_token_t *token2, int *cmp_value) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(vol_obj); + HDassert(cmp_value); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if((ret_value = H5VL__token_cmp(vol_obj->data, vol_obj->connector->cls, token1, token2, cmp_value)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "token compare failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_token_cmp() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLtoken_cmp + * + * Purpose: Compares two VOL connector object tokens + * + * Note: Both object tokens must be from the same VOL connector class + * + * Return: Success: Non-negative, with *cmp_value set to positive if + * token1 is greater than token2, negative if token2 + * is greater than token1 and zero if token1 and + * token2 are equal. + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLtoken_cmp(void *obj, hid_t connector_id, const H5O_token_t *token1, + const H5O_token_t *token2, int *cmp_value) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xi*k*k*Is", obj, connector_id, token1, token2, cmp_value); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + if(NULL == cmp_value) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid cmp_value pointer") + + /* Call the corresponding internal VOL routine */ + if(H5VL__token_cmp(obj, cls, token1, token2, cmp_value) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "object token comparison failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLtoken_cmp() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__token_to_str + * + * Purpose: Serialize a connector's object token into a string + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__token_to_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, + const H5O_token_t *token, char **token_str) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(obj); + HDassert(cls); + HDassert(token); + HDassert(token_str); + + /* Use the class's token serialization routine on the token if there is a + * callback, otherwise just set the token_str to NULL. + */ + if(cls->token_cls.to_str) { + if((cls->token_cls.to_str)(obj, obj_type, token, token_str) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "can't serialize object token") + } /* end if */ + else + *token_str = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__token_to_str() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_token_to_str + * + * Purpose: Serialize a connector's object token into a string + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, + const H5O_token_t *token, char **token_str) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(vol_obj); + HDassert(token); + HDassert(token_str); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if((ret_value = H5VL__token_to_str(vol_obj->data, obj_type, vol_obj->connector->cls, token, token_str)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "token serialization failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_token_to_str() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLtoken_to_str + * + * Purpose: Serialize a connector's object token into a string + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLtoken_to_str(void *obj, H5I_type_t obj_type, hid_t connector_id, + const H5O_token_t *token, char **token_str) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xIti*k**s", obj, obj_type, connector_id, token, token_str); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + if(NULL == token) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer") + if(NULL == token_str) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token_str pointer") + + /* Call the corresponding internal VOL routine */ + if(H5VL__token_to_str(obj, obj_type, cls, token, token_str) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "object token to string failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLtoken_to_str() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__token_from_str + * + * Purpose: Deserialize a string into a connector object token + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__token_from_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, + const char *token_str, H5O_token_t *token) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(obj); + HDassert(cls); + HDassert(token_str); + HDassert(token); + + /* Use the class's token deserialization routine on the token if there is a + * callback, otherwise just set the token to H5_TOKEN_UNDEF. + */ + if(cls->token_cls.from_str) { + if((cls->token_cls.from_str)(obj, obj_type, token_str, token) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token string") + } /* end if */ + else + *token = H5O_TOKEN_UNDEF; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__token_from_str() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_token_from_str + * + * Purpose: Deserialize a string into a connector object token + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, + const char *token_str, H5O_token_t *token) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(vol_obj); + HDassert(token); + HDassert(token_str); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if((ret_value = H5VL__token_from_str(vol_obj->data, obj_type, vol_obj->connector->cls, token_str, token)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "token deserialization failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_token_from_str() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLtoken_from_str + * + * Purpose: Deserialize a string into a connector object token + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector_id, + const char *token_str, H5O_token_t *token) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xIti*s*k", obj, obj_type, connector_id, token_str, token); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + if(NULL == token) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer") + if(NULL == token_str) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token_str pointer") + + /* Call the corresponding internal VOL routine */ + if(H5VL__token_from_str(obj, obj_type, cls, token_str, token) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "object token from string failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLtoken_from_str() */ + + +/*------------------------------------------------------------------------- * Function: H5VL__optional * * Purpose: Optional operation specific to connectors. diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h index 4ce6bb1..9bc3a7b 100644 --- a/src/H5VLconnector.h +++ b/src/H5VLconnector.h @@ -43,8 +43,6 @@ /* The maximum size allowed for blobs */ #define H5VL_MAX_BLOB_ID_SIZE (16) /* Allow for 128-bits blob IDs */ -/* The maximum size allowed for tokens */ -#define H5VL_MAX_TOKEN_SIZE (16) /* Allow for 128-bits tokens */ /*******************/ /* Public Typedefs */ @@ -64,15 +62,10 @@ typedef enum H5VL_subclass_t { H5VL_SUBCLS_LINK, /* 'Link' subclass */ H5VL_SUBCLS_OBJECT, /* 'Object' subclass */ H5VL_SUBCLS_REQUEST, /* 'Request' subclass */ - H5VL_SUBCLS_BLOB /* 'Blob' subclass */ + H5VL_SUBCLS_BLOB, /* 'Blob' subclass */ + H5VL_SUBCLS_TOKEN /* 'Token' subclass */ } H5VL_subclass_t; -/* type for tokens. Token are unique and permanent identifiers that are - * used to reference HDF5 objects. */ -typedef struct { - char __data[H5VL_MAX_TOKEN_SIZE]; -} H5VL_token_t; - /* types for attribute GET callback */ typedef enum H5VL_attr_get_t { H5VL_ATTR_GET_ACPL, /* creation property list */ @@ -201,7 +194,8 @@ typedef int H5VL_link_optional_t; typedef enum H5VL_object_get_t { H5VL_OBJECT_GET_FILE, /* object file */ H5VL_OBJECT_GET_NAME, /* object name */ - H5VL_OBJECT_GET_TYPE /* object type */ + H5VL_OBJECT_GET_TYPE, /* object type */ + H5VL_OBJECT_GET_INFO /* H5Oget_info(_by_idx|name)3 */ } H5VL_object_get_t; /* types for object SPECIFIC callback */ @@ -262,7 +256,7 @@ typedef struct H5VL_loc_by_idx { } H5VL_loc_by_idx_t; typedef struct H5VL_loc_by_token { - H5VL_token_t *token; + H5O_token_t *token; } H5VL_loc_by_token_t; /* Structure to hold parameters for object locations. @@ -459,6 +453,13 @@ typedef struct H5VL_blob_class_t { herr_t (*optional)(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments); } H5VL_blob_class_t; +/* Object token routines */ +typedef struct H5VL_token_class_t { + herr_t (*cmp)(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value); + herr_t (*to_str)(void *obj, H5I_type_t obj_type, const H5O_token_t *token, char **token_str); + herr_t (*from_str)(void *obj, H5I_type_t obj_type, const char *token_str, H5O_token_t *token); +} H5VL_token_class_t; + /* Class information for each VOL connector */ typedef struct H5VL_class_t { /* Overall connector fields & callbacks */ @@ -486,6 +487,7 @@ typedef struct H5VL_class_t { H5VL_introspect_class_t introspect_cls; /* Container/connector introspection class callbacks */ H5VL_request_class_t request_cls; /* Asynchronous request class callbacks */ H5VL_blob_class_t blob_cls; /* 'Blob' class callbacks */ + H5VL_token_class_t token_cls; /* VOL connector object token class callbacks */ /* Catch-all */ herr_t (*optional)(void *obj, int op_type, hid_t dxpl_id, void **req, va_list arguments); /* Optional callback */ diff --git a/src/H5VLconnector_passthru.h b/src/H5VLconnector_passthru.h index 5a937bf..b04f5eb 100644 --- a/src/H5VLconnector_passthru.h +++ b/src/H5VLconnector_passthru.h @@ -170,6 +170,11 @@ H5_DLL herr_t H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, v H5_DLL herr_t H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments); H5_DLL herr_t H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments); +/* Public wrappers for token callbacks */ +H5_DLL herr_t H5VLtoken_cmp(void *obj, hid_t connector_id, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value); +H5_DLL herr_t H5VLtoken_to_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const H5O_token_t *token, char **token_str); +H5_DLL herr_t H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const char *token_str, H5O_token_t *token); + /* Public wrappers for generic 'optional' callback */ H5_DLL herr_t H5VLoptional(void *obj, hid_t connector_id, int op_type, hid_t dxpl_id, void **req, va_list arguments); diff --git a/src/H5VLint.c b/src/H5VLint.c index 242b1c7..9038d38 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -425,7 +425,7 @@ H5VL__set_def_conn(void) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check if VOL connector already registered") else if(connector_is_registered) { /* Retrieve the ID of the already-registered VOL connector */ - if((connector_id = H5VL__get_connector_id(tok, FALSE)) < 0) + if((connector_id = H5VL__get_connector_id_by_name(tok, FALSE)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector ID") } /* end else-if */ else { @@ -1366,6 +1366,41 @@ done: /*------------------------------------------------------------------------- * Function: H5VL__get_connector_id * + * Purpose: Retrieves the VOL connector ID for a given object ID. + * + * Return: Positive if the VOL class has been registered + * Negative on error (if the class is not a valid class or not registered) + * + * Programmer: Dana Robinson + * June 17, 2017 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__get_connector_id(hid_t obj_id, hbool_t is_api) +{ + H5VL_object_t *vol_obj = NULL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Get the underlying VOL object for the object ID */ + if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Return the VOL object's VOL class ID */ + ret_value = vol_obj->connector->id; + if(H5I_inc_ref(ret_value, is_api) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__get_connector_id() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__get_connector_id_by_name + * * Purpose: Retrieves the ID for a registered VOL connector. * * Return: Positive if the VOL class has been registered @@ -1377,7 +1412,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL__get_connector_id(const char *name, hbool_t is_api) +H5VL__get_connector_id_by_name(const char *name, hbool_t is_api) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -1393,7 +1428,7 @@ H5VL__get_connector_id(const char *name, hbool_t is_api) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__get_connector_id() */ +} /* end H5VL__get_connector_id_by_name() */ /*------------------------------------------------------------------------- diff --git a/src/H5VLnative.c b/src/H5VLnative.c index dfa57ef..616ca60 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -16,9 +16,15 @@ */ #include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ +#include "H5Tprivate.h" /* Datatypes */ #include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ @@ -130,6 +136,11 @@ static const H5VL_class_t H5VL_native_cls_g = { H5VL__native_blob_specific, /* specific */ NULL /* optional */ }, + { /* token_cls */ + H5VL__native_token_cmp, /* cmp */ + H5VL__native_token_to_str, /* to_str */ + H5VL__native_str_to_token /* from_str */ + }, NULL /* optional */ }; @@ -212,3 +223,337 @@ H5VL__native_introspect_get_conn_cls(void H5_ATTR_UNUSED *obj, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VL__native_introspect_get_conn_cls() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_native_get_file_addr_len + * + * Purpose: Convenience function to get a file's address length from a + * location ID. Useful when you have to encode/decode addresses + * to/from tokens. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_native_get_file_addr_len(hid_t loc_id, size_t *addr_len) +{ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + void *vol_obj = NULL; /* VOL Object of loc_id */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check arguments */ + HDassert(addr_len); + + /* Get object type */ + if((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve underlying VOL object */ + if(NULL == (vol_obj = H5VL_object(loc_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve file address length */ + if(H5VL__native_get_file_addr_len(vol_obj, vol_obj_type, addr_len) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get file address length") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_get_file_addr_len() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_get_file_addr_len + * + * Purpose: Convenience function to get a file's address length from a + * VOL object. Useful when you have to encode/decode addresses + * to/from tokens. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_get_file_addr_len(void *obj, H5I_type_t obj_type, size_t *addr_len) +{ + H5F_t *file = NULL; /* File stuct pointer */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* check arguments */ + HDassert(obj); + HDassert(addr_len); + + /* Retrieve file from the VOL object */ + if(H5VL_native_get_file_struct(obj, obj_type, &file) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "couldn't get file from VOL object") + + /* Get the length of an address in this file */ + *addr_len = H5F_SIZEOF_ADDR(file); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_get_file_addr_len() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLnative_addr_to_token + * + * Purpose: Converts a native VOL haddr_t address to an abstract VOL token. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLnative_addr_to_token(hid_t loc_id, haddr_t addr, H5O_token_t *token) +{ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + void *vol_obj = NULL; /* VOL Object of loc_id */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ia*k", loc_id, addr, token); + + /* Check args */ + if(NULL == token) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "token pointer can't be NULL") + + /* Get object type */ + if((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve underlying VOL object */ + if(NULL == (vol_obj = H5VL_object(loc_id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") + +#ifndef NDEBUG + { + H5VL_object_t *vol_obj_container; + hbool_t is_native_vol_obj; + + /* Get the location object */ + if(NULL == (vol_obj_container = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Make sure that the VOL object is a native connector object */ + if(H5VL_object_is_native(vol_obj_container, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + + HDassert(is_native_vol_obj && "not a native VOL connector object"); + } +#endif + + /* Convert the haddr_t to an object token */ + if(H5VL_native_addr_to_token(vol_obj, vol_obj_type, addr, token) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "couldn't serialize haddr_t into object token") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLnative_addr_to_token() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_addr_to_token + * + * Purpose: Converts a native VOL haddr_t address to an abstract VOL token. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_native_addr_to_token(void *obj, H5I_type_t obj_type, haddr_t addr, H5O_token_t *token) +{ + uint8_t *p; + size_t addr_len = 0; /* Size of haddr_t */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(obj); + HDassert(token); + + /* Get the length of an haddr_t in the file */ + if(H5VL__native_get_file_addr_len(obj, obj_type, &addr_len) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "couldn't get length of haddr_t from VOL object") + + /* Ensure that token is initialized */ + HDmemset(token, 0, sizeof(H5O_token_t)); + + /* Encode token */ + p = (uint8_t *)token; + H5F_addr_encode_len(addr_len, &p, addr); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_addr_to_token() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLnative_token_to_addr + * + * Purpose: Converts an abstract VOL token to a native VOL haddr_t address. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLnative_token_to_addr(hid_t loc_id, H5O_token_t token, haddr_t *addr) +{ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + void *vol_obj = NULL; /* VOL Object of loc_id */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ik*a", loc_id, token, addr); + + /* Check args */ + if(NULL == addr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr pointer can't be NULL") + + /* Get object type */ + if((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve underlying VOL object */ + if(NULL == (vol_obj = H5VL_object(loc_id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") + +#ifndef NDEBUG + { + H5VL_object_t *vol_obj_container; + hbool_t is_native_vol_obj; + + /* Get the location object */ + if(NULL == (vol_obj_container = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Make sure that the VOL object is a native connector object */ + if(H5VL_object_is_native(vol_obj_container, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + + HDassert(is_native_vol_obj && "not a native VOL connector object"); + } +#endif + + /* Convert the object token to an haddr_t */ + if(H5VL_native_token_to_addr(vol_obj, vol_obj_type, token, addr) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "couldn't deserialize object token into haddr_t") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLnative_token_to_addr() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_token_to_addr + * + * Purpose: Converts an abstract VOL token to a native VOL haddr_t address. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_native_token_to_addr(void *obj, H5I_type_t obj_type, H5O_token_t token, haddr_t *addr) +{ + const uint8_t *p; + size_t addr_len = 0; /* Size of haddr_t */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(obj); + HDassert(addr); + + /* Get the length of an haddr_t in the file */ + if(H5VL__native_get_file_addr_len(obj, obj_type, &addr_len) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "couldn't get length of haddr_t from VOL object") + + /* Decode token */ + p = (const uint8_t *)&token; + H5F_addr_decode_len(addr_len, &p, addr); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_token_to_addr() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_native_get_file_struct + * + * Purpose: Utility routine to get file struct for an object + * + * Returns: SUCCEED/FAIL + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL_native_get_file_struct(void *obj, H5I_type_t type, H5F_t **file) +{ + H5O_loc_t *oloc = NULL; /* Object location for ID */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL); + + *file = NULL; + + switch(type) { + case H5I_FILE: + *file = (H5F_t *)obj; + break; + + case H5I_GROUP: + oloc = H5G_oloc((H5G_t *)obj); + break; + + case H5I_DATATYPE: + oloc = H5T_oloc((H5T_t *)obj); + break; + + case H5I_DATASET: + oloc = H5D_oloc((H5D_t *)obj); + break; + + case H5I_ATTR: + oloc = H5A_oloc((H5A_t *)obj); + break; + + case H5I_MAP: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "maps not supported in native VOL connector") + + case H5I_UNINIT: + case H5I_BADID: + case H5I_DATASPACE: + case H5I_VFL: + case H5I_VOL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_SPACE_SEL_ITER: + case H5I_NTYPES: + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + } /* end switch */ + + /* Set return value for objects (not files) */ + if(oloc) + *file = oloc->file; + + /* Couldn't find a file struct */ + if(!*file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5VL_native_get_file_struct */ + diff --git a/src/H5VLnative.h b/src/H5VLnative.h index 44ed670..e1f3f93 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -88,11 +88,23 @@ /* Values for native VOL connector object optional VOL operations */ #define H5VL_NATIVE_OBJECT_GET_COMMENT 0 /* H5G|H5Oget_comment, H5Oget_comment_by_name */ -#define H5VL_NATIVE_OBJECT_GET_INFO 1 /* H5Oget_info(_by_idx, _by_name)(2) */ -#define H5VL_NATIVE_OBJECT_SET_COMMENT 2 /* H5G|H5Oset_comment, H5Oset_comment_by_name */ -#define H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES 3 /* H5Odisable_mdc_flushes */ -#define H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES 4 /* H5Oenable_mdc_flushes */ -#define H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED 5 /* H5Oare_mdc_flushes_disabled */ +#define H5VL_NATIVE_OBJECT_SET_COMMENT 1 /* H5G|H5Oset_comment, H5Oset_comment_by_name */ +#define H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES 2 /* H5Odisable_mdc_flushes */ +#define H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES 3 /* H5Oenable_mdc_flushes */ +#define H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED 4 /* H5Oare_mdc_flushes_disabled */ +#define H5VL_NATIVE_OBJECT_GET_NATIVE_INFO 5 /* H5Oget_native_info(_by_idx, _by_name) */ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ /*******************/ /* Public Typedefs */ @@ -110,7 +122,11 @@ extern "C" { #endif -/* Private functions */ +/* Token <--> address converters */ +H5_DLL herr_t H5VLnative_addr_to_token(hid_t loc_id, haddr_t addr, H5O_token_t *token); +H5_DLL herr_t H5VLnative_token_to_addr(hid_t loc_id, H5O_token_t token, haddr_t *addr); + +/* Not really public but must be included here */ H5_DLL hid_t H5VL_native_register(void); #ifdef __cplusplus diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c index 005859d..23ea37b 100644 --- a/src/H5VLnative_file.c +++ b/src/H5VLnative_file.c @@ -226,7 +226,7 @@ H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, ssize_t *ret = HDva_arg(arguments, ssize_t *); size_t len; - if(NULL == (f = H5F__get_file(obj, type))) + if(H5VL_native_get_file_struct(obj, type, &f) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") len = HDstrlen(H5F_OPEN_NAME(f)); @@ -313,7 +313,7 @@ H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, H5F_t *f = NULL; /* File to flush */ /* Get the file for the object */ - if(NULL == (f = H5F__get_file(obj, type))) + if(H5VL_native_get_file_struct(obj, type, &f) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Nothing to do if the file is read only. This determination is @@ -519,7 +519,7 @@ H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, /* Get the file struct. This call is careful to not return the file pointer * for the top file in a mount hierarchy. */ - if(NULL == (f = H5F__get_file(obj, type))) + if(H5VL_native_get_file_struct(obj, type, &f) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct") /* Get the file info */ diff --git a/src/H5VLnative_link.c b/src/H5VLnative_link.c index 9a633ac..051de19 100644 --- a/src/H5VLnative_link.c +++ b/src/H5VLnative_link.c @@ -241,16 +241,16 @@ H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_ /* H5Lget_info/H5Lget_info_by_idx */ case H5VL_LINK_GET_INFO: { - H5L_info_t *linfo = HDva_arg(arguments, H5L_info_t *); + H5L_info2_t *linfo2 = HDva_arg(arguments, H5L_info2_t *); /* Get the link information */ if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */ - if(H5L_get_info(&loc, loc_params->loc_data.loc_by_name.name, linfo) < 0) + if(H5L_get_info(&loc, loc_params->loc_data.loc_by_name.name, linfo2) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") } /* end if */ else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ if(H5L_get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, linfo) < 0) + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, linfo2) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") } /* end else-if */ else @@ -341,12 +341,12 @@ H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_ case H5VL_LINK_ITER: { H5G_loc_t loc; - hbool_t recursive = (hbool_t)HDva_arg(arguments, unsigned); - H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ - H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ - hsize_t *idx_p = HDva_arg(arguments, hsize_t *); - H5L_iterate_t op = HDva_arg(arguments, H5L_iterate_t); - void *op_data = HDva_arg(arguments, void *); + hbool_t recursive = (hbool_t)HDva_arg(arguments, unsigned); + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + hsize_t *idx_p = HDva_arg(arguments, hsize_t *); + H5L_iterate2_t op = HDva_arg(arguments, H5L_iterate2_t); + void *op_data = HDva_arg(arguments, void *); /* Get the location */ if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c index e6b3295..3a29b6c 100644 --- a/src/H5VLnative_object.c +++ b/src/H5VLnative_object.c @@ -72,11 +72,12 @@ H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_typ case H5VL_OBJECT_BY_TOKEN: { - const uint8_t *p = (const uint8_t *)loc_params->loc_data.loc_by_token.token; + H5O_token_t token = *loc_params->loc_data.loc_by_token.token; haddr_t addr; /* Decode token */ - H5F_addr_decode(loc.oloc->file, &p, &addr); + if(H5VL_native_token_to_addr(loc.oloc->file, H5I_FILE, token, &addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, NULL, "can't deserialize object token into address") /* Open the object */ if(NULL == (ret_value = H5O_open_by_addr(&loc, addr, opened_type))) @@ -184,13 +185,15 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj } /* end if */ else if(loc_params->type == H5VL_OBJECT_BY_TOKEN) { H5O_loc_t obj_oloc; /* Object location */ - const uint8_t *p = (const uint8_t *)loc_params->loc_data.loc_by_token.token; + H5O_token_t token = *loc_params->loc_data.loc_by_token.token; /* Initialize the object location */ H5O_loc_reset(&obj_oloc); obj_oloc.file = loc.oloc->file; + /* Decode token */ - H5F_addr_decode(obj_oloc.file, &p, &obj_oloc.addr); + if(H5VL_native_token_to_addr(obj_oloc.file, H5I_FILE, token, &obj_oloc.addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") /* Retrieve object's name */ if((*ret = H5G_get_name_by_addr(loc.oloc->file, &obj_oloc, name, size)) < 0) @@ -209,13 +212,15 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj if(loc_params->type == H5VL_OBJECT_BY_TOKEN) { H5O_loc_t obj_oloc; /* Object location */ unsigned rc; /* Reference count of object */ - const uint8_t *p = (const uint8_t *)loc_params->loc_data.loc_by_token.token; + H5O_token_t token = *loc_params->loc_data.loc_by_token.token; /* Initialize the object location */ H5O_loc_reset(&obj_oloc); obj_oloc.file = loc.oloc->file; + /* Decode token */ - H5F_addr_decode(obj_oloc.file, &p, &obj_oloc.addr); + if(H5VL_native_token_to_addr(obj_oloc.file, H5I_FILE, token, &obj_oloc.addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") /* Get the # of links for object, and its type */ /* (To check to make certain that this object hasn't been deleted) */ @@ -226,6 +231,56 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj break; } + /* H5Oget_info(_name|_by_idx)3 */ + case H5VL_OBJECT_GET_INFO: + { + H5O_info2_t *oinfo = HDva_arg(arguments, H5O_info2_t *); + unsigned fields = HDva_arg(arguments, unsigned); + + /* Use the original H5Oget_info code to get the data */ + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ + /* Retrieve the object's information */ + if(H5G_loc_info(&loc, ".", oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ + /* Retrieve the object's information */ + if(H5G_loc_info(&loc, loc_params->loc_data.loc_by_name.name, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ + 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 */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location, according to the order in the index */ + if(H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the object's information */ + if(H5O_get_info(obj_loc.oloc, oinfo, fields) < 0) { + H5G_loc_free(&obj_loc); + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + } /* end if */ + + /* Release the object location */ + if(H5G_loc_free(&obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + } /* end else-if */ + else + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + break; + } + default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object") } /* end switch */ @@ -287,7 +342,7 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5V /* Lookup object */ case H5VL_OBJECT_LOOKUP: { - H5VL_token_t *token = va_arg(arguments, H5VL_token_t *); + H5O_token_t *token = va_arg(arguments, H5O_token_t *); HDassert(token); @@ -295,7 +350,6 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5V H5G_loc_t obj_loc; /* Group hier. location of object */ H5G_name_t obj_path; /* Object group hier. path */ H5O_loc_t obj_oloc; /* Object object location */ - uint8_t *p = (uint8_t *)token; /* Pointer to token */ /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -307,7 +361,8 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5V HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") /* Encode token */ - H5F_addr_encode(obj_oloc.file, &p, obj_loc.oloc->addr); + if(H5VL_native_addr_to_token(loc.oloc->file, H5I_FILE, obj_loc.oloc->addr, token) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") /* Release the object location */ if(H5G_loc_free(&obj_loc) < 0) @@ -322,7 +377,7 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5V { H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ - H5O_iterate_t op = HDva_arg(arguments, H5O_iterate_t); + H5O_iterate2_t op = HDva_arg(arguments, H5O_iterate2_t); void *op_data = HDva_arg(arguments, void *); unsigned fields = HDva_arg(arguments, unsigned); @@ -397,54 +452,6 @@ H5VL__native_object_optional(void *obj, H5VL_object_optional_t optional_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") switch(optional_type) { - /* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */ - case H5VL_NATIVE_OBJECT_GET_INFO: - { - H5O_info_t *obj_info = HDva_arg(arguments, H5O_info_t *); - unsigned fields = HDva_arg(arguments, unsigned); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, ".", obj_info, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, loc_params->loc_data.loc_by_name.name, obj_info, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end else-if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ - 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 */ - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") - - /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, obj_info, fields) < 0) { - H5G_loc_free(&obj_loc); - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") - } /* end if */ - - /* Release the object location */ - if(H5G_loc_free(&obj_loc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - } /* end else-if */ - else - HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") - break; - } - /* H5Oget_comment / H5Oget_comment_by_name */ case H5VL_NATIVE_OBJECT_GET_COMMENT: { @@ -520,6 +527,57 @@ H5VL__native_object_optional(void *obj, H5VL_object_optional_t optional_type, break; } + /* H5Oget_native_info(_name|_by_idx) */ + case H5VL_NATIVE_OBJECT_GET_NATIVE_INFO: + { + H5O_native_info_t *native_info = HDva_arg(arguments, H5O_native_info_t *); + unsigned fields = HDva_arg(arguments, unsigned); + + /* Use the original H5Oget_info code to get the data */ + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ + /* Retrieve the object's information */ + if(H5G_loc_native_info(&loc, ".", native_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ + /* Retrieve the object's information */ + if(H5G_loc_native_info(&loc, loc_params->loc_data.loc_by_name.name, native_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ + 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 */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location, according to the order in the index */ + if(H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the object's information */ + if(H5O_get_native_info(obj_loc.oloc, native_info, fields) < 0) { + H5G_loc_free(&obj_loc); + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + } /* end if */ + + /* Release the object location */ + if(H5G_loc_free(&obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + } /* end else-if */ + else + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + + break; + } + default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object"); } /* end switch */ diff --git a/src/H5VLnative_private.h b/src/H5VLnative_private.h index ad9a496..30bddb6 100644 --- a/src/H5VLnative_private.h +++ b/src/H5VLnative_private.h @@ -18,7 +18,8 @@ #define _H5VLnative_private_H /* Private headers needed by this file */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5Fprivate.h" /* Files */ +#include "H5VLnative.h" /* Native VOL connector */ /**************************/ @@ -110,6 +111,18 @@ H5_DLL herr_t H5VL__native_blob_put(void *obj, const void *buf, size_t size, voi H5_DLL herr_t H5VL__native_blob_get(void *obj, const void *blob_id, void *buf, size_t size, void *ctx); H5_DLL herr_t H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments); +/* Token callbacks */ +H5_DLL herr_t H5VL__native_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value); +H5_DLL herr_t H5VL__native_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, char **token_str); +H5_DLL herr_t H5VL__native_str_to_token(void *obj, H5I_type_t obj_type, const char *token_str, H5O_token_t *token); + +/* Helper functions */ +H5_DLL herr_t H5VL_native_get_file_addr_len(hid_t loc_id, size_t *addr_len); +H5_DLL herr_t H5VL__native_get_file_addr_len(void *obj, H5I_type_t obj_type, size_t *addr_len); +H5_DLL herr_t H5VL_native_addr_to_token(void *obj, H5I_type_t obj_type, haddr_t addr, H5O_token_t *token); +H5_DLL herr_t H5VL_native_token_to_addr(void *obj, H5I_type_t obj_type, H5O_token_t token, haddr_t *addr); +H5_DLL herr_t H5VL_native_get_file_struct(void *obj, H5I_type_t type, H5F_t **file); + #ifdef __cplusplus } #endif diff --git a/src/H5VLnative_token.c b/src/H5VLnative_token.c new file mode 100644 index 0000000..2b5429e --- /dev/null +++ b/src/H5VLnative_token.c @@ -0,0 +1,157 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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: Object token callbacks for the native VOL connector + */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory handling */ +#include "H5VLnative_private.h" /* Native VOL connector */ + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*--------------------------------------------------------------------------- + * Function: H5VL__native_token_cmp + * + * Purpose: Compare two of the connector's object tokens, setting + * *cmp_value, following the same rules as strcmp(). + * + * Return: Success: 0 + * Failure: (can't fail) + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__native_token_cmp(void H5_ATTR_UNUSED *obj, + const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE_NOERR + + /* Check parameters */ + HDassert(token1); + HDassert(token2); + + *cmp_value = HDmemcmp(token1, token2, sizeof(H5O_token_t)); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_token_cmp() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL__native_token_to_str + * + * Purpose: Serialize an object token into a string + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__native_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, + char **token_str) +{ + haddr_t addr; + size_t addr_ndigits; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + /* Check parameters */ + HDassert(obj); + HDassert(token); + + if(H5VL_native_token_to_addr(obj, obj_type, *token, &addr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't convert object token to address") + + if(addr == 0) + addr_ndigits = 1; + else + addr_ndigits = (size_t)(HDfloor(HDlog10((double)addr)) + 1); + + if(NULL == (*token_str = H5MM_malloc(addr_ndigits + 1))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate buffer for token string") + + HDsnprintf(*token_str, addr_ndigits + 1, H5_PRINTF_HADDR_FMT, addr); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_token_to_str() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL__native_str_to_token + * + * Purpose: Deserialize a string into an object token + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__native_str_to_token(void *obj, H5I_type_t obj_type, + const char *token_str, H5O_token_t *token) +{ + haddr_t addr; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + /* Check parameters */ + HDassert(token_str); + + HDsscanf(token_str, H5_PRINTF_HADDR_FMT, &addr); + + if(H5VL_native_addr_to_token(obj, obj_type, addr, token) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't convert address to object token") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_str_to_token() */ + diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c index 076d6de..5c9f28c 100644 --- a/src/H5VLpassthru.c +++ b/src/H5VLpassthru.c @@ -188,6 +188,11 @@ static herr_t H5VL_pass_through_blob_get(void *obj, const void *blob_id, void *b static herr_t H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments); static herr_t H5VL_pass_through_blob_optional(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments); +/* Token callbacks */ +static herr_t H5VL_pass_through_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value); +static herr_t H5VL_pass_through_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, char **token_str); +static herr_t H5VL_pass_through_token_from_str(void *obj, H5I_type_t obj_type, const char *token_str, H5O_token_t *token); + /* Generic optional callback */ static herr_t H5VL_pass_through_optional(void *obj, int op_type, hid_t dxpl_id, void **req, va_list arguments); @@ -296,6 +301,11 @@ static const H5VL_class_t H5VL_pass_through_g = { H5VL_pass_through_blob_specific, /* specific */ H5VL_pass_through_blob_optional /* optional */ }, + { /* token_cls */ + H5VL_pass_through_token_cmp, /* cmp */ + H5VL_pass_through_token_to_str, /* to_str */ + H5VL_pass_through_token_from_str /* from_str */ + }, H5VL_pass_through_optional /* optional */ }; @@ -3028,6 +3038,104 @@ H5VL_pass_through_blob_optional(void *obj, void *blob_id, } /* end H5VL_pass_through_blob_optional() */ +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_token_cmp + * + * Purpose: Compare two of the connector's object tokens, setting + * *cmp_value, following the same rules as strcmp(). + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_token_cmp(void *obj, const H5O_token_t *token1, + const H5O_token_t *token2, int *cmp_value) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL TOKEN Compare\n"); +#endif + + /* Sanity checks */ + assert(obj); + assert(token1); + assert(token2); + assert(cmp_value); + + ret_value = H5VLtoken_cmp(o->under_object, o->under_vol_id, token1, token2, cmp_value); + + return ret_value; +} /* end H5VL_pass_through_token_cmp() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_token_to_str + * + * Purpose: Serialize the connector's object token into a string. + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_token_to_str(void *obj, H5I_type_t obj_type, + const H5O_token_t *token, char **token_str) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL TOKEN To string\n"); +#endif + + /* Sanity checks */ + assert(obj); + assert(token); + assert(token_str); + + ret_value = H5VLtoken_to_str(o->under_object, obj_type, o->under_vol_id, token, token_str); + + return ret_value; +} /* end H5VL_pass_through_token_to_str() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_token_from_str + * + * Purpose: Deserialize the connector's object token from a string. + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_token_from_str(void *obj, H5I_type_t obj_type, + const char *token_str, H5O_token_t *token) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL TOKEN From string\n"); +#endif + + /* Sanity checks */ + assert(obj); + assert(token); + assert(token_str); + + ret_value = H5VLtoken_from_str(o->under_object, obj_type, o->under_vol_id, token_str, token); + + return ret_value; +} /* end H5VL_pass_through_token_from_str() */ + + /*------------------------------------------------------------------------- * Function: H5VL_pass_through_optional * diff --git a/src/H5VLpkg.h b/src/H5VLpkg.h index fc3088d..5965adc 100644 --- a/src/H5VLpkg.h +++ b/src/H5VLpkg.h @@ -54,7 +54,8 @@ H5_DLL hid_t H5VL__register_connector_by_name(const char *name, hbool_t app_ref, H5_DLL hid_t H5VL__register_connector_by_value(H5VL_class_value_t value, hbool_t app_ref, hid_t vipl_id); H5_DLL htri_t H5VL__is_connector_registered(const char *name); -H5_DLL hid_t H5VL__get_connector_id(const char *name, hbool_t is_api); +H5_DLL hid_t H5VL__get_connector_id(hid_t obj_id, hbool_t is_api); +H5_DLL hid_t H5VL__get_connector_id_by_name(const char *name, hbool_t is_api); H5_DLL hid_t H5VL__peek_connector_id(const char *name); H5_DLL herr_t H5VL__connector_str_to_info(const char *str, hid_t connector_id, void **info); diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 18d6825..24ae1f3 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -209,6 +209,14 @@ H5_DLL herr_t H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, v H5_DLL herr_t H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_specific_t specific_type, ...); H5_DLL herr_t H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_optional_t opt_type, ...); +/* Token functions */ +H5_DLL herr_t H5VL_token_cmp(const H5VL_object_t *vol_obj, const H5O_token_t *token1, + const H5O_token_t *token2, int *cmp_value); +H5_DLL herr_t H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, + const H5O_token_t *token, char **token_str); +H5_DLL herr_t H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, + const char *token_str, H5O_token_t *token); + /* Generic functions */ H5_DLL herr_t H5VL_optional(const H5VL_object_t *vol_obj, int op_type, hid_t dxpl_id, void **req, ...); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 34a642e..883aac8 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -66,7 +66,8 @@ extern "C" { H5_DLL hid_t H5VLregister_connector_by_name(const char *connector_name, hid_t vipl_id); H5_DLL hid_t H5VLregister_connector_by_value(H5VL_class_value_t connector_value, hid_t vipl_id); H5_DLL htri_t H5VLis_connector_registered(const char *name); -H5_DLL hid_t H5VLget_connector_id(const char *name); +H5_DLL hid_t H5VLget_connector_id(hid_t obj_id); +H5_DLL hid_t H5VLget_connector_id_by_name(const char *name); H5_DLL ssize_t H5VLget_connector_name(hid_t id, char *name/*out*/, size_t size); H5_DLL herr_t H5VLclose(hid_t connector_id); H5_DLL herr_t H5VLunregister_connector(hid_t connector_id); diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 2245bd3..6d07513 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -324,7 +324,7 @@ static void H5Z_print(H5Z_node *tree, FILE *stream); #define H5Z_XFORM_DO_OP5(TYPE, SIZE) \ { \ - TYPE val = (TYPE)((tree->type == H5Z_XFORM_INTEGER) ? tree->value.int_val : tree->value.float_val); \ + TYPE val = ((tree->type == H5Z_XFORM_INTEGER) ? (TYPE)tree->value.int_val : (TYPE)tree->value.float_val); \ H5VM_array_fill(array, &val, sizeof(TYPE), (SIZE)); \ } diff --git a/src/H5mpi.c b/src/H5mpi.c index f529b3d..4e1bc95 100644 --- a/src/H5mpi.c +++ b/src/H5mpi.c @@ -75,7 +75,7 @@ H5_mpi_set_bigio_count(hsize_t new_count) *------------------------------------------------------------------------- */ hsize_t -H5_mpi_get_bigio_count() +H5_mpi_get_bigio_count(void) { return bigio_count; } @@ -482,7 +482,7 @@ H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, /* Calculate how many Big MPI datatypes are needed to represent the buffer */ num_big_types = (int)(num_elements/bigio_count); - leftover = num_elements - num_big_types * (hsize_t)bigio_count; + leftover = (hsize_t)num_elements - (hsize_t)num_big_types * bigio_count; H5_CHECKED_ASSIGN(remaining_bytes, int, leftover, hsize_t); /* Create a contiguous datatype of size equal to the largest @@ -491,11 +491,11 @@ H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, * use type_hvector to create the type with the displacement provided */ if (0 == stride_bytes) { - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(bigio_count, old_type, &inner_type))) + if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)bigio_count, old_type, &inner_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) } /* end if */ else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector(bigio_count, 1, stride_bytes, old_type, &inner_type))) + if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)bigio_count, 1, stride_bytes, old_type, &inner_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) /* Create a contiguous datatype of the buffer (minus the remaining < 2GB part) diff --git a/src/H5overflow.txt b/src/H5overflow.txt index a9e5099..9fb3b89 100644 --- a/src/H5overflow.txt +++ b/src/H5overflow.txt @@ -29,7 +29,9 @@ # Creation Date: 2009/04/09 unsigned, UNSIGNED; +int8_t, SIGNED; int, SIGNED; +long, SIGNED; int64_t, SIGNED; uint8_t, UNSIGNED; uint16_t, UNSIGNED; diff --git a/src/H5private.h b/src/H5private.h index 5ab9daf..fbea9b8 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -305,15 +305,21 @@ */ #ifdef __cplusplus # define H5_ATTR_FORMAT(X,Y,Z) /*void*/ -# define H5_ATTR_UNUSED /*void*/ -# define H5_ATTR_NORETURN /*void*/ -# define H5_ATTR_CONST /*void*/ -# define H5_ATTR_PURE /*void*/ -# define H5_ATTR_FALLTHROUGH /*void*/ +# define H5_ATTR_UNUSED /*void*/ +# define H5_ATTR_NDEBUG_UNUSED /*void*/ +# define H5_ATTR_NORETURN /*void*/ +# define H5_ATTR_CONST /*void*/ +# define H5_ATTR_PURE /*void*/ +# define H5_ATTR_FALLTHROUGH /*void*/ #else /* __cplusplus */ #if defined(H5_HAVE_ATTRIBUTE) && !defined(__SUNPRO_C) # define H5_ATTR_FORMAT(X,Y,Z) __attribute__((format(X, Y, Z))) # define H5_ATTR_UNUSED __attribute__((unused)) +#ifndef NDEBUG +#define H5_ATTR_NDEBUG_UNUSED /*void*/ +#else /* NDEBUG */ +#define H5_ATTR_NDEBUG_UNUSED H5_ATTR_UNUSED +#endif /* NDEBUG */ # define H5_ATTR_NORETURN __attribute__((noreturn)) # define H5_ATTR_CONST __attribute__((const)) # define H5_ATTR_PURE __attribute__((pure)) @@ -324,11 +330,12 @@ #endif #else # define H5_ATTR_FORMAT(X,Y,Z) /*void*/ -# define H5_ATTR_UNUSED /*void*/ -# define H5_ATTR_NORETURN /*void*/ -# define H5_ATTR_CONST /*void*/ -# define H5_ATTR_PURE /*void*/ -# define H5_ATTR_FALLTHROUGH /*void*/ +# define H5_ATTR_UNUSED /*void*/ +# define H5_ATTR_NDEBUG_UNUSED /*void*/ +# define H5_ATTR_NORETURN /*void*/ +# define H5_ATTR_CONST /*void*/ +# define H5_ATTR_PURE /*void*/ +# define H5_ATTR_FALLTHROUGH /*void*/ #endif #endif /* __cplusplus */ @@ -527,28 +534,6 @@ #define H5_REQUEST_NULL NULL /* - * A macro to portably decrement enumerated types. - */ -#ifndef H5_DEC_ENUM -# define H5_DEC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)-1)) -#endif - -/* Double constant wrapper - * - * Quiets gcc warnings from -Wunsuffixed-float-constants. - * - * This is a really annoying warning since the standard specifies that - * constants of type double do NOT get a suffix so there's no way - * to specify a constant of type double. To quiet gcc, we specify floating - * point constants as type long double and cast to double. - * - * Note that this macro only needs to be used where using a double - * is important. For most code, suffixing constants with F will quiet the - * compiler and not produce erroneous code. - */ -#define H5_DOUBLE(S) ((double) S ## L) - -/* * Methods to compare the equality of floating-point values: * * 1. H5_XXX_ABS_EQUAL - check if the difference is smaller than the diff --git a/src/H5public.h b/src/H5public.h index 8021027..86a1fbb 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -328,6 +328,18 @@ typedef struct H5_ih_info_t { hsize_t heap_size; } H5_ih_info_t; +/* Tokens are unique and permanent identifiers that are + * used to reference HDF5 objects in a container. */ + +/* The maximum size allowed for tokens */ +#define H5O_MAX_TOKEN_SIZE (16) /* Allows for 128-bit tokens */ + +/* Type for object tokens */ +/* (Hoisted here, since it's used by both the H5Lpublic.h and H5Opublic.h headers) */ +typedef struct H5O_token_t { + uint8_t __data[H5O_MAX_TOKEN_SIZE]; +} H5O_token_t; + /* Functions in H5.c */ H5_DLL herr_t H5open(void); H5_DLL herr_t H5close(void); diff --git a/src/H5system.c b/src/H5system.c index 4b5e290..9310243 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -90,6 +90,8 @@ static hbool_t H5_ntzset = FALSE; * * The conversion 't' refers to an htri_t type. * + * The conversion 'k' refers to an H5O_token_t type. + * * Return: Success: Number of characters printed * * Failure: -1 @@ -416,6 +418,32 @@ HDfprintf(FILE *stream, const char *fmt, ...) } break; + case 'k': + { + H5O_token_t token = HDva_arg(ap, H5O_token_t); + + /* Print the raw token. */ + n = fprintf(stream, "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + (unsigned char)token.__data[15], + (unsigned char)token.__data[14], + (unsigned char)token.__data[13], + (unsigned char)token.__data[12], + (unsigned char)token.__data[11], + (unsigned char)token.__data[10], + (unsigned char)token.__data[9], + (unsigned char)token.__data[8], + (unsigned char)token.__data[7], + (unsigned char)token.__data[6], + (unsigned char)token.__data[5], + (unsigned char)token.__data[4], + (unsigned char)token.__data[3], + (unsigned char)token.__data[2], + (unsigned char)token.__data[1], + (unsigned char)token.__data[0] + ); + } + break; + default: HDfputs(format_templ, stream); n = (int)HDstrlen(format_templ); diff --git a/src/H5trace.c b/src/H5trace.c index 83f0ac7..ec5c6a2 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -155,7 +155,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end if */ /* Get time for event */ - if(H5_DBL_ABS_EQUAL(first_time.etime, H5_DOUBLE(0.0))) + if(H5_DBL_ABS_EQUAL(first_time.etime, 0.0)) H5_timer_begin(&first_time); if(H5_debug_g.ttimes) H5_timer_begin(&event_time); @@ -1630,6 +1630,22 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end switch */ break; + case 'k': + if(ptr) { + if(vp) + HDfprintf(out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5O_token_t token = HDva_arg(ap, H5O_token_t); + int j; + + for (j = 0; j < H5O_MAX_TOKEN_SIZE; j++) + HDfprintf(out, "%02x", token.__data[j]); + } /* end else */ + break; + case 'L': switch(type[1]) { case 'l': @@ -3069,6 +3085,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5VL_OBJECT_GET_TYPE: HDfprintf(out, "H5VL_OBJECT_GET_TYPE"); break; + case H5VL_OBJECT_GET_INFO: + HDfprintf(out, "H5VL_OBJECT_GET_INFO"); + break; default: HDfprintf(out, "%ld", (long)get); break; @@ -3209,6 +3228,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5VL_SUBCLS_BLOB: HDfprintf(out, "H5VL_SUBCLS_BLOB"); break; + case H5VL_SUBCLS_TOKEN: + HDfprintf(out, "H5VL_SUBCLS_TOKEN"); + break; default: HDfprintf(out, "%ld", (long)subclass); break; @@ -3442,9 +3464,6 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5VL_NATIVE_OBJECT_GET_COMMENT: HDfprintf(out, "H5VL_NATIVE_OBJECT_GET_COMMENT"); break; - case H5VL_NATIVE_OBJECT_GET_INFO: - HDfprintf(out, "H5VL_NATIVE_OBJECT_GET_INFO"); - break; case H5VL_NATIVE_OBJECT_SET_COMMENT: HDfprintf(out, "H5VL_NATIVE_OBJECT_SET_COMMENT"); break; @@ -3457,6 +3476,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED: HDfprintf(out, "H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED"); break; + case H5VL_NATIVE_OBJECT_GET_NATIVE_INFO: + HDfprintf(out, "H5VL_NATIVE_OBJECT_GET_NATIVE_INFO"); + break; default: HDfprintf(out, "%ld", (long)optional); break; diff --git a/src/H5vers.txt b/src/H5vers.txt index 4b2f222..ae1d600 100644 --- a/src/H5vers.txt +++ b/src/H5vers.txt @@ -56,11 +56,26 @@ 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: H5Lget_info; H5L_info; v18, v112 +FUNCTION: H5Lget_info_by_idx; H5L_info; v18, v112 +FUNCTION: H5Literate; H5L_iterate; v18, v112 +FUNCTION: H5Literate_by_name; H5L_iterate; v18, v112 +FUNCTION: H5Lvisit; H5L_iterate; v18, v112 +FUNCTION: H5Lvisit_by_name; H5L_iterate; v18, v112 +# Note: v111 is allowed in make_vers because H5O functions were prematurely +# versioned in HDF5 1.10. Because users were affected by this, the +# versioning was rescinded but the H5O version 2 functions were kept +# to be called directly. Now that the version macros are added in 1.12, +# along with a 3rd version of the H5O functions, the H5O function +# version for default api=v110 should be version 1 to work correctly +# with 1.10 applications that were using unversioned H5O functions, +# and the H5O function version should be version 3 for default api=v112 +# (the default api version for 1.12). +FUNCTION: H5Oget_info; ; v18, v111, v112 +FUNCTION: H5Oget_info_by_name; ; v18, v111, v112 +FUNCTION: H5Oget_info_by_idx; ; v18, v111, v112 +FUNCTION: H5Ovisit; ; v18, v111, v112 +FUNCTION: H5Ovisit_by_name; ; v18, v111, v112 FUNCTION: H5Pencode; ; v110, v112 FUNCTION: H5Pget_filter; ; v10, v18 FUNCTION: H5Pget_filter_by_id; ; v16, v18 @@ -78,5 +93,7 @@ FUNCTION: H5Topen; ; v10, v18 # (although not required, it's easier to compare this file with the headers # generated if the list below is in alphanumeric sort order - QAK) TYPEDEF: H5E_auto; v10, v18 +TYPEDEF: H5O_info; v18, v112 +TYPEDEF: H5O_iterate; v18, v112 TYPEDEF: H5Z_class; v16, v18 diff --git a/src/Makefile.am b/src/Makefile.am index 8a4afbc..0c07c1b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -38,7 +38,8 @@ MOSTLYCLEANFILES=H5Tinit.c H5lib_settings.c DISTCLEANFILES=H5pubconf.h # library sources -libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ +libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \ + H5timer.c H5trace.c \ H5A.c H5Abtree2.c H5Adense.c H5Adeprec.c H5Aint.c H5Atest.c \ H5AC.c H5ACdbg.c H5ACproxy_entry.c \ H5B.c H5Bcache.c H5Bdbg.c \ @@ -48,59 +49,49 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Cprefetched.c H5Cquery.c H5Ctag.c H5Ctest.c \ H5CS.c \ H5CX.c \ - H5D.c H5Dbtree.c H5Dbtree2.c H5Dchunk.c H5Dcompact.c H5Dcontig.c H5Ddbg.c \ - H5Ddeprec.c H5Dearray.c H5Defl.c H5Dfarray.c H5Dfill.c H5Dint.c \ - H5Dio.c H5Dlayout.c H5Dnone.c \ - H5Doh.c H5Dscatgath.c H5Dselect.c \ - H5Dsingle.c H5Dtest.c H5Dvirtual.c \ + H5D.c H5Dbtree.c H5Dbtree2.c H5Dchunk.c H5Dcompact.c H5Dcontig.c \ + H5Ddbg.c H5Ddeprec.c H5Dearray.c H5Defl.c H5Dfarray.c H5Dfill.c \ + H5Dint.c H5Dio.c H5Dlayout.c H5Dnone.c H5Doh.c H5Dscatgath.c \ + H5Dselect.c H5Dsingle.c H5Dtest.c H5Dvirtual.c \ H5E.c H5Edeprec.c H5Eint.c \ H5EA.c H5EAcache.c H5EAdbg.c H5EAdblkpage.c H5EAdblock.c H5EAhdr.c \ H5EAiblock.c H5EAint.c H5EAsblock.c H5EAstat.c H5EAtest.c \ - H5F.c H5Faccum.c H5Fcwfs.c \ - H5Fdbg.c H5Fdeprec.c H5Fefc.c H5Ffake.c H5Fint.c H5Fio.c \ - H5Fmount.c H5Fquery.c \ - H5Fsfile.c H5Fspace.c H5Fsuper.c H5Fsuper_cache.c H5Ftest.c \ + H5F.c H5Faccum.c H5Fcwfs.c H5Fdbg.c H5Fdeprec.c H5Fefc.c H5Ffake.c \ + H5Fint.c H5Fio.c H5Fmount.c H5Fquery.c H5Fsfile.c H5Fspace.c \ + H5Fsuper.c H5Fsuper_cache.c H5Ftest.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAint.c H5FAstat.c H5FAtest.c \ H5FD.c H5FDcore.c H5FDfamily.c H5FDhdfs.c H5FDint.c H5FDlog.c \ H5FDmulti.c H5FDsec2.c H5FDspace.c H5FDstdio.c H5FDtest.c \ H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSint.c H5FSsection.c \ H5FSstat.c H5FStest.c \ - H5G.c H5Gbtree2.c H5Gcache.c \ - H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c \ - H5Gint.c H5Glink.c \ - H5Gloc.c H5Gname.c H5Gnode.c H5Gobj.c H5Goh.c H5Groot.c H5Gstab.c H5Gtest.c \ - H5Gtraverse.c \ + H5G.c H5Gbtree2.c H5Gcache.c H5Gcompact.c H5Gdense.c H5Gdeprec.c \ + H5Gent.c H5Gint.c H5Glink.c H5Gloc.c H5Gname.c H5Gnode.c H5Gobj.c \ + H5Goh.c H5Groot.c H5Gstab.c H5Gtest.c H5Gtraverse.c \ H5HF.c H5HFbtree2.c H5HFcache.c H5HFdbg.c H5HFdblock.c H5HFdtable.c \ H5HFhdr.c H5HFhuge.c H5HFiblock.c H5HFiter.c H5HFman.c H5HFsection.c \ H5HFspace.c H5HFstat.c H5HFtest.c H5HFtiny.c \ H5HG.c H5HGcache.c H5HGdbg.c H5HGquery.c \ - H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c H5HLprfx.c H5HLdblk.c\ - H5HP.c H5I.c H5Itest.c H5L.c H5Lexternal.c H5lib_settings.c \ + H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c H5HLprfx.c H5HLdblk.c \ + H5HP.c \ + H5I.c H5Itest.c \ + H5L.c H5Ldeprec.c H5Lexternal.c \ H5M.c \ H5MF.c H5MFaggr.c H5MFdbg.c H5MFsection.c \ H5MM.c H5MP.c H5MPtest.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 H5Ocopy_ref.c H5Odbg.c H5Odrvinfo.c H5Odtype.c H5Oefl.c \ - H5Ofill.c H5Oflush.c H5Ofsinfo.c H5Oginfo.c \ - H5Oint.c H5Olayout.c \ - H5Olinfo.c H5Olink.c H5Omessage.c H5Omtime.c \ - H5Oname.c H5Onull.c H5Opline.c H5Orefcount.c \ - H5Osdspace.c H5Oshared.c \ - H5Oshmesg.c \ - H5Ostab.c \ - H5Otest.c H5Ounknown.c \ - H5P.c H5Pacpl.c H5Pdapl.c H5Pdcpl.c \ - H5Pdeprec.c H5Pdxpl.c H5Pencdec.c \ - H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \ - H5Pgcpl.c H5Pint.c H5Plapl.c H5Plcpl.c \ - H5Pmapl.c H5Pmcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c \ - H5Ptest.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 H5Ocopy_ref.c H5Odbg.c H5Odrvinfo.c H5Odtype.c \ + H5Oefl.c H5Ofill.c H5Oflush.c H5Ofsinfo.c H5Oginfo.c H5Oint.c \ + H5Olayout.c H5Olinfo.c H5Olink.c H5Omessage.c H5Omtime.c H5Oname.c \ + H5Onull.c H5Opline.c H5Orefcount.c H5Osdspace.c H5Oshared.c \ + H5Oshmesg.c H5Ostab.c H5Otest.c H5Ounknown.c \ + H5P.c H5Pacpl.c H5Pdapl.c H5Pdcpl.c H5Pdeprec.c H5Pdxpl.c H5Pencdec.c \ + H5Pfapl.c H5Pfcpl.c H5Pfmpl.c H5Pgcpl.c H5Pint.c H5Plapl.c H5Plcpl.c \ + H5Pmapl.c H5Pmcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \ H5PB.c \ H5PL.c H5PLint.c H5PLpath.c H5PLplugin_cache.c \ - H5R.c H5Rint.c H5Rdeprec.c \ + H5R.c H5Rdeprec.c H5Rint.c \ H5UC.c \ H5RS.c \ H5S.c H5Sall.c H5Sdbg.c H5Sdeprec.c H5Shyper.c H5Snone.c H5Spoint.c \ @@ -109,21 +100,20 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5SM.c H5SMbtree2.c H5SMcache.c H5SMmessage.c H5SMtest.c \ H5ST.c \ H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c H5Tcompound.c H5Tconv.c \ - H5Tcset.c H5Tdbg.c H5Tdeprec.c H5Tenum.c H5Tfields.c \ - H5Tfixed.c \ - H5Tfloat.c H5Tinit.c H5Tnative.c H5Toffset.c H5Toh.c \ - H5Topaque.c \ - H5Torder.c \ - H5Tref.c \ - H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvisit.c H5Tvlen.c H5TS.c \ + H5Tcset.c H5Tdbg.c H5Tdeprec.c H5Tenum.c H5Tfields.c H5Tfixed.c \ + H5Tfloat.c H5Tinit.c H5Tnative.c H5Toffset.c H5Toh.c H5Topaque.c \ + H5Torder.c H5Tref.c H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvisit.c \ + H5Tvlen.c \ + H5TS.c \ H5VL.c H5VLcallback.c H5VLint.c H5VLnative.c \ H5VLnative_attr.c H5VLnative_blob.c H5VLnative_dataset.c \ H5VLnative_datatype.c H5VLnative_file.c H5VLnative_group.c \ H5VLnative_link.c H5VLnative_introspect.c H5VLnative_object.c \ + H5VLnative_token.c \ H5VLpassthru.c \ H5VM.c H5WB.c H5Z.c \ - H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c \ - H5Zscaleoffset.c H5Zszip.c H5Ztrans.c + H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c H5Zscaleoffset.c \ + H5Zszip.c H5Ztrans.c # Only compile parallel sources if necessary if BUILD_PARALLEL_CONDITIONAL |