diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 6a01a10a58..a92e2ed9be 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -121,6 +121,10 @@ New Features Library: -------- + - The H5VLstart_lib_state / H5VLfinish_lib_state API routines for pass- + through connector authors now require a parameter that can be used to + store the library's context. + - Removed H5FDperform_init API routine. Virtual File Driver (VFD) developers who wish to provide an ID for their driver should create a routine specific to their individual implementation. diff --git a/src/H5.c b/src/H5.c index 8fcc8eeb2b..3da7a43ccf 100644 --- a/src/H5.c +++ b/src/H5.c @@ -304,9 +304,10 @@ H5_term_library(void) size_t at = 0; char loop[1024]; H5E_auto2_t func; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ /* Acquire the API lock */ - H5CANCEL_DECL + FUNC_ENTER_API_VARS H5_API_LOCK /* Don't do anything if the library is already closed */ @@ -317,7 +318,7 @@ H5_term_library(void) H5_TERM_GLOBAL = true; /* Push the API context without checking for errors */ - H5CX_push_special(); + H5CX_push(&api_ctx); /* Check if we should display error output */ (void)H5Eget_auto2(H5E_DEFAULT, &func, NULL); diff --git a/src/H5Atest.c b/src/H5Atest.c index 5961ba7366..0cdb75d2cb 100644 --- a/src/H5Atest.c +++ b/src/H5Atest.c @@ -105,9 +105,10 @@ done: herr_t H5A__get_shared_rc_test(hid_t attr_id, hsize_t *ref_count) { - H5A_t *attr; /* Attribute object for ID */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_t *attr; /* Attribute object for ID */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -116,7 +117,7 @@ H5A__get_shared_rc_test(hid_t attr_id, hsize_t *ref_count) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute"); /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; diff --git a/src/H5CX.c b/src/H5CX.c index c2a25e8d7a..78892aacbd 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -60,41 +60,43 @@ /* Check if the property list is already available */ \ if (NULL == (*head)->ctx.PL) \ /* Get the property list pointer */ \ - if (NULL == ((*head)->ctx.PL = (H5P_genplist_t *)H5I_object((*head)->ctx.H5_GLUE(PL, _id)))) \ + if (H5_UNLIKELY(NULL == \ + ((*head)->ctx.PL = (H5P_genplist_t *)H5I_object((*head)->ctx.H5_GLUE(PL, _id))))) \ HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, (FAILVAL), "can't get property list"); /* Common macro for the duplicated code to retrieve properties from a property list */ #define H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ - /* Check for default property list */ \ - if ((*head)->ctx.H5_GLUE(PL, _id) == (DEF_PL)) \ - H5MM_memcpy(&(*head)->ctx.PROP_FIELD, &H5_GLUE3(H5CX_def_, PL, _cache).PROP_FIELD, \ - sizeof(H5_GLUE3(H5CX_def_, PL, _cache).PROP_FIELD)); \ - else { \ - /* Retrieve the property list */ \ - H5CX_RETRIEVE_PLIST(PL, FAIL) \ + { \ \ - /* Get the property */ \ - if (H5P_get((*head)->ctx.PL, (PROP_NAME), &(*head)->ctx.PROP_FIELD) < 0) \ - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't retrieve value from API context"); \ - } /* end else */ \ + /* Check for default property list */ \ + if ((*head)->ctx.H5_GLUE(PL, _id) == (DEF_PL)) \ + H5MM_memcpy(&(*head)->ctx.PROP_FIELD, &H5_GLUE3(H5CX_def_, PL, _cache).PROP_FIELD, \ + sizeof(H5_GLUE3(H5CX_def_, PL, _cache).PROP_FIELD)); \ + else { \ + /* Retrieve the property list */ \ + H5CX_RETRIEVE_PLIST(PL, FAIL) \ \ - /* Mark the field as valid */ \ - (*head)->ctx.H5_GLUE(PROP_FIELD, _valid) = true; + /* Get the property */ \ + if (H5_UNLIKELY(H5P_get((*head)->ctx.PL, (PROP_NAME), &(*head)->ctx.PROP_FIELD) < 0)) \ + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't retrieve value from API context"); \ + } /* end else */ \ + \ + /* Mark the field as valid */ \ + (*head)->ctx.H5_GLUE(PROP_FIELD, _valid) = true; \ + } /* Macro for the duplicated code to retrieve a value from a plist if the context value is invalid */ #define H5CX_RETRIEVE_PROP_VALID(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ /* Check if the value has been retrieved already */ \ - if (!(*head)->ctx.H5_GLUE(PROP_FIELD, _valid)) { \ - H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ - } /* end if */ + if (!(*head)->ctx.H5_GLUE(PROP_FIELD, _valid)) \ + H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) /* Macro for the duplicated code to retrieve a value from a plist if the context value is invalid, or the * library has previously modified the context value for return */ #define H5CX_RETRIEVE_PROP_VALID_SET(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ /* Check if the value has been retrieved already */ \ - if (!((*head)->ctx.H5_GLUE(PROP_FIELD, _valid) || (*head)->ctx.H5_GLUE(PROP_FIELD, _set))) { \ - H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ - } /* end if */ + if (!((*head)->ctx.H5_GLUE(PROP_FIELD, _valid) || (*head)->ctx.H5_GLUE(PROP_FIELD, _set))) \ + H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) #if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_INSTRUMENTED_LIBRARY) /* Macro for the duplicated code to set a context field that may not exist as a property */ @@ -107,7 +109,7 @@ /* Retrieve the dataset transfer property list */ \ H5CX_RETRIEVE_PLIST(dxpl, FAIL) \ \ - if ((check_prop = H5P_exist_plist((*head)->ctx.dxpl, PROP_NAME)) < 0) \ + if (H5_UNLIKELY((check_prop = H5P_exist_plist((*head)->ctx.dxpl, PROP_NAME)) < 0)) \ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "error checking for property"); \ } /* end if */ \ \ @@ -124,247 +126,17 @@ #define H5CX_SET_PROP(PROP_NAME, PROP_FIELD) \ if ((*head)->ctx.H5_GLUE(PROP_FIELD, _set)) { \ /* Retrieve the dataset transfer property list */ \ - H5CX_RETRIEVE_PLIST(dxpl, NULL) \ + H5CX_RETRIEVE_PLIST(dxpl, FAIL) \ \ /* Set the property */ \ - if (H5P_set((*head)->ctx.dxpl, PROP_NAME, &(*head)->ctx.PROP_FIELD) < 0) \ - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTSET, NULL, "error setting data xfer property"); \ + if (H5_UNLIKELY(H5P_set((*head)->ctx.dxpl, PROP_NAME, &(*head)->ctx.PROP_FIELD) < 0)) \ + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTSET, FAIL, "error setting data xfer property"); \ } /* end if */ /******************/ /* Local Typedefs */ /******************/ -/* Typedef for context about each API call, as it proceeds */ -/* Fields in this struct are of several types: - * - The DXPL & LAPL ID are either library default ones (from the API context - * initialization) or passed in from the application via an API call - * parameter. The corresponding H5P_genplist_t* is just the underlying - * property list struct for the ID, to optimize retrieving properties - * from the list multiple times. - * - * - Internal fields, used and set only within the library, for managing the - * operation under way. These do not correspond to properties in the - * DXPL or LAPL and can have any name. - * - * - Cached fields, which are not returned to the application, for managing - * the operation under way. These correspond to properties in the DXPL - * or LAPL, and are retrieved either from the (global) cache for a - * default property list, or from the corresponding property in the - * application's (non-default) property list. Getting / setting these - * properties within the library does _not_ affect the application's - * property list. Note that the naming of these fields, and - * _valid, is important for the H5CX_RETRIEVE_PROP_VALID - * macro to work properly. - * - * - "Return-only" properties that are returned to the application, mainly - * for sending out "introspection" information ("Why did collective I/O - * get broken for this operation?", "Which filters are set on the chunk I - * just directly read in?", etc) Setting these fields will cause the - * corresponding property in the property list to be set when the API - * context is popped, when returning from the API routine. Note that the - * naming of these fields, and _set, is important for the - * H5CX_TEST_SET_PROP and H5CX_SET_PROP macros to work properly. - * - * - "Return-and-read" properties that are returned to the application to send out introspection information, - * but are also queried by the library internally. If the context value has been 'set' by an accessor, - * all future queries will return the stored value from the context, to avoid later queries overwriting - * that stored value with the value from the property list. - * - * These properties have both a 'valid' and 'set' flag. _valid is true if the field has ever been - * populated from its underlying property list. _set flag is true if this field has ever been set on - * the context for application introspection. The naming of these fields is important for the - * H5CX_RETRIEVE_PROP_VALID_SET macro to work properly. - * - * If a field has been set on the context but never read internally, _valid will be false - * despite the context containing a meaningful cached value. - */ -typedef struct H5CX_t { - /* DXPL */ - hid_t dxpl_id; /* DXPL ID for API operation */ - H5P_genplist_t *dxpl; /* Dataset Transfer Property List */ - - /* LCPL */ - hid_t lcpl_id; /* LCPL ID for API operation */ - H5P_genplist_t *lcpl; /* Link Creation Property List */ - - /* LAPL */ - hid_t lapl_id; /* LAPL ID for API operation */ - H5P_genplist_t *lapl; /* Link Access Property List */ - - /* DCPL */ - hid_t dcpl_id; /* DCPL ID for API operation */ - H5P_genplist_t *dcpl; /* Dataset Creation Property List */ - - /* DAPL */ - hid_t dapl_id; /* DAPL ID for API operation */ - H5P_genplist_t *dapl; /* Dataset Access Property List */ - - /* FAPL */ - hid_t fapl_id; /* FAPL ID for API operation */ - H5P_genplist_t *fapl; /* File Access Property List */ - - /* Internal: Object tagging info */ - haddr_t tag; /* Current object's tag (ohdr chunk #0 address) */ - - /* Internal: Metadata cache info */ - H5AC_ring_t ring; /* Current metadata cache ring for entries */ - -#ifdef H5_HAVE_PARALLEL - /* Internal: Parallel I/O settings */ - bool coll_metadata_read; /* Whether to use collective I/O for metadata read */ - MPI_Datatype btype; /* MPI datatype for buffer, when using collective I/O */ - MPI_Datatype ftype; /* MPI datatype for file, when using collective I/O */ - bool mpi_file_flushing; /* Whether an MPI-opened file is being flushed */ - bool rank0_bcast; /* Whether a dataset meets read-with-rank0-and-bcast requirements */ -#endif /* H5_HAVE_PARALLEL */ - - /* Cached DXPL properties */ - size_t max_temp_buf; /* Maximum temporary buffer size (H5D_XFER_MAX_TEMP_BUF_NAME) .*/ - bool max_temp_buf_valid; /* Whether maximum temporary buffer size is valid */ - void *tconv_buf; /* Temporary conversion buffer (H5D_XFER_TCONV_BUF_NAME) */ - bool tconv_buf_valid; /* Whether temporary conversion buffer is valid */ - void *bkgr_buf; /* Background conversion buffer (H5D_XFER_BKGR_BUF_NAME) */ - bool bkgr_buf_valid; /* Whether background conversion buffer is valid */ - H5T_bkg_t bkgr_buf_type; /* Background buffer type (H5D_XFER_BKGR_BUF_TYPE_NAME) */ - bool bkgr_buf_type_valid; /* Whether background buffer type is valid */ - double btree_split_ratio[3]; /* B-tree split ratios (H5D_XFER_BTREE_SPLIT_RATIO_NAME) */ - bool btree_split_ratio_valid; /* Whether B-tree split ratios are valid */ - size_t vec_size; /* Size of hyperslab vector (H5D_XFER_HYPER_VECTOR_SIZE_NAME) */ - bool vec_size_valid; /* Whether hyperslab vector is valid */ -#ifdef H5_HAVE_PARALLEL - H5FD_mpio_xfer_t io_xfer_mode; /* Parallel transfer mode for this request (H5D_XFER_IO_XFER_MODE_NAME) */ - bool io_xfer_mode_valid; /* Whether parallel transfer mode is valid */ - H5FD_mpio_collective_opt_t mpio_coll_opt; /* Parallel transfer with independent IO or collective IO with - this mode (H5D_XFER_MPIO_COLLECTIVE_OPT_NAME) */ - bool mpio_coll_opt_valid; /* Whether parallel transfer option is valid */ - H5FD_mpio_chunk_opt_t - mpio_chunk_opt_mode; /* Collective chunk option (H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME) */ - bool mpio_chunk_opt_mode_valid; /* Whether collective chunk option is valid */ - unsigned mpio_chunk_opt_num; /* Collective chunk threshold (H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME) */ - bool mpio_chunk_opt_num_valid; /* Whether collective chunk threshold is valid */ - unsigned mpio_chunk_opt_ratio; /* Collective chunk ratio (H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME) */ - bool mpio_chunk_opt_ratio_valid; /* Whether collective chunk ratio is valid */ -#endif /* H5_HAVE_PARALLEL */ - H5Z_EDC_t err_detect; /* Error detection info (H5D_XFER_EDC_NAME) */ - bool err_detect_valid; /* Whether error detection info is valid */ - H5Z_cb_t filter_cb; /* Filter callback function (H5D_XFER_FILTER_CB_NAME) */ - bool filter_cb_valid; /* Whether filter callback function is valid */ - H5Z_data_xform_t *data_transform; /* Data transform info (H5D_XFER_XFORM_NAME) */ - bool data_transform_valid; /* Whether data transform info is valid */ - H5T_vlen_alloc_info_t vl_alloc_info; /* VL datatype alloc info (H5D_XFER_VLEN_*_NAME) */ - bool vl_alloc_info_valid; /* Whether VL datatype alloc info is valid */ - H5T_conv_cb_t dt_conv_cb; /* Datatype conversion struct (H5D_XFER_CONV_CB_NAME) */ - bool dt_conv_cb_valid; /* Whether datatype conversion struct is valid */ - H5D_selection_io_mode_t selection_io_mode; /* Selection I/O mode (H5D_XFER_SELECTION_IO_MODE_NAME) */ - bool selection_io_mode_valid; /* Whether selection I/O mode is valid */ - bool modify_write_buf; /* Whether the library can modify write buffers (H5D_XFER_MODIFY_WRITE_BUF_NAME)*/ - bool modify_write_buf_valid; /* Whether the modify_write_buf field is valid */ - - /* Return-only DXPL properties to return to application */ -#ifdef H5_HAVE_PARALLEL - H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chunk_opt; /* Chunk optimization mode used for parallel I/O - (H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME) */ - bool mpio_actual_chunk_opt_set; /* Whether chunk optimization mode used for parallel I/O is set */ - H5D_mpio_actual_io_mode_t - mpio_actual_io_mode; /* Actual I/O mode used for parallel I/O (H5D_MPIO_ACTUAL_IO_MODE_NAME) */ - bool mpio_actual_io_mode_set; /* Whether actual I/O mode used for parallel I/O is set */ - uint32_t mpio_local_no_coll_cause; /* Local reason for breaking collective I/O - (H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME) */ - bool mpio_local_no_coll_cause_set; /* Whether local reason for breaking collective I/O is set */ - bool mpio_local_no_coll_cause_valid; /* Whether local reason for breaking collective I/O is valid */ - uint32_t mpio_global_no_coll_cause; /* Global reason for breaking collective I/O - (H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME) */ - bool mpio_global_no_coll_cause_set; /* Whether global reason for breaking collective I/O is set */ - bool mpio_global_no_coll_cause_valid; /* Whether global reason for breaking collective I/O is valid */ -#ifdef H5_HAVE_INSTRUMENTED_LIBRARY - int mpio_coll_chunk_link_hard; /* Instrumented "collective chunk link hard" value - (H5D_XFER_COLL_CHUNK_LINK_HARD_NAME) */ - bool mpio_coll_chunk_link_hard_set; /* Whether instrumented "collective chunk link hard" value is set */ - int mpio_coll_chunk_multi_hard; /* Instrumented "collective chunk multi hard" value - (H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME) */ - bool mpio_coll_chunk_multi_hard_set; /* Whether instrumented "collective chunk multi hard" value is set */ - int mpio_coll_chunk_link_num_true; /* Instrumented "collective chunk link num true" value - (H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME) */ - bool mpio_coll_chunk_link_num_true_set; /* Whether instrumented "collective chunk link num true" value - is set */ - int mpio_coll_chunk_link_num_false; /* Instrumented "collective chunk link num false" value - (H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME) */ - bool mpio_coll_chunk_link_num_false_set; /* Whether instrumented "collective chunk link num false" - value is set */ - int mpio_coll_chunk_multi_ratio_coll; /* Instrumented "collective chunk multi ratio coll" value - (H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME) */ - bool mpio_coll_chunk_multi_ratio_coll_set; /* Whether instrumented "collective chunk multi ratio coll" - value is set */ - int mpio_coll_chunk_multi_ratio_ind; /* Instrumented "collective chunk multi ratio ind" value - (H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME) */ - bool mpio_coll_chunk_multi_ratio_ind_set; /* Whether instrumented "collective chunk multi ratio ind" - value is set */ - bool mpio_coll_rank0_bcast; /* Instrumented "collective rank 0 broadcast" value - (H5D_XFER_COLL_RANK0_BCAST_NAME) */ - bool mpio_coll_rank0_bcast_set; /* Whether instrumented "collective rank 0 broadcast" value is set */ -#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ -#endif /* H5_HAVE_PARALLEL */ - uint32_t no_selection_io_cause; /* Reason for not performing selection I/O - (H5D_XFER_NO_SELECTION_IO_CAUSE_NAME) */ - bool no_selection_io_cause_set; /* Whether reason for not performing selection I/O is set */ - bool no_selection_io_cause_valid; /* Whether reason for not performing selection I/O is valid */ - - uint32_t actual_selection_io_mode; /* Actual selection I/O mode used - (H5D_XFER_ACTUAL_SELECTION_IO_MODE_NAME) */ - bool actual_selection_io_mode_set; /* Whether actual selection I/O mode is set */ - bool actual_selection_io_mode_valid; /* Whether actual selection I/O mode is valid */ - - /* Cached LCPL properties */ - H5T_cset_t encoding; /* Link name character encoding (H5P_STRCRT_CHAR_ENCODING_NAME) */ - bool encoding_valid; /* Whether link name character encoding is valid */ - unsigned intermediate_group; /* Whether to create intermediate groups (H5L_CRT_INTERMEDIATE_GROUP_NAME) */ - bool intermediate_group_valid; /* Whether create intermediate group flag is valid */ - - /* Cached LAPL properties */ - size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */ - bool nlinks_valid; /* Whether number of soft / UD links to traverse is valid */ - - /* Cached DCPL properties */ - bool do_min_dset_ohdr; /* Whether to minimize dataset object header (H5D_CRT_MIN_DSET_HDR_SIZE_NAME) */ - bool do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ - uint8_t ohdr_flags; /* Object header flags (H5O_CRT_OHDR_FLAGS_NAME) */ - bool ohdr_flags_valid; /* Whether the object headers flags are valid */ - - /* Cached DAPL properties */ - const char *extfile_prefix; /* Prefix for external file (H5D_ACS_EFILE_PREFIX_NAME) */ - bool extfile_prefix_valid; /* Whether the prefix for external file is valid */ - const char *vds_prefix; /* Prefix for VDS (H5D_ACS_VDS_PREFIX_NAME) */ - bool vds_prefix_valid; /* Whether the prefix for VDS is valid */ - - /* Cached FAPL properties */ - H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() - (H5F_ACS_LIBVER_LOW_BOUND_NAME) */ - bool low_bound_valid; /* Whether low_bound property is valid */ - H5F_libver_t high_bound; /* high_bound property for H5Pset_libver_bounds - (H5F_ACS_LIBVER_HIGH_BOUND_NAME) */ - bool high_bound_valid; /* Whether high_bound property is valid */ - - /* Cached VOL settings */ - H5VL_connector_prop_t vol_connector_prop; /* Property for VOL connector ID & info - This is treated as an independent field with - no relation to the property H5F_ACS_VOL_CONN_NAME stored on the FAPL */ - bool vol_connector_prop_valid; /* Whether property for VOL connector ID & info is valid */ - void *vol_wrap_ctx; /* VOL connector's "wrap context" for creating IDs */ - bool vol_wrap_ctx_valid; /* Whether VOL connector's "wrap context" for creating IDs is valid */ -} H5CX_t; - -/* Typedef for nodes on the API context stack */ -/* Each entry into the library through an API routine invokes H5CX_push() - * in a FUNC_ENTER_API* macro, which pushes an H5CX_node_t on the API - * context [thread-local] stack, after initializing it with default values - * in H5CX__push_common(). - */ -typedef struct H5CX_node_t { - H5CX_t ctx; /* Context for current API call */ - struct H5CX_node_t *next; /* Pointer to previous context, on stack */ -} H5CX_node_t; - /* Typedef for cached default dataset transfer property list information */ /* This is initialized to the values in the default DXPL during package * initialization and then remains constant for the rest of the library's @@ -442,8 +214,6 @@ typedef struct H5CX_fapl_cache_t { /********************/ /* Local Prototypes */ /********************/ -static void H5CX__push_common(H5CX_node_t *cnode); -static H5CX_node_t *H5CX__pop_common(bool update_dxpl_props); /*********************/ /* Package Variables */ @@ -478,9 +248,6 @@ static H5CX_dapl_cache_t H5CX_def_dapl_cache; /* Define a "default" file access property list cache structure to use for default FAPLs */ static H5CX_fapl_cache_t H5CX_def_fapl_cache; -/* Declare a static free list to manage H5CX_node_t structs */ -H5FL_DEFINE_STATIC(H5CX_node_t); - /* Declare a static free list to manage H5CX_state_t structs */ H5FL_DEFINE_STATIC(H5CX_state_t); @@ -711,19 +478,14 @@ H5CX_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR if (H5_PKG_INIT_VAR) { - H5CX_node_t *cnode; /* Context node */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ - /* Pop the top context node from the stack */ - /* (Can't check for errors, as rest of library is shut down) */ - cnode = H5CX__pop_common(false); + /* Get the pointer to the head of the API context, for this thread */ + head = H5CX_get_my_context(); + assert(head); - /* Free the context node */ - /* (Allocated with malloc() in H5CX_push_special() ) */ - free(cnode); - -#ifndef H5_HAVE_THREADSAFE - H5CX_head_g = NULL; -#endif /* H5_HAVE_THREADSAFE */ + /* Reset head of context list */ + *head = NULL; H5_PKG_INIT_VAR = false; } /* end if */ @@ -758,20 +520,21 @@ H5CX_pushed(void) } /*------------------------------------------------------------------------- - * Function: H5CX__push_common + * Function: H5CX_push * - * Purpose: Internal routine to push a context for an API call. + * Purpose: Pushes a context for an API call. * * Return: Non-negative on success / Negative on failure * *------------------------------------------------------------------------- */ -static void -H5CX__push_common(H5CX_node_t *cnode) +herr_t +H5CX_push(H5CX_node_t *cnode) { - H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE_NOERR + FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ assert(cnode); @@ -797,65 +560,10 @@ H5CX__push_common(H5CX_node_t *cnode) cnode->next = *head; *head = cnode; - FUNC_LEAVE_NOAPI_VOID -} /* end H5CX__push_common() */ - -/*------------------------------------------------------------------------- - * Function: H5CX_push - * - * Purpose: Pushes a context for an API call. - * - * Return: Non-negative on success / Negative on failure - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_push(void) -{ - H5CX_node_t *cnode = NULL; /* Context node */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Allocate & clear API context node */ - if (NULL == (cnode = H5FL_CALLOC(H5CX_node_t))) - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTALLOC, FAIL, "unable to allocate new struct"); - - /* Set context info */ - H5CX__push_common(cnode); - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_push() */ -/*------------------------------------------------------------------------- - * Function: H5CX_push_special - * - * Purpose: Pushes a context for an API call, without using library routines. - * - * Note: This should only be called in special circumstances, like H5close. - * - * Return: - * - *------------------------------------------------------------------------- - */ -void -H5CX_push_special(void) -{ - H5CX_node_t *cnode = NULL; /* Context node */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Allocate & clear API context node, without using library API routines */ - cnode = (H5CX_node_t *)calloc(1, sizeof(H5CX_node_t)); - assert(cnode); - - /* Set context info */ - H5CX__push_common(cnode); - - FUNC_LEAVE_NOAPI_VOID -} /* end H5CX_push_special() */ - /*------------------------------------------------------------------------- * Function: H5CX_retrieve_state * @@ -3596,21 +3304,21 @@ done: } /* End H5CX_get_ohdr_flags() */ /*------------------------------------------------------------------------- - * Function: H5CX__pop_common + * Function: H5CX_pop * - * Purpose: Common code for popping the context for an API call. + * Purpose: Pops the context for an API call. * * Return: Non-negative on success / Negative on failure * *------------------------------------------------------------------------- */ -static H5CX_node_t * -H5CX__pop_common(bool update_dxpl_props) +herr_t +H5CX_pop(bool update_dxpl_props) { - H5CX_node_t **head = NULL; /* Pointer to head of API context list */ - H5CX_node_t *ret_value = NULL; /* Return value */ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ @@ -3647,36 +3355,7 @@ H5CX__pop_common(bool update_dxpl_props) } /* end if */ /* Pop the top context node from the stack */ - ret_value = (*head); - (*head) = (*head)->next; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX__pop_common() */ - -/*------------------------------------------------------------------------- - * Function: H5CX_pop - * - * Purpose: Pops the context for an API call. - * - * Return: Non-negative on success / Negative on failure - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_pop(bool update_dxpl_props) -{ - H5CX_node_t *cnode; /* Context node */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Perform common operations and get top context from stack */ - if (NULL == (cnode = H5CX__pop_common(update_dxpl_props))) - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "error getting API context node"); - - /* Free the context node */ - cnode = H5FL_FREE(H5CX_node_t, cnode); + (*head) = (*head)->next; done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index 71935de75a..ad61a1a430 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -22,6 +22,9 @@ #ifdef H5_HAVE_PARALLEL #include "H5FDprivate.h" /* File drivers */ #endif /* H5_HAVE_PARALLEL */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5Tconv.h" /* Datatype conversions */ #include "H5Zprivate.h" /* Data filters */ /**************************/ @@ -47,6 +50,235 @@ typedef struct H5CX_state_t { #endif /* H5_HAVE_PARALLEL */ } H5CX_state_t; +/* Typedef for context about each API call, as it proceeds */ +/* Fields in this struct are of several types: + * - The DXPL & LAPL ID are either library default ones (from the API context + * initialization) or passed in from the application via an API call + * parameter. The corresponding H5P_genplist_t* is just the underlying + * property list struct for the ID, to optimize retrieving properties + * from the list multiple times. + * + * - Internal fields, used and set only within the library, for managing the + * operation under way. These do not correspond to properties in the + * DXPL or LAPL and can have any name. + * + * - Cached fields, which are not returned to the application, for managing + * the operation under way. These correspond to properties in the DXPL + * or LAPL, and are retrieved either from the (global) cache for a + * default property list, or from the corresponding property in the + * application's (non-default) property list. Getting / setting these + * properties within the library does _not_ affect the application's + * property list. Note that the naming of these fields, and + * _valid, is important for the H5CX_RETRIEVE_PROP_VALID + * macro to work properly. + * + * - "Return-only" properties that are returned to the application, mainly + * for sending out "introspection" information ("Why did collective I/O + * get broken for this operation?", "Which filters are set on the chunk I + * just directly read in?", etc) Setting these fields will cause the + * corresponding property in the property list to be set when the API + * context is popped, when returning from the API routine. Note that the + * naming of these fields, and _set, is important for the + * H5CX_TEST_SET_PROP and H5CX_SET_PROP macros to work properly. + * + * - "Return-and-read" properties that are returned to the application to send out introspection information, + * but are also queried by the library internally. If the context value has been 'set' by an accessor, + * all future queries will return the stored value from the context, to avoid later queries overwriting + * that stored value with the value from the property list. + * + * These properties have both a 'valid' and 'set' flag. _valid is true if the field has ever been + * populated from its underlying property list. _set flag is true if this field has ever been set on + * the context for application introspection. The naming of these fields is important for the + * H5CX_RETRIEVE_PROP_VALID_SET macro to work properly. + * + * If a field has been set on the context but never read internally, _valid will be false + * despite the context containing a meaningful cached value. + */ +typedef struct H5CX_t { + /* DXPL */ + hid_t dxpl_id; /* DXPL ID for API operation */ + H5P_genplist_t *dxpl; /* Dataset Transfer Property List */ + + /* LCPL */ + hid_t lcpl_id; /* LCPL ID for API operation */ + H5P_genplist_t *lcpl; /* Link Creation Property List */ + + /* LAPL */ + hid_t lapl_id; /* LAPL ID for API operation */ + H5P_genplist_t *lapl; /* Link Access Property List */ + + /* DCPL */ + hid_t dcpl_id; /* DCPL ID for API operation */ + H5P_genplist_t *dcpl; /* Dataset Creation Property List */ + + /* DAPL */ + hid_t dapl_id; /* DAPL ID for API operation */ + H5P_genplist_t *dapl; /* Dataset Access Property List */ + + /* FAPL */ + hid_t fapl_id; /* FAPL ID for API operation */ + H5P_genplist_t *fapl; /* File Access Property List */ + + /* Internal: Object tagging info */ + haddr_t tag; /* Current object's tag (ohdr chunk #0 address) */ + + /* Internal: Metadata cache info */ + H5AC_ring_t ring; /* Current metadata cache ring for entries */ + +#ifdef H5_HAVE_PARALLEL + /* Internal: Parallel I/O settings */ + bool coll_metadata_read; /* Whether to use collective I/O for metadata read */ + MPI_Datatype btype; /* MPI datatype for buffer, when using collective I/O */ + MPI_Datatype ftype; /* MPI datatype for file, when using collective I/O */ + bool mpi_file_flushing; /* Whether an MPI-opened file is being flushed */ + bool rank0_bcast; /* Whether a dataset meets read-with-rank0-and-bcast requirements */ +#endif /* H5_HAVE_PARALLEL */ + + /* Cached DXPL properties */ + size_t max_temp_buf; /* Maximum temporary buffer size (H5D_XFER_MAX_TEMP_BUF_NAME) .*/ + bool max_temp_buf_valid; /* Whether maximum temporary buffer size is valid */ + void *tconv_buf; /* Temporary conversion buffer (H5D_XFER_TCONV_BUF_NAME) */ + bool tconv_buf_valid; /* Whether temporary conversion buffer is valid */ + void *bkgr_buf; /* Background conversion buffer (H5D_XFER_BKGR_BUF_NAME) */ + bool bkgr_buf_valid; /* Whether background conversion buffer is valid */ + H5T_bkg_t bkgr_buf_type; /* Background buffer type (H5D_XFER_BKGR_BUF_TYPE_NAME) */ + bool bkgr_buf_type_valid; /* Whether background buffer type is valid */ + double btree_split_ratio[3]; /* B-tree split ratios (H5D_XFER_BTREE_SPLIT_RATIO_NAME) */ + bool btree_split_ratio_valid; /* Whether B-tree split ratios are valid */ + size_t vec_size; /* Size of hyperslab vector (H5D_XFER_HYPER_VECTOR_SIZE_NAME) */ + bool vec_size_valid; /* Whether hyperslab vector is valid */ +#ifdef H5_HAVE_PARALLEL + H5FD_mpio_xfer_t io_xfer_mode; /* Parallel transfer mode for this request (H5D_XFER_IO_XFER_MODE_NAME) */ + bool io_xfer_mode_valid; /* Whether parallel transfer mode is valid */ + H5FD_mpio_collective_opt_t mpio_coll_opt; /* Parallel transfer with independent IO or collective IO with + this mode (H5D_XFER_MPIO_COLLECTIVE_OPT_NAME) */ + bool mpio_coll_opt_valid; /* Whether parallel transfer option is valid */ + H5FD_mpio_chunk_opt_t + mpio_chunk_opt_mode; /* Collective chunk option (H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME) */ + bool mpio_chunk_opt_mode_valid; /* Whether collective chunk option is valid */ + unsigned mpio_chunk_opt_num; /* Collective chunk threshold (H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME) */ + bool mpio_chunk_opt_num_valid; /* Whether collective chunk threshold is valid */ + unsigned mpio_chunk_opt_ratio; /* Collective chunk ratio (H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME) */ + bool mpio_chunk_opt_ratio_valid; /* Whether collective chunk ratio is valid */ +#endif /* H5_HAVE_PARALLEL */ + H5Z_EDC_t err_detect; /* Error detection info (H5D_XFER_EDC_NAME) */ + bool err_detect_valid; /* Whether error detection info is valid */ + H5Z_cb_t filter_cb; /* Filter callback function (H5D_XFER_FILTER_CB_NAME) */ + bool filter_cb_valid; /* Whether filter callback function is valid */ + H5Z_data_xform_t *data_transform; /* Data transform info (H5D_XFER_XFORM_NAME) */ + bool data_transform_valid; /* Whether data transform info is valid */ + H5T_vlen_alloc_info_t vl_alloc_info; /* VL datatype alloc info (H5D_XFER_VLEN_*_NAME) */ + bool vl_alloc_info_valid; /* Whether VL datatype alloc info is valid */ + H5T_conv_cb_t dt_conv_cb; /* Datatype conversion struct (H5D_XFER_CONV_CB_NAME) */ + bool dt_conv_cb_valid; /* Whether datatype conversion struct is valid */ + H5D_selection_io_mode_t selection_io_mode; /* Selection I/O mode (H5D_XFER_SELECTION_IO_MODE_NAME) */ + bool selection_io_mode_valid; /* Whether selection I/O mode is valid */ + bool modify_write_buf; /* Whether the library can modify write buffers (H5D_XFER_MODIFY_WRITE_BUF_NAME)*/ + bool modify_write_buf_valid; /* Whether the modify_write_buf field is valid */ + + /* Return-only DXPL properties to return to application */ +#ifdef H5_HAVE_PARALLEL + H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chunk_opt; /* Chunk optimization mode used for parallel I/O + (H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME) */ + bool mpio_actual_chunk_opt_set; /* Whether chunk optimization mode used for parallel I/O is set */ + H5D_mpio_actual_io_mode_t + mpio_actual_io_mode; /* Actual I/O mode used for parallel I/O (H5D_MPIO_ACTUAL_IO_MODE_NAME) */ + bool mpio_actual_io_mode_set; /* Whether actual I/O mode used for parallel I/O is set */ + uint32_t mpio_local_no_coll_cause; /* Local reason for breaking collective I/O + (H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME) */ + bool mpio_local_no_coll_cause_set; /* Whether local reason for breaking collective I/O is set */ + bool mpio_local_no_coll_cause_valid; /* Whether local reason for breaking collective I/O is valid */ + uint32_t mpio_global_no_coll_cause; /* Global reason for breaking collective I/O + (H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME) */ + bool mpio_global_no_coll_cause_set; /* Whether global reason for breaking collective I/O is set */ + bool mpio_global_no_coll_cause_valid; /* Whether global reason for breaking collective I/O is valid */ +#ifdef H5_HAVE_INSTRUMENTED_LIBRARY + int mpio_coll_chunk_link_hard; /* Instrumented "collective chunk link hard" value + (H5D_XFER_COLL_CHUNK_LINK_HARD_NAME) */ + bool mpio_coll_chunk_link_hard_set; /* Whether instrumented "collective chunk link hard" value is set */ + int mpio_coll_chunk_multi_hard; /* Instrumented "collective chunk multi hard" value + (H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME) */ + bool mpio_coll_chunk_multi_hard_set; /* Whether instrumented "collective chunk multi hard" value is set */ + int mpio_coll_chunk_link_num_true; /* Instrumented "collective chunk link num true" value + (H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME) */ + bool mpio_coll_chunk_link_num_true_set; /* Whether instrumented "collective chunk link num true" value + is set */ + int mpio_coll_chunk_link_num_false; /* Instrumented "collective chunk link num false" value + (H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME) */ + bool mpio_coll_chunk_link_num_false_set; /* Whether instrumented "collective chunk link num false" + value is set */ + int mpio_coll_chunk_multi_ratio_coll; /* Instrumented "collective chunk multi ratio coll" value + (H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME) */ + bool mpio_coll_chunk_multi_ratio_coll_set; /* Whether instrumented "collective chunk multi ratio coll" + value is set */ + int mpio_coll_chunk_multi_ratio_ind; /* Instrumented "collective chunk multi ratio ind" value + (H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME) */ + bool mpio_coll_chunk_multi_ratio_ind_set; /* Whether instrumented "collective chunk multi ratio ind" + value is set */ + bool mpio_coll_rank0_bcast; /* Instrumented "collective rank 0 broadcast" value + (H5D_XFER_COLL_RANK0_BCAST_NAME) */ + bool mpio_coll_rank0_bcast_set; /* Whether instrumented "collective rank 0 broadcast" value is set */ +#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ +#endif /* H5_HAVE_PARALLEL */ + uint32_t no_selection_io_cause; /* Reason for not performing selection I/O + (H5D_XFER_NO_SELECTION_IO_CAUSE_NAME) */ + bool no_selection_io_cause_set; /* Whether reason for not performing selection I/O is set */ + bool no_selection_io_cause_valid; /* Whether reason for not performing selection I/O is valid */ + + uint32_t actual_selection_io_mode; /* Actual selection I/O mode used + (H5D_XFER_ACTUAL_SELECTION_IO_MODE_NAME) */ + bool actual_selection_io_mode_set; /* Whether actual selection I/O mode is set */ + bool actual_selection_io_mode_valid; /* Whether actual selection I/O mode is valid */ + + /* Cached LCPL properties */ + H5T_cset_t encoding; /* Link name character encoding (H5P_STRCRT_CHAR_ENCODING_NAME) */ + bool encoding_valid; /* Whether link name character encoding is valid */ + unsigned intermediate_group; /* Whether to create intermediate groups (H5L_CRT_INTERMEDIATE_GROUP_NAME) */ + bool intermediate_group_valid; /* Whether create intermediate group flag is valid */ + + /* Cached LAPL properties */ + size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */ + bool nlinks_valid; /* Whether number of soft / UD links to traverse is valid */ + + /* Cached DCPL properties */ + bool do_min_dset_ohdr; /* Whether to minimize dataset object header (H5D_CRT_MIN_DSET_HDR_SIZE_NAME) */ + bool do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ + uint8_t ohdr_flags; /* Object header flags (H5O_CRT_OHDR_FLAGS_NAME) */ + bool ohdr_flags_valid; /* Whether the object headers flags are valid */ + + /* Cached DAPL properties */ + const char *extfile_prefix; /* Prefix for external file (H5D_ACS_EFILE_PREFIX_NAME) */ + bool extfile_prefix_valid; /* Whether the prefix for external file is valid */ + const char *vds_prefix; /* Prefix for VDS (H5D_ACS_VDS_PREFIX_NAME) */ + bool vds_prefix_valid; /* Whether the prefix for VDS is valid */ + + /* Cached FAPL properties */ + H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() + (H5F_ACS_LIBVER_LOW_BOUND_NAME) */ + bool low_bound_valid; /* Whether low_bound property is valid */ + H5F_libver_t high_bound; /* high_bound property for H5Pset_libver_bounds + (H5F_ACS_LIBVER_HIGH_BOUND_NAME) */ + bool high_bound_valid; /* Whether high_bound property is valid */ + + /* Cached VOL settings */ + H5VL_connector_prop_t vol_connector_prop; /* Property for VOL connector ID & info + This is treated as an independent field with + no relation to the property H5F_ACS_VOL_CONN_NAME stored on the FAPL */ + bool vol_connector_prop_valid; /* Whether property for VOL connector ID & info is valid */ + void *vol_wrap_ctx; /* VOL connector's "wrap context" for creating IDs */ + bool vol_wrap_ctx_valid; /* Whether VOL connector's "wrap context" for creating IDs is valid */ +} H5CX_t; + +/* Typedef for nodes on the API context stack */ +/* Each entry into the library through an API routine invokes H5CX_push() + * in a FUNC_ENTER_API* macro, which pushes an H5CX_node_t on the API + * context [thread-local] stack, after initializing it with default values. + */ +typedef struct H5CX_node_t { + H5CX_t ctx; /* Context for current API call */ + struct H5CX_node_t *next; /* Pointer to previous context, on stack */ +} H5CX_node_t; + /*****************************/ /* Library-private Variables */ /*****************************/ @@ -56,13 +288,10 @@ typedef struct H5CX_state_t { /***************************************/ /* Library private routines */ -#ifndef H5private_H -H5_DLL herr_t H5CX_push(void); +H5_DLL herr_t H5CX_push(H5CX_node_t *cnode); H5_DLL herr_t H5CX_pop(bool update_dxpl_props); -#endif /* H5private_H */ -H5_DLL bool H5CX_pushed(void); -H5_DLL void H5CX_push_special(void); -H5_DLL bool H5CX_is_def_dxpl(void); +H5_DLL bool H5CX_pushed(void); +H5_DLL bool H5CX_is_def_dxpl(void); /* API context state routines */ H5_DLL herr_t H5CX_retrieve_state(H5CX_state_t **api_state); diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 53e4790283..68a40f1fec 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -125,7 +125,7 @@ H5_DLL htri_t H5FD_is_driver_registered_by_name(const char *driver_name, H5_DLL htri_t H5FD_is_driver_registered_by_value(H5FD_class_value_t driver_value, hid_t *registered_id); H5_DLL hid_t H5FD_get_driver_id_by_name(const char *name, bool is_api); H5_DLL hid_t H5FD_get_driver_id_by_value(H5FD_class_value_t value, bool is_api); -H5_DLL herr_t H5FD_open(bool try, H5FD_t **file, const char *name, unsigned flags, hid_t fapl_id, +H5_DLL herr_t H5FD_open(bool attempt, H5FD_t **file, const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); H5_DLL herr_t H5FD_close(H5FD_t *file); H5_DLL int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 3237504629..8509a997f7 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -493,7 +493,7 @@ typedef enum H5F_prefix_open_t { /* Private functions */ H5_DLL herr_t H5F_init(void); -H5_DLL herr_t H5F_open(bool try, H5F_t **file, const char *name, unsigned flags, hid_t fcpl_id, +H5_DLL herr_t H5F_open(bool attempt, H5F_t **file, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5F_try_close(H5F_t *f, bool *was_closed /*out*/); H5_DLL hid_t H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, bool app_ref); @@ -657,9 +657,9 @@ H5_DLL herr_t H5F_shared_get_mpi_file_sync_required(const H5F_shared_t *f_sh, H5_DLL herr_t H5F_efc_close(H5F_t *parent, H5F_t *file); /* File prefix routines */ -H5_DLL herr_t H5F_prefix_open_file(bool try, H5F_t **file, H5F_t *primary_file, H5F_prefix_open_t prefix_type, - const char *prop_prefix, const char *file_name, unsigned file_intent, - hid_t fapl_id); +H5_DLL herr_t H5F_prefix_open_file(bool attempt, H5F_t **file, H5F_t *primary_file, + H5F_prefix_open_t prefix_type, const char *prop_prefix, + const char *file_name, unsigned file_intent, hid_t fapl_id); /* Global heap CWFS routines */ H5_DLL herr_t H5F_cwfs_add(H5F_t *f, struct H5HG_heap_t *heap); diff --git a/src/H5Ftest.c b/src/H5Ftest.c index aacdd4cf4e..540ef9c9b9 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -82,9 +82,10 @@ herr_t H5F__get_sohm_mesg_count_test(hid_t file_id, unsigned type_id, size_t *mesg_count) { - H5F_t *file; /* File info */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file; /* File info */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -93,7 +94,7 @@ H5F__get_sohm_mesg_count_test(hid_t file_id, unsigned type_id, size_t *mesg_coun HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file"); /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; @@ -123,9 +124,10 @@ done: herr_t H5F__check_cached_stab_test(hid_t file_id) { - H5F_t *file; /* File info */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file; /* File info */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -134,7 +136,7 @@ H5F__check_cached_stab_test(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file"); /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; diff --git a/src/H5Gtest.c b/src/H5Gtest.c index d8d74ed63f..c82411b754 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -83,11 +83,12 @@ htri_t H5G__is_empty_test(hid_t gid) { - H5G_t *grp = NULL; /* Pointer to group */ - htri_t msg_exists = false; /* Indicate that a header message is present */ - htri_t linfo_exists = false; /* Indicate that the 'link info' message is present */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - htri_t ret_value = true; /* Return value */ + H5G_t *grp = NULL; /* Pointer to group */ + htri_t msg_exists = false; /* Indicate that a header message is present */ + htri_t linfo_exists = false; /* Indicate that the 'link info' message is present */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + htri_t ret_value = true; /* Return value */ FUNC_ENTER_PACKAGE @@ -96,7 +97,7 @@ H5G__is_empty_test(hid_t gid) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; @@ -203,10 +204,11 @@ done: htri_t H5G__has_links_test(hid_t gid, unsigned *nmsgs) { - H5G_t *grp = NULL; /* Pointer to group */ - htri_t msg_exists = 0; /* Indicate that a header message is present */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - htri_t ret_value = true; /* Return value */ + H5G_t *grp = NULL; /* Pointer to group */ + htri_t msg_exists = 0; /* Indicate that a header message is present */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + htri_t ret_value = true; /* Return value */ FUNC_ENTER_PACKAGE @@ -215,7 +217,7 @@ H5G__has_links_test(hid_t gid, unsigned *nmsgs) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; @@ -269,10 +271,11 @@ done: htri_t H5G__has_stab_test(hid_t gid) { - H5G_t *grp = NULL; /* Pointer to group */ - htri_t msg_exists = 0; /* Indicate that a header message is present */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - htri_t ret_value = true; /* Return value */ + H5G_t *grp = NULL; /* Pointer to group */ + htri_t msg_exists = 0; /* Indicate that a header message is present */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + htri_t ret_value = true; /* Return value */ FUNC_ENTER_PACKAGE @@ -281,7 +284,7 @@ H5G__has_stab_test(hid_t gid) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; @@ -327,10 +330,11 @@ done: htri_t H5G__is_new_dense_test(hid_t gid) { - H5G_t *grp = NULL; /* Pointer to group */ - htri_t msg_exists = 0; /* Indicate that a header message is present */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - htri_t ret_value = true; /* Return value */ + H5G_t *grp = NULL; /* Pointer to group */ + htri_t msg_exists = 0; /* Indicate that a header message is present */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + htri_t ret_value = true; /* Return value */ FUNC_ENTER_PACKAGE @@ -339,7 +343,7 @@ H5G__is_new_dense_test(hid_t gid) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; @@ -403,12 +407,13 @@ done: herr_t H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) { - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - H5O_linfo_t linfo; /* Link info message */ - H5G_t *grp = NULL; /* Pointer to group */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + H5O_linfo_t linfo; /* Link info message */ + H5G_t *grp = NULL; /* Pointer to group */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -417,7 +422,7 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; @@ -494,10 +499,11 @@ done: herr_t H5G__lheap_size_test(hid_t gid, size_t *lheap_size) { - H5G_t *grp = NULL; /* Pointer to group */ - H5O_stab_t stab; /* Symbol table message */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_t *grp = NULL; /* Pointer to group */ + H5O_stab_t stab; /* Symbol table message */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -506,7 +512,7 @@ H5G__lheap_size_test(hid_t gid, size_t *lheap_size) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; @@ -550,10 +556,11 @@ done: herr_t H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigned *obj_hidden) { - void *obj_ptr; /* Pointer to object for ID */ - const H5G_name_t *obj_path; /* Pointer to group hier. path for obj */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + void *obj_ptr; /* Pointer to object for ID */ + const H5G_name_t *obj_path; /* Pointer to group hier. path for obj */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -566,7 +573,7 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get object for ID"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; diff --git a/src/H5Itest.c b/src/H5Itest.c index feb87dda1d..f1600eed72 100644 --- a/src/H5Itest.c +++ b/src/H5Itest.c @@ -63,17 +63,18 @@ ssize_t H5I__get_name_test(hid_t id, char *name /*out*/, size_t size, bool *cached) { - H5VL_object_t *vol_obj; /* Object of id */ - H5G_loc_t loc; /* Object location */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - bool vol_wrapper_set = false; /* Whether the VOL object wrapping context was set up */ - size_t name_len = 0; /* Length of name */ - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t *vol_obj; /* Object of id */ + H5G_loc_t loc; /* Object location */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + bool vol_wrapper_set = false; /* Whether the VOL object wrapping context was set up */ + size_t name_len = 0; /* Length of name */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, (-1), "can't set API context"); api_ctx_pushed = true; diff --git a/src/H5Otest.c b/src/H5Otest.c index e44ad92902..dd45ef8c50 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -82,11 +82,12 @@ htri_t H5O__is_attr_dense_test(hid_t oid) { - H5O_t *oh = NULL; /* Object header */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - H5O_loc_t *loc; /* Pointer to object's location */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - htri_t ret_value = FAIL; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + H5O_loc_t *loc; /* Pointer to object's location */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -95,7 +96,7 @@ H5O__is_attr_dense_test(hid_t oid) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; @@ -151,14 +152,15 @@ done: htri_t H5O__is_attr_empty_test(hid_t oid) { - H5O_t *oh = NULL; /* Object header */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - htri_t ainfo_exists = false; /* Whether the attribute info exists in the file */ - H5O_loc_t *loc; /* Pointer to object's location */ - hsize_t nattrs; /* Number of attributes */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - htri_t ret_value = FAIL; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + htri_t ainfo_exists = false; /* Whether the attribute info exists in the file */ + H5O_loc_t *loc; /* Pointer to object's location */ + hsize_t nattrs; /* Number of attributes */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -167,7 +169,7 @@ H5O__is_attr_empty_test(hid_t oid) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; @@ -254,13 +256,14 @@ done: herr_t H5O__num_attrs_test(hid_t oid, hsize_t *nattrs) { - H5O_t *oh = NULL; /* Object header */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - H5O_loc_t *loc; /* Pointer to object's location */ - hsize_t obj_nattrs; /* Number of attributes */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + H5O_loc_t *loc; /* Pointer to object's location */ + hsize_t obj_nattrs; /* Number of attributes */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -269,7 +272,7 @@ H5O__num_attrs_test(hid_t oid, hsize_t *nattrs) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; @@ -353,13 +356,14 @@ done: herr_t H5O__attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) { - H5O_t *oh = NULL; /* Object header */ - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - H5O_loc_t *loc; /* Pointer to object's location */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + H5O_loc_t *loc; /* Pointer to object's location */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -368,7 +372,7 @@ H5O__attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; @@ -624,12 +628,13 @@ done: herr_t H5O__msg_get_chunkno_test(hid_t oid, unsigned msg_type, unsigned *chunk_num) { - H5O_t *oh = NULL; /* Object header */ - H5O_loc_t *loc; /* Pointer to object's location */ - H5O_mesg_t *idx_msg; /* Pointer to message */ - unsigned idx; /* Index of message */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + H5O_loc_t *loc; /* Pointer to object's location */ + H5O_mesg_t *idx_msg; /* Pointer to message */ + unsigned idx; /* Index of message */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -638,7 +643,7 @@ H5O__msg_get_chunkno_test(hid_t oid, unsigned msg_type, unsigned *chunk_num) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; @@ -691,12 +696,13 @@ done: herr_t H5O__msg_move_to_new_chunk_test(hid_t oid, unsigned msg_type) { - H5O_t *oh = NULL; /* Object header */ - H5O_loc_t *loc; /* Pointer to object's location */ - H5O_mesg_t *curr_msg; /* Pointer to current message */ - unsigned idx; /* Index of message */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + H5O_loc_t *loc; /* Pointer to object's location */ + H5O_mesg_t *curr_msg; /* Pointer to current message */ + unsigned idx; /* Index of message */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -705,7 +711,7 @@ H5O__msg_move_to_new_chunk_test(hid_t oid, unsigned msg_type) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); /* Set API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context"); api_ctx_pushed = true; diff --git a/src/H5TSmutex.h b/src/H5TSmutex.h index cb67fb35a8..014634eecb 100644 --- a/src/H5TSmutex.h +++ b/src/H5TSmutex.h @@ -54,7 +54,7 @@ #ifdef H5_HAVE_C11_THREADS -#define H5TS_mutex_lock(mutex) ((H5_UNLIKELY(mtx_lock(mutex) != thrd_success)) ? FAIL : SUCCEED) +#define H5TS_mutex_lock(mutex) (H5_UNLIKELY(mtx_lock(mutex) != thrd_success) ? FAIL : SUCCEED) #define H5TS_mutex_unlock(mutex) (H5_UNLIKELY(mtx_unlock(mutex) != thrd_success) ? FAIL : SUCCEED) #else @@ -94,8 +94,8 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) } /* end H5TS_mutex_unlock() */ #else -#define H5TS_mutex_lock(mutex) (H5_UNLIKELY(pthread_mutex_lock(mutex)) ? FAIL : SUCCEED) -#define H5TS_mutex_unlock(mutex) (H5_UNLIKELY(pthread_mutex_unlock(mutex)) ? FAIL : SUCCEED) +#define H5TS_mutex_lock(mutex) (H5_UNLIKELY(0 != pthread_mutex_lock(mutex)) ? FAIL : SUCCEED) +#define H5TS_mutex_unlock(mutex) (H5_UNLIKELY(0 != pthread_mutex_unlock(mutex)) ? FAIL : SUCCEED) #endif #endif diff --git a/src/H5TSprivate.h b/src/H5TSprivate.h index cc6fc61d86..1e62a4ec9a 100644 --- a/src/H5TSprivate.h +++ b/src/H5TSprivate.h @@ -300,11 +300,13 @@ H5_DLL herr_t H5TS_mutex_destroy(H5TS_mutex_t *mutex); /* R/W locks */ H5_DLL herr_t H5TS_rwlock_init(H5TS_rwlock_t *lock); /* R/W lock & unlock calls are defined in H5TSrwlock.h */ +#if !defined(__cplusplus) static inline herr_t H5TS_rwlock_rdlock(H5TS_rwlock_t *lock); static inline herr_t H5TS_rwlock_rdunlock(H5TS_rwlock_t *lock); static inline herr_t H5TS_rwlock_wrlock(H5TS_rwlock_t *lock); static inline herr_t H5TS_rwlock_wrunlock(H5TS_rwlock_t *lock); -H5_DLL herr_t H5TS_rwlock_destroy(H5TS_rwlock_t *lock); +#endif +H5_DLL herr_t H5TS_rwlock_destroy(H5TS_rwlock_t *lock); /* Condition variable operations */ H5_DLL herr_t H5TS_cond_init(H5TS_cond_t *cond); @@ -325,11 +327,13 @@ H5_DLL void H5TS_thread_yield(void); /* Thread pools */ H5_DLL herr_t H5TS_pool_create(H5TS_pool_t **pool, unsigned num_threads); /* Thread pool add task call is defined in H5TSpool.h */ +#if !defined(__cplusplus) static inline herr_t H5TS_pool_add_task(H5TS_pool_t *pool, H5TS_thread_start_func_t func, void *ctx); -H5_DLL herr_t H5TS_pool_destroy(H5TS_pool_t *pool); +#endif +H5_DLL herr_t H5TS_pool_destroy(H5TS_pool_t *pool); /* Emulated C11 atomics */ -#if !(defined(H5_HAVE_STDATOMIC_H) && !defined(__cplusplus)) +#if !defined(H5_HAVE_STDATOMIC_H) && !defined(__cplusplus) /* atomic_int */ H5_DLL void H5TS_atomic_init_int(H5TS_atomic_int_t *obj, int desired); /* Atomic 'int' load, store, etc. calls are defined in H5TSatomic.h */ @@ -360,26 +364,32 @@ H5_DLL void H5TS_atomic_destroy_voidp(H5TS_atomic_voidp_t *obj); /* Barrier related function declarations */ H5_DLL herr_t H5TS_barrier_init(H5TS_barrier_t *barrier, unsigned count); /* Barrier wait call is defined in H5TSbarrier.h */ +#if !defined(__cplusplus) static inline herr_t H5TS_barrier_wait(H5TS_barrier_t *barrier); -H5_DLL herr_t H5TS_barrier_destroy(H5TS_barrier_t *barrier); +#endif /* H5_HAVE_PTHREAD_BARRIER */ +H5_DLL herr_t H5TS_barrier_destroy(H5TS_barrier_t *barrier); H5_DLL herr_t H5TS_semaphore_init(H5TS_semaphore_t *sem, unsigned initial_count); /* Semaphore signal & wait calls are defined in H5TSsemaphore.h */ +#if !defined(__cplusplus) static inline herr_t H5TS_semaphore_signal(H5TS_semaphore_t *sem); static inline herr_t H5TS_semaphore_wait(H5TS_semaphore_t *sem); -H5_DLL herr_t H5TS_semaphore_destroy(H5TS_semaphore_t *sem); +#endif +H5_DLL herr_t H5TS_semaphore_destroy(H5TS_semaphore_t *sem); /* Headers with inlined routines */ #include "H5TScond.h" #include "H5TSmutex.h" #include "H5TSkey.h" -#if !(defined(H5_HAVE_STDATOMIC_H) && !defined(__cplusplus)) +#if !defined(__cplusplus) +#if !defined(H5_HAVE_STDATOMIC_H) #include "H5TSatomic.h" #endif /* H5_HAVE_STDATOMIC_H */ #include "H5TSbarrier.h" #include "H5TSrwlock.h" #include "H5TSsemaphore.h" #include "H5TSpool.h" +#endif #endif /* H5_HAVE_THREADS */ diff --git a/src/H5Tconv_array.c b/src/H5Tconv_array.c index dc08ab96c5..35f6393186 100644 --- a/src/H5Tconv_array.c +++ b/src/H5Tconv_array.c @@ -22,9 +22,10 @@ /***********/ /* Headers */ /***********/ -#include "H5Eprivate.h" -#include "H5Iprivate.h" -#include "H5Tconv.h" +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tconv.h" /* Datatype conversions */ #include "H5Tconv_array.h" /******************/ diff --git a/src/H5Tconv_bitfield.c b/src/H5Tconv_bitfield.c index 8a8a2e4de4..f9b227196f 100644 --- a/src/H5Tconv_bitfield.c +++ b/src/H5Tconv_bitfield.c @@ -22,8 +22,9 @@ /***********/ /* Headers */ /***********/ -#include "H5Eprivate.h" -#include "H5Tconv.h" +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Tconv.h" /* Datatype conversions */ #include "H5Tconv_bitfield.h" /*------------------------------------------------------------------------- diff --git a/src/H5Tconv_compound.c b/src/H5Tconv_compound.c index e509c0c470..b05fb5e75d 100644 --- a/src/H5Tconv_compound.c +++ b/src/H5Tconv_compound.c @@ -22,9 +22,10 @@ /***********/ /* Headers */ /***********/ -#include "H5Eprivate.h" -#include "H5Iprivate.h" -#include "H5Tconv.h" +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tconv.h" /* Datatype conversions */ #include "H5Tconv_compound.h" /******************/ diff --git a/src/H5Tconv_enum.c b/src/H5Tconv_enum.c index 66c5358314..744f7b9920 100644 --- a/src/H5Tconv_enum.c +++ b/src/H5Tconv_enum.c @@ -22,8 +22,9 @@ /***********/ /* Headers */ /***********/ -#include "H5Eprivate.h" -#include "H5Tconv.h" +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Tconv.h" /* Datatype conversions */ #include "H5Tconv_enum.h" /******************/ diff --git a/src/H5Tconv_float.c b/src/H5Tconv_float.c index 561e29714d..165c360ac4 100644 --- a/src/H5Tconv_float.c +++ b/src/H5Tconv_float.c @@ -22,7 +22,8 @@ /***********/ /* Headers */ /***********/ -#include "H5Tconv.h" +#include "H5private.h" /* Generic Functions */ +#include "H5Tconv.h" /* Datatype conversions */ #include "H5Tconv_macros.h" #include "H5Tconv_float.h" diff --git a/src/H5Tconv_integer.c b/src/H5Tconv_integer.c index 6d92c67ed2..01808ab5dd 100644 --- a/src/H5Tconv_integer.c +++ b/src/H5Tconv_integer.c @@ -22,7 +22,8 @@ /***********/ /* Headers */ /***********/ -#include "H5Tconv.h" +#include "H5private.h" /* Generic Functions */ +#include "H5Tconv.h" /* Datatype conversions */ #include "H5Tconv_macros.h" #include "H5Tconv_integer.h" diff --git a/src/H5Tconv_reference.c b/src/H5Tconv_reference.c index 44a642a3cd..1404127e15 100644 --- a/src/H5Tconv_reference.c +++ b/src/H5Tconv_reference.c @@ -23,10 +23,11 @@ /***********/ /* Headers */ /***********/ -#include "H5Eprivate.h" -#include "H5FLprivate.h" -#include "H5Rpkg.h" -#include "H5Tconv.h" +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Rpkg.h" /* References */ +#include "H5Tconv.h" /* Datatype conversions */ #include "H5Tconv_reference.h" /*******************/ diff --git a/src/H5Tconv_string.c b/src/H5Tconv_string.c index 158ffd7aa6..727021af95 100644 --- a/src/H5Tconv_string.c +++ b/src/H5Tconv_string.c @@ -22,8 +22,9 @@ /***********/ /* Headers */ /***********/ -#include "H5Eprivate.h" -#include "H5Tconv.h" +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Tconv.h" /* Datatype conversions */ #include "H5Tconv_string.h" /*------------------------------------------------------------------------- diff --git a/src/H5Tconv_vlen.c b/src/H5Tconv_vlen.c index 2f368879be..5f6c35f127 100644 --- a/src/H5Tconv_vlen.c +++ b/src/H5Tconv_vlen.c @@ -22,10 +22,11 @@ /***********/ /* Headers */ /***********/ -#include "H5CXprivate.h" -#include "H5Eprivate.h" -#include "H5Iprivate.h" -#include "H5Tconv.h" +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tconv.h" /* Datatype conversions */ #include "H5Tconv_vlen.h" /****************/ diff --git a/src/H5VL.c b/src/H5VL.c index 9b0477493c..04563ce3a7 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -771,26 +771,36 @@ done: /*--------------------------------------------------------------------------- * Function: H5VLstart_lib_state * - * Purpose: Opens a new internal state for the HDF5 library. + * Purpose: Opens a new internal context for the HDF5 library. The context + * returned (via the OUT parameter) must be passed to + * H5VLfinish_lib_state to conclude the library's context and + * release resources. * * Note: This routine is _only_ for HDF5 VOL connector authors! It is * _not_ part of the public API for HDF5 application developers. * - * Return: Success: Non-negative - * Failure: Negative + * Note: Should probably rename this to 'H5VLopen_lib_context' or + * similar. + * + * Return: Success: Non-negative, *context set + * Failure: Negative, *context unset * *--------------------------------------------------------------------------- */ herr_t -H5VLstart_lib_state(void) +H5VLstart_lib_state(void **context) { herr_t ret_value = SUCCEED; /* Return value */ /* Must use this, to avoid modifying the API context stack in FUNC_ENTER */ FUNC_ENTER_API_NOINIT + /* Check args */ + if (NULL == context) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid context pointer"); + /* Start a new library state */ - if (H5VL_start_lib_state() < 0) + if (H5VL_start_lib_state(context) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't start new library state"); done: @@ -843,21 +853,28 @@ done: * H5VLstart_lib_state. It can be called before / after / * independently of H5VLfree_lib_state. * + * Note: Should probably rename this to 'H5VLclose_lib_context' or + * similar. + * * Return: Success: Non-negative * Failure: Negative * *--------------------------------------------------------------------------- */ herr_t -H5VLfinish_lib_state(void) +H5VLfinish_lib_state(void *context) { herr_t ret_value = SUCCEED; /* Return value */ /* Must use this, to avoid modifying the API context stack in FUNC_ENTER */ FUNC_ENTER_API_NOINIT + /* Check args */ + if (NULL == context) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid context pointer"); + /* Reset the library state */ - if (H5VL_finish_lib_state() < 0) + if (H5VL_finish_lib_state(context) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset library state"); done: diff --git a/src/H5VLconnector_passthru.h b/src/H5VLconnector_passthru.h index 90afbbc061..9438ed117f 100644 --- a/src/H5VLconnector_passthru.h +++ b/src/H5VLconnector_passthru.h @@ -80,11 +80,13 @@ H5_DLL herr_t H5VLcmp_connector_cls(int *cmp, hid_t connector_id1, hid_t connect * can't be retrieved. * */ -H5_DLL hid_t H5VLwrap_register(void *obj, H5I_type_t type); +H5_DLL hid_t H5VLwrap_register(void *obj, H5I_type_t type); + +/* Library context and state routines */ H5_DLL herr_t H5VLretrieve_lib_state(void **state); -H5_DLL herr_t H5VLstart_lib_state(void); +H5_DLL herr_t H5VLstart_lib_state(void **context); H5_DLL herr_t H5VLrestore_lib_state(const void *state); -H5_DLL herr_t H5VLfinish_lib_state(void); +H5_DLL herr_t H5VLfinish_lib_state(void *context); H5_DLL herr_t H5VLfree_lib_state(void *state); /* Pass-through callbacks */ diff --git a/src/H5VLint.c b/src/H5VLint.c index c3c4cd744b..6d2864e2d9 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -2062,25 +2062,41 @@ done: * * Purpose: Opens a new internal state for the HDF5 library. * - * Note: Currently just pushes a new API context state, but could be + * Note: Currently just pushes a new API context, but could be * expanded in the future. * - * Return: SUCCEED / FAIL + * Return: Success: Non-negative, *context set + * Failure: Negative, *context unset * *------------------------------------------------------------------------- */ herr_t -H5VL_start_lib_state(void) +H5VL_start_lib_state(void **context) { - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t *cnode = NULL; /* API context */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + /* Sanity check */ + assert(context); + + /* Allocate & clear a new API context */ + if (NULL == (cnode = H5MM_calloc(sizeof(H5CX_node_t)))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate library context"); + /* Push a new API context on the stack */ - if (H5CX_push() < 0) + if (H5CX_push(cnode) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't push API context"); + /* Set output parameter */ + *context = cnode; + done: + if (ret_value < 0) + if (cnode) + H5MM_xfree(cnode); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_start_lib_state() */ @@ -2132,16 +2148,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_finish_lib_state(void) +H5VL_finish_lib_state(void *context) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + /* Sanity check */ + assert(context); + /* Pop the API context off the stack */ if (H5CX_pop(false) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't pop API context"); + /* Release library context */ + H5MM_xfree(context); + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_finish_lib_state() */ diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 11b77f890b..bcdfdba8b7 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -134,9 +134,9 @@ H5_DLL void H5VL_obj_reset_data(H5VL_object_t *vol_obj); /* Library state functions */ H5_DLL herr_t H5VL_retrieve_lib_state(void **state); -H5_DLL herr_t H5VL_start_lib_state(void); +H5_DLL herr_t H5VL_start_lib_state(void **context); H5_DLL herr_t H5VL_restore_lib_state(const void *state); -H5_DLL herr_t H5VL_finish_lib_state(void); +H5_DLL herr_t H5VL_finish_lib_state(void *context); H5_DLL herr_t H5VL_free_lib_state(void *state); /* ID registration functions */ diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index 775373d4ca..eac576874e 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -78,7 +78,7 @@ H5_DLL herr_t H5Z_modify(const struct H5O_pline_t *pline, H5Z_filter_t filter, u H5_DLL herr_t H5Z_pipeline(const struct H5O_pline_t *pline, unsigned flags, unsigned *filter_mask /*in,out*/, H5Z_EDC_t edc_read, H5Z_cb_t cb_struct, size_t *nbytes /*in,out*/, size_t *buf_size /*in,out*/, void **buf /*in,out*/); -H5_DLL herr_t H5Z_find(bool try, H5Z_filter_t id, H5Z_class2_t **cls); +H5_DLL herr_t H5Z_find(bool attempt, H5Z_filter_t id, H5Z_class2_t **cls); H5_DLL herr_t H5Z_can_apply(hid_t dcpl_id, hid_t type_id); H5_DLL herr_t H5Z_set_local(hid_t dcpl_id, hid_t type_id); H5_DLL herr_t H5Z_can_apply_direct(const struct H5O_pline_t *pline); diff --git a/src/H5private.h b/src/H5private.h index 6bd1f292e2..5347938bf4 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -501,6 +501,18 @@ #define LOCK_UN 0x08 #endif /* H5_HAVE_FLOCK */ +/* Private typedefs */ + +/* Union for const/non-const pointer for use by functions that manipulate + * pointers but do not write to their targets or return pointers to const + * specified locations. Also used for I/O functions that work for read and + * write - these functions are expected to never write to these locations in the + * write case. This helps us avoid compiler warnings. */ +typedef union { + void *vp; + const void *cvp; +} H5_flexible_const_ptr_t; + /* If necessary, create a typedef for library usage of the * _Float16 type to avoid issues when compiling the library * with the -pedantic flag or similar where we get warnings @@ -1124,10 +1136,7 @@ extern char H5_lib_vers_info_g[]; #define H5_PACKAGE_INIT(pkg_init, err) #endif /* H5_MY_PKG */ -/* Forward declaration of H5CXpush() / H5CXpop() */ -/* (Including H5CXprivate.h creates bad circular dependencies - QAK, 3/18/2018) */ -H5_DLL herr_t H5CX_push(void); -H5_DLL herr_t H5CX_pop(bool update_dxpl_props); +#include "H5CXprivate.h" /* API Contexts */ #ifndef NDEBUG #define FUNC_ENTER_CHECK_NAME(asrt) \ @@ -1174,7 +1183,7 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props); #define FUNC_ENTER_API_PUSH(err) \ /* Push the API context */ \ - if (H5_UNLIKELY(H5CX_push() < 0)) \ + if (H5_UNLIKELY(H5CX_push(&api_ctx) < 0)) \ HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, err, "can't set API context"); \ else \ api_ctx_pushed = true; @@ -1183,7 +1192,8 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props); #define FUNC_ENTER_API(err) \ { \ { \ - bool api_ctx_pushed = false; \ + H5CX_node_t api_ctx = {{0}, NULL}; \ + bool api_ctx_pushed = false; \ \ FUNC_ENTER_API_COMMON \ FUNC_ENTER_API_INIT(err); \ @@ -1199,7 +1209,8 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props); #define FUNC_ENTER_API_NOCLEAR(err) \ { \ { \ - bool api_ctx_pushed = false; \ + H5CX_node_t api_ctx = {{0}, NULL}; \ + bool api_ctx_pushed = false; \ \ FUNC_ENTER_API_COMMON \ FUNC_ENTER_API_INIT(err); \ @@ -1247,9 +1258,7 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props); { \ { \ { \ - FUNC_ENTER_API_VARS \ - FUNC_ENTER_COMMON(H5_IS_API(__func__)); \ - H5_API_LOCK \ + FUNC_ENTER_API_COMMON \ FUNC_ENTER_API_INIT(err); \ { @@ -1508,18 +1517,6 @@ H5_PKG_DECLARE_FUNC(H5_MY_PKG_INIT, H5_MY_PKG) #define HDcompile_assert(e) do { typedef struct { unsigned int b: (e); } x; } while(0) */ -/* Private typedefs */ - -/* Union for const/non-const pointer for use by functions that manipulate - * pointers but do not write to their targets or return pointers to const - * specified locations. Also used for I/O functions that work for read and - * write - these functions are expected to never write to these locations in the - * write case. This helps us avoid compiler warnings. */ -typedef union { - void *vp; - const void *cvp; -} H5_flexible_const_ptr_t; - /* File-independent encode/decode routines */ #include "H5encode.h" diff --git a/test/accum.c b/test/accum.c index e2c70d64f5..9966b31b69 100644 --- a/test/accum.c +++ b/test/accum.c @@ -80,12 +80,13 @@ void accum_printf(const H5F_t *f); int main(void) { - unsigned nerrors = 0; /* track errors */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - hid_t fid = H5I_INVALID_HID; - hid_t fapl = H5I_INVALID_HID; /* File access property list */ - char filename[1024]; - H5F_t *f = NULL; /* File for all tests */ + unsigned nerrors = 0; /* track errors */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + hid_t fid = H5I_INVALID_HID; + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + char filename[1024]; + H5F_t *f = NULL; /* File for all tests */ /* Test Setup */ puts("Testing the metadata accumulator"); @@ -101,7 +102,7 @@ main(void) FAIL_STACK_ERROR; /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; @@ -2058,7 +2059,8 @@ test_swmr_write_big(bool newest_format) uint8_t wbuf[1024]; /* Buffer for reading & writing */ unsigned u; /* Local index variable */ bool process_success = false; - bool api_ctx_pushed = false; /* Whether API context pushed */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ if (newest_format) TESTING("SWMR write of large metadata: with latest format"); @@ -2110,7 +2112,7 @@ test_swmr_write_big(bool newest_format) FAIL_STACK_ERROR; /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/accum_swmr_reader.c b/test/accum_swmr_reader.c index 5feb19b401..a7ad977911 100644 --- a/test/accum_swmr_reader.c +++ b/test/accum_swmr_reader.c @@ -45,10 +45,11 @@ main(void) hid_t fapl = H5I_INVALID_HID; /* file access property list ID */ H5F_t *f = NULL; /* File pointer */ char filename[1024]; - unsigned u; /* Local index variable */ - uint8_t rbuf[1024]; /* Buffer for reading */ - uint8_t buf[1024]; /* Buffer for holding the expected data */ - bool api_ctx_pushed = false; /* Whether API context pushed */ + unsigned u; /* Local index variable */ + uint8_t rbuf[1024]; /* Buffer for reading */ + uint8_t buf[1024]; /* Buffer for holding the expected data */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ /* Testing setup */ h5_test_init(); @@ -75,7 +76,7 @@ main(void) FAIL_STACK_ERROR; /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/btree2.c b/test/btree2.c index 41c25ccb9f..03fed030b0 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -9916,8 +9916,9 @@ main(void) unsigned nerrors = 0; /* Cumulative error count */ unsigned reopen; /* Whether to reopen B-tree during tests */ const char *driver_name; - bool api_ctx_pushed = false; /* Whether API context pushed */ - int localTestExpress; /* localized TestExpress */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + int localTestExpress; /* localized TestExpress */ driver_name = h5_get_test_driver_name(); @@ -9937,7 +9938,7 @@ main(void) init_cparam(&cparam, &cparam2); /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/cache.c b/test/cache.c index 08c051a853..f3599e8158 100644 --- a/test/cache.c +++ b/test/cache.c @@ -247,14 +247,15 @@ static void takedown_cache(H5F_t *file_ptr, bool dump_stats, bool dump_detailed_ static unsigned smoke_check_1(int express_test, unsigned paged) { - bool show_progress = false; - int dirty_unprotects = false; - int dirty_destroys = false; - bool display_stats = false; - int32_t lag = 10; - int32_t max_index = (10 * 1024) - 1; - int mile_stone = 1; - H5F_t *file_ptr = NULL; + bool show_progress = false; + int dirty_unprotects = false; + int dirty_destroys = false; + bool display_stats = false; + int32_t lag = 10; + int32_t max_index = (10 * 1024) - 1; + int mile_stone = 1; + H5F_t *file_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("smoke check #1P -- all clean, ins, dest, ren, 4/2 MB cache"); @@ -302,6 +303,9 @@ smoke_check_1(int express_test, unsigned paged) if (show_progress) /* 3 */ fprintf(stdout, "%s() - %0d -- pass = %d\n", __func__, mile_stone++, (int)pass); + /* Push API context */ + H5CX_push(&api_ctx); + row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, /* lag */ lag, @@ -422,8 +426,10 @@ smoke_check_1(int express_test, unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* smoke_check_1() */ /*------------------------------------------------------------------------- @@ -442,14 +448,15 @@ smoke_check_1(int express_test, unsigned paged) static unsigned smoke_check_2(int express_test, unsigned paged) { - bool show_progress = false; - int dirty_unprotects = true; - int dirty_destroys = true; - bool display_stats = false; - int32_t max_index = (10 * 1024) - 1; - int32_t lag = 10; - int mile_stone = 1; - H5F_t *file_ptr = NULL; + bool show_progress = false; + int dirty_unprotects = true; + int dirty_destroys = true; + bool display_stats = false; + int32_t max_index = (10 * 1024) - 1; + int32_t lag = 10; + int mile_stone = 1; + H5F_t *file_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("smoke check #2P -- ~1/2 dirty, ins, dest, ren, 4/2 MB cache"); @@ -497,6 +504,9 @@ smoke_check_2(int express_test, unsigned paged) if (show_progress) /* 3 */ fprintf(stdout, "%s() - %0d -- pass = %d\n", __func__, mile_stone++, (int)pass); + /* Push API context */ + H5CX_push(&api_ctx); + row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, /* lag */ lag, @@ -617,8 +627,10 @@ smoke_check_2(int express_test, unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* smoke_check_2() */ /*------------------------------------------------------------------------- @@ -636,14 +648,15 @@ smoke_check_2(int express_test, unsigned paged) static unsigned smoke_check_3(int express_test, unsigned paged) { - bool show_progress = false; - int dirty_unprotects = false; - int dirty_destroys = false; - bool display_stats = false; - int32_t max_index = (10 * 1024) - 1; - int32_t lag = 10; - int mile_stone = 1; - H5F_t *file_ptr = NULL; + bool show_progress = false; + int dirty_unprotects = false; + int dirty_destroys = false; + bool display_stats = false; + int32_t max_index = (10 * 1024) - 1; + int32_t lag = 10; + int mile_stone = 1; + H5F_t *file_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("smoke check #3P -- all clean, ins, dest, ren, 2/1 KB cache"); @@ -691,6 +704,9 @@ smoke_check_3(int express_test, unsigned paged) if (show_progress) /* 3 */ fprintf(stdout, "%s() - %0d -- pass = %d\n", __func__, mile_stone++, (int)pass); + /* Push API context */ + H5CX_push(&api_ctx); + row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, /* lag */ lag, @@ -811,8 +827,10 @@ smoke_check_3(int express_test, unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* smoke_check_3() */ /*------------------------------------------------------------------------- @@ -831,14 +849,15 @@ smoke_check_3(int express_test, unsigned paged) static unsigned smoke_check_4(int express_test, unsigned paged) { - bool show_progress = false; - int dirty_unprotects = true; - int dirty_destroys = true; - bool display_stats = false; - int32_t max_index = (10 * 1024) - 1; - int32_t lag = 10; - int mile_stone = 1; - H5F_t *file_ptr = NULL; + bool show_progress = false; + int dirty_unprotects = true; + int dirty_destroys = true; + bool display_stats = false; + int32_t max_index = (10 * 1024) - 1; + int32_t lag = 10; + int mile_stone = 1; + H5F_t *file_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("smoke check #4P -- ~1/2 dirty, ins, dest, ren, 2/1 KB cache"); @@ -886,6 +905,9 @@ smoke_check_4(int express_test, unsigned paged) if (show_progress) /* 3 */ fprintf(stdout, "%s() - %0d -- pass = %d\n", __func__, mile_stone++, (int)pass); + /* Push API context */ + H5CX_push(&api_ctx); + row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, /* lag */ lag, @@ -1006,8 +1028,10 @@ smoke_check_4(int express_test, unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* smoke_check_4() */ /*------------------------------------------------------------------------- @@ -1074,6 +1098,7 @@ smoke_check_5(int express_test, unsigned paged) /* bool apply_empty_reserve = */ true, /* double empty_reserve = */ 0.5}; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("smoke check #5P -- all clean, ins, prot, unprot, AR cache 1"); @@ -1119,6 +1144,9 @@ smoke_check_5(int express_test, unsigned paged) file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); @@ -1230,8 +1258,10 @@ smoke_check_5(int express_test, unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* smoke_check_5() */ /*------------------------------------------------------------------------- @@ -1298,6 +1328,7 @@ smoke_check_6(int express_test, unsigned paged) /* bool apply_empty_reserve = */ true, /* double empty_reserve = */ 0.05}; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("smoke check #6P -- ~1/2 dirty, ins, prot, unprot, AR cache 1"); @@ -1343,6 +1374,9 @@ smoke_check_6(int express_test, unsigned paged) file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); @@ -1454,8 +1488,10 @@ smoke_check_6(int express_test, unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* smoke_check_6() */ /*------------------------------------------------------------------------- @@ -1523,6 +1559,7 @@ smoke_check_7(int express_test, unsigned paged) /* bool apply_empty_reserve = */ true, /* double empty_reserve = */ 0.1}; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("smoke check #7P -- all clean, ins, prot, unprot, AR cache 2"); @@ -1568,6 +1605,9 @@ smoke_check_7(int express_test, unsigned paged) file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); @@ -1679,8 +1719,10 @@ smoke_check_7(int express_test, unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* smoke_check_7() */ /*------------------------------------------------------------------------- @@ -1748,6 +1790,7 @@ smoke_check_8(int express_test, unsigned paged) /* bool apply_empty_reserve = */ true, /* double empty_reserve = */ 0.1}; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("smoke check #8P -- ~1/2 dirty, ins, prot, unprot, AR cache 2"); @@ -1793,6 +1836,9 @@ smoke_check_8(int express_test, unsigned paged) file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); @@ -1904,8 +1950,10 @@ smoke_check_8(int express_test, unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* smoke_check_8() */ /*------------------------------------------------------------------------- @@ -1927,17 +1975,18 @@ smoke_check_8(int express_test, unsigned paged) static unsigned smoke_check_9(int express_test, unsigned paged) { - herr_t result; - bool show_progress = false; - int dirty_unprotects = false; - int dirty_destroys = false; - bool display_stats = false; - bool display_detailed_stats = false; - int32_t max_index = (10 * 1024) - 1; - int32_t lag = 10; - int mile_stone = 1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; + herr_t result; + bool show_progress = false; + int dirty_unprotects = false; + int dirty_destroys = false; + bool display_stats = false; + bool display_detailed_stats = false; + int32_t max_index = (10 * 1024) - 1; + int32_t lag = 10; + int mile_stone = 1; + H5F_t *file_ptr = NULL; + H5C_t *cache_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("smoke check #9P -- all clean, ins, dest, ren, 4/2 MB, corked"); @@ -1983,11 +2032,13 @@ smoke_check_9(int express_test, unsigned paged) file_ptr = setup_cache((size_t)(4 * 1024 * 1024), (size_t)(2 * 1024 * 1024), paged); cache_ptr = file_ptr->shared->cache; - /* disable evictions */ - if (show_progress) /* 3 */ fprintf(stdout, "%s() - %0d -- pass = %d\n", __func__, mile_stone++, (int)pass); + /* Push API context */ + H5CX_push(&api_ctx); + + /* disable evictions */ if (pass) { result = H5C_set_evictions_enabled(cache_ptr, false); @@ -2209,8 +2260,10 @@ smoke_check_9(int express_test, unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* smoke_check_9() */ /*------------------------------------------------------------------------- @@ -2232,17 +2285,18 @@ smoke_check_9(int express_test, unsigned paged) static unsigned smoke_check_10(int express_test, unsigned paged) { - herr_t result; - bool show_progress = false; - int dirty_unprotects = true; - int dirty_destroys = true; - bool display_stats = false; - bool display_detailed_stats = false; - int32_t max_index = (10 * 1024) - 1; - int32_t lag = 10; - int mile_stone = 1; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; + herr_t result; + bool show_progress = false; + int dirty_unprotects = true; + int dirty_destroys = true; + bool display_stats = false; + bool display_detailed_stats = false; + int32_t max_index = (10 * 1024) - 1; + int32_t lag = 10; + int mile_stone = 1; + H5F_t *file_ptr = NULL; + H5C_t *cache_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("smoke check #10P -- ~1/2 dirty, ins, dest, ren, 4/2 MB, corked"); @@ -2288,6 +2342,9 @@ smoke_check_10(int express_test, unsigned paged) file_ptr = setup_cache((size_t)(4 * 1024 * 1024), (size_t)(2 * 1024 * 1024), paged); cache_ptr = file_ptr->shared->cache; + /* Push API context */ + H5CX_push(&api_ctx); + if (show_progress) /* 3 */ fprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", __func__, mile_stone++, (int)pass); @@ -2509,8 +2566,10 @@ smoke_check_10(int express_test, unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* smoke_check_10() */ /*------------------------------------------------------------------------- @@ -2537,12 +2596,13 @@ write_permitted_check(int #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - bool show_progress = false; - bool display_stats = false; - int32_t max_index = (10 * 1024) - 1; - int32_t lag = 10; - int mile_stone = 1; - H5F_t *file_ptr = NULL; + bool show_progress = false; + bool display_stats = false; + int32_t max_index = (10 * 1024) - 1; + int32_t lag = 10; + int mile_stone = 1; + H5F_t *file_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ @@ -2588,6 +2648,9 @@ write_permitted_check(int if (show_progress) /* 3 */ fprintf(stdout, "%s() - %0d -- pass = %d\n", __func__, mile_stone++, (int)pass); + /* Push API context */ + H5CX_push(&api_ctx); + row_major_scan_forward(/* file_ptr */ file_ptr, /* max_index */ max_index, /* lag */ lag, @@ -2706,6 +2769,9 @@ write_permitted_check(int fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } + /* Pop API context */ + H5CX_pop(false); + #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ SKIPPED(); @@ -2715,7 +2781,6 @@ write_permitted_check(int #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ return (unsigned)!pass; - } /* write_permitted_check() */ /*------------------------------------------------------------------------- @@ -2750,6 +2815,7 @@ check_insert_entry(unsigned paged) test_entry_t *base_addr; test_entry_t *entry_ptr; struct H5C_cache_entry_t *search_ptr; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("H5C_insert_entry() functionality (paged aggregation)"); @@ -2776,6 +2842,9 @@ check_insert_entry(unsigned paged) cache_ptr = file_ptr->shared->cache; } + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { insert_entry(file_ptr, entry_type, 0, H5C__NO_FLAGS_SET); @@ -2968,8 +3037,10 @@ check_insert_entry(unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_insert_entry() */ /*------------------------------------------------------------------------- @@ -2986,7 +3057,8 @@ check_insert_entry(unsigned paged) static unsigned check_flush_cache(unsigned paged) { - H5F_t *file_ptr = NULL; + H5F_t *file_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("H5C_flush_cache() functionality (paged aggregation)"); @@ -3007,6 +3079,9 @@ check_flush_cache(unsigned paged) file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); } + /* Push API context */ + H5CX_push(&api_ctx); + /* first test behaviour on an empty cache. Can't do much sanity * checking in this case, so simply check the return values. */ @@ -3052,8 +3127,10 @@ check_flush_cache(unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_flush_cache() */ /*------------------------------------------------------------------------- @@ -7574,7 +7651,7 @@ check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) { struct expected_entry_status *expected = NULL; H5C_t *cache_ptr = file_ptr->shared->cache; - int i; + long i; const int num_variable_entries = 10; const int num_monster_entries = 31; int num_large_entries = 14; @@ -7874,13 +7951,13 @@ check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) /* Now fill up the cache with other, unrelated entries */ for (i = 0; i < 31; i++) { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } for (i = 0; i < 1; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } /* The cache should now be exactly full */ @@ -8115,13 +8192,13 @@ check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) * as they are pinned and thus not in the LRU list to begin with. */ for (i = 0; i < 31; i++) { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } for (i = 0; i < 5; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } /* verify cache size */ @@ -8188,8 +8265,8 @@ check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) num_large_entries = 8; for (i = 5; i < 8; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } /* verify cache size */ @@ -8248,8 +8325,8 @@ check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) num_large_entries = 9; for (i = 8; i < 9; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } /* verify cache size */ @@ -8310,8 +8387,8 @@ check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) num_large_entries = 10; for (i = 9; i < 10; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } /* verify cache size */ @@ -8340,13 +8417,13 @@ check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) * now in the LRU list. */ for (i = 0; i < 31; i++) { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } for (i = 0; i < 10; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } /* verify cache size */ @@ -8496,8 +8573,8 @@ check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) } for (i = 10; i < 12; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } /* verify cache size */ @@ -8548,23 +8625,23 @@ check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) entry_ptr->destroyed = false; for (i = 1; i < num_monster_entries; i++) { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } for (i = 0; i < num_large_entries; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } for (i = 0; i < num_monster_entries; i++) { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } for (i = 0; i < num_large_entries; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } /* update the expected array to mark all these entries dirty again. */ @@ -8669,8 +8746,8 @@ check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) } for (i = 12; i < 14; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, (int)i, H5C__DIRTIED_FLAG); } /* verify cache size */ @@ -9500,6 +9577,7 @@ check_get_entry_status(unsigned paged) H5F_t *file_ptr = NULL; test_entry_t *base_addr = NULL; test_entry_t *entry_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("H5C_get_entry_status() functionality (paged aggregation)"); @@ -9526,6 +9604,9 @@ check_get_entry_status(unsigned paged) } } + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { /* entry not in cache -- only in_cache should be touched by @@ -9688,8 +9769,10 @@ check_get_entry_status(unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_get_entry_status() */ /*------------------------------------------------------------------------- @@ -9715,6 +9798,7 @@ check_expunge_entry(unsigned paged) H5F_t *file_ptr = NULL; test_entry_t *base_addr; test_entry_t *entry_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("H5C_expunge_entry() functionality (paged aggregation)"); @@ -9733,6 +9817,9 @@ check_expunge_entry(unsigned paged) entry_ptr = &(base_addr[0]); } + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { /* entry not in cache -- only in_cache should be touched by @@ -9963,8 +10050,10 @@ check_expunge_entry(unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_expunge_entry() */ /*------------------------------------------------------------------------- @@ -9985,6 +10074,7 @@ check_multiple_read_protect(unsigned paged) H5C_t *cache_ptr = NULL; #endif /* H5C_COLLECT_CACHE_STATS */ test_entry_t *entry_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("multiple read only protects on a single entry (paged aggr)"); @@ -10033,6 +10123,9 @@ check_multiple_read_protect(unsigned paged) } } + /* Push API context */ + H5CX_push(&api_ctx); + #if H5C_COLLECT_CACHE_STATS if ((cache_ptr->write_protects[0] != 0) || (cache_ptr->read_protects[0] != 0) || (cache_ptr->max_read_protects[0] != 0)) { @@ -10347,8 +10440,10 @@ check_multiple_read_protect(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_multiple_read_protect() */ /*------------------------------------------------------------------------- @@ -10386,6 +10481,7 @@ check_move_entry(unsigned paged) /* bool is_pinned = */ true, /* bool is_protected = */ true}, }; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("H5C_move_entry() functionality (paged aggregation)"); @@ -10426,6 +10522,9 @@ check_move_entry(unsigned paged) file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); } + /* Push API context */ + H5CX_push(&api_ctx); + u = 0; while (pass && (u < NELMTS(test_specs))) { check_move_entry__run_test(file_ptr, u, &(test_specs[u])); @@ -10443,6 +10542,9 @@ check_move_entry(unsigned paged) if (!pass) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_move_entry() */ @@ -10613,6 +10715,7 @@ check_pin_protected_entry(unsigned paged) H5F_t *file_ptr = NULL; test_entry_t *base_addr; test_entry_t *entry_ptr; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("H5C_pin_protected_entry() functionality (paged aggregation)"); @@ -10639,6 +10742,9 @@ check_pin_protected_entry(unsigned paged) } } + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { protect_entry(file_ptr, 0, 0); @@ -10688,8 +10794,10 @@ check_pin_protected_entry(unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_pin_protected_entry() */ /*------------------------------------------------------------------------- @@ -10718,6 +10826,7 @@ check_resize_entry(unsigned paged) H5C_t *cache_ptr = NULL; test_entry_t *base_addr; test_entry_t *entry_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("entry resize functionality (paged aggregation)"); @@ -10777,6 +10886,9 @@ check_resize_entry(unsigned paged) } } + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0) || (cache_ptr->slist_len != 0) || @@ -11547,8 +11659,10 @@ check_resize_entry(unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_resize_entry() */ /*------------------------------------------------------------------------- @@ -11576,6 +11690,7 @@ check_evictions_enabled(unsigned paged) H5C_t *cache_ptr = NULL; test_entry_t *base_addr = NULL; test_entry_t *entry_ptr; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("evictions enabled/disabled functionality (paged aggregation)"); @@ -11641,6 +11756,9 @@ check_evictions_enabled(unsigned paged) } } + /* Push API context */ + H5CX_push(&api_ctx); + if (show_progress) /* 2 */ fprintf(stdout, "%s() - %0d -- pass = %d\n", __func__, mile_stone++, (int)pass); @@ -12188,8 +12306,10 @@ check_evictions_enabled(unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_evictions_enabled() */ /*------------------------------------------------------------------------- @@ -12206,8 +12326,9 @@ check_evictions_enabled(unsigned paged) static unsigned check_flush_protected_err(unsigned paged) { - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; + H5F_t *file_ptr = NULL; + H5C_t *cache_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("flush cache with protected entry error (paged aggregation)"); @@ -12221,49 +12342,47 @@ check_flush_protected_err(unsigned paged) * succeed. */ - if (pass) { + reset_entries(); + file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + if (pass) + cache_ptr = file_ptr->shared->cache; - reset_entries(); - - file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); - - if (pass) { - - cache_ptr = file_ptr->shared->cache; - } + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) protect_entry(file_ptr, 0, 0); - /* enable slist prior to flush */ - if ((pass) && (H5C_set_slist_enabled(cache_ptr, true, true) < 0)) { + /* enable slist prior to flush */ + if ((pass) && (H5C_set_slist_enabled(cache_ptr, true, true) < 0)) { - pass = false; - failure_mssg = "unable to enable slist prior to flush.\n"; - } + pass = false; + failure_mssg = "unable to enable slist prior to flush.\n"; + } - if ((pass) && (H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET) >= 0)) { + if ((pass) && (H5C_flush_cache(file_ptr, H5C__NO_FLAGS_SET) >= 0)) { - pass = false; - failure_mssg = "flush succeeded on cache with protected entry.\n"; - } + pass = false; + failure_mssg = "flush succeeded on cache with protected entry.\n"; + } - /* disable the slist after the flush */ - if ((pass) && (H5C_set_slist_enabled(cache_ptr, false, false) < 0)) { + /* disable the slist after the flush */ + if ((pass) && (H5C_set_slist_enabled(cache_ptr, false, false) < 0)) { - pass = false; - failure_mssg = "unable to disable slist after flush.\n"; - } + pass = false; + failure_mssg = "unable to disable slist after flush.\n"; + } + if (pass) unprotect_entry(file_ptr, 0, 0, H5C__DIRTIED_FLAG); - if (pass) { + if (pass) { - H5C_FLUSH_CACHE(file_ptr, H5C__NO_FLAGS_SET, "flush failed after unprotect.\n") - } - - takedown_cache(file_ptr, false, false); + H5C_FLUSH_CACHE(file_ptr, H5C__NO_FLAGS_SET, "flush failed after unprotect.\n") } + takedown_cache(file_ptr, false, false); + if (pass) { PASSED(); } @@ -12276,8 +12395,10 @@ check_flush_protected_err(unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_flush_protected_err() */ /*------------------------------------------------------------------------- @@ -12294,7 +12415,8 @@ check_flush_protected_err(unsigned paged) static unsigned check_destroy_pinned_err(unsigned paged) { - H5F_t *file_ptr = NULL; + H5F_t *file_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("destroy cache with permanently pinned entry error (pgd aggr)"); @@ -12312,7 +12434,12 @@ check_destroy_pinned_err(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { protect_entry(file_ptr, 0, 0); unprotect_entry(file_ptr, 0, 0, H5C__PIN_ENTRY_FLAG); @@ -12358,8 +12485,10 @@ check_destroy_pinned_err(unsigned paged) if (!pass) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_destroy_pinned_err() */ /*------------------------------------------------------------------------- @@ -12376,7 +12505,8 @@ check_destroy_pinned_err(unsigned paged) static unsigned check_destroy_protected_err(unsigned paged) { - H5F_t *file_ptr = NULL; + H5F_t *file_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("destroy cache with protected entry error (paged aggregation)"); @@ -12395,7 +12525,12 @@ check_destroy_protected_err(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { /* Note: normally this call would go just before the series of * flushes prior to file close -- in particular, all entries * should be unprotected when this call is made. @@ -12449,8 +12584,10 @@ check_destroy_protected_err(unsigned paged) if (!pass) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_destroy_protected_err() */ /*------------------------------------------------------------------------- @@ -12471,6 +12608,7 @@ check_duplicate_insert_err(unsigned paged) H5F_t *file_ptr = NULL; test_entry_t *base_addr; test_entry_t *entry_ptr; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("duplicate entry insertion error (paged aggregation)"); @@ -12489,7 +12627,12 @@ check_duplicate_insert_err(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { protect_entry(file_ptr, 0, 0); if (pass) { @@ -12526,8 +12669,10 @@ check_duplicate_insert_err(unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_duplicate_insert_err() */ /*------------------------------------------------------------------------- @@ -12547,6 +12692,7 @@ check_double_pin_err(unsigned paged) herr_t result; H5F_t *file_ptr = NULL; test_entry_t *entry_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("pin a pinned entry error (paged aggregation)"); @@ -12566,7 +12712,12 @@ check_double_pin_err(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { protect_entry(file_ptr, 0, 0); unprotect_entry(file_ptr, 0, 0, H5C__PIN_ENTRY_FLAG); @@ -12608,8 +12759,10 @@ check_double_pin_err(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_double_pin_err() */ /*------------------------------------------------------------------------- @@ -12629,6 +12782,7 @@ check_double_unpin_err(unsigned paged) herr_t result; H5F_t *file_ptr = NULL; test_entry_t *entry_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("unpin an unpinned entry error (paged aggregation)"); @@ -12650,7 +12804,12 @@ check_double_unpin_err(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { protect_entry(file_ptr, 0, 0); entry_ptr = &((entries[0])[0]); @@ -12699,8 +12858,10 @@ check_double_unpin_err(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_double_unpin_err() */ /*------------------------------------------------------------------------- @@ -12720,6 +12881,7 @@ check_pin_entry_errs(unsigned paged) herr_t result; H5F_t *file_ptr = NULL; test_entry_t *entry_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("pin entry related errors (paged aggregation)"); @@ -12745,7 +12907,12 @@ check_pin_entry_errs(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { protect_entry(file_ptr, 0, 0); unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); @@ -12804,8 +12971,10 @@ check_pin_entry_errs(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_pin_entry_errs() */ /*------------------------------------------------------------------------- @@ -12825,6 +12994,7 @@ check_double_protect_err(unsigned paged) H5F_t *file_ptr = NULL; test_entry_t *entry_ptr = NULL; H5C_cache_entry_t *cache_entry_ptr; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("protect a protected entry error (paged aggregation)"); @@ -12843,7 +13013,12 @@ check_double_protect_err(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { protect_entry(file_ptr, 0, 0); entry_ptr = &((entries[0])[0]); @@ -12883,8 +13058,10 @@ check_double_protect_err(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_double_protect_err() */ /*------------------------------------------------------------------------- @@ -12904,6 +13081,7 @@ check_double_unprotect_err(unsigned paged) herr_t result; H5F_t *file_ptr = NULL; test_entry_t *entry_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("unprotect an unprotected entry error (paged aggregation)"); @@ -12922,7 +13100,12 @@ check_double_unprotect_err(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { protect_entry(file_ptr, 0, 0); unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); @@ -12958,8 +13141,10 @@ check_double_unprotect_err(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_double_unprotect_err() */ /*------------------------------------------------------------------------- @@ -12982,6 +13167,7 @@ check_mark_entry_dirty_errs(unsigned paged) herr_t result; H5F_t *file_ptr = NULL; test_entry_t *entry_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("mark entry dirty related errors (paged aggregation)"); @@ -13001,7 +13187,12 @@ check_mark_entry_dirty_errs(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { protect_entry(file_ptr, 0, 0); unprotect_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); @@ -13037,8 +13228,10 @@ check_mark_entry_dirty_errs(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_mark_entry_dirty_errs() */ /*------------------------------------------------------------------------- @@ -13058,6 +13251,7 @@ check_expunge_entry_errs(unsigned paged) herr_t result; H5F_t *file_ptr = NULL; test_entry_t *entry_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("expunge entry related errors (paged aggregation)"); @@ -13083,7 +13277,12 @@ check_expunge_entry_errs(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { entry_ptr = &((entries[0])[0]); protect_entry(file_ptr, 0, 0); @@ -13147,8 +13346,10 @@ check_expunge_entry_errs(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_expunge_entry_errs() */ /*------------------------------------------------------------------------- @@ -13171,6 +13372,7 @@ check_move_entry_errs(unsigned paged) test_entry_t *entry_0_0_ptr = NULL; test_entry_t *entry_0_1_ptr = NULL; test_entry_t *entry_1_0_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("move entry related errors (paged aggregation)"); @@ -13189,7 +13391,12 @@ check_move_entry_errs(unsigned paged) file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { insert_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); insert_entry(file_ptr, 0, 1, H5C__NO_FLAGS_SET); insert_entry(file_ptr, 1, 0, H5C__NO_FLAGS_SET); @@ -13220,6 +13427,9 @@ check_move_entry_errs(unsigned paged) if (pass) takedown_cache(file_ptr, false, false); + /* Pop API context */ + H5CX_pop(false); + /* Allocate a cache, protect an entry R/O, and then call * H5C_move_entry() to move it -- this should fail. * @@ -13232,7 +13442,12 @@ check_move_entry_errs(unsigned paged) file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); cache_ptr = file_ptr->shared->cache; + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { insert_entry(file_ptr, 0, 0, H5C__NO_FLAGS_SET); protect_entry_ro(file_ptr, 0, 0); @@ -13261,6 +13476,9 @@ check_move_entry_errs(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } /* end else */ + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_move_entry_errs() */ @@ -13281,6 +13499,7 @@ check_resize_entry_errs(unsigned paged) herr_t result; H5F_t *file_ptr = NULL; test_entry_t *entry_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("resize entry related errors (paged aggregation)"); @@ -13305,7 +13524,12 @@ check_resize_entry_errs(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { entry_ptr = &((entries[0])[0]); protect_entry(file_ptr, 0, 0); @@ -13358,8 +13582,10 @@ check_resize_entry_errs(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_resize_entry_errs() */ /*------------------------------------------------------------------------- @@ -13379,6 +13605,7 @@ check_unprotect_ro_dirty_err(unsigned paged) herr_t result; H5F_t *file_ptr = NULL; test_entry_t *entry_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("unprotect a read only entry dirty error (paged aggregation)"); @@ -13397,7 +13624,12 @@ check_unprotect_ro_dirty_err(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { protect_entry_ro(file_ptr, 0, 0); entry_ptr = &((entries[0])[0]); @@ -13424,6 +13656,9 @@ check_unprotect_ro_dirty_err(unsigned paged) takedown_cache(file_ptr, false, false); } + /* Pop API context */ + H5CX_pop(false); + /* allocate a another cache, protect an entry read only twice, and * then unprotect it with the dirtied flag set. This should fail. * Unprotect it with no flags set twice and then destroy the cache. @@ -13435,7 +13670,12 @@ check_unprotect_ro_dirty_err(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { protect_entry_ro(file_ptr, 0, 0); protect_entry_ro(file_ptr, 0, 0); @@ -13476,8 +13716,10 @@ check_unprotect_ro_dirty_err(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_unprotect_ro_dirty_err() */ /*------------------------------------------------------------------------- @@ -13497,6 +13739,7 @@ check_protect_ro_rw_err(unsigned paged) H5F_t *file_ptr = NULL; test_entry_t *entry_ptr = NULL; void *thing_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("protect a read only entry rw error (paged aggregation)"); @@ -13516,7 +13759,12 @@ check_protect_ro_rw_err(unsigned paged) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024), paged); + } + /* Push API context */ + H5CX_push(&api_ctx); + + if (pass) { protect_entry_ro(file_ptr, 0, 0); entry_ptr = &((entries[0])[0]); @@ -13556,8 +13804,10 @@ check_protect_ro_rw_err(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_protect_ro_rw_err() */ /*------------------------------------------------------------------------- @@ -13580,6 +13830,7 @@ check_protect_retries(unsigned paged) H5C_cache_entry_t *cache_entry_ptr = NULL; int32_t type; int32_t idx; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("protect an entry to verify retries (paged aggregation)"); @@ -13600,6 +13851,9 @@ check_protect_retries(unsigned paged) file_ptr->shared->retries_nbins = 1; } + /* Push API context */ + H5CX_push(&api_ctx); + /* Test only for this type which has a speculative load */ type = VARIABLE_ENTRY_TYPE; idx = 0; @@ -13683,8 +13937,10 @@ check_protect_retries(unsigned paged) fprintf(stdout, "%s: failure_msg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_protect_retries() */ /*------------------------------------------------------------------------- @@ -13701,10 +13957,11 @@ check_protect_retries(unsigned paged) static unsigned check_check_evictions_enabled_err(unsigned paged) { - herr_t result; - bool evictions_enabled; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; + herr_t result; + bool evictions_enabled; + H5F_t *file_ptr = NULL; + H5C_t *cache_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("get/set evictions enabled errors (paged aggregation)"); @@ -13734,6 +13991,9 @@ check_check_evictions_enabled_err(unsigned paged) cache_ptr = file_ptr->shared->cache; } + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { result = H5C_get_evictions_enabled(NULL, &evictions_enabled); @@ -13816,8 +14076,10 @@ check_check_evictions_enabled_err(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_evictions_enabled_err() */ /*------------------------------------------------------------------------- @@ -13896,6 +14158,7 @@ check_auto_cache_resize(bool cork_ageout, unsigned paged) /* bool apply_empty_reserve = */ true, /* double empty_reserve = */ 0.05}; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("automatic cache resizing (paged aggregation)"); @@ -13919,6 +14182,9 @@ check_auto_cache_resize(bool cork_ageout, unsigned paged) cache_ptr = file_ptr->shared->cache; } + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); if (result != SUCCEED) { @@ -17678,6 +17944,9 @@ check_auto_cache_resize(bool cork_ageout, unsigned paged) if (!pass) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_auto_cache_resize() */ @@ -17742,6 +18011,7 @@ check_auto_cache_resize_disable(unsigned paged) /* bool apply_empty_reserve = */ true, /* double empty_reserve = */ 0.05}; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("automatic cache resize disable (paged aggregation)"); @@ -17775,6 +18045,9 @@ check_auto_cache_resize_disable(unsigned paged) } } + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); @@ -20270,8 +20543,10 @@ check_auto_cache_resize_disable(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_auto_cache_resize_disable() */ /*------------------------------------------------------------------------- @@ -20336,6 +20611,7 @@ check_auto_cache_resize_epoch_markers(unsigned paged) /* bool apply_empty_reserve = */ true, /* double empty_reserve = */ 0.05}; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("automatic cache resize epoch marker management (paged aggr)"); @@ -20355,6 +20631,9 @@ check_auto_cache_resize_epoch_markers(unsigned paged) cache_ptr = file_ptr->shared->cache; } + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); @@ -20952,8 +21231,10 @@ check_auto_cache_resize_epoch_markers(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_auto_cache_resize_epoch_markers() */ /*------------------------------------------------------------------------- @@ -21017,6 +21298,7 @@ check_auto_cache_resize_input_errs(unsigned paged) H5C_auto_size_ctl_t invalid_auto_size_ctl; H5C_auto_size_ctl_t test_auto_size_ctl; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("automatic cache resize input errors (paged aggregation)"); @@ -21039,6 +21321,9 @@ check_auto_cache_resize_input_errs(unsigned paged) cache_ptr = file_ptr->shared->cache; } + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &ref_auto_size_ctl); @@ -23163,8 +23448,10 @@ check_auto_cache_resize_input_errs(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_auto_cache_resize_input_errs() */ /*------------------------------------------------------------------------- @@ -23235,6 +23522,7 @@ check_auto_cache_resize_aux_fcns(unsigned paged) /* bool apply_empty_reserve = */ true, /* double empty_reserve = */ 0.5}; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("automatic cache resize auxiliary functions (paged aggregation)"); @@ -23254,6 +23542,9 @@ check_auto_cache_resize_aux_fcns(unsigned paged) cache_ptr = file_ptr->shared->cache; } + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { result = H5C_set_cache_auto_resize_config(cache_ptr, &auto_size_ctl); @@ -23649,8 +23940,10 @@ check_auto_cache_resize_aux_fcns(unsigned paged) fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_auto_cache_resize_aux_fcns() */ /*------------------------------------------------------------------------- @@ -23687,6 +23980,7 @@ check_metadata_blizzard_absence(bool fill_via_insertion, unsigned paged) int32_t checkpoint = 0; int32_t entry_idx = 0; int32_t i; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ /* Expected deserialized status of entries depends on how they get into * the cache. Insertions = not deserialized, protect/unprotect = deserialized. @@ -23766,6 +24060,9 @@ check_metadata_blizzard_absence(bool fill_via_insertion, unsigned paged) cache_ptr = file_ptr->shared->cache; } + /* Push API context */ + H5CX_push(&api_ctx); + if (show_progress) /* 1 */ fprintf(stdout, "%s: check point %d -- pass %d\n", __func__, checkpoint++, pass); @@ -24378,8 +24675,10 @@ check_metadata_blizzard_absence(bool fill_via_insertion, unsigned paged) H5_FAILED(); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_metadata_blizzard_absence() */ /*------------------------------------------------------------------------- @@ -24413,6 +24712,7 @@ check_flush_deps(unsigned paged) { PICO_ENTRY_TYPE, 4, PICO_ENTRY_SIZE, false, true, false, false, false, false, false, false, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, false} }; /* clang-format on */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("flush dependencies (paged aggregation)"); @@ -24433,6 +24733,9 @@ check_flush_deps(unsigned paged) if (!pass) CACHE_ERROR("setup_cache failed") + /* Push API context */ + H5CX_push(&api_ctx); + /* Insert entries to work with into the cache */ for (u = 0; u < 5; u++) { insert_entry(file_ptr, entry_type, (int32_t)u, H5C__NO_FLAGS_SET); @@ -26299,6 +26602,9 @@ done: fprintf(stdout, "%s.\n", failure_mssg); } /* end else */ + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_flush_deps() */ @@ -26315,9 +26621,10 @@ done: static unsigned check_flush_deps_err(unsigned paged) { - H5F_t *file_ptr = NULL; /* File for this test */ - int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */ - unsigned test_count; /* Test iteration variable */ + H5F_t *file_ptr = NULL; /* File for this test */ + int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */ + unsigned test_count; /* Test iteration variable */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("flush dependency errors (paged aggregation)"); @@ -26339,6 +26646,9 @@ check_flush_deps_err(unsigned paged) if (!pass) CACHE_ERROR("setup_cache failed") + /* Push API context */ + H5CX_push(&api_ctx); + /* Insert entries to work with into the cache */ for (u = 0; u < 10; u++) { insert_entry(file_ptr, entry_type, (int32_t)u, H5C__NO_FLAGS_SET); @@ -26549,11 +26859,17 @@ check_flush_deps_err(unsigned paged) if (!pass) CACHE_ERROR("takedown_cache failed") file_ptr = NULL; + + /* Pop API context */ + H5CX_pop(false); } /* end for */ done: - if (file_ptr) + if (file_ptr) { takedown_cache(file_ptr, false, false); + /* Pop API context */ + H5CX_pop(false); + } if (pass) PASSED(); @@ -26596,6 +26912,7 @@ check_flush_deps_order(unsigned paged) { PICO_ENTRY_TYPE, 4, PICO_ENTRY_SIZE, false, true, false, false, false, false, false, false, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, false} }; /* clang-format on */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("flush dependencies flush order (paged aggregation)"); @@ -26615,6 +26932,9 @@ check_flush_deps_order(unsigned paged) if (!pass) CACHE_ERROR("setup_cache failed") + /* Push API context */ + H5CX_push(&api_ctx); + /* Insert entries to work with into the cache */ for (u = 0; u < 5; u++) { insert_entry(file_ptr, entry_type, (int32_t)u, H5C__NO_FLAGS_SET); @@ -29289,6 +29609,9 @@ done: fprintf(stdout, "%s.\n", failure_mssg); } /* end else */ + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_flush_deps_order() */ @@ -29323,6 +29646,7 @@ check_notify_cb(unsigned paged) { NOTIFY_ENTRY_TYPE, 4, NOTIFY_ENTRY_SIZE, false, true, false, false, false, false, false, false, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, 0, 0, 0, -1, false} }; /* clang-format on */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("'notify' callback (paged)"); @@ -29345,6 +29669,9 @@ check_notify_cb(unsigned paged) if (!pass) CACHE_ERROR("setup_cache failed") + /* Push API context */ + H5CX_push(&api_ctx); + /* Insert entries to work with into the cache */ for (u = 0; u < 5; u++) { insert_entry(file_ptr, entry_type, (int32_t)u, H5C__NO_FLAGS_SET); @@ -29502,6 +29829,9 @@ done: fprintf(stdout, "%s.\n", failure_mssg); } /* end else */ + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_notify_cb() */ @@ -29530,6 +29860,7 @@ check_metadata_cork(bool fill_via_insertion, unsigned paged) int32_t checkpoint = 0; int32_t entry_idx = 0; int32_t i; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ /* Expected deserialized status of entries depends on how they get into * the cache. Insertions = not deserialized, protect/unprotect = deserialized. @@ -29601,6 +29932,9 @@ check_metadata_cork(bool fill_via_insertion, unsigned paged) cache_ptr = file_ptr->shared->cache; } + /* Push API context */ + H5CX_push(&api_ctx); + /* Cork the cache entry type */ cork_entry_type(file_ptr, entry_type); @@ -30089,8 +30423,10 @@ check_metadata_cork(bool fill_via_insertion, unsigned paged) H5_FAILED(); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_metadata_cork() */ /*------------------------------------------------------------------------- @@ -30119,7 +30455,8 @@ check_metadata_cork(bool fill_via_insertion, unsigned paged) static unsigned check_entry_deletions_during_scans(unsigned paged) { - H5F_t *file_ptr = NULL; + H5F_t *file_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (paged) TESTING("entry deletion during list scan detection and adaption (par)"); @@ -30140,6 +30477,9 @@ check_entry_deletions_during_scans(unsigned paged) file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); } + /* Push API context */ + H5CX_push(&api_ctx); + /* run the tests. This set of tests is somewhat eclectic, as * we are trying to test all locations where the deletion of * an entry from the cache as a side effect of the fluch of @@ -30180,8 +30520,10 @@ check_entry_deletions_during_scans(unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } - return (unsigned)!pass; + /* Pop API context */ + H5CX_pop(false); + return (unsigned)!pass; } /* check_entry_deletions_during_scans() */ /*------------------------------------------------------------------------- @@ -31537,8 +31879,8 @@ check_stats(unsigned paged) { #if H5C_COLLECT_CACHE_STATS - - H5F_t *file_ptr = NULL; + H5F_t *file_ptr = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ #endif /* H5C_COLLECT_CACHE_STATS */ @@ -31555,6 +31897,9 @@ check_stats(unsigned paged) file_ptr = setup_cache((size_t)(2 * 1024 * 1024), (size_t)(1 * 1024 * 1024), paged); + /* Push API context */ + H5CX_push(&api_ctx); + if (pass) { check_stats__smoke_check_1(file_ptr); @@ -31577,6 +31922,9 @@ check_stats(unsigned paged) fprintf(stdout, "%s(): failure_mssg = \"%s\".\n", __func__, failure_mssg); } + /* Pop API context */ + H5CX_pop(false); + #else /* H5C_COLLECT_CACHE_STATS */ SKIPPED(); @@ -31586,7 +31934,6 @@ check_stats(unsigned paged) #endif /* H5C_COLLECT_CACHE_STATS */ return (unsigned)!pass; - } /* check_stats() */ /*------------------------------------------------------------------------- @@ -32022,17 +32369,18 @@ check_write_permitted(const H5F_t H5_ATTR_UNUSED *f, bool *write_permitted_ptr) H5F_t * setup_cache(size_t max_cache_size, size_t min_clean_size, unsigned paged) { - char filename[512]; - bool show_progress = false; - bool verbose = true; - int mile_stone = 1; - hid_t fid = H5I_INVALID_HID; - H5F_t *file_ptr = NULL; - H5C_t *cache_ptr = NULL; - H5F_t *ret_val = NULL; - haddr_t actual_base_addr; - hid_t fapl_id = H5P_DEFAULT; - hid_t fcpl_id = H5P_DEFAULT; + char filename[512]; + bool show_progress = false; + bool verbose = true; + int mile_stone = 1; + hid_t fid = H5I_INVALID_HID; + H5F_t *file_ptr = NULL; + H5C_t *cache_ptr = NULL; + H5F_t *ret_val = NULL; + haddr_t actual_base_addr; + hid_t fapl_id = H5P_DEFAULT; + hid_t fcpl_id = H5P_DEFAULT; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (show_progress) /* 1 */ fprintf(stdout, "%s() - %0d -- pass = %d\n", __func__, mile_stone++, (int)pass); @@ -32123,7 +32471,7 @@ setup_cache(size_t max_cache_size, size_t min_clean_size, unsigned paged) } /* end if */ /* Push API context */ - H5CX_push(); + H5CX_push(&api_ctx); if (show_progress) /* 4 */ fprintf(stdout, "%s() - %0d -- pass = %d\n", __func__, mile_stone++, (int)pass); @@ -32348,7 +32696,6 @@ takedown_cache(H5F_t *file_ptr, bool dump_stats, bool dump_detailed_stats) } } } - } /* takedown_cache() */ /*------------------------------------------------------------------------- diff --git a/test/cache_common.h b/test/cache_common.h index 61a79b7328..a55ebd8ad2 100644 --- a/test/cache_common.h +++ b/test/cache_common.h @@ -21,6 +21,7 @@ #define H5F_FRIEND /*suppress error about including H5Fpkg */ /* Include library header files */ +#include "H5private.h" #include "H5ACprivate.h" #include "H5MFprivate.h" #include "H5Cpkg.h" diff --git a/test/cache_tagging.c b/test/cache_tagging.c index b6a6396da5..78bbbee4af 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -16,12 +16,12 @@ #define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING -#include "H5Fpkg.h" #include "h5test.h" #include "cache_common.h" #include "H5CXprivate.h" /* API Contexts */ +#include "H5Fpkg.h" #include "H5HLprivate.h" #include "H5VLnative_private.h" /* Native VOL connector */ @@ -4353,13 +4353,14 @@ check_invalid_tag_application(void) { #ifdef H5C_DO_TAGGING_SANITY_CHECKS /* Variables */ - H5F_t *f = NULL; - hid_t fid = H5I_INVALID_HID; - haddr_t addr; - H5HL_t *lheap = NULL; - hid_t fapl = H5I_INVALID_HID; /* File access prop list */ - bool api_ctx_pushed = false; /* Whether API context pushed */ -#endif /* H5C_DO_TAGGING_SANITY_CHECKS */ + H5F_t *f = NULL; + hid_t fid = H5I_INVALID_HID; + haddr_t addr; + H5HL_t *lheap = NULL; + hid_t fapl = H5I_INVALID_HID; /* File access prop list */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ +#endif /* H5C_DO_TAGGING_SANITY_CHECKS */ /* Testing Macro */ TESTING("failure on invalid tag application"); @@ -4377,7 +4378,7 @@ check_invalid_tag_application(void) TEST_ERROR; /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) TEST_ERROR; api_ctx_pushed = true; diff --git a/test/chunk_info.c b/test/chunk_info.c index 3da2d9d258..335542c000 100644 --- a/test/chunk_info.c +++ b/test/chunk_info.c @@ -36,9 +36,9 @@ */ #define H5D_FRIEND #define H5D_TESTING /* to use H5D__ functions */ -#include "H5Dpkg.h" #include "h5test.h" +#include "H5Dpkg.h" #ifdef H5_HAVE_FILTER_DEFLATE #if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER) #define H5_ZLIB_HEADER "zlib.h" diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index 5596c955da..ec253c5e60 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -13,12 +13,12 @@ /* See H5private.h for how to include headers */ #undef NDEBUG -#define H5T_FRIEND /*suppress error about including H5Tpkg */ -#include "H5Tpkg.h" /*to turn off hardware conversions*/ -#include "H5Tconv_compound.h" -#include "H5Iprivate.h" +#define H5T_FRIEND /*suppress error about including H5Tpkg */ #include "h5test.h" +#include "H5Iprivate.h" +#include "H5Tpkg.h" /*to turn off hardware conversions*/ +#include "H5Tconv_compound.h" static const char *FILENAME[] = {"cmpd_dset", "src_subset", "dst_subset", "select_cmpd_dset", NULL}; diff --git a/test/dsets.c b/test/dsets.c index 4ff2fe625c..07e653aa2b 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -2845,6 +2845,7 @@ test_missing_filter(hid_t file) size_t i, j; /* Local index variables */ herr_t ret; /* Generic return value */ const char *testfile = H5_get_srcdir_filename(FILE_DEFLATE_NAME); /* Corrected test file name */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ bool api_ctx_pushed = false; /* Whether API context pushed */ TESTING("dataset access with missing filter"); @@ -2859,7 +2860,7 @@ test_missing_filter(hid_t file) } /* end if */ /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/earray.c b/test/earray.c index b7592f26f7..cd97413c22 100644 --- a/test/earray.c +++ b/test/earray.c @@ -2297,6 +2297,7 @@ main(void) earray_iter_type_t curr_iter; /* Current iteration type being worked on */ hid_t fapl = H5I_INVALID_HID; /* File access property list for data files */ unsigned nerrors = 0; /* Cumulative error count */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ bool api_ctx_pushed = false; /* Whether API context pushed */ /* Reset library */ @@ -2307,7 +2308,7 @@ main(void) h5_fixname(FILENAME[0], fapl, filename_g, sizeof(filename_g)); /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/efc.c b/test/efc.c index 2d8c62682c..7b6c344731 100644 --- a/test/efc.c +++ b/test/efc.c @@ -2635,11 +2635,12 @@ error: int main(void) { - unsigned nerrors = 0; /* track errors */ - H5P_genplist_t *plist; /* Property list pointer for FAPL */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - int i; /* iterator */ + unsigned nerrors = 0; /* track errors */ + H5P_genplist_t *plist; /* Property list pointer for FAPL */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + int i; /* iterator */ /* Test Setup */ puts("Testing the external file cache"); @@ -2662,7 +2663,7 @@ main(void) h5_fixname(FILENAME[5], fapl_id, filename[5], PATH_MAX); /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/farray.c b/test/farray.c index 06ff7e524c..5751ffca25 100644 --- a/test/farray.c +++ b/test/farray.c @@ -1628,6 +1628,7 @@ main(void) farray_iter_type_t curr_iter; /* Current iteration type being worked on */ hid_t fapl = H5I_INVALID_HID; /* File access property list for data files */ unsigned nerrors = 0; /* Cumulative error count */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ bool api_ctx_pushed = false; /* Whether API context pushed */ /* Reset library */ @@ -1638,7 +1639,7 @@ main(void) h5_fixname(FILENAME[0], fapl, filename_g, sizeof(filename_g)); /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/fheap.c b/test/fheap.c index 9f02d9f48e..bdca2c7db2 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -15958,8 +15958,9 @@ main(void) unsigned nerrors = 0; /* Cumulative error count */ unsigned num_pb_fs = 1; /* The number of settings to test for page buffering and file space handling */ const char *driver_name; /* Environment variable */ - bool contig_addr_vfd; /* Whether VFD used has a contiguous address space */ - bool api_ctx_pushed = false; /* Whether API context pushed */ + bool contig_addr_vfd; /* Whether VFD used has a contiguous address space */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ int test_express; /* Don't run this test using certain file drivers */ @@ -15999,7 +16000,7 @@ main(void) init_large_cparam(&large_cparam); /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/freespace.c b/test/freespace.c index 278d811cc2..ff8f8cddd8 100644 --- a/test/freespace.c +++ b/test/freespace.c @@ -2874,9 +2874,10 @@ error: int main(void) { - hid_t fapl = H5I_INVALID_HID; /* File access property list for data files */ - unsigned nerrors = 0; /* Cumulative error count */ - bool api_ctx_pushed = false; /* Whether API context pushed */ + hid_t fapl = H5I_INVALID_HID; /* File access property list for data files */ + unsigned nerrors = 0; /* Cumulative error count */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ h5_test_init(); @@ -2886,7 +2887,7 @@ main(void) } /* end if */ /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/gheap.c b/test/gheap.c index 9cd94ebb04..46035e04d2 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -557,16 +557,17 @@ error: int main(void) { - int nerrors = 0; - hid_t fapl_id = H5I_INVALID_HID; - bool api_ctx_pushed = false; /* Whether API context pushed */ + int nerrors = 0; + hid_t fapl_id = H5I_INVALID_HID; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ h5_test_init(); if ((fapl_id = h5_fileaccess()) < 0) goto error; /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/lheap.c b/test/lheap.c index 7cdbc09c5f..b8e613c218 100644 --- a/test/lheap.c +++ b/test/lheap.c @@ -41,17 +41,18 @@ static const char *FILENAME[] = {"lheap", NULL}; int main(void) { - hid_t fapl = H5P_DEFAULT; /* file access properties */ - hid_t file = H5I_INVALID_HID; /* hdf5 file */ - H5F_t *f = NULL; /* hdf5 file pointer */ - char filename[1024]; /* file name */ - haddr_t heap_addr; /* local heap address */ - H5HL_t *heap = NULL; /* local heap */ - size_t obj[NOBJS]; /* offsets within the heap */ - int i, j; /* miscellaneous counters */ - char buf[1024]; /* the value to store */ - const char *s; /* value to read */ - bool api_ctx_pushed = false; /* Whether API context pushed */ + hid_t fapl = H5P_DEFAULT; /* file access properties */ + hid_t file = H5I_INVALID_HID; /* hdf5 file */ + H5F_t *f = NULL; /* hdf5 file pointer */ + char filename[1024]; /* file name */ + haddr_t heap_addr; /* local heap address */ + H5HL_t *heap = NULL; /* local heap */ + size_t obj[NOBJS]; /* offsets within the heap */ + int i, j; /* miscellaneous counters */ + char buf[1024]; /* the value to store */ + const char *s; /* value to read */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ bool driver_is_default_compatible; /* Reset library */ @@ -59,7 +60,7 @@ main(void) fapl = h5_fileaccess(); /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/mf.c b/test/mf.c index b4c5845e66..74dca0a487 100644 --- a/test/mf.c +++ b/test/mf.c @@ -9126,12 +9126,13 @@ error: int main(void) { - hid_t fapl = H5I_INVALID_HID; /* File access property list for data files */ - hid_t new_fapl = H5I_INVALID_HID; /* File access property list for alignment & aggr setting */ - unsigned nerrors = 0; /* Cumulative error count */ - test_type_t curr_test; /* Current test being worked on */ - const char *driver_name; /* File Driver value from environment */ - bool api_ctx_pushed = false; /* Whether API context pushed */ + hid_t fapl = H5I_INVALID_HID; /* File access property list for data files */ + hid_t new_fapl = H5I_INVALID_HID; /* File access property list for alignment & aggr setting */ + unsigned nerrors = 0; /* Cumulative error count */ + test_type_t curr_test; /* Current test being worked on */ + const char *driver_name; /* File Driver value from environment */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ /* Get the VFD to use */ driver_name = h5_get_test_driver_name(); @@ -9141,7 +9142,7 @@ main(void) fapl = h5_fileaccess(); /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/ntypes.c b/test/ntypes.c index 671b406c9b..3fcd40ffb4 100644 --- a/test/ntypes.c +++ b/test/ntypes.c @@ -335,9 +335,9 @@ test_compound_dtype2(hid_t file) TESTING("nested compound datatype"); /* Allocate space for the points & check arrays */ - if (NULL == (points = (s1 *)malloc(sizeof(s1) * DIM0 * DIM1))) + if (NULL == (points = malloc(sizeof(s1) * DIM0 * DIM1))) TEST_ERROR; - if (NULL == (check = (s1 *)calloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (check = calloc(DIM0 * DIM1, sizeof(s1)))) TEST_ERROR; /* Initialize the dataset */ @@ -535,7 +535,7 @@ test_compound_dtype2(hid_t file) * Cray */ if (NULL == (tmp = malloc(DIM0 * DIM1 * H5Tget_size(native_type)))) TEST_ERROR; - if (NULL == (bkg = calloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (bkg = calloc(DIM0 * DIM1, sizeof(s1)))) TEST_ERROR; if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) @@ -648,9 +648,9 @@ test_compound_dtype(hid_t file) TESTING("compound datatype"); /* Allocate space for the points & check arrays */ - if (NULL == (points = (s1 *)malloc(sizeof(s1) * DIM0 * DIM1))) + if (NULL == (points = malloc(sizeof(s1) * DIM0 * DIM1))) TEST_ERROR; - if (NULL == (check = (s1 *)calloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (check = calloc(DIM0 * DIM1, sizeof(s1)))) TEST_ERROR; /* Initialize the dataset */ @@ -754,7 +754,7 @@ test_compound_dtype(hid_t file) * Cray */ if (NULL == (tmp = malloc(DIM0 * DIM1 * H5Tget_size(native_type)))) TEST_ERROR; - if (NULL == (bkg = calloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (bkg = calloc(DIM0 * DIM1, sizeof(s1)))) TEST_ERROR; if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) @@ -856,9 +856,9 @@ test_compound_dtype3(hid_t file) TESTING("compound datatype with array as field"); /* Allocate space for the points & check arrays */ - if (NULL == (points = (s1 *)malloc(sizeof(s1) * DIM0 * DIM1))) + if (NULL == (points = malloc(sizeof(s1) * DIM0 * DIM1))) TEST_ERROR; - if (NULL == (check = (s1 *)calloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (check = calloc(DIM0 * DIM1, sizeof(s1)))) TEST_ERROR; /* Initialize the dataset */ @@ -982,7 +982,7 @@ test_compound_dtype3(hid_t file) * Cray */ if (NULL == (tmp = malloc(DIM0 * DIM1 * H5Tget_size(native_type)))) TEST_ERROR; - if (NULL == (bkg = calloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (bkg = calloc(DIM0 * DIM1, sizeof(s1)))) TEST_ERROR; if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) @@ -1091,9 +1091,9 @@ test_compound_opaque(hid_t file) TESTING("compound datatype with opaque field"); /* Allocate space for the points & check arrays */ - if (NULL == (points = (s1 *)malloc(sizeof(s1) * DIM0 * DIM1))) + if (NULL == (points = malloc(sizeof(s1) * DIM0 * DIM1))) TEST_ERROR; - if (NULL == (check = (s1 *)calloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (check = calloc(DIM0 * DIM1, sizeof(s1)))) TEST_ERROR; /* Initialize the dataset */ @@ -1208,7 +1208,7 @@ test_compound_opaque(hid_t file) * Cray */ if (NULL == (tmp = malloc(DIM0 * DIM1 * H5Tget_size(native_type)))) TEST_ERROR; - if (NULL == (bkg = calloc(sizeof(s1), DIM0 * DIM1))) + if (NULL == (bkg = calloc(DIM0 * DIM1, sizeof(s1)))) TEST_ERROR; if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0) @@ -1469,9 +1469,9 @@ test_array_dtype(hid_t file) TESTING("array of compound datatype"); /* Allocate space for the points & check arrays */ - if (NULL == (points = (s1 *)malloc(sizeof(s1) * DIM0 * DIM1 * 5))) + if (NULL == (points = malloc(sizeof(s1) * DIM0 * DIM1 * 5))) TEST_ERROR; - if (NULL == (check = (s1 *)calloc(sizeof(s1), DIM0 * DIM1 * 5))) + if (NULL == (check = calloc(DIM0 * DIM1 * 5, sizeof(s1)))) TEST_ERROR; /* Initialize the dataset */ @@ -2428,9 +2428,9 @@ test_refer_dtype2(hid_t file) TESTING("dataset region reference"); /* Allocate write & read buffers */ - if (NULL == (dwbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2))) + if (NULL == (dwbuf = malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2))) TEST_ERROR; - if (NULL == (drbuf = (uint8_t *)calloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2))) + if (NULL == (drbuf = calloc(SPACE2_DIM1 * SPACE2_DIM2, sizeof(uint8_t)))) TEST_ERROR; /* Create dataspace for datasets */ diff --git a/test/ohdr.c b/test/ohdr.c index fe36b45095..6df628748f 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -1834,9 +1834,10 @@ main(void) H5O_loc_t oh_loc; /* Object header locations */ H5F_libver_t low, high; /* File format bounds */ time_t time_new, ro; - int i; /* Local index variable */ - bool api_ctx_pushed = false; /* Whether API context pushed */ - herr_t ret; /* Generic return value */ + int i; /* Local index variable */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ + herr_t ret; /* Generic return value */ /* Get the VFD to use */ driver_name = h5_get_test_driver_name(); @@ -1850,7 +1851,7 @@ main(void) h5_fixname(FILENAME[0], fapl, filename, sizeof filename); /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/page_buffer.c b/test/page_buffer.c index 06176e7f42..6e9c17df8d 100644 --- a/test/page_buffer.c +++ b/test/page_buffer.c @@ -2051,6 +2051,7 @@ main(void) hid_t fapl = H5I_INVALID_HID; /* File access property list for data files */ unsigned nerrors = 0; /* Cumulative error count */ const char *driver_name = NULL; /* File Driver value from environment */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ bool api_ctx_pushed = false; /* Whether API context pushed */ h5_test_init(); @@ -2075,7 +2076,7 @@ main(void) } /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/titerate.c b/test/titerate.c index e3d4ad72e6..0450500bd3 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -698,7 +698,7 @@ test_iter_group_large(hid_t fapl) } s1_t; /* Allocate & initialize array */ - names = (iter_info *)calloc(sizeof(iter_info), (ITER_NGROUPS + 2)); + names = (iter_info *)calloc((ITER_NGROUPS + 2), sizeof(iter_info)); CHECK_PTR(names, "calloc"); /* Output message about test being performed */ diff --git a/test/trefer.c b/test/trefer.c index a1a8f7a3a3..ac35ea5978 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -124,10 +124,10 @@ test_reference_params(void) MESSAGE(5, ("Testing Reference Parameters\n")); /* Allocate write & read buffers */ - wbuf = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - rbuf = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - tbuf = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - obuf = calloc(sizeof(unsigned), SPACE1_DIM1); + wbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + rbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + tbuf = (H5R_ref_t *)calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + obuf = calloc(SPACE1_DIM1, sizeof(unsigned)); for (i = 0; i < SPACE1_DIM1; i++) obuf[i] = i * 3; @@ -468,10 +468,10 @@ test_reference_obj(void) MESSAGE(5, ("Testing Object Reference Functions\n")); /* Allocate write & read buffers */ - wbuf = calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - rbuf = calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - ibuf = calloc(sizeof(unsigned), SPACE1_DIM1); - obuf = calloc(sizeof(unsigned), SPACE1_DIM1); + wbuf = calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + rbuf = calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + ibuf = calloc(SPACE1_DIM1, sizeof(unsigned)); + obuf = calloc(SPACE1_DIM1, sizeof(unsigned)); for (i = 0; i < SPACE1_DIM1; i++) obuf[i] = i * 3; @@ -571,7 +571,7 @@ test_reference_obj(void) VERIFY(obj_type, H5O_TYPE_NAMED_DATATYPE, "H5Rget_obj_type3"); /* Check copying a reference */ - wbuf_cp = calloc(sizeof(H5R_ref_t), 1); + wbuf_cp = calloc(1, sizeof(H5R_ref_t)); ret = H5Rcopy(&wbuf[0], &wbuf_cp[0]); CHECK(ret, FAIL, "H5Rcopy"); @@ -838,9 +838,9 @@ test_reference_vlen_obj(void) MESSAGE(5, ("Testing Object Reference Functions within VLEN type\n")); /* Allocate write & read buffers */ - wbuf = calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - ibuf = calloc(sizeof(unsigned), SPACE1_DIM1); - obuf = calloc(sizeof(unsigned), SPACE1_DIM1); + wbuf = calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + ibuf = calloc(SPACE1_DIM1, sizeof(unsigned)); + obuf = calloc(SPACE1_DIM1, sizeof(unsigned)); for (i = 0; i < SPACE1_DIM1; i++) obuf[i] = i * 3; @@ -1102,8 +1102,8 @@ test_reference_cmpnd_obj(void) MESSAGE(5, ("Testing Object Reference Functions within compound type\n")); /* Allocate write & read buffers */ - ibuf = calloc(sizeof(unsigned), SPACE1_DIM1); - obuf = calloc(sizeof(unsigned), SPACE1_DIM1); + ibuf = calloc(SPACE1_DIM1, sizeof(unsigned)); + obuf = calloc(SPACE1_DIM1, sizeof(unsigned)); for (i = 0; i < SPACE1_DIM1; i++) obuf[i] = i * 3; @@ -1411,10 +1411,10 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) MESSAGE(5, ("Testing Dataset Region Reference Functions\n")); /* Allocate write & read buffers */ - wbuf = calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - rbuf = calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - dwbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); - drbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); + wbuf = calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + rbuf = calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + dwbuf = (uint8_t *)calloc((size_t)(SPACE2_DIM1 * SPACE2_DIM2), sizeof(uint8_t)); + drbuf = (uint8_t *)calloc((size_t)(SPACE2_DIM1 * SPACE2_DIM2), sizeof(uint8_t)); for (tu8 = dwbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++) *tu8++ = (uint8_t)(i * 3); @@ -1867,10 +1867,10 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) MESSAGE(5, ("Testing 1-D Dataset Region Reference Functions\n")); /* Allocate write & read buffers */ - wbuf = calloc(sizeof(H5R_ref_t), (size_t)SPACE1_DIM1); - rbuf = calloc(sizeof(H5R_ref_t), (size_t)SPACE1_DIM1); - dwbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); - drbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); + wbuf = calloc((size_t)SPACE1_DIM1, sizeof(H5R_ref_t)); + rbuf = calloc((size_t)SPACE1_DIM1, sizeof(H5R_ref_t)); + dwbuf = (uint8_t *)calloc((size_t)SPACE3_DIM1, sizeof(uint8_t)); + drbuf = (uint8_t *)calloc((size_t)SPACE3_DIM1, sizeof(uint8_t)); for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) *tu8++ = (uint8_t)(i * 3); @@ -3125,10 +3125,10 @@ test_reference_compat_conv(void) } /* Allocate write & read buffers */ - wbuf_obj = (hobj_ref_t *)calloc(sizeof(hobj_ref_t), SPACE1_DIM1); - rbuf_obj = calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - wbuf_reg = calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - rbuf_reg = calloc(sizeof(H5R_ref_t), SPACE1_DIM1); + wbuf_obj = calloc(SPACE1_DIM1, sizeof(hobj_ref_t)); + rbuf_obj = calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + wbuf_reg = calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t)); + rbuf_reg = calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); /* Create dataspace for datasets */ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); @@ -3434,17 +3434,17 @@ test_reference_perf(void) MESSAGE(5, ("Testing Object Reference Performance\n")); /* Allocate write & read buffers */ - wbuf = calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - obuf = calloc(sizeof(unsigned), SPACE1_DIM1); - ibuf = calloc(sizeof(unsigned), SPACE1_DIM1); - wbuf_deprec = (hobj_ref_t *)calloc(sizeof(hobj_ref_t), SPACE1_DIM1); - rbuf = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - rbuf_deprec = (hobj_ref_t *)calloc(sizeof(hobj_ref_t), SPACE1_DIM1); - tbuf = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - wbuf_reg = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - rbuf_reg = (H5R_ref_t *)calloc(sizeof(H5R_ref_t), SPACE1_DIM1); - wbuf_reg_deprec = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - rbuf_reg_deprec = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + wbuf = calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + obuf = calloc(SPACE1_DIM1, sizeof(unsigned)); + ibuf = calloc(SPACE1_DIM1, sizeof(unsigned)); + wbuf_deprec = calloc(SPACE1_DIM1, sizeof(hobj_ref_t)); + rbuf = calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + rbuf_deprec = calloc(SPACE1_DIM1, sizeof(hobj_ref_t)); + tbuf = calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + wbuf_reg = calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + rbuf_reg = calloc(SPACE1_DIM1, sizeof(H5R_ref_t)); + wbuf_reg_deprec = calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t)); + rbuf_reg_deprec = calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t)); for (i = 0; i < SPACE1_DIM1; i++) obuf[i] = i * 3; diff --git a/test/trefer_deprec.c b/test/trefer_deprec.c index 81da6bc3e1..3f932f53b9 100644 --- a/test/trefer_deprec.c +++ b/test/trefer_deprec.c @@ -623,10 +623,10 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) MESSAGE(5, ("Testing Dataset Region Reference Functions\n")); /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); - rbuf = (hdset_reg_ref_t *)malloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); - dwbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); - drbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); + wbuf = calloc((size_t)SPACE1_DIM1, sizeof(hdset_reg_ref_t)); + rbuf = malloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + dwbuf = malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); + drbuf = calloc((size_t)(SPACE2_DIM1 * SPACE2_DIM2), sizeof(uint8_t)); /* Create file access property list */ fapl = H5Pcreate(H5P_FILE_ACCESS); @@ -1064,10 +1064,10 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) MESSAGE(5, ("Testing 1-D Dataset Region Reference Functions\n")); /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); - rbuf = (hdset_reg_ref_t *)malloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); - dwbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE3_DIM1); - drbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); + wbuf = calloc((size_t)SPACE1_DIM1, sizeof(hdset_reg_ref_t)); + rbuf = malloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + dwbuf = malloc(sizeof(uint8_t) * SPACE3_DIM1); + drbuf = calloc((size_t)SPACE3_DIM1, sizeof(uint8_t)); /* Create the file access property list */ fapl = H5Pcreate(H5P_FILE_ACCESS); @@ -1636,10 +1636,10 @@ test_reference_compat(void) MESSAGE(5, ("Testing Deprecated Object Reference Functions\n")); /* Allocate write & read buffers */ - wbuf_obj = (hobj_ref_t *)calloc(sizeof(hobj_ref_t), SPACE1_DIM1); - rbuf_obj = (hobj_ref_t *)malloc(sizeof(hobj_ref_t) * SPACE1_DIM1); - wbuf_reg = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - rbuf_reg = (hdset_reg_ref_t *)malloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + wbuf_obj = calloc(SPACE1_DIM1, sizeof(hobj_ref_t)); + rbuf_obj = malloc(sizeof(hobj_ref_t) * SPACE1_DIM1); + wbuf_reg = calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t)); + rbuf_reg = malloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); /* Create file */ fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); diff --git a/test/tselect.c b/test/tselect.c index 1ce0655173..6f9bc6f142 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -249,7 +249,7 @@ test_select_hyper(hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); + rbuf = (uint8_t *)calloc((size_t)(SPACE3_DIM1 * SPACE3_DIM2), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -503,7 +503,7 @@ test_select_point(hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); + rbuf = (uint8_t *)calloc((size_t)(SPACE3_DIM1 * SPACE3_DIM2), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -865,7 +865,7 @@ test_select_all(hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE4_DIM1 * SPACE4_DIM2 * SPACE4_DIM3); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE4_DIM1 * SPACE4_DIM2 * SPACE4_DIM3)); + rbuf = (uint8_t *)calloc((size_t)(SPACE4_DIM1 * SPACE4_DIM2 * SPACE4_DIM3), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -952,7 +952,7 @@ test_select_all_hyper(hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); + rbuf = (uint8_t *)calloc((size_t)(SPACE3_DIM1 * SPACE3_DIM2), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -1106,7 +1106,7 @@ test_select_combo(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); + rbuf = (uint8_t *)calloc((size_t)(SPACE3_DIM1 * SPACE3_DIM2), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -1301,7 +1301,7 @@ test_select_hyper_stride(hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint16_t *)malloc(sizeof(uint16_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint16_t *)calloc(sizeof(uint16_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); + rbuf = (uint16_t *)calloc((size_t)(SPACE3_DIM1 * SPACE3_DIM2), sizeof(uint16_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -1447,7 +1447,7 @@ test_select_hyper_contig(hid_t dset_type, hid_t xfer_plist) /* Allocate write & read buffers */ wbuf = (uint16_t *)malloc(sizeof(uint16_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint16_t *)calloc(sizeof(uint16_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); + rbuf = (uint16_t *)calloc((size_t)(SPACE2_DIM1 * SPACE2_DIM2), sizeof(uint16_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -1588,7 +1588,7 @@ test_select_hyper_contig2(hid_t dset_type, hid_t xfer_plist) wbuf = (uint16_t *)malloc(sizeof(uint16_t) * SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4); CHECK_PTR(wbuf, "malloc"); rbuf = - (uint16_t *)calloc(sizeof(uint16_t), (size_t)(SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4)); + (uint16_t *)calloc((size_t)(SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4), sizeof(uint16_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -1734,7 +1734,7 @@ test_select_hyper_contig3(hid_t dset_type, hid_t xfer_plist) wbuf = (uint16_t *)malloc(sizeof(uint16_t) * SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4); CHECK_PTR(wbuf, "malloc"); rbuf = - (uint16_t *)calloc(sizeof(uint16_t), (size_t)(SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4)); + (uint16_t *)calloc((size_t)(SPACE8_DIM1 * SPACE8_DIM2 * SPACE8_DIM3 * SPACE8_DIM4), sizeof(uint16_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -2003,9 +2003,9 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, co block_ptr = &(block[SS_DR_MAX_RANK - large_rank]); /* Allocate buffers */ - small_cube_buf_1 = (uint16_t *)calloc(sizeof(uint16_t), small_cube_size); + small_cube_buf_1 = (uint16_t *)calloc(small_cube_size, sizeof(uint16_t)); CHECK_PTR(small_cube_buf_1, "calloc"); - large_cube_buf_1 = (uint16_t *)calloc(sizeof(uint16_t), large_cube_size); + large_cube_buf_1 = (uint16_t *)calloc(large_cube_size, sizeof(uint16_t)); CHECK_PTR(large_cube_buf_1, "calloc"); /* Create a dataset transfer property list */ @@ -2539,7 +2539,7 @@ test_select_hyper_contig_dr(hid_t dset_type, hid_t xfer_plist) *cube_ptr++ = (uint16_t)s; /* Allocate cube buffer for zeroing values on disk */ - zero_buf = (uint16_t *)calloc(sizeof(uint16_t), max_cube_size); + zero_buf = (uint16_t *)calloc(max_cube_size, sizeof(uint16_t)); CHECK_PTR(zero_buf, "calloc"); for (large_rank = 1; large_rank <= max_rank; large_rank++) { @@ -2988,9 +2988,9 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ assert(large_cube_size < (size_t)(64 * 1024)); /* Allocate & initialize buffers */ - small_cube_buf_1 = (uint16_t *)calloc(sizeof(uint16_t), small_cube_size); + small_cube_buf_1 = (uint16_t *)calloc(small_cube_size, sizeof(uint16_t)); CHECK_PTR(small_cube_buf_1, "calloc"); - large_cube_buf_1 = (uint16_t *)calloc(sizeof(uint16_t), large_cube_size); + large_cube_buf_1 = (uint16_t *)calloc(large_cube_size, sizeof(uint16_t)); CHECK_PTR(large_cube_buf_1, "calloc"); /* Create a dataset transfer property list */ @@ -3615,7 +3615,7 @@ test_select_hyper_checker_board_dr(hid_t dset_type, hid_t xfer_plist) *cube_ptr++ = (uint16_t)s; /* Allocate cube buffer for zeroing values on disk */ - zero_buf = (uint16_t *)calloc(sizeof(uint16_t), max_cube_size); + zero_buf = (uint16_t *)calloc(max_cube_size, sizeof(uint16_t)); CHECK_PTR(zero_buf, "calloc"); for (large_rank = 1; large_rank <= max_rank; large_rank++) { @@ -3681,9 +3681,9 @@ test_select_hyper_copy(void) /* Allocate write & read buffers */ wbuf = (uint16_t *)malloc(sizeof(uint16_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint16_t *)calloc(sizeof(uint16_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); + rbuf = (uint16_t *)calloc((size_t)(SPACE3_DIM1 * SPACE3_DIM2), sizeof(uint16_t)); CHECK_PTR(rbuf, "calloc"); - rbuf2 = (uint16_t *)calloc(sizeof(uint16_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); + rbuf2 = (uint16_t *)calloc((size_t)(SPACE3_DIM1 * SPACE3_DIM2), sizeof(uint16_t)); CHECK_PTR(rbuf2, "calloc"); /* Initialize write buffer */ @@ -3852,9 +3852,9 @@ test_select_point_copy(void) /* Allocate write & read buffers */ wbuf = (uint16_t *)malloc(sizeof(uint16_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint16_t *)calloc(sizeof(uint16_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); + rbuf = (uint16_t *)calloc((size_t)(SPACE3_DIM1 * SPACE3_DIM2), sizeof(uint16_t)); CHECK_PTR(rbuf, "calloc"); - rbuf2 = (uint16_t *)calloc(sizeof(uint16_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); + rbuf2 = (uint16_t *)calloc((size_t)(SPACE3_DIM1 * SPACE3_DIM2), sizeof(uint16_t)); CHECK_PTR(rbuf2, "calloc"); /* Initialize write buffer */ @@ -4070,7 +4070,7 @@ test_select_hyper_offset(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); + rbuf = (uint8_t *)calloc((size_t)(SPACE3_DIM1 * SPACE3_DIM2), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -4278,7 +4278,7 @@ test_select_hyper_offset2(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE7_DIM1 * SPACE7_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE7_DIM1 * SPACE7_DIM2)); + rbuf = (uint8_t *)calloc((size_t)(SPACE7_DIM1 * SPACE7_DIM2), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -4408,7 +4408,7 @@ test_select_point_offset(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); + rbuf = (uint8_t *)calloc((size_t)(SPACE3_DIM1 * SPACE3_DIM2), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -4635,7 +4635,7 @@ test_select_hyper_union(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); + rbuf = (uint8_t *)calloc((size_t)(SPACE3_DIM1 * SPACE3_DIM2), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -5413,7 +5413,7 @@ test_select_hyper_union_3d(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE4_DIM1 * SPACE4_DIM2 * SPACE4_DIM3); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), SPACE3_DIM1 * SPACE3_DIM2); + rbuf = (uint8_t *)calloc(SPACE3_DIM1 * SPACE3_DIM2, sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -5737,7 +5737,7 @@ test_select_hyper_and_2d(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); + rbuf = (uint8_t *)calloc((size_t)(SPACE2_DIM1 * SPACE2_DIM2), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -5876,7 +5876,7 @@ test_select_hyper_xor_2d(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); + rbuf = (uint8_t *)calloc((size_t)(SPACE2_DIM1 * SPACE2_DIM2), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -6017,7 +6017,7 @@ test_select_hyper_notb_2d(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); + rbuf = (uint8_t *)calloc((size_t)(SPACE2_DIM1 * SPACE2_DIM2), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -6156,7 +6156,7 @@ test_select_hyper_nota_2d(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); + rbuf = (uint8_t *)calloc((size_t)(SPACE2_DIM1 * SPACE2_DIM2), sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -6326,8 +6326,8 @@ test_select_hyper_union_random_5d(hid_t read_plist) /* Allocate write & read buffers */ wbuf = (int *)malloc(sizeof(int) * SPACE5_DIM1 * SPACE5_DIM2 * SPACE5_DIM3 * SPACE5_DIM4 * SPACE5_DIM5); CHECK_PTR(wbuf, "malloc"); - rbuf = (int *)calloc(sizeof(int), - (size_t)(SPACE5_DIM1 * SPACE5_DIM2 * SPACE5_DIM3 * SPACE5_DIM4 * SPACE5_DIM5)); + rbuf = (int *)calloc((size_t)(SPACE5_DIM1 * SPACE5_DIM2 * SPACE5_DIM3 * SPACE5_DIM4 * SPACE5_DIM5), + sizeof(int)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -7997,7 +7997,7 @@ test_select_none(void) /* Allocate write & read buffers */ wbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE7_DIM1 * SPACE7_DIM2); CHECK_PTR(wbuf, "malloc"); - rbuf = (uint8_t *)calloc(sizeof(uint8_t), SPACE7_DIM1 * SPACE7_DIM2); + rbuf = (uint8_t *)calloc(SPACE7_DIM1 * SPACE7_DIM2, sizeof(uint8_t)); CHECK_PTR(rbuf, "calloc"); /* Initialize write buffer */ @@ -13581,7 +13581,7 @@ test_select_hyper_chunk_offset(void) /* Allocate buffers */ wbuf = (int *)malloc(sizeof(int) * SPACE10_DIM1); CHECK_PTR(wbuf, "malloc"); - rbuf = (int *)calloc(sizeof(int), SPACE10_DIM1); + rbuf = (int *)calloc(SPACE10_DIM1, sizeof(int)); CHECK_PTR(rbuf, "calloc"); /* Initialize the write buffer */ diff --git a/test/unregister.c b/test/unregister.c index 528adf9ddf..871343ae4d 100644 --- a/test/unregister.c +++ b/test/unregister.c @@ -275,16 +275,17 @@ error: int main(void) { - hid_t fapl_id = H5I_INVALID_HID; - int nerrors = 0; - bool api_ctx_pushed = false; /* Whether API context pushed */ + hid_t fapl_id = H5I_INVALID_HID; + int nerrors = 0; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ /* Testing setup */ h5_test_init(); fapl_id = h5_fileaccess(); /* Push API context */ - if (H5CX_push() < 0) + if (H5CX_push(&api_ctx) < 0) FAIL_STACK_ERROR; api_ctx_pushed = true; diff --git a/test/vol.c b/test/vol.c index a6d1d6caf8..368e6f44f3 100644 --- a/test/vol.c +++ b/test/vol.c @@ -1681,7 +1681,8 @@ exercise_reg_opt_oper(hid_t fake_vol_id, hid_t reg_opt_vol_id, H5VL_subclass_t s int fake_obj, fake_arg; int op_val = -1, op_val2 = -1; int find_op_val; - herr_t ret = SUCCEED; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + herr_t ret = SUCCEED; /* Test registering optional operation */ snprintf(op_name, sizeof(op_name), "%s-op1", subcls_name); @@ -1724,7 +1725,7 @@ exercise_reg_opt_oper(hid_t fake_vol_id, hid_t reg_opt_vol_id, H5VL_subclass_t s /* Push a new API context on the stack */ /* (Necessary for the named datatype construction routines) */ if (H5VL_SUBCLS_DATATYPE == subcls) - H5CX_push(); + H5CX_push(&api_ctx); /* Create fake object on fake VOL connector */ if (H5I_INVALID_HID == (obj_id = H5VL__register_using_vol_id_test(id_type, &fake_obj, fake_vol_id))) @@ -1779,8 +1780,9 @@ exercise_reg_opt_oper(hid_t fake_vol_id, hid_t reg_opt_vol_id, H5VL_subclass_t s /* Push a new API context on the stack */ /* (Necessary for the named datatype construction routines) */ + memset(&api_ctx, 0, sizeof(api_ctx)); if (H5VL_SUBCLS_DATATYPE == subcls) - H5CX_push(); + H5CX_push(&api_ctx); /* Create fake object on reg_opt VOL connector */ if (H5I_INVALID_HID == (obj_id = H5VL__register_using_vol_id_test(id_type, &fake_obj, reg_opt_vol_id))) diff --git a/testpar/t_cache.c b/testpar/t_cache.c index 7b546e04eb..633bf2010f 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -3591,6 +3591,7 @@ setup_cache_for_test(hid_t *fid_ptr, H5F_t **file_ptr_ptr, H5C_t **cache_ptr_ptr H5F_t *file_ptr = NULL; H5C_t *cache_ptr = NULL; haddr_t actual_base_addr; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ assert(fid_ptr != NULL); assert(file_ptr_ptr != NULL); @@ -3599,7 +3600,7 @@ setup_cache_for_test(hid_t *fid_ptr, H5F_t **file_ptr_ptr, H5C_t **cache_ptr_ptr fid = H5Fcreate(filenames[0], H5F_ACC_TRUNC, H5P_DEFAULT, fapl); /* Push API context */ - H5CX_push(); + H5CX_push(&api_ctx); if (fid < 0) { nerrors++; @@ -4043,7 +4044,6 @@ take_down_cache(hid_t fid, H5C_t *cache_ptr) } return (success); - } /* take_down_cache() */ /***************************************************************************** @@ -4945,6 +4945,7 @@ smoke_check_1(int metadata_write_strategy) } else /* run the clients */ { + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { nerrors++; @@ -4955,6 +4956,9 @@ smoke_check_1(int metadata_write_strategy) } } + /* Push API context */ + H5CX_push(&api_ctx); + for (i = 0; i < (virt_num_data_entries / 2); i++) { insert_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); } @@ -5021,6 +5025,9 @@ smoke_check_1(int metadata_write_strategy) } } } + + /* Pop API context */ + H5CX_pop(false); } max_nerrors = get_max_nerrors(); @@ -5041,7 +5048,6 @@ smoke_check_1(int metadata_write_strategy) success = ((success) && (max_nerrors == 0)); return (success); - } /* smoke_check_1() */ /***************************************************************************** @@ -5107,6 +5113,7 @@ smoke_check_2(int metadata_write_strategy) } else /* run the clients */ { + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { nerrors++; @@ -5117,6 +5124,9 @@ smoke_check_2(int metadata_write_strategy) } } + /* Push API context */ + H5CX_push(&api_ctx); + for (i = 0; i < (virt_num_data_entries / 2); i++) { insert_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); @@ -5217,6 +5227,9 @@ smoke_check_2(int metadata_write_strategy) } } } + + /* Pop API context */ + H5CX_pop(false); } max_nerrors = get_max_nerrors(); @@ -5237,7 +5250,6 @@ smoke_check_2(int metadata_write_strategy) success = ((success) && (max_nerrors == 0)); return (success); - } /* smoke_check_2() */ /***************************************************************************** @@ -5310,6 +5322,7 @@ smoke_check_3(int metadata_write_strategy) } else /* run the clients */ { + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { nerrors++; @@ -5320,6 +5333,9 @@ smoke_check_3(int metadata_write_strategy) } } + /* Push API context */ + H5CX_push(&api_ctx); + min_count = 100 / ((file_mpi_rank + 1) * (file_mpi_rank + 1)); max_count = min_count + 50; @@ -5500,6 +5516,9 @@ smoke_check_3(int metadata_write_strategy) } } } + + /* Pop API context */ + H5CX_pop(false); } max_nerrors = get_max_nerrors(); @@ -5520,7 +5539,6 @@ smoke_check_3(int metadata_write_strategy) success = ((success) && (max_nerrors == 0)); return (success); - } /* smoke_check_3() */ /***************************************************************************** @@ -5593,6 +5611,7 @@ smoke_check_4(int metadata_write_strategy) } else /* run the clients */ { + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { nerrors++; @@ -5603,6 +5622,9 @@ smoke_check_4(int metadata_write_strategy) } } + /* Push API context */ + H5CX_push(&api_ctx); + min_count = 100 * (file_mpi_rank % 4); max_count = min_count + 50; @@ -5782,6 +5804,9 @@ smoke_check_4(int metadata_write_strategy) } } } + + /* Pop API context */ + H5CX_pop(false); } max_nerrors = get_max_nerrors(); @@ -5802,7 +5827,6 @@ smoke_check_4(int metadata_write_strategy) success = ((success) && (max_nerrors == 0)); return (success); - } /* smoke_check_4() */ /***************************************************************************** @@ -5866,6 +5890,7 @@ smoke_check_5(int metadata_write_strategy) } else /* run the clients */ { + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { @@ -5877,6 +5902,9 @@ smoke_check_5(int metadata_write_strategy) } } + /* Push API context */ + H5CX_push(&api_ctx); + for (i = 0; i < (virt_num_data_entries / 2); i++) { insert_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); } @@ -5972,6 +6000,9 @@ smoke_check_5(int metadata_write_strategy) } } } + + /* Pop API context */ + H5CX_pop(false); } max_nerrors = get_max_nerrors(); @@ -5992,7 +6023,6 @@ smoke_check_5(int metadata_write_strategy) success = ((success) && (max_nerrors == 0)); return (success); - } /* smoke_check_5() */ /***************************************************************************** @@ -6148,6 +6178,7 @@ trace_file_check(int metadata_write_strategy) } else { /* run the clients */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { @@ -6158,6 +6189,9 @@ trace_file_check(int metadata_write_strategy) fprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", world_mpi_rank, __func__); } + /* Push API context */ + H5CX_push(&api_ctx); + if (nerrors == 0) { config.version = H5AC__CURR_CACHE_CONFIG_VERSION; @@ -6370,6 +6404,9 @@ trace_file_check(int metadata_write_strategy) trace_file_ptr = NULL; HDremove(trace_file_name); } + + /* Pop API context */ + H5CX_pop(false); } /* end giant else that runs clients */ max_nerrors = get_max_nerrors(); @@ -6388,7 +6425,6 @@ trace_file_check(int metadata_write_strategy) success = ((success) && (max_nerrors == 0)); return (success); - } /* trace_file_check() */ /***************************************************************************** @@ -6453,7 +6489,8 @@ smoke_check_6(int metadata_write_strategy) } else /* run the clients */ { - int temp; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + int temp; if (!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy)) { @@ -6465,6 +6502,9 @@ smoke_check_6(int metadata_write_strategy) } } + /* Push API context */ + H5CX_push(&api_ctx); + temp = virt_num_data_entries; virt_num_data_entries = NUM_DATA_ENTRIES; @@ -6621,6 +6661,9 @@ smoke_check_6(int metadata_write_strategy) } } virt_num_data_entries = temp; + + /* Pop API context */ + H5CX_pop(false); } max_nerrors = get_max_nerrors(); @@ -6641,7 +6684,6 @@ smoke_check_6(int metadata_write_strategy) success = ((success) && (max_nerrors == 0)); return (success); - } /* smoke_check_6() */ /***************************************************************************** diff --git a/testpar/t_file.c b/testpar/t_file.c index 77fd69782d..51b244e99d 100644 --- a/testpar/t_file.c +++ b/testpar/t_file.c @@ -141,12 +141,13 @@ test_page_buffer_access(const void *params) hid_t fcpl, fapl; herr_t ret; /* generic return value */ #ifdef PB_OUT - size_t page_count = 0; - int i, num_elements = 200; - haddr_t raw_addr, meta_addr; - int *data; - H5F_t *f = NULL; - bool api_ctx_pushed = false; /* Whether API context pushed */ + size_t page_count = 0; + int i, num_elements = 200; + haddr_t raw_addr, meta_addr; + int *data; + H5F_t *f = NULL; + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ #endif MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); @@ -229,7 +230,7 @@ test_page_buffer_access(const void *params) VRFY((file_id >= 0), ""); /* Push API context */ - ret = H5CX_push(); + ret = H5CX_push(&api_ctx); VRFY((ret == 0), "H5CX_push()"); api_ctx_pushed = true; @@ -339,7 +340,7 @@ test_page_buffer_access(const void *params) VRFY((file_id >= 0), ""); /* Push API context */ - ret = H5CX_push(); + ret = H5CX_push(&api_ctx); VRFY((ret == 0), "H5CX_push()"); api_ctx_pushed = true; @@ -483,7 +484,8 @@ create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_str H5F_t *f = NULL; H5C_t *cache_ptr = NULL; H5AC_cache_config_t config; - bool api_ctx_pushed = false; /* Whether API context pushed */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ herr_t ret; file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); @@ -493,7 +495,7 @@ create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_str VRFY((ret == 0), ""); /* Push API context */ - ret = H5CX_push(); + ret = H5CX_push(&api_ctx); VRFY((ret == 0), "H5CX_push()"); api_ctx_pushed = true; @@ -639,7 +641,8 @@ open_file(const char *filename, hid_t fapl, int metadata_write_strategy, hsize_t H5F_t *f = NULL; H5C_t *cache_ptr = NULL; H5AC_cache_config_t config; - bool api_ctx_pushed = false; /* Whether API context pushed */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ herr_t ret; config.version = H5AC__CURR_CACHE_CONFIG_VERSION; @@ -656,7 +659,7 @@ open_file(const char *filename, hid_t fapl, int metadata_write_strategy, hsize_t VRFY((file_id >= 0), ""); /* Push API context */ - ret = H5CX_push(); + ret = H5CX_push(&api_ctx); VRFY((ret == 0), "H5CX_push()"); api_ctx_pushed = true; diff --git a/testpar/t_shapesame.c b/testpar/t_shapesame.c index be1d2758ed..56b460d789 100644 --- a/testpar/t_shapesame.c +++ b/testpar/t_shapesame.c @@ -21,10 +21,10 @@ /* Define this macro to indicate that the testing APIs should be available */ #define H5S_TESTING -#include "H5Spkg.h" /* Dataspaces */ - #include "testpar.h" +#include "H5Spkg.h" /* Dataspaces */ + /* Include testing framework functionality */ #include "testframe.h" diff --git a/tools/src/misc/h5debug.c b/tools/src/misc/h5debug.c index b4051fd621..b8d8aaf3f6 100644 --- a/tools/src/misc/h5debug.c +++ b/tools/src/misc/h5debug.c @@ -233,7 +233,8 @@ main(int argc, char *argv[]) size_t u; H5E_auto2_t func = NULL; void *edata = NULL; - bool api_ctx_pushed = false; /* Whether API context pushed */ + H5CX_node_t api_ctx = {{0}, NULL}; /* API context node to push */ + bool api_ctx_pushed = false; /* Whether API context pushed */ herr_t status = SUCCEED; int exit_value = 0; @@ -275,7 +276,7 @@ main(int argc, char *argv[]) } /* end if */ /* Push API context */ - if (H5CX_push() < 0) { + if (H5CX_push(&api_ctx) < 0) { fprintf(stderr, "cannot set API context\n"); exit_value = 1; goto done;