diff options
author | Chris Hogan <chogan@hdfgroup.org> | 2019-11-14 21:56:15 (GMT) |
---|---|---|
committer | Chris Hogan <chogan@hdfgroup.org> | 2019-11-14 21:56:15 (GMT) |
commit | a7b35b8584e547d72ff4c215a0295fa9f1241082 (patch) | |
tree | 476d11725a759b7dae3f9e461875ff291a4cf83a | |
parent | 07ff0a842a41f4e6a257d9e957e5fbc5628d996e (diff) | |
download | hdf5-a7b35b8584e547d72ff4c215a0295fa9f1241082.zip hdf5-a7b35b8584e547d72ff4c215a0295fa9f1241082.tar.gz hdf5-a7b35b8584e547d72ff4c215a0295fa9f1241082.tar.bz2 |
Add object header flags to API context
Add missing DCPL to API context state
Replace a couple LCPL H5P_get calls with H5CX_get_*
-rw-r--r-- | src/H5CX.c | 51 | ||||
-rw-r--r-- | src/H5CXprivate.h | 2 | ||||
-rw-r--r-- | src/H5L.c | 10 | ||||
-rw-r--r-- | src/H5Oint.c | 14 |
4 files changed, 72 insertions, 5 deletions
@@ -285,7 +285,6 @@ typedef struct H5CX_t { /* Cached LCPL properties */ H5T_cset_t encoding; /* Link name character encoding */ hbool_t encoding_valid; /* Whether link name character encoding is valid */ - unsigned intermediate_group; /* Whether to create intermediate groups */ hbool_t intermediate_group_valid; /* Whether create intermediate group flag is valid */ @@ -296,6 +295,8 @@ typedef struct H5CX_t { /* Cached DCPL properties */ hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ + uint8_t ohdr_flags; /* Object header flags */ + hbool_t ohdr_flags_valid; /* Whether the object headers flags are valid */ /* Cached DAPL properties */ const char *extfile_prefix; /* Prefix for external file */ @@ -374,6 +375,7 @@ typedef struct H5CX_lapl_cache_t { /* (Same as the cached DXPL struct, above, except for the default DCPL) */ typedef struct H5CX_dcpl_cache_t { hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ + uint8_t ohdr_flags; /* Object header flags */ } H5CX_dcpl_cache_t; /* Typedef for cached default dataset access property list information */ @@ -591,6 +593,10 @@ H5CX__init_package(void) if(H5P_get(dc_plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &H5CX_def_dcpl_cache.do_min_dset_ohdr) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") + /* Get object header flags */ + if(H5P_get(dc_plist, H5O_CRT_OHDR_FLAGS_NAME, &H5CX_def_dcpl_cache.ohdr_flags) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve object header flags") + /* Reset the "default DAPL cache" information */ HDmemset(&H5CX_def_dapl_cache, 0, sizeof(H5CX_dapl_cache_t)); @@ -860,6 +866,18 @@ H5CX_retrieve_state(H5CX_state_t **api_state) if(NULL == (*api_state = H5FL_CALLOC(H5CX_state_t))) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTALLOC, FAIL, "unable to allocate new API context state") + /* Check for non-default DCPL */ + if(H5P_DATASET_CREATE_DEFAULT != (*head)->ctx.dcpl_id) { + /* Retrieve the DCPL property list */ + H5CX_RETRIEVE_PLIST(dcpl, FAIL) + + /* Copy the DCPL ID */ + if(((*api_state)->dcpl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.dcpl, FALSE)) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "can't copy property list") + } /* end if */ + else + (*api_state)->dcpl_id = H5P_DATASET_CREATE_DEFAULT; + /* Check for non-default DXPL */ if(H5P_DATASET_XFER_DEFAULT != (*head)->ctx.dxpl_id) { /* Retrieve the DXPL property list */ @@ -968,6 +986,10 @@ H5CX_restore_state(const H5CX_state_t *api_state) HDassert(head && *head); HDassert(api_state); + /* Restore the DCPL info */ + (*head)->ctx.dcpl_id = api_state->dcpl_id; + (*head)->ctx.dcpl = NULL; + /* Restore the DXPL info */ (*head)->ctx.dxpl_id = api_state->dxpl_id; (*head)->ctx.dxpl = NULL; @@ -1020,6 +1042,11 @@ H5CX_free_state(H5CX_state_t *api_state) /* Sanity check */ HDassert(api_state); + /* Release the DCPL */ + if(api_state->dcpl_id != H5P_DATASET_CREATE_DEFAULT) + if(H5I_dec_ref(api_state->dcpl_id) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on DCPL") + /* Release the DXPL */ if(api_state->dxpl_id != H5P_DATASET_XFER_DEFAULT) if(H5I_dec_ref(api_state->dxpl_id) < 0) @@ -3442,6 +3469,28 @@ done: #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ #endif /* H5_HAVE_PARALLEL */ +herr_t +H5CX_get_ohdr_flags(uint8_t *ohdr_flags) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(ohdr_flags); + HDassert(head && *head); + HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); + + H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5O_CRT_OHDR_FLAGS_NAME, ohdr_flags) + + /* Get the value */ + *ohdr_flags = (*head)->ctx.ohdr_flags; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* End H5CX_get_ohdr_flags() */ + /*------------------------------------------------------------------------- * Function: H5CX__pop_common diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index e3e9780..2ae71f3 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -41,6 +41,7 @@ /* API context state */ typedef struct H5CX_state_t { + hid_t dcpl_id; /* DCPL for operation */ hid_t dxpl_id; /* DXPL for operation */ hid_t lapl_id; /* LAPL for operation */ hid_t lcpl_id; /* LCPL for operation */ @@ -133,6 +134,7 @@ H5_DLL herr_t H5CX_get_nlinks(size_t *nlinks); /* "Getter" routines for DCPL properties cached in API context */ H5_DLL herr_t H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag); +H5_DLL herr_t H5CX_get_ohdr_flags(uint8_t *ohdr_flags); /* "Getter" routines for DAPL properties cached in API context */ H5_DLL herr_t H5CX_get_ext_file_prefix(const char **prefix_extfile); @@ -299,6 +299,9 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, if(H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Set the LCPL for the API context */ + H5CX_set_lcpl(lcpl_id); + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < 0) @@ -386,6 +389,9 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, if(H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Set the LCPL for the API context */ + H5CX_set_lcpl(lcpl_id); + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < 0) @@ -2890,7 +2896,7 @@ H5L_move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_lo HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get intermediate group creation property */ - if(H5P_get(lc_plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, &crt_intmd_group) < 0) + if(H5CX_get_intermediate_group(&crt_intmd_group) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for creating missing groups") /* Set target flags for source and destination */ @@ -2898,7 +2904,7 @@ H5L_move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_lo dst_target_flags |= H5G_CRT_INTMD_GROUP; /* Get character encoding property */ - if(H5P_get(lc_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &char_encoding) < 0) + if(H5CX_get_encoding(&char_encoding) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for character encoding") } /* end if */ diff --git a/src/H5Oint.c b/src/H5Oint.c index ecf347c..b97ff30 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -352,8 +352,18 @@ H5O__create_ohdr(H5F_t *f, hid_t ocpl_id) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, NULL, "not a property list") /* Get any object header status flags set by properties */ - if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get object header flags") + if(H5P_DATASET_CREATE_DEFAULT == ocpl_id) + { + /* If the OCPL is the default DCPL, we can get the header flags from the + * API context. Otherwise we have to call H5P_get */ + if(H5CX_get_ohdr_flags(&oh_flags) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get object header flags") + } + else + { + if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get object header flags") + } if(H5O_set_version(f, oh, oh_flags, H5F_STORE_MSG_CRT_IDX(f)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, NULL, "can't set version of object header") |