From c5d3ff5a2db69a1b81e916d98d8b17e52739229e Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Mon, 17 May 2021 16:51:10 -0500 Subject: [PATCH 01/13] Revert addition of & to 2 parameters in DSetCreatPropList::setVirtual to maintain binary compatibility. --- c++/src/H5DcreatProp.cpp | 4 ++-- c++/src/H5DcreatProp.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index 383e38faed4..4c71d5ece90 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -775,8 +775,8 @@ DSetCreatPropList::setVirtual(const DataSpace &vspace, const char *src_fname, co // Programmer Binh-Minh Ribler - Mar, 2017 //-------------------------------------------------------------------------- void -DSetCreatPropList::setVirtual(const DataSpace &vspace, const H5std_string &src_fname, - const H5std_string &src_dsname, const DataSpace &sspace) const +DSetCreatPropList::setVirtual(const DataSpace &vspace, const H5std_string src_fname, + const H5std_string src_dsname, const DataSpace &sspace) const { setVirtual(vspace, src_fname.c_str(), src_dsname.c_str(), sspace); } diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 820c0d1df19..3c032ee5c6d 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -123,7 +123,7 @@ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { // Maps elements of a virtual dataset to elements of the source dataset. void setVirtual(const DataSpace &vspace, const char *src_fname, const char *src_dsname, const DataSpace &sspace) const; - void setVirtual(const DataSpace &vspace, const H5std_string &src_fname, const H5std_string &src_dsname, + void setVirtual(const DataSpace &vspace, const H5std_string src_fname, const H5std_string src_dsname, const DataSpace &sspace) const; ///\brief Returns this class name. From 426b50484841118cf633fd6147302a63a30fd746 Mon Sep 17 00:00:00 2001 From: jhendersonHDF Date: Tue, 11 May 2021 22:22:45 -0500 Subject: [PATCH 02/13] Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625) --- src/H5E.c | 47 ++++++++++++++++++++++++++++++------- test/testfiles/err_compat_1 | 14 ++++++++++- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/src/H5E.c b/src/H5E.c index da75edeb28f..f13e571be0d 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -244,6 +244,20 @@ H5E_term_package(void) nstk = H5I_nmembers(H5I_ERROR_STACK); if ((ncls + nmsg + nstk) > 0) { + /* Clear the default error stack. Note that + * the following H5I_clear_type calls do not + * force the clears and will not be able to + * clear any error message IDs that are still + * in use by the default error stack unless we + * clear that stack manually. + * + * Error message IDs will typically still be + * in use by the default error stack when the + * application does H5E_BEGIN/END_TRY cleanup + * at the very end. + */ + H5E_clear_stack(NULL); + /* Clear any outstanding error stacks */ if (nstk > 0) (void)H5I_clear_type(H5I_ERROR_STACK, FALSE, FALSE); @@ -1561,7 +1575,8 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data) H5E_auto_op_t op; /* Error stack function */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE3("e", "i*x**x", estack_id, func, client_data); if (estack_id == H5E_DEFAULT) { @@ -1569,8 +1584,13 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data) non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ - else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + else { + /* Only clear the error stack if it's not the default stack */ + H5E_clear_stack(NULL); + + if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + } /* end else */ /* Get the automatic error reporting information */ if (H5E__get_auto(estack, &op, client_data) < 0) @@ -1627,8 +1647,13 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data) non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ - else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + else { + /* Only clear the error stack if it's not the default stack */ + H5E_clear_stack(NULL); + + if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + } /* end else */ #ifndef H5_NO_DEPRECATED_SYMBOLS /* Get the automatic error reporting information */ @@ -1675,7 +1700,8 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) H5E_t *estack; /* Error stack to operate on */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE2("e", "i*Iu", estack_id, is_stack); if (estack_id == H5E_DEFAULT) { @@ -1683,8 +1709,13 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ - else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + else { + /* Only clear the error stack if it's not the default stack */ + H5E_clear_stack(NULL); + + if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + } /* end else */ /* Check if the error stack reporting function is the "newer" stack type */ if (is_stack) diff --git a/test/testfiles/err_compat_1 b/test/testfiles/err_compat_1 index d81dba1ea16..e3ec405d2d7 100644 --- a/test/testfiles/err_compat_1 +++ b/test/testfiles/err_compat_1 @@ -28,7 +28,19 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Inappropriate type ********* Print error stack in customized way ********* - error #000: (file name) in H5Eget_auto(1 or 2)(): line (number) + error #000: (file name) in H5VL_vol_object(): line (number) + major: Invalid arguments to routine + minor: Inappropriate type + error #001: (file name) in H5VL_setup_acc_args(): line (number) + major: Invalid arguments to routine + minor: Inappropriate type + error #002: (file name) in H5D__create_api_common(): line (number) + major: Dataset + minor: Can't set value + error #003: (file name) in H5Dcreate2(): line (number) + major: Dataset + minor: Unable to create file + error #004: (file name) in H5Eget_auto(1 or 2)(): line (number) major: Error API minor: Can't get value From da089c510866a8e61c0e12b2875e0a34ee5143d6 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Fri, 7 May 2021 09:45:05 -0700 Subject: [PATCH 03/13] Removes gratuitous (double)x.yF casts (#632) * Committing clang-format changes * Removes gratuitous (double)x.yF casts * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- c++/test/dsets.cpp | 4 +- hl/src/H5LT.c | 2 +- src/H5C.c | 98 ++++++++-------- src/H5Cdbg.c | 23 ++-- src/H5Cimage.c | 9 +- src/H5Cprivate.h | 16 +-- src/H5HFdbg.c | 2 +- src/H5HLdbg.c | 2 +- src/H5Pdapl.c | 2 +- src/H5Pdxpl.c | 5 +- src/H5Pfapl.c | 2 +- src/H5T.c | 4 +- src/H5Zdeflate.c | 2 +- src/H5Zscaleoffset.c | 2 +- src/H5timer.c | 40 +++---- src/H5trace.c | 3 +- test/cache.c | 8 +- test/cache_api.c | 174 ++++++++++++++--------------- test/cross_read.c | 6 +- test/dsets.c | 6 +- test/dt_arith.c | 2 +- test/dtypes.c | 6 +- test/enc_dec_plist.c | 64 ++++++----- test/gen_cross.c | 2 +- test/gen_plist.c | 18 +-- test/links.c | 2 +- test/mtime.c | 2 +- test/objcopy.c | 2 +- test/tattr.c | 22 ++-- test/tgenprop.c | 2 +- test/th5s.c | 2 +- test/timer.c | 22 ++-- test/tmisc.c | 22 ++-- testpar/t_prop.c | 20 ++-- tools/src/h5diff/h5diff_common.c | 2 +- tools/src/h5ls/h5ls.c | 2 +- tools/src/h5stat/h5stat.c | 4 +- tools/test/h5import/h5importtest.c | 4 +- tools/test/perform/chunk.c | 16 +-- tools/test/perform/chunk_cache.c | 30 ++--- tools/test/perform/iopipe.c | 11 +- tools/test/perform/sio_perf.c | 3 +- tools/test/perform/zip_perf.c | 11 +- 43 files changed, 336 insertions(+), 345 deletions(-) diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index d47d5412d51..8a18a3596db 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -1169,7 +1169,7 @@ test_chunk_cache(const FileAccPropList &fapl) // Verify that chunk cache parameters are the same int mdc_nelmts = 0; size_t nslots_1 = 0, nslots_4 = 0, nbytes_1 = 0, nbytes_4 = 0; - double w0_1 = 0.0F, w0_4 = 0.0F; + double w0_1 = 0.0, w0_4 = 0.0; fapl_def.getCache(mdc_nelmts, nslots_1, nbytes_1, w0_1); dapl.getChunkCache(nslots_4, nbytes_4, w0_4); verify_val(nslots_1, nslots_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); @@ -1187,7 +1187,7 @@ test_chunk_cache(const FileAccPropList &fapl) // Set new rdcc settings on fapl local size_t nslots_2 = nslots_1 * 2; size_t nbytes_2 = nbytes_1 * 2; - double w0_2 = w0_1 / (double)2.0F; + double w0_2 = w0_1 / 2.0; fapl_local.getCache(mdc_nelmts, nslots_2, nbytes_2, w0_2); // Create a new file using default fcpl and the passed-in fapl diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 45cf3177d8e..a804b390009 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -822,7 +822,7 @@ H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) char file_name[64]; /* Filename buffer */ size_t alloc_incr; /* Buffer allocation increment */ size_t min_incr = 65536; /* Minimum buffer increment */ - double buf_prcnt = 0.1f; /* Percentage of buffer size to set + double buf_prcnt = 0.1; /* Percentage of buffer size to set as increment */ static long file_name_counter; H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy, &image_realloc, &image_free, diff --git a/src/H5C.c b/src/H5C.c index 15471895ee2..ecd99e8be64 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -459,8 +459,8 @@ H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, (cache_ptr->resize_ctl).max_increment = H5C__DEF_AR_MAX_INCREMENT; (cache_ptr->resize_ctl).flash_incr_mode = H5C_flash_incr__off; - (cache_ptr->resize_ctl).flash_multiple = 1.0f; - (cache_ptr->resize_ctl).flash_threshold = 0.25f; + (cache_ptr->resize_ctl).flash_multiple = 1.0; + (cache_ptr->resize_ctl).flash_threshold = 0.25; (cache_ptr->resize_ctl).decr_mode = H5C_decr__off; (cache_ptr->resize_ctl).upper_hr_threshold = H5C__DEF_AR_UPPER_THRESHHOLD; @@ -2718,7 +2718,7 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_p break; case H5C_incr__threshold: - if ((config_ptr->lower_hr_threshold <= (double)0.0f) || (config_ptr->increment <= (double)1.0f) || + if ((config_ptr->lower_hr_threshold <= 0.0) || (config_ptr->increment <= 1.0) || ((config_ptr->apply_max_increment) && (config_ptr->max_increment <= 0))) cache_ptr->size_increase_possible = FALSE; break; @@ -2738,21 +2738,21 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_p break; case H5C_decr__threshold: - if ((config_ptr->upper_hr_threshold >= (double)1.0f) || (config_ptr->decrement >= (double)1.0f) || + if ((config_ptr->upper_hr_threshold >= 1.0) || (config_ptr->decrement >= 1.0) || ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0))) cache_ptr->size_decrease_possible = FALSE; break; case H5C_decr__age_out: - if (((config_ptr->apply_empty_reserve) && (config_ptr->empty_reserve >= (double)1.0f)) || + if (((config_ptr->apply_empty_reserve) && (config_ptr->empty_reserve >= 1.0)) || ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0))) cache_ptr->size_decrease_possible = FALSE; break; case H5C_decr__age_out_with_threshold: - if (((config_ptr->apply_empty_reserve) && (config_ptr->empty_reserve >= (double)1.0f)) || + if (((config_ptr->apply_empty_reserve) && (config_ptr->empty_reserve >= 1.0)) || ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0)) || - (config_ptr->upper_hr_threshold >= (double)1.0f)) + (config_ptr->upper_hr_threshold >= 1.0)) cache_ptr->size_decrease_possible = FALSE; break; @@ -3730,10 +3730,8 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "initial_size must be in the interval [min_size, max_size]") - if ((config_ptr->min_clean_fraction < (double)0.0f) || - (config_ptr->min_clean_fraction > (double)1.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "min_clean_fraction must be in the interval [0.0, 1.0]") + if ((config_ptr->min_clean_fraction < 0.0) || (config_ptr->min_clean_fraction > 1.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_clean_fraction must be in the interval [0.0, 1.0]") if (config_ptr->epoch_length < H5C__MIN_AR_EPOCH_LENGTH) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epoch_length too small") @@ -3746,15 +3744,13 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) if ((config_ptr->incr_mode != H5C_incr__off) && (config_ptr->incr_mode != H5C_incr__threshold)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid incr_mode") - if (config_ptr->incr_mode == H5C_incr__threshold) { - if ((config_ptr->lower_hr_threshold < (double)0.0f) || - (config_ptr->lower_hr_threshold > (double)1.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "lower_hr_threshold must be in the range [0.0, 1.0]") + if (config_ptr->incr_mode == H5C_incr__threshold) { + if ((config_ptr->lower_hr_threshold < 0.0) || (config_ptr->lower_hr_threshold > 1.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "lower_hr_threshold must be in the range [0.0, 1.0]") - if (config_ptr->increment < (double)1.0f) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "increment must be greater than or equal to 1.0") + if (config_ptr->increment < 1.0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "increment must be greater than or equal to 1.0") /* no need to check max_increment, as it is a size_t, * and thus must be non-negative. @@ -3766,16 +3762,14 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) /* nothing to do here */ break; - case H5C_flash_incr__add_space: - if ((config_ptr->flash_multiple < (double)0.1f) || - (config_ptr->flash_multiple > (double)10.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "flash_multiple must be in the range [0.1, 10.0]") - if ((config_ptr->flash_threshold < (double)0.1f) || - (config_ptr->flash_threshold > (double)1.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "flash_threshold must be in the range [0.1, 1.0]") - break; + case H5C_flash_incr__add_space: + if ((config_ptr->flash_multiple < 0.1) || (config_ptr->flash_multiple > 10.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "flash_multiple must be in the range [0.1, 10.0]") + if ((config_ptr->flash_threshold < 0.1) || (config_ptr->flash_threshold > 1.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "flash_threshold must be in the range [0.1, 1.0]") + break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid flash_incr_mode") @@ -3792,12 +3786,12 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid decr_mode") } - if (config_ptr->decr_mode == H5C_decr__threshold) { - if (config_ptr->upper_hr_threshold > (double)1.0f) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "upper_hr_threshold must be <= 1.0") + if (config_ptr->decr_mode == H5C_decr__threshold) { + if (config_ptr->upper_hr_threshold > 1.0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "upper_hr_threshold must be <= 1.0") - if ((config_ptr->decrement > (double)1.0f) || (config_ptr->decrement < (double)0.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "decrement must be in the interval [0.0, 1.0]") + if ((config_ptr->decrement > 1.0) || (config_ptr->decrement < 0.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "decrement must be in the interval [0.0, 1.0]") /* no need to check max_decrement as it is a size_t * and thus must be non-negative. @@ -3812,31 +3806,29 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) if (config_ptr->epochs_before_eviction > H5C__MAX_EPOCH_MARKERS) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction too big") - if ((config_ptr->apply_empty_reserve) && ((config_ptr->empty_reserve > (double)1.0f) || - (config_ptr->empty_reserve < (double)0.0f))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "empty_reserve must be in the interval [0.0, 1.0]") + if ((config_ptr->apply_empty_reserve) && + ((config_ptr->empty_reserve > 1.0) || (config_ptr->empty_reserve < 0.0))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty_reserve must be in the interval [0.0, 1.0]") /* no need to check max_decrement as it is a size_t * and thus must be non-negative. */ } /* H5C_decr__age_out || H5C_decr__age_out_with_threshold */ - if (config_ptr->decr_mode == H5C_decr__age_out_with_threshold) { - if ((config_ptr->upper_hr_threshold > (double)1.0f) || - (config_ptr->upper_hr_threshold < (double)0.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "upper_hr_threshold must be in the interval [0.0, 1.0]") - } /* H5C_decr__age_out_with_threshold */ - } /* H5C_RESIZE_CFG__VALIDATE_DECREMENT */ - - if ((tests & H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) != 0) { - if ((config_ptr->incr_mode == H5C_incr__threshold) && - ((config_ptr->decr_mode == H5C_decr__threshold) || - (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) && - (config_ptr->lower_hr_threshold >= config_ptr->upper_hr_threshold)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "conflicting threshold fields in config") - } /* H5C_RESIZE_CFG__VALIDATE_INTERACTIONS */ + if (config_ptr->decr_mode == H5C_decr__age_out_with_threshold) { + if ((config_ptr->upper_hr_threshold > 1.0) || (config_ptr->upper_hr_threshold < 0.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "upper_hr_threshold must be in the interval [0.0, 1.0]") + } /* H5C_decr__age_out_with_threshold */ + } /* H5C_RESIZE_CFG__VALIDATE_DECREMENT */ + + if ((tests & H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) != 0) { + if ((config_ptr->incr_mode == H5C_incr__threshold) && + ((config_ptr->decr_mode == H5C_decr__threshold) || + (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) && + (config_ptr->lower_hr_threshold >= config_ptr->upper_hr_threshold)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "conflicting threshold fields in config") + } /* H5C_RESIZE_CFG__VALIDATE_INTERACTIONS */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index e602284a957..c52c8d52d05 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -429,11 +429,11 @@ H5C_stats(H5C_t *cache_ptr, const char *cache_name, int32_t aggregate_max_pins = 0; double hit_rate; double prefetch_use_rate; - double average_successful_search_depth = 0.0f; - double average_failed_search_depth = 0.0f; - double average_entries_skipped_per_calls_to_msic = 0.0f; - double average_dirty_pf_entries_skipped_per_call_to_msic = 0.0f; - double average_entries_scanned_per_calls_to_msic = 0.0f; + double average_successful_search_depth = 0.0; + double average_failed_search_depth = 0.0; + double average_entries_skipped_per_calls_to_msic = 0.0; + double average_dirty_pf_entries_skipped_per_call_to_msic = 0.0; + double average_entries_scanned_per_calls_to_msic = 0.0; #endif /* H5C_COLLECT_CACHE_STATS */ herr_t ret_value = SUCCEED; /* Return value */ @@ -492,9 +492,9 @@ H5C_stats(H5C_t *cache_ptr, const char *cache_name, } /* end for */ if ((total_hits > 0) || (total_misses > 0)) - hit_rate = (double)100.0f * ((double)(total_hits)) / ((double)(total_hits + total_misses)); + hit_rate = 100.0 * ((double)(total_hits)) / ((double)(total_hits + total_misses)); else - hit_rate = 0.0f; + hit_rate = 0.0; if (cache_ptr->successful_ht_searches > 0) average_successful_search_depth = ((double)(cache_ptr->total_successful_ht_search_depth)) / @@ -630,10 +630,9 @@ H5C_stats(H5C_t *cache_ptr, const char *cache_name, (long long)(cache_ptr->evictions[H5AC_PREFETCHED_ENTRY_ID])); if (cache_ptr->prefetches > 0) - prefetch_use_rate = - (double)100.0f * ((double)(cache_ptr->prefetch_hits)) / ((double)(cache_ptr->prefetches)); + prefetch_use_rate = 100.0 * ((double)(cache_ptr->prefetch_hits)) / ((double)(cache_ptr->prefetches)); else - prefetch_use_rate = 0.0f; + prefetch_use_rate = 0.0; HDfprintf(stdout, "%s prefetched entry use rate = %lf\n", cache_ptr->prefix, prefetch_use_rate); @@ -658,10 +657,10 @@ H5C_stats(H5C_t *cache_ptr, const char *cache_name, ((cache_ptr->class_table_ptr))[i]->name); if ((cache_ptr->hits[i] > 0) || (cache_ptr->misses[i] > 0)) - hit_rate = (double)100.0f * ((double)(cache_ptr->hits[i])) / + hit_rate = 100.0 * ((double)(cache_ptr->hits[i])) / ((double)(cache_ptr->hits[i] + cache_ptr->misses[i])); else - hit_rate = 0.0f; + hit_rate = 0.0; HDfprintf(stdout, "%s hits / misses / hit_rate = %ld / %ld / %f\n", cache_ptr->prefix, (long)(cache_ptr->hits[i]), (long)(cache_ptr->misses[i]), hit_rate); diff --git a/src/H5Cimage.c b/src/H5Cimage.c index fcf1b1c24fd..24aafba86dc 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -980,15 +980,14 @@ H5C_image_stats(H5C_t *cache_ptr, hbool_t H5_ATTR_UNUSED print_header) } /* end for */ if ((total_hits > 0) || (total_misses > 0)) - hit_rate = (double)100.0f * ((double)(total_hits)) / ((double)(total_hits + total_misses)); + hit_rate = 100.0 * ((double)(total_hits)) / ((double)(total_hits + total_misses)); else - hit_rate = 0.0f; + hit_rate = 0.0; if (cache_ptr->prefetches > 0) - prefetch_use_rate = - (double)100.0f * ((double)(cache_ptr->prefetch_hits)) / ((double)(cache_ptr->prefetches)); + prefetch_use_rate = 100.0 * ((double)(cache_ptr->prefetch_hits)) / ((double)(cache_ptr->prefetches)); else - prefetch_use_rate = 0.0f; + prefetch_use_rate = 0.0; if (print_header) { HDfprintf(stdout, "\nhit prefetches prefetch image pf hit\n"); diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 6863763ce6d..102c9bf649a 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -115,20 +115,20 @@ #define H5C__CURR_CACHE_IMAGE_CTL_VER 1 /* Default configuration settings */ -#define H5C__DEF_AR_UPPER_THRESHHOLD 0.9999f -#define H5C__DEF_AR_LOWER_THRESHHOLD 0.9f +#define H5C__DEF_AR_UPPER_THRESHHOLD 0.9999 +#define H5C__DEF_AR_LOWER_THRESHHOLD 0.9 #define H5C__DEF_AR_MAX_SIZE ((size_t)(16 * 1024 * 1024)) #define H5C__DEF_AR_INIT_SIZE ((size_t)(1 * 1024 * 1024)) #define H5C__DEF_AR_MIN_SIZE ((size_t)(1 * 1024 * 1024)) -#define H5C__DEF_AR_MIN_CLEAN_FRAC 0.5f -#define H5C__DEF_AR_INCREMENT 2.0f +#define H5C__DEF_AR_MIN_CLEAN_FRAC 0.5 +#define H5C__DEF_AR_INCREMENT 2.0 #define H5C__DEF_AR_MAX_INCREMENT ((size_t)(2 * 1024 * 1024)) -#define H5C__DEF_AR_FLASH_MULTIPLE 1.0f -#define H5C__DEV_AR_FLASH_THRESHOLD 0.25f -#define H5C__DEF_AR_DECREMENT 0.9f +#define H5C__DEF_AR_FLASH_MULTIPLE 1.0 +#define H5C__DEV_AR_FLASH_THRESHOLD 0.25 +#define H5C__DEF_AR_DECREMENT 0.9 #define H5C__DEF_AR_MAX_DECREMENT ((size_t)(1 * 1024 * 1024)) #define H5C__DEF_AR_EPCHS_B4_EVICT 3 -#define H5C__DEF_AR_EMPTY_RESERVE 0.05f +#define H5C__DEF_AR_EMPTY_RESERVE 0.05 #define H5C__MIN_AR_EPOCH_LENGTH 100 #define H5C__DEF_AR_EPOCH_LENGTH 50000 #define H5C__MAX_AR_EPOCH_LENGTH 1000000 diff --git a/src/H5HFdbg.c b/src/H5HFdbg.c index cc61aa19179..a2440357d0e 100644 --- a/src/H5HFdbg.c +++ b/src/H5HFdbg.c @@ -543,7 +543,7 @@ H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, amount_free = 0; HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, "Percent of available space for data used:", - ((double)100.0f * (double)((dblock->size - blk_prefix_size) - amount_free) / + (100.0 * (double)((dblock->size - blk_prefix_size) - amount_free) / (double)(dblock->size - blk_prefix_size))); /* diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index d0cfa960107..76e4ec09cbb 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -102,7 +102,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, if (h->dblk_size) HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, "Percent of heap used:", - ((double)100.0f * (double)(h->dblk_size - amount_free) / (double)h->dblk_size)); + (100.0 * (double)(h->dblk_size - amount_free) / (double)h->dblk_size)); /* Print the data in a VMS-style octal dump */ H5_buffer_dump(stream, indent, h->dblk_image, marker, (size_t)0, h->dblk_size); diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index 0ef15193c30..3b14959aded 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -768,7 +768,7 @@ H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, size_t rdcc_nbytes, double /* Check arguments. Note that we allow negative values - they are * considered to "unset" the property. */ - if (rdcc_w0 > (double)1.0f) + if (rdcc_w0 > 1.0) HGOTO_ERROR( H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive, or H5D_CHUNK_CACHE_W0_DEFAULT"); diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index f2fb1271012..1f2153af47b 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -1486,9 +1486,8 @@ H5Pset_btree_ratios(hid_t plist_id, double left, double middle, double right) H5TRACE4("e", "iddd", plist_id, left, middle, right); /* Check arguments */ - if (left < (double)0.0f || left > (double)1.0f || middle < (double)0.0f || middle > (double)1.0f || - right < (double)0.0f || right > (double)1.0f) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "split ratio must satisfy 0.0<=X<=1.0") + if (left < 0.0 || left > 1.0 || middle < 0.0 || middle > 1.0 || right < 0.0 || right > 1.0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "split ratio must satisfy 0.0 <= X <= 1.0") /* Get the plist structure */ if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 1a69c1021cb..fe5a81e8df0 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -1634,7 +1634,7 @@ H5Pset_cache(hid_t plist_id, int H5_ATTR_UNUSED mdc_nelmts, size_t rdcc_nslots, H5TRACE5("e", "iIszzd", plist_id, mdc_nelmts, rdcc_nslots, rdcc_nbytes, rdcc_w0); /* Check arguments */ - if (rdcc_w0 < (double)0.0f || rdcc_w0 > (double)1.0f) + if (rdcc_w0 < 0.0 || rdcc_w0 > 1.0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive") diff --git a/src/H5T.c b/src/H5T.c index 8856f17f076..739c8b285a8 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -540,8 +540,8 @@ size_t H5T_NATIVE_UINT_FAST64_ALIGN_g = 0; /* (+/- Inf for all floating-point types) */ float H5T_NATIVE_FLOAT_POS_INF_g = 0.0f; float H5T_NATIVE_FLOAT_NEG_INF_g = 0.0f; -double H5T_NATIVE_DOUBLE_POS_INF_g = (double)0.0f; -double H5T_NATIVE_DOUBLE_NEG_INF_g = (double)0.0f; +double H5T_NATIVE_DOUBLE_POS_INF_g = 0.0; +double H5T_NATIVE_DOUBLE_NEG_INF_g = 0.0; /* Declare the free list for H5T_t's and H5T_shared_t's */ H5FL_DEFINE(H5T_t); diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c index d8fed413190..d29d8e565eb 100644 --- a/src/H5Zdeflate.c +++ b/src/H5Zdeflate.c @@ -48,7 +48,7 @@ const H5Z_class2_t H5Z_DEFLATE[1] = {{ H5Z__filter_deflate, /* The actual filter function */ }}; -#define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * (double)1.001f) + 12) +#define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * 1.001) + 12) /*------------------------------------------------------------------------- * Function: H5Z__filter_deflate diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 25acc05a58c..97678b04d18 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -1116,7 +1116,7 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu unsigned filavail; /* flag indicating if fill value is defined or not */ H5Z_SO_scale_type_t scale_type = H5Z_SO_FLOAT_DSCALE; /* scale type */ int scale_factor = 0; /* scale factor */ - double D_val = 0.0f; /* decimal scale factor */ + double D_val = 0.0; /* decimal scale factor */ uint32_t minbits = 0; /* minimum number of bits to store values */ unsigned long long minval = 0; /* minimum value of input buffer */ enum H5Z_scaleoffset_t type; /* memory type corresponding to dataset datatype */ diff --git a/src/H5timer.c b/src/H5timer.c index ac3a01e174c..9af38f00057 100644 --- a/src/H5timer.c +++ b/src/H5timer.c @@ -41,9 +41,9 @@ #define H5TIMER_TIME_STRING_LEN 1536 /* Conversion factors */ -#define H5_SEC_PER_DAY (double)(24.0F * 60.0F * 60.0F) -#define H5_SEC_PER_HOUR (double)(60.0F * 60.0F) -#define H5_SEC_PER_MIN (double)(60.0F) +#define H5_SEC_PER_DAY (24.0 * 60.0 * 60.0) +#define H5_SEC_PER_HOUR (60.0 * 60.0) +#define H5_SEC_PER_MIN (60.0) /******************/ /* Local Typedefs */ @@ -99,13 +99,13 @@ H5_bandwidth(char *buf /*out*/, double nbytes, double nseconds) { double bw; - if (nseconds <= (double)0.0F) + if (nseconds <= 0.0) HDstrcpy(buf, " NaN"); else { bw = nbytes / nseconds; - if (H5_DBL_ABS_EQUAL(bw, (double)0.0F)) + if (H5_DBL_ABS_EQUAL(bw, 0.0)) HDstrcpy(buf, "0.000 B/s"); - else if (bw < (double)1.0F) + else if (bw < 1.0) HDsprintf(buf, "%10.4e", bw); else if (bw < (double)H5_KB) { HDsprintf(buf, "%05.4f", bw); @@ -223,7 +223,7 @@ H5_now_usec(void) double H5_get_time(void) { - double ret_value = (double)0.0f; + double ret_value = 0.0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -232,14 +232,14 @@ H5_get_time(void) struct timespec ts; HDclock_gettime(CLOCK_MONOTONIC, &ts); - ret_value = (double)ts.tv_sec + ((double)ts.tv_nsec / (double)1000000000.0f); + ret_value = (double)ts.tv_sec + ((double)ts.tv_nsec / 1000000000.0); } #elif defined(H5_HAVE_GETTIMEOFDAY) { struct timeval now_tv; HDgettimeofday(&now_tv, NULL); - ret_value = (double)now_tv.tv_sec + ((double)now_tv.tv_usec / (double)1000000.0f); + ret_value = (double)now_tv.tv_sec + ((double)now_tv.tv_usec / 1000000.0); } #else ret_value = (double)HDtime(NULL); @@ -288,8 +288,8 @@ H5__timer_get_timevals(H5_timevals_t *times /*in,out*/) if (HDgetrusage(RUSAGE_SELF, &res) < 0) return -1; - times->system = (double)res.ru_stime.tv_sec + ((double)res.ru_stime.tv_usec / (double)1.0E6F); - times->user = (double)res.ru_utime.tv_sec + ((double)res.ru_utime.tv_usec / (double)1.0E6F); + times->system = (double)res.ru_stime.tv_sec + ((double)res.ru_stime.tv_usec / 1.0E6); + times->user = (double)res.ru_utime.tv_sec + ((double)res.ru_utime.tv_usec / 1.0E6); } #else /* No suitable way to get system/user times */ @@ -588,7 +588,7 @@ H5_timer_get_time_string(double seconds) double remainder_sec = 0.0; /* Extract larger time units from count of seconds */ - if (seconds > (double)60.0F) { + if (seconds > 60.0) { /* Set initial # of seconds */ remainder_sec = seconds; @@ -616,19 +616,19 @@ H5_timer_get_time_string(double seconds) * time unit. Perhaps this could be passed as an integer. * (name? round_up_size? ?) */ - if (seconds < (double)0.0F) + if (seconds < 0.0) HDsprintf(s, "N/A"); - else if (H5_DBL_ABS_EQUAL((double)0.0F, seconds)) + else if (H5_DBL_ABS_EQUAL(0.0, seconds)) HDsprintf(s, "0.0 s"); - else if (seconds < (double)1.0E-6F) + else if (seconds < 1.0E-6) /* t < 1 us, Print time in ns */ - HDsprintf(s, "%.f ns", seconds * (double)1.0E9F); - else if (seconds < (double)1.0E-3F) + HDsprintf(s, "%.f ns", seconds * 1.0E9); + else if (seconds < 1.0E-3) /* t < 1 ms, Print time in us */ - HDsprintf(s, "%.1f us", seconds * (double)1.0E6F); - else if (seconds < (double)1.0F) + HDsprintf(s, "%.1f us", seconds * 1.0E6); + else if (seconds < 1.0) /* t < 1 s, Print time in ms */ - HDsprintf(s, "%.1f ms", seconds * (double)1.0E3F); + HDsprintf(s, "%.1f ms", seconds * 1.0E3); else if (seconds < H5_SEC_PER_MIN) /* t < 1 m, Print time in s */ HDsprintf(s, "%.2f s", seconds); diff --git a/src/H5trace.c b/src/H5trace.c index a70a9e209f8..3ebb1981d31 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -2663,7 +2663,6 @@ H5_trace(const double *returning, const char *func, const char *type, ...) (function_times.elapsed - *returning)); } /* end if */ -error: HDva_end(ap); if (returning) HDfprintf(out, ";\n"); @@ -2676,5 +2675,5 @@ H5_trace(const double *returning, const char *func, const char *type, ...) if (H5_debug_g.ttimes) return function_times.elapsed; else - return (double)0.0F; + return 0.0; } /* end H5_trace() */ diff --git a/test/cache.c b/test/cache.c index 895d3013c6d..85cc4170cb9 100644 --- a/test/cache.c +++ b/test/cache.c @@ -26482,7 +26482,7 @@ check_auto_cache_resize_aux_fcns(unsigned paged) pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate failed.\n"; } - else if (!H5_DBL_ABS_EQUAL(hit_rate, (double)0.0f)) { /* i.e. hit_rate != 0.0 */ + else if (!H5_DBL_ABS_EQUAL(hit_rate, 0.0)) { /* i.e. hit_rate != 0.0 */ pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate returned unexpected hit rate 1.\n"; @@ -26513,7 +26513,7 @@ check_auto_cache_resize_aux_fcns(unsigned paged) pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate failed.\n"; } - else if (!H5_DBL_ABS_EQUAL(hit_rate, (double)0.0f)) { /* i.e. hit_rate != 0.0 */ + else if (!H5_DBL_ABS_EQUAL(hit_rate, 0.0)) { /* i.e. hit_rate != 0.0 */ pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate returned unexpected hit rate 2.\n"; @@ -26554,7 +26554,7 @@ check_auto_cache_resize_aux_fcns(unsigned paged) pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate failed.\n"; } - else if (!H5_DBL_ABS_EQUAL(hit_rate, (double)0.5f)) { /* i.e. hit_rate != 0.5 */ + else if (!H5_DBL_ABS_EQUAL(hit_rate, 0.5)) { /* i.e. hit_rate != 0.5 */ pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate returned unexpected hit rate 3.\n"; @@ -26627,7 +26627,7 @@ check_auto_cache_resize_aux_fcns(unsigned paged) pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate failed.\n"; } - else if (!H5_DBL_ABS_EQUAL(hit_rate, (double)0.5F)) { /* i.e. hit_rate != 0.5 */ + else if (!H5_DBL_ABS_EQUAL(hit_rate, 0.5)) { /* i.e. hit_rate != 0.5 */ pass = FALSE; failure_mssg = "H5C_get_cache_hit_rate returned unexpected hit rate 4.\n"; diff --git a/test/cache_api.c b/test/cache_api.c index 60014c885d6..de975d2ebda 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -81,27 +81,27 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024 + 1), - /* double min_clean_fraction = */ 0.2f, + /* double min_clean_fraction = */ 0.2, /* size_t max_size = */ (16 * 1024 * 1024 + 1), /* size_t min_size = */ (1 * 1024 * 1024 + 1), /* long int epoch_length = */ 50001, /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, - /* double lower_hr_threshold = */ 0.91f, - /* double increment = */ 2.1f, + /* double lower_hr_threshold = */ 0.91, + /* double increment = */ 2.1, /* hbool_t apply_max_increment = */ TRUE, /* size_t max_increment = */ (4 * 1024 * 1024 + 1), /* enum H5C_cache_flash_incr_mode */ /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, + /* double flash_multiple = */ 2.0, + /* double flash_threshold = */ 0.5, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out, - /* double upper_hr_threshold = */ 0.998f, - /* double decrement = */ 0.91f, + /* double upper_hr_threshold = */ 0.998, + /* double decrement = */ 0.91, /* hbool_t apply_max_decrement = */ TRUE, /* size_t max_decrement = */ (1 * 1024 * 1024 - 1), /* int epochs_before_eviction = */ 4, /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f, + /* double empty_reserve = */ 0.05, /* int dirty_bytes_threshold = */ (256 * 1024), /* int metadata_write_strategy = */ H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; @@ -526,22 +526,22 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024 + 1), - /* double min_clean_fraction = */ 0.2f, + /* double min_clean_fraction = */ 0.2, /* size_t max_size = */ (16 * 1024 * 1024 + 1), /* size_t min_size = */ (1 * 1024 * 1024 + 1), /* long int epoch_length = */ 50001, /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, - /* double lower_hr_threshold = */ 0.91f, - /* double increment = */ 2.1f, + /* double lower_hr_threshold = */ 0.91, + /* double increment = */ 2.1, /* hbool_t apply_max_increment = */ TRUE, /* size_t max_increment = */ (4 * 1024 * 1024 + 1), /* enum H5C_cache_flash_incr_mode */ /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, + /* double flash_multiple = */ 2.0, + /* double flash_threshold = */ 0.5, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out, - /* double upper_hr_threshold = */ 0.998f, - /* double decrement = */ 0.91f, + /* double upper_hr_threshold = */ 0.998, + /* double decrement = */ 0.91, /* hbool_t apply_max_decrement = */ TRUE, /* size_t max_decrement = */ (1 * 1024 * 1024 - 1), /* int epochs_before_eviction = */ 4, @@ -559,27 +559,27 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (512 * 1024), - /* double min_clean_fraction = */ 0.1f, + /* double min_clean_fraction = */ 0.1, /* size_t max_size = */ (8 * 1024 * 1024), /* size_t min_size = */ (512 * 1024), /* long int epoch_length = */ 25000, /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, - /* double lower_hr_threshold = */ 0.9f, - /* double increment = */ 2.0f, + /* double lower_hr_threshold = */ 0.9, + /* double increment = */ 2.0, /* hbool_t apply_max_increment = */ TRUE, /* size_t max_increment = */ (2 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 1.5f, - /* double flash_threshold = */ 0.4f, + /* double flash_multiple = */ 1.5, + /* double flash_threshold = */ 0.4, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__threshold, - /* double upper_hr_threshold = */ 0.9995f, - /* double decrement = */ 0.95f, + /* double upper_hr_threshold = */ 0.9995, + /* double decrement = */ 0.95, /* hbool_t apply_max_decrement = */ TRUE, /* size_t max_decrement = */ (512 * 1024), /* int epochs_before_eviction = */ 4, /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f, + /* double empty_reserve = */ 0.05, /* int dirty_bytes_threshold = */ (256 * 1024), /* int metadata_write_strategy = */ H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; @@ -592,27 +592,27 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), - /* double min_clean_fraction = */ 0.2f, + /* double min_clean_fraction = */ 0.2, /* size_t max_size = */ (16 * 1024 * 1024), /* size_t min_size = */ (1 * 1024 * 1024), /* long int epoch_length = */ 50000, /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, - /* double lower_hr_threshold = */ 0.90f, - /* double increment = */ 2.0f, + /* double lower_hr_threshold = */ 0.90, + /* double increment = */ 2.0, /* hbool_t apply_max_increment = */ TRUE, /* size_t max_increment = */ (4 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.1f, - /* double flash_threshold = */ 0.6f, + /* double flash_multiple = */ 2.1, + /* double flash_threshold = */ 0.6, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, - /* double upper_hr_threshold = */ 0.999f, - /* double decrement = */ 0.9f, + /* double upper_hr_threshold = */ 0.999, + /* double decrement = */ 0.9, /* hbool_t apply_max_decrement = */ FALSE, /* size_t max_decrement = */ (1 * 1024 * 1024 - 1), /* int epochs_before_eviction = */ 3, /* hbool_t apply_empty_reserve = */ FALSE, - /* double empty_reserve = */ 0.05f, + /* double empty_reserve = */ 0.05, /* int dirty_bytes_threshold = */ (256 * 1024), /* int metadata_write_strategy = */ H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; @@ -625,28 +625,28 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), - /* double min_clean_fraction = */ 0.15f, + /* double min_clean_fraction = */ 0.15, /* size_t max_size = */ (20 * 1024 * 1024), /* size_t min_size = */ (1 * 1024 * 1024), /* long int epoch_length = */ 75000, /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, - /* double lower_hr_threshold = */ 0.9f, - /* double increment = */ 2.0f, + /* double lower_hr_threshold = */ 0.9, + /* double increment = */ 2.0, /* hbool_t apply_max_increment = */ TRUE, /* size_t max_increment = */ (2 * 1024 * 1024), /* enum H5C_cache_flash_incr_mode */ /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 1.1f, - /* double flash_threshold = */ 0.3f, + /* double flash_multiple = */ 1.1, + /* double flash_threshold = */ 0.3, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out_with_threshold, - /* double upper_hr_threshold = */ 0.999f, - /* double decrement = */ 0.9f, + /* double upper_hr_threshold = */ 0.999, + /* double decrement = */ 0.9, /* hbool_t apply_max_decrement = */ TRUE, /* size_t max_decrement = */ (1 * 1024 * 1024), /* int epochs_before_eviction = */ 3, /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.1f, + /* double empty_reserve = */ 0.1, /* int dirty_bytes_threshold = */ (256 * 1024), /* int metadata_write_strategy = */ H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; @@ -755,7 +755,7 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) pass = FALSE; failure_mssg = "H5Fget_mdc_hit_rate() failed 1.\n"; } - else if (!H5_DBL_ABS_EQUAL(hit_rate, (double)0.0f)) { + else if (!H5_DBL_ABS_EQUAL(hit_rate, 0.0)) { pass = FALSE; failure_mssg = "H5Fget_mdc_hit_rate() returned unexpected hit rate.\n"; @@ -857,7 +857,7 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) hbool_t valid_chunk; hbool_t dump_hit_rate = FALSE; int64_t min_accesses = 1000; - double min_hit_rate = 0.90f; + double min_hit_rate = 0.90; hbool_t dump_cache_size = FALSE; hid_t file_id = -1; hid_t dataspace_id = -1; @@ -883,27 +883,27 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ 500000, - /* double min_clean_fraction = */ 0.1f, + /* double min_clean_fraction = */ 0.1, /* size_t max_size = */ 16000000, /* size_t min_size = */ 250000, /* long int epoch_length = */ 50000, /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, - /* double lower_hr_threshold = */ 0.95f, - /* double increment = */ 2.0f, + /* double lower_hr_threshold = */ 0.95, + /* double increment = */ 2.0, /* hbool_t apply_max_increment = */ FALSE, /* size_t max_increment = */ 4000000, /* enum H5C_cache_flash_incr_mode */ /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, + /* double flash_multiple = */ 2.0, + /* double flash_threshold = */ 0.5, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, - /* double upper_hr_threshold = */ 0.999f, - /* double decrement = */ 0.9f, + /* double upper_hr_threshold = */ 0.999, + /* double decrement = */ 0.9, /* hbool_t apply_max_decrement = */ FALSE, /* size_t max_decrement = */ 1000000, /* int epochs_before_eviction = */ 2, /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f, + /* double empty_reserve = */ 0.05, /* int dirty_bytes_threshold = */ (256 * 1024), /* int metadata_write_strategy = */ H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; @@ -916,27 +916,27 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ 12000000, - /* double min_clean_fraction = */ 0.1f, + /* double min_clean_fraction = */ 0.1, /* size_t max_size = */ 16000000, /* size_t min_size = */ 250000, /* long int epoch_length = */ 50000, /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, - /* double lower_hr_threshold = */ 0.95f, - /* double increment = */ 2.0f, + /* double lower_hr_threshold = */ 0.95, + /* double increment = */ 2.0, /* hbool_t apply_max_increment = */ FALSE, /* size_t max_increment = */ 4000000, /* enum H5C_cache_flash_incr_mode */ /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, + /* double flash_multiple = */ 2.0, + /* double flash_threshold = */ 0.5, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, - /* double upper_hr_threshold = */ 0.999f, - /* double decrement = */ 0.9f, + /* double upper_hr_threshold = */ 0.999, + /* double decrement = */ 0.9, /* hbool_t apply_max_decrement = */ FALSE, /* size_t max_decrement = */ 1000000, /* int epochs_before_eviction = */ 2, /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f, + /* double empty_reserve = */ 0.05, /* int dirty_bytes_threshold = */ (256 * 1024), /* int metadata_write_strategy = */ H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; @@ -949,27 +949,27 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ 2000000, - /* double min_clean_fraction = */ 0.1f, + /* double min_clean_fraction = */ 0.1, /* size_t max_size = */ 16000000, /* size_t min_size = */ 250000, /* long int epoch_length = */ 50000, /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off, - /* double lower_hr_threshold = */ 0.95f, - /* double increment = */ 2.0f, + /* double lower_hr_threshold = */ 0.95, + /* double increment = */ 2.0, /* hbool_t apply_max_increment = */ FALSE, /* size_t max_increment = */ 4000000, /* enum H5C_cache_flash_incr_mode */ /* flash_incr_mode = */ H5C_flash_incr__off, - /* double flash_multiple = */ 2.0f, - /* double flash_threshold = */ 0.5f, + /* double flash_multiple = */ 2.0, + /* double flash_threshold = */ 0.5, /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, - /* double upper_hr_threshold = */ 0.999f, - /* double decrement = */ 0.9f, + /* double upper_hr_threshold = */ 0.999, + /* double decrement = */ 0.9, /* hbool_t apply_max_decrement = */ FALSE, /* size_t max_decrement = */ 1000000, /* int epochs_before_eviction = */ 2, /* hbool_t apply_empty_reserve = */ TRUE, - /* double empty_reserve = */ 0.05f, + /* double empty_reserve = */ 0.05, /* int dirty_bytes_threshold = */ (256 * 1024), /* int metadata_write_strategy = */ H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; @@ -1517,26 +1517,26 @@ init_invalid_configs(void) configs[i].evictions_enabled = TRUE; configs[i].set_initial_size = TRUE; configs[i].initial_size = (1 * 1024 * 1024); - configs[i].min_clean_fraction = 0.25F; + configs[i].min_clean_fraction = 0.25; configs[i].max_size = (16 * 1024 * 1024); configs[i].min_size = (1 * 1024 * 1024); configs[i].epoch_length = 50000; configs[i].incr_mode = H5C_incr__threshold; - configs[i].lower_hr_threshold = 0.9F; - configs[i].increment = 2.0F; + configs[i].lower_hr_threshold = 0.9; + configs[i].increment = 2.0; configs[i].apply_max_increment = TRUE; configs[i].max_increment = (4 * 1024 * 1024); configs[i].flash_incr_mode = H5C_flash_incr__off; - configs[i].flash_multiple = 2.0F; - configs[i].flash_threshold = 0.5F; + configs[i].flash_multiple = 2.0; + configs[i].flash_threshold = 0.5; configs[i].decr_mode = H5C_decr__age_out_with_threshold; - configs[i].upper_hr_threshold = 0.999F; - configs[i].decrement = 0.9F; + configs[i].upper_hr_threshold = 0.999; + configs[i].decrement = 0.9; configs[i].apply_max_decrement = TRUE; configs[i].max_decrement = (1 * 1024 * 1024); configs[i].epochs_before_eviction = 3; configs[i].apply_empty_reserve = TRUE; - configs[i].empty_reserve = 0.1F; + configs[i].empty_reserve = 0.1; configs[i].dirty_bytes_threshold = (256 * 1024); configs[i].metadata_write_strategy = H5AC__DEFAULT_METADATA_WRITE_STRATEGY; } @@ -1567,10 +1567,10 @@ init_invalid_configs(void) configs[6].initial_size = (1 * 1024 * 1024 - 1); /* 7 -- min_clean_fraction too big */ - configs[7].min_clean_fraction = 1.000001f; + configs[7].min_clean_fraction = 1.000001; /* 8 -- min_clean_fraction too small */ - configs[8].min_clean_fraction = -0.00000001f; + configs[8].min_clean_fraction = -0.00000001; /* 9 -- epoch_length too small */ configs[9].epoch_length = H5C__MIN_AR_EPOCH_LENGTH - 1; @@ -1582,10 +1582,10 @@ init_invalid_configs(void) configs[11].incr_mode = (enum H5C_cache_incr_mode) - 1; /* 12 -- lower_hr_threshold too small */ - configs[12].lower_hr_threshold = -0.000001f; + configs[12].lower_hr_threshold = -0.000001; /* 13 -- lower_hr_threshold too big */ - configs[13].lower_hr_threshold = 1.00000001f; + configs[13].lower_hr_threshold = 1.00000001; /* 14 -- increment too small */ configs[14].increment = 0.999999999999; @@ -1595,29 +1595,29 @@ init_invalid_configs(void) /* 16 -- flash_multiple too small */ configs[16].flash_incr_mode = H5C_flash_incr__add_space; - configs[16].flash_multiple = 0.09f; + configs[16].flash_multiple = 0.09; /* 17 -- flash_multiple too big */ configs[17].flash_incr_mode = H5C_flash_incr__add_space; - configs[17].flash_multiple = 10.001f; + configs[17].flash_multiple = 10.001; /* 18 -- flash_threshold too small */ configs[18].flash_incr_mode = H5C_flash_incr__add_space; - configs[18].flash_threshold = 0.099f; + configs[18].flash_threshold = 0.099; /* 19 -- flash_threshold too big */ configs[19].flash_incr_mode = H5C_flash_incr__add_space; - configs[19].flash_threshold = 1.001f; + configs[19].flash_threshold = 1.001; /* 20 -- bad decr_mode */ configs[20].decr_mode = (enum H5C_cache_decr_mode) - 1; /* 21 -- upper_hr_threshold too big */ - configs[21].upper_hr_threshold = 1.00001f; + configs[21].upper_hr_threshold = 1.00001; /* 22 -- decrement too small */ configs[22].decr_mode = H5C_decr__threshold; - configs[22].decrement = -0.0000000001f; + configs[22].decrement = -0.0000000001; /* 23 -- decrement too big */ configs[23].decr_mode = H5C_decr__threshold; @@ -1630,20 +1630,20 @@ init_invalid_configs(void) configs[25].epochs_before_eviction = H5C__MAX_EPOCH_MARKERS + 1; /* 26 -- empty_reserve too small */ - configs[26].empty_reserve = -0.0000000001f; + configs[26].empty_reserve = -0.0000000001; /* 27 -- empty_reserve too big */ configs[27].empty_reserve = 1.00000000001; /* 28 -- upper_hr_threshold too small */ - configs[28].upper_hr_threshold = -0.000000001f; + configs[28].upper_hr_threshold = -0.000000001; /* 29 -- upper_hr_threshold too big */ configs[29].upper_hr_threshold = 1.00000001; /* 30 -- upper_hr_threshold <= lower_hr_threshold */ - configs[30].lower_hr_threshold = 0.9f; - configs[30].upper_hr_threshold = 0.9f; + configs[30].lower_hr_threshold = 0.9; + configs[30].upper_hr_threshold = 0.9; /* 31 -- dirty_bytes_threshold too small */ configs[31].dirty_bytes_threshold = (H5C__MIN_MAX_CACHE_SIZE / 2) - 1; diff --git a/test/cross_read.c b/test/cross_read.c index 386c0dae73b..eef814f151d 100644 --- a/test/cross_read.c +++ b/test/cross_read.c @@ -159,9 +159,9 @@ check_data_f(const char *dsetname, hid_t fid) /* Input (last row is different) */ for (i = 0; i < NX; i++) for (j = 0; j < NY; j++) - data_in[i][j] = ((double)(i + j + 1)) / (double)3.0F; + data_in[i][j] = ((double)(i + j + 1)) / 3.0; for (i = 0; i < NY; i++) - data_in[NX][i] = -2.2F; + data_in[NX][i] = -2.2; /* Output */ HDmemset(data_out, 0, (NX + 1) * NY * sizeof(double)); @@ -174,7 +174,7 @@ check_data_f(const char *dsetname, hid_t fid) /* Check results */ for (i = 0; i < (NX + 1); i++) for (j = 0; j < NY; j++) - if (!H5_DBL_REL_EQUAL(data_out[i][j], data_in[i][j], (double)0.001F)) + if (!H5_DBL_REL_EQUAL(data_out[i][j], data_in[i][j], 0.001)) if (!nerrors++) { H5_FAILED(); HDprintf("element [%d][%d] is %g but should have been %g\n", (int)i, (int)j, diff --git a/test/dsets.c b/test/dsets.c index 6160c65d617..39bb874f100 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -6520,7 +6520,7 @@ test_set_local(hid_t fapl) for (i = 0; i < DSET_DIM1; i++) for (j = 0; j < DSET_DIM2; j++) { points[i][j] = (int)n++; - points_dbl[i][j] = (double)1.5F * n++; + points_dbl[i][j] = 1.5 * n++; } /* Open file */ @@ -6716,7 +6716,7 @@ test_set_local(hid_t fapl) for (j = 0; j < dims[1]; j++) { /* If the difference between two values is greater than 0.001%, they're * considered not equal. */ - if (!H5_DBL_REL_EQUAL(points_dbl[i][j], check_dbl[i][j], (double)0.00001F)) { + if (!H5_DBL_REL_EQUAL(points_dbl[i][j], check_dbl[i][j], 0.00001)) { H5_FAILED(); HDprintf(" Line %d: Read different values than written.\n", __LINE__); HDprintf(" At index %lu,%lu\n", (unsigned long)(i), (unsigned long)(j)); @@ -8803,7 +8803,7 @@ test_chunk_cache(hid_t fapl) /* Set new rdcc settings on fapl */ nslots_2 = nslots_1 * 2; nbytes_2 = nbytes_1 * 2; - w0_2 = w0_1 / (double)2.0F; + w0_2 = w0_1 / 2.0; if (H5Pset_cache(fapl_local, 0, nslots_2, nbytes_2, w0_2) < 0) FAIL_STACK_ERROR diff --git a/test/dt_arith.c b/test/dt_arith.c index f2bf6cf48b9..0ce147541a3 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -3322,7 +3322,7 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) int expo_diff = check_expo[0] - check_expo[1]; int valid_bits = (int)((dst_ebias + dst_msize) + (size_t)MIN(check_expo[0], check_expo[1])) - 1; - double epsilon = 1.0F; + double epsilon = 1.0; /* Re-scale the mantissas based on any exponent difference */ if (expo_diff != 0) diff --git a/test/dtypes.c b/test/dtypes.c index b7b8dbdc15e..03516a14de9 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -2284,9 +2284,9 @@ test_compound_11(void) /* Initialize buffer */ for (u = 0; u < NTESTELEM; u++) { - ((big_t *)buf)[u].d1 = (double)u * (double)1.5f; - ((big_t *)buf)[u].d2 = (double)u * (double)2.5f; - ((big_t *)buf)[u].d3 = (double)u * (double)3.5f; + ((big_t *)buf)[u].d1 = (double)u * 1.5; + ((big_t *)buf)[u].d2 = (double)u * 2.5; + ((big_t *)buf)[u].d3 = (double)u * 3.5; ((big_t *)buf)[u].i1 = (int)(u * 3); ((big_t *)buf)[u].i2 = (int)(u * 5); ((big_t *)buf)[u].s1 = (char *)HDmalloc((size_t)32); diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c index 700014002da..5879e38e9a5 100644 --- a/test/enc_dec_plist.c +++ b/test/enc_dec_plist.c @@ -66,28 +66,32 @@ test_encode_decode(hid_t orig_pl) int main(void) { - hid_t dcpl; /* dataset create prop. list */ - hid_t dapl; /* dataset access prop. list */ - hid_t dxpl; /* dataset xfer prop. list */ - hid_t gcpl; /* group create prop. list */ - hid_t ocpypl; /* object copy prop. list */ - hid_t ocpl; /* object create prop. list */ - hid_t lcpl; /* link create prop. list */ - hid_t lapl; /* link access prop. list */ - hid_t fapl; /* file access prop. list */ - hid_t fcpl; /* file create prop. list */ - hid_t strcpl; /* string create prop. list */ - hid_t acpl; /* attribute create prop. list */ - - hsize_t chunk_size[2] = {16384, 4}; /* chunk size */ - double fill = 2.7f; /* Fill value */ - hsize_t max_size[1]; /* data space maximum size */ - size_t nslots = 521 * 2; - size_t nbytes = 1048576 * 10; - double w0 = 0.5f; - unsigned max_compact; - unsigned min_dense; - const char * c_to_f = "x+32"; + hid_t dcpl; /* dataset create prop. list */ + hid_t dapl; /* dataset access prop. list */ + hid_t dxpl; /* dataset xfer prop. list */ + hid_t gcpl; /* group create prop. list */ + hid_t ocpypl; /* object copy prop. list */ + hid_t ocpl; /* object create prop. list */ + hid_t lcpl; /* link create prop. list */ + hid_t lapl; /* link access prop. list */ + hid_t fapl; /* file access prop. list */ + hid_t fcpl; /* file create prop. list */ + hid_t strcpl; /* string create prop. list */ + hid_t acpl; /* attribute create prop. list */ + hid_t srcspace = -1; /* Source dataspaces */ + hid_t vspace = -1; /* Virtual dset dataspaces */ + hsize_t dims[1] = {3}; /* Data space current size */ + hsize_t chunk_size[2] = {16384, 4}; /* chunk size */ + double fill = 2.7; /* Fill value */ + hsize_t max_size[1]; /* data space maximum size */ + size_t nslots = 521 * 2; + size_t nbytes = 1048576 * 10; + double w0 = 0.5; + unsigned max_compact; + unsigned min_dense; + const char * c_to_f = "x+32"; + H5F_libver_t low, high; /* Low and high bounds */ + H5AC_cache_config_t my_cache_config = {H5AC__CURR_CACHE_CONFIG_VERSION, TRUE, FALSE, @@ -96,26 +100,26 @@ main(void) TRUE, FALSE, (2 * 2048 * 1024), - 0.3f, + 0.3, (64 * 1024 * 1024), (4 * 1024 * 1024), 60000, H5C_incr__threshold, - 0.8f, - 3.0f, + 0.8, + 3.0, TRUE, (8 * 1024 * 1024), H5C_flash_incr__add_space, - 2.0f, - 0.25f, + 2.0, + 0.25, H5C_decr__age_out_with_threshold, - 0.997f, - 0.8f, + 0.997, + 0.8, TRUE, (3 * 1024 * 1024), 3, FALSE, - 0.2f, + 0.2, (256 * 2048), H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; diff --git a/test/gen_cross.c b/test/gen_cross.c index 3eac79a1604..2746bb6190c 100644 --- a/test/gen_cross.c +++ b/test/gen_cross.c @@ -295,7 +295,7 @@ create_scale_offset_dsets_double(hid_t fid, hid_t fsid, hid_t msid) hid_t dataset = -1; /* dataset handles */ hid_t dcpl = -1; double data[NX][NY]; /* data to write */ - double fillvalue = -2.2f; + double fillvalue = -2.2; hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; int i, j; diff --git a/test/gen_plist.c b/test/gen_plist.c index 911e6d1c766..e9db75268e2 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -42,7 +42,7 @@ main(void) hsize_t max_size[1]; /* data space maximum size */ size_t nslots = 521 * 2; size_t nbytes = 1048576 * 10; - double w0 = 0.5f; + double w0 = 0.5; unsigned max_compact; unsigned min_dense; const char * c_to_f = "x+32"; @@ -56,26 +56,26 @@ main(void) 1 /*TRUE*/, 0 /*FALSE*/, (2 * 2048 * 1024), - 0.3f, + 0.3, (64 * 1024 * 1024), (4 * 1024 * 1024), 60000, H5C_incr__threshold, - 0.8f, - 3.0f, + 0.8, + 3.0, 1 /*TRUE*/, (8 * 1024 * 1024), H5C_flash_incr__add_space, - 2.0f, - 0.25f, + 2.0, + 0.25, H5C_decr__age_out_with_threshold, - 0.997f, - 0.8f, + 0.997, + 0.8, 1 /*TRUE*/, (3 * 1024 * 1024), 3, 0 /*FALSE*/, - 0.2f, + 0.2, (256 * 2048), H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY}; H5AC_cache_image_config_t my_cache_image_config = {H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, TRUE, FALSE, diff --git a/test/links.c b/test/links.c index 3dfba36cf9e..77a2c496b88 100644 --- a/test/links.c +++ b/test/links.c @@ -139,7 +139,7 @@ const char *FILENAME[] = {"links0", #define H5L_DIM1 100 #define H5L_DIM2 100 -#define FILTER_FILESIZE_MAX_FRACTION (double)0.9F +#define FILTER_FILESIZE_MAX_FRACTION 0.9 /* Creation order macros */ #define CORDER_GROUP_NAME "corder_group" diff --git a/test/mtime.c b/test/mtime.c index 02ba0f06211..fd5fc42bf5b 100644 --- a/test/mtime.c +++ b/test/mtime.c @@ -117,7 +117,7 @@ main(void) HDputs(" cannot be queried on this system. See H5O_mtime_decode()."); return 0; } - else if (HDfabs(HDdifftime(now, oi1.ctime)) > (double)60.0F) { + else if (HDfabs(HDdifftime(now, oi1.ctime)) > 60.0) { H5_FAILED(); tm = HDlocaltime(&(oi1.ctime)); HDstrftime((char *)buf1, sizeof buf1, "%Y-%m-%d %H:%M:%S", tm); diff --git a/test/objcopy.c b/test/objcopy.c index a1ca06b896a..52239ec2751 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -2897,7 +2897,7 @@ test_copy_dataset_compound(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t HDmemset(buf, 0, sizeof(buf)); for (i = 0; i < DIM_SIZE_1; i++) { buf[i].a = i; - buf[i].d = (double)1.0F / (double)(i + 1); + buf[i].d = 1.0 / (double)(i + 1); } /* end for */ /* Initialize the filenames */ diff --git a/test/tattr.c b/test/tattr.c index 69e625aa684..9f0e4e40487 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -508,13 +508,13 @@ test_attr_basic_read(hid_t fapl) static void test_attr_flush(hid_t fapl) { - hid_t fil, /* File ID */ - att, /* Attribute ID */ - spc, /* Dataspace ID */ - set; /* Dataset ID */ - double wdata = 3.14159F; /* Data to write */ - double rdata; /* Data read in */ - herr_t ret; /* Generic return value */ + hid_t fil, /* File ID */ + att, /* Attribute ID */ + spc, /* Dataspace ID */ + set; /* Dataset ID */ + double wdata = 3.14159; /* Data to write */ + double rdata; /* Data read in */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Attribute Flushing\n")); @@ -534,8 +534,8 @@ test_attr_flush(hid_t fapl) ret = H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); CHECK(ret, FAIL, "H5Awrite"); - if (!H5_DBL_ABS_EQUAL(rdata, (double)0.0f)) - TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n", rdata, (double)0.0F); + if (!H5_DBL_ABS_EQUAL(rdata, 0.0)) + TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n", rdata, 0.0); ret = H5Fflush(fil, H5F_SCOPE_GLOBAL); CHECK(ret, FAIL, "H5Fflush"); @@ -543,8 +543,8 @@ test_attr_flush(hid_t fapl) ret = H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); CHECK(ret, FAIL, "H5Awrite"); - if (!H5_DBL_ABS_EQUAL(rdata, (double)0.0f)) - TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n", rdata, (double)0.0F); + if (!H5_DBL_ABS_EQUAL(rdata, 0.0)) + TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n", rdata, 0.0); ret = H5Awrite(att, H5T_NATIVE_DOUBLE, &wdata); CHECK(ret, FAIL, "H5Awrite"); diff --git a/test/tgenprop.c b/test/tgenprop.c index 7e805e22cde..55e5a9b5cd0 100644 --- a/test/tgenprop.c +++ b/test/tgenprop.c @@ -55,7 +55,7 @@ char prop3_def[10] = "Ten chars"; /* Property 3 default value */ #define PROP3_DEF_VALUE (&prop3_def) #define PROP4_NAME "Property 4" -double prop4_def = 1.41F; /* Property 4 default value */ +double prop4_def = 1.41; /* Property 4 default value */ #define PROP4_SIZE sizeof(prop4_def) #define PROP4_DEF_VALUE (&prop4_def) diff --git a/test/th5s.c b/test/th5s.c index e6984906503..9bcd52f38fc 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -1765,7 +1765,7 @@ test_h5s_chunk(void) for (i = 0; i < CHUNK_DATA_NX; i++) { for (j = 0; j < CHUNK_DATA_NY; j++) { /* Check if the two values are within 0.001% range. */ - if (!H5_DBL_REL_EQUAL(chunk_data_dbl[i][j], (double)chunk_data_flt[i][j], (double)0.00001F)) + if (!H5_DBL_REL_EQUAL(chunk_data_dbl[i][j], (double)chunk_data_flt[i][j], 0.00001)) TestErrPrintf("%u: chunk_data_dbl[%d][%d]=%e, chunk_data_flt[%d][%d]=%e\n", (unsigned)__LINE__, i, j, chunk_data_dbl[i][j], i, j, (double)chunk_data_flt[i][j]); diff --git a/test/timer.c b/test/timer.c index 24f3245099f..bb474ca172c 100644 --- a/test/timer.c +++ b/test/timer.c @@ -144,7 +144,7 @@ test_timer_system_user(void) /* The system and user times may not be present on some systems. They * will be -1.0 if they are not. */ - if (timer.initial.system < (double)0.0f || timer.initial.user < (double)0.0f) { + if (timer.initial.system < 0.0 || timer.initial.user < 0.0) { SKIPPED(); HDprintf("NOTE: No suitable way to get system/user times on this platform.\n"); return 0; @@ -165,7 +165,7 @@ test_timer_system_user(void) TEST_ERROR; /* System and user times should be non-negative. */ - if (times.system < (double)0.0f || times.user < (double)0.0f) + if (times.system < 0.0 || times.user < 0.0) TEST_ERROR; PASSED(); @@ -224,7 +224,7 @@ test_timer_elapsed(void) TEST_ERROR; /* Elapsed time should be non-negative. */ - if (times.elapsed < (double)0.0f) + if (times.elapsed < 0.0) TEST_ERROR; PASSED(); @@ -260,11 +260,11 @@ test_timer_functionality(void) /* Times should be initialized to zero */ err = H5_timer_get_times(timer, ×); - if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) + if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, 0.0)) TEST_ERROR; err = H5_timer_get_total_times(timer, ×); - if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) + if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, 0.0)) TEST_ERROR; /******************** @@ -289,11 +289,11 @@ test_timer_functionality(void) /* Times should be positive and non-negative */ err = H5_timer_get_times(timer, ×); - if (err < 0 || times.elapsed < (double)0.0f) + if (err < 0 || times.elapsed < 0.0) TEST_ERROR; err = H5_timer_get_total_times(timer, ×); - if (err < 0 || times.elapsed < (double)0.0f) + if (err < 0 || times.elapsed < 0.0) TEST_ERROR; /********************** @@ -306,11 +306,11 @@ test_timer_functionality(void) TEST_ERROR; err = H5_timer_get_times(timer, ×); - if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) + if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, 0.0)) TEST_ERROR; err = H5_timer_get_total_times(timer, ×); - if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) + if (err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, 0.0)) TEST_ERROR; /* Timer state should flip */ @@ -326,12 +326,12 @@ test_timer_functionality(void) /* Times should be non-negative */ err = H5_timer_get_times(timer, ×); - if (err < 0 || times.elapsed < (double)0.0f) + if (err < 0 || times.elapsed < 0.0) TEST_ERROR; prev_etime = times.elapsed; err = H5_timer_get_total_times(timer, ×); - if (err < 0 || times.elapsed < (double)0.0f) + if (err < 0 || times.elapsed < 0.0) TEST_ERROR; prev_total_etime = times.elapsed; diff --git a/test/tmisc.c b/test/tmisc.c index 8dac16d36a0..a5591914ad2 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -2521,17 +2521,17 @@ test_misc13(void) static void test_misc14(void) { - hid_t file_id; /* File ID */ - hid_t fapl; /* File access property list ID */ - hid_t DataSpace; /* Dataspace ID */ - hid_t Dataset1; /* Dataset ID #1 */ - hid_t Dataset2; /* Dataset ID #2 */ - hid_t Dataset3; /* Dataset ID #3 */ - double data1 = 5.0F; /* Data to write for dataset #1 */ - double data2 = 10.0F; /* Data to write for dataset #2 */ - double data3 = 15.0F; /* Data to write for dataset #3 */ - double rdata; /* Data read in */ - herr_t ret; /* Generic return value */ + hid_t file_id; /* File ID */ + hid_t fapl; /* File access property list ID */ + hid_t DataSpace; /* Dataspace ID */ + hid_t Dataset1; /* Dataset ID #1 */ + hid_t Dataset2; /* Dataset ID #2 */ + hid_t Dataset3; /* Dataset ID #3 */ + double data1 = 5.0; /* Data to write for dataset #1 */ + double data2 = 10.0; /* Data to write for dataset #2 */ + double data3 = 15.0; /* Data to write for dataset #3 */ + double rdata; /* Data read in */ + herr_t ret; /* Generic return value */ /* Test creating two datasets and deleting the second */ diff --git a/testpar/t_prop.c b/testpar/t_prop.c index bcde00e231e..518fec63f02 100644 --- a/testpar/t_prop.c +++ b/testpar/t_prop.c @@ -98,10 +98,10 @@ test_plist_ed(void) int mpi_size, mpi_rank, recv_proc; hsize_t chunk_size = 16384; /* chunk size */ - double fill = 2.7f; /* Fill value */ + double fill = 2.7; /* Fill value */ size_t nslots = 521 * 2; size_t nbytes = 1048576 * 10; - double w0 = 0.5f; + double w0 = 0.5; unsigned max_compact; unsigned min_dense; hsize_t max_size[1]; /*data space maximum size */ @@ -114,26 +114,26 @@ test_plist_ed(void) TRUE, FALSE, (2 * 2048 * 1024), - 0.3f, + 0.3, (64 * 1024 * 1024), (4 * 1024 * 1024), 60000, H5C_incr__threshold, - 0.8f, - 3.0f, + 0.8, + 3.0, TRUE, (8 * 1024 * 1024), H5C_flash_incr__add_space, - 2.0f, - 0.25f, + 2.0, + 0.25, H5C_decr__age_out_with_threshold, - 0.997f, - 0.8f, + 0.997, + 0.8, TRUE, (3 * 1024 * 1024), 3, FALSE, - 0.2f, + 0.2, (256 * 2048), H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; diff --git a/tools/src/h5diff/h5diff_common.c b/tools/src/h5diff/h5diff_common.c index 05c0e05406c..e6b384ae93f 100644 --- a/tools/src/h5diff/h5diff_common.c +++ b/tools/src/h5diff/h5diff_common.c @@ -369,7 +369,7 @@ parse_command_line(int argc, const char *argv[], const char **fname1, const char opts->percent = HDatof(opt_arg); /* -p 0 is the same as default */ - if (H5_DBL_ABS_EQUAL(opts->percent, (double)0.0F)) + if (H5_DBL_ABS_EQUAL(opts->percent, 0.0)) opts->percent_bool = 0; break; diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index fcd403ec931..bb164a85f53 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -1969,7 +1969,7 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name) HSIZE_T_FORMAT " logical byte%s, " HSIZE_T_FORMAT " allocated byte%s", total, 1 == total ? "" : "s", used, 1 == used ? "" : "s"); if (used > 0) { - utilization = ((double)total * (double)100.0f) / (double)used; + utilization = ((double)total * 100.0) / (double)used; h5tools_str_append(&buffer, ", %1.2f%% utilization", utilization); } } diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index b000c46683f..e5b235d01d5 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -1603,7 +1603,7 @@ print_storage_summary(const iter_t *iter) { hsize_t total_meta = 0; hsize_t unaccount = 0; - double percent = 0.0f; + double percent = 0.0; HDfprintf(stdout, "File space management strategy: %s\n", FS_STRATEGY_NAME[iter->fs_strategy]); HDfprintf(stdout, "File space page size: %" PRIuHSIZE " bytes\n", iter->fsp_size); @@ -1618,7 +1618,7 @@ print_storage_summary(const iter_t *iter) HDfprintf(stdout, " File metadata: %" PRIuHSIZE " bytes\n", total_meta); HDfprintf(stdout, " Raw data: %" PRIuHSIZE " bytes\n", iter->dset_storage_size); - percent = ((double)iter->free_space / (double)iter->filesize) * (double)100.0f; + percent = ((double)iter->free_space / (double)iter->filesize) * 100.0; HDfprintf(stdout, " Amount/Percent of tracked free space: %" PRIuHSIZE " bytes/%3.1f%%\n", iter->free_space, percent); diff --git a/tools/test/h5import/h5importtest.c b/tools/test/h5import/h5importtest.c index 340e31bd299..e49125bc784 100644 --- a/tools/test/h5import/h5importtest.c +++ b/tools/test/h5import/h5importtest.c @@ -64,8 +64,8 @@ main(void) double b64r3[5][3][4]; double row8[3], col8[4], pln8[5]; - double rowo8 = 11.0F, colo8 = 21.0F, plno8 = 51.0F; - double rowi8 = 1.0F, coli8 = 2.0F, plni8 = 5.0F; + double rowo8 = 11.0, colo8 = 21.0, plno8 = 51.0; + double rowi8 = 1.0, coli8 = 2.0, plni8 = 5.0; /* Initialize machine endian */ volatile uint32_t ibyte = 0x01234567; diff --git a/tools/test/perform/chunk.c b/tools/test/perform/chunk.c index ada2ed39420..1b6793a5950 100644 --- a/tools/test/perform/chunk.c +++ b/tools/test/perform/chunk.c @@ -55,20 +55,20 @@ #define RM_CACHE_STRT 25 #define RM_CACHE_END 25 #define RM_CACHE_DELT 5 -#define RM_START (double)0.50F -#define RM_END (double)5.00F -#define RM_DELTA (double)0.50F -#define RM_W0 0.0F +#define RM_START 0.50 +#define RM_END 5.00 +#define RM_DELTA 0.50 +#define RM_W0 0.0 #define RM_NRDCC 521 /* Diagonal test */ #define DIAG_CACHE_STRT 25 #define DIAG_CACHE_END 25 #define DIAG_CACHE_DELT 5 -#define DIAG_START (double)0.50F -#define DIAG_END (double)5.00F -#define DIAG_DELTA (double)0.50F -/* #define DIAG_W0 0.65F */ +#define DIAG_START 0.50 +#define DIAG_END 5.00 +#define DIAG_DELTA 0.50 +/* #define DIAG_W0 0.65 */ /* #define DIAG_NRDCC 521 */ static size_t nio_g; diff --git a/tools/test/perform/chunk_cache.c b/tools/test/perform/chunk_cache.c index fcaa33736f0..25fa34cb880 100644 --- a/tools/test/perform/chunk_cache.c +++ b/tools/test/perform/chunk_cache.c @@ -262,13 +262,14 @@ check_partial_chunks_perf(hid_t file) end_t = H5_get_time(); - if ((end_t - start_t) > (double)0.0f) - printf("1. Partial chunks: total read time is %lf; number of bytes being read from file is %zu\n", - (end_t - start_t), nbytes_global); + if ((end_t - start_t) > 0.0) + HDprintf("1. Partial chunks: total read time is %lf; number of bytes being read from file is %zu\n", + (end_t - start_t), nbytes_global); else - printf("1. Partial chunks: no total read time because timer is not available; number of bytes being " - "read from file is %zu\n", - nbytes_global); + HDprintf( + "1. Partial chunks: no total read time because timer is not available; number of bytes being " + "read from file is %zu\n", + nbytes_global); H5Dclose(dataset); H5Sclose(filespace); @@ -340,13 +341,14 @@ check_hash_value_perf(hid_t file) end_t = H5_get_time(); - if ((end_t - start_t) > (double)0.0f) - printf("2. Hash value: total read time is %lf; number of bytes being read from file is %zu\n", - (end_t - start_t), nbytes_global); + if ((end_t - start_t) > 0.0) + HDprintf("2. Hash value: total read time is %lf; number of bytes being read from file is %zu\n", + (end_t - start_t), nbytes_global); else - printf("2. Hash value: no total read time because timer is not available; number of bytes being read " - "from file is %zu\n", - nbytes_global); + HDprintf( + "2. Hash value: no total read time because timer is not available; number of bytes being read " + "from file is %zu\n", + nbytes_global); H5Dclose(dataset); H5Sclose(filespace); @@ -375,7 +377,7 @@ check_hash_value_perf(hid_t file) int main(void) { - hid_t file; /* handles */ + hid_t file = H5I_INVALID_HID; /* file ID */ int nerrors = 0; /* Create a new file. If file exists its contents will be overwritten. */ @@ -404,6 +406,6 @@ main(void) return 0; error: - fprintf(stderr, "*** ERRORS DETECTED ***\n"); + HDfprintf(stderr, "*** ERRORS DETECTED ***\n"); return 1; } diff --git a/tools/test/perform/iopipe.c b/tools/test/perform/iopipe.c index 68eaa3aa7af..d0db06aeabf 100644 --- a/tools/test/perform/iopipe.c +++ b/tools/test/perform/iopipe.c @@ -64,11 +64,11 @@ print_stats(const char *prefix, #ifdef H5_HAVE_GETRUSAGE double u_time, s_time; - u_time = ((double)(r_stop->ru_utime.tv_sec) + (double)(r_stop->ru_utime.tv_usec) / (double)1000000.0F) - - ((double)(r_start->ru_utime.tv_sec) + (double)(r_start->ru_utime.tv_usec) / (double)1000000.0F); + u_time = ((double)(r_stop->ru_utime.tv_sec) + (double)(r_stop->ru_utime.tv_usec) / 1000000.0) - + ((double)(r_start->ru_utime.tv_sec) + (double)(r_start->ru_utime.tv_usec) / 1000000.0); - s_time = ((double)(r_stop->ru_stime.tv_sec) + (double)(r_stop->ru_stime.tv_usec) / (double)1000000.0F) - - ((double)(r_start->ru_stime.tv_sec) + (double)(r_start->ru_stime.tv_usec) / (double)1000000.0F); + s_time = ((double)(r_stop->ru_stime.tv_sec) + (double)(r_stop->ru_stime.tv_usec) / 1000000.0) - + ((double)(r_start->ru_stime.tv_sec) + (double)(r_start->ru_stime.tv_usec) / 1000000.0); #endif e_time = t_stop - t_start; H5_bandwidth(bw, (double)nbytes, e_time); @@ -149,8 +149,7 @@ main(void) * Win32 version 5.0 compiler. * 1998-11-06 ptl */ - HDprintf("I/O request size is %1.1fMB\n", - (double)(hssize_t)(size[0] * size[1]) / (double)1024.0F * (double)1024); + HDprintf("I/O request size is %1.1fMB\n", (double)(hssize_t)(size[0] * size[1]) / 1024.0 * 1024.0); /* Open the files */ file = H5Fcreate(HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); diff --git a/tools/test/perform/sio_perf.c b/tools/test/perform/sio_perf.c index 5b3a9e8e8dd..fe4e7e7435b 100644 --- a/tools/test/perform/sio_perf.c +++ b/tools/test/perform/sio_perf.c @@ -65,8 +65,7 @@ #define SIO_HDF5 0x4 /* report 0.0 in case t is zero too */ -#define MB_PER_SEC(bytes, t) \ - (H5_DBL_ABS_EQUAL(t, (double)0.0F) ? (double)0.0F : ((((double)bytes) / (double)ONE_MB) / (t))) +#define MB_PER_SEC(bytes, t) (H5_DBL_ABS_EQUAL(t, 0.0) ? 0.0 : ((((double)bytes) / (double)ONE_MB) / (t))) #ifndef TRUE #define TRUE 1 diff --git a/tools/test/perform/zip_perf.c b/tools/test/perform/zip_perf.c index 6a1e1aae8e0..517866b4fb5 100644 --- a/tools/test/perform/zip_perf.c +++ b/tools/test/perform/zip_perf.c @@ -32,11 +32,10 @@ #define ONE_MB (ONE_KB * ONE_KB) #define ONE_GB (ONE_MB * ONE_KB) -#define MICROSECOND 1000000.0F +#define MICROSECOND 1000000.0 /* report 0.0 in case t is zero too */ -#define MB_PER_SEC(bytes, t) \ - ((fabs(t) < (double)0.0000000001F) ? (double)0.0F : ((((double)bytes) / (double)ONE_MB) / (t))) +#define MB_PER_SEC(bytes, t) ((fabs(t) < 0.0000000001) ? 0.0 : ((((double)bytes) / (double)ONE_MB) / (t))) #ifndef TRUE #define TRUE 1 @@ -169,7 +168,7 @@ write_file(Bytef *source, uLongf sourceLen) /* destination buffer needs to be at least 0.1% larger than sourceLen * plus 12 bytes */ - destLen = (uLongf)((double)sourceLen + ((double)sourceLen * (double)0.1F)) + 12; + destLen = (uLongf)((double)sourceLen + ((double)sourceLen * 0.1)) + 12; dest = (Bytef *)HDmalloc(destLen); if (!dest) @@ -179,8 +178,8 @@ write_file(Bytef *source, uLongf sourceLen) compress_buffer(dest, &destLen, source, sourceLen); HDgettimeofday(&timer_stop, NULL); - compression_time += ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / (double)MICROSECOND) - - ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / (double)MICROSECOND); + compression_time += ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / MICROSECOND) - + ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / MICROSECOND); if (report_once_flag) { HDfprintf(stdout, "\tCompression Ratio: %g\n", ((double)destLen) / (double)sourceLen); From e2bfcf452c34f608af47c3579fded0ea2abfa286 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Fri, 7 May 2021 09:44:07 -0700 Subject: [PATCH 04/13] Cleans up a const warning left over from previous constification (#633) * Committing clang-format changes * Adds consts to a few global variables * Cleans up a const warning left over from previous constification Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- src/H5Clog.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/H5Clog.h b/src/H5Clog.h index bd5c413bbd8..790a0736be3 100644 --- a/src/H5Clog.h +++ b/src/H5Clog.h @@ -79,10 +79,10 @@ typedef struct H5C_log_class_t { /* Logging information */ struct H5C_log_info_t { - hbool_t enabled; /* Was the logging set up? */ - hbool_t logging; /* Are we currently logging? */ - H5C_log_class_t *cls; /* Callbacks for writing log messages */ - void * udata; /* Log-specific data */ + hbool_t enabled; /* Was the logging set up? */ + hbool_t logging; /* Are we currently logging? */ + const H5C_log_class_t *cls; /* Callbacks for writing log messages */ + void * udata; /* Log-specific data */ }; /*****************************/ From a31787359ddbaa824bbd200de49f5d3e4fd2bec1 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Tue, 11 May 2021 09:05:03 -0700 Subject: [PATCH 05/13] Purges UFAIL from the library (#637) * Committing clang-format changes * Purges UFAIL from the library * H5HL_insert change requested in PR Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- src/H5Dchunk.c | 6 +- src/H5Dearray.c | 16 +- src/H5Dlayout.c | 17 +- src/H5Gent.c | 13 +- src/H5Gstab.c | 5 +- src/H5HL.c | 42 ++--- src/H5HLprivate.h | 2 +- src/H5Oefl.c | 8 +- src/H5SM.c | 59 +++--- src/H5Smpio.c | 3 +- src/H5Tbit.c | 9 +- src/H5VM.c | 386 +++++++++++++++++++-------------------- src/H5VMprivate.h | 2 +- src/H5private.h | 1 - test/dsets.c | 6 +- test/lheap.c | 2 +- tools/src/misc/h5debug.c | 2 +- 17 files changed, 274 insertions(+), 305 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 7700c0e1048..a727d886028 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -708,10 +708,8 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize } /* end for */ /* Get the "down" sizes for each dimension */ - if (H5VM_array_down(ndims, layout->chunks, layout->down_chunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute 'down' chunk size value") - if (H5VM_array_down(ndims, layout->max_chunks, layout->max_down_chunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute 'down' chunk size value") + H5VM_array_down(ndims, layout->chunks, layout->down_chunks); + H5VM_array_down(ndims, layout->max_chunks, layout->max_down_chunks); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Dearray.c b/src/H5Dearray.c index 24e8df2ff95..abce23308cf 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -1160,9 +1160,7 @@ H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda static herr_t H5D__earray_idx_resize(H5O_layout_chunk_t *layout) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(layout); @@ -1182,8 +1180,7 @@ H5D__earray_idx_resize(H5O_layout_chunk_t *layout) H5VM_swizzle_coords(hsize_t, swizzled_chunks, layout->u.earray.unlim_dim); /* Get the swizzled "down" sizes for each dimension */ - if (H5VM_array_down((layout->ndims - 1), swizzled_chunks, layout->u.earray.swizzled_down_chunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute swizzled 'down' chunk size value") + H5VM_array_down((layout->ndims - 1), swizzled_chunks, layout->u.earray.swizzled_down_chunks); /* Get the swizzled max number of chunks in each dimension */ H5MM_memcpy(swizzled_max_chunks, layout->max_chunks, @@ -1191,13 +1188,10 @@ H5D__earray_idx_resize(H5O_layout_chunk_t *layout) H5VM_swizzle_coords(hsize_t, swizzled_max_chunks, layout->u.earray.unlim_dim); /* Get the swizzled max "down" sizes for each dimension */ - if (H5VM_array_down((layout->ndims - 1), swizzled_max_chunks, - layout->u.earray.swizzled_max_down_chunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute swizzled 'down' chunk size value") - } /* end if */ + H5VM_array_down((layout->ndims - 1), swizzled_max_chunks, layout->u.earray.swizzled_max_down_chunks); + } -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_idx_resize() */ /*------------------------------------------------------------------------- diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index a85565175d2..c8b4b33ccee 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -502,6 +502,7 @@ H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) H5HL_t * heap; /* Pointer to local heap for EFL file names */ size_t heap_size = H5HL_ALIGN(1); size_t u; + size_t name_offset; /* Determine size of heap needed to stored the file names */ for (u = 0; u < efl->nused; ++u) @@ -516,24 +517,22 @@ H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect EFL file name heap") /* Insert "empty" name first */ - if (UFAIL == H5HL_insert(file, heap, (size_t)1, "")) { + if (H5HL_insert(file, heap, (size_t)1, "", &name_offset) < 0) { H5HL_unprotect(heap); HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert file name into heap") - } /* end if */ + } for (u = 0; u < efl->nused; ++u) { - size_t offset; /* Offset of file name in heap */ - /* Insert file name into heap */ - if (UFAIL == - (offset = H5HL_insert(file, heap, HDstrlen(efl->slot[u].name) + 1, efl->slot[u].name))) { + if (H5HL_insert(file, heap, HDstrlen(efl->slot[u].name) + 1, efl->slot[u].name, &name_offset) < + 0) { H5HL_unprotect(heap); HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert file name into heap") - } /* end if */ + } /* Store EFL file name offset */ - efl->slot[u].name_offset = offset; - } /* end for */ + efl->slot[u].name_offset = name_offset; + } /* Release the heap */ if (H5HL_unprotect(heap) < 0) diff --git a/src/H5Gent.c b/src/H5Gent.c index a0fa28d9037..b200c0ea361 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -387,11 +387,8 @@ H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk /* Reset the new entry */ H5G__ent_reset(ent); - /* - * Add the new name to the heap. - */ - name_offset = H5HL_insert(f, heap, HDstrlen(name) + 1, name); - if (0 == name_offset || UFAIL == name_offset) + /* Add the new name to the heap */ + if (H5HL_insert(f, heap, HDstrlen(name) + 1, name, &name_offset) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert symbol name into heap") ent->name_off = name_offset; @@ -479,14 +476,12 @@ H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk size_t lnk_offset; /* Offset to sym-link value */ /* Insert link value into local heap */ - if (UFAIL == - (lnk_offset = H5HL_insert(f, heap, HDstrlen(lnk->u.soft.name) + 1, lnk->u.soft.name))) + if (H5HL_insert(f, heap, HDstrlen(lnk->u.soft.name) + 1, lnk->u.soft.name, &lnk_offset) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write link value to local heap") ent->type = H5G_CACHED_SLINK; ent->cache.slink.lval_offset = lnk_offset; - } /* end case */ - break; + } break; case H5L_TYPE_ERROR: case H5L_TYPE_EXTERNAL: diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 6203fd0255b..67f75249ad3 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -150,11 +150,10 @@ H5G__stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Insert name into the heap */ - if (UFAIL == (name_offset = H5HL_insert(f, heap, (size_t)1, ""))) + if (H5HL_insert(f, heap, (size_t)1, "", &name_offset) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert name into heap") - /* - * B-tree's won't work if the first name isn't at the beginning + /* B-trees won't work if the first name isn't at the beginning * of the heap. */ HDassert(0 == name_offset); diff --git a/src/H5HL.c b/src/H5HL.c index 50d24c3deb2..ca8344526e4 100644 --- a/src/H5HL.c +++ b/src/H5HL.c @@ -508,27 +508,31 @@ END_FUNC(STATIC) /* end H5HL__dirty() */ * * Purpose: Inserts a new item into the heap. * - * Return: Success: Offset of new item within heap. - * Failure: UFAIL + * Return: Success: SUCCEED + * Offset set to location of new item within heap + * + * Failure: FAIL + * Offset set to SIZE_MAX * * Programmer: Robb Matzke * Jul 17 1997 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, size_t, UFAIL, UFAIL, - H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, + H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf, size_t *offset_out)) H5HL_free_t *fl = NULL, *last_fl = NULL; - size_t offset = 0; size_t need_size; + size_t offset = 0; hbool_t found; - /* check arguments */ + /* Check arguments */ HDassert(f); HDassert(heap); HDassert(buf_size > 0); HDassert(buf); + HDassert(offset_out); /* Mark heap as dirty in cache */ /* (A bit early in the process, but it's difficult to determine in the @@ -539,20 +543,18 @@ BEGIN_FUNC(PRIV, ERR, size_t, UFAIL, UFAIL, if (FAIL == H5HL__dirty(heap)) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty"); - /* - * In order to keep the free list descriptors aligned on word boundaries, + /* In order to keep the free list descriptors aligned on word boundaries, * whatever that might mean, we round the size up to the next multiple of * a word. */ need_size = H5HL_ALIGN(buf_size); - /* - * Look for a free slot large enough for this object and which would + /* Look for a free slot large enough for this object and which would * leave zero or at least H5G_SIZEOF_FREE bytes left over. */ for (fl = heap->freelist, found = FALSE; fl; fl = fl->next) { if (fl->size > need_size && fl->size - need_size >= H5HL_SIZEOF_FREE(f)) { - /* a big enough free block was found */ + /* A big enough free block was found */ offset = fl->offset; fl->offset += need_size; fl->size -= need_size; @@ -562,20 +564,19 @@ BEGIN_FUNC(PRIV, ERR, size_t, UFAIL, UFAIL, break; } else if (fl->size == need_size) { - /* free block of exact size found */ + /* Free block of exact size found */ offset = fl->offset; fl = H5HL__remove_free(heap, fl); found = TRUE; break; } else if (!last_fl || last_fl->offset < fl->offset) { - /* track free space that's closest to end of heap */ + /* Track free space that's closest to end of heap */ last_fl = fl; } } /* end for */ - /* - * If no free chunk was large enough, then allocate more space and + /* If no free chunk was large enough, then allocate more space and * add it to the free list. If the heap ends with a free chunk, we * can extend that free chunk. Otherwise we'll have to make another * free chunk. If the heap must expand, we double its size. @@ -587,7 +588,8 @@ BEGIN_FUNC(PRIV, ERR, size_t, UFAIL, UFAIL, htri_t was_extended; /* Whether the local heap's data segment on disk was extended */ /* At least double the heap's size, making certain there's enough room - * for the new object */ + * for the new object + */ need_more = MAX(need_size, heap->dblk_size); /* If there is no last free block or it's not at the end of the heap, @@ -657,8 +659,7 @@ BEGIN_FUNC(PRIV, ERR, size_t, UFAIL, UFAIL, } } /* end if */ else { - /* - * Create a new free list element large enough that we can + /* Create a new free list element large enough that we can * take some space out of it right away. */ offset = old_dblk_size; @@ -700,11 +701,10 @@ BEGIN_FUNC(PRIV, ERR, size_t, UFAIL, UFAIL, /* Copy the data into the heap */ H5MM_memcpy(heap->dblk_image + offset, buf, buf_size); - /* Set return value */ - ret_value = offset; + *offset_out = offset; CATCH - /* No special processing on errors */ + /* No special processing on exit */ END_FUNC(PRIV) /* H5HL_insert() */ diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h index 739e7619272..5c9884629db 100644 --- a/src/H5HLprivate.h +++ b/src/H5HLprivate.h @@ -57,7 +57,7 @@ H5_DLL herr_t H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr /*out*/); H5_DLL herr_t H5HL_delete(H5F_t *f, haddr_t addr); H5_DLL herr_t H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size); H5_DLL herr_t H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size); -H5_DLL size_t H5HL_insert(H5F_t *f, H5HL_t *heap, size_t size, const void *buf); +H5_DLL herr_t H5HL_insert(H5F_t *f, H5HL_t *heap, size_t size, const void *buf, size_t *offset); H5_DLL void * H5HL_offset_into(const H5HL_t *heap, size_t offset); H5_DLL H5HL_t *H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags); H5_DLL herr_t H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size); diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 5ec85aaea88..2fdb2963e15 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -466,7 +466,7 @@ H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_d HGOTO_ERROR(H5E_EFL, H5E_PROTECT, NULL, "unable to protect EFL file name heap") /* Insert "empty" name first */ - if (UFAIL == (name_offset = H5HL_insert(file_dst, heap, (size_t)1, ""))) + if (H5HL_insert(file_dst, heap, (size_t)1, "", &name_offset) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTINSERT, NULL, "can't insert file name into heap") HDassert(0 == name_offset); @@ -483,10 +483,10 @@ H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_d /* copy the name from the source */ for (idx = 0; idx < efl_src->nused; idx++) { efl_dst->slot[idx].name = H5MM_xstrdup(efl_src->slot[idx].name); - if (UFAIL == (efl_dst->slot[idx].name_offset = H5HL_insert( - file_dst, heap, HDstrlen(efl_dst->slot[idx].name) + 1, efl_dst->slot[idx].name))) + if (H5HL_insert(file_dst, heap, HDstrlen(efl_dst->slot[idx].name) + 1, efl_dst->slot[idx].name, + &(efl_dst->slot[idx].name_offset)) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTINSERT, NULL, "can't insert file name into heap") - } /* end for */ + } /* Set return value */ ret_value = efl_dst; diff --git a/src/H5SM.c b/src/H5SM.c index ad2d9ef8c1c..a72a4ddfde4 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -1220,16 +1220,16 @@ static herr_t H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, hbool_t defer, unsigned type_id, void *mesg, unsigned *cache_flags_ptr) { - H5SM_list_t * list = NULL; /* List index */ - H5SM_mesg_key_t key; /* Key used to search the index */ - H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - H5O_shared_t shared; /* Shared H5O message */ - hbool_t found = FALSE; /* Was the message in the index? */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ - size_t buf_size; /* Size of the encoded message */ - void * encoding_buf = NULL; /* Buffer for encoded message */ - size_t empty_pos = UFAIL; /* Empty entry in list */ + H5SM_list_t * list = NULL; /* List index */ + H5SM_mesg_key_t key; /* Key used to search the index */ + H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + H5O_shared_t shared; /* Shared H5O message */ + hbool_t found = FALSE; /* Was the message in the index? */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + size_t buf_size; /* Size of the encoded message */ + void * encoding_buf = NULL; /* Buffer for encoded message */ + size_t empty_pos = SIZE_MAX; /* Empty entry in list */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) @@ -1283,11 +1283,11 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, hbool_t HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to search for message in list") if (defer) { - if (list_pos != UFAIL) + if (list_pos != SIZE_MAX) found = TRUE; } /* end if */ else { - if (list_pos != UFAIL) { + if (list_pos != SIZE_MAX) { /* If the message was previously shared in an object header, share * it in the heap now. */ @@ -1442,13 +1442,13 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, hbool_t /* Insert the new message into the SOHM index */ if (header->index_type == H5SM_LIST) { /* Index is a list. Find an empty spot if we haven't already */ - if (empty_pos == UFAIL) { + if (empty_pos == SIZE_MAX) { size_t pos; if (H5SM__find_in_list(list, NULL, &empty_pos, &pos) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to search for message in list") - if (pos == UFAIL || empty_pos == UFAIL) + if (pos == SIZE_MAX || empty_pos == SIZE_MAX) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to find empty entry in list") } /* Insert message into list */ @@ -1608,9 +1608,14 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) * * If EMPTY_POS is NULL, don't store anything in it. * - * Return: Message's position in the list on success - * UFAIL if message couldn't be found - * empty_pos set to position of empty message or UFAIL. + * Return: Success: SUCCEED + * pos = position (if found) + * pos = SIZE_MAX (if not found) + * empty_pos = indeterminate (if found) + * empty_pos = 1st empty position (if not found) + * + * Failure: FAIL + * pos & empty_pos indeterminate * * Programmer: James Laird * Tuesday, May 2, 2006 @@ -1631,7 +1636,7 @@ H5SM__find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, size_t * /* Initialize empty_pos to an invalid value */ if (empty_pos) - *empty_pos = UFAIL; + *empty_pos = SIZE_MAX; /* Find the first (only) message equal to the key passed in. * Also record the first empty position we find. @@ -1654,11 +1659,11 @@ H5SM__find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, size_t * /* Found earlier position possible, don't check any more */ empty_pos = NULL; - } /* end if */ - } /* end for */ + } + } /* If we reached this point, we didn't find the message */ - *pos = UFAIL; + *pos = SIZE_MAX; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1826,7 +1831,7 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, c /* Find the message in the list */ if (H5SM__find_in_list(list, &key, NULL, &list_pos) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to search for message in list") - if (list_pos == UFAIL) + if (list_pos == SIZE_MAX) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") if (list->messages[list_pos].location == H5SM_IN_HEAP) @@ -2208,7 +2213,7 @@ H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, hsize /* Find the message in the list */ if (H5SM__find_in_list(list, &key, NULL, &list_pos) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to search for message in list") - if (list_pos == UFAIL) + if (list_pos == SIZE_MAX) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") /* Copy the message */ @@ -2505,7 +2510,7 @@ H5SM_list_free(H5SM_list_t *list) * * Purpose: Print debugging information for the master table. * - * If table_vers and num_indexes are not UFAIL, they are used + * If table_vers and num_indexes are not UINT_MAX, they are used * instead of the values in the superblock. * * Return: Non-negative on success/Negative on failure @@ -2532,14 +2537,14 @@ H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, int fwi HDassert(indent >= 0); HDassert(fwidth >= 0); - /* If table_vers and num_indexes are UFAIL, replace them with values from + /* If table_vers and num_indexes are UINT_MAX, replace them with values from * userblock */ - if (table_vers == UFAIL) + if (table_vers == UINT_MAX) table_vers = H5F_SOHM_VERS(f); else if (table_vers != H5F_SOHM_VERS(f)) HDfprintf(stream, "*** SOHM TABLE VERSION DOESN'T MATCH VERSION IN SUPERBLOCK!\n"); - if (num_indexes == UFAIL) + if (num_indexes == UINT_MAX) num_indexes = H5F_SOHM_NINDEXES(f); else if (num_indexes != H5F_SOHM_NINDEXES(f)) HDfprintf(stream, "*** NUMBER OF SOHM INDEXES DOESN'T MATCH VALUE IN SUPERBLOCK!\n"); diff --git a/src/H5Smpio.c b/src/H5Smpio.c index 9a38aaa8b55..7b85209c650 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -1014,8 +1014,7 @@ H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *ne elmt_type_is_derived = TRUE; /* Compute 'down' sizes for each dimension */ - if (H5VM_array_down(space->extent.rank, space->extent.size, down) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGETSIZE, FAIL, "couldn't compute 'down' dimension sizes") + H5VM_array_down(space->extent.rank, space->extent.size, down); /* Acquire an operation generation value for creating MPI datatypes */ op_gen = H5S__hyper_get_op_gen(); diff --git a/src/H5Tbit.c b/src/H5Tbit.c index e2ca4b9db85..9f0c061b37d 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -228,10 +228,7 @@ H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) * Purpose: Return a small bit sequence as a number. Bit vector starts * at OFFSET and is SIZE bits long. * - * Return: Success: The bit sequence interpretted as an unsigned - * integer. - * - * Failure: 0 + * Return: The bit sequence interpretted as an unsigned integer * *------------------------------------------------------------------------- */ @@ -264,8 +261,8 @@ H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size) case H5T_ORDER_NONE: case H5T_ORDER_MIXED: default: - /* Unknown endianness. Bail out. */ - HGOTO_DONE(UFAIL) + /* This function can't return errors */ + HDassert(0 && "unknown byte order"); } /* Set return value */ diff --git a/src/H5VM.c b/src/H5VM.c index 7ce3476476a..71074b5d107 100644 --- a/src/H5VM.c +++ b/src/H5VM.c @@ -43,20 +43,20 @@ static void H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size, unsigned dst_n #endif /* LATER */ /*------------------------------------------------------------------------- - * Function: H5VM__stride_optimize1 + * Function: H5VM__stride_optimize1 * - * Purpose: Given a stride vector which references elements of the - * specified size, optimize the dimensionality, the stride - * vector, and the element size to minimize the dimensionality - * and the number of memory accesses. + * Purpose: Given a stride vector which references elements of the + * specified size, optimize the dimensionality, the stride + * vector, and the element size to minimize the dimensionality + * and the number of memory accesses. * - * All arguments are passed by reference and their values may be - * modified by this function. + * All arguments are passed by reference and their values may be + * modified by this function. * - * Return: None + * Return: void * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ @@ -66,15 +66,12 @@ H5VM__stride_optimize1(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, c { FUNC_ENTER_STATIC_NOERR - /* - * This has to be true because if we optimize the dimensionality down to + /* This has to be true because if we optimize the dimensionality down to * zero we still must make one reference. */ HDassert(1 == H5VM_vector_reduce_product(0, NULL)); - /* - * Combine adjacent memory accesses - */ + /* Combine adjacent memory accesses */ while (*np && stride1[*np - 1] > 0 && (hsize_t)(stride1[*np - 1]) == *elmt_size) { *elmt_size *= size[*np - 1]; if (--*np) @@ -85,20 +82,20 @@ H5VM__stride_optimize1(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, c } /*------------------------------------------------------------------------- - * Function: H5VM__stride_optimize2 + * Function: H5VM__stride_optimize2 * - * Purpose: Given two stride vectors which reference elements of the - * specified size, optimize the dimensionality, the stride - * vectors, and the element size to minimize the dimensionality - * and the number of memory accesses. + * Purpose: Given two stride vectors which reference elements of the + * specified size, optimize the dimensionality, the stride + * vectors, and the element size to minimize the dimensionality + * and the number of memory accesses. * - * All arguments are passed by reference and their values may be - * modified by this function. + * All arguments are passed by reference and their values may be + * modified by this function. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ @@ -108,16 +105,13 @@ H5VM__stride_optimize2(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, c { FUNC_ENTER_STATIC_NOERR - /* - * This has to be true because if we optimize the dimensionality down to + /* This has to be true because if we optimize the dimensionality down to * zero we still must make one reference. */ HDassert(1 == H5VM_vector_reduce_product(0, NULL)); HDassert(*elmt_size > 0); - /* - * Combine adjacent memory accesses - */ + /* Combine adjacent memory accesses */ /* Unroll loop for common cases */ switch (*np) { @@ -206,29 +200,26 @@ H5VM__stride_optimize2(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, c } /*------------------------------------------------------------------------- - * Function: H5VM_hyper_stride - * - * Purpose: Given a description of a hyperslab, this function returns - * (through STRIDE[]) the byte strides appropriate for accessing - * all bytes of the hyperslab and the byte offset where the - * striding will begin. The SIZE can be passed to the various - * stride functions. + * Function: H5VM_hyper_stride * - * The dimensionality of the whole array, the hyperslab, and the - * returned stride array is N. The whole array dimensions are - * TOTAL_SIZE and the hyperslab is at offset OFFSET and has - * dimensions SIZE. + * Purpose: Given a description of a hyperslab, this function returns + * (through STRIDE[]) the byte strides appropriate for accessing + * all bytes of the hyperslab and the byte offset where the + * striding will begin. The SIZE can be passed to the various + * stride functions. * - * The stride and starting point returned will cause the - * hyperslab elements to be referenced in C order. + * The dimensionality of the whole array, the hyperslab, and the + * returned stride array is N. The whole array dimensions are + * TOTAL_SIZE and the hyperslab is at offset OFFSET and has + * dimensions SIZE. * - * Return: Success: Byte offset from beginning of array to start - * of striding. + * The stride and starting point returned will cause the + * hyperslab elements to be referenced in C order. * - * Failure: abort() -- should never fail + * Return: Byte offset from beginning of array to start of striding. * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ @@ -308,23 +299,22 @@ H5VM_hyper_stride(unsigned n, const hsize_t *size, const hsize_t *total_size, co } /*------------------------------------------------------------------------- - * Function: H5VM_hyper_eq + * Function: H5VM_hyper_eq * - * Purpose: Determines whether two hyperslabs are equal. This function - * assumes that both hyperslabs are relative to the same array, - * for if not, they could not possibly be equal. + * Purpose: Determines whether two hyperslabs are equal. This function + * assumes that both hyperslabs are relative to the same array, + * for if not, they could not possibly be equal. * - * Return: Success: TRUE if the hyperslabs are equal (that is, - * both refer to exactly the same elements of an - * array) + * Return: TRUE if the hyperslabs are equal (that is, + * both refer to exactly the same elements of an + * array) * - * FALSE otherwise. + * FALSE otherwise * - * Failure: TRUE the rank is zero or if both hyperslabs - * are of zero size. + * Never returns FAIL * - * Programmer: Robb Matzke - * Friday, October 17, 1997 + * Programmer: Robb Matzke + * Friday, October 17, 1997 * *------------------------------------------------------------------------- */ @@ -360,19 +350,19 @@ H5VM_hyper_eq(unsigned n, const hsize_t *offset1, const hsize_t *size1, const hs /*------------------------------------------------------------------------- * Function: H5VM_hyper_fill * - * Purpose: Similar to memset() except it operates on hyperslabs... + * Purpose: Similar to memset() except it operates on hyperslabs... * - * Fills a hyperslab of array BUF with some value VAL. BUF - * is treated like a C-order array with N dimensions where the - * size of each dimension is TOTAL_SIZE[]. The hyperslab which - * will be filled with VAL begins at byte offset OFFSET[] from - * the minimum corner of BUF and continues for SIZE[] bytes in - * each dimension. + * Fills a hyperslab of array BUF with some value VAL. BUF + * is treated like a C-order array with N dimensions where the + * size of each dimension is TOTAL_SIZE[]. The hyperslab which + * will be filled with VAL begins at byte offset OFFSET[] from + * the minimum corner of BUF and continues for SIZE[] bytes in + * each dimension. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Friday, October 10, 1997 + * Programmer: Robb Matzke + * Friday, October 10, 1997 * *------------------------------------------------------------------------- */ @@ -418,31 +408,31 @@ H5VM_hyper_fill(unsigned n, const hsize_t *_size, const hsize_t *total_size, con } /*------------------------------------------------------------------------- - * Function: H5VM_hyper_copy + * Function: H5VM_hyper_copy * - * Purpose: Copies a hyperslab from the source to the destination. + * Purpose: Copies a hyperslab from the source to the destination. * - * A hyperslab is a logically contiguous region of - * multi-dimensional size SIZE of an array whose dimensionality - * is N and whose total size is DST_TOTAL_SIZE or SRC_TOTAL_SIZE. - * The minimum corner of the hyperslab begins at a - * multi-dimensional offset from the minimum corner of the DST - * (destination) or SRC (source) array. The sizes and offsets - * are assumed to be in C order, that is, the first size/offset - * varies the slowest while the last varies the fastest in the - * mapping from N-dimensional space to linear space. This - * function assumes that the array elements are single bytes (if - * your array has multi-byte elements then add an additional - * dimension whose size is that of your element). + * A hyperslab is a logically contiguous region of + * multi-dimensional size SIZE of an array whose dimensionality + * is N and whose total size is DST_TOTAL_SIZE or SRC_TOTAL_SIZE. + * The minimum corner of the hyperslab begins at a + * multi-dimensional offset from the minimum corner of the DST + * (destination) or SRC (source) array. The sizes and offsets + * are assumed to be in C order, that is, the first size/offset + * varies the slowest while the last varies the fastest in the + * mapping from N-dimensional space to linear space. This + * function assumes that the array elements are single bytes (if + * your array has multi-byte elements then add an additional + * dimension whose size is that of your element). * - * The SRC and DST array may be the same array, but the results - * are undefined if the source hyperslab overlaps the - * destination hyperslab. + * The SRC and DST array may be the same array, but the results + * are undefined if the source hyperslab overlaps the + * destination hyperslab. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Friday, October 10, 1997 + * Programmer: Robb Matzke + * Friday, October 10, 1997 * *------------------------------------------------------------------------- */ @@ -597,13 +587,13 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size, /*------------------------------------------------------------------------- * Function: H5VM_stride_fill * - * Purpose: Fills all bytes of a hyperslab with the same value using - * memset(). + * Purpose: Fills all bytes of a hyperslab with the same value using + * memset(). * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ @@ -648,19 +638,19 @@ H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize /*------------------------------------------------------------------------- * Function: H5VM_stride_copy * - * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays - * DST and SRC while copying bytes from SRC to DST. This - * function minimizes the number of calls to memcpy() by - * combining various strides, but it will never touch memory - * outside the hyperslab defined by the strides. + * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays + * DST and SRC while copying bytes from SRC to DST. This + * function minimizes the number of calls to memcpy() by + * combining various strides, but it will never touch memory + * outside the hyperslab defined by the strides. * - * Note: If the src_stride is all zero and elmt_size is one, then it's - * probably more efficient to use H5VM_stride_fill() instead. + * Note: If the src_stride is all zero and elmt_size is one, then it's + * probably more efficient to use H5VM_stride_fill() instead. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ @@ -714,19 +704,19 @@ H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize /*------------------------------------------------------------------------- * Function: H5VM_stride_copy_s * - * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays - * DST and SRC while copying bytes from SRC to DST. This - * function minimizes the number of calls to memcpy() by - * combining various strides, but it will never touch memory - * outside the hyperslab defined by the strides. + * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays + * DST and SRC while copying bytes from SRC to DST. This + * function minimizes the number of calls to memcpy() by + * combining various strides, but it will never touch memory + * outside the hyperslab defined by the strides. * - * Note: If the src_stride is all zero and elmt_size is one, then it's - * probably more efficient to use H5VM_stride_fill() instead. + * Note: If the src_stride is all zero and elmt_size is one, then it's + * probably more efficient to use H5VM_stride_fill() instead. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ @@ -780,17 +770,17 @@ H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size, const hss #ifdef LATER /*------------------------------------------------------------------------- - * Function: H5VM__stride_copy2 + * Function: H5VM__stride_copy2 * - * Purpose: Similar to H5VM_stride_copy() except the source and - * destination each have their own dimensionality and size and - * we copy exactly NELMTS elements each of size ELMT_SIZE. The - * size counters wrap if NELMTS is more than a size counter. + * Purpose: Similar to H5VM_stride_copy() except the source and + * destination each have their own dimensionality and size and + * we copy exactly NELMTS elements each of size ELMT_SIZE. The + * size counters wrap if NELMTS is more than a size counter. * - * Return: None + * Return: void * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ @@ -852,16 +842,16 @@ H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size, #endif /* LATER */ /*------------------------------------------------------------------------- - * Function: H5VM_array_fill + * Function: H5VM_array_fill * - * Purpose: Fills all bytes of an array with the same value using - * memset(). Increases amount copied by power of two until the - * halfway point is crossed, then copies the rest in one swoop. + * Purpose: Fills all bytes of an array with the same value using + * memset(). Increases amount copied by power of two until the + * halfway point is crossed, then copies the rest in one swoop. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, June 18, 1998 + * Programmer: Quincey Koziol + * Thursday, June 18, 1998 * *------------------------------------------------------------------------- */ @@ -904,25 +894,25 @@ H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count) } /* H5VM_array_fill() */ /*------------------------------------------------------------------------- - * Function: H5VM_array_down + * Function: H5VM_array_down * - * Purpose: Given a set of dimension sizes, calculate the size of each + * Purpose: Given a set of dimension sizes, calculate the size of each * "down" slice. This is the size of the dimensions for all the * dimensions below the current one, which is used for indexing * offsets in this dimension. * - * Return: Non-negative on success/Negative on failure + * Return: void * - * Programmer: Quincey Koziol - * Monday, April 28, 2003 + * Programmer: Quincey Koziol + * Monday, April 28, 2003 * *------------------------------------------------------------------------- */ -herr_t +void H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down) { - hsize_t acc; /*accumulator */ - int i; /*counter */ + hsize_t acc; /* Accumulator */ + int i; /* Counter */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -930,31 +920,31 @@ H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down) HDassert(total_size); HDassert(down); - /* Build the sizes of each dimension in the array */ - /* (From fastest to slowest) */ + /* Build the sizes of each dimension in the array + * (From fastest to slowest) + */ for (i = (int)(n - 1), acc = 1; i >= 0; i--) { down[i] = acc; acc *= total_size[i]; - } /* end for */ + } - FUNC_LEAVE_NOAPI(SUCCEED) + FUNC_LEAVE_NOAPI_VOID } /* end H5VM_array_down() */ /*------------------------------------------------------------------------- * Function: H5VM_array_offset_pre * - * Purpose: Given a coordinate description of a location in an array, this - * function returns the byte offset of the coordinate. + * Purpose: Given a coordinate description of a location in an array, this + * function returns the byte offset of the coordinate. * - * The dimensionality of the whole array, and the offset is N. + * The dimensionality of the whole array, and the offset is N. * The whole array dimensions are TOTAL_SIZE and the coordinate * is at offset OFFSET. * - * Return: Success: Byte offset from beginning of array to element offset - * Failure: abort() -- should never fail + * Return: Byte offset from beginning of array to element offset * * Programmer: Quincey Koziol - * Tuesday, June 22, 1999 + * Tuesday, June 22, 1999 * *------------------------------------------------------------------------- */ @@ -980,18 +970,17 @@ H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset) /*------------------------------------------------------------------------- * Function: H5VM_array_offset * - * Purpose: Given a coordinate description of a location in an array, this - * function returns the byte offset of the coordinate. + * Purpose: Given a coordinate description of a location in an array, + * this function returns the byte offset of the coordinate. * - * The dimensionality of the whole array, and the offset is N. + * The dimensionality of the whole array, and the offset is N. * The whole array dimensions are TOTAL_SIZE and the coordinate * is at offset OFFSET. * - * Return: Success: Byte offset from beginning of array to element offset - * Failure: abort() -- should never fail + * Return: Byte offset from beginning of array to element offset * * Programmer: Quincey Koziol - * Tuesday, June 22, 1999 + * Tuesday, June 22, 1999 * *------------------------------------------------------------------------- */ @@ -1001,38 +990,36 @@ H5VM_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset) hsize_t acc_arr[H5VM_HYPER_NDIMS]; /* Accumulated size of down dimensions */ hsize_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI((HDabort(), 0)) /*lint !e527 Don't worry about unreachable statement */ + FUNC_ENTER_NOAPI_NOERR HDassert(n <= H5VM_HYPER_NDIMS); HDassert(total_size); HDassert(offset); /* Build the sizes of each dimension in the array */ - if (H5VM_array_down(n, total_size, acc_arr) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, UFAIL, "can't compute down sizes") + H5VM_array_down(n, total_size, acc_arr); /* Set return value */ ret_value = H5VM_array_offset_pre(n, acc_arr, offset); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VM_array_offset() */ /*------------------------------------------------------------------------- * Function: H5VM_array_calc_pre * - * Purpose: Given a linear offset in an array, the dimensions of that + * Purpose: Given a linear offset in an array, the dimensions of that * array and the pre-computed 'down' (accumulator) sizes, this * function computes the coordinates of that offset in the array. * - * The dimensionality of the whole array, and the coordinates is N. + * The dimensionality of the whole array, and the coordinates is N. * The array dimensions are TOTAL_SIZE and the coordinates * are returned in COORD. The linear offset is in OFFSET. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, July 16, 2009 + * Programmer: Quincey Koziol + * Thursday, July 16, 2009 * *------------------------------------------------------------------------- */ @@ -1059,18 +1046,18 @@ H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, hsize_t *co /*------------------------------------------------------------------------- * Function: H5VM_array_calc * - * Purpose: Given a linear offset in an array and the dimensions of that + * Purpose: Given a linear offset in an array and the dimensions of that * array, this function computes the coordinates of that offset * in the array. * - * The dimensionality of the whole array, and the coordinates is N. + * The dimensionality of the whole array, and the coordinates is N. * The array dimensions are TOTAL_SIZE and the coordinates * are returned in COORD. The linear offset is in OFFSET. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Wednesday, April 16, 2003 + * Programmer: Quincey Koziol + * Wednesday, April 16, 2003 * *------------------------------------------------------------------------- */ @@ -1088,8 +1075,7 @@ H5VM_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t * HDassert(coords); /* Build the sizes of each dimension in the array */ - if (H5VM_array_down(n, total_size, idx) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute down sizes") + H5VM_array_down(n, total_size, idx); /* Compute the coordinates from the offset */ if (H5VM_array_calc_pre(offset, n, idx, coords) < 0) @@ -1102,7 +1088,7 @@ H5VM_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t * /*------------------------------------------------------------------------- * Function: H5VM_chunk_index * - * Purpose: Given a coordinate offset (COORD), the size of each chunk + * Purpose: Given a coordinate offset (COORD), the size of each chunk * (CHUNK), the number of chunks in each dimension (NCHUNKS) * and the number of dimensions of all of these (NDIMS), calculate * a "chunk index" for the chunk that the coordinate offset is @@ -1132,10 +1118,10 @@ H5VM_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t * * The chunk index is placed in the CHUNK_IDX location for return * from this function * - * Return: Chunk index on success (can't fail) + * Return: Chunk index on success (can't fail) * - * Programmer: Quincey Koziol - * Monday, April 21, 2003 + * Programmer: Quincey Koziol + * Monday, April 21, 2003 * *------------------------------------------------------------------------- */ @@ -1160,14 +1146,14 @@ H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, co } /* end H5VM_chunk_index() */ /*------------------------------------------------------------------------- - * Function: H5VM_chunk_scaled + * Function: H5VM_chunk_scaled * - * Purpose: Compute the scaled coordinates for a chunk offset + * Purpose: Compute the scaled coordinates for a chunk offset * - * Return: + * Return: void * - * Programmer: Quincey Koziol - * Wednesday, November 19, 2014 + * Programmer: Quincey Koziol + * Wednesday, November 19, 2014 * *------------------------------------------------------------------------- */ @@ -1195,7 +1181,7 @@ H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, h /*------------------------------------------------------------------------- * Function: H5VM_chunk_index_scaled * - * Purpose: Given a coordinate offset (COORD), the size of each chunk + * Purpose: Given a coordinate offset (COORD), the size of each chunk * (CHUNK), the number of chunks in each dimension (NCHUNKS) * and the number of dimensions of all of these (NDIMS), calculate * a "chunk index" for the chunk that the coordinate offset is @@ -1225,13 +1211,13 @@ H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, h * The chunk index is placed in the CHUNK_IDX location for return * from this function * - * Note: This routine is identical to H5VM_chunk_index(), except for - * caching the scaled information. Make changes in both places. + * Note: This routine is identical to H5VM_chunk_index(), except for + * caching the scaled information. Make changes in both places. * - * Return: Chunk index on success (can't fail) + * Return: Chunk index on success (can't fail) * - * Programmer: Vailin Choi - * Monday, February 9, 2015 + * Programmer: Vailin Choi + * Monday, February 9, 2015 * *------------------------------------------------------------------------- */ @@ -1266,22 +1252,22 @@ H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *ch /*------------------------------------------------------------------------- * Function: H5VM_opvv * - * Purpose: Perform an operation on a source & destination sequences - * of offset/length pairs. Each set of sequnces has an array - * of lengths, an array of offsets, the maximum number of - * sequences and the current sequence to start at in the sequence. + * Purpose: Perform an operation on a source & destination sequences + * of offset/length pairs. Each set of sequnces has an array + * of lengths, an array of offsets, the maximum number of + * sequences and the current sequence to start at in the sequence. * * There may be different numbers of bytes in the source and * destination sequences, the operation stops when either the * source or destination sequence runs out of information. * - * Note: The algorithm in this routine is [basically] the same as for - * H5VM_memcpyvv(). Changes should be made to both! + * Note: The algorithm in this routine is [basically] the same as for + * H5VM_memcpyvv(). Changes should be made to both! * - * Return: Non-negative # of bytes operated on, on success/Negative on failure + * Return: Non-negative # of bytes operated on, on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, September 30, 2010 + * Programmer: Quincey Koziol + * Thursday, September 30, 2010 * *------------------------------------------------------------------------- */ @@ -1469,7 +1455,7 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize /*------------------------------------------------------------------------- * Function: H5VM_memcpyvv * - * Purpose: Given source and destination buffers in memory (SRC & DST) + * Purpose: Given source and destination buffers in memory (SRC & DST) * copy sequences of from the source buffer into the destination * buffer. Each set of sequences has an array of lengths, an * array of offsets, the maximum number of sequences and the @@ -1479,13 +1465,13 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize * destination sequences, data copying stops when either the * source or destination buffer runs out of sequence information. * - * Note: The algorithm in this routine is [basically] the same as for - * H5VM_opvv(). Changes should be made to both! + * Note: The algorithm in this routine is [basically] the same as for + * H5VM_opvv(). Changes should be made to both! * - * Return: Non-negative # of bytes copied on success/Negative on failure + * Return: Non-negative # of bytes copied on success/Negative on failure * - * Programmer: Quincey Koziol - * Friday, May 2, 2003 + * Programmer: Quincey Koziol + * Friday, May 2, 2003 * *------------------------------------------------------------------------- */ diff --git a/src/H5VMprivate.h b/src/H5VMprivate.h index 2fea2fcd7ad..0d3bd0fe795 100644 --- a/src/H5VMprivate.h +++ b/src/H5VMprivate.h @@ -105,7 +105,7 @@ H5_DLL herr_t H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *_ const hssize_t *dst_stride, void *_dst, const hssize_t *src_stride, const void *_src); H5_DLL herr_t H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count); -H5_DLL herr_t H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down); +H5_DLL void H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down); H5_DLL hsize_t H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset); H5_DLL hsize_t H5VM_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset); H5_DLL herr_t H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, hsize_t *coords); diff --git a/src/H5private.h b/src/H5private.h index fc213e5d313..6100b6d57bc 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -360,7 +360,6 @@ */ #define SUCCEED 0 #define FAIL (-1) -#define UFAIL (unsigned)(-1) /* The HDF5 library uses the symbol `ERR` frequently. So do * header files for libraries such as curses(3), terminfo(3), etc. diff --git a/test/dsets.c b/test/dsets.c index 39bb874f100..88337bf9cff 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -9525,8 +9525,7 @@ test_chunk_fast(const char *env_h5_driver, hid_t fapl) npoints = (hsize_t)snpoints; /* Compute the "down" dimension values */ - if (H5VM_array_down(ndims, dim, down) < 0) - FAIL_STACK_ERROR + H5VM_array_down(ndims, dim, down); /* Create chunked dataset */ if ((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, @@ -9708,8 +9707,7 @@ test_chunk_fast(const char *env_h5_driver, hid_t fapl) H5VM_swizzle_coords(hsize_t, swizzled_dim, unlim_dim); /* Compute the "down" dimension values */ - if (H5VM_array_down(ndims, swizzled_dim, down) < 0) - FAIL_STACK_ERROR + H5VM_array_down(ndims, swizzled_dim, down); /* Read elements */ for (u = 0; u < npoints; u++) { diff --git a/test/lheap.c b/test/lheap.c index 25dfed0d545..6c9983504a0 100644 --- a/test/lheap.c +++ b/test/lheap.c @@ -102,7 +102,7 @@ main(void) if (j > 4) buf[j] = '\0'; - if (UFAIL == (obj[i] = H5HL_insert(f, heap, HDstrlen(buf) + 1, buf))) { + if (H5HL_insert(f, heap, HDstrlen(buf) + 1, buf, &obj[i]) < 0) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; diff --git a/tools/src/misc/h5debug.c b/tools/src/misc/h5debug.c index ed64061fb06..95c81b72513 100644 --- a/tools/src/misc/h5debug.c +++ b/tools/src/misc/h5debug.c @@ -619,7 +619,7 @@ main(int argc, char *argv[]) * Debug shared message master table. */ - status = H5SM_table_debug(f, addr, stdout, 0, VCOL, (unsigned)UFAIL, (unsigned)UFAIL); + status = H5SM_table_debug(f, addr, stdout, 0, VCOL, UINT_MAX, UINT_MAX); } else if (!HDmemcmp(sig, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* From cc05a1e179f42f6eb6ddd263f32f8d8881b477f0 Mon Sep 17 00:00:00 2001 From: bmribler <39579120+bmribler@users.noreply.github.com> Date: Wed, 12 May 2021 15:35:53 -0400 Subject: [PATCH 06/13] Bmr dev hdffv 11223 (#640) * Fixed HDFFV-11223 (CVE-2018-14460) Description - Added checks against buffer size to prevent segfault, in case of data corruption, for sdim->size and sdim->max. - Renamed data files in an existing test to shorten their length as agreed with other developers previously. Platforms tested: Linux/64 (jelly) * Committing clang-format changes * Updated for test files * Updated for HDFFV-11223 Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- MANIFEST | 2 ++ release_docs/RELEASE.txt | 13 +++++++++- src/H5Osdspace.c | 23 ++++++++++++++---- tools/test/h5repack/CMakeTests.cmake | 12 +++++++++ tools/test/h5repack/h5repack.sh.in | 11 +++++++++ .../testfiles/h5repack_CVE-2018-14460.h5 | Bin 0 -> 2560 bytes .../testfiles/h5repack_CVE-2018-17432.h5 | Bin 0 -> 7648 bytes 7 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 tools/test/h5repack/testfiles/h5repack_CVE-2018-14460.h5 create mode 100644 tools/test/h5repack/testfiles/h5repack_CVE-2018-17432.h5 diff --git a/MANIFEST b/MANIFEST index 5a966848dd2..258f3403b57 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2752,6 +2752,8 @@ ./tools/test/h5repack/testfiles/h5repack_layout.h5-plugin_test.ddl ./tools/test/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl ./tools/test/h5repack/testfiles/h5repack_layout.h5-plugin_zero.ddl +./tools/test/h5repack/testfiles/h5repack_CVE-2018-17432.h5 +./tools/test/h5repack/testfiles/h5repack_CVE-2018-14460.h5 ./tools/test/h5repack/testfiles/GS.h5repack_paged_nopersist.h5.ddl ./tools/test/h5repack/testfiles/S.h5repack_fsm_aggr_persist.h5.ddl ./tools/test/h5repack/testfiles/SP.h5repack_fsm_aggr_nopersist.h5.ddl diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index b5f8f20d330..a725c63c134 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -339,7 +339,18 @@ Bug Fixes since HDF5-1.10.7 release =================================== Library ------- - - Fixed CVE-2018-17435 + - Fixed CVE-2018-14460 + + The tool h5repack produced a segfault when the rank in dataspace + message was corrupted, causing invalid read while decoding the + dimension sizes. + + The problem was fixed by ensuring that decoding the dimension sizes + and max values will not go beyong the end of the buffer. + + (BMR - 2021/05/12, HDFFV-11223) + + - Fixed CVE-2018-11206 The tool h5dump produced a segfault when the size of a fill value message was corrupted and caused a buffer overflow. diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index c715df85cf4..6a2557f9101 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -106,12 +106,13 @@ H5FL_ARR_EXTERN(hsize_t); --------------------------------------------------------------------------*/ static void * H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5S_extent_t *sdim = NULL; /* New extent dimensionality structure */ - unsigned flags, version; - unsigned i; /* Local counting variable */ - void * ret_value = NULL; /* Return value */ + H5S_extent_t * sdim = NULL; /* New extent dimensionality structure */ + unsigned flags, version; + unsigned i; /* Local counting variable */ + const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -158,6 +159,13 @@ H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UN /* Decode dimension sizes */ if (sdim->rank > 0) { + /* Ensure that rank doesn't cause reading passed buffer's end, + due to possible data corruption */ + uint8_t sizeof_size = H5F_SIZEOF_SIZE(f); + if (p + (sizeof_size * sdim->rank - 1) > p_end) { + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "rank might cause reading passed buffer's end") + } + if (NULL == (sdim->size = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") @@ -167,6 +175,11 @@ H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UN if (flags & H5S_VALID_MAX) { if (NULL == (sdim->max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + + /* Ensure that rank doesn't cause reading passed buffer's end */ + if (p + (sizeof_size * sdim->rank - 1) > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "rank might cause reading passed buffer's end") + for (i = 0; i < sdim->rank; i++) H5F_DECODE_LENGTH(f, p, sdim->max[i]); } /* end if */ diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index f32c994ddd2..91d729b0b1f 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -51,6 +51,8 @@ ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_named_dtypes.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_nested_8bit_enum.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_nested_8bit_enum_deflated.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_CVE-2018-17432.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_CVE-2018-14460.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_nbit.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_objs.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_refs.h5 @@ -1543,6 +1545,16 @@ # Note: this test is experimental for sharing test file among tools ADD_H5_TEST (HDFFV-7840 "TEST" h5diff_attr1.h5) +# test CVE-2018-17432 fix + set (arg h5repack_CVE-2018-17432.h5 h5repack__CVE-2018-17432_out.h5 --low=1 --high=2 -f GZIP=8 -l dset1:CHUNK=5x6) + set (TESTTYPE "TEST") + ADD_H5_FILTER_TEST (HDFFV-10590 "" ${TESTTYPE} 1 ${arg}) + +# test CVE-2018-14460 fix + set (arg h5repack_CVE-2018-14460.h5 h5repack_CVE-2018-14460_out.h5) + set (TESTTYPE "TEST") + ADD_H5_FILTER_TEST (HDFFV-11223 "" ${TESTTYPE} 1 ${arg}) + # tests for metadata block size option ('-M') ADD_H5_TEST_META (meta_short h5repack_layout.h5 -M 8192) ADD_H5_TEST_META (meta_long h5repack_layout.h5 --metadata_block_size=8192) diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index 26a10fd82e2..3f8e722df90 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -124,6 +124,9 @@ $SRC_H5REPACK_TESTFILES/h5repack_paged_nopersist.h5 $SRC_H5REPACK_TESTFILES/h5repack_paged_persist.h5 ########h5diff/testfile######## $SRC_H5DIFF_TESTFILES/h5diff_attr1.h5 +########test#HDFFV-10590######## +$SRC_H5REPACK_TESTFILES/h5repack_CVE-2018-17432.h5 +$SRC_H5REPACK_TESTFILES/h5repack_CVE-2018-14460.h5 ########tools/testfiles#for#external#links######## $SRC_TOOLS_TESTFILES/tsoftlinks.h5 $SRC_TOOLS_TESTFILES/textlinkfar.h5 @@ -1675,6 +1678,14 @@ TOOLTEST HDFFV-5932 h5repack_attr_refs.h5 # Note: this test is experimental for sharing test file among tools TOOLTEST HDFFV-7840 h5diff_attr1.h5 +# test HDFFV-10590 +arg="h5repack_CVE-2018-17432.h5 h5repack_CVE-2018-17432_out.h5 --low=1 --high=2 -f GZIP=8 -l dset1:CHUNK=5x6" +TOOLTEST_FAIL $arg + +# test HDFFV-11223 +arg="h5repack_CVE-2018-14460.h5 h5repack_CVE-2018-14460_out.h5" +TOOLTEST_FAIL $arg + # tests for metadata block size option TOOLTEST_META meta_short h5repack_layout.h5 -M 8192 TOOLTEST_META meta_long h5repack_layout.h5 --metadata_block_size=8192 diff --git a/tools/test/h5repack/testfiles/h5repack_CVE-2018-14460.h5 b/tools/test/h5repack/testfiles/h5repack_CVE-2018-14460.h5 new file mode 100644 index 0000000000000000000000000000000000000000..f4093b575c340cec6492194a505b3206a69370cf GIT binary patch literal 2560 zcmeD5aB<`1lHy_j0S*oZ76t(ZW-tdr{D%SthzbTcAF5^nR52rz-vDJKK=~f7jsajM zR9ph44obtQl;YG9Lm&r48v$vUc`slJhAABqJlP{1}0L1hM!G8WO zpfH5_>jHA&hQ&Fse5S#MMREiSF*2~Bq$?I+h=O9Ag`ojR3dRsjXH1av0gDG*G|}k{ en4UoZWDW=;(pdtKHws2WfY=Zai~*(Jk%|H4HB;&U literal 0 HcmV?d00001 diff --git a/tools/test/h5repack/testfiles/h5repack_CVE-2018-17432.h5 b/tools/test/h5repack/testfiles/h5repack_CVE-2018-17432.h5 new file mode 100644 index 0000000000000000000000000000000000000000..7a815ba9e3b70dc37cebdccd80d4fb754785e09e GIT binary patch literal 7648 zcmeI$ZLAzs8Nl(gx9#oFQrVV;PTNtp>o86x+hKR!XLdKcr0q>97E50YkK+$N3_5&ogVgtsg#AJO*BPi5o=KMEltxBLx zOoT~hpMB=#?C+d;&dJ<+=bBYB3+64Ir^?MR)NEB(v#LaYoMt=u#mmwA2d0)mpBRAcfa?Rt|Vm)Byzd>-QeXd$C*wSclkT3Jt-sYL z2VRe_sS&8DscJ4X>GeXHpXJ=x%LLiR@kywu>FT`xP->1cs;^U1Q`H@_xW9gplDS@P z&FZtJ^vs-^s#2vF1f?1}l~&BEomn;cT5ZjzA2QY>70p-CX~ug}Up4CMO$_F__0^oOPd&2e z%<(?AzCLp1>DRxX-w2e`wtO<>(<+yRIkJ~CV6N=t)REPqS`x}aX@W{=2r8 zNPDlQCjL`fOQpS6T3`RIt!2{QE2-6&Ys-@Ms%^M5dFDB5<%*$43=evp&B2Ysf_!x2 zx?_Jj_>bXAj?avz@A~dTj}O;!e%;4@xaQ+O-9KEFAU$w{Wtvbx+PD{-8S4pJ6o5p_;B~0$A)8kV|CN<&wgW<I_`X7}yG z@!YLDkG=UX5`TQnmY;1OX`Yf8-Tc^-xx~sT@vB!~cl#lUm3O3SWrNEkR&I&%^T+o| zto#z6I{w$syf{+29}-80_eMJ;R{fE9aR2<1zm{0_Youl^+Hvn)>m^qGllalKZ^@5H ztokYOH&=Y~x50=P1Bu#a;4|Ps415MY1D}DxNC+4oR--v8k?-f_YqWU6)NI<&``u zxvtNq+H>l~<)knfj+^TFi$3_heWMn>7QPm~7QPm~7QPm~7QPm~7QPm~7QPm~7QPm~7QPm~7QPm~ z7CsxFjnBqs#ZYA5dH6hh9zGABhtI?3;q&l$_&j_bJ`bOV&%@{8^YD52JbWI$Hoi8# zHoi8#Hoi8#Hoi8#Hoi8#Hoi8#Hoi8#Hoi8#Hoi8#Hoi7KAD@rU$LHho@%i|Cd_F!O zpO4SS=i~G7`S^T%K0Y6xkI%>F Date: Thu, 3 Jun 2021 19:20:32 +0000 Subject: [PATCH 07/13] Committing clang-format changes --- src/H5C.c | 79 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/src/H5C.c b/src/H5C.c index ecd99e8be64..233d6aef460 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -3730,8 +3730,9 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "initial_size must be in the interval [min_size, max_size]") - if ((config_ptr->min_clean_fraction < 0.0) || (config_ptr->min_clean_fraction > 1.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_clean_fraction must be in the interval [0.0, 1.0]") + if ((config_ptr->min_clean_fraction < 0.0) || (config_ptr->min_clean_fraction > 1.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "min_clean_fraction must be in the interval [0.0, 1.0]") if (config_ptr->epoch_length < H5C__MIN_AR_EPOCH_LENGTH) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epoch_length too small") @@ -3744,13 +3745,14 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) if ((config_ptr->incr_mode != H5C_incr__off) && (config_ptr->incr_mode != H5C_incr__threshold)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid incr_mode") - if (config_ptr->incr_mode == H5C_incr__threshold) { - if ((config_ptr->lower_hr_threshold < 0.0) || (config_ptr->lower_hr_threshold > 1.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "lower_hr_threshold must be in the range [0.0, 1.0]") + if (config_ptr->incr_mode == H5C_incr__threshold) { + if ((config_ptr->lower_hr_threshold < 0.0) || (config_ptr->lower_hr_threshold > 1.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "lower_hr_threshold must be in the range [0.0, 1.0]") - if (config_ptr->increment < 1.0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "increment must be greater than or equal to 1.0") + if (config_ptr->increment < 1.0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "increment must be greater than or equal to 1.0") /* no need to check max_increment, as it is a size_t, * and thus must be non-negative. @@ -3762,14 +3764,14 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) /* nothing to do here */ break; - case H5C_flash_incr__add_space: - if ((config_ptr->flash_multiple < 0.1) || (config_ptr->flash_multiple > 10.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "flash_multiple must be in the range [0.1, 10.0]") - if ((config_ptr->flash_threshold < 0.1) || (config_ptr->flash_threshold > 1.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "flash_threshold must be in the range [0.1, 1.0]") - break; + case H5C_flash_incr__add_space: + if ((config_ptr->flash_multiple < 0.1) || (config_ptr->flash_multiple > 10.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "flash_multiple must be in the range [0.1, 10.0]") + if ((config_ptr->flash_threshold < 0.1) || (config_ptr->flash_threshold > 1.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "flash_threshold must be in the range [0.1, 1.0]") + break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid flash_incr_mode") @@ -3786,12 +3788,12 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid decr_mode") } - if (config_ptr->decr_mode == H5C_decr__threshold) { - if (config_ptr->upper_hr_threshold > 1.0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "upper_hr_threshold must be <= 1.0") + if (config_ptr->decr_mode == H5C_decr__threshold) { + if (config_ptr->upper_hr_threshold > 1.0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "upper_hr_threshold must be <= 1.0") - if ((config_ptr->decrement > 1.0) || (config_ptr->decrement < 0.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "decrement must be in the interval [0.0, 1.0]") + if ((config_ptr->decrement > 1.0) || (config_ptr->decrement < 0.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "decrement must be in the interval [0.0, 1.0]") /* no need to check max_decrement as it is a size_t * and thus must be non-negative. @@ -3806,29 +3808,30 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) if (config_ptr->epochs_before_eviction > H5C__MAX_EPOCH_MARKERS) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction too big") - if ((config_ptr->apply_empty_reserve) && - ((config_ptr->empty_reserve > 1.0) || (config_ptr->empty_reserve < 0.0))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty_reserve must be in the interval [0.0, 1.0]") + if ((config_ptr->apply_empty_reserve) && + ((config_ptr->empty_reserve > 1.0) || (config_ptr->empty_reserve < 0.0))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "empty_reserve must be in the interval [0.0, 1.0]") /* no need to check max_decrement as it is a size_t * and thus must be non-negative. */ } /* H5C_decr__age_out || H5C_decr__age_out_with_threshold */ - if (config_ptr->decr_mode == H5C_decr__age_out_with_threshold) { - if ((config_ptr->upper_hr_threshold > 1.0) || (config_ptr->upper_hr_threshold < 0.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "upper_hr_threshold must be in the interval [0.0, 1.0]") - } /* H5C_decr__age_out_with_threshold */ - } /* H5C_RESIZE_CFG__VALIDATE_DECREMENT */ - - if ((tests & H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) != 0) { - if ((config_ptr->incr_mode == H5C_incr__threshold) && - ((config_ptr->decr_mode == H5C_decr__threshold) || - (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) && - (config_ptr->lower_hr_threshold >= config_ptr->upper_hr_threshold)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "conflicting threshold fields in config") - } /* H5C_RESIZE_CFG__VALIDATE_INTERACTIONS */ + if (config_ptr->decr_mode == H5C_decr__age_out_with_threshold) { + if ((config_ptr->upper_hr_threshold > 1.0) || (config_ptr->upper_hr_threshold < 0.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "upper_hr_threshold must be in the interval [0.0, 1.0]") + } /* H5C_decr__age_out_with_threshold */ + } /* H5C_RESIZE_CFG__VALIDATE_DECREMENT */ + + if ((tests & H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) != 0) { + if ((config_ptr->incr_mode == H5C_incr__threshold) && + ((config_ptr->decr_mode == H5C_decr__threshold) || + (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) && + (config_ptr->lower_hr_threshold >= config_ptr->upper_hr_threshold)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "conflicting threshold fields in config") + } /* H5C_RESIZE_CFG__VALIDATE_INTERACTIONS */ done: FUNC_LEAVE_NOAPI(ret_value) From 6ed1a942df781f95c8268196118c7a0def1ffd24 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Thu, 3 Jun 2021 14:29:24 -0500 Subject: [PATCH 08/13] Restore "error:" in line 2666. --- src/H5trace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/H5trace.c b/src/H5trace.c index 3ebb1981d31..1565a864be9 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -2663,6 +2663,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) (function_times.elapsed - *returning)); } /* end if */ +error: HDva_end(ap); if (returning) HDfprintf(out, ";\n"); From d3a6523eb2e5fe818694a55754554307dda699ec Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Thu, 3 Jun 2021 15:11:45 -0500 Subject: [PATCH 09/13] Revert "Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625)" This reverts commit 426b50484841118cf633fd6147302a63a30fd746. --- src/H5E.c | 47 +++++++------------------------------ test/testfiles/err_compat_1 | 14 +---------- 2 files changed, 9 insertions(+), 52 deletions(-) diff --git a/src/H5E.c b/src/H5E.c index f13e571be0d..da75edeb28f 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -244,20 +244,6 @@ H5E_term_package(void) nstk = H5I_nmembers(H5I_ERROR_STACK); if ((ncls + nmsg + nstk) > 0) { - /* Clear the default error stack. Note that - * the following H5I_clear_type calls do not - * force the clears and will not be able to - * clear any error message IDs that are still - * in use by the default error stack unless we - * clear that stack manually. - * - * Error message IDs will typically still be - * in use by the default error stack when the - * application does H5E_BEGIN/END_TRY cleanup - * at the very end. - */ - H5E_clear_stack(NULL); - /* Clear any outstanding error stacks */ if (nstk > 0) (void)H5I_clear_type(H5I_ERROR_STACK, FALSE, FALSE); @@ -1575,8 +1561,7 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data) H5E_auto_op_t op; /* Error stack function */ herr_t ret_value = SUCCEED; /* Return value */ - /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(FAIL) + FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x**x", estack_id, func, client_data); if (estack_id == H5E_DEFAULT) { @@ -1584,13 +1569,8 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data) non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ - else { - /* Only clear the error stack if it's not the default stack */ - H5E_clear_stack(NULL); - - if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") - } /* end else */ + else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* Get the automatic error reporting information */ if (H5E__get_auto(estack, &op, client_data) < 0) @@ -1647,13 +1627,8 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data) non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ - else { - /* Only clear the error stack if it's not the default stack */ - H5E_clear_stack(NULL); - - if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") - } /* end else */ + else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") #ifndef H5_NO_DEPRECATED_SYMBOLS /* Get the automatic error reporting information */ @@ -1700,8 +1675,7 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) H5E_t *estack; /* Error stack to operate on */ herr_t ret_value = SUCCEED; /* Return value */ - /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(FAIL) + FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Iu", estack_id, is_stack); if (estack_id == H5E_DEFAULT) { @@ -1709,13 +1683,8 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ - else { - /* Only clear the error stack if it's not the default stack */ - H5E_clear_stack(NULL); - - if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") - } /* end else */ + else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* Check if the error stack reporting function is the "newer" stack type */ if (is_stack) diff --git a/test/testfiles/err_compat_1 b/test/testfiles/err_compat_1 index e3ec405d2d7..d81dba1ea16 100644 --- a/test/testfiles/err_compat_1 +++ b/test/testfiles/err_compat_1 @@ -28,19 +28,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Inappropriate type ********* Print error stack in customized way ********* - error #000: (file name) in H5VL_vol_object(): line (number) - major: Invalid arguments to routine - minor: Inappropriate type - error #001: (file name) in H5VL_setup_acc_args(): line (number) - major: Invalid arguments to routine - minor: Inappropriate type - error #002: (file name) in H5D__create_api_common(): line (number) - major: Dataset - minor: Can't set value - error #003: (file name) in H5Dcreate2(): line (number) - major: Dataset - minor: Unable to create file - error #004: (file name) in H5Eget_auto(1 or 2)(): line (number) + error #000: (file name) in H5Eget_auto(1 or 2)(): line (number) major: Error API minor: Can't get value From 8234aac0075c007e5ea489b5ef5c1190af062b06 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Wed, 14 Jul 2021 10:59:09 -0500 Subject: [PATCH 10/13] Snapshot version 1.10 release 8-1. Update version to 1.10.8-2. Squashed commit of the following: commit 60734e63fe077238f10de3d6ca8f037f9a42af89 Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Thu Jun 24 14:20:39 2021 -0500 Hdf5 1 10 Fix tools test (#796) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop * Fix cmake configure path * Update missing release note info. * Update code owners * Add known problem * Use only core library for testing dynamic plugins. CMake uses H5_HAVE_DIRECT instead of DIRECT_VFD Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit bfb780a4441e4ef43dd23708d415e5e3b84800f4 Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Wed Jun 23 14:11:46 2021 -0500 Hdf5 1 10 Release Note (#786) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop * Fix cmake configure path * Update missing release note info. * Update code owners * Add known problem Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 9f5040736868f8eec584ab5af6d2a77e4d45ae30 Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Tue Jun 22 07:03:26 2021 -0500 Hdf5 1 10 Update missing release note info. (#778) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop * Fix cmake configure path * Update missing release note info. * Update code owners Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 2e80c9cdec98d6cee5b4609643839a4ad2a848fb Author: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Fri Jun 18 06:42:23 2021 -0700 Brings hash table IDs feature from develop/1.12 (#768) * Brings updated tid test from develop * Adds empty H5Iint.c and H5Idbg.c files * H5I renaming to match 1.12/develop * Splits off H5I debug code to H5Idbg.c * Splits internal H5I.c functionality to H5Iint.c * Header cleanup * More renaming cleanup to match develop/1.12 * Adds "save last ID" optimization * Adds uthash.h * Adds hash table IDs from develop/1.12 * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 1e29bcbfe24956f0158b3363a3fbb8a42c8e7e0f Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Thu Jun 17 11:21:43 2021 -0500 Hdf5 1 10 Fix cmake configure path (#762) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop * Fix cmake configure path Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 475cdaf431c9ef5bfef6243dbc26d0005d08c49d Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Wed Jun 16 15:45:58 2021 -0500 Hdf5 1 10 merge warnings changes (#756) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit e25980e7f35b8508db90648409ba80ee36d61c9e Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Tue Jun 8 14:37:13 2021 -0500 Hdf5 1 10 merges of CMake changes (#738) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 061b23ac0011d3a26f660a7f4d07c40f41d63f10 Author: Larry Knox Date: Thu Jun 3 16:07:23 2021 -0500 Partial merge issue #642 develop branch PRs to Hdf5 1 10 (#718) * Revert addition of & to 2 parameters in DSetCreatPropList::setVirtual to maintain binary compatibility. * Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625) * Removes gratuitous (double)x.yF casts (#632) * Committing clang-format changes * Removes gratuitous (double)x.yF casts * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Cleans up a const warning left over from previous constification (#633) * Committing clang-format changes * Adds consts to a few global variables * Cleans up a const warning left over from previous constification Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Purges UFAIL from the library (#637) * Committing clang-format changes * Purges UFAIL from the library * H5HL_insert change requested in PR Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Bmr dev hdffv 11223 (#640) * Fixed HDFFV-11223 (CVE-2018-14460) Description - Added checks against buffer size to prevent segfault, in case of data corruption, for sdim->size and sdim->max. - Renamed data files in an existing test to shorten their length as agreed with other developers previously. Platforms tested: Linux/64 (jelly) * Committing clang-format changes * Updated for test files * Updated for HDFFV-11223 Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Committing clang-format changes * Restore "error:" in line 2666. * Revert "Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625)" This reverts commit 426b50484841118cf633fd6147302a63a30fd746. Co-authored-by: jhendersonHDF Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> --- .github/CODEOWNERS | 4 +- MANIFEST | 12 +- README.txt | 2 +- c++/src/cpp_doc_config | 2 +- c++/test/CMakeVFDTests.cmake | 2 +- config/clang-cxxflags | 12 - config/clang-warnings/noerror-general | 6 +- config/cmake/ConfigureChecks.cmake | 116 +- config/cmake/H5pubconf.h.in | 20 +- config/cmake/HDF5UseFortran.cmake | 223 +-- config/cmake/HDFCXXCompilerFlags.cmake | 95 +- config/cmake/HDFCompilerFlags.cmake | 33 +- config/cmake/HDFFortranCompilerFlags.cmake | 14 +- config/cmake/scripts/HDF5config.cmake | 2 +- config/gnu-cxxflags | 20 +- config/gnu-flags | 6 +- config/gnu-warnings/cxx-4.9 | 1 + config/gnu-warnings/cxx-9 | 4 + config/gnu-warnings/developer-10 | 4 - config/gnu-warnings/noerror-general | 6 +- config/intel-cxxflags | 184 +++ config/intel-fflags | 62 +- config/intel-flags | 78 +- config/intel-warnings/15 | 19 + config/intel-warnings/18 | 8 + config/intel-warnings/developer-general | 4 + config/intel-warnings/general | 1 - config/intel-warnings/general-19 | 2 + config/linux-gnulibc1 | 14 +- config/pgi-cxxflags | 100 ++ config/pgi-fflags | 64 +- config/pgi-flags | 87 +- configure.ac | 2 +- release_docs/RELEASE.txt | 49 +- src/CMakeLists.txt | 4 + src/H5I.c | 1546 ++------------------ src/H5Idbg.c | 181 +++ src/H5Iint.c | 1364 +++++++++++++++++ src/H5Ipkg.h | 59 +- src/H5Iprivate.h | 6 +- src/H5Itest.c | 7 +- src/H5public.h | 4 +- src/Makefile.am | 4 +- src/uthash.h | 1184 +++++++++++++++ test/CMakeVFDTests.cmake | 2 +- test/tid.c | 380 +++-- testpar/CMakeVFDTests.cmake | 2 +- tools/test/h5copy/CMakeLists.txt | 2 +- tools/test/h5copy/CMakeTests.cmake | 22 +- tools/test/h5diff/CMakeLists.txt | 2 +- tools/test/h5diff/CMakeTests.cmake | 2 +- tools/test/h5dump/CMakeLists.txt | 2 +- tools/test/h5dump/CMakeVFDTests.cmake | 2 +- tools/test/h5ls/CMakeLists.txt | 2 +- tools/test/h5ls/CMakeTests.cmake | 4 +- tools/test/h5ls/CMakeTestsVDS.cmake | 4 +- tools/test/h5repack/CMakeLists.txt | 4 +- tools/test/h5repack/CMakeVFDTests.cmake | 2 +- 58 files changed, 3993 insertions(+), 2056 deletions(-) create mode 100644 config/gnu-warnings/cxx-9 create mode 100644 config/intel-cxxflags create mode 100644 config/intel-warnings/15 create mode 100644 config/intel-warnings/18 create mode 100644 config/intel-warnings/developer-general create mode 100644 config/intel-warnings/general-19 create mode 100644 config/pgi-cxxflags create mode 100644 src/H5Idbg.c create mode 100644 src/H5Iint.c create mode 100644 src/uthash.h diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a80d51cc265..107aeb273f0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -19,7 +19,7 @@ CMakeTests.* @byrnHDF @derobins /doc/ @gnuoyd @jrmainzer -/examples/ @lrknox @derobins @bljhdf +/examples/ @lrknox @derobins @bmribler /fortran/ @brtnfld @epourmal @@ -29,7 +29,7 @@ CMakeTests.* @byrnHDF @derobins /m4/ @lrknox @derobins -/release_docs/ @lrknox @bljhdf @byrnHDF +/release_docs/ @lrknox @bmribler @byrnHDF /src/ @jhendersonHDF @derobins @fortnern @soumagne @vchoi-hdfgroup @jrmainzer diff --git a/MANIFEST b/MANIFEST index 258f3403b57..2c86f7ed257 100644 --- a/MANIFEST +++ b/MANIFEST @@ -136,6 +136,7 @@ ./config/cygwin ./config/ibm-aix ./config/ibm-flags +./config/intel-cxxflags ./config/intel-fflags ./config/intel-flags ./config/libhdf5.pc.in @@ -147,6 +148,7 @@ ./config/lt_vers.am ./config/Makefile.am.blank ./config/netbsd +./config/pgi-cxxflags ./config/pgi-fflags ./config/pgi-flags ./config/solaris @@ -172,6 +174,7 @@ ./config/gnu-warnings/cxx-4.8 ./config/gnu-warnings/cxx-4.9 ./config/gnu-warnings/cxx-5 +./config/gnu-warnings/cxx-9 ./config/gnu-warnings/cxx-error-5 ./config/gnu-warnings/cxx-error-general ./config/gnu-warnings/cxx-noerror-5 @@ -196,8 +199,12 @@ ./config/gnu-warnings/noerror-5 ./config/gnu-warnings/noerror-8 ./config/gnu-warnings/noerror-general -./config/intel-warnings/ifort-general +./config/intel-warnings/15 +./config/intel-warnings/18 +./config/intel-warnings/developer-general ./config/intel-warnings/general +./config/intel-warnings/general-19 +./config/intel-warnings/ifort-general ./config/site-specific/BlankForm @@ -872,6 +879,8 @@ ./src/H5HP.c ./src/H5HPprivate.h ./src/H5I.c +./src/H5Idbg.c +./src/H5Iint.c ./src/H5Imodule.h ./src/H5Ipkg.h ./src/H5Iprivate.h @@ -1061,6 +1070,7 @@ ./src/hdf5.h ./src/libhdf5.settings.in ./src/H5win32defs.h +./src/uthash.h ./test/AtomicWriterReader.txt ./test/H5srcdir.h diff --git a/README.txt b/README.txt index 79de239fde3..c6bca8bfc80 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -HDF5 version 1.10.8-1 currently under development +HDF5 version 1.10.8-2 currently under development ------------------------------------------------------------------------------ Please refer to the release_docs/INSTALL file for installation instructions. diff --git a/c++/src/cpp_doc_config b/c++/src/cpp_doc_config index 73f8c4f606a..ca5034a1593 100644 --- a/c++/src/cpp_doc_config +++ b/c++/src/cpp_doc_config @@ -38,7 +38,7 @@ PROJECT_NAME = # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "1.10.8-1, currently under development" +PROJECT_NUMBER = "1.10.8-2, currently under development" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/c++/test/CMakeVFDTests.cmake b/c++/test/CMakeVFDTests.cmake index 70556ba741b..f1c67999038 100644 --- a/c++/test/CMakeVFDTests.cmake +++ b/c++/test/CMakeVFDTests.cmake @@ -25,7 +25,7 @@ set (VFD_LIST family ) -if (DIRECT_VFD) +if (H5_HAVE_DIRECT) set (VFD_LIST ${VFD_LIST} direct) endif () diff --git a/config/clang-cxxflags b/config/clang-cxxflags index e7ab6d8631c..23ba6a3d1b2 100644 --- a/config/clang-cxxflags +++ b/config/clang-cxxflags @@ -113,18 +113,6 @@ if test "X-clang" = "X-$cxx_vendor" -o "X-Apple LLVM" = "X-$cxx_vendor"; then ;; esac - case "$host_os-$host_cpu" in - # cygwin needs the "-std=c99" flag removed, so make - # a specific case for Cygwin without the flag and a default - # case to add the flag everywhere else - cygwin-*) - ;; - - *) - H5_CXXFLAGS="$H5_CXXFLAGS -std=c++11" - ;; - esac - H5_CXXFLAGS="$H5_CXXFLAGS $arch" ############## diff --git a/config/clang-warnings/noerror-general b/config/clang-warnings/noerror-general index b570b2384aa..f90c81292c4 100644 --- a/config/clang-warnings/noerror-general +++ b/config/clang-warnings/noerror-general @@ -1,6 +1,8 @@ # -# HDF5 code should not trigger the following warnings under any -# circumstances, so ask the compiler to treat them as errors: +# These warnings will be treated as errors, using the error-general file, +# when HDF5_ENABLE_WARNINGS_AS_ERRORS is set to true for CMake or +# the --enable-warnings-as-errors option is specified for configure. +# Otherwise this file will be used to treat them as warnings. # -Wbad-function-cast -Wimplicit-function-declaration diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 0d826689cb1..1ded895cd77 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -221,18 +221,126 @@ endif() # Check if C has __float128 extension #----------------------------------------------------------------------------- -CHECK_TYPE_SIZE("__float128" ${HDF_PREFIX}_SIZEOF___FLOAT128) -if (${${HDF_PREFIX}_SIZEOF___FLOAT128}) +HDF_CHECK_TYPE_SIZE(__float128 _SIZEOF___FLOAT128) +if (${_SIZEOF___FLOAT128}) set (${HDF_PREFIX}_HAVE_FLOAT128 1) + set (${HDF_PREFIX}_SIZEOF___FLOAT128 ${_SIZEOF___FLOAT128}) else () set (${HDF_PREFIX}_HAVE_FLOAT128 0) set (${HDF_PREFIX}_SIZEOF___FLOAT128 0) endif () -CHECK_TYPE_SIZE("_Quad" ${HDF_PREFIX}_SIZEOF__QUAD) -if (NOT ${${HDF_PREFIX}_SIZEOF__QUAD}) +HDF_CHECK_TYPE_SIZE(_Quad _SIZEOF__QUAD) +if (NOT ${_SIZEOF__QUAD}) set (${HDF_PREFIX}_SIZEOF__QUAD 0) +else () + set (${HDF_PREFIX}_SIZEOF__QUAD ${_SIZEOF__QUAD}) +endif () + +#----------------------------------------------------------------------------- +# The provided CMake C macros don't provide a general compile/run function +# so this one is used. +#----------------------------------------------------------------------------- +set (RUN_OUTPUT_PATH_DEFAULT ${CMAKE_BINARY_DIR}) +macro (C_RUN FUNCTION_NAME SOURCE_CODE RETURN_VAR) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Detecting C ${FUNCTION_NAME}") + endif () + file (WRITE + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c + ${SOURCE_CODE} + ) + TRY_RUN (RUN_RESULT_VAR COMPILE_RESULT_VAR + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c + COMPILE_DEFINITIONS "-D_SIZEOF___FLOAT128=${H5_SIZEOF___FLOAT128};-D_HAVE_QUADMATH_H=${H5_HAVE_QUADMATH_H}" + COMPILE_OUTPUT_VARIABLE COMPILEOUT + RUN_OUTPUT_VARIABLE OUTPUT_VAR + ) + + set (${RETURN_VAR} ${OUTPUT_VAR}) + + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + message (VERBOSE "Test COMPILE_RESULT_VAR ${COMPILE_RESULT_VAR} ") + message (VERBOSE "Test COMPILE_OUTPUT ${COMPILEOUT} ") + message (VERBOSE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + message (VERBOSE "Test RUN_RESULT_VAR ${RUN_RESULT_VAR} ") + message (VERBOSE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + endif () + + if (${COMPILE_RESULT_VAR}) + if (${RUN_RESULT_VAR} MATCHES 0) + set (${RUN_RESULT_VAR} 1 CACHE INTERNAL "Have C function ${FUNCTION_NAME}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Testing C ${FUNCTION_NAME} - OK") + endif () + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the C ${FUNCTION_NAME} exists passed with the following output:\n" + "${OUTPUT_VAR}\n\n" + ) + else () + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Testing C ${FUNCTION_NAME} - Fail") + endif () + set (${RUN_RESULT_VAR} 0 CACHE INTERNAL "Have C function ${FUNCTION_NAME}") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the C ${FUNCTION_NAME} exists failed with the following output:\n" + "${OUTPUT_VAR}\n\n") + endif () + else () + message (FATAL_ERROR "Compilation of C ${FUNCTION_NAME} - Failed") + endif () +endmacro () + +set (PROG_SRC + " +#include \n\ +#include \n\ +#define CHECK_FLOAT128 _SIZEOF___FLOAT128\n\ +#if CHECK_FLOAT128!=0\n\ +#if _HAVE_QUADMATH_H!=0\n\ +#include \n\ +#endif\n\ +#ifdef FLT128_DIG\n\ +#define C_FLT128_DIG FLT128_DIG\n\ +#else\n\ +#define C_FLT128_DIG 0\n\ +#endif\n\ +#else\n\ +#define C_FLT128_DIG 0\n\ +#endif\n\ +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n\ +#define C_LDBL_DIG DECIMAL_DIG\n\ +#else\n\ +#define C_LDBL_DIG LDBL_DIG\n\ +#endif\n\nint main() {\nFILE *pFile = fopen(\"pac_Cconftest.out\",\"w\")\\\;\nfprintf(pFile, \"\\%d\\\;\\%d\\\;\", C_LDBL_DIG, C_FLT128_DIG)\\\;\n\nreturn 0\\\;\n}\n + " +) + +C_RUN ("maximum decimal precision for C" ${PROG_SRC} PROG_RES) +file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_Cconftest.out" PROG_OUTPUT4) +message (STATUS "Testing maximum decimal precision for C - ${PROG_OUTPUT4}") + +# dnl The output from the above program will be: +# dnl -- long double decimal precision -- __float128 decimal precision + +list (GET PROG_OUTPUT4 0 H5_LDBL_DIG) +list (GET PROG_OUTPUT4 1 H5_FLT128_DIG) + +if (${HDF_PREFIX}_SIZEOF___FLOAT128 EQUAL 0 OR FLT128_DIG EQUAL 0) + set (${HDF_PREFIX}_HAVE_FLOAT128 0) + set (${HDF_PREFIX}_SIZEOF___FLOAT128 0) + set (_PAC_C_MAX_REAL_PRECISION ${H5_LDBL_DIG}) +else () + set (_PAC_C_MAX_REAL_PRECISION ${H5_FLT128_DIG}) +endif () +if (NOT ${_PAC_C_MAX_REAL_PRECISION}) + set (${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION 0) +else () + set (${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION ${_PAC_C_MAX_REAL_PRECISION}) endif () +message (STATUS "maximum decimal precision for C var - ${${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION}") #----------------------------------------------------------------------------- # Macro to determine the various conversion capabilities diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 59f0dca47be..00d80974f87 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -32,7 +32,7 @@ /* Define the default plugins path to compile */ #cmakedefine H5_DEFAULT_PLUGINDIR "@H5_DEFAULT_PLUGINDIR@" -/* Define if `dev_t' is a scalar */ +/* Define if dev_t is a scalar */ #cmakedefine H5_DEV_T_IS_SCALAR @H5_DEV_T_IS_SCALAR@ /* Define to dummy `main' function (if any) required to link to the Fortran @@ -88,6 +88,9 @@ /* Define to 1 if you have the `alarm' function. */ #cmakedefine H5_HAVE_ALARM @H5_HAVE_ALARM@ +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_ARPA_INET_H @H5_HAVE_ARPA_INET_H@ + /* Define to 1 if you have the `asprintf' function. */ #cmakedefine H5_HAVE_ASPRINTF @H5_HAVE_ASPRINTF@ @@ -101,9 +104,6 @@ /* Define if the compiler understands the __func__ keyword */ #cmakedefine H5_HAVE_C99_FUNC @H5_HAVE_C99_FUNC@ -/* Define to 1 if you have the header file. */ -#cmakedefine H5_HAVE_ARPA_INET_H @H5_HAVE_ARPA_INET_H@ - /* Define to 1 if you have the `clock_gettime' function. */ #cmakedefine H5_HAVE_CLOCK_GETTIME @H5_HAVE_CLOCK_GETTIME@ @@ -267,7 +267,7 @@ /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_MEMORY_H @H5_HAVE_MEMORY_H@ -/* Define if we can build the Mirror VFD */ +/* Define whether the Mirror virtual file driver (VFD) will be compiled */ #cmakedefine H5_HAVE_MIRROR_VFD @H5_HAVE_MIRROR_VFD@ /* Define if we have MPE support */ @@ -276,10 +276,10 @@ /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_MPE_H @H5_HAVE_MPE_H@ -/* Define if MPI_Comm_c2f and MPI_Comm_f2c exists */ +/* Define if MPI_Comm_c2f and MPI_Comm_f2c exist */ #cmakedefine H5_HAVE_MPI_MULTI_LANG_Comm @H5_HAVE_MPI_MULTI_LANG_Comm@ -/* Define if MPI_Info_c2f and MPI_Info_f2c exists */ +/* Define if MPI_Info_c2f and MPI_Info_f2c exist */ #cmakedefine H5_HAVE_MPI_MULTI_LANG_Info @H5_HAVE_MPI_MULTI_LANG_Info@ /* Define to 1 if you have the header file. */ @@ -483,7 +483,7 @@ /* Define if the compiler understands __inline__ */ #cmakedefine H5_HAVE___INLINE__ @H5_HAVE___INLINE__@ -/* Define if the library will ignore file locks when disabled */ +/* Define if the library will ignore file locks when disabled */ #cmakedefine H5_IGNORE_DISABLED_FILE_LOCKS @H5_IGNORE_DISABLED_FILE_LOCKS@ /* Define if the high-level library headers should be included in hdf5.h */ @@ -542,10 +542,10 @@ #define H5_PACKAGE_VERSION "@HDF5_PACKAGE_VERSION_STRING@" /* Determine the maximum decimal precision in C */ -#cmakedefine H5_PAC_C_MAX_REAL_PRECISION @H5_PAC_C_MAX_REAL_PRECISION@ +#define H5_PAC_C_MAX_REAL_PRECISION @H5_PAC_C_MAX_REAL_PRECISION@ /* Define Fortran Maximum Real Decimal Precision */ -#cmakedefine H5_PAC_FC_MAX_REAL_PRECISION @H5_PAC_FC_MAX_REAL_PRECISION@ +#define H5_PAC_FC_MAX_REAL_PRECISION @H5_PAC_FC_MAX_REAL_PRECISION@ /* Width for printf() for type `long long' or `__int64', use `ll' */ #cmakedefine H5_PRINTF_LL_WIDTH @H5_PRINTF_LL_WIDTH@ diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake index 003f24fcd09..e192ec4dd65 100644 --- a/config/cmake/HDF5UseFortran.cmake +++ b/config/cmake/HDF5UseFortran.cmake @@ -129,74 +129,12 @@ endif () # Determine the available KINDs for REALs and INTEGERs #----------------------------------------------------------------------------- -#READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" SOURCE_CODE) -set (PROG_SRC_CODE - " - PROGRAM FC_AVAIL_KINDS - IMPLICIT NONE - INTEGER :: ik, jk, k, max_decimal_prec - INTEGER :: num_rkinds = 1, num_ikinds = 1 - INTEGER, DIMENSION(1:10) :: list_ikinds = -1 - INTEGER, DIMENSION(1:10) :: list_rkinds = -1 - - OPEN(8, FILE='pac_fconftest.out', FORM='formatted') - - ! Find integer KINDs - list_ikinds(num_ikinds)=SELECTED_INT_KIND(1) - DO ik = 2, 36 - k = SELECTED_INT_KIND(ik) - IF(k.LT.0) EXIT - IF(k.GT.list_ikinds(num_ikinds))THEN - num_ikinds = num_ikinds + 1 - list_ikinds(num_ikinds) = k - ENDIF - ENDDO - - DO k = 1, num_ikinds - WRITE(8,'(I0)', ADVANCE='NO') list_ikinds(k) - IF(k.NE.num_ikinds)THEN - WRITE(8,'(A)',ADVANCE='NO') ',' - ELSE - WRITE(8,'()') - ENDIF - ENDDO - - ! Find real KINDs - list_rkinds(num_rkinds)=SELECTED_REAL_KIND(1) - max_decimal_prec = 1 - - prec: DO ik = 2, 36 - exp: DO jk = 1, 17000 - k = SELECTED_REAL_KIND(ik,jk) - IF(k.LT.0) EXIT exp - IF(k.GT.list_rkinds(num_rkinds))THEN - num_rkinds = num_rkinds + 1 - list_rkinds(num_rkinds) = k - ENDIF - max_decimal_prec = ik - ENDDO exp - ENDDO prec - - DO k = 1, num_rkinds - WRITE(8,'(I0)', ADVANCE='NO') list_rkinds(k) - IF(k.NE.num_rkinds)THEN - WRITE(8,'(A)',ADVANCE='NO') ',' - ELSE - WRITE(8,'()') - ENDIF - ENDDO - - WRITE(8,'(I0)') max_decimal_prec - WRITE(8,'(I0)') num_ikinds - WRITE(8,'(I0)') num_rkinds - END PROGRAM FC_AVAIL_KINDS - " -) +READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" SOURCE_CODE) if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") - check_fortran_source_runs (${PROG_SRC_CODE} FC_AVAIL_KINDS_RESULT SRC_EXT f90) + check_fortran_source_runs (${SOURCE_CODE} FC_AVAIL_KINDS_RESULT SRC_EXT f90) else () FORTRAN_RUN ("REAL and INTEGER KINDs" - "${PROG_SRC_CODE}" + "${SOURCE_CODE}" XX YY FC_AVAIL_KINDS_RESULT @@ -260,7 +198,7 @@ foreach (KIND ${VAR}) USE ISO_C_BINDING IMPLICIT NONE INTEGER (KIND=${KIND}) a - OPEN(8,FILE='pac_validIntKinds.out',FORM='formatted') + OPEN(8,FILE='pac_validIntKinds.${KIND}.out',FORM='formatted') WRITE(8,'(I0)') ${FC_SIZEOF_A} CLOSE(8) END @@ -271,7 +209,7 @@ foreach (KIND ${VAR}) else () FORTRAN_RUN("INTEGER KIND SIZEOF" ${PROG_SRC_${KIND}} XX YY VALIDINTKINDS_RESULT_${KIND}) endif () - file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validIntKinds.out" PROG_OUTPUT1) + file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validIntKinds.${KIND}.out" PROG_OUTPUT1) string (REGEX REPLACE "\n" "" PROG_OUTPUT1 "${PROG_OUTPUT1}") set (pack_int_sizeof "${pack_int_sizeof} ${PROG_OUTPUT1},") endforeach () @@ -309,7 +247,7 @@ foreach (KIND ${VAR} ) USE ISO_C_BINDING IMPLICIT NONE REAL (KIND=${KIND}) a - OPEN(8,FILE='pac_validRealKinds.out',FORM='formatted') + OPEN(8,FILE='pac_validRealKinds.${KIND}.out',FORM='formatted') WRITE(8,'(I0)') ${FC_SIZEOF_A} CLOSE(8) END @@ -320,7 +258,7 @@ foreach (KIND ${VAR} ) else () FORTRAN_RUN ("REAL KIND SIZEOF" ${PROG_SRC2_${KIND}} XX YY VALIDREALKINDS_RESULT_${KIND}) endif () - file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validRealKinds.out" PROG_OUTPUT1) + file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validRealKinds.${KIND}.out" PROG_OUTPUT1) string (REGEX REPLACE "\n" "" PROG_OUTPUT1 "${PROG_OUTPUT1}") set (pack_real_sizeof "${pack_real_sizeof} ${PROG_OUTPUT1},") endforeach () @@ -375,7 +313,7 @@ if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") else () FORTRAN_RUN ("SIZEOF NATIVE KINDs" ${PROG_SRC3} XX YY PAC_SIZEOF_NATIVE_KINDS_RESULT) endif () -file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_sizeof_native_kinds.out" PROG_OUTPUT) +file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_sizeof_native_kinds.out" PROG_OUTPUT3) # dnl The output from the above program will be: # dnl -- LINE 1 -- sizeof INTEGER # dnl -- LINE 2 -- kind of INTEGER @@ -385,14 +323,14 @@ file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_sizeof_native_kinds.out" PROG_OUTPUT) # dnl -- LINE 6 -- kind of DOUBLE PRECISION # Convert the string to a list of strings by replacing the carriage return with a semicolon -string (REGEX REPLACE "\n" ";" PROG_OUTPUT "${PROG_OUTPUT}") +string (REGEX REPLACE "\n" ";" PROG_OUTPUT3 "${PROG_OUTPUT3}") -list (GET PROG_OUTPUT 0 PAC_FORTRAN_NATIVE_INTEGER_SIZEOF) -list (GET PROG_OUTPUT 1 PAC_FORTRAN_NATIVE_INTEGER_KIND) -list (GET PROG_OUTPUT 2 PAC_FORTRAN_NATIVE_REAL_SIZEOF) -list (GET PROG_OUTPUT 3 PAC_FORTRAN_NATIVE_REAL_KIND) -list (GET PROG_OUTPUT 4 PAC_FORTRAN_NATIVE_DOUBLE_SIZEOF) -list (GET PROG_OUTPUT 5 PAC_FORTRAN_NATIVE_DOUBLE_KIND) +list (GET PROG_OUTPUT3 0 PAC_FORTRAN_NATIVE_INTEGER_SIZEOF) +list (GET PROG_OUTPUT3 1 PAC_FORTRAN_NATIVE_INTEGER_KIND) +list (GET PROG_OUTPUT3 2 PAC_FORTRAN_NATIVE_REAL_SIZEOF) +list (GET PROG_OUTPUT3 3 PAC_FORTRAN_NATIVE_REAL_KIND) +list (GET PROG_OUTPUT3 4 PAC_FORTRAN_NATIVE_DOUBLE_SIZEOF) +list (GET PROG_OUTPUT3 5 PAC_FORTRAN_NATIVE_DOUBLE_KIND) if (NOT PAC_FORTRAN_NATIVE_INTEGER_SIZEOF) message (FATAL_ERROR "Failed to find SIZEOF NATIVE INTEGER KINDs for Fortran") @@ -434,132 +372,13 @@ endif () set (${HDF_PREFIX}_H5CONFIG_F_NUM_RKIND "INTEGER, PARAMETER :: num_rkinds = ${NUM_RKIND}") -string (REGEX REPLACE "{" "" OUT_VAR ${PAC_FC_ALL_REAL_KINDS}) -string (REGEX REPLACE "}" "" OUT_VAR ${OUT_VAR}) -set (${HDF_PREFIX}_H5CONFIG_F_RKIND "INTEGER, DIMENSION(1:num_rkinds) :: rkind = (/${OUT_VAR}/)") - -string (REGEX REPLACE "{" "" OUT_VAR ${PAC_FC_ALL_REAL_KINDS_SIZEOF}) -string (REGEX REPLACE "}" "" OUT_VAR ${OUT_VAR}) -set (${HDF_PREFIX}_H5CONFIG_F_RKIND_SIZEOF "INTEGER, DIMENSION(1:num_rkinds) :: rkind_sizeof = (/${OUT_VAR}/)") - -ENABLE_LANGUAGE (C) - -if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") - include (CheckCSourceRuns) -else () -#----------------------------------------------------------------------------- -# The provided CMake C macros don't provide a general compile/run function -# so this one is used. -#----------------------------------------------------------------------------- -macro (C_RUN FUNCTION_NAME SOURCE_CODE RETURN_VAR) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "Detecting C ${FUNCTION_NAME}") - endif () - if (HDF5_REQUIRED_LIBRARIES) - set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${HDF5_REQUIRED_LIBRARIES}") - else () - set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) - endif () - file (WRITE - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c - ${SOURCE_CODE} - ) - TRY_RUN (RUN_RESULT_VAR COMPILE_RESULT_VAR - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c - CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" - RUN_OUTPUT_VARIABLE OUTPUT_VAR - ) - - set (${RETURN_VAR} ${OUTPUT_VAR}) - - #if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - # message (TRACE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") - # message (TRACE "Test COMPILE_RESULT_VAR ${COMPILE_RESULT_VAR} ") - # message (TRACE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") - # message (TRACE "Test RUN_RESULT_VAR ${RUN_RESULT_VAR} ") - # message (TRACE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") - #endif () - - if (${COMPILE_RESULT_VAR}) - if (${RUN_RESULT_VAR} MATCHES 1) - set (${RUN_RESULT_VAR} 1 CACHE INTERNAL "Have C function ${FUNCTION_NAME}") - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "Testing C ${FUNCTION_NAME} - OK") - endif () - file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the C ${FUNCTION_NAME} exists passed with the following output:\n" - "${OUTPUT_VAR}\n\n" - ) - else () - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "Testing C ${FUNCTION_NAME} - Fail") - endif () - set (${RUN_RESULT_VAR} 0 CACHE INTERNAL "Have C function ${FUNCTION_NAME}") - file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the C ${FUNCTION_NAME} exists failed with the following output:\n" - "${OUTPUT_VAR}\n\n") - endif () - else () - message (FATAL_ERROR "Compilation of C ${FUNCTION_NAME} - Failed") - endif () -endmacro () -endif () - -set (PROG_SRC - " -#include -#include -#define CHECK_FLOAT128 ${${HDF_PREFIX}_SIZEOF___FLOAT128} -#if CHECK_FLOAT128!=0 -# if ${${HDF_PREFIX}_HAVE_QUADMATH_H}!=0 -#include -# endif -# ifdef FLT128_DIG -#define C_FLT128_DIG FLT128_DIG -# else -#define C_FLT128_DIG 0 -# endif -#else -#define C_FLT128_DIG 0 -#endif -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define C_LDBL_DIG DECIMAL_DIG -#else -#define C_LDBL_DIG LDBL_DIG -#endif - int main() { - printf(\"%d\\\\n%d\\\\n\", C_LDBL_DIG, C_FLT128_DIG)\\\; - return 1\\\; - } - " -) - -if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") - check_c_source_runs (${PROG_SRC} PROG_OUTPUT) -else () - C_RUN ("maximum decimal precision for C" ${PROG_SRC} PROG_OUTPUT) -endif () - -# dnl The output from the above program will be: -# dnl -- LINE 1 -- long double decimal precision -# dnl -- LINE 2 -- __float128 decimal precision - -# Convert the string to a list of strings by replacing the carriage return with a semicolon -string (REGEX REPLACE "\n" ";" PROG_OUTPUT "${PROG_OUTPUT}") - -list (GET PROG_OUTPUT 0 LDBL_DIG) -list (GET PROG_OUTPUT 1 FLT128_DIG) - -if (${HDF_PREFIX}_SIZEOF___FLOAT128 EQUAL 0 OR FLT128_DIG EQUAL 0) - set (${HDF_PREFIX}_HAVE_FLOAT128 0) - set (${HDF_PREFIX}_SIZEOF___FLOAT128 0) - set (${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION ${LDBL_DIG}) -else () - set(${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION ${FLT128_DIG}) -endif () +string (REGEX REPLACE "{" "" OUT_VAR1 ${PAC_FC_ALL_REAL_KINDS}) +string (REGEX REPLACE "}" "" OUT_VAR1 ${OUT_VAR1}) +set (${HDF_PREFIX}_H5CONFIG_F_RKIND "INTEGER, DIMENSION(1:num_rkinds) :: rkind = (/${OUT_VAR1}/)") +string (REGEX REPLACE "{" "" OUT_VAR2 ${PAC_FC_ALL_REAL_KINDS_SIZEOF}) +string (REGEX REPLACE "}" "" OUT_VAR2 ${OUT_VAR2}) +set (${HDF_PREFIX}_H5CONFIG_F_RKIND_SIZEOF "INTEGER, DIMENSION(1:num_rkinds) :: rkind_sizeof = (/${OUT_VAR2}/)") # Setting definition if there is a 16 byte fortran integer string (FIND ${PAC_FC_ALL_INTEGER_KINDS_SIZEOF} "16" pos) diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake index 757692c3313..64ec0107d2c 100644 --- a/config/cmake/HDFCXXCompilerFlags.cmake +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -71,10 +71,6 @@ endif () # HDF5 library compile options #----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- -# CDash is configured to only allow 3000 warnings, so -# break into groups (from the config/gnu-flags file) -#----------------------------------------------------------------------------- if (NOT MSVC AND NOT MINGW) if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") list (APPEND HDF5_CMAKE_CXX_FLAGS "-erroff=%none -DBSD_COMP") @@ -90,9 +86,11 @@ if (NOT MSVC AND NOT MINGW) # warnings that are emitted. If you need it, add it at configure time. if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/general") + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0) + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/15") + endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0) - list (APPEND H5_CXXFLAGS "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow") - list (APPEND H5_CXXFLAGS "-Wsign-compare -Wtrigraphs -Wwrite-strings") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/18") endif() elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED @@ -121,21 +119,20 @@ if (NOT MSVC AND NOT MINGW) #----------------------------------------------------------------------------- if (HDF5_ENABLE_DEV_WARNINGS) message (STATUS "....HDF5 developer group warnings are enabled") - # if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - # list (APPEND H5_CXXFLAGS "-Winline -Wreorder -Wport -Wstrict-aliasing") - # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # autotools always add the C flags with the CXX flags + if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/developer-general") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # Use the C warnings as CXX warnings are the same ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") - # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - # ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") endif () else () if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # autotools always add the C flags with the CXX flags + # Use the C warnings as CXX warnings are the same ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general") - # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - # ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") endif () endif () @@ -143,28 +140,28 @@ if (NOT MSVC AND NOT MINGW) # Technically, variable-length arrays are part of the C99 standard, but # we should approach them a bit cautiously... Only needed for gcc 4.X if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0 AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.8) - # autotools always add the C flags with the CXX flags + # Use the C warnings as CXX warnings are the same ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8-4.last") endif () - # Append more extra warning flags that only gcc 4.8+ know about + # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) - ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-4.8") if (HDF5_ENABLE_DEV_WARNINGS) + # Use the C warnings as CXX warnings are the same ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8") else () ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.8") endif () endif () - # Append more extra warning flags that only gcc 4.9+ know about + # Append more extra warning flags that only gcc 4.9+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") + # Use the C warnings as CXX warnings are the same ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-4.9") endif () - # Append more extra warning flags that only gcc 5.1+ know about + # Append more extra warning flags that only gcc 5.1+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) # autotools always add the C flags with the CXX flags ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-5") @@ -175,35 +172,35 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 6.x+ know about + # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) - # autotools always add the C flags with the CXX flags + # Use the C warnings as CXX warnings are the same ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") endif () - # Append more extra warning flags that only gcc 7.x+ know about + # Append more extra warning flags that only gcc 7.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) - # autotools always add the C flags with the CXX flags + # Use the C warnings as CXX warnings are the same ADD_H5_FLAGS (H5_CXxFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") if (HDF5_ENABLE_DEV_WARNINGS) - # autotools always add the C flags with the CXX flags + # Use the C warnings as CXX warnings are the same ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-7") #else () # ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-7") endif () endif () - # Append more extra warning flags that only gcc 8.x+ know about + # Append more extra warning flags that only gcc 8.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) - # autotools always add the C flags with the CXX flags + # Use the C warnings as CXX warnings are the same ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") - #if (HDF5_ENABLE_WARNINGS_AS_ERRORS) - # ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-8") - #else () - # ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/noerror-8") - #endif () + if (HDF5_ENABLE_WARNINGS_AS_ERRORS) + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-8") + else () + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/noerror-8") + endif () if (HDF5_ENABLE_DEV_WARNINGS) - # autotools always add the C flags with the CXX flags + # Use the C warnings as CXX warnings are the same ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-8") else () # autotools always add the C flags with the CXX flags @@ -211,16 +208,28 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 9.x+ know about + # Append more extra warning flags that only gcc 9.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-9") endif () - endif () -else () - if (NOT MINGW) - list (APPEND HDF5_CMAKE_CXX_FLAGS "/EHsc") + + # Append more extra warning flags that only gcc 9.3+ knows about + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.3) + # do not use C warnings, gnu-warnings 9.3, no cxx warniings + # ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9.3") endif () + + # Append more extra warning flags that only gcc 10.x+ knows about + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) + if (HDF5_ENABLE_DEV_WARNINGS) + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-10") + #else () + # ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-10") + endif () + endif () + endif () endif () #----------------------------------------------------------------------------- diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index bb6ad78ded5..e38a92b76b1 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -81,10 +81,6 @@ endif () # HDF5 library compile options #----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- -# CDash is configured to only allow 3000 warnings, so -# break into groups (from the config/gnu-flags file) -#----------------------------------------------------------------------------- if (NOT MSVC AND NOT MINGW) #----------------------------------------------------------------------------- # Option to allow the user to interpret certain warnings as errors @@ -112,14 +108,13 @@ if (NOT MSVC AND NOT MINGW) # warnings that are emitted. If you need it, add it at configure time. if (CMAKE_C_COMPILER_ID STREQUAL "Intel") ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/general") - list (APPEND H5_CFLAGS "-Wcomment -Wdeprecated -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith") - list (APPEND H5_CFLAGS "-Wreturn-type -Wstrict-prototypes -Wuninitialized") - list (APPEND H5_CFLAGS "-Wunknown-pragmas -Wunused-function -Wunused-variable") + if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0) + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/15") + endif() # this is just a failsafe list (APPEND H5_CFLAGS "-finline-functions") if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 18.0) - list (APPEND H5_CFLAGS "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow") - list (APPEND H5_CFLAGS "-Wsign-compare -Wtrigraphs -Wwrite-strings") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/18") endif() elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") # Add general CFlags for GCC versions 4.8 and above @@ -157,7 +152,7 @@ if (NOT MSVC AND NOT MINGW) if (HDF5_ENABLE_DEV_WARNINGS) message (STATUS "....HDF5 developer group warnings are enabled") if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - list (APPEND H5_CFLAGS "-Winline -Wreorder -Wport -Wstrict-aliasing") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/developer-general") elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.8) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") elseif (CMAKE_C_COMPILER_ID MATCHES "[Cc]lang") @@ -178,7 +173,7 @@ if (NOT MSVC AND NOT MINGW) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8-4.last") endif () - # Append more extra warning flags that only gcc 4.8+ know about + # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") if (HDF5_ENABLE_DEV_WARNINGS) @@ -188,12 +183,12 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 4.9+ know about + # Append more extra warning flags that only gcc 4.9+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") endif () - # Append more extra warning flags that only gcc 5.x+ know about + # Append more extra warning flags that only gcc 5.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/5") if (HDF5_ENABLE_WARNINGS_AS_ERRORS) @@ -203,12 +198,12 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 6.x+ know about + # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") endif () - # Append more extra warning flags that only gcc 7.x+ know about + # Append more extra warning flags that only gcc 7.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 7.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") if (HDF5_ENABLE_DEV_WARNINGS) @@ -218,7 +213,7 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 8.x+ know about + # Append more extra warning flags that only gcc 8.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") if (HDF5_ENABLE_WARNINGS_AS_ERRORS) @@ -231,17 +226,17 @@ if (NOT MSVC AND NOT MINGW) endif () endif () - # Append more extra warning flags that only gcc 9.x+ know about + # Append more extra warning flags that only gcc 9.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") endif () - # Append more extra warning flags that only gcc 9.3+ know about + # Append more extra warning flags that only gcc 9.3+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.3) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9.3") endif () - # Append more extra warning flags that only gcc 10.x+ know about + # Append more extra warning flags that only gcc 10.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 10.0) if (HDF5_ENABLE_DEV_WARNINGS) ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-10") diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 8b631ad003d..18ab62186de 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -80,37 +80,37 @@ if (NOT MSVC AND NOT MINGW) if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") - # Append more extra warning flags that only gcc 4.8+ know about + # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.8) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8") endif () - # Append more extra warning flags that only gcc 4.9+ know about + # Append more extra warning flags that only gcc 4.9+ knows about #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.9) # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.9") #endif () - # Append more extra warning flags that only gcc 5.x+ know about + # Append more extra warning flags that only gcc 5.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-5") endif () - # Append more extra warning flags that only gcc 6.x+ know about + # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-6") endif () - # Append more extra warning flags that only gcc 7.x+ know about + # Append more extra warning flags that only gcc 7.x+ knows about #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0) # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-7") #endif () - # Append more extra warning flags that only gcc 8.x+ know about + # Append more extra warning flags that only gcc 8.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-8") endif () - # Append more extra warning flags that only gcc 9.x+ know about + # Append more extra warning flags that only gcc 9.x+ knows about #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0) # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-9") #endif () diff --git a/config/cmake/scripts/HDF5config.cmake b/config/cmake/scripts/HDF5config.cmake index a5444c883e6..5ed97a439c6 100755 --- a/config/cmake/scripts/HDF5config.cmake +++ b/config/cmake/scripts/HDF5config.cmake @@ -38,7 +38,7 @@ cmake_minimum_required (VERSION 3.12) ############################################################################## set (CTEST_SOURCE_VERSION "1.10.8") -set (CTEST_SOURCE_VERSEXT "-1") +set (CTEST_SOURCE_VERSEXT "-2") ############################################################################## # handle input parameters to script. diff --git a/config/gnu-cxxflags b/config/gnu-cxxflags index cba8298293e..b2ba08d47ec 100644 --- a/config/gnu-cxxflags +++ b/config/gnu-cxxflags @@ -183,7 +183,6 @@ if test "X-g++" = "X-$cxx_vendor"; then # Warnings # ############ -# First load the C warnings then add CXX warnings (if needed) ########### # General # @@ -199,6 +198,7 @@ if test "X-g++" = "X-$cxx_vendor"; then # Developer warnings # ###################### + # Use the C warnings as CXX warnings are the same NO_DEVELOPER_WARNING_CXXFLAGS=$(load_gnu_arguments no-developer-general) DEVELOPER_WARNING_CXXFLAGS=$(load_gnu_arguments developer-general) @@ -210,6 +210,7 @@ if test "X-g++" = "X-$cxx_vendor"; then # GCC 4.8 through the end of GCC 4 series if test $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 8; then + # Use the C warnings as CXX warnings are the same H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.8-4.last)" fi @@ -220,13 +221,13 @@ if test "X-g++" = "X-$cxx_vendor"; then # gcc >= 4.8 if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 8; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-4.8)" + # Use the C warnings as CXX warnings are the same DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.8)" NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.8)" fi # gcc >= 4.9 if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 9; then - H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.9)" H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-4.9)" fi @@ -239,27 +240,40 @@ if test "X-g++" = "X-$cxx_vendor"; then # gcc >= 6 if test $cxx_vers_major -ge 6; then + # Use the C warnings as CXX warnings are the same H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 6)" fi # gcc >= 7 if test $cxx_vers_major -ge 7; then + # Use the C warnings as CXX warnings are the same H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 7)" DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-7)" fi # gcc 8 if test $cxx_vers_major -ge 8; then + # Use the C warnings as CXX warnings are the same H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 8)" #H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-8)" #H5_NECXXFLAGS="$H5_NECXXFLAGS $(load_gnu_arguments noerror-8)" + # Use the C warnings as CXX warnings are the same DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-8)" NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-8)" fi # gcc 9 if test $cxx_vers_major -ge 9; then - H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 9)" + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-9)" + fi + + # gcc >= 9.3 + # no cxx warnings, do NOT use C warnings + + # gcc >= 10 + if test $cxx_vers_major -ge 10; then + # Use the C warnings as CXX warnings are the same + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gnu_arguments developer-10)" fi ################# diff --git a/config/gnu-flags b/config/gnu-flags index 01533de30ac..3e4ceb222fc 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -207,9 +207,9 @@ if test "X-gcc" = "X-$cc_vendor"; then H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_arguments error-general)" H5_NECFLAGS="$H5_NECFLAGS $(load_gnu_arguments noerror-general)" - ###################### - # Developer warnings # - ###################### + ###################### + # Developer warnings # + ###################### NO_DEVELOPER_WARNING_CFLAGS=$(load_gnu_arguments no-developer-general) DEVELOPER_WARNING_CFLAGS=$(load_gnu_arguments developer-general) diff --git a/config/gnu-warnings/cxx-4.9 b/config/gnu-warnings/cxx-4.9 index 046d6dbdc08..30553bdab79 100644 --- a/config/gnu-warnings/cxx-4.9 +++ b/config/gnu-warnings/cxx-4.9 @@ -1 +1,2 @@ +-Wdate-time -Wopenmp-simd diff --git a/config/gnu-warnings/cxx-9 b/config/gnu-warnings/cxx-9 new file mode 100644 index 00000000000..8f843a46c23 --- /dev/null +++ b/config/gnu-warnings/cxx-9 @@ -0,0 +1,4 @@ +-Wattribute-alias=2 +-Wmissing-profile +# Turn this on when the C++ wrappers obey the Rule of Five +-Wno-deprecated-copy diff --git a/config/gnu-warnings/developer-10 b/config/gnu-warnings/developer-10 index fcd460dbd38..022c97f9666 100644 --- a/config/gnu-warnings/developer-10 +++ b/config/gnu-warnings/developer-10 @@ -1,6 +1,2 @@ # New warning -Warith-conversion - -# Enable static analysis of program flow --fanalyzer --fdiagnostics-path-format=none diff --git a/config/gnu-warnings/noerror-general b/config/gnu-warnings/noerror-general index f5b4afbebab..80c197503c7 100644 --- a/config/gnu-warnings/noerror-general +++ b/config/gnu-warnings/noerror-general @@ -1,6 +1,8 @@ # -# HDF5 code should not trigger the following warnings under any -# circumstances, so ask the compiler to treat them as errors: +# These warnings will be treated as errors, using the error-general file, +# when HDF5_ENABLE_WARNINGS_AS_ERRORS is set to true for CMake or +# the --enable-warnings-as-errors option is specified for configure. +# Otherwise this file will be used to treat them as warnings. # -Wbad-function-cast -Wimplicit-function-declaration diff --git a/config/intel-cxxflags b/config/intel-cxxflags new file mode 100644 index 00000000000..484100f403f --- /dev/null +++ b/config/intel-cxxflags @@ -0,0 +1,184 @@ +# -*- shell-script -*- +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. + + +# This file should be sourced into configure if the compiler is the +# Intel icpc compiler or a derivative. It is careful not to do anything +# if the compiler is not Intel; otherwise `cxx_flags_set' is set to `yes' +# + +# +# Prepend `$srcdir/config/intel-warnings/` to the filename suffix(es) given as +# subroutine argument(s), remove comments starting with # and ending +# at EOL, replace spans of whitespace (including newlines) with spaces, +# and re-emit the file(s) thus filtered on the standard output stream. +# +load_intel_arguments() +{ + set -- $(for arg; do + sed 's,#.*$,,' $srcdir/config/intel-warnings/${arg} + done) + IFS=' ' echo "$*" +} + +# Get the compiler version in a way that works for icpc +# icpc unless a compiler version is already known +# +# cxx_vendor: The compiler name: icpc +# cxx_version: Version number: 8.0 +# +if test X = "X$cxx_flags_set"; then + cxx_version="`$CXX $CXXFLAGS $H5_CXXFLAGS -V 2>&1 |grep 'Version'`" + if test X != "X$cxx_version"; then + cxx_vendor=icpc + cxx_version=`echo $cxx_version |sed 's/.*Version \([-a-z0-9\.\-]*\).*/\1/'` + echo "compiler '$CXX' is Intel $cxx_vendor-$cxx_version" + + # Some version numbers + # Intel version numbers are of the form: "major.minor" + cxx_vers_major=`echo $cxx_version | cut -f1 -d.` + cxx_vers_minor=`echo $cxx_version | cut -f2 -d.` + #cxx_vers_patch=`echo $cxx_version | cut -f2 -d.` + test -n "$cxx_vers_major" || cxx_vers_major=0 + test -n "$cxx_vers_minor" || cxx_vers_minor=0 + test -n "$cxx_vers_patch" || cxx_vers_patch=0 + cxx_vers_all=`expr $cxx_vers_major '*' 1000000 + $cxx_vers_minor '*' 1000 + $cxx_vers_patch` + fi +fi + +# Common Intel flags for various situations +if test "X-icpc" = "X-$cxx_vendor"; then + # Insert section about version specific problems from compiler flags here, + # if necessary. + + arch= + # Architecture-specific flags + # Nothing currently. (Uncomment code below and modify to add any) + #case "$host_os-$host_cpu" in + # *-i686) + # arch="-march=i686" + # ;; + #esac + + # Host-specific flags + # Nothing currently. (Uncomment code below and modify to add any) + #case "`hostname`" in + # sleipnir.ncsa.uiuc.edu) + # arch="$arch -pipe" + # ;; + #esac + + ########### + # General # + ########### + + H5_CXXFLAGS="$H5_CXXFLAGS $arch" + + ############## + # Production # + ############## + + PROD_CXXFLAGS= + + ######### + # Debug # + ######### + + # NDEBUG is handled explicitly in configure + # -g is handled by the symbols flags + DEBUG_CXXFLAGS= + + ########### + # Symbols # + ########### + + NO_SYMBOLS_CXXFLAGS="-Wl,-s" + SYMBOLS_CXXFLAGS="-g" + + ############# + # Profiling # + ############# + + PROFILE_CXXFLAGS="-p" + + ################ + # Optimization # + ################ + + HIGH_OPT_CXXFLAGS="-O3" + DEBUG_OPT_CXXFLAGS="-O0" + NO_OPT_CXXFLAGS="-O0" + + ############ + # Warnings # + ############ + + ########### + # General # + ########### + + # Add various general warning flags in intel-warnings. + # Use the C warnings as CXX warnings are the same + H5_CXXFLAGS="$H5_CXXFLAGS $(load_intel_arguments general)" + + ###################### + # Developer warnings # + ###################### + + # Use the C warnings as CXX warnings are the same + #NO_DEVELOPER_WARNING_CXXFLAGS=$(load_intel_arguments no-developer-general) + #DEVELOPER_WARNING_CXXFLAGS=$(load_intel_arguments developer-general) + + ############################# + # Version-specific warnings # + ############################# + + # intel == 8.0 + if test $cxx_vers_major -eq 8 -a $cxx_vers_minor -eq 0; then + # v8.0 -O3 infinite loops when compiling test/tselect.c. Use -O2. + HIGH_OPT_CFLAGS="-O2" + fi + + # intel == 10 + if test $cxx_vers_major -eq 10; then + HIGH_OPT_CFLAGS="-O1" + fi + + # intel >= 15 + if test $cxx_vers_major -ge 15; then + # Use the C warnings as CXX warnings are the same + H5_CXXFLAGS="$H5_CXXFLAGS $(load_intel_arguments 15)" + fi + + # intel >= 18 + if test $cxx_vers_major -ge 18; then + # Use the C warnings as CXX warnings are the same + H5_CXXFLAGS="$H5_CXXFLAGS $(load_intel_arguments 18)" + fi + + # intel <= 19 + if test $cxx_vers_major -le 19; then + # Use the C warnings as CXX warnings are the same + H5_CXXFLAGS="$H5_CXXFLAGS $(load_intel_arguments general-19)" + fi + + ################# + # Flags are set # + ################# + cxx_flags_set=yes +fi + +# Clear cxx info if no flags set +if test "X-$cxx_flags_set" = "X-"; then + cxx_vendor= + cxx_version= +fi diff --git a/config/intel-fflags b/config/intel-fflags index b759dfac88a..42c17819912 100644 --- a/config/intel-fflags +++ b/config/intel-fflags @@ -56,13 +56,17 @@ if test X = "X$f9x_flags_set"; then fi fi -# Common Intel flags for various situations if test "X-ifort" = "X-$f9x_vendor"; then - # Insert section about version specific problems from compiler flags here, - # if necessary. + + FC_BASENAME=ifort + F9XSUFFIXFLAG="" + FSEARCH_DIRS="" + + ############################### + # Architecture-specific flags # + ############################### arch= - # Architecture-specific flags # Nothing currently. (Uncomment code below and modify to add any) #case "$host_os-$host_cpu" in # *-i686) @@ -78,32 +82,55 @@ if test "X-ifort" = "X-$f9x_vendor"; then # ;; #esac - # General - FC_BASENAME=ifort - F9XSUFFIXFLAG="" - FSEARCH_DIRS="" - H5_FCFLAGS="$H5_FCFLAGS -stand:f03 -free" - H5_FCFLAGS="$H5_FCFLAGS $(load_intel_arguments ifort-general)" + ############## + # Production # + ############## - # Production PROD_FCFLAGS= - # Debug + ######### + # Debug # + ######### + DEBUG_FCFLAGS="-check all" - # Symbols - SYMBOLS_FCFLAGS="-g" + ########### + # Symbols # + ########### + NO_SYMBOLS_FCFLAGS= + SYMBOLS_FCFLAGS="-g" + + ############# + # Profiling # + ############# - # Profiling - # Use this for profiling with gprof PROFILE_FCFLAGS="-p" - # Optimization + ################ + # Optimization # + ################ + HIGH_OPT_FCFLAGS="-O3" DEBUG_OPT_FCFLAGS= NO_OPT_FCFLAGS= + ############ + # Warnings # + ############ + + ########### + # General # + ########### + + H5_FCFLAGS="$H5_FCFLAGS -stand:f03 -free" + H5_FCFLAGS="$H5_FCFLAGS $(load_intel_arguments ifort-general)" + + ############################# + # Version-specific warnings # + ############################# + + ################# # Flags are set # ################# @@ -116,4 +143,3 @@ if test "X-$f9x_flags_set" = "X-"; then f9x_version= fi - diff --git a/config/intel-flags b/config/intel-flags index 409ffe971a7..f46da0aa6da 100644 --- a/config/intel-flags +++ b/config/intel-flags @@ -78,26 +78,43 @@ if test "X-icc" = "X-$cc_vendor"; then # ;; #esac - # General + ########### + # General # + ########### + # Default to C99 standard. H5_CFLAGS="$H5_CFLAGS $arch -std=c99" - # Production + ############## + # Production # + ############## + PROD_CFLAGS= - # Debug + ######### + # Debug # + ######### + # NDEBUG is handled explicitly in configure DEBUG_CFLAGS= - # Symbols - SYMBOLS_CFLAGS="-g" + ########### + # Symbols # + ########### + NO_SYMBOLS_CFLAGS="-Wl,-s" + SYMBOLS_CFLAGS="-g" + + ############# + # Profiling # + ############# - # Profiling - # Use this for profiling with gprof PROFILE_CFLAGS="-p" - # Optimization + ################ + # Optimization # + ################ + HIGH_OPT_CFLAGS="-O3" DEBUG_OPT_CFLAGS="-O0" NO_OPT_CFLAGS="-O0" @@ -110,32 +127,51 @@ if test "X-icc" = "X-$cc_vendor"; then # General # ########### + # Add various general warning flags in intel-warnings. H5_CFLAGS="$H5_CFLAGS $(load_intel_arguments general)" + ###################### + # Developer warnings # + ###################### + + #NO_DEVELOPER_WARNING_CFLAGS=$(load_intel_arguments no-developer-general) + #DEVELOPER_WARNING_CFLAGS=$(load_intel_arguments developer-general) + ############################# # Version-specific warnings # ############################# -case "$cc_vendor-$cc_version" in - icc-1[5-6]*) - H5_CFLAGS="$H5_CFLAGS -Wcomment -Wdeprecated -Wextra-tokens -Wformat -Wformat-security -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith -Wreturn-type -Wshadow -Wstrict-prototypes -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-variable -Wwrite-strings" - ;; - icc-10*) - HIGH_OPT_CFLAGS="-O1" - ;; - icc-8.0*) + # intel == 8.0 + if test $cc_vers_major -eq 8 -a $cc_vers_minor -eq 0; then # v8.0 -O3 infinite loops when compiling test/tselect.c. Use -O2. HIGH_OPT_CFLAGS="-O2" - ;; - icc-*) - ;; -esac + fi + + # intel == 10 + if test $cc_vers_major -eq 10; then + HIGH_OPT_CFLAGS="-O1" + fi + + # intel >= 15 + if test $cc_vers_major -ge 15; then + H5_CFLAGS="$H5_CFLAGS $(load_intel_arguments 15)" + fi + + # intel >= 18 + if test $cc_vers_major -ge 18; then + H5_CFLAGS="$H5_CFLAGS $(load_intel_arguments 18)" + fi + + # intel <= 19 + # this file has warnings only available before oneapi versions + if test $cc_vers_major -le 19; then + H5_CFLAGS="$H5_CFLAGS $(load_intel_arguments general-19)" + fi ################# # Flags are set # ################# cc_flags_set=yes - fi # Clear cc info if no flags set diff --git a/config/intel-warnings/15 b/config/intel-warnings/15 new file mode 100644 index 00000000000..6746f975736 --- /dev/null +++ b/config/intel-warnings/15 @@ -0,0 +1,19 @@ +-Wcomment +-Wdeprecated +-Wextra-tokens +-Wformat +-Wformat-security +-Wmain +-Wmissing-declarations +-Wmissing-prototypes +-Wp64 +-Wpointer-arith +-Wreturn-type +-Wshadow +-Wstrict-prototypes +-Wtrigraphs +-Wuninitialized +-Wunknown-pragmas +-Wunused-function +-Wunused-variable +-Wwrite-strings diff --git a/config/intel-warnings/18 b/config/intel-warnings/18 new file mode 100644 index 00000000000..565b47a4d85 --- /dev/null +++ b/config/intel-warnings/18 @@ -0,0 +1,8 @@ +-Wextra-tokens +-Wformat +-Wformat-security +-Wic-pointer +-Wshadow +-Wsign-compare +-Wtrigraphs +-Wwrite-strings diff --git a/config/intel-warnings/developer-general b/config/intel-warnings/developer-general new file mode 100644 index 00000000000..fae56f0acc8 --- /dev/null +++ b/config/intel-warnings/developer-general @@ -0,0 +1,4 @@ +-Winline +-Wreorder +-Wport +-Wstrict-aliasing diff --git a/config/intel-warnings/general b/config/intel-warnings/general index d0b2e25e997..bd866b6966d 100644 --- a/config/intel-warnings/general +++ b/config/intel-warnings/general @@ -1,2 +1 @@ -Wall --Wcheck \ No newline at end of file diff --git a/config/intel-warnings/general-19 b/config/intel-warnings/general-19 new file mode 100644 index 00000000000..e35af30213c --- /dev/null +++ b/config/intel-warnings/general-19 @@ -0,0 +1,2 @@ +# this is only available before oneapi versions +-Wcheck diff --git a/config/linux-gnulibc1 b/config/linux-gnulibc1 index 0fef1616984..d952c4eeffb 100644 --- a/config/linux-gnulibc1 +++ b/config/linux-gnulibc1 @@ -199,9 +199,16 @@ if test -z "$CXX"; then CXX_BASENAME=g++ fi +# Figure out Intel CXX compiler flags +# Do this ahead of GNU to avoid icpc being detected as g++ +. $srcdir/config/intel-cxxflags + # Figure out GNU CXX compiler flags . $srcdir/config/gnu-cxxflags +# Figure out PGI CXX compiler flags +. $srcdir/config/pgi-cxxflags + # Figure out Clang CXX compiler flags . $srcdir/config/clang-cxxflags @@ -314,6 +321,9 @@ fi # check if the compiler_version_info is already set if test -z "$cxx_version_info"; then case $CXX in + *pgc++*) + cxx_version_info=`$CXX $CXXFLAGS $H5_CXXFLAGS -V 2>&1 | grep 'pgc++'` + ;; *g++*) cxx_version_info=`$CXX $CXXFLAGS $H5_CXXFLAGS --version 2>&1 |\ grep 'GCC' | sed 's/\(.*(GCC) [-a-z0-9\. ]*\).*/\1/'` @@ -322,10 +332,6 @@ case $CXX in cxx_version_info=`$CXX $CXXFLAGS $H5_CXXFLAGS -V 2>&1 | grep 'Version' |\ sed 's/\(Intel.* Compiler\).*\( Version [a-z0-9\.]*\).*\( Build [0-9]*\)/\1\2\3/'` ;; - *pgCC*) - cxx_version_info=`$CXX $CXXFLAGS $H5_CXXFLAGS -V 2>&1 | grep 'pgCC'` - ;; - *mpicxx*) cxx_version_info=`$CXX $CXXFLAGS $H5_CXXFLAGS -v 2>&1 | grep 'version' |\ sed 's/^[a-z0-9]* for //' |\ diff --git a/config/pgi-cxxflags b/config/pgi-cxxflags new file mode 100644 index 00000000000..5fc74ae24f4 --- /dev/null +++ b/config/pgi-cxxflags @@ -0,0 +1,100 @@ +# -*- shell-script -*- +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. + + +# This file should be sourced into configure if the compiler is the +# PGI pgc++ compiler or a derivative. It is careful not to do anything +# if the compiler is not PGI; otherwise `cxx_flags_set' is set to `yes' +# + +# Get the compiler version in a way that works for pgc++ +# pgc++ unless a compiler version is already known +# +# cxx_vendor: The compiler name: pgc++ +# cxx_version: Version number: 5.0-2, 5.2-2 +# +if test X = "X$cxx_flags_set"; then + cxx_version="`$CXX $CXXFLAGS -V 2>&1 |grep '^pgc++ '`" + if test X != "X$cxx_version"; then + cxx_vendor=`echo $cxx_version |sed 's/\([a-z]*++\).*/\1/'` + cxx_version=`echo $cxx_version |sed 's/pgc++ \([-a-z0-9\.\-]*\).*/\1/'` + echo "compiler '$CXX' is PGI $cxx_vendor-$cxx_version" + + # Some version numbers + # PGI version numbers are of the form: "major.minor-patch" + cxx_vers_major=`echo $cxx_version | cut -f1 -d.` + cxx_vers_minor=`echo $cxx_version | cut -f2 -d. | cut -f1 -d-` + cxx_vers_patch=`echo $cxx_version | cut -f2 -d. | cut -f2 -d-` + test -n "$cxx_vers_major" || cxx_vers_major=0 + test -n "$cxx_vers_minor" || cxx_vers_minor=0 + test -n "$cxx_vers_patch" || cxx_vers_patch=0 + cxx_vers_all=`expr $cxx_vers_major '*' 1000000 + $cxx_vers_minor '*' 1000 + $cxx_vers_patch` + fi +fi + +# Common PGI flags for various situations +if test "X-pgc++" = "X-$cxx_vendor"; then + + ########### + # General # + ########### + + H5_CXXFLAGS="$H5_CXXFLAGS -Minform=warn" + + ############## + # Production # + ############## + + PROD_CXXFLAGS= + + ######### + # Debug # + ######### + + # NDEBUG is handled explicitly in configure + # -g is handled by the symbols flags + DEBUG_CXXFLAGS="-Mbounds" + + ########### + # Symbols # + ########### + + NO_SYMBOLS_CXXFLAGS="-s" + SYMBOLS_CXXFLAGS="-g" + + ############# + # Profiling # + ############# + + PROFILE_CXXFLAGS="-Mprof=func,line" + # Use this for profiling with gprof + #PROFILE_CXXFLAGS="-pg" + + ################ + # Optimization # + ################ + + HIGH_OPT_CXXFLAGS="-O4" + DEBUG_OPT_CXXFLAGS="-gopt -O2" + NO_OPT_CXXFLAGS="-O0" + + ################# + # Flags are set # + ################# + cxx_flags_set=yes +fi + +# Clear cxx info if no flags set +if test "X-$cxx_flags_set" = "X-"; then + cxx_vendor= + cxx_version= +fi diff --git a/config/pgi-fflags b/config/pgi-fflags index 31716955172..6401d8dd5b0 100644 --- a/config/pgi-fflags +++ b/config/pgi-fflags @@ -1,4 +1,4 @@ -# -*- shell-script -*- +# -*- shell-script -*- # # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. @@ -45,11 +45,12 @@ fi # Common PGI flags for various situations if test "X-pgf90" = "X-$f9x_vendor"; then - # Insert section about version specific problems from gnu-flags here, if - # necessary. + + ############################### + # Architecture-specific flags # + ############################### arch= - # Architecture-specific flags # Nothing currently. (Uncomment code below and modify to add any) #case "$host_os-$host_cpu" in # *-i686) @@ -65,15 +66,10 @@ if test "X-pgf90" = "X-$f9x_vendor"; then # ;; #esac - # General - FC_BASENAME=pgf90 - Fortran_COMPILER_ID=PGI - F9XSUFFIXFLAG="" - FSEARCH_DIRS="" - # Uncomment the following to add something specific for FCFLAGS. - #FCFLAGS="$FCFLAGS" + ############## + # Production # + ############## - # Production # Check for MPI wrapper being used and tweak down compiler options # Comment out the Tweaking since it caused problems to mpich1.2.6. # Need to investigate the reasons to tweak. @@ -84,24 +80,55 @@ if test "X-pgf90" = "X-$f9x_vendor"; then #fi PROD_FCFLAGS="-fast -Mnoframe" - # Debug + ######### + # Debug # + ######### + DEBUG_FCFLAGS="-Mbounds -Mchkptr -Mdclchk" - # Symbols - SYMBOLS_FCFLAGS="-g" + ########### + # Symbols # + ########### + NO_SYMBOLS_FCFLAGS="-s" + SYMBOLS_FCFLAGS="-g" + + ############# + # Profiling # + ############# - # Profiling PROFILE_FCFLAGS="-Mprof=func,line" # Use this for profiling with gprof #PROFILE_FCFLAGS="-pg" - # Optimization + ################ + # Optimization # + ################ + HIGH_OPT_FCFLAGS= DEBUG_OPT_FCFLAGS= NO_OPT_FCFLAGS= - # Flags are set + ############ + # Warnings # + ############ + + ########### + # General # + ########### + + FC_BASENAME=pgf90 + Fortran_COMPILER_ID=PGI + F9XSUFFIXFLAG="" + FSEARCH_DIRS="" + # Uncomment the following to add something specific for FCFLAGS. + #FCFLAGS="$FCFLAGS" + + + + ################# + # Flags are set # + ################# f9x_flags_set=yes fi @@ -111,4 +138,3 @@ if test "X-$f9x_flags_set" = "X-"; then f9x_version= fi - diff --git a/config/pgi-flags b/config/pgi-flags index e1bec000486..b197a1ce7f3 100644 --- a/config/pgi-flags +++ b/config/pgi-flags @@ -1,4 +1,4 @@ -# -*- shell-script -*- +# -*- shell-script -*- # # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. @@ -45,8 +45,8 @@ fi # Common PGI flags for various situations if test "X-pgcc" = "X-$cc_vendor"; then - # Insert section about version specific problems from gnu-flags here, if - # necessary. + # Insert section about version specific problems from compiler flags here, + # if necessary. arch= # Architecture-specific flags @@ -65,58 +65,59 @@ if test "X-pgcc" = "X-$cc_vendor"; then # ;; #esac - # General - H5_CFLAGS="$H5_CFLAGS $arch -c99 -Minform=inform" - - # Production - case "$cc_vendor-$cc_version" in - pgcc-10.6*) - PROD_CFLAGS= - ;; - pgcc-9.*) - PROD_CFLAGS= - ;; - *) - PROD_CFLAGS="-fast" - ;; - esac - - # Debug + ########### + # General # + ########### + + # Default to C99 standard. + H5_CFLAGS="$H5_CFLAGS $arch -c99 -Minform=warn" + + ############## + # Production # + ############## + + # NDEBUG is handled explicitly by the configure script + PROD_CFLAGS="-fast" + + ######### + # Debug # + ######### + # NDEBUG is handled explicitly by the configure script + # -g is handled by the symbols flags DEBUG_CFLAGS="-Mbounds" - # Symbols - SYMBOLS_CFLAGS="-g" + ########### + # Symbols # + ########### + NO_SYMBOLS_CFLAGS="-s" + SYMBOLS_CFLAGS="-g" + + ############# + # Profiling # + ############# - # Profiling PROFILE_CFLAGS="-Mprof=func,line" # Use this for profiling with gprof #PROFILE_CFLAGS="-pg" - # Optimization - case "$cc_vendor-$cc_version" in - # Tweak down compiler optimizations for v10.6, it has a bug - pgcc-10.6*) - HIGH_OPT_CFLAGS="-O1" - ;; - # Tweak down compiler optimizations for v9.x - pgcc-9.*) - HIGH_OPT_CFLAGS="-O1" - ;; - *) - HIGH_OPT_CFLAGS= - ;; - esac - DEBUG_OPT_CFLAGS= - NO_OPT_CFLAGS= - - # Flags are set + ################ + # Optimization # + ################ + + HIGH_OPT_CFLAGS="-O4" + DEBUG_OPT_CFLAGS="-gopt -O2" + NO_OPT_CFLAGS="-O0" + + ################# + # Flags are set # + ################# cc_flags_set=yes fi # Clear cc info if no flags set if test "X-$cc_flags_set" = "X-"; then - cc_vendor= - cc_version= + cc_vendor= + cc_version= fi diff --git a/configure.ac b/configure.ac index e9776f5661b..d0ce46a6d22 100644 --- a/configure.ac +++ b/configure.ac @@ -24,7 +24,7 @@ AC_PREREQ([2.69]) ## NOTE: Do not forget to change the version number here when we do a ## release!!! ## -AC_INIT([HDF5], [1.10.8-1], [help@hdfgroup.org]) +AC_INIT([HDF5], [1.10.8-2], [help@hdfgroup.org]) AC_CONFIG_SRCDIR([src/H5.c]) AC_CONFIG_HEADERS([src/H5config.h]) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index a725c63c134..a250a15f7e1 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -1,4 +1,4 @@ -HDF5 version 1.10.8-1 currently under development +HDF5 version 1.10.8-2 currently under development ================================================================================ @@ -49,6 +49,30 @@ New Features Configuration: ------------- + - Adds C++ Autotools configuration file for Intel + + * Checks for icpc as the compiler + * Copies most non-warning flags from intel-flags + + (DER - 2021/06/02) + + - Adds C++ Autotools configuration file for PGI + + * Checks for pgc++ as the compiler name (was: pgCC) + * Other options basically match new C options (below) + + (DER - 2021/06/02) + + - Updates PGI C options + + * -Minform set to warn (was: inform) to suppress spurious messages + * Sets -gopt -O2 as debug options + * Sets -O4 as 'high optimization' option + * Sets -O0 as 'no optimization' option + * Removes specific settings for PGI 9 and 10 + + (DER - 2021/06/02) + - CMake no longer builds the C++ library by default HDF5_BUILD_CPP_LIB now defaults to OFF, which is in line with the @@ -84,7 +108,7 @@ New Features To do so, set CMAKE_OSX_ARCHITECTURES="x86_64;arm64" - (SAM - 2021/02/07, https://github.com/HDFGroup/hdf5/issues/311) + (SAM - 2021/02/07, github-311) - Added a configure-time option to control certain compiler warnings diagnostics @@ -179,7 +203,7 @@ New Features CMake target is 'doxygen' for all available doxygen targets CMake target is 'hdf5lib_doc' for the src subdirectory - (ADB - 2020/11/13) + (ADB - 2020/11/13, HDFFV-11243) - CMake option to use MSVC naming conventions with MinGW @@ -395,6 +419,22 @@ Bug Fixes since HDF5-1.10.7 release Configuration ------------- + - Refactor CMake configure for Fortran + + The Fortran configure tests for KINDs reused a single output file that was + read to form the Integer and Real Kinds defines. However, if config was run + more then once, the CMake completed variable prevented the tests from executing + again and the last value saved in the file was used to create the define. + Creating separate files for each KIND solved the issue. + + In addition the test for H5_PAC_C_MAX_REAL_PRECISION was not pulling in + defines for proper operation and did not define H5_PAC_C_MAX_REAL_PRECISION + correctly for a zero value. This was fixed by supplying the required defines. + In addition it was moved from the Fortran specific HDF5UseFortran.camke file + to the C centric ConfigureChecks.cmake file. + + (ADB - 2021/06/03) + - Remove arbitrary warning flag groups from CMake builds The arbitrary groups were created to reduce the quantity of warnings being @@ -672,6 +712,9 @@ Known Problems CPP ptable test fails on both VS2017 and VS2019 with Intel compiler, JIRA issue: HDFFV-10628. This test will pass with VS2015 with Intel compiler. + The subsetting option in ph5diff currently will fail and should be avoided. + The subsetting option works correctly in serial h5diff. + Known problems in previous releases can be found in the HISTORY*.txt files in the HDF5 source. Please report any new problems found to help@hdfgroup.org. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ac6d65a69f8..f19c62ab117 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -372,6 +372,8 @@ IDE_GENERATED_PROPERTIES ("H5HP" "${H5HP_HDRS}" "${H5HP_SOURCES}" ) set (H5I_SOURCES ${HDF5_SRC_DIR}/H5I.c + ${HDF5_SRC_DIR}/H5Idbg.c + ${HDF5_SRC_DIR}/H5Iint.c ${HDF5_SRC_DIR}/H5Itest.c ) set (H5I_HDRS @@ -904,6 +906,8 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5Zprivate.h ${HDF5_SRC_DIR}/H5win32defs.h + + ${HDF5_SRC_DIR}/uthash.h ) set (H5_GENERATED_HEADERS diff --git a/src/H5I.c b/src/H5I.c index 3d985f7961e..75678c7cac4 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -12,58 +12,31 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * FILE: H5I.c - Internal storage routines for handling "IDs" - * - * REMARKS: IDs which allow objects (void * currently) to be bundled - * into "types" for more general storage. - * - * DESIGN: The types are stored in an array of pointers to store each - * type in an element. Each "type" node contains a link to a - * hash table to manage the IDs in each type. Allowed types are - * values within the range 1 to H5I_MAX_NUM_TYPES and are given out - * at run-time. Types used by the library are stored in global - * variables defined in H5Ipublic.h. + * H5I.c - Public routines for handling IDs */ +/****************/ +/* Module Setup */ +/****************/ + #include "H5Imodule.h" /* This source code file is part of the H5I module */ -#define H5T_FRIEND /* Suppress error about including H5Tpkg */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ #include "H5Gprivate.h" /* Groups */ #include "H5Ipkg.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5SLprivate.h" /* Skip Lists */ -#include "H5Tpkg.h" /* Datatypes */ +/****************/ /* Local Macros */ +/****************/ -/* Combine a Type number and an atom index into an atom */ -#define H5I_MAKE(g, i) ((((hid_t)(g)&TYPE_MASK) << ID_BITS) | ((hid_t)(i)&ID_MASK)) - -/* Local typedefs */ - -/* Atom information structure used */ -typedef struct H5I_id_info_t { - hid_t id; /* ID for this info */ - unsigned count; /* ref. count for this atom */ - unsigned app_count; /* ref. count of application visible atoms */ - const void *obj_ptr; /* pointer associated with the atom */ -} H5I_id_info_t; - -/* ID type structure used */ -typedef struct { - const H5I_class_t *cls; /* Pointer to ID class */ - unsigned init_count; /* # of times this type has been initialized */ - uint64_t id_count; /* Current number of IDs held */ - uint64_t nextid; /* ID to use for the next atom */ - H5SL_t * ids; /* Pointer to skip list that stores IDs */ -} H5I_id_type_t; +/******************/ +/* Local Typedefs */ +/******************/ typedef struct { H5I_search_func_t app_cb; /* Application's callback routine */ @@ -71,107 +44,27 @@ typedef struct { void * ret_obj; /* Object to return */ } H5I_search_ud_t; -/* User data for iterator callback for ID iteration */ -typedef struct { - H5I_search_func_t user_func; /* 'User' function to invoke */ - void * user_udata; /* User data to pass to 'user' function */ - hbool_t app_ref; /* Whether this is an appl. ref. call */ -} H5I_iterate_ud_t; +/********************/ +/* Package Typedefs */ +/********************/ -/* User data for H5I__clear_type_cb */ -typedef struct { - H5I_id_type_t *type_ptr; /* Pointer to the type being cleard */ - hbool_t force; /* Whether to always remove the id */ - hbool_t app_ref; /* Whether this is an appl. ref. call */ -} H5I_clear_type_ud_t; - -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - -/*-------------------- Locally scoped variables -----------------------------*/ - -/* Array of pointers to atomic types */ -static H5I_id_type_t *H5I_id_type_list_g[H5I_MAX_NUM_TYPES]; - -/* Variable to keep track of the number of types allocated. Its value is the */ -/* next type ID to be handed out, so it is always one greater than the number */ -/* of types. */ -/* Starts at 1 instead of 0 because it makes trace output look nicer. If more */ -/* types (or IDs within a type) are needed, adjust TYPE_BITS in H5Ipkg.h */ -/* and/or increase size of hid_t */ -static int H5I_next_type = (int)H5I_NTYPES; - -/* Declare a free list to manage the H5I_id_info_t struct */ -H5FL_DEFINE_STATIC(H5I_id_info_t); - -/* Declare a free list to manage the H5I_id_type_t struct */ -H5FL_DEFINE_STATIC(H5I_id_type_t); - -/* Declare a free list to manage the H5I_class_t struct */ -H5FL_DEFINE_STATIC(H5I_class_t); - -/*--------------------- Local function prototypes ---------------------------*/ -static htri_t H5I__clear_type_cb(void *_id, void *key, void *udata); -static int H5I__destroy_type(H5I_type_t type); -static void * H5I__remove_verify(hid_t id, H5I_type_t id_type); -static void * H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id); -static int H5I__inc_type_ref(H5I_type_t type); -static int H5I__get_type_ref(H5I_type_t type); -static int H5I__search_cb(void *obj, hid_t id, void *_udata); -static H5I_id_info_t *H5I__find_id(hid_t id); -static int H5I__debug_cb(void *_item, void *_key, void *_udata); -static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); +/********************/ +/* Local Prototypes */ +/********************/ -/*------------------------------------------------------------------------- - * Function: H5I_term_package - * - * Purpose: Terminate the H5I interface: release all memory, reset all - * global variables to initial values. This only happens if all - * types have been destroyed from other interfaces. - * - * Return: Success: Positive if any action was taken that might - * affect some other interface; zero otherwise. - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -int -H5I_term_package(void) -{ - int n = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - if (H5_PKG_INIT_VAR) { - H5I_id_type_t *type_ptr; /* Pointer to ID type */ - int type; /* Type of ID */ - - /* How many types are still being used? */ - for (type = 0; type < H5I_next_type; type++) - if ((type_ptr = H5I_id_type_list_g[type]) && type_ptr->ids) - n++; - - /* If no types are used then clean up */ - if (0 == n) { - for (type = 0; type < H5I_next_type; type++) { - type_ptr = H5I_id_type_list_g[type]; - if (type_ptr) { - HDassert(NULL == type_ptr->ids); - type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); - H5I_id_type_list_g[type] = NULL; - n++; - } /* end if */ - } /* end for */ - - /* Mark interface closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ - } /* end if */ - - FUNC_LEAVE_NOAPI(n) -} /* end H5I_term_package() */ +static int H5I__search_cb(void *obj, hid_t id, void *_udata); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ /*------------------------------------------------------------------------- * Function: H5Iregister_type @@ -193,8 +86,8 @@ H5I_term_package(void) H5I_type_t H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, H5I_free_t free_func) { - H5I_class_t *cls = NULL; /* New ID class */ - H5I_type_t new_type; /* New ID type value */ + H5I_class_t *cls = NULL; /* New ID class */ + H5I_type_t new_type = H5I_BADID; /* New ID type value */ H5I_type_t ret_value = H5I_BADID; /* Return value */ FUNC_ENTER_API(H5I_BADID) @@ -203,18 +96,18 @@ H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, H5I /* Generate a new H5I_type_t value */ /* Increment the number of types */ - if (H5I_next_type < H5I_MAX_NUM_TYPES) { - new_type = (H5I_type_t)H5I_next_type; - H5I_next_type++; - } /* end if */ + if (H5I_next_type_g < H5I_MAX_NUM_TYPES) { + new_type = (H5I_type_t)H5I_next_type_g; + H5I_next_type_g++; + } else { hbool_t done; /* Indicate that search was successful */ - int i; /* Local index variable */ + int i; /* Look for a free type to give out */ done = FALSE; for (i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES && done == FALSE; i++) { - if (NULL == H5I_id_type_list_g[i]) { + if (NULL == H5I_type_info_array_g[i]) { /* Found a free type ID */ new_type = (H5I_type_t)i; done = TRUE; @@ -227,11 +120,11 @@ H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, H5I } /* Allocate new ID class */ - if (NULL == (cls = H5FL_CALLOC(H5I_class_t))) + if (NULL == (cls = H5MM_calloc(sizeof(H5I_class_t)))) HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, H5I_BADID, "ID class allocation failed") /* Initialize class fields */ - cls->type_id = new_type; + cls->type = new_type; cls->flags = H5I_CLASS_IS_APPLICATION; cls->reserved = reserved; cls->free_func = free_func; @@ -247,70 +140,11 @@ H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, H5I /* Clean up on error */ if (ret_value < 0) if (cls) - cls = H5FL_FREE(H5I_class_t, cls); + cls = H5MM_xfree(cls); FUNC_LEAVE_API(ret_value) } /* end H5Iregister_type() */ -/*------------------------------------------------------------------------- - * Function: H5I_register_type - * - * Purpose: Creates a new type of ID's to give out. - * The class is initialized or its reference count is incremented - * (if it is already initialized). - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5I_register_type(const H5I_class_t *cls) -{ - H5I_id_type_t *type_ptr = NULL; /* Ptr to the atomic type*/ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(cls); - HDassert(cls->type_id > 0 && (int)cls->type_id < H5I_MAX_NUM_TYPES); - - /* Initialize the type */ - if (NULL == H5I_id_type_list_g[cls->type_id]) { - /* Allocate the type information for new type */ - if (NULL == (type_ptr = (H5I_id_type_t *)H5FL_CALLOC(H5I_id_type_t))) - HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, FAIL, "ID type allocation failed") - H5I_id_type_list_g[cls->type_id] = type_ptr; - } /* end if */ - else { - /* Get the pointer to the existing type */ - type_ptr = H5I_id_type_list_g[cls->type_id]; - } /* end else */ - - /* Initialize the ID type structure for new types */ - if (type_ptr->init_count == 0) { - type_ptr->cls = cls; - type_ptr->id_count = 0; - type_ptr->nextid = cls->reserved; - if (NULL == (type_ptr->ids = H5SL_create(H5SL_TYPE_HID, NULL))) - HGOTO_ERROR(H5E_ATOM, H5E_CANTCREATE, FAIL, "skip list creation failed") - } /* end if */ - - /* Increment the count of the times this type has been initialized */ - type_ptr->init_count++; - -done: - if (ret_value < 0) { /* Clean up on error */ - if (type_ptr) { - if (type_ptr->ids) - H5SL_close(type_ptr->ids); - (void)H5FL_FREE(H5I_id_type_t, type_ptr); - } /* end if */ - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_register_type() */ - /*------------------------------------------------------------------------- * Function: H5Itype_exists * @@ -332,10 +166,10 @@ H5Itype_exists(H5I_type_t type) /* Validate parameter */ if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") - if (type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if (NULL == H5I_id_type_list_g[type]) + if (NULL == H5I_type_info_array_g[type]) ret_value = FALSE; done: @@ -361,7 +195,7 @@ H5Itype_exists(H5I_type_t type) herr_t H5Inmembers(H5I_type_t type, hsize_t *num_members) { - int ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "It*h", type, num_members); @@ -373,9 +207,9 @@ H5Inmembers(H5I_type_t type, hsize_t *num_members) * the private interface handle it, because the public interface throws * an error when the supplied type does not exist. */ - if (type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if (NULL == H5I_id_type_list_g[type]) + if (NULL == H5I_type_info_array_g[type]) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "supplied type does not exist") if (num_members) { @@ -391,42 +225,6 @@ H5Inmembers(H5I_type_t type, hsize_t *num_members) FUNC_LEAVE_API(ret_value) } /* end H5Inmembers() */ -/*------------------------------------------------------------------------- - * Function: H5I_nmembers - * - * Purpose: Returns the number of members in a type. - * - * Return: Success: Number of members; zero if the type is empty - * or has been deleted. - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Wednesday, March 24, 1999 - * - *------------------------------------------------------------------------- - */ -int64_t -H5I_nmembers(H5I_type_t type) -{ - H5I_id_type_t *type_ptr; /* Pointer to the ID type */ - int64_t ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Validate parameter */ - if (type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if (NULL == (type_ptr = H5I_id_type_list_g[type]) || type_ptr->init_count <= 0) - HGOTO_DONE(0); - - /* Set return value */ - H5_CHECKED_ASSIGN(ret_value, int64_t, type_ptr->id_count, uint64_t); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_nmembers() */ - /*------------------------------------------------------------------------- * Function: H5Iclear_type * @@ -459,117 +257,10 @@ H5Iclear_type(H5I_type_t type, hbool_t force) FUNC_LEAVE_API(ret_value) } /* end H5Iclear_type() */ -/*------------------------------------------------------------------------- - * Function: H5I_clear_type - * - * Purpose: Removes all objects from the type, calling the free - * function for each object regardless of the reference count. - * - * Return: SUCCEED/FAIL - * - * Programmer: Robb Matzke - * Wednesday, March 24, 1999 - * - *------------------------------------------------------------------------- - */ -herr_t -H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) -{ - H5I_clear_type_ud_t udata; /* udata struct for callback */ - int ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Validate parameters */ - if (type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - - udata.type_ptr = H5I_id_type_list_g[type]; - if (udata.type_ptr == NULL || udata.type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - - /* Finish constructing udata */ - udata.force = force; - udata.app_ref = app_ref; - - /* Attempt to free all ids in the type */ - if (H5SL_try_free_safe(udata.type_ptr->ids, H5I__clear_type_cb, &udata) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, FAIL, "can't free ids in type") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_clear_type() */ - -/*------------------------------------------------------------------------- - * Function: H5I__clear_type_cb - * - * Purpose: Attempts to free the specified ID, calling the free - * function for the object. - * - * Return: TRUE/FALSE/FAIL - * - * Programmer: Neil Fortner - * Friday, July 10, 2015 - * - *------------------------------------------------------------------------- - */ -static htri_t -H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) -{ - H5I_id_info_t * id = (H5I_id_info_t *)_id; /* Current ID being worked with */ - H5I_clear_type_ud_t *udata = (H5I_clear_type_ud_t *)_udata; /* udata struct */ - htri_t ret_value = FALSE; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Sanity checks */ - HDassert(id); - HDassert(udata); - HDassert(udata->type_ptr); - - /* Do nothing to the object if the reference count is larger than - * one and forcing is off. - */ - if (udata->force || (id->count - (!udata->app_ref * id->app_count)) <= 1) { - /* Check for a 'free' function and call it, if it exists */ - if (udata->type_ptr->cls->free_func && - (udata->type_ptr->cls->free_func)((void *)id->obj_ptr) < 0) { /* (Casting away const OK -QAK) */ - if (udata->force) { -#ifdef H5I_DEBUG - if (H5DEBUG(I)) { - HDfprintf(H5DEBUG(I), - "H5I: free type=%d obj=0x%08lx " - "failure ignored\n", - (int)udata->type_ptr->cls->type_id, (unsigned long)(id->obj_ptr)); - } /* end if */ -#endif /*H5I_DEBUG*/ - - /* Indicate node should be removed from list */ - ret_value = TRUE; - } /* end if */ - } /* end if */ - else { - /* Indicate node should be removed from list */ - ret_value = TRUE; - } /* end else */ - - /* Remove ID if requested */ - if (ret_value) { - /* Free ID info */ - id = H5FL_FREE(H5I_id_info_t, id); - - /* Decrement the number of IDs in the type */ - udata->type_ptr->id_count--; - } /* end if */ - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__clear_type_cb() */ - /*------------------------------------------------------------------------- * Function: H5Idestroy_type * - * Purpose: Destroys a type along with all atoms in that type + * Purpose: Destroys a type along with all IDs in that type * regardless of their reference counts. Destroying IDs * involves calling the free-func for each ID's object and * then adding the ID struct to the ID free list. Public @@ -599,63 +290,10 @@ H5Idestroy_type(H5I_type_t type) FUNC_LEAVE_API(ret_value) } /* end H5Idestroy_type() */ -/*------------------------------------------------------------------------- - * Function: H5I__destroy_type - * - * Purpose: Destroys a type along with all atoms in that type - * regardless of their reference counts. Destroying IDs - * involves calling the free-func for each ID's object and - * then adding the ID struct to the ID free list. - * - * Return: SUCCEED/FAIL - * - * Programmer: Nathaniel Furrer - * James Laird - * - *------------------------------------------------------------------------- - */ -static herr_t -H5I__destroy_type(H5I_type_t type) -{ - H5I_id_type_t *type_ptr; /* ptr to the atomic type */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Validate parameter */ - if (type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - - type_ptr = H5I_id_type_list_g[type]; - if (type_ptr == NULL || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - - /* Close/clear/destroy all IDs for this type */ - H5E_BEGIN_TRY - { - H5I_clear_type(type, TRUE, FALSE); - } - H5E_END_TRY /*don't care about errors*/ - - /* Check if we should release the ID class */ - if (type_ptr->cls->flags & H5I_CLASS_IS_APPLICATION) - type_ptr->cls = H5FL_FREE(H5I_class_t, (void *)type_ptr->cls); - - if (H5SL_close(type_ptr->ids) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEOBJ, FAIL, "can't close skip list") - type_ptr->ids = NULL; - - type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); - H5I_id_type_list_g[type] = NULL; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__destroy_type() */ - /*------------------------------------------------------------------------- * Function: H5Iregister * - * Purpose: Public interface to H5I_register. + * Purpose: Register an object. * * Return: Success: New object ID * Failure: H5I_INVALID_HID @@ -671,7 +309,7 @@ H5Iregister(H5I_type_t type, const void *object) H5TRACE2("i", "It*x", type, object); if (H5I_IS_LIB_TYPE(type)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, H5I_INVALID_HID, "cannot call public function on library type") ret_value = H5I_register(type, object, TRUE); @@ -679,196 +317,6 @@ H5Iregister(H5I_type_t type, const void *object) FUNC_LEAVE_API(ret_value) } /* end H5Iregister() */ -/*------------------------------------------------------------------------- - * Function: H5I_register - * - * Purpose: Registers an OBJECT in a TYPE and returns an ID for it. - * This routine does _not_ check for unique-ness of the objects, - * if you register an object twice, you will get two different - * IDs for it. This routine does make certain that each ID in a - * type is unique. IDs are created by getting a unique number - * for the type the ID is in and incorporating the type into - * the ID which is returned to the user. - * - * Return: Success: New object ID - * Failure: H5I_INVALID_HID - * - *------------------------------------------------------------------------- - */ -hid_t -H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) -{ - H5I_id_type_t *type_ptr = NULL; /* ptr to the type */ - H5I_id_info_t *id_ptr = NULL; /* ptr to the new ID information */ - hid_t new_id = -1; /* new ID */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ - - FUNC_ENTER_NOAPI(H5I_INVALID_HID) - - /* Check arguments */ - if (type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "invalid type number") - type_ptr = H5I_id_type_list_g[type]; - if ((NULL == type_ptr) || (type_ptr->init_count <= 0)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, H5I_INVALID_HID, "invalid type") - if (NULL == (id_ptr = H5FL_MALLOC(H5I_id_info_t))) - HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") - - /* Create the struct & its ID */ - new_id = H5I_MAKE(type, type_ptr->nextid); - id_ptr->id = new_id; - id_ptr->count = 1; /* initial reference count */ - id_ptr->app_count = !!app_ref; - id_ptr->obj_ptr = object; - - /* Insert into the type */ - if (H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert ID node into skip list") - type_ptr->id_count++; - type_ptr->nextid++; - - /* Sanity check for the 'nextid' getting too large and wrapping around */ - HDassert(type_ptr->nextid <= ID_MASK); - - /* Set return value */ - ret_value = new_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_register() */ - -/*------------------------------------------------------------------------- - * Function: H5I_register_using_existing_id - * - * Purpose: Registers an OBJECT in a TYPE with the supplied ID for it. - * This routine will check to ensure the supplied ID is not already - * in use, and ensure that it is a valid ID for the given type, - * but will NOT check to ensure the OBJECT is not already - * registered (thus, it is possible to register one object under - * multiple IDs). - * - * NOTE: Intended for use in refresh calls, where we have to close - * and re-open the underlying data, then hook the object back - * up to the original ID. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, hid_t existing_id) -{ - H5I_id_type_t *type_ptr; /* ptr to the type */ - H5I_id_info_t *id_ptr; /* ptr to the new ID information */ - herr_t ret_value = SUCCEED; /* return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check arguments */ - HDassert(object); - - /* Make sure ID is not already in use */ - if (NULL != (id_ptr = H5I__find_id(existing_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use") - - /* Make sure type number is valid */ - if (type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - - /* Get type pointer from list of types */ - type_ptr = H5I_id_type_list_g[type]; - - if (NULL == type_ptr || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - - /* Make sure requested ID belongs to object's type */ - if (H5I_TYPE(existing_id) != type) - HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "invalid type for provided ID") - - /* Allocate new structure to house this ID */ - if (NULL == (id_ptr = H5FL_MALLOC(H5I_id_info_t))) - HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Create the struct & insert requested ID */ - id_ptr->id = existing_id; - id_ptr->count = 1; /* initial reference count*/ - id_ptr->app_count = !!app_ref; - id_ptr->obj_ptr = object; - - /* Insert into the type */ - if (H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, FAIL, "can't insert ID node into skip list") - type_ptr->id_count++; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_register_using_existing_id() */ - -/*------------------------------------------------------------------------- - * Function: H5I_subst - * - * Purpose: Substitute a new object pointer for the specified ID. - * - * Return: Success: Non-NULL previous object pointer associated - * with the specified ID. - * Failure: NULL - * - * Programmer: Quincey Koziol - * Saturday, February 27, 2010 - * - *------------------------------------------------------------------------- - */ -void * -H5I_subst(hid_t id, const void *new_object) -{ - H5I_id_info_t *id_ptr; /* Pointer to the atom */ - void * ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* General lookup of the ID */ - if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_NOTFOUND, NULL, "can't get ID ref count") - - /* Get the old object pointer to return */ - ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ - - /* Set the new object pointer for the ID */ - id_ptr->obj_ptr = new_object; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_subst() */ - -/*------------------------------------------------------------------------- - * Function: H5I_object - * - * Purpose: Find an object pointer for the specified ID. - * - * Return: Success: Non-NULL object pointer associated with the - * specified ID - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5I_object(hid_t id) -{ - H5I_id_info_t *id_ptr; /* Pointer to the new atom */ - void * ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOERR - - /* General lookup of the ID */ - if (NULL != (id_ptr = H5I__find_id(id))) { - /* Get the object pointer to return */ - ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ - } - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_object() */ - /*------------------------------------------------------------------------- * Function: H5Iobject_verify * @@ -883,92 +331,25 @@ H5I_object(hid_t id) *------------------------------------------------------------------------- */ void * -H5Iobject_verify(hid_t id, H5I_type_t id_type) +H5Iobject_verify(hid_t id, H5I_type_t type) { void *ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) - H5TRACE2("*x", "iIt", id, id_type); + H5TRACE2("*x", "iIt", id, type); /* Validate parameters */ - if (H5I_IS_LIB_TYPE(id_type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") - if (id_type < 1 || (int)id_type >= H5I_next_type) + if (type < 1 || (int)type >= H5I_next_type_g) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "identifier has invalid type") - ret_value = H5I_object_verify(id, id_type); + ret_value = H5I_object_verify(id, type); done: FUNC_LEAVE_API(ret_value) } /* end H5Iobject_verify() */ -/*------------------------------------------------------------------------- - * Function: H5I_object_verify - * - * Purpose: Find an object pointer for the specified ID, verifying that - * its in a particular type. - * - * Return: Success: Non-NULL object pointer associated with the - * specified ID. - * Failure: NULL - * - * Programmer: Quincey Koziol - * Wednesday, July 31, 2002 - * - *------------------------------------------------------------------------- - */ -void * -H5I_object_verify(hid_t id, H5I_type_t id_type) -{ - H5I_id_info_t *id_ptr = NULL; /* Pointer to the new atom */ - void * ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOERR - - HDassert(id_type >= 1 && (int)id_type < H5I_next_type); - - /* Verify that the type of the ID is correct & lookup the ID */ - if (id_type == H5I_TYPE(id) && NULL != (id_ptr = H5I__find_id(id))) { - /* Get the object pointer to return */ - ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ - } - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5I_object_verify() */ - -/*------------------------------------------------------------------------- - * Function: H5I_get_type - * - * Purpose: Given an object ID return the type to which it - * belongs. The ID need not be the ID of an object which - * currently exists because the type number is encoded - * in the object ID. - * - * Return: Success: A positive integer (corresponding to an H5I_type_t - * enum value for library ID types, but not for user - * ID types). - * Failure: H5I_BADID - * - * Programmer: Robb Matzke - * Friday, February 19, 1999 - * - *------------------------------------------------------------------------- - */ -H5I_type_t -H5I_get_type(hid_t id) -{ - H5I_type_t ret_value = H5I_BADID; /* Return value */ - - FUNC_ENTER_NOAPI_NOERR - - if (id > 0) - ret_value = H5I_TYPE(id); - - HDassert(ret_value >= H5I_BADID && (int)ret_value < H5I_next_type); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_get_type() */ - /*------------------------------------------------------------------------- * Function: H5Iget_type * @@ -994,7 +375,7 @@ H5Iget_type(hid_t id) ret_value = H5I_get_type(id); - if (ret_value <= H5I_BADID || (int)ret_value >= H5I_next_type || NULL == H5I_object(id)) + if (ret_value <= H5I_BADID || (int)ret_value >= H5I_next_type_g || NULL == H5I_object(id)) HGOTO_DONE(H5I_BADID); done: @@ -1019,138 +400,29 @@ H5Iget_type(hid_t id) *------------------------------------------------------------------------- */ void * -H5Iremove_verify(hid_t id, H5I_type_t id_type) +H5Iremove_verify(hid_t id, H5I_type_t type) { void *ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) - H5TRACE2("*x", "iIt", id, id_type); + H5TRACE2("*x", "iIt", id, type); - if (H5I_IS_LIB_TYPE(id_type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") /* Remove the id */ - ret_value = H5I__remove_verify(id, id_type); + ret_value = H5I__remove_verify(id, type); done: FUNC_LEAVE_API(ret_value) } /* end H5Iremove_verify() */ /*------------------------------------------------------------------------- - * Function: H5I__remove_verify + * Function: H5Idec_ref * - * Purpose: Removes the specified ID from its type, first checking that - * the ID's type is the same as the ID type supplied as an argument - * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL - * - * Programmer: James Laird - * Nat Furrer - * - *------------------------------------------------------------------------- - */ -static void * -H5I__remove_verify(hid_t id, H5I_type_t id_type) -{ - void *ret_value = NULL; /*return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Argument checking will be performed by H5I_remove() */ - - /* Verify that the type of the ID is correct */ - if (id_type == H5I_TYPE(id)) - ret_value = H5I_remove(id); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__remove_verify() */ - -/*------------------------------------------------------------------------- - * Function: H5I__remove_common - * - * Purpose: Common code to remove a specified ID from its type. - * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL - * - * Programmer: Quincey Koziol - * October 3, 2013 - * - *------------------------------------------------------------------------- - */ -static void * -H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id) -{ - H5I_id_info_t *curr_id; /* Pointer to the current atom */ - void * ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(type_ptr); - - /* Get the ID node for the ID */ - if (NULL == (curr_id = (H5I_id_info_t *)H5SL_remove(type_ptr->ids, &id))) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node from skip list") - - ret_value = (void *)curr_id->obj_ptr; /* (Casting away const OK -QAK) */ - curr_id = H5FL_FREE(H5I_id_info_t, curr_id); - - /* Decrement the number of IDs in the type */ - (type_ptr->id_count)--; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__remove_common() */ - -/*------------------------------------------------------------------------- - * Function: H5I_remove - * - * Purpose: Removes the specified ID from its type. - * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5I_remove(hid_t id) -{ - H5I_id_type_t *type_ptr; /* Pointer to the atomic type */ - H5I_type_t type; /* Atom's atomic type */ - void * ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Check arguments */ - type = H5I_TYPE(id); - if (type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid type number") - type_ptr = H5I_id_type_list_g[type]; - if (type_ptr == NULL || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid type") - - /* Remove the node from the type */ - if (NULL == (ret_value = H5I__remove_common(type_ptr, id))) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_remove() */ - -/*------------------------------------------------------------------------- - * Function: H5Idec_ref - * - * Purpose: Decrements the number of references outstanding for an ID. - * If the reference count for an ID reaches zero, the object - * will be closed. + * Purpose: Decrements the number of references outstanding for an ID. + * If the reference count for an ID reaches zero, the object + * will be closed. * * Return: Success: New reference count * Failure: -1 @@ -1180,163 +452,6 @@ H5Idec_ref(hid_t id) FUNC_LEAVE_API(ret_value) } /* end H5Idec_ref() */ -/*------------------------------------------------------------------------- - * Function: H5I_dec_ref - * - * Purpose: Decrements the number of references outstanding for an ID. - * This will fail if the type is not a reference counted type. - * The ID type's 'free' function will be called for the ID - * if the reference count for the ID reaches 0 and a free - * function has been defined at type creation time. - * - * Return: Success: New reference count - * - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -int -H5I_dec_ref(hid_t id) -{ - H5I_id_info_t *id_ptr; /* Pointer to the new ID */ - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI((-1)) - - /* Sanity check */ - HDassert(id >= 0); - - /* General lookup of the ID */ - if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") - - /* If this is the last reference to the object then invoke the type's - * free method on the object. If the free method is undefined or - * successful then remove the object from the type; otherwise leave - * the object in the type without decrementing the reference - * count. If the reference count is more than one then decrement the - * reference count without calling the free method. - * - * Beware: the free method may call other H5I functions. - * - * If an object is closing, we can remove the ID even though the free - * method might fail. This can happen when a mandatory filter fails to - * write when a dataset is closed and the chunk cache is flushed to the - * file. We have to close the dataset anyway. (SLU - 2010/9/7) - */ - if (1 == id_ptr->count) { - H5I_id_type_t *type_ptr; /*ptr to the type */ - - /* Get the ID's type */ - type_ptr = H5I_id_type_list_g[H5I_TYPE(id)]; - - /* (Casting away const OK -QAK) */ - if (!type_ptr->cls->free_func || (type_ptr->cls->free_func)((void *)id_ptr->obj_ptr) >= 0) { - /* Remove the node from the type */ - if (NULL == H5I__remove_common(type_ptr, id)) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, (-1), "can't remove ID node") - ret_value = 0; - } /* end if */ - else - ret_value = -1; - } /* end if */ - else { - --(id_ptr->count); - ret_value = (int)id_ptr->count; - } /* end else */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_dec_ref() */ - -/*------------------------------------------------------------------------- - * Function: H5I_dec_app_ref - * - * Purpose: H5I_dec_ref wrapper for case of modifying the application ref. - * count for an ID as well as normal reference count. - * - * Return: Success: New app. reference count - * Failure: -1 - * - * Programmer: Quincey Koziol - * Sept 16, 2010 - * - *------------------------------------------------------------------------- - */ -int -H5I_dec_app_ref(hid_t id) -{ - H5I_id_info_t *id_ptr; /* Pointer to the new ID */ - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI((-1)) - - /* Sanity check */ - HDassert(id >= 0); - - /* Call regular decrement reference count routine */ - if ((ret_value = H5I_dec_ref(id)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") - - /* Check if the ID still exists */ - if (ret_value > 0) { - /* General lookup of the ID */ - if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") - - /* Adjust app_ref */ - --(id_ptr->app_count); - HDassert(id_ptr->count >= id_ptr->app_count); - - /* Set return value */ - ret_value = (int)id_ptr->app_count; - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_dec_app_ref() */ - -/*------------------------------------------------------------------------- - * Function: H5I_dec_app_ref_always_close - * - * Purpose: H5I_dec_app_ref wrapper for case of always closing the ID, - * even when the free routine fails - * - * Return: Success: New app. reference count - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -int -H5I_dec_app_ref_always_close(hid_t id) -{ - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI((-1)) - - /* Sanity check */ - HDassert(id >= 0); - - /* Call application decrement reference count routine */ - ret_value = H5I_dec_app_ref(id); - - /* Check for failure */ - if (ret_value < 0) { - /* - * If an object is closing, we can remove the ID even though the free - * method might fail. This can happen when a mandatory filter fails to - * write when a dataset is closed and the chunk cache is flushed to the - * file. We have to close the dataset anyway. (SLU - 2010/9/7) - */ - H5I_remove(id); - - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_dec_app_ref_always_close() */ - /*------------------------------------------------------------------------- * Function: H5Iinc_ref * @@ -1367,43 +482,6 @@ H5Iinc_ref(hid_t id) FUNC_LEAVE_API(ret_value) } /* end H5Iinc_ref() */ -/*------------------------------------------------------------------------- - * Function: H5I_inc_ref - * - * Purpose: Increment the reference count for an object. - * - * Return: Success: The new reference count - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -int -H5I_inc_ref(hid_t id, hbool_t app_ref) -{ - H5I_id_info_t *id_ptr; /* Pointer to the ID */ - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI((-1)) - - /* Sanity check */ - HDassert(id >= 0); - - /* General lookup of the ID */ - if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") - - /* Adjust reference counts */ - ++(id_ptr->count); - if (app_ref) - ++(id_ptr->app_count); - - /* Set return value */ - ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_inc_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iget_ref * @@ -1434,38 +512,6 @@ H5Iget_ref(hid_t id) FUNC_LEAVE_API(ret_value) } /* end H5Iget_ref() */ -/*------------------------------------------------------------------------- - * Function: H5I_get_ref - * - * Purpose: Retrieve the reference count for an object. - * - * Return: Success: The reference count - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -int -H5I_get_ref(hid_t id, hbool_t app_ref) -{ - H5I_id_info_t *id_ptr; /* Pointer to the ID */ - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI((-1)) - - /* Sanity check */ - HDassert(id >= 0); - - /* General lookup of the ID */ - if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") - - /* Set return value */ - ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_get_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iinc_type_ref * @@ -1485,7 +531,7 @@ H5Iinc_type_ref(H5I_type_t type) H5TRACE1("Is", "It", type); /* Check arguments */ - if (type <= 0 || (int)type >= H5I_next_type) + if (type <= 0 || (int)type >= H5I_next_type_g) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") @@ -1498,46 +544,13 @@ H5Iinc_type_ref(H5I_type_t type) FUNC_LEAVE_API(ret_value) } /* end H5Iinc_ref() */ -/*------------------------------------------------------------------------- - * Function: H5I__inc_type_ref - * - * Purpose: Increment the reference count for an ID type. - * - * Return: Success: The new reference count - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -static int -H5I__inc_type_ref(H5I_type_t type) -{ - H5I_id_type_t *type_ptr; /* Pointer to the type */ - int ret_value = -1; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(type > 0 && (int)type < H5I_next_type); - - /* Check arguments */ - type_ptr = H5I_id_type_list_g[type]; - if (NULL == type_ptr) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") - - /* Set return value */ - ret_value = (int)(++(type_ptr->init_count)); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__inc_type_ref() */ - /*------------------------------------------------------------------------- * Function: H5Idec_type_ref * * Purpose: Decrements the reference count on an entire type of IDs. * If the type reference count becomes zero then the type is - * destroyed along with all atoms in that type regardless of - * their reference counts. Destroying IDs involves calling + * destroyed along with all IDs in that type regardless of + * their reference counts. Destroying IDs involves calling * the free-func for each ID's object and then adding the ID * struct to the ID free list. Public interface to * H5I_dec_type_ref. @@ -1572,58 +585,6 @@ H5Idec_type_ref(H5I_type_t type) FUNC_LEAVE_API(ret_value) } /* end H5Idec_type_ref() */ -/*------------------------------------------------------------------------- - * Function: H5I_dec_type_ref - * - * Purpose: Decrements the reference count on an entire type of IDs. - * If the type reference count becomes zero then the type is - * destroyed along with all atoms in that type regardless of - * their reference counts. Destroying IDs involves calling - * the free-func for each ID's object and then adding the ID - * struct to the ID free list. - * Returns the number of references to the type on success; a - * return value of 0 means that the type will have to be - * re-initialized before it can be used again (and should probably - * be set to H5I_UNINIT). - * - * Return: Success: Number of references to type - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -int -H5I_dec_type_ref(H5I_type_t type) -{ - H5I_id_type_t *type_ptr; /* Pointer to the ID type */ - herr_t ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI((-1)) - - if (type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "invalid type number") - - type_ptr = H5I_id_type_list_g[type]; - if (type_ptr == NULL || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") - - /* Decrement the number of users of the atomic type. If this is the - * last user of the type then release all atoms from the type and - * free all memory it used. The free function is invoked for each atom - * being freed. - */ - if (1 == type_ptr->init_count) { - H5I__destroy_type(type); - ret_value = 0; - } - else { - --(type_ptr->init_count); - ret_value = (herr_t)type_ptr->init_count; - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_dec_type_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iget_type_ref * @@ -1643,7 +604,7 @@ H5Iget_type_ref(H5I_type_t type) H5TRACE1("Is", "It", type); /* Check arguments */ - if (type <= 0 || (int)type >= H5I_next_type) + if (type <= 0 || (int)type >= H5I_next_type_g) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") @@ -1656,40 +617,6 @@ H5Iget_type_ref(H5I_type_t type) FUNC_LEAVE_API(ret_value) } /* end H5Iget_ref() */ -/*------------------------------------------------------------------------- - * Function: H5I__get_type_ref - * - * Purpose: Retrieve the reference count for an ID type. - * - * Return: Success: The reference count - * - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -static int -H5I__get_type_ref(H5I_type_t type) -{ - H5I_id_type_t *type_ptr; /* Pointer to the type */ - int ret_value = -1; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(type >= 0); - - /* Check arguments */ - type_ptr = H5I_id_type_list_g[type]; - if (!type_ptr) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - - /* Set return value */ - ret_value = (int)type_ptr->init_count; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__get_type_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iis_valid * @@ -1703,16 +630,16 @@ H5I__get_type_ref(H5I_type_t type) htri_t H5Iis_valid(hid_t id) { - H5I_id_info_t *id_ptr; /* ptr to the ID */ + H5I_id_info_t *info = NULL; /* Pointer to the ID info */ htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", id); /* Find the ID */ - if (NULL == (id_ptr = H5I__find_id(id))) + if (NULL == (info = H5I__find_id(id))) ret_value = FALSE; - else if (!id_ptr->app_count) /* Check if the found id is an internal id */ + else if (!info->app_count) /* Check if the found id is an internal id */ ret_value = FALSE; done: @@ -1804,138 +731,41 @@ H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key) } /* end H5Isearch() */ /*------------------------------------------------------------------------- - * Function: H5I__iterate_cb - * - * Purpose: Callback routine for H5I_iterate, invokes "user" callback - * function, and then sets return value, based on the result of - * that callback. - * - * Return: Success: H5_ITER_CONT (0) or H5_ITER_STOP (1) - * Failure: H5_ITER_ERROR (-1) - * - *------------------------------------------------------------------------- - */ -static int -H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) -{ - H5I_id_info_t * item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_iterate_ud_t *udata = (H5I_iterate_ud_t *)_udata; /* User data for callback */ - int ret_value = H5_ITER_CONT; /* Callback return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Only invoke the callback function if this ID is visible externally and - * its reference count is positive. - */ - if ((!udata->app_ref) || (item->app_count > 0)) { - herr_t cb_ret_val; - - /* Invoke callback function */ - cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, - udata->user_udata); /* (Casting away const OK) */ - - /* Set the return value based on the callback's return value */ - if (cb_ret_val > 0) - ret_value = H5_ITER_STOP; /* terminate iteration early */ - else if (cb_ret_val < 0) - ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ - } - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__iterate_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5I_iterate - * - * Purpose: Apply function FUNC to each member of type TYPE (with - * non-zero application reference count if app_ref is TRUE). - * Stop if FUNC returns a non zero value (i.e. anything - * other than H5_ITER_CONT). - * - * If FUNC returns a positive value (i.e. H5_ITER_STOP), - * return SUCCEED. - * - * If FUNC returns a negative value (i.e. H5_ITER_ERROR), - * return FAIL. + * Function: H5Iget_file_id * - * The FUNC should take a pointer to the object and the - * udata as arguments and return non-zero to terminate - * siteration, and zero to continue. + * Purpose: Obtains the file ID given an object ID. The user has to + * close this ID. * - * Limitation: Currently there is no way to start the iteration from - * where a previous iteration left off. + * Return: Success: The file ID associated with the object * - * Return: SUCCEED/FAIL + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ -herr_t -H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref) +hid_t +H5Iget_file_id(hid_t obj_id) { - H5I_id_type_t *type_ptr; /* Pointer to the type */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check arguments */ - if (type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - type_ptr = H5I_id_type_list_g[type]; + H5I_type_t type; /* ID type */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - /* Only iterate through ID list if it is initialized and there are IDs in type */ - if (type_ptr && type_ptr->init_count > 0 && type_ptr->id_count > 0) { - H5I_iterate_ud_t iter_udata; /* User data for iteration callback */ - herr_t iter_status; /* Iteration status */ + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "i", obj_id); - /* Set up iterator user data */ - iter_udata.user_func = func; - iter_udata.user_udata = udata; - iter_udata.app_ref = app_ref; + /* Get object type */ + type = H5I_TYPE(obj_id); - /* Iterate over IDs */ - if ((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") + /* Call internal function */ + if (H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || + H5I_ATTR == type) { + if ((ret_value = H5I_get_file_id(obj_id, type)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") } + else + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "not an ID of a file object") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_iterate() */ - -/*------------------------------------------------------------------------- - * Function: H5I__find_id - * - * Purpose: Given an object ID find the info struct that describes the - * object. - * - * Return: Success: A pointer to the object's info struct. - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static H5I_id_info_t * -H5I__find_id(hid_t id) -{ - H5I_type_t type; /*ID's type */ - H5I_id_type_t *type_ptr; /*ptr to the type */ - H5I_id_info_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Check arguments */ - type = H5I_TYPE(id); - if (type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_DONE(NULL) - type_ptr = H5I_id_type_list_g[type]; - if (!type_ptr || type_ptr->init_count <= 0) - HGOTO_DONE(NULL) - - /* Locate the ID node for the ID */ - ret_value = (H5I_id_info_t *)H5SL_search(type_ptr->ids, &id); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__find_id() */ + FUNC_LEAVE_API(ret_value) +} /* end H5Iget_file_id() */ /*------------------------------------------------------------------------- * Function: H5Iget_name @@ -1946,7 +776,7 @@ H5I__find_id(hid_t id) * * Failure: -1 * - * Comments: Public function + * Notes: * If 'name' is non-NULL then write up to 'size' bytes into that * buffer and always return the length of the entry name. * Otherwise 'size' is ignored and the function does not store the name, @@ -1961,8 +791,8 @@ H5I__find_id(hid_t id) ssize_t H5Iget_name(hid_t id, char *name /*out*/, size_t size) { - H5G_loc_t loc; /* Object location */ - ssize_t ret_value; /* Return value */ + H5G_loc_t loc; /* Object location */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", id, name, size); @@ -1978,185 +808,3 @@ H5Iget_name(hid_t id, char *name /*out*/, size_t size) done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_name() */ - -/*------------------------------------------------------------------------- - * Function: H5Iget_file_id - * - * Purpose: Obtains the file ID given an object ID. The user has to - * close this ID. - * - * Return: Success: The file ID associated with the object - * - * Failure: H5I_INVALID_HID - * - *------------------------------------------------------------------------- - */ -hid_t -H5Iget_file_id(hid_t obj_id) -{ - H5I_type_t type; /* ID type */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ - - FUNC_ENTER_API(H5I_INVALID_HID) - H5TRACE1("i", "i", obj_id); - - /* Get object type */ - type = H5I_TYPE(obj_id); - - /* Call internal function */ - if (H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || - H5I_ATTR == type) { - if ((ret_value = H5I_get_file_id(obj_id, type)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") - } - else - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "not an ID of a file object") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Iget_file_id() */ - -/*------------------------------------------------------------------------- - * Function: H5I_get_file_id - * - * Purpose: The private version of H5Iget_file_id(), obtains the file - * ID given an object ID. - * - * Return: Success: The file ID associated with the object - * Failure: H5I_INVALID_HID - * - *------------------------------------------------------------------------- - */ -hid_t -H5I_get_file_id(hid_t obj_id, H5I_type_t type) -{ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Process based on object type */ - if (type == H5I_FILE) { - /* Increment reference count on file ID */ - if (H5I_inc_ref(obj_id, TRUE) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") - - /* Set return value */ - ret_value = obj_id; - } - else { - H5G_loc_t loc; /* Location of object */ - - /* Get the object location information */ - if (H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get object location") - - /* Get the file ID for the object */ - if ((ret_value = H5F_get_id(loc.oloc->file, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get file ID") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_get_file_id() */ - -/*------------------------------------------------------------------------- - * Function: H5I__id_dump_cb - * - * Purpose: Dump the contents of an ID to stderr for debugging. - * - * Return: H5_ITER_CONT (always) - * - *------------------------------------------------------------------------- - */ -static int -H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) -{ - H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ - H5G_name_t * path = NULL; /* Path to file object */ - - FUNC_ENTER_STATIC_NOERR - - HDfprintf(stderr, " id = %lu\n", (unsigned long)(item->id)); - HDfprintf(stderr, " count = %u\n", item->count); - HDfprintf(stderr, " obj = 0x%08lx\n", (unsigned long)(item->obj_ptr)); - - /* Get the group location, so we get get the name */ - switch (type) { - case H5I_GROUP: { - path = H5G_nameof((const H5G_t *)item->obj_ptr); - break; - } - case H5I_DATASET: { - path = H5D_nameof((const H5D_t *)item->obj_ptr); - break; - } - case H5I_DATATYPE: { - path = H5T_nameof((const H5T_t *)item->obj_ptr); - break; - } - case H5I_UNINIT: - case H5I_BADID: - case H5I_FILE: - case H5I_DATASPACE: - case H5I_ATTR: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - break; /* Other types of IDs are not stored in files */ - } - - if (path) { - if (path->user_path_r) - HDfprintf(stderr, " user_path = %s\n", H5RS_get_str(path->user_path_r)); - if (path->full_path_r) - HDfprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r)); - } - - FUNC_LEAVE_NOAPI(H5_ITER_CONT) -} /* end H5I__id_dump_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5I_dump_ids_for_type - * - * Purpose: Dump the contents of a type to stderr for debugging. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5I_dump_ids_for_type(H5I_type_t type) -{ - H5I_id_type_t *type_ptr = NULL; - - FUNC_ENTER_NOAPI_NOERR - - HDfprintf(stderr, "Dumping ID type %d\n", (int)type); - type_ptr = H5I_id_type_list_g[type]; - - if (type_ptr) { - - /* Header */ - HDfprintf(stderr, " init_count = %u\n", type_ptr->init_count); - HDfprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved); - HDfprintf(stderr, " id_count = %llu\n", (unsigned long long)type_ptr->id_count); - HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid); - - /* List */ - if (type_ptr->id_count > 0) { - HDfprintf(stderr, " List:\n"); - H5SL_iterate(type_ptr->ids, H5I__id_dump_cb, &type); - } - } - else - HDfprintf(stderr, "Global type info/tracking pointer for that type is NULL\n"); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5I_dump_ids_for_type() */ diff --git a/src/H5Idbg.c b/src/H5Idbg.c new file mode 100644 index 00000000000..ef8ea65064a --- /dev/null +++ b/src/H5Idbg.c @@ -0,0 +1,181 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * H5Idbg.c - Debugging routines for handling IDs + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Imodule.h" /* This source code file is part of the H5I module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Ipkg.h" /* IDs */ +#include "H5RSprivate.h" /* Reference-counted strings */ +#include "H5Tprivate.h" /* Datatypes */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5I__id_dump_cb + * + * Purpose: Dump the contents of an ID to stderr for debugging. + * + * Return: H5_ITER_CONT (always) + * + *------------------------------------------------------------------------- + */ +static int +H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) +{ + H5I_id_info_t * info = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ + const H5G_name_t *path = NULL; /* Path to file object */ + + FUNC_ENTER_STATIC_NOERR + + HDfprintf(stderr, " id = %llu\n", (unsigned long long)(info->id)); + HDfprintf(stderr, " count = %u\n", info->count); + HDfprintf(stderr, " obj = 0x%8p\n", info->object); + HDfprintf(stderr, " marked = %d\n", info->marked); + + /* Get the group location, so we get get the name */ + switch (type) { + case H5I_GROUP: { + H5_GCC_DIAG_OFF("cast-qual") + path = H5G_nameof((H5G_t *)info->object); + H5_GCC_DIAG_ON("cast-qual") + break; + } + case H5I_DATASET: { + path = H5D_nameof((const H5D_t *)info->object); + break; + } + case H5I_DATATYPE: { + path = H5T_nameof((const H5T_t *)info->object); + break; + } + case H5I_UNINIT: + case H5I_BADID: + case H5I_FILE: + case H5I_DATASPACE: + case H5I_ATTR: + case H5I_REFERENCE: + case H5I_VFL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_NTYPES: + default: + break; /* Other types of IDs are not stored in files */ + } + + if (path) { + if (path->user_path_r) + HDfprintf(stderr, " user_path = %s\n", H5RS_get_str(path->user_path_r)); + if (path->full_path_r) + HDfprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r)); + } + + FUNC_LEAVE_NOAPI(H5_ITER_CONT) +} /* end H5I__id_dump_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5I_dump_ids_for_type + * + * Purpose: Dump the contents of a type to stderr for debugging. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5I_dump_ids_for_type(H5I_type_t type) +{ + H5I_type_info_t *type_info = NULL; + + FUNC_ENTER_NOAPI_NOERR + + HDfprintf(stderr, "Dumping ID type %d\n", (int)type); + type_info = H5I_type_info_array_g[type]; + + if (type_info) { + + H5I_id_info_t *item = NULL; + H5I_id_info_t *tmp = NULL; + + /* Header */ + HDfprintf(stderr, " init_count = %u\n", type_info->init_count); + HDfprintf(stderr, " reserved = %u\n", type_info->cls->reserved); + HDfprintf(stderr, " id_count = %llu\n", (unsigned long long)type_info->id_count); + HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_info->nextid); + + /* List */ + if (type_info->id_count > 0) { + HDfprintf(stderr, " List:\n"); + /* Normally we care about the callback's return value + * (H5I_ITER_CONT, etc.), but this is an iteration over all + * the IDs so we don't care. + * + * XXX: Update this to emit an error message on errors? + */ + HDfprintf(stderr, " (HASH TABLE)\n"); + HASH_ITER(hh, type_info->hash_table, item, tmp) + { + H5I__id_dump_cb((void *)item, NULL, (void *)&type); + } + } + } + else + HDfprintf(stderr, "Global type info/tracking pointer for that type is NULL\n"); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5I_dump_ids_for_type() */ diff --git a/src/H5Iint.c b/src/H5Iint.c new file mode 100644 index 00000000000..c1438b2858b --- /dev/null +++ b/src/H5Iint.c @@ -0,0 +1,1364 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * H5Iint.c - Private routines for handling IDs + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Imodule.h" /* This source code file is part of the H5I module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Ipkg.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Tprivate.h" /* Datatypes */ + +/****************/ +/* Local Macros */ +/****************/ + +/* Combine a Type number and an ID index into an ID */ +#define H5I_MAKE(g, i) ((((hid_t)(g)&TYPE_MASK) << ID_BITS) | ((hid_t)(i)&ID_MASK)) + +/******************/ +/* Local Typedefs */ +/******************/ + +/* User data for iterator callback for ID iteration */ +typedef struct { + H5I_search_func_t user_func; /* 'User' function to invoke */ + void * user_udata; /* User data to pass to 'user' function */ + hbool_t app_ref; /* Whether this is an appl. ref. call */ +} H5I_iterate_ud_t; + +/* User data for H5I__clear_type_cb */ +typedef struct { + H5I_type_info_t *type_info; /* Pointer to the type's info to be cleared */ + hbool_t force; /* Whether to always remove the ID */ + hbool_t app_ref; /* Whether this is an appl. ref. call */ +} H5I_clear_type_ud_t; + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +static herr_t H5I__mark_node(void *_id, void *key, void *udata); +static void * H5I__remove_common(H5I_type_info_t *type_info, hid_t id); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + +/* Declared extern in H5Ipkg.h and documented there */ +H5I_type_info_t *H5I_type_info_array_g[H5I_MAX_NUM_TYPES]; +int H5I_next_type_g = (int)H5I_NTYPES; + +/* Declare a free list to manage the H5I_id_info_t struct */ +H5FL_DEFINE_STATIC(H5I_id_info_t); + +/* Whether deletes are actually marks (for mark-and-sweep) */ +hbool_t H5I_marking_g = FALSE; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5I_term_package + * + * Purpose: Terminate the H5I interface: release all memory, reset all + * global variables to initial values. This only happens if all + * types have been destroyed from other interfaces. + * + * Return: Success: Positive if any action was taken that might + * affect some other interface; zero otherwise. + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +int +H5I_term_package(void) +{ + int in_use = 0; /* Number of ID types still in use */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if (H5_PKG_INIT_VAR) { + H5I_type_info_t *type_info = NULL; /* Pointer to ID type */ + int i; + + /* Count the number of types still in use */ + for (i = 0; i < H5I_next_type_g; i++) + if ((type_info = H5I_type_info_array_g[i]) && type_info->hash_table) + in_use++; + + /* If no types are still being used then clean up */ + if (0 == in_use) { + for (i = 0; i < H5I_next_type_g; i++) { + type_info = H5I_type_info_array_g[i]; + if (type_info) { + HDassert(NULL == type_info->hash_table); + type_info = H5MM_xfree(type_info); + H5I_type_info_array_g[i] = NULL; + in_use++; + } + } + + /* Mark interface closed */ + if (0 == in_use) + H5_PKG_INIT_VAR = FALSE; + } + } + + FUNC_LEAVE_NOAPI(in_use) +} /* end H5I_term_package() */ + +/*------------------------------------------------------------------------- + * Function: H5I_register_type + * + * Purpose: Creates a new type of ID's to give out. + * The class is initialized or its reference count is incremented + * (if it is already initialized). + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5I_register_type(const H5I_class_t *cls) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the ID type*/ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(cls); + HDassert(cls->type > 0 && (int)cls->type < H5I_MAX_NUM_TYPES); + + /* Initialize the type */ + if (NULL == H5I_type_info_array_g[cls->type]) { + /* Allocate the type information for new type */ + if (NULL == (type_info = (H5I_type_info_t *)H5MM_calloc(sizeof(H5I_type_info_t)))) + HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, FAIL, "ID type allocation failed") + H5I_type_info_array_g[cls->type] = type_info; + } + else { + /* Get the pointer to the existing type */ + type_info = H5I_type_info_array_g[cls->type]; + } + + /* Initialize the ID type structure for new types */ + if (type_info->init_count == 0) { + type_info->cls = cls; + type_info->id_count = 0; + type_info->nextid = cls->reserved; + type_info->last_id_info = NULL; + type_info->hash_table = NULL; + } + + /* Increment the count of the times this type has been initialized */ + type_info->init_count++; + +done: + /* Clean up on error */ + if (ret_value < 0) + if (type_info) + H5MM_free(type_info); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_register_type() */ + +/*------------------------------------------------------------------------- + * Function: H5I_nmembers + * + * Purpose: Returns the number of members in a type. + * + * Return: Success: Number of members; zero if the type is empty + * or has been deleted. + * + * Failure: Negative + * + * Programmer: Robb Matzke + * Wednesday, March 24, 1999 + * + *------------------------------------------------------------------------- + */ +int64_t +H5I_nmembers(H5I_type_t type) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the ID type */ + int64_t ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + /* Validate parameter */ + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + if (NULL == (type_info = H5I_type_info_array_g[type]) || type_info->init_count <= 0) + HGOTO_DONE(0); + + /* Set return value */ + H5_CHECKED_ASSIGN(ret_value, int64_t, type_info->id_count, uint64_t); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_nmembers() */ + +/*------------------------------------------------------------------------- + * Function: H5I_clear_type + * + * Purpose: Removes all objects from the type, calling the free + * function for each object regardless of the reference count. + * + * Return: SUCCEED/FAIL + * + * Programmer: Robb Matzke + * Wednesday, March 24, 1999 + * + *------------------------------------------------------------------------- + */ +herr_t +H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) +{ + H5I_clear_type_ud_t udata; /* udata struct for callback */ + H5I_id_info_t * item = NULL; + H5I_id_info_t * tmp = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Validate parameters */ + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + + udata.type_info = H5I_type_info_array_g[type]; + if (udata.type_info == NULL || udata.type_info->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + + /* Finish constructing udata */ + udata.force = force; + udata.app_ref = app_ref; + + /* Clearing a type is done in two phases (mark-and-sweep). This is because + * the type's free callback can free other IDs, potentially corrupting + * the data structure during the traversal. + */ + + /* Set marking flag */ + H5I_marking_g = TRUE; + + /* Mark nodes for deletion */ + HASH_ITER(hh, udata.type_info->hash_table, item, tmp) + { + if (!item->marked) + if (H5I__mark_node((void *)item, NULL, (void *)&udata) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed while clearing the ID type") + } + + /* Unset marking flag */ + H5I_marking_g = FALSE; + + /* Perform sweep */ + HASH_ITER(hh, udata.type_info->hash_table, item, tmp) + { + if (item->marked) { + HASH_DELETE(hh, udata.type_info->hash_table, item); + item = H5FL_FREE(H5I_id_info_t, item); + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_clear_type() */ + +/*------------------------------------------------------------------------- + * Function: H5I__mark_node + * + * Purpose: Attempts to mark the node for freeing and calls the free + * function for the object, if any + * + * Return: SUCCEED/FAIL + * + * Programmer: Neil Fortner + * Friday, July 10, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5I__mark_node(void *_info, void H5_ATTR_UNUSED *key, void *_udata) +{ + H5I_id_info_t * info = (H5I_id_info_t *)_info; /* Current ID info being worked with */ + H5I_clear_type_ud_t *udata = (H5I_clear_type_ud_t *)_udata; /* udata struct */ + hbool_t mark = FALSE; + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(info); + HDassert(udata); + HDassert(udata->type_info); + + /* Do nothing to the object if the reference count is larger than + * one and forcing is off. + */ + if (udata->force || (info->count - (!udata->app_ref * info->app_count)) <= 1) { + /* Check for a 'free' function and call it, if it exists */ + H5_GCC_DIAG_OFF("cast-qual") + if (udata->type_info->cls->free_func && + (udata->type_info->cls->free_func)((void *)info->object) < 0) { + if (udata->force) { +#ifdef H5I_DEBUG + if (H5DEBUG(I)) { + HDfprintf(H5DEBUG(I), + "H5I: free type=%d obj=0x%08lx " + "failure ignored\n", + (int)udata->type_info->cls->type, (unsigned long)(info->object)); + } +#endif /* H5I_DEBUG */ + + /* Indicate node should be removed from list */ + mark = TRUE; + } + } + else { + /* Indicate node should be removed from list */ + mark = TRUE; + } + H5_GCC_DIAG_ON("cast-qual") + + /* Remove ID if requested */ + if (mark) { + /* Mark ID for deletion */ + info->marked = TRUE; + + /* Decrement the number of IDs in the type */ + udata->type_info->id_count--; + } + } + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5I__mark_node() */ + +/*------------------------------------------------------------------------- + * Function: H5I__destroy_type + * + * Purpose: Destroys a type along with all IDs in that type + * regardless of their reference counts. Destroying IDs + * involves calling the free-func for each ID's object and + * then adding the ID struct to the ID free list. + * + * Return: SUCCEED/FAIL + * + * Programmer: Nathaniel Furrer + * James Laird + * + *------------------------------------------------------------------------- + */ +herr_t +H5I__destroy_type(H5I_type_t type) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the ID type */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Validate parameter */ + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + + type_info = H5I_type_info_array_g[type]; + if (type_info == NULL || type_info->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + + /* Close/clear/destroy all IDs for this type */ + H5E_BEGIN_TRY + { + H5I_clear_type(type, TRUE, FALSE); + } + H5E_END_TRY /* don't care about errors */ + + /* Check if we should release the ID class */ + if (type_info->cls->flags & H5I_CLASS_IS_APPLICATION) + type_info->cls = H5MM_xfree_const(type_info->cls); + + HASH_CLEAR(hh, type_info->hash_table); + type_info->hash_table = NULL; + + type_info = H5MM_xfree(type_info); + + H5I_type_info_array_g[type] = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__destroy_type() */ + +/*------------------------------------------------------------------------- + * Function: H5I_register + * + * Purpose: Registers an OBJECT in a TYPE and returns an ID for it. + * This routine does _not_ check for unique-ness of the objects, + * if you register an object twice, you will get two different + * IDs for it. This routine does make certain that each ID in a + * type is unique. IDs are created by getting a unique number + * for the type the ID is in and incorporating the type into + * the ID which is returned to the user. + * + * Return: Success: New object ID + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the type */ + H5I_id_info_t * info = NULL; /* Pointer to the new ID information */ + hid_t new_id = H5I_INVALID_HID; /* New ID */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Check arguments */ + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "invalid type number") + type_info = H5I_type_info_array_g[type]; + if ((NULL == type_info) || (type_info->init_count <= 0)) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, H5I_INVALID_HID, "invalid type") + if (NULL == (info = H5FL_CALLOC(H5I_id_info_t))) + HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") + + /* Create the struct & its ID */ + new_id = H5I_MAKE(type, type_info->nextid); + info->id = new_id; + info->count = 1; /* initial reference count */ + info->app_count = !!app_ref; + info->object = object; + info->marked = FALSE; + + /* Insert into the type */ + HASH_ADD(hh, type_info->hash_table, id, sizeof(hid_t), info); + type_info->id_count++; + type_info->nextid++; + + /* Sanity check for the 'nextid' getting too large and wrapping around */ + HDassert(type_info->nextid <= ID_MASK); + + /* Set the most recent ID to this object */ + type_info->last_id_info = info; + + /* Set return value */ + ret_value = new_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_register() */ + +/*------------------------------------------------------------------------- + * Function: H5I_register_using_existing_id + * + * Purpose: Registers an OBJECT in a TYPE with the supplied ID for it. + * This routine will check to ensure the supplied ID is not already + * in use, and ensure that it is a valid ID for the given type, + * but will NOT check to ensure the OBJECT is not already + * registered (thus, it is possible to register one object under + * multiple IDs). + * + * NOTE: Intended for use in refresh calls, where we have to close + * and re-open the underlying data, then hook the object back + * up to the original ID. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, hid_t existing_id) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the type */ + H5I_id_info_t * info = NULL; /* Pointer to the new ID information */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ + HDassert(object); + + /* Make sure ID is not already in use */ + if (NULL != (info = H5I__find_id(existing_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use") + + /* Make sure type number is valid */ + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + + /* Get type pointer from list of types */ + type_info = H5I_type_info_array_g[type]; + + if (NULL == type_info || type_info->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + + /* Make sure requested ID belongs to object's type */ + if (H5I_TYPE(existing_id) != type) + HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "invalid type for provided ID") + + /* Allocate new structure to house this ID */ + if (NULL == (info = H5FL_CALLOC(H5I_id_info_t))) + HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Create the struct & insert requested ID */ + info->id = existing_id; + info->count = 1; /* initial reference count*/ + info->app_count = !!app_ref; + info->object = object; + info->marked = FALSE; + + /* Insert into the type */ + HASH_ADD(hh, type_info->hash_table, id, sizeof(hid_t), info); + type_info->id_count++; + + /* Set the most recent ID to this object */ + type_info->last_id_info = info; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_register_using_existing_id() */ + +/*------------------------------------------------------------------------- + * Function: H5I_subst + * + * Purpose: Substitute a new object pointer for the specified ID. + * + * Return: Success: Non-NULL previous object pointer associated + * with the specified ID. + * Failure: NULL + * + * Programmer: Quincey Koziol + * Saturday, February 27, 2010 + * + *------------------------------------------------------------------------- + */ +void * +H5I_subst(hid_t id, const void *new_object) +{ + H5I_id_info_t *info = NULL; /* Pointer to the ID's info */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* General lookup of the ID */ + if (NULL == (info = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_NOTFOUND, NULL, "can't get ID ref count") + + /* Get the old object pointer to return */ + H5_GCC_DIAG_OFF("cast-qual") + ret_value = (void *)info->object; + H5_GCC_DIAG_ON("cast-qual") + + /* Set the new object pointer for the ID */ + info->object = new_object; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_subst() */ + +/*------------------------------------------------------------------------- + * Function: H5I_object + * + * Purpose: Find an object pointer for the specified ID. + * + * Return: Success: Non-NULL object pointer associated with the + * specified ID + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5I_object(hid_t id) +{ + H5I_id_info_t *info = NULL; /* Pointer to the ID info */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOERR + + /* General lookup of the ID */ + if (NULL != (info = H5I__find_id(id))) { + /* Get the object pointer to return */ + H5_GCC_DIAG_OFF("cast-qual") + ret_value = (void *)info->object; + H5_GCC_DIAG_ON("cast-qual") + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_object() */ + +/*------------------------------------------------------------------------- + * Function: H5I_object_verify + * + * Purpose: Find an object pointer for the specified ID, verifying that + * its in a particular type. + * + * Return: Success: Non-NULL object pointer associated with the + * specified ID. + * Failure: NULL + * + * Programmer: Quincey Koziol + * Wednesday, July 31, 2002 + * + *------------------------------------------------------------------------- + */ +void * +H5I_object_verify(hid_t id, H5I_type_t type) +{ + H5I_id_info_t *info = NULL; /* Pointer to the ID info */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOERR + + HDassert(type >= 1 && (int)type < H5I_next_type_g); + + /* Verify that the type of the ID is correct & lookup the ID */ + if (type == H5I_TYPE(id) && NULL != (info = H5I__find_id(id))) { + /* Get the object pointer to return */ + H5_GCC_DIAG_OFF("cast-qual") + ret_value = (void *)info->object; + H5_GCC_DIAG_ON("cast-qual") + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5I_object_verify() */ + +/*------------------------------------------------------------------------- + * Function: H5I_get_type + * + * Purpose: Given an object ID return the type to which it + * belongs. The ID need not be the ID of an object which + * currently exists because the type number is encoded + * in the object ID. + * + * Return: Success: A positive integer (corresponding to an H5I_type_t + * enum value for library ID types, but not for user + * ID types). + * Failure: H5I_BADID + * + * Programmer: Robb Matzke + * Friday, February 19, 1999 + * + *------------------------------------------------------------------------- + */ +H5I_type_t +H5I_get_type(hid_t id) +{ + H5I_type_t ret_value = H5I_BADID; /* Return value */ + + FUNC_ENTER_NOAPI_NOERR + + if (id > 0) + ret_value = H5I_TYPE(id); + + HDassert(ret_value >= H5I_BADID && (int)ret_value < H5I_next_type_g); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_get_type() */ + +/*------------------------------------------------------------------------- + * Function: H5I__remove_verify + * + * Purpose: Removes the specified ID from its type, first checking that + * the ID's type is the same as the ID type supplied as an argument + * + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL + * + * Programmer: James Laird + * Nat Furrer + * + *------------------------------------------------------------------------- + */ +void * +H5I__remove_verify(hid_t id, H5I_type_t type) +{ + void *ret_value = NULL; /*return value */ + + FUNC_ENTER_PACKAGE_NOERR + + /* Argument checking will be performed by H5I_remove() */ + + /* Verify that the type of the ID is correct */ + if (type == H5I_TYPE(id)) + ret_value = H5I_remove(id); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__remove_verify() */ + +/*------------------------------------------------------------------------- + * Function: H5I__remove_common + * + * Purpose: Common code to remove a specified ID from its type. + * + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL + * + * Programmer: Quincey Koziol + * October 3, 2013 + * + *------------------------------------------------------------------------- + */ +static void * +H5I__remove_common(H5I_type_info_t *type_info, hid_t id) +{ + H5I_id_info_t *info = NULL; /* Pointer to the current ID */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(type_info); + + /* Delete or mark the node */ + HASH_FIND(hh, type_info->hash_table, &id, sizeof(hid_t), info); + if (info) { + HDassert(!info->marked); + if (!H5I_marking_g) + HASH_DELETE(hh, type_info->hash_table, info); + else + info->marked = TRUE; + } + else + HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node from hash table") + + /* Check if this ID was the last one accessed */ + if (type_info->last_id_info == info) + type_info->last_id_info = NULL; + + H5_GCC_DIAG_OFF("cast-qual") + ret_value = (void *)info->object; + H5_GCC_DIAG_ON("cast-qual") + + if (!H5I_marking_g) + info = H5FL_FREE(H5I_id_info_t, info); + + /* Decrement the number of IDs in the type */ + (type_info->id_count)--; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__remove_common() */ + +/*------------------------------------------------------------------------- + * Function: H5I_remove + * + * Purpose: Removes the specified ID from its type. + * + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5I_remove(hid_t id) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the ID type */ + H5I_type_t type = H5I_BADID; /* ID's type */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ + type = H5I_TYPE(id); + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid type number") + type_info = H5I_type_info_array_g[type]; + if (type_info == NULL || type_info->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid type") + + /* Remove the node from the type */ + if (NULL == (ret_value = H5I__remove_common(type_info, id))) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_remove() */ + +/*------------------------------------------------------------------------- + * Function: H5I_dec_ref + * + * Purpose: Decrements the number of references outstanding for an ID. + * This will fail if the type is not a reference counted type. + * The ID type's 'free' function will be called for the ID + * if the reference count for the ID reaches 0 and a free + * function has been defined at type creation time. + * + * Return: Success: New reference count + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +H5I_dec_ref(hid_t id) +{ + H5I_id_info_t *info = NULL; /* Pointer to the ID */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + /* Sanity check */ + HDassert(id >= 0); + + /* General lookup of the ID */ + if (NULL == (info = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") + + /* If this is the last reference to the object then invoke the type's + * free method on the object. If the free method is undefined or + * successful then remove the object from the type; otherwise leave + * the object in the type without decrementing the reference + * count. If the reference count is more than one then decrement the + * reference count without calling the free method. + * + * Beware: the free method may call other H5I functions. + * + * If an object is closing, we can remove the ID even though the free + * method might fail. This can happen when a mandatory filter fails to + * write when a dataset is closed and the chunk cache is flushed to the + * file. We have to close the dataset anyway. (SLU - 2010/9/7) + */ + if (1 == info->count) { + H5I_type_info_t *type_info; /*ptr to the type */ + + /* Get the ID's type */ + type_info = H5I_type_info_array_g[H5I_TYPE(id)]; + + H5_GCC_DIAG_OFF("cast-qual") + /* (Casting away const OK -QAK) */ + if (!type_info->cls->free_func || (type_info->cls->free_func)((void *)info->object) >= 0) { + /* Remove the node from the type */ + if (NULL == H5I__remove_common(type_info, id)) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, (-1), "can't remove ID node") + ret_value = 0; + } /* end if */ + else + ret_value = -1; + H5_GCC_DIAG_ON("cast-qual") + } /* end if */ + else { + --(info->count); + ret_value = (int)info->count; + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_dec_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I_dec_app_ref + * + * Purpose: Wrapper for case of modifying the application ref. + * count for an ID as well as normal reference count. + * + * Return: Success: New app. reference count + * Failure: -1 + * + * Programmer: Quincey Koziol + * Sept 16, 2010 + * + *------------------------------------------------------------------------- + */ +int +H5I_dec_app_ref(hid_t id) +{ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + /* Sanity check */ + HDassert(id >= 0); + + /* Call regular decrement reference count routine */ + if ((ret_value = H5I_dec_ref(id)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") + + /* Check if the ID still exists */ + if (ret_value > 0) { + H5I_id_info_t *info = NULL; /* Pointer to the ID info */ + + /* General lookup of the ID */ + if (NULL == (info = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") + + /* Adjust app_ref */ + --(info->app_count); + HDassert(info->count >= info->app_count); + + /* Set return value */ + ret_value = (int)info->app_count; + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_dec_app_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I_dec_app_ref_always_close + * + * Purpose: Wrapper for case of always closing the ID, even when the free + * routine fails + * + * Return: Success: New app. reference count + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +H5I_dec_app_ref_always_close(hid_t id) +{ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + /* Sanity check */ + HDassert(id >= 0); + + /* Call application decrement reference count routine */ + ret_value = H5I_dec_app_ref(id); + + /* Check for failure */ + if (ret_value < 0) { + /* + * If an object is closing, we can remove the ID even though the free + * method might fail. This can happen when a mandatory filter fails to + * write when a dataset is closed and the chunk cache is flushed to the + * file. We have to close the dataset anyway. (SLU - 2010/9/7) + */ + H5I_remove(id); + + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_dec_app_ref_always_close() */ + +/*------------------------------------------------------------------------- + * Function: H5I_inc_ref + * + * Purpose: Increment the reference count for an object. + * + * Return: Success: The new reference count + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +H5I_inc_ref(hid_t id, hbool_t app_ref) +{ + H5I_id_info_t *info = NULL; /* Pointer to the ID info */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + /* Sanity check */ + HDassert(id >= 0); + + /* General lookup of the ID */ + if (NULL == (info = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") + + /* Adjust reference counts */ + ++(info->count); + if (app_ref) + ++(info->app_count); + + /* Set return value */ + ret_value = (int)(app_ref ? info->app_count : info->count); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_inc_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I_get_ref + * + * Purpose: Retrieve the reference count for an object. + * + * Return: Success: The reference count + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +H5I_get_ref(hid_t id, hbool_t app_ref) +{ + H5I_id_info_t *info = NULL; /* Pointer to the ID */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + /* Sanity check */ + HDassert(id >= 0); + + /* General lookup of the ID */ + if (NULL == (info = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") + + /* Set return value */ + ret_value = (int)(app_ref ? info->app_count : info->count); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_get_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I__inc_type_ref + * + * Purpose: Increment the reference count for an ID type. + * + * Return: Success: The new reference count + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +H5I__inc_type_ref(H5I_type_t type) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the type */ + int ret_value = -1; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(type > 0 && (int)type < H5I_next_type_g); + + /* Check arguments */ + type_info = H5I_type_info_array_g[type]; + if (NULL == type_info) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") + + /* Set return value */ + ret_value = (int)(++(type_info->init_count)); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__inc_type_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I_dec_type_ref + * + * Purpose: Decrements the reference count on an entire type of IDs. + * If the type reference count becomes zero then the type is + * destroyed along with all IDs in that type regardless of + * their reference counts. Destroying IDs involves calling + * the free-func for each ID's object and then adding the ID + * struct to the ID free list. + * Returns the number of references to the type on success; a + * return value of 0 means that the type will have to be + * re-initialized before it can be used again (and should probably + * be set to H5I_UNINIT). + * + * Return: Success: Number of references to type + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +H5I_dec_type_ref(H5I_type_t type) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the ID type */ + herr_t ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "invalid type number") + + type_info = H5I_type_info_array_g[type]; + if (type_info == NULL || type_info->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") + + /* Decrement the number of users of the ID type. If this is the + * last user of the type then release all IDs from the type and + * free all memory it used. The free function is invoked for each ID + * being freed. + */ + if (1 == type_info->init_count) { + H5I__destroy_type(type); + ret_value = 0; + } + else { + --(type_info->init_count); + ret_value = (herr_t)type_info->init_count; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_dec_type_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I__get_type_ref + * + * Purpose: Retrieve the reference count for an ID type. + * + * Return: Success: The reference count + * + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +H5I__get_type_ref(H5I_type_t type) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the type */ + int ret_value = -1; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(type >= 0); + + /* Check arguments */ + type_info = H5I_type_info_array_g[type]; + if (!type_info) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") + + /* Set return value */ + ret_value = (int)type_info->init_count; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__get_type_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I__iterate_cb + * + * Purpose: Callback routine for H5I_iterate, invokes "user" callback + * function, and then sets return value, based on the result of + * that callback. + * + * Return: Success: H5_ITER_CONT (0) or H5_ITER_STOP (1) + * Failure: H5_ITER_ERROR (-1) + * + *------------------------------------------------------------------------- + */ +static int +H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) +{ + H5I_id_info_t * info = (H5I_id_info_t *)_item; /* Pointer to the ID info */ + H5I_iterate_ud_t *udata = (H5I_iterate_ud_t *)_udata; /* User data for callback */ + int ret_value = H5_ITER_CONT; /* Callback return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Only invoke the callback function if this ID is visible externally and + * its reference count is positive. + */ + if ((!udata->app_ref) || (info->app_count > 0)) { + herr_t cb_ret_val; + + /* Invoke callback function */ + H5_GCC_DIAG_OFF("cast-qual") + cb_ret_val = (*udata->user_func)((void *)info->object, info->id, udata->user_udata); + H5_GCC_DIAG_ON("cast-qual") + + /* Set the return value based on the callback's return value */ + if (cb_ret_val > 0) + ret_value = H5_ITER_STOP; /* terminate iteration early */ + else if (cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__iterate_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5I_iterate + * + * Purpose: Apply function FUNC to each member of type TYPE (with + * non-zero application reference count if app_ref is TRUE). + * Stop if FUNC returns a non zero value (i.e. anything + * other than H5_ITER_CONT). + * + * If FUNC returns a positive value (i.e. H5_ITER_STOP), + * return SUCCEED. + * + * If FUNC returns a negative value (i.e. H5_ITER_ERROR), + * return FAIL. + * + * The FUNC should take a pointer to the object and the + * udata as arguments and return non-zero to terminate + * siteration, and zero to continue. + * + * Limitation: Currently there is no way to start the iteration from + * where a previous iteration left off. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the type */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + type_info = H5I_type_info_array_g[type]; + + /* Only iterate through ID list if it is initialized and there are IDs in type */ + if (type_info && type_info->init_count > 0 && type_info->id_count > 0) { + H5I_iterate_ud_t iter_udata; /* User data for iteration callback */ + H5I_id_info_t * item = NULL; + H5I_id_info_t * tmp = NULL; + + /* Set up iterator user data */ + iter_udata.user_func = func; + iter_udata.user_udata = udata; + iter_udata.app_ref = app_ref; + + /* Iterate over IDs */ + HASH_ITER(hh, type_info->hash_table, item, tmp) + { + if (!item->marked) { + int ret = H5I__iterate_cb((void *)item, NULL, (void *)&iter_udata); + if (H5_ITER_ERROR == ret) + HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") + if (H5_ITER_STOP == ret) + break; + } + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_iterate() */ + +/*------------------------------------------------------------------------- + * Function: H5I__find_id + * + * Purpose: Given an object ID find the info struct that describes the + * object. + * + * Return: Success: A pointer to the object's info struct. + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5I_id_info_t * +H5I__find_id(hid_t id) +{ + H5I_type_t type; /* ID's type */ + H5I_type_info_t *type_info = NULL; /* Pointer to the type */ + H5I_id_info_t * id_info = NULL; /* ID's info */ + H5I_id_info_t * ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE_NOERR + + /* Check arguments */ + type = H5I_TYPE(id); + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_DONE(NULL) + type_info = H5I_type_info_array_g[type]; + if (!type_info || type_info->init_count <= 0) + HGOTO_DONE(NULL) + + /* Check for same ID as we have looked up last time */ + if (type_info->last_id_info && type_info->last_id_info->id == id) + id_info = type_info->last_id_info; + else { + HASH_FIND(hh, type_info->hash_table, &id, sizeof(hid_t), id_info); + + /* Remember this ID */ + type_info->last_id_info = id_info; + } + + /* Set return value */ + ret_value = id_info; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__find_id() */ + +/*------------------------------------------------------------------------- + * Function: H5I_get_file_id + * + * Purpose: The private version of H5Iget_file_id(), obtains the file + * ID given an object ID. + * + * Return: Success: The file ID associated with the object + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5I_get_file_id(hid_t obj_id, H5I_type_t type) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Process based on object type */ + if (type == H5I_FILE) { + /* Increment reference count on file ID */ + if (H5I_inc_ref(obj_id, TRUE) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") + + /* Set return value */ + ret_value = obj_id; + } + else { + H5G_loc_t loc; /* Location of object */ + + /* Get the object location information */ + if (H5G_loc(obj_id, &loc) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get object location") + + /* Get the file ID for the object */ + if ((ret_value = H5F_get_id(loc.oloc->file, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get file ID") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_get_file_id() */ diff --git a/src/H5Ipkg.h b/src/H5Ipkg.h index 425308f773e..1bcea26cb51 100644 --- a/src/H5Ipkg.h +++ b/src/H5Ipkg.h @@ -29,14 +29,21 @@ /* Get package's private header */ #include "H5Iprivate.h" -/* Other private headers needed by this file */ +/* uthash is an external, header-only hash table implementation. + * + * We include the file directly in src/ and #define a few functions + * to use our internal memory calls. + */ +#define uthash_malloc(sz) H5MM_malloc(sz) +#define uthash_free(ptr, sz) H5MM_free(ptr) /* Ignoring sz is intentional */ +#include "uthash.h" /**************************/ /* Package Private Macros */ /**************************/ /* - * Number of bits to use for ID Type in each atom. Increase if more types + * Number of bits to use for ID Type in each ID. Increase if more types * are needed (though this will decrease the number of available IDs per * type). This is the only number that must be changed since all other bit * field sizes and masks are calculated from TYPE_BITS. @@ -47,23 +54,67 @@ #define H5I_MAX_NUM_TYPES TYPE_MASK /* - * Number of bits to use for the Atom index in each atom (assumes 8-bit + * Number of bits to use for the ID index in each ID (assumes 8-bit * bytes). We don't use the sign bit. */ #define ID_BITS ((sizeof(hid_t) * 8) - (TYPE_BITS + 1)) #define ID_MASK (((hid_t)1 << ID_BITS) - 1) -/* Map an atom to an ID type number */ +/* Map an ID to an ID type number */ #define H5I_TYPE(a) ((H5I_type_t)(((hid_t)(a) >> ID_BITS) & TYPE_MASK)) /****************************/ /* Package Private Typedefs */ /****************************/ +/* ID information structure used */ +typedef struct H5I_id_info_t { + hid_t id; /* ID for this info */ + unsigned count; /* Ref. count for this ID */ + unsigned app_count; /* Ref. count of application visible IDs */ + const void *object; /* Pointer associated with the ID */ + + /* Hash table ID fields */ + hbool_t marked; /* Marked for deletion */ + UT_hash_handle hh; /* Hash table handle (must be LAST) */ +} H5I_id_info_t; + +/* Type information structure used */ +typedef struct H5I_type_info_t { + const H5I_class_t *cls; /* Pointer to ID class */ + unsigned init_count; /* # of times this type has been initialized */ + uint64_t id_count; /* Current number of IDs held */ + uint64_t nextid; /* ID to use for the next object */ + H5I_id_info_t * last_id_info; /* Info for most recent ID looked up */ + H5I_id_info_t * hash_table; /* Hash table pointer for this ID type */ +} H5I_type_info_t; + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + +/* Array of pointers to ID types */ +H5_DLLVAR H5I_type_info_t *H5I_type_info_array_g[H5I_MAX_NUM_TYPES]; + +/* Variable to keep track of the number of types allocated. Its value is the + * next type ID to be handed out, so it is always one greater than the number + * of types. + * Starts at 1 instead of 0 because it makes trace output look nicer. If more + * types (or IDs within a type) are needed, adjust TYPE_BITS in H5Ipkg.h + * and/or increase size of hid_t + */ +H5_DLLVAR int H5I_next_type_g; + /******************************/ /* Package Private Prototypes */ /******************************/ +H5_DLL int H5I__destroy_type(H5I_type_t type); +H5_DLL void *H5I__remove_verify(hid_t id, H5I_type_t type); +H5_DLL int H5I__inc_type_ref(H5I_type_t type); +H5_DLL int H5I__get_type_ref(H5I_type_t type); +H5_DLL H5I_id_info_t *H5I__find_id(hid_t id); + /* Testing functions */ #ifdef H5I_TESTING H5_DLL ssize_t H5I__get_name_test(hid_t id, char *name /*out*/, size_t size, hbool_t *cached); diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 6e8bacd8eb9..9afcb4930f3 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -41,7 +41,7 @@ /****************************/ typedef struct H5I_class_t { - H5I_type_t type_id; /* Class ID for the type */ + H5I_type_t type; /* Class "value" for the type */ unsigned flags; /* Class behavior flags */ unsigned reserved; /* Number of reserved IDs for this type */ /* [A specific number of type entries may be @@ -71,11 +71,11 @@ H5_DLL int H5I_dec_ref(hid_t id); H5_DLL int H5I_dec_app_ref(hid_t id); H5_DLL int H5I_dec_app_ref_always_close(hid_t id); H5_DLL int H5I_dec_type_ref(H5I_type_t type); -H5_DLL hid_t H5I_get_file_id(hid_t obj_id, H5I_type_t id_type); +H5_DLL hid_t H5I_get_file_id(hid_t obj_id, H5I_type_t type); /* Functions that manipulate objects */ H5_DLL void *H5I_object(hid_t id); -H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type); +H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t type); H5_DLL void *H5I_remove(hid_t id); H5_DLL void *H5I_subst(hid_t id, const void *new_object); diff --git a/src/H5Itest.c b/src/H5Itest.c index 8458557ab01..19a2e03f045 100644 --- a/src/H5Itest.c +++ b/src/H5Itest.c @@ -11,10 +11,8 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol - * Tuesday, July 27, 2010 - * - * Purpose: ID testing functions. +/* + * H5Itest.c - ID testing functions */ /****************/ @@ -28,7 +26,6 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ #include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ #include "H5Gprivate.h" /* Groups */ diff --git a/src/H5public.h b/src/H5public.h index 888dc3199be..470f8b8b953 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -107,11 +107,11 @@ extern "C" { /** * For pre-releases like \c snap0. Empty string for official releases. */ -#define H5_VERS_SUBRELEASE "1" +#define H5_VERS_SUBRELEASE "2" /** * Full version string */ -#define H5_VERS_INFO "HDF5 library version: 1.10.8-1" +#define H5_VERS_INFO "HDF5 library version: 1.10.8-2" #define H5check() H5check_version(H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE) diff --git a/src/Makefile.am b/src/Makefile.am index 1d426b2fd1e..75e04616429 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -79,7 +79,9 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5HFspace.c H5HFstat.c H5HFtest.c H5HFtiny.c \ H5HG.c H5HGcache.c H5HGdbg.c H5HGquery.c \ H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c H5HLprfx.c H5HLdblk.c\ - H5HP.c H5I.c H5Itest.c H5L.c H5Lexternal.c H5lib_settings.c \ + H5HP.c \ + H5I.c H5Idbg.c H5Iint.c H5Itest.c \ + H5L.c H5Lexternal.c H5lib_settings.c \ H5MF.c H5MFaggr.c H5MFdbg.c H5MFsection.c \ H5MM.c H5MP.c H5MPtest.c \ H5O.c H5Odeprec.c H5Oainfo.c H5Oalloc.c H5Oattr.c \ diff --git a/src/uthash.h b/src/uthash.h new file mode 100644 index 00000000000..8bdca557f7f --- /dev/null +++ b/src/uthash.h @@ -0,0 +1,1184 @@ +/* +Copyright (c) 2003-2018, Troy D. Hanson http://troydhanson.github.com/uthash/ +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef UTHASH_H +#define UTHASH_H + +#define UTHASH_VERSION 2.1.0 + +#include /* memcmp, memset, strlen */ +#include /* ptrdiff_t */ +#include /* exit */ + +/* These macros use decltype or the earlier __typeof GNU extension. + As decltype is only available in newer compilers (VS2010 or gcc 4.3+ + when compiling c++ source) this code uses whatever method is needed + or, for VS2008 where neither is available, uses casting workarounds. */ +#if !defined(DECLTYPE) && !defined(NO_DECLTYPE) +#if defined(_MSC_VER) /* MS compiler */ +#if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */ +#define DECLTYPE(x) (decltype(x)) +#else /* VS2008 or older (or VS2010 in C mode) */ +#define NO_DECLTYPE +#endif +#elif defined(__BORLANDC__) || defined(__ICCARM__) || defined(__LCC__) || defined(__WATCOMC__) +#define NO_DECLTYPE +#else /* GNU, Sun and other compilers */ +#define DECLTYPE(x) (__typeof(x)) +#endif +#endif + +#ifdef NO_DECLTYPE +#define DECLTYPE(x) +#define DECLTYPE_ASSIGN(dst, src) \ + do { \ + char **_da_dst = (char **)(&(dst)); \ + *_da_dst = (char *)(src); \ + } while (0) +#else +#define DECLTYPE_ASSIGN(dst, src) \ + do { \ + (dst) = DECLTYPE(dst)(src); \ + } while (0) +#endif + +/* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */ +#if defined(_WIN32) +#if defined(_MSC_VER) && _MSC_VER >= 1600 +#include +#elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__) +#include +#else +typedef unsigned int uint32_t; +typedef unsigned char uint8_t; +#endif +#elif defined(__GNUC__) && !defined(__VXWORKS__) +#include +#else +typedef unsigned int uint32_t; +typedef unsigned char uint8_t; +#endif + +#ifndef uthash_malloc +#define uthash_malloc(sz) malloc(sz) /* malloc fcn */ +#endif +#ifndef uthash_free +#define uthash_free(ptr, sz) free(ptr) /* free fcn */ +#endif +#ifndef uthash_bzero +#define uthash_bzero(a, n) memset(a, '\0', n) +#endif +#ifndef uthash_strlen +#define uthash_strlen(s) strlen(s) +#endif + +#ifdef uthash_memcmp +/* This warning will not catch programs that define uthash_memcmp AFTER including uthash.h. */ +#warning "uthash_memcmp is deprecated; please use HASH_KEYCMP instead" +#else +#define uthash_memcmp(a, b, n) memcmp(a, b, n) +#endif + +#ifndef HASH_KEYCMP +#define HASH_KEYCMP(a, b, n) uthash_memcmp(a, b, n) +#endif + +#ifndef uthash_noexpand_fyi +#define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */ +#endif +#ifndef uthash_expand_fyi +#define uthash_expand_fyi(tbl) /* can be defined to log expands */ +#endif + +#ifndef HASH_NONFATAL_OOM +#define HASH_NONFATAL_OOM 0 +#endif + +#if HASH_NONFATAL_OOM +/* malloc failures can be recovered from */ + +#ifndef uthash_nonfatal_oom +#define uthash_nonfatal_oom(obj) \ + do { \ + } while (0) /* non-fatal OOM error */ +#endif + +#define HASH_RECORD_OOM(oomed) \ + do { \ + (oomed) = 1; \ + } while (0) +#define IF_HASH_NONFATAL_OOM(x) x + +#else +/* malloc failures result in lost memory, hash tables are unusable */ + +#ifndef uthash_fatal +#define uthash_fatal(msg) exit(-1) /* fatal OOM error */ +#endif + +#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory") +#define IF_HASH_NONFATAL_OOM(x) + +#endif + +/* initial number of buckets */ +#define HASH_INITIAL_NUM_BUCKETS 32U /* initial number of buckets */ +#define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */ +#define HASH_BKT_CAPACITY_THRESH 10U /* expand when bucket count reaches */ + +/* calculate the element whose hash handle address is hhp */ +#define ELMT_FROM_HH(tbl, hhp) ((void *)(((char *)(hhp)) - ((tbl)->hho))) +/* calculate the hash handle from element address elp */ +#define HH_FROM_ELMT(tbl, elp) ((UT_hash_handle *)(void *)(((char *)(elp)) + ((tbl)->hho))) + +#define HASH_ROLLBACK_BKT(hh, head, itemptrhh) \ + do { \ + struct UT_hash_handle *_hd_hh_item = (itemptrhh); \ + unsigned _hd_bkt; \ + HASH_TO_BKT(_hd_hh_item->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ + (head)->hh.tbl->buckets[_hd_bkt].count++; \ + _hd_hh_item->hh_next = NULL; \ + _hd_hh_item->hh_prev = NULL; \ + } while (0) + +#define HASH_VALUE(keyptr, keylen, hashv) \ + do { \ + HASH_FCN(keyptr, keylen, hashv); \ + } while (0) + +#define HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, hashval, out) \ + do { \ + (out) = NULL; \ + if (head) { \ + unsigned _hf_bkt; \ + HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _hf_bkt); \ + if (HASH_BLOOM_TEST((head)->hh.tbl, hashval) != 0) { \ + HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[_hf_bkt], keyptr, keylen, \ + hashval, out); \ + } \ + } \ + } while (0) + +#define HASH_FIND(hh, head, keyptr, keylen, out) \ + do { \ + (out) = NULL; \ + if (head) { \ + unsigned _hf_hashv; \ + HASH_VALUE(keyptr, keylen, _hf_hashv); \ + HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \ + } \ + } while (0) + +#ifdef HASH_BLOOM +#define HASH_BLOOM_BITLEN (1UL << HASH_BLOOM) +#define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN / 8UL) + (((HASH_BLOOM_BITLEN % 8UL) != 0UL) ? 1UL : 0UL) +#define HASH_BLOOM_MAKE(tbl, oomed) \ + do { \ + (tbl)->bloom_nbits = HASH_BLOOM; \ + (tbl)->bloom_bv = (uint8_t *)uthash_malloc(HASH_BLOOM_BYTELEN); \ + if (!(tbl)->bloom_bv) { \ + HASH_RECORD_OOM(oomed); \ + } \ + else { \ + uthash_bzero((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ + (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ + } \ + } while (0) + +#define HASH_BLOOM_FREE(tbl) \ + do { \ + uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ + } while (0) + +#define HASH_BLOOM_BITSET(bv, idx) (bv[(idx) / 8U] |= (1U << ((idx) % 8U))) +#define HASH_BLOOM_BITTEST(bv, idx) (bv[(idx) / 8U] & (1U << ((idx) % 8U))) + +#define HASH_BLOOM_ADD(tbl, hashv) \ + HASH_BLOOM_BITSET((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) + +#define HASH_BLOOM_TEST(tbl, hashv) \ + HASH_BLOOM_BITTEST((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) + +#else +#define HASH_BLOOM_MAKE(tbl, oomed) +#define HASH_BLOOM_FREE(tbl) +#define HASH_BLOOM_ADD(tbl, hashv) +#define HASH_BLOOM_TEST(tbl, hashv) (1) +#define HASH_BLOOM_BYTELEN 0U +#endif + +#define HASH_MAKE_TABLE(hh, head, oomed) \ + do { \ + (head)->hh.tbl = (UT_hash_table *)uthash_malloc(sizeof(UT_hash_table)); \ + if (!(head)->hh.tbl) { \ + HASH_RECORD_OOM(oomed); \ + } \ + else { \ + uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \ + (head)->hh.tbl->tail = &((head)->hh); \ + (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ + (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ + (head)->hh.tbl->hho = (char *)(&(head)->hh) - (char *)(head); \ + (head)->hh.tbl->buckets = \ + (UT_hash_bucket *)uthash_malloc(HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + (head)->hh.tbl->signature = HASH_SIGNATURE; \ + if (!(head)->hh.tbl->buckets) { \ + HASH_RECORD_OOM(oomed); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + } \ + else { \ + uthash_bzero((head)->hh.tbl->buckets, \ + HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + HASH_BLOOM_MAKE((head)->hh.tbl, oomed); \ + IF_HASH_NONFATAL_OOM(if (oomed) { \ + uthash_free((head)->hh.tbl->buckets, \ + HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + }) \ + } \ + } \ + } while (0) + +#define HASH_REPLACE_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, hashval, add, replaced, cmpfcn) \ + do { \ + (replaced) = NULL; \ + HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \ + if (replaced) { \ + HASH_DELETE(hh, head, replaced); \ + } \ + HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn); \ + } while (0) + +#define HASH_REPLACE_BYHASHVALUE(hh, head, fieldname, keylen_in, hashval, add, replaced) \ + do { \ + (replaced) = NULL; \ + HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \ + if (replaced) { \ + HASH_DELETE(hh, head, replaced); \ + } \ + HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add); \ + } while (0) + +#define HASH_REPLACE(hh, head, fieldname, keylen_in, add, replaced) \ + do { \ + unsigned _hr_hashv; \ + HASH_VALUE(&((add)->fieldname), keylen_in, _hr_hashv); \ + HASH_REPLACE_BYHASHVALUE(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced); \ + } while (0) + +#define HASH_REPLACE_INORDER(hh, head, fieldname, keylen_in, add, replaced, cmpfcn) \ + do { \ + unsigned _hr_hashv; \ + HASH_VALUE(&((add)->fieldname), keylen_in, _hr_hashv); \ + HASH_REPLACE_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced, cmpfcn); \ + } while (0) + +#define HASH_APPEND_LIST(hh, head, add) \ + do { \ + (add)->hh.next = NULL; \ + (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \ + (head)->hh.tbl->tail->next = (add); \ + (head)->hh.tbl->tail = &((add)->hh); \ + } while (0) + +#define HASH_AKBI_INNER_LOOP(hh, head, add, cmpfcn) \ + do { \ + do { \ + if (cmpfcn(DECLTYPE(head)(_hs_iter), add) > 0) { \ + break; \ + } \ + } while ((_hs_iter = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->next)); \ + } while (0) + +#ifdef NO_DECLTYPE +#undef HASH_AKBI_INNER_LOOP +#define HASH_AKBI_INNER_LOOP(hh, head, add, cmpfcn) \ + do { \ + char *_hs_saved_head = (char *)(head); \ + do { \ + DECLTYPE_ASSIGN(head, _hs_iter); \ + if (cmpfcn(head, add) > 0) { \ + DECLTYPE_ASSIGN(head, _hs_saved_head); \ + break; \ + } \ + DECLTYPE_ASSIGN(head, _hs_saved_head); \ + } while ((_hs_iter = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->next)); \ + } while (0) +#endif + +#if HASH_NONFATAL_OOM + +#define HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, oomed) \ + do { \ + if (!(oomed)) { \ + unsigned _ha_bkt; \ + (head)->hh.tbl->num_items++; \ + HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ + HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \ + if (oomed) { \ + HASH_ROLLBACK_BKT(hh, head, &(add)->hh); \ + HASH_DELETE_HH(hh, head, &(add)->hh); \ + (add)->hh.tbl = NULL; \ + uthash_nonfatal_oom(add); \ + } \ + else { \ + HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ + HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + } \ + } \ + else { \ + (add)->hh.tbl = NULL; \ + uthash_nonfatal_oom(add); \ + } \ + } while (0) + +#else + +#define HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, oomed) \ + do { \ + unsigned _ha_bkt; \ + (head)->hh.tbl->num_items++; \ + HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ + HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \ + HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ + HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + } while (0) + +#endif + +#define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, keyptr, keylen_in, hashval, add, cmpfcn) \ + do { \ + IF_HASH_NONFATAL_OOM(int _ha_oomed = 0;) \ + (add)->hh.hashv = (hashval); \ + (add)->hh.key = (char *)(keyptr); \ + (add)->hh.keylen = (unsigned)(keylen_in); \ + if (!(head)) { \ + (add)->hh.next = NULL; \ + (add)->hh.prev = NULL; \ + HASH_MAKE_TABLE(hh, add, _ha_oomed); \ + IF_HASH_NONFATAL_OOM(if (!_ha_oomed) { ) \ + (head) = (add); \ + IF_HASH_NONFATAL_OOM( \ + }) \ + } \ + else { \ + void *_hs_iter = (head); \ + (add)->hh.tbl = (head)->hh.tbl; \ + HASH_AKBI_INNER_LOOP(hh, head, add, cmpfcn); \ + if (_hs_iter) { \ + (add)->hh.next = _hs_iter; \ + if (((add)->hh.prev = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->prev)) { \ + HH_FROM_ELMT((head)->hh.tbl, (add)->hh.prev)->next = (add); \ + } \ + else { \ + (head) = (add); \ + } \ + HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->prev = (add); \ + } \ + else { \ + HASH_APPEND_LIST(hh, head, add); \ + } \ + } \ + HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \ + HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE_INORDER"); \ + } while (0) + +#define HASH_ADD_KEYPTR_INORDER(hh, head, keyptr, keylen_in, add, cmpfcn) \ + do { \ + unsigned _hs_hashv; \ + HASH_VALUE(keyptr, keylen_in, _hs_hashv); \ + HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, keyptr, keylen_in, _hs_hashv, add, cmpfcn); \ + } while (0) + +#define HASH_ADD_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, hashval, add, cmpfcn) \ + HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn) + +#define HASH_ADD_INORDER(hh, head, fieldname, keylen_in, add, cmpfcn) \ + HASH_ADD_KEYPTR_INORDER(hh, head, &((add)->fieldname), keylen_in, add, cmpfcn) + +#define HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, hashval, add) \ + do { \ + IF_HASH_NONFATAL_OOM(int _ha_oomed = 0;) \ + (add)->hh.hashv = (hashval); \ + (add)->hh.key = (char *)(keyptr); \ + (add)->hh.keylen = (unsigned)(keylen_in); \ + if (!(head)) { \ + (add)->hh.next = NULL; \ + (add)->hh.prev = NULL; \ + HASH_MAKE_TABLE(hh, add, _ha_oomed); \ + IF_HASH_NONFATAL_OOM(if (!_ha_oomed) { ) \ + (head) = (add); \ + IF_HASH_NONFATAL_OOM( \ + }) \ + } \ + else { \ + (add)->hh.tbl = (head)->hh.tbl; \ + HASH_APPEND_LIST(hh, head, add); \ + } \ + HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \ + HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE"); \ + } while (0) + +#define HASH_ADD_KEYPTR(hh, head, keyptr, keylen_in, add) \ + do { \ + unsigned _ha_hashv; \ + HASH_VALUE(keyptr, keylen_in, _ha_hashv); \ + HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add); \ + } while (0) + +#define HASH_ADD_BYHASHVALUE(hh, head, fieldname, keylen_in, hashval, add) \ + HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add) + +#define HASH_ADD(hh, head, fieldname, keylen_in, add) \ + HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add) + +#define HASH_TO_BKT(hashv, num_bkts, bkt) \ + do { \ + bkt = ((hashv) & ((num_bkts)-1U)); \ + } while (0) + +/* delete "delptr" from the hash table. + * "the usual" patch-up process for the app-order doubly-linked-list. + * The use of _hd_hh_del below deserves special explanation. + * These used to be expressed using (delptr) but that led to a bug + * if someone used the same symbol for the head and deletee, like + * HASH_DELETE(hh,users,users); + * We want that to work, but by changing the head (users) below + * we were forfeiting our ability to further refer to the deletee (users) + * in the patch-up process. Solution: use scratch space to + * copy the deletee pointer, then the latter references are via that + * scratch pointer rather than through the repointed (users) symbol. + */ +#define HASH_DELETE(hh, head, delptr) HASH_DELETE_HH(hh, head, &(delptr)->hh) + +#define HASH_DELETE_HH(hh, head, delptrhh) \ + do { \ + struct UT_hash_handle *_hd_hh_del = (delptrhh); \ + if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) { \ + HASH_BLOOM_FREE((head)->hh.tbl); \ + uthash_free((head)->hh.tbl->buckets, \ + (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + (head) = NULL; \ + } \ + else { \ + unsigned _hd_bkt; \ + if (_hd_hh_del == (head)->hh.tbl->tail) { \ + (head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev); \ + } \ + if (_hd_hh_del->prev != NULL) { \ + HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next; \ + } \ + else { \ + DECLTYPE_ASSIGN(head, _hd_hh_del->next); \ + } \ + if (_hd_hh_del->next != NULL) { \ + HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev; \ + } \ + HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ + HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \ + (head)->hh.tbl->num_items--; \ + } \ + HASH_FSCK(hh, head, "HASH_DELETE_HH"); \ + } while (0) + +/* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */ +#define HASH_FIND_STR(head, findstr, out) \ + do { \ + unsigned _uthash_hfstr_keylen = (unsigned)uthash_strlen(findstr); \ + HASH_FIND(hh, head, findstr, _uthash_hfstr_keylen, out); \ + } while (0) +#define HASH_ADD_STR(head, strfield, add) \ + do { \ + unsigned _uthash_hastr_keylen = (unsigned)uthash_strlen((add)->strfield); \ + HASH_ADD(hh, head, strfield[0], _uthash_hastr_keylen, add); \ + } while (0) +#define HASH_REPLACE_STR(head, strfield, add, replaced) \ + do { \ + unsigned _uthash_hrstr_keylen = (unsigned)uthash_strlen((add)->strfield); \ + HASH_REPLACE(hh, head, strfield[0], _uthash_hrstr_keylen, add, replaced); \ + } while (0) +#define HASH_FIND_INT(head, findint, out) HASH_FIND(hh, head, findint, sizeof(int), out) +#define HASH_ADD_INT(head, intfield, add) HASH_ADD(hh, head, intfield, sizeof(int), add) +#define HASH_REPLACE_INT(head, intfield, add, replaced) \ + HASH_REPLACE(hh, head, intfield, sizeof(int), add, replaced) +#define HASH_FIND_PTR(head, findptr, out) HASH_FIND(hh, head, findptr, sizeof(void *), out) +#define HASH_ADD_PTR(head, ptrfield, add) HASH_ADD(hh, head, ptrfield, sizeof(void *), add) +#define HASH_REPLACE_PTR(head, ptrfield, add, replaced) \ + HASH_REPLACE(hh, head, ptrfield, sizeof(void *), add, replaced) +#define HASH_DEL(head, delptr) HASH_DELETE(hh, head, delptr) + +/* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined. + * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined. + */ +#ifdef HASH_DEBUG +#include /* fprintf, stderr */ +#define HASH_OOPS(...) \ + do { \ + fprintf(stderr, __VA_ARGS__); \ + exit(-1); \ + } while (0) +#define HASH_FSCK(hh, head, where) \ + do { \ + struct UT_hash_handle *_thh; \ + if (head) { \ + unsigned _bkt_i; \ + unsigned _count = 0; \ + char * _prev; \ + for (_bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; ++_bkt_i) { \ + unsigned _bkt_count = 0; \ + _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \ + _prev = NULL; \ + while (_thh) { \ + if (_prev != (char *)(_thh->hh_prev)) { \ + HASH_OOPS("%s: invalid hh_prev %p, actual %p\n", (where), (void *)_thh->hh_prev, \ + (void *)_prev); \ + } \ + _bkt_count++; \ + _prev = (char *)(_thh); \ + _thh = _thh->hh_next; \ + } \ + _count += _bkt_count; \ + if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \ + HASH_OOPS("%s: invalid bucket count %u, actual %u\n", (where), \ + (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \ + } \ + } \ + if (_count != (head)->hh.tbl->num_items) { \ + HASH_OOPS("%s: invalid hh item count %u, actual %u\n", (where), (head)->hh.tbl->num_items, \ + _count); \ + } \ + _count = 0; \ + _prev = NULL; \ + _thh = &(head)->hh; \ + while (_thh) { \ + _count++; \ + if (_prev != (char *)_thh->prev) { \ + HASH_OOPS("%s: invalid prev %p, actual %p\n", (where), (void *)_thh->prev, \ + (void *)_prev); \ + } \ + _prev = (char *)ELMT_FROM_HH((head)->hh.tbl, _thh); \ + _thh = (_thh->next ? HH_FROM_ELMT((head)->hh.tbl, _thh->next) : NULL); \ + } \ + if (_count != (head)->hh.tbl->num_items) { \ + HASH_OOPS("%s: invalid app item count %u, actual %u\n", (where), (head)->hh.tbl->num_items, \ + _count); \ + } \ + } \ + } while (0) +#else +#define HASH_FSCK(hh, head, where) +#endif + +/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to + * the descriptor to which this macro is defined for tuning the hash function. + * The app can #include to get the prototype for write(2). */ +#ifdef HASH_EMIT_KEYS +#define HASH_EMIT_KEY(hh, head, keyptr, fieldlen) \ + do { \ + unsigned _klen = fieldlen; \ + write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \ + write(HASH_EMIT_KEYS, keyptr, (unsigned long)fieldlen); \ + } while (0) +#else +#define HASH_EMIT_KEY(hh, head, keyptr, fieldlen) +#endif + +/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ +#ifdef HASH_FUNCTION +#define HASH_FCN HASH_FUNCTION +#else +#define HASH_FCN HASH_JEN +#endif + +/* The Bernstein hash function, used in Perl prior to v5.6. Note (x<<5+x)=x*33. */ +#define HASH_BER(key, keylen, hashv) \ + do { \ + unsigned _hb_keylen = (unsigned)keylen; \ + const unsigned char *_hb_key = (const unsigned char *)(key); \ + (hashv) = 0; \ + while (_hb_keylen-- != 0U) { \ + (hashv) = (((hashv) << 5) + (hashv)) + *_hb_key++; \ + } \ + } while (0) + +/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at + * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */ +#define HASH_SAX(key, keylen, hashv) \ + do { \ + unsigned _sx_i; \ + const unsigned char *_hs_key = (const unsigned char *)(key); \ + hashv = 0; \ + for (_sx_i = 0; _sx_i < keylen; _sx_i++) { \ + hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \ + } \ + } while (0) +/* FNV-1a variation */ +#define HASH_FNV(key, keylen, hashv) \ + do { \ + unsigned _fn_i; \ + const unsigned char *_hf_key = (const unsigned char *)(key); \ + (hashv) = 2166136261U; \ + for (_fn_i = 0; _fn_i < keylen; _fn_i++) { \ + hashv = hashv ^ _hf_key[_fn_i]; \ + hashv = hashv * 16777619U; \ + } \ + } while (0) + +#define HASH_OAT(key, keylen, hashv) \ + do { \ + unsigned _ho_i; \ + const unsigned char *_ho_key = (const unsigned char *)(key); \ + hashv = 0; \ + for (_ho_i = 0; _ho_i < keylen; _ho_i++) { \ + hashv += _ho_key[_ho_i]; \ + hashv += (hashv << 10); \ + hashv ^= (hashv >> 6); \ + } \ + hashv += (hashv << 3); \ + hashv ^= (hashv >> 11); \ + hashv += (hashv << 15); \ + } while (0) + +#define HASH_JEN_MIX(a, b, c) \ + do { \ + a -= b; \ + a -= c; \ + a ^= (c >> 13); \ + b -= c; \ + b -= a; \ + b ^= (a << 8); \ + c -= a; \ + c -= b; \ + c ^= (b >> 13); \ + a -= b; \ + a -= c; \ + a ^= (c >> 12); \ + b -= c; \ + b -= a; \ + b ^= (a << 16); \ + c -= a; \ + c -= b; \ + c ^= (b >> 5); \ + a -= b; \ + a -= c; \ + a ^= (c >> 3); \ + b -= c; \ + b -= a; \ + b ^= (a << 10); \ + c -= a; \ + c -= b; \ + c ^= (b >> 15); \ + } while (0) + +#define HASH_JEN(key, keylen, hashv) \ + do { \ + unsigned _hj_i, _hj_j, _hj_k; \ + unsigned const char *_hj_key = (unsigned const char *)(key); \ + hashv = 0xfeedbeefu; \ + _hj_i = _hj_j = 0x9e3779b9u; \ + _hj_k = (unsigned)(keylen); \ + while (_hj_k >= 12U) { \ + _hj_i += (_hj_key[0] + ((unsigned)_hj_key[1] << 8) + ((unsigned)_hj_key[2] << 16) + \ + ((unsigned)_hj_key[3] << 24)); \ + _hj_j += (_hj_key[4] + ((unsigned)_hj_key[5] << 8) + ((unsigned)_hj_key[6] << 16) + \ + ((unsigned)_hj_key[7] << 24)); \ + hashv += (_hj_key[8] + ((unsigned)_hj_key[9] << 8) + ((unsigned)_hj_key[10] << 16) + \ + ((unsigned)_hj_key[11] << 24)); \ + \ + HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ + \ + _hj_key += 12; \ + _hj_k -= 12U; \ + } \ + hashv += (unsigned)(keylen); \ + switch (_hj_k) { \ + case 11: \ + hashv += ((unsigned)_hj_key[10] << 24); /* FALLTHROUGH */ \ + case 10: \ + hashv += ((unsigned)_hj_key[9] << 16); /* FALLTHROUGH */ \ + case 9: \ + hashv += ((unsigned)_hj_key[8] << 8); /* FALLTHROUGH */ \ + case 8: \ + _hj_j += ((unsigned)_hj_key[7] << 24); /* FALLTHROUGH */ \ + case 7: \ + _hj_j += ((unsigned)_hj_key[6] << 16); /* FALLTHROUGH */ \ + case 6: \ + _hj_j += ((unsigned)_hj_key[5] << 8); /* FALLTHROUGH */ \ + case 5: \ + _hj_j += _hj_key[4]; /* FALLTHROUGH */ \ + case 4: \ + _hj_i += ((unsigned)_hj_key[3] << 24); /* FALLTHROUGH */ \ + case 3: \ + _hj_i += ((unsigned)_hj_key[2] << 16); /* FALLTHROUGH */ \ + case 2: \ + _hj_i += ((unsigned)_hj_key[1] << 8); /* FALLTHROUGH */ \ + case 1: \ + _hj_i += _hj_key[0]; \ + } \ + HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ + } while (0) + +/* The Paul Hsieh hash function */ +#undef get16bits +#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) || defined(_MSC_VER) || \ + defined(__BORLANDC__) || defined(__TURBOC__) +#define get16bits(d) (*((const uint16_t *)(d))) +#endif + +#if !defined(get16bits) +#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) + (uint32_t)(((const uint8_t *)(d))[0])) +#endif +#define HASH_SFH(key, keylen, hashv) \ + do { \ + unsigned const char *_sfh_key = (unsigned const char *)(key); \ + uint32_t _sfh_tmp, _sfh_len = (uint32_t)keylen; \ + \ + unsigned _sfh_rem = _sfh_len & 3U; \ + _sfh_len >>= 2; \ + hashv = 0xcafebabeu; \ + \ + /* Main loop */ \ + for (; _sfh_len > 0U; _sfh_len--) { \ + hashv += get16bits(_sfh_key); \ + _sfh_tmp = ((uint32_t)(get16bits(_sfh_key + 2)) << 11) ^ hashv; \ + hashv = (hashv << 16) ^ _sfh_tmp; \ + _sfh_key += 2U * sizeof(uint16_t); \ + hashv += hashv >> 11; \ + } \ + \ + /* Handle end cases */ \ + switch (_sfh_rem) { \ + case 3: \ + hashv += get16bits(_sfh_key); \ + hashv ^= hashv << 16; \ + hashv ^= (uint32_t)(_sfh_key[sizeof(uint16_t)]) << 18; \ + hashv += hashv >> 11; \ + break; \ + case 2: \ + hashv += get16bits(_sfh_key); \ + hashv ^= hashv << 11; \ + hashv += hashv >> 17; \ + break; \ + case 1: \ + hashv += *_sfh_key; \ + hashv ^= hashv << 10; \ + hashv += hashv >> 1; \ + } \ + \ + /* Force "avalanching" of final 127 bits */ \ + hashv ^= hashv << 3; \ + hashv += hashv >> 5; \ + hashv ^= hashv << 4; \ + hashv += hashv >> 17; \ + hashv ^= hashv << 25; \ + hashv += hashv >> 6; \ + } while (0) + +/* iterate over items in a known bucket to find desired item */ +#define HASH_FIND_IN_BKT(tbl, hh, head, keyptr, keylen_in, hashval, out) \ + do { \ + if ((head).hh_head != NULL) { \ + DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (head).hh_head)); \ + } \ + else { \ + (out) = NULL; \ + } \ + while ((out) != NULL) { \ + if ((out)->hh.hashv == (hashval) && (out)->hh.keylen == (keylen_in)) { \ + if (HASH_KEYCMP((out)->hh.key, keyptr, keylen_in) == 0) { \ + break; \ + } \ + } \ + if ((out)->hh.hh_next != NULL) { \ + DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (out)->hh.hh_next)); \ + } \ + else { \ + (out) = NULL; \ + } \ + } \ + } while (0) + +/* add an item to a bucket */ +#define HASH_ADD_TO_BKT(head, hh, addhh, oomed) \ + do { \ + UT_hash_bucket *_ha_head = &(head); \ + _ha_head->count++; \ + (addhh)->hh_next = _ha_head->hh_head; \ + (addhh)->hh_prev = NULL; \ + if (_ha_head->hh_head != NULL) { \ + _ha_head->hh_head->hh_prev = (addhh); \ + } \ + _ha_head->hh_head = (addhh); \ + if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) && \ + !(addhh)->tbl->noexpand) { \ + HASH_EXPAND_BUCKETS(addhh, (addhh)->tbl, oomed); \ + IF_HASH_NONFATAL_OOM(if (oomed) { HASH_DEL_IN_BKT(head, addhh); }) \ + } \ + } while (0) + +/* remove an item from a given bucket */ +#define HASH_DEL_IN_BKT(head, delhh) \ + do { \ + UT_hash_bucket *_hd_head = &(head); \ + _hd_head->count--; \ + if (_hd_head->hh_head == (delhh)) { \ + _hd_head->hh_head = (delhh)->hh_next; \ + } \ + if ((delhh)->hh_prev) { \ + (delhh)->hh_prev->hh_next = (delhh)->hh_next; \ + } \ + if ((delhh)->hh_next) { \ + (delhh)->hh_next->hh_prev = (delhh)->hh_prev; \ + } \ + } while (0) + +/* Bucket expansion has the effect of doubling the number of buckets + * and redistributing the items into the new buckets. Ideally the + * items will distribute more or less evenly into the new buckets + * (the extent to which this is true is a measure of the quality of + * the hash function as it applies to the key domain). + * + * With the items distributed into more buckets, the chain length + * (item count) in each bucket is reduced. Thus by expanding buckets + * the hash keeps a bound on the chain length. This bounded chain + * length is the essence of how a hash provides constant time lookup. + * + * The calculation of tbl->ideal_chain_maxlen below deserves some + * explanation. First, keep in mind that we're calculating the ideal + * maximum chain length based on the *new* (doubled) bucket count. + * In fractions this is just n/b (n=number of items,b=new num buckets). + * Since the ideal chain length is an integer, we want to calculate + * ceil(n/b). We don't depend on floating point arithmetic in this + * hash, so to calculate ceil(n/b) with integers we could write + * + * ceil(n/b) = (n/b) + ((n%b)?1:0) + * + * and in fact a previous version of this hash did just that. + * But now we have improved things a bit by recognizing that b is + * always a power of two. We keep its base 2 log handy (call it lb), + * so now we can write this with a bit shift and logical AND: + * + * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0) + * + */ +#define HASH_EXPAND_BUCKETS(hh, tbl, oomed) \ + do { \ + unsigned _he_bkt; \ + unsigned _he_bkt_i; \ + struct UT_hash_handle *_he_thh, *_he_hh_nxt; \ + UT_hash_bucket * _he_new_buckets, *_he_newbkt; \ + _he_new_buckets = \ + (UT_hash_bucket *)uthash_malloc(2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ + if (!_he_new_buckets) { \ + HASH_RECORD_OOM(oomed); \ + } \ + else { \ + uthash_bzero(_he_new_buckets, 2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ + (tbl)->ideal_chain_maxlen = \ + ((tbl)->num_items >> ((tbl)->log2_num_buckets + 1U)) + \ + ((((tbl)->num_items & (((tbl)->num_buckets * 2U) - 1U)) != 0U) ? 1U : 0U); \ + (tbl)->nonideal_items = 0; \ + for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \ + _he_thh = (tbl)->buckets[_he_bkt_i].hh_head; \ + while (_he_thh != NULL) { \ + _he_hh_nxt = _he_thh->hh_next; \ + HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \ + _he_newbkt = &(_he_new_buckets[_he_bkt]); \ + if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \ + (tbl)->nonideal_items++; \ + if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \ + _he_newbkt->expand_mult++; \ + } \ + } \ + _he_thh->hh_prev = NULL; \ + _he_thh->hh_next = _he_newbkt->hh_head; \ + if (_he_newbkt->hh_head != NULL) { \ + _he_newbkt->hh_head->hh_prev = _he_thh; \ + } \ + _he_newbkt->hh_head = _he_thh; \ + _he_thh = _he_hh_nxt; \ + } \ + } \ + uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ + (tbl)->num_buckets *= 2U; \ + (tbl)->log2_num_buckets++; \ + (tbl)->buckets = _he_new_buckets; \ + (tbl)->ineff_expands = \ + ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? ((tbl)->ineff_expands + 1U) : 0U; \ + if ((tbl)->ineff_expands > 1U) { \ + (tbl)->noexpand = 1; \ + uthash_noexpand_fyi(tbl); \ + } \ + uthash_expand_fyi(tbl); \ + } \ + } while (0) + +/* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */ +/* Note that HASH_SORT assumes the hash handle name to be hh. + * HASH_SRT was added to allow the hash handle name to be passed in. */ +#define HASH_SORT(head, cmpfcn) HASH_SRT(hh, head, cmpfcn) +#define HASH_SRT(hh, head, cmpfcn) \ + do { \ + unsigned _hs_i; \ + unsigned _hs_looping, _hs_nmerges, _hs_insize, _hs_psize, _hs_qsize; \ + struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \ + if (head != NULL) { \ + _hs_insize = 1; \ + _hs_looping = 1; \ + _hs_list = &((head)->hh); \ + while (_hs_looping != 0U) { \ + _hs_p = _hs_list; \ + _hs_list = NULL; \ + _hs_tail = NULL; \ + _hs_nmerges = 0; \ + while (_hs_p != NULL) { \ + _hs_nmerges++; \ + _hs_q = _hs_p; \ + _hs_psize = 0; \ + for (_hs_i = 0; _hs_i < _hs_insize; ++_hs_i) { \ + _hs_psize++; \ + _hs_q = ((_hs_q->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_q->next) : NULL); \ + if (_hs_q == NULL) { \ + break; \ + } \ + } \ + _hs_qsize = _hs_insize; \ + while ((_hs_psize != 0U) || ((_hs_qsize != 0U) && (_hs_q != NULL))) { \ + if (_hs_psize == 0U) { \ + _hs_e = _hs_q; \ + _hs_q = \ + ((_hs_q->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_q->next) : NULL); \ + _hs_qsize--; \ + } \ + else if ((_hs_qsize == 0U) || (_hs_q == NULL)) { \ + _hs_e = _hs_p; \ + if (_hs_p != NULL) { \ + _hs_p = ((_hs_p->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_p->next) \ + : NULL); \ + } \ + _hs_psize--; \ + } \ + else if ((cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_p)), \ + DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_q)))) <= 0) { \ + _hs_e = _hs_p; \ + if (_hs_p != NULL) { \ + _hs_p = ((_hs_p->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_p->next) \ + : NULL); \ + } \ + _hs_psize--; \ + } \ + else { \ + _hs_e = _hs_q; \ + _hs_q = \ + ((_hs_q->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_q->next) : NULL); \ + _hs_qsize--; \ + } \ + if (_hs_tail != NULL) { \ + _hs_tail->next = ((_hs_e != NULL) ? ELMT_FROM_HH((head)->hh.tbl, _hs_e) : NULL); \ + } \ + else { \ + _hs_list = _hs_e; \ + } \ + if (_hs_e != NULL) { \ + _hs_e->prev = \ + ((_hs_tail != NULL) ? ELMT_FROM_HH((head)->hh.tbl, _hs_tail) : NULL); \ + } \ + _hs_tail = _hs_e; \ + } \ + _hs_p = _hs_q; \ + } \ + if (_hs_tail != NULL) { \ + _hs_tail->next = NULL; \ + } \ + if (_hs_nmerges <= 1U) { \ + _hs_looping = 0; \ + (head)->hh.tbl->tail = _hs_tail; \ + DECLTYPE_ASSIGN(head, ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \ + } \ + _hs_insize *= 2U; \ + } \ + HASH_FSCK(hh, head, "HASH_SRT"); \ + } \ + } while (0) + +/* This function selects items from one hash into another hash. + * The end result is that the selected items have dual presence + * in both hashes. There is no copy of the items made; rather + * they are added into the new hash through a secondary hash + * hash handle that must be present in the structure. */ +#define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \ + do { \ + unsigned _src_bkt, _dst_bkt; \ + void * _last_elt = NULL, *_elt; \ + UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh = NULL; \ + ptrdiff_t _dst_hho = ((char *)(&(dst)->hh_dst) - (char *)(dst)); \ + if ((src) != NULL) { \ + for (_src_bkt = 0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \ + for (_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; _src_hh != NULL; \ + _src_hh = _src_hh->hh_next) { \ + _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \ + if (cond(_elt)) { \ + IF_HASH_NONFATAL_OOM(int _hs_oomed = 0;) \ + _dst_hh = (UT_hash_handle *)(void *)(((char *)_elt) + _dst_hho); \ + _dst_hh->key = _src_hh->key; \ + _dst_hh->keylen = _src_hh->keylen; \ + _dst_hh->hashv = _src_hh->hashv; \ + _dst_hh->prev = _last_elt; \ + _dst_hh->next = NULL; \ + if (_last_elt_hh != NULL) { \ + _last_elt_hh->next = _elt; \ + } \ + if ((dst) == NULL) { \ + DECLTYPE_ASSIGN(dst, _elt); \ + HASH_MAKE_TABLE(hh_dst, dst, _hs_oomed); \ + IF_HASH_NONFATAL_OOM(if (_hs_oomed) { \ + uthash_nonfatal_oom(_elt); \ + (dst) = NULL; \ + continue; \ + }) \ + } \ + else { \ + _dst_hh->tbl = (dst)->hh_dst.tbl; \ + } \ + HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \ + HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], hh_dst, _dst_hh, _hs_oomed); \ + (dst)->hh_dst.tbl->num_items++; \ + IF_HASH_NONFATAL_OOM(if (_hs_oomed) { \ + HASH_ROLLBACK_BKT(hh_dst, dst, _dst_hh); \ + HASH_DELETE_HH(hh_dst, dst, _dst_hh); \ + _dst_hh->tbl = NULL; \ + uthash_nonfatal_oom(_elt); \ + continue; \ + }) \ + HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \ + _last_elt = _elt; \ + _last_elt_hh = _dst_hh; \ + } \ + } \ + } \ + } \ + HASH_FSCK(hh_dst, dst, "HASH_SELECT"); \ + } while (0) + +#define HASH_CLEAR(hh, head) \ + do { \ + if ((head) != NULL) { \ + HASH_BLOOM_FREE((head)->hh.tbl); \ + uthash_free((head)->hh.tbl->buckets, \ + (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + (head) = NULL; \ + } \ + } while (0) + +#define HASH_OVERHEAD(hh, head) \ + (((head) != NULL) ? ((size_t)(((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \ + ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \ + sizeof(UT_hash_table) + (HASH_BLOOM_BYTELEN))) \ + : 0U) + +#ifdef NO_DECLTYPE +#define HASH_ITER(hh, head, el, tmp) \ + for (((el) = (head)), ((*(char **)(&(tmp))) = (char *)((head != NULL) ? (head)->hh.next : NULL)); \ + (el) != NULL; \ + ((el) = (tmp)), ((*(char **)(&(tmp))) = (char *)((tmp != NULL) ? (tmp)->hh.next : NULL))) +#else +#define HASH_ITER(hh, head, el, tmp) \ + for (((el) = (head)), ((tmp) = DECLTYPE(el)((head != NULL) ? (head)->hh.next : NULL)); (el) != NULL; \ + ((el) = (tmp)), ((tmp) = DECLTYPE(el)((tmp != NULL) ? (tmp)->hh.next : NULL))) +#endif + +/* obtain a count of items in the hash */ +#define HASH_COUNT(head) HASH_CNT(hh, head) +#define HASH_CNT(hh, head) ((head != NULL) ? ((head)->hh.tbl->num_items) : 0U) + +typedef struct UT_hash_bucket { + struct UT_hash_handle *hh_head; + unsigned count; + + /* expand_mult is normally set to 0. In this situation, the max chain length + * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If + * the bucket's chain exceeds this length, bucket expansion is triggered). + * However, setting expand_mult to a non-zero value delays bucket expansion + * (that would be triggered by additions to this particular bucket) + * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH. + * (The multiplier is simply expand_mult+1). The whole idea of this + * multiplier is to reduce bucket expansions, since they are expensive, in + * situations where we know that a particular bucket tends to be overused. + * It is better to let its chain length grow to a longer yet-still-bounded + * value, than to do an O(n) bucket expansion too often. + */ + unsigned expand_mult; + +} UT_hash_bucket; + +/* random signature used only to find hash tables in external analysis */ +#define HASH_SIGNATURE 0xa0111fe1u +#define HASH_BLOOM_SIGNATURE 0xb12220f2u + +typedef struct UT_hash_table { + UT_hash_bucket * buckets; + unsigned num_buckets, log2_num_buckets; + unsigned num_items; + struct UT_hash_handle *tail; /* tail hh in app order, for fast append */ + ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */ + + /* in an ideal situation (all buckets used equally), no bucket would have + * more than ceil(#items/#buckets) items. that's the ideal chain length. */ + unsigned ideal_chain_maxlen; + + /* nonideal_items is the number of items in the hash whose chain position + * exceeds the ideal chain maxlen. these items pay the penalty for an uneven + * hash distribution; reaching them in a chain traversal takes >ideal steps */ + unsigned nonideal_items; + + /* ineffective expands occur when a bucket doubling was performed, but + * afterward, more than half the items in the hash had nonideal chain + * positions. If this happens on two consecutive expansions we inhibit any + * further expansion, as it's not helping; this happens when the hash + * function isn't a good fit for the key domain. When expansion is inhibited + * the hash will still work, albeit no longer in constant time. */ + unsigned ineff_expands, noexpand; + + uint32_t signature; /* used only to find hash tables in external analysis */ +#ifdef HASH_BLOOM + uint32_t bloom_sig; /* used only to test bloom exists in external analysis */ + uint8_t *bloom_bv; + uint8_t bloom_nbits; +#endif + +} UT_hash_table; + +typedef struct UT_hash_handle { + struct UT_hash_table * tbl; + void * prev; /* prev element in app order */ + void * next; /* next element in app order */ + struct UT_hash_handle *hh_prev; /* previous hh in bucket order */ + struct UT_hash_handle *hh_next; /* next hh in bucket order */ + void * key; /* ptr to enclosing struct's key */ + unsigned keylen; /* enclosing struct's key len */ + unsigned hashv; /* result of hash-fcn(key) */ +} UT_hash_handle; + +#endif /* UTHASH_H */ diff --git a/test/CMakeVFDTests.cmake b/test/CMakeVFDTests.cmake index dada9a90a8c..892ccf361fe 100644 --- a/test/CMakeVFDTests.cmake +++ b/test/CMakeVFDTests.cmake @@ -26,7 +26,7 @@ set (VFD_LIST multi family ) -if (DIRECT_VFD) +if (H5_HAVE_DIRECT) set (VFD_LIST ${VFD_LIST} direct) endif () diff --git a/test/tid.c b/test/tid.c index 94f08ff79aa..2f5188e5665 100644 --- a/test/tid.c +++ b/test/tid.c @@ -569,197 +569,301 @@ test_id_type_list(void) /* There was a rare bug where, if an id free callback being called by * H5I_clear_type() removed another id in that type, a segfault could occur. * This test tests for that error (and freeing ids "out of order" within - * H5Iclear_type() in general). */ + * H5Iclear_type() in general). + * + * NB: RCT = "remove clear type" + */ + /* Macro definitions */ -#define TEST_RCT_MAX_NOBJS 25 -#define TEST_RCT_MIN_NOBJS 5 -#define TEST_RCT_NITER 50 +#define RCT_MAX_NOBJS 25 /* Maximum number of objects in the list */ +#define RCT_MIN_NOBJS 5 +#define RCT_NITER 50 /* Number of times we cycle through object creation and deletion */ + +/* Structure to hold the master list of objects */ +typedef struct rct_obj_list_t { + + /* Pointer to the objects */ + struct rct_obj_t *objects; + + /* The number of objects in the list */ + long count; -/* Structure to hold the list of objects */ -typedef struct { - struct test_rct_obj_t *list; /* List of objects */ - long nobjs; /* Number of objects in list */ - long nobjs_rem; /* Number of objects in list that have not been freed */ -} test_rct_list_t; + /* The number of objects in the list that have not been freed */ + long remaining; +} rct_obj_list_t; /* Structure for an object */ -typedef struct test_rct_obj_t { - hid_t id; /* ID for this object */ - int nfrees; /* Number of times this object has been freed */ - hbool_t freeing; /* Whether we are currently freeing this object directly (through H5Idec_ref()) */ - test_rct_list_t *obj_list; /* List of all objects */ -} test_rct_obj_t; - -/* Free callback */ +typedef struct rct_obj_t { + /* The ID for this object */ + hid_t id; + + /* The number of times this object has been freed */ + int nfrees; + + /* Whether we are currently freeing this object directly + * through H5Idec_ref(). + */ + hbool_t freeing; + + /* Pointer to the master list of all objects */ + rct_obj_list_t *list; +} rct_obj_t; + +/* Free callback passed to H5Iclear_type() + * + * When invoked on a closing object, frees a random unfreed ID in the + * master list of objects. + */ static herr_t -test_rct_free(void *_obj) +rct_free_cb(void *_obj) { - test_rct_obj_t *obj = (test_rct_obj_t *)_obj; - long rem_idx, i; - herr_t ret; /* return value */ + rct_obj_t *obj = (rct_obj_t *)_obj; + long remove_nth; + long i; + herr_t ret; /* Mark this object as freed */ obj->nfrees++; - obj->obj_list->nobjs_rem--; - - /* Check freeing and nobjs_rem */ - if (!obj->freeing && (obj->obj_list->nobjs_rem > 0)) { - /* Remove a random object from the list */ - rem_idx = HDrandom() % obj->obj_list->nobjs_rem; - - /* Scan the list, finding the rem_idx'th object that has not been - * freed */ - for (i = 0; i < obj->obj_list->nobjs; i++) - if (obj->obj_list->list[i].nfrees == 0) { - if (rem_idx == 0) + + /* Decrement the number of objects in the list that have not been freed */ + obj->list->remaining--; + + /* If this object isn't already being freed by a callback free call and + * the master object list still contains objects to free, pick another + * object and free it. + */ + if (!obj->freeing && (obj->list->remaining > 0)) { + + /* Pick a random object from the list. This is done by picking a + * random number between 0 and the # of remaining unfreed objects + * and then scanning through the list to find that nth unfreed + * object. + */ + remove_nth = HDrandom() % obj->list->remaining; + for (i = 0; i < obj->list->count; i++) + if (obj->list->objects[i].nfrees == 0) { + if (remove_nth == 0) break; else - rem_idx--; - } /* end if */ - if (i == obj->obj_list->nobjs) { + remove_nth--; + } + + /* Badness if we scanned through the list and didn't manage to + * select one to delete (the list stats were probably updated + * incorrectly). + */ + if (i == obj->list->count) { ERROR("invalid obj_list"); - goto out; - } /* end if */ - else { - /* Remove the object. Mark as "freeing" so its own callback does - * not free another object. */ - obj->obj_list->list[i].freeing = TRUE; - ret = H5Idec_ref(obj->obj_list->list[i].id); - CHECK(ret, FAIL, "H5Idec_ref"); - if (ret == FAIL) - goto out; - obj->obj_list->list[i].freeing = FALSE; - } /* end else */ - } /* end if */ - - /* Verify nobjs_rem is non-negative */ - if (obj->obj_list->nobjs_rem < 0) { - ERROR("invalid nobjs_rem"); - goto out; - } /* end if */ + goto error; + } + + /* Mark the object we're about to free so its own callback does + * not free another object. We don't want to recursively free the + * entire list when we free the first ID. + */ + obj->list->objects[i].freeing = TRUE; + + /* Decrement the reference count on the object */ + ret = H5Idec_ref(obj->list->objects[i].id); + CHECK(ret, FAIL, "H5Idec_ref"); + if (ret == FAIL) + goto error; + + /* Unset the "freeing" flag */ + obj->list->objects[i].freeing = FALSE; + } + + /* Verify the number of objects remaining in the master list is non-negative */ + if (obj->list->remaining < 0) { + ERROR("invalid number of objects remaining"); + goto error; + } return 0; -out: +error: return -1; -} /* end test_rct_free() */ +} /* end rct_free_cb() */ /* Test function */ static int test_remove_clear_type(void) { - H5I_type_t obj_type; - test_rct_list_t obj_list; - test_rct_obj_t list[TEST_RCT_MAX_NOBJS]; - long i, j; - long nobjs_found; - hsize_t nmembers; - herr_t ret; /* return value */ - - /* Register type */ - obj_type = H5Iregister_type((size_t)8, 0, test_rct_free); + H5I_type_t obj_type; + rct_obj_list_t obj_list; + rct_obj_t * objects = NULL; /* Convenience pointer to objects stored in master list */ + size_t list_size; + long i, j; + herr_t ret; /* return value */ + + /* Register a user-defined type with our custom ID-deleting callback */ + obj_type = H5Iregister_type((size_t)8, 0, rct_free_cb); CHECK(obj_type, H5I_BADID, "H5Iregister_type"); if (obj_type == H5I_BADID) - goto out; + goto error; + + /* Create an array to hold the objects in the master list */ + list_size = RCT_MAX_NOBJS * sizeof(rct_obj_t); + obj_list.objects = HDmalloc(list_size); + CHECK_PTR(obj_list.objects, "HDcalloc"); + if (NULL == obj_list.objects) + goto error; + + /* Set a convenience pointer to the object array */ + objects = obj_list.objects; + + for (i = 0; i < RCT_NITER; i++) { + + /* The number of members in the type, according to the HDF5 library */ + hsize_t nmembers = 1234567; /* (init to fake number) */ + + /* The number of objects found while scanning through the object list */ + int found; + + /********************* + * Build object list * + *********************/ + + HDmemset(obj_list.objects, 0, list_size); - /* Init obj_list.list */ - obj_list.list = list; - - for (i = 0; i < TEST_RCT_NITER; i++) { - /* Build object list */ - obj_list.nobjs = obj_list.nobjs_rem = - TEST_RCT_MIN_NOBJS + (HDrandom() % (long)(TEST_RCT_MAX_NOBJS - TEST_RCT_MIN_NOBJS + 1)); - for (j = 0; j < obj_list.nobjs; j++) { - list[j].nfrees = 0; - list[j].freeing = FALSE; - list[j].obj_list = &obj_list; - list[j].id = H5Iregister(obj_type, &list[j]); - CHECK(list[j].id, FAIL, "H5Iregister"); - if (list[j].id == FAIL) - goto out; + /* The number of objects used is a random number between the min and max */ + obj_list.count = obj_list.remaining = + RCT_MIN_NOBJS + (HDrandom() % (long)(RCT_MAX_NOBJS - RCT_MIN_NOBJS + 1)); + + /* Create the actual objects */ + for (j = 0; j < obj_list.count; j++) { + + /* Object setup */ + objects[j].nfrees = 0; + objects[j].freeing = FALSE; + objects[j].list = &obj_list; + + /* Register an ID for it */ + objects[j].id = H5Iregister(obj_type, &objects[j]); + CHECK(objects[j].id, FAIL, "H5Iregister"); + if (objects[j].id == FAIL) + goto error; + + /* Bump the reference count by 1 (to 2) 50% of the time */ if (HDrandom() % 2) { - ret = H5Iinc_ref(list[j].id); + ret = H5Iinc_ref(objects[j].id); CHECK(ret, FAIL, "H5Iinc_ref"); if (ret == FAIL) - goto out; - } /* end if */ - } /* end for */ + goto error; + } + } - /* Clear the type */ + /****************************************** + * Clear the type with force set to FALSE * + ******************************************/ + + /* Clear the type. Since force is FALSE, only + * IDs with a reference count of 1 will be cleared. + */ ret = H5Iclear_type(obj_type, FALSE); CHECK(ret, FAIL, "H5Iclear_type"); if (ret == FAIL) - goto out; - - /* Verify list */ - nobjs_found = 0; - for (j = 0; j < obj_list.nobjs; j++) { - if (list[j].nfrees == 0) - nobjs_found++; + goto error; + + /* Verify that the object struct fields are sane and count the + * number of unfreed objects + */ + found = 0; + for (j = 0; j < obj_list.count; j++) { + + if (objects[j].nfrees == 0) { + /* Count unfreed objects */ + found++; + } else { - VERIFY(list[j].nfrees, (long)1, "list[j].nfrees"); - if (list[j].nfrees != (long)1) - goto out; - } /* end else */ - VERIFY(list[j].freeing, FALSE, "list[j].freeing"); - if (list[j].freeing != FALSE) - goto out; - } /* end for */ - - /* Verify number of objects */ - VERIFY(obj_list.nobjs_rem, nobjs_found, "obj_list.nobjs_rem"); - if (obj_list.nobjs_rem != nobjs_found) - goto out; + /* Every freed object should have been freed exactly once */ + VERIFY(objects[j].nfrees, 1, "object freed more than once"); + if (objects[j].nfrees != 1) + goto error; + } + + /* No object should still be marked as "freeing" */ + VERIFY(objects[j].freeing, FALSE, "object marked as freeing"); + if (objects[j].freeing != FALSE) + goto error; + } + + /* Verify the number of unfreed objects we found during our scan + * matches the number stored in the list + */ + VERIFY(obj_list.remaining, found, "incorrect number of objects remaining"); + if (obj_list.remaining != found) + goto error; + + /* Make sure the HDF5 library confirms our count */ ret = H5Inmembers(obj_type, &nmembers); CHECK(ret, FAIL, "H5Inmembers"); if (ret == FAIL) - goto out; - VERIFY(nmembers, (size_t)nobjs_found, "H5Inmembers"); - if (nmembers != (size_t)nobjs_found) - goto out; + goto error; + VERIFY(nmembers, found, "The number of members remaining in the type did not match our count"); + if (nmembers != (hsize_t)found) + goto error; - /* Clear the type with force set to TRUE */ + /***************************************** + * Clear the type with force set to TRUE * + *****************************************/ + + /* Clear the type. Since force is TRUE, all IDs will be cleared. */ ret = H5Iclear_type(obj_type, TRUE); CHECK(ret, FAIL, "H5Iclear_type"); if (ret == FAIL) - goto out; + goto error; - /* Verify list */ - for (j = 0; j < obj_list.nobjs; j++) { - VERIFY(list[j].nfrees, (long)1, "list[j].nfrees"); - if (list[j].nfrees != (long)1) - goto out; - VERIFY(list[j].freeing, FALSE, "list[j].freeing"); - if (list[j].freeing != FALSE) - goto out; - } /* end for */ - - /* Verify number of objects is 0 */ - VERIFY(obj_list.nobjs_rem, (long)0, "obj_list.nobjs_rem"); - if (obj_list.nobjs_rem != (long)0) - goto out; + /* Verify that the object struct fields are sane */ + for (j = 0; j < obj_list.count; j++) { + + /* Every object should have been freed exactly once */ + VERIFY(objects[j].nfrees, 1, "object freed more than once"); + if (objects[j].nfrees != 1) + goto error; + + /* No object should still be marked as "freeing" */ + VERIFY(objects[j].freeing, FALSE, "object marked as freeing"); + if (objects[j].freeing != FALSE) + goto error; + } + + /* Verify the number of objects is 0 */ + VERIFY(obj_list.remaining, 0, "objects remaining was not zero"); + if (obj_list.remaining != 0) + goto error; + + /* Make sure the HDF5 library confirms zero members in the type */ ret = H5Inmembers(obj_type, &nmembers); CHECK(ret, FAIL, "H5Inmembers"); if (ret == FAIL) - goto out; - VERIFY(nmembers, (size_t)0, "H5Inmembers"); - if (nmembers != (size_t)0) - goto out; - } /* end for */ + goto error; + VERIFY(nmembers, 0, "The number of members remaining in the type was not zero"); + if (nmembers != 0) + goto error; + } - /* Destroy type */ + /* Destroy the type */ ret = H5Idestroy_type(obj_type); CHECK(ret, FAIL, "H5Idestroy_type"); if (ret == FAIL) - goto out; + goto error; + + /* Free the object array */ + HDfree(obj_list.objects); return 0; -out: +error: /* Cleanup. For simplicity, just destroy the types and ignore errors. */ H5E_BEGIN_TRY - H5Idestroy_type(obj_type); + { + H5Idestroy_type(obj_type); + } H5E_END_TRY + + HDfree(obj_list.objects); + return -1; } /* end test_remove_clear_type() */ diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake index 8c076fd625a..8947a293b8e 100644 --- a/testpar/CMakeVFDTests.cmake +++ b/testpar/CMakeVFDTests.cmake @@ -29,7 +29,7 @@ set (H5P_VFD_TESTS t_pflush2 ) -if (DIRECT_VFD) +if (H5_HAVE_DIRECT) set (VFD_LIST ${VFD_LIST} direct) endif () diff --git a/tools/test/h5copy/CMakeLists.txt b/tools/test/h5copy/CMakeLists.txt index f76a65ef153..f63eb847601 100644 --- a/tools/test/h5copy/CMakeLists.txt +++ b/tools/test/h5copy/CMakeLists.txt @@ -32,7 +32,7 @@ if (BUILD_SHARED_LIBS) add_library (${H5COPY_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_copy.c) target_include_directories (${H5COPY_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (${H5COPY_TOOL_PLUGIN_LIB_TARGET} SHARED) - target_link_libraries (${H5COPY_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + target_link_libraries (${H5COPY_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_LIBSH_TARGET}) H5_SET_LIB_OPTIONS (${H5COPY_TOOL_PLUGIN_LIB_TARGET} ${H5COPY_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") #----------------------------------------------------------------------------- diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake index 73fbda60c0a..e9b36fe3c94 100644 --- a/tools/test/h5copy/CMakeTests.cmake +++ b/tools/test/h5copy/CMakeTests.cmake @@ -76,13 +76,13 @@ endif () # resultcode=2 will cause the test to skip the diff test - if (NOT ${resultcode} EQUAL 2) + if (NOT "${resultcode}" STREQUAL "2") add_test ( NAME H5COPY_F-${testname}-DIFF COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) set_tests_properties (H5COPY_F-${testname}-DIFF PROPERTIES DEPENDS H5COPY_F-${testname}) - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY_F-${testname}-DIFF PROPERTIES WILL_FAIL "true") endif () endif () @@ -110,13 +110,13 @@ endif () # resultcode=2 will cause the test to skip the diff test - if (NOT ${resultcode} EQUAL 2) + if (NOT "${resultcode}" STREQUAL "2") add_test ( NAME H5COPY-${testname}-DIFF COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES DEPENDS H5COPY-${testname}) - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES WILL_FAIL "true") endif () endif () @@ -159,13 +159,13 @@ ) set_tests_properties (H5COPY-${testname} PROPERTIES DEPENDS H5COPY-${testname}-prefill) # resultcode=2 will cause the test to skip the diff test - if (NOT ${resultcode} EQUAL 2) + if (NOT "${resultcode}" STREQUAL "2") add_test ( NAME H5COPY-${testname}-DIFF COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES DEPENDS H5COPY-${testname}) - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES WILL_FAIL "true") endif () endif () @@ -198,13 +198,13 @@ ) set_tests_properties (H5COPY_SAME-${testname} PROPERTIES DEPENDS H5COPY_SAME-${testname}-prefill) # resultcode=2 will cause the test to skip the diff test - if (NOT ${resultcode} EQUAL 2) + if (NOT "${resultcode}" STREQUAL "2") add_test ( NAME H5COPY_SAME-${testname}-DIFF COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -v ./testfiles/${testname}.out.h5 ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) set_tests_properties (H5COPY_SAME-${testname}-DIFF PROPERTIES DEPENDS H5COPY_SAME-${testname}) - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY_SAME-${testname}-DIFF PROPERTIES WILL_FAIL "true") endif () endif () @@ -218,7 +218,7 @@ # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME H5COPY-CMP-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -i ./testfiles/${infile} -o ./testfiles/${testname}.out.h5 ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN}) - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY-CMP-${testname} PROPERTIES WILL_FAIL "true") endif () if (last_test) @@ -255,7 +255,7 @@ NAME H5COPY_UD-${testname}-clear-objects COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testname}.out.h5 ) - if (${resultcode} EQUAL 2) + if ("${resultcode}" STREQUAL "2") add_test ( NAME H5COPY_UD-${testname} COMMAND "${CMAKE_COMMAND}" @@ -318,7 +318,7 @@ NAME H5COPY_UD_ERR-${testname}-clearall-objects COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testname}_ERR.out.h5 ) - if (${resultcode} EQUAL 2) + if ("${resultcode}" STREQUAL "2") add_test ( NAME H5COPY_UD_ERR-${testname} COMMAND "${CMAKE_COMMAND}" diff --git a/tools/test/h5diff/CMakeLists.txt b/tools/test/h5diff/CMakeLists.txt index 9349ace9e11..f74db0f0fe9 100644 --- a/tools/test/h5diff/CMakeLists.txt +++ b/tools/test/h5diff/CMakeLists.txt @@ -32,7 +32,7 @@ if (BUILD_SHARED_LIBS) add_library (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_diff.c) target_include_directories (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} SHARED) - target_link_libraries (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + target_link_libraries (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_LIBSH_TARGET}) H5_SET_LIB_OPTIONS (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} ${H5DIFF_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") #----------------------------------------------------------------------------- diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index ff27d496558..b350444719d 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -434,7 +434,7 @@ macro (ADD_H5_UD_TEST testname resultcode resultfile) if (NOT HDF5_ENABLE_USING_MEMCHECKER) - if (${resultcode} EQUAL 2) + if ("${resultcode}" STREQUAL "2") add_test ( NAME H5DIFF_UD-${testname} COMMAND "${CMAKE_COMMAND}" diff --git a/tools/test/h5dump/CMakeLists.txt b/tools/test/h5dump/CMakeLists.txt index 242465eb575..a7b4846cc29 100644 --- a/tools/test/h5dump/CMakeLists.txt +++ b/tools/test/h5dump/CMakeLists.txt @@ -12,7 +12,7 @@ if (BUILD_SHARED_LIBS) add_library (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_dump.c) target_include_directories (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} SHARED) - target_link_libraries (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + target_link_libraries (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_LIBSH_TARGET}) H5_SET_LIB_OPTIONS (${H5DUMP_TOOL_PLUGIN_LIB_TARGET} ${H5DUMP_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") #----------------------------------------------------------------------------- diff --git a/tools/test/h5dump/CMakeVFDTests.cmake b/tools/test/h5dump/CMakeVFDTests.cmake index 014790f055b..01834b3aa87 100644 --- a/tools/test/h5dump/CMakeVFDTests.cmake +++ b/tools/test/h5dump/CMakeVFDTests.cmake @@ -26,7 +26,7 @@ set (VFD_H5DUMP_LIST family ) -if (DIRECT_VFD) +if (H5_HAVE_DIRECT) set (VFD_H5DUMP_LIST ${VFD_H5DUMP_LIST} direct) endif () diff --git a/tools/test/h5ls/CMakeLists.txt b/tools/test/h5ls/CMakeLists.txt index ee223b83f5f..ba6e4688399 100644 --- a/tools/test/h5ls/CMakeLists.txt +++ b/tools/test/h5ls/CMakeLists.txt @@ -12,7 +12,7 @@ if (BUILD_SHARED_LIBS) add_library (${H5LS_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_ls.c) target_include_directories (${H5LS_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (${H5LS_TOOL_PLUGIN_LIB_TARGET} SHARED) - target_link_libraries (${H5LS_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + target_link_libraries (${H5LS_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_LIBSH_TARGET}) H5_SET_LIB_OPTIONS (${H5LS_TOOL_PLUGIN_LIB_TARGET} ${H5LS_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") #----------------------------------------------------------------------------- diff --git a/tools/test/h5ls/CMakeTests.cmake b/tools/test/h5ls/CMakeTests.cmake index 98435ce8e01..cd2f764b236 100644 --- a/tools/test/h5ls/CMakeTests.cmake +++ b/tools/test/h5ls/CMakeTests.cmake @@ -139,7 +139,7 @@ if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5LS-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") endif () else () @@ -164,7 +164,7 @@ if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5LS-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") endif () else () diff --git a/tools/test/h5ls/CMakeTestsVDS.cmake b/tools/test/h5ls/CMakeTestsVDS.cmake index e8b11bf1455..e93e7e7b278 100644 --- a/tools/test/h5ls/CMakeTestsVDS.cmake +++ b/tools/test/h5ls/CMakeTestsVDS.cmake @@ -85,7 +85,7 @@ if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME H5LS-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) set_tests_properties (H5LS-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") endif () else () @@ -112,7 +112,7 @@ ENVIRONMENT "HDF5_VDS_PREFIX=\${ORIGIN}" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" ) - if (${resultcode} EQUAL 1) + if ("${resultcode}" STREQUAL "1") set_tests_properties (H5LS_PREFIX-${resultfile} PROPERTIES WILL_FAIL "true") endif () else () diff --git a/tools/test/h5repack/CMakeLists.txt b/tools/test/h5repack/CMakeLists.txt index 26db85a4a6f..0b907504b0f 100644 --- a/tools/test/h5repack/CMakeLists.txt +++ b/tools/test/h5repack/CMakeLists.txt @@ -54,13 +54,13 @@ if (BUILD_SHARED_LIBS) add_library (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_rpk.c) target_include_directories (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} SHARED) - target_link_libraries (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + target_link_libraries (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_LIBSH_TARGET}) H5_SET_LIB_OPTIONS (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} ${H5REPACK_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") add_library (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} SHARED dynlib_vrpk.c) target_include_directories (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} SHARED) - target_link_libraries (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + target_link_libraries (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} PRIVATE ${HDF5_LIBSH_TARGET}) H5_SET_LIB_OPTIONS (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} ${H5REPACK_TOOL_PLUGIN_LIB_VNAME} SHARED "LIB") #----------------------------------------------------------------------------- diff --git a/tools/test/h5repack/CMakeVFDTests.cmake b/tools/test/h5repack/CMakeVFDTests.cmake index 27bc1996c83..7eea4cc0833 100644 --- a/tools/test/h5repack/CMakeVFDTests.cmake +++ b/tools/test/h5repack/CMakeVFDTests.cmake @@ -25,7 +25,7 @@ set (VFD_LIST family ) -if (DIRECT_VFD) +if (H5_HAVE_DIRECT) set (VFD_LIST ${VFD_LIST} direct) endif () From ef387ad0ff13f6d4fce6d41e7b31f3373873d791 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Tue, 20 Jul 2021 09:23:39 -0500 Subject: [PATCH 11/13] Squashed commit of the following: commit e2578640fedf671cf11535cf22313dd477da1165 Author: Larry Knox Date: Fri Jul 16 10:57:51 2021 -0500 Merge issue 839 changes to hdf5 1 10 (#841) * Revert addition of & to 2 parameters in DSetCreatPropList::setVirtual to maintain binary compatibility. * Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625) * Removes gratuitous (double)x.yF casts (#632) * Committing clang-format changes * Removes gratuitous (double)x.yF casts * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Cleans up a const warning left over from previous constification (#633) * Committing clang-format changes * Adds consts to a few global variables * Cleans up a const warning left over from previous constification Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Purges UFAIL from the library (#637) * Committing clang-format changes * Purges UFAIL from the library * H5HL_insert change requested in PR Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Bmr dev hdffv 11223 (#640) * Fixed HDFFV-11223 (CVE-2018-14460) Description - Added checks against buffer size to prevent segfault, in case of data corruption, for sdim->size and sdim->max. - Renamed data files in an existing test to shorten their length as agreed with other developers previously. Platforms tested: Linux/64 (jelly) * Committing clang-format changes * Updated for test files * Updated for HDFFV-11223 Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Committing clang-format changes * Restore "error:" in line 2666. * Revert "Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625)" This reverts commit 426b50484841118cf633fd6147302a63a30fd746. * Snapshot version 1.10 release 8-1. Update version to 1.10.8-2. Squashed commit of the following: commit 60734e63fe077238f10de3d6ca8f037f9a42af89 Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Thu Jun 24 14:20:39 2021 -0500 Hdf5 1 10 Fix tools test (#796) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop * Fix cmake configure path * Update missing release note info. * Update code owners * Add known problem * Use only core library for testing dynamic plugins. CMake uses H5_HAVE_DIRECT instead of DIRECT_VFD Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit bfb780a4441e4ef43dd23708d415e5e3b84800f4 Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Wed Jun 23 14:11:46 2021 -0500 Hdf5 1 10 Release Note (#786) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop * Fix cmake configure path * Update missing release note info. * Update code owners * Add known problem Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 9f5040736868f8eec584ab5af6d2a77e4d45ae30 Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Tue Jun 22 07:03:26 2021 -0500 Hdf5 1 10 Update missing release note info. (#778) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop * Fix cmake configure path * Update missing release note info. * Update code owners Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 2e80c9cdec98d6cee5b4609643839a4ad2a848fb Author: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Fri Jun 18 06:42:23 2021 -0700 Brings hash table IDs feature from develop/1.12 (#768) * Brings updated tid test from develop * Adds empty H5Iint.c and H5Idbg.c files * H5I renaming to match 1.12/develop * Splits off H5I debug code to H5Idbg.c * Splits internal H5I.c functionality to H5Iint.c * Header cleanup * More renaming cleanup to match develop/1.12 * Adds "save last ID" optimization * Adds uthash.h * Adds hash table IDs from develop/1.12 * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 1e29bcbfe24956f0158b3363a3fbb8a42c8e7e0f Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Thu Jun 17 11:21:43 2021 -0500 Hdf5 1 10 Fix cmake configure path (#762) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop * Fix cmake configure path Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 475cdaf431c9ef5bfef6243dbc26d0005d08c49d Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Wed Jun 16 15:45:58 2021 -0500 Hdf5 1 10 merge warnings changes (#756) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit e25980e7f35b8508db90648409ba80ee36d61c9e Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Tue Jun 8 14:37:13 2021 -0500 Hdf5 1 10 merges of CMake changes (#738) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 061b23ac0011d3a26f660a7f4d07c40f41d63f10 Author: Larry Knox Date: Thu Jun 3 16:07:23 2021 -0500 Partial merge issue #642 develop branch PRs to Hdf5 1 10 (#718) * Revert addition of & to 2 parameters in DSetCreatPropList::setVirtual to maintain binary compatibility. * Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625) * Removes gratuitous (double)x.yF casts (#632) * Committing clang-format changes * Removes gratuitous (double)x.yF casts * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Cleans up a const warning left over from previous constification (#633) * Committing clang-format changes * Adds consts to a few global variables * Cleans up a const warning left over from previous constification Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Purges UFAIL from the library (#637) * Committing clang-format changes * Purges UFAIL from the library * H5HL_insert change requested in PR Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Bmr dev hdffv 11223 (#640) * Fixed HDFFV-11223 (CVE-2018-14460) Description - Added checks against buffer size to prevent segfault, in case of data corruption, for sdim->size and sdim->max. - Renamed data files in an existing test to shorten their length as agreed with other developers previously. Platforms tested: Linux/64 (jelly) * Committing clang-format changes * Updated for test files * Updated for HDFFV-11223 Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Committing clang-format changes * Restore "error:" in line 2666. * Revert "Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625)" This reverts commit 426b50484841118cf633fd6147302a63a30fd746. Co-authored-by: jhendersonHDF Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> * (fix) Segmentation fault when using a compound type. (#143) * (fix) Segmentation fault when using a compound type. In the case when a compounded attribute is written to dataset followed by writing the data with a data transform function to the dataset will result in a segmentation fault. It turns out the data is classified as compounded while it is not. Now, the state is always reset first to not compounded followed by the existing check if the variable is compounded. * (fix) Removed undesired comment lines. * (fix) Segmentation fault when using a compound type: added test. * (fix) Added the missing cmpd_transform.c file to MANIFEST. * (fix) cmpd_dtransform test: autotools and source header. Added the cmp_dtransform test to the autotools configuration and updated the HDF Group copyright header. Co-authored-by: Jan-Willem Blokland * (fix) H5Z_xform_create function and scientific notation (#144) * (fix) H5Z_xform_create function and scientific notation Implemented a more sophisticated check to support scientific notation in the expression of the H5Zset_data_transform function. * (fix) H5Z_xform_create and scientific notation: Added test. Added a test to demonstrate that the parsing of expression which includes scientific notation works correctly. Improved inline comment. Co-authored-by: Jan-Willem Blokland * Adds const to a few global variables (#623) * Committing clang-format changes * Adds consts to a few global variables Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Made private my_yyinput function static (#618) This prevents it being exported as a public symbol. * Reduces overly-pedantic casting in the public headers (#644) * Committing clang-format changes * Fixes overly pedantic casting in public headers Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Use internal version of H5Eprint2 to avoid possible stack overflow (#661) * Fixes for a couple of trivial warnings (#676) * Committing clang-format changes * Trivial warning fixes: * Removes an unused done target in H5Tbit.c * Add (void) to quiet "ignored return value" warnings in the generators (which generally ignore errors) Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes alternative function enter/leave macro scheme (#678) * Committing clang-format changes * Converted BEGIN_FUNC, etc. macros to FUNC_ENTER * Rips out the BEGIN_FUNC, etc. macros * Removes 'end if', etc. comments from H5HL package * Committing clang-format changes * Fixes an H5EA iterate issue * Fixes an issue in the H5FA iterator code * Further cleanup in bin/trace after macro removal * Iterator changes in H5EA and H5FA Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Various CMake changes (#679) * Committing clang-format changes * Several CMake updates: * Removes unused HDF5_ENABLE_HSIZET * Switches TEST_SHELL_SCRIPTS to ON * Sets SH_PROGRAM to bash instead of sh * Set default build type back to RelWithDebInfo Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Revert "Removes alternative function enter/leave macro scheme (#678)" This reverts commit edddb11b791adbdcaafed3ba718c95dd349a4e9a. * err_compat test cleanup (#681) * Committing clang-format changes * Cleans up err_compat test and output * Formatted source Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Sets the memory alloc sanity check option to disabled in autotools (#686) * Revert "Sets the memory alloc sanity check option to disabled in autotools (#686)" This reverts commit 652ffca58699388fff960c6a92c8ecfd1fc5d19b. (Only for release branch). * Removes alternative function enter/leave macro scheme (#678) * Committing clang-format changes * Converted BEGIN_FUNC, etc. macros to FUNC_ENTER * Rips out the BEGIN_FUNC, etc. macros * Removes 'end if', etc. comments from H5HL package * Committing clang-format changes * Fixes an H5EA iterate issue * Fixes an issue in the H5FA iterator code * Further cleanup in bin/trace after macro removal * Iterator changes in H5EA and H5FA Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Committing clang-format changes Co-authored-by: jhendersonHDF Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> Co-authored-by: Jan-Willem Blokland Co-authored-by: Jan-Willem Blokland Co-authored-by: Sean McBride commit 14794490ec522fbd3ac2faa6efa0920979490fbc Author: Larry Knox Date: Wed Jul 14 13:50:26 2021 -0500 Update version to 1.10.8-2 after snapshot release of 1.10.8-1 (#838) * Revert addition of & to 2 parameters in DSetCreatPropList::setVirtual to maintain binary compatibility. * Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625) * Removes gratuitous (double)x.yF casts (#632) * Committing clang-format changes * Removes gratuitous (double)x.yF casts * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Cleans up a const warning left over from previous constification (#633) * Committing clang-format changes * Adds consts to a few global variables * Cleans up a const warning left over from previous constification Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Purges UFAIL from the library (#637) * Committing clang-format changes * Purges UFAIL from the library * H5HL_insert change requested in PR Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Bmr dev hdffv 11223 (#640) * Fixed HDFFV-11223 (CVE-2018-14460) Description - Added checks against buffer size to prevent segfault, in case of data corruption, for sdim->size and sdim->max. - Renamed data files in an existing test to shorten their length as agreed with other developers previously. Platforms tested: Linux/64 (jelly) * Committing clang-format changes * Updated for test files * Updated for HDFFV-11223 Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Committing clang-format changes * Restore "error:" in line 2666. * Revert "Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625)" This reverts commit 426b50484841118cf633fd6147302a63a30fd746. * Snapshot version 1.10 release 8-1. Update version to 1.10.8-2. Squashed commit of the following: commit 60734e63fe077238f10de3d6ca8f037f9a42af89 Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Thu Jun 24 14:20:39 2021 -0500 Hdf5 1 10 Fix tools test (#796) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop * Fix cmake configure path * Update missing release note info. * Update code owners * Add known problem * Use only core library for testing dynamic plugins. CMake uses H5_HAVE_DIRECT instead of DIRECT_VFD Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit bfb780a4441e4ef43dd23708d415e5e3b84800f4 Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Wed Jun 23 14:11:46 2021 -0500 Hdf5 1 10 Release Note (#786) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop * Fix cmake configure path * Update missing release note info. * Update code owners * Add known problem Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 9f5040736868f8eec584ab5af6d2a77e4d45ae30 Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Tue Jun 22 07:03:26 2021 -0500 Hdf5 1 10 Update missing release note info. (#778) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop * Fix cmake configure path * Update missing release note info. * Update code owners Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 2e80c9cdec98d6cee5b4609643839a4ad2a848fb Author: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Fri Jun 18 06:42:23 2021 -0700 Brings hash table IDs feature from develop/1.12 (#768) * Brings updated tid test from develop * Adds empty H5Iint.c and H5Idbg.c files * H5I renaming to match 1.12/develop * Splits off H5I debug code to H5Idbg.c * Splits internal H5I.c functionality to H5Iint.c * Header cleanup * More renaming cleanup to match develop/1.12 * Adds "save last ID" optimization * Adds uthash.h * Adds hash table IDs from develop/1.12 * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 1e29bcbfe24956f0158b3363a3fbb8a42c8e7e0f Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Thu Jun 17 11:21:43 2021 -0500 Hdf5 1 10 Fix cmake configure path (#762) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop * Fix cmake configure path Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 475cdaf431c9ef5bfef6243dbc26d0005d08c49d Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Wed Jun 16 15:45:58 2021 -0500 Hdf5 1 10 merge warnings changes (#756) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args * Merge warnings files fixes from develop Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit e25980e7f35b8508db90648409ba80ee36d61c9e Author: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Tue Jun 8 14:37:13 2021 -0500 Hdf5 1 10 merges of CMake changes (#738) * HDFFV-10865 - merge from dev, HDFArray perf fix. * Remove duplicate setting * Whitespace changes after clang format * Undo version 11 clang format changes * Merge CMake changes from develop * test testing script merge from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge small changes from develop * Minor non-space formatting changes * #386 copyright corrections for java folder * Merges from develop #358 patches from vtk #361 fix header guard spelling * Merge updates #358 patches from vtk #361 fix header guard spelling * format fix * Fix missing underscore and make H5public.h closer to dev * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings header guard underscore cleanup JNI cleanup * format alignment * Add missing test ref file * Merge #380 from develop * Finish java merges from develop * Fix java issues with tests and javadoc * Correct use of attribute access plist * Remove debug code * Remove unused variable * Change file access to read only for java tests * Split clang format operations. * More javadoc comments * Remove pre-split setting * format source * Change windows TS to use older VS. * Mostly all javadoc fixes, one argument rename. * synch file * Merge of long double fix and compiler flags * HDFFV-11229 merge changes from develop * HDFFV-11229 correct test script * HDFFV-11229 update autotools test script for two ref files * HDFFV-11229 merge dev changes for long double display in tools * Committing clang-format changes * minor whitespace * remove unneeded macro * Committing clang-format changes * Add "option" command for clang options * Rework CMake add_custom to use the BYPRODUCTS argument Update pkgconfig scripts for parallel builds. Fix install COPYING file reference. Remove unused round defines. Change CMake default setting of BUILD_CPP to off. * Fortran target depends * Remove incorrect source attribute * Revert define removal * printf specifiers and VS2015 min changes * Committing clang-format changes * Add time struct * TRILAB-227 and tools debug merges from develop * Merge various changes from dev * Issue #669 remove version from pkgcfg filename * remove version from h5cc script * doxygen changes merged from develop * Committing clang-format changes * Merge CMake fortran ninja changes from dev * Enable fortran to gcc yaml * Refactor Fortran CMake config tests and CMake test args Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> commit 061b23ac0011d3a26f660a7f4d07c40f41d63f10 Author: Larry Knox Date: Thu Jun 3 16:07:23 2021 -0500 Partial merge issue #642 develop branch PRs to Hdf5 1 10 (#718) * Revert addition of & to 2 parameters in DSetCreatPropList::setVirtual to maintain binary compatibility. * Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625) * Removes gratuitous (double)x.yF casts (#632) * Committing clang-format changes * Removes gratuitous (double)x.yF casts * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Cleans up a const warning left over from previous constification (#633) * Committing clang-format changes * Adds consts to a few global variables * Cleans up a const warning left over from previous constification Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Purges UFAIL from the library (#637) * Committing clang-format changes * Purges UFAIL from the library * H5HL_insert change requested in PR Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Bmr dev hdffv 11223 (#640) * Fixed HDFFV-11223 (CVE-2018-14460) Description - Added checks against buffer size to prevent segfault, in case of data corruption, for sdim->size and sdim->max. - Renamed data files in an existing test to shorten their length as agreed with other developers previously. Platforms tested: Linux/64 (jelly) * Committing clang-format changes * Updated for test files * Updated for HDFFV-11223 Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Committing clang-format changes * Restore "error:" in line 2666. * Revert "Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625)" This reverts commit 426b50484841118cf633fd6147302a63a30fd746. Co-authored-by: jhendersonHDF Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> Co-authored-by: jhendersonHDF Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> --- MANIFEST | 1 + config/cmake/ConfigureChecks.cmake | 8 - hl/src/H5LTanalyze.c | 4 +- hl/src/H5LTanalyze.l | 4 +- release_docs/INSTALL_CMake.txt | 4 +- release_docs/RELEASE.txt | 16 + src/H5.c | 4 - src/H5Clog_json.c | 52 +-- src/H5Clog_trace.c | 52 +-- src/H5Dpublic.h | 16 +- src/H5E.c | 35 +- src/H5EA.c | 410 +++++++++-------- src/H5EAcache.c | 699 ++++++++++++++++------------- src/H5EAdbg.c | 145 +++--- src/H5EAdblkpage.c | 126 +++--- src/H5EAdblock.c | 177 +++++--- src/H5EAhdr.c | 317 ++++++++----- src/H5EAiblock.c | 169 ++++--- src/H5EAint.c | 32 +- src/H5EAsblock.c | 164 ++++--- src/H5EAstat.c | 14 +- src/H5EAtest.c | 183 ++++---- src/H5Eprivate.h | 47 -- src/H5Epublic.h | 2 +- src/H5FA.c | 337 +++++++------- src/H5FAcache.c | 398 +++++++++------- src/H5FAdbg.c | 79 ++-- src/H5FAdblkpage.c | 121 +++-- src/H5FAdblock.c | 155 ++++--- src/H5FAhdr.c | 263 ++++++----- src/H5FAint.c | 32 +- src/H5FAstat.c | 14 +- src/H5FAtest.c | 129 +++--- src/H5Fpublic.h | 4 +- src/H5HL.c | 390 +++++++++------- src/H5HLcache.c | 24 +- src/H5HLdbg.c | 28 +- src/H5HLdblk.c | 82 ++-- src/H5HLint.c | 60 ++- src/H5HLpkg.h | 2 +- src/H5HLprfx.c | 33 +- src/H5HLprivate.h | 2 +- src/H5Lpublic.h | 4 +- src/H5MF.c | 14 +- src/H5MFpkg.h | 6 +- src/H5MFsection.c | 6 +- src/H5Ppublic.h | 2 +- src/H5Spublic.h | 2 +- src/H5T.c | 25 +- src/H5Tbit.c | 1 - src/H5Tpublic.h | 2 +- src/H5Ztrans.c | 42 +- src/H5private.h | 243 +--------- test/CMakeLists.txt | 1 + test/CMakeTests.cmake | 2 +- test/Makefile.am | 2 +- test/ShellTests.cmake | 2 +- test/cmpd_dtransform.c | 136 ++++++ test/dtransform.c | 24 + test/err_compat.c | 273 +++++------ test/error_test.c | 2 +- test/testfiles/err_compat_1 | 12 +- tools/lib/h5tools_error.h | 26 +- tools/test/h5jam/h5jamgentest.c | 6 +- tools/test/h5stat/h5stat_gentest.c | 2 +- 65 files changed, 3159 insertions(+), 2510 deletions(-) create mode 100644 test/cmpd_dtransform.c diff --git a/MANIFEST b/MANIFEST index 2c86f7ed257..ce941e653b9 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1114,6 +1114,7 @@ ./test/cache_tagging.c ./test/chunk_info.c ./test/cmpd_dset.c +./test/cmpd_dtransform.c ./test/cork.c ./test/corrupt_stab_msg.h5 ./test/cross_read.c diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 1ded895cd77..87b20066863 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -86,14 +86,6 @@ else () set (HDF5_FILE_LOCKING_SETTING "no") endif () -#----------------------------------------------------------------------------- -# Are we going to use HSIZE_T -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_HSIZET "Enable datasets larger than memory" ON) -if (HDF5_ENABLE_HSIZET) - set (${HDF_PREFIX}_HAVE_LARGE_HSIZET 1) -endif () - # so far we have no check for this set (${HDF_PREFIX}_HAVE_TMPFILE 1) diff --git a/hl/src/H5LTanalyze.c b/hl/src/H5LTanalyze.c index 65da9d03df7..875a37a9eed 100644 --- a/hl/src/H5LTanalyze.c +++ b/hl/src/H5LTanalyze.c @@ -916,7 +916,7 @@ char *yytext; #include "H5LTparse.h" static char *trim_quotes(const char *); -int my_yyinput(char *, int); +static int my_yyinput(char *, int); #undef YY_INPUT #define YY_INPUT(b, r, ms) (r=my_yyinput(b, ms)) #define token(x) (int)x @@ -2554,7 +2554,7 @@ trim_quotes(const char *quoted) return trimmed; } -int my_yyinput(char *buf, int max_size) +static int my_yyinput(char *buf, int max_size) { int ret; diff --git a/hl/src/H5LTanalyze.l b/hl/src/H5LTanalyze.l index fd1cbe59d6b..50066126fbf 100644 --- a/hl/src/H5LTanalyze.l +++ b/hl/src/H5LTanalyze.l @@ -27,7 +27,7 @@ #include "H5LTparse.h" static char *trim_quotes(const char *); -int my_yyinput(char *, int); +static int my_yyinput(char *, int); #undef YY_INPUT #define YY_INPUT(b, r, ms) (r=my_yyinput(b, ms)) #define token(x) (int)x @@ -144,7 +144,7 @@ trim_quotes(const char *quoted) return trimmed; } -int my_yyinput(char *buf, int max_size) +static int my_yyinput(char *buf, int max_size) { int ret; diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt index bb5fb3f9108..aa28939e2ca 100644 --- a/release_docs/INSTALL_CMake.txt +++ b/release_docs/INSTALL_CMake.txt @@ -753,7 +753,6 @@ HDF5_ENABLE_DEBUG_APIS "Turn on extra debug output in all packages" HDF5_ENABLE_DEPRECATED_SYMBOLS "Enable deprecated public API symbols" ON HDF5_ENABLE_DIRECT_VFD "Build the Direct I/O Virtual File Driver" OFF HDF5_ENABLE_EMBEDDED_LIBINFO "embed library info into executables" ON -HDF5_ENABLE_HSIZET "Enable datasets larger than memory" ON HDF5_ENABLE_PARALLEL "Enable parallel build (requires MPI)" OFF HDF5_ENABLE_PREADWRITE "Use pread/pwrite in sec2/log/core VFDs in place of read/write (when available)" ON HDF5_ENABLE_TRACE "Enable API tracing capability" OFF @@ -795,8 +794,7 @@ HDF5_BUILD_DOC "Build documentation" HDF5_ENABLE_ANALYZER_TOOLS "enable the use of Clang tools" OFF HDF5_ENABLE_SANITIZERS "execute the Clang sanitizer" OFF HDF5_ENABLE_FORMATTERS "format source files" OFF -HDF5_USE_FILE_LOCKING "Use file locking by default (mainly for SWMR)" ON -HDF5_IGNORE_DISABLED_FILE_LOCKS "Ignore file locks when disabled on file system" ON +TEST_SHELL_SCRIPTS "Enable shell script tests" ON ---------------- External Library Options --------------------- HDF5_ALLOW_EXTERNAL_SUPPORT "Allow External Library Building (NO GIT TGZ)" "NO" diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index a250a15f7e1..4c8fe0a9f20 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -73,6 +73,22 @@ New Features (DER - 2021/06/02) + - CMake will now run the shell script tests in test/ by default + + The test directory includes several shell script tests that previously + were not run by CMake. These are now run by default. TEST_SHELL_SCRIPTS + has been set to ON and SH_PROGRAM has been set to bash (some test + scripts use bash-isms). Platforms without bash (e.g., Windows) will + ignore the script tests. + + (DER - 2021/05/23) + + - Removed unused HDF5_ENABLE_HSIZET option from CMake + + This has been unused for some time and has no effect. + + (DER - 2021/05/23) + - CMake no longer builds the C++ library by default HDF5_BUILD_CPP_LIB now defaults to OFF, which is in line with the diff --git a/src/H5.c b/src/H5.c index b69544f89bc..17afafeb6af 100644 --- a/src/H5.c +++ b/src/H5.c @@ -63,10 +63,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Library Private Variables */ /*****************************/ -/* HDF5 API Entered variable */ -/* (move to H5.c when new FUNC_ENTER macros in actual use -QAK) */ -hbool_t H5_api_entered_g = FALSE; - /* statically initialize block for pthread_once call used in initializing */ /* the first global mutex */ #ifdef H5_HAVE_THREADSAFE diff --git a/src/H5Clog_json.c b/src/H5Clog_json.c index 731d741d650..18323ca74e9 100644 --- a/src/H5Clog_json.c +++ b/src/H5Clog_json.c @@ -118,32 +118,32 @@ static herr_t H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_ /* Note that there's no cache set up call since that's the * place where this struct is wired into the cache. */ -static H5C_log_class_t H5C_json_log_class_g = {"json", - H5C__json_tear_down_logging, - NULL, /* start logging */ - NULL, /* stop logging */ - H5C__json_write_start_log_msg, - H5C__json_write_stop_log_msg, - H5C__json_write_create_cache_log_msg, - H5C__json_write_destroy_cache_log_msg, - H5C__json_write_evict_cache_log_msg, - H5C__json_write_expunge_entry_log_msg, - H5C__json_write_flush_cache_log_msg, - H5C__json_write_insert_entry_log_msg, - H5C__json_write_mark_entry_dirty_log_msg, - H5C__json_write_mark_entry_clean_log_msg, - H5C__json_write_mark_unserialized_entry_log_msg, - H5C__json_write_mark_serialized_entry_log_msg, - H5C__json_write_move_entry_log_msg, - H5C__json_write_pin_entry_log_msg, - H5C__json_write_create_fd_log_msg, - H5C__json_write_protect_entry_log_msg, - H5C__json_write_resize_entry_log_msg, - H5C__json_write_unpin_entry_log_msg, - H5C__json_write_destroy_fd_log_msg, - H5C__json_write_unprotect_entry_log_msg, - H5C__json_write_set_cache_config_log_msg, - H5C__json_write_remove_entry_log_msg}; +static const H5C_log_class_t H5C_json_log_class_g = {"json", + H5C__json_tear_down_logging, + NULL, /* start logging */ + NULL, /* stop logging */ + H5C__json_write_start_log_msg, + H5C__json_write_stop_log_msg, + H5C__json_write_create_cache_log_msg, + H5C__json_write_destroy_cache_log_msg, + H5C__json_write_evict_cache_log_msg, + H5C__json_write_expunge_entry_log_msg, + H5C__json_write_flush_cache_log_msg, + H5C__json_write_insert_entry_log_msg, + H5C__json_write_mark_entry_dirty_log_msg, + H5C__json_write_mark_entry_clean_log_msg, + H5C__json_write_mark_unserialized_entry_log_msg, + H5C__json_write_mark_serialized_entry_log_msg, + H5C__json_write_move_entry_log_msg, + H5C__json_write_pin_entry_log_msg, + H5C__json_write_create_fd_log_msg, + H5C__json_write_protect_entry_log_msg, + H5C__json_write_resize_entry_log_msg, + H5C__json_write_unpin_entry_log_msg, + H5C__json_write_destroy_fd_log_msg, + H5C__json_write_unprotect_entry_log_msg, + H5C__json_write_set_cache_config_log_msg, + H5C__json_write_remove_entry_log_msg}; /*------------------------------------------------------------------------- * Function: H5C__json_write_log_message diff --git a/src/H5Clog_trace.c b/src/H5Clog_trace.c index c30f79e3e6a..d33d1b05a65 100644 --- a/src/H5Clog_trace.c +++ b/src/H5Clog_trace.c @@ -113,32 +113,32 @@ static herr_t H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache /* Note that there's no cache set up call since that's the * place where this struct is wired into the cache. */ -static H5C_log_class_t H5C_trace_log_class_g = {"trace", - H5C__trace_tear_down_logging, - NULL, /* start logging */ - NULL, /* stop logging */ - NULL, /* write start message */ - NULL, /* write stop message */ - NULL, /* write create cache message */ - NULL, /* write destroy cache message */ - NULL, /* write evict cache message */ - H5C__trace_write_expunge_entry_log_msg, - H5C__trace_write_flush_cache_log_msg, - H5C__trace_write_insert_entry_log_msg, - H5C__trace_write_mark_entry_dirty_log_msg, - H5C__trace_write_mark_entry_clean_log_msg, - H5C__trace_write_mark_unserialized_entry_log_msg, - H5C__trace_write_mark_serialized_entry_log_msg, - H5C__trace_write_move_entry_log_msg, - H5C__trace_write_pin_entry_log_msg, - H5C__trace_write_create_fd_log_msg, - H5C__trace_write_protect_entry_log_msg, - H5C__trace_write_resize_entry_log_msg, - H5C__trace_write_unpin_entry_log_msg, - H5C__trace_write_destroy_fd_log_msg, - H5C__trace_write_unprotect_entry_log_msg, - H5C__trace_write_set_cache_config_log_msg, - H5C__trace_write_remove_entry_log_msg}; +static const H5C_log_class_t H5C_trace_log_class_g = {"trace", + H5C__trace_tear_down_logging, + NULL, /* start logging */ + NULL, /* stop logging */ + NULL, /* write start message */ + NULL, /* write stop message */ + NULL, /* write create cache message */ + NULL, /* write destroy cache message */ + NULL, /* write evict cache message */ + H5C__trace_write_expunge_entry_log_msg, + H5C__trace_write_flush_cache_log_msg, + H5C__trace_write_insert_entry_log_msg, + H5C__trace_write_mark_entry_dirty_log_msg, + H5C__trace_write_mark_entry_clean_log_msg, + H5C__trace_write_mark_unserialized_entry_log_msg, + H5C__trace_write_mark_serialized_entry_log_msg, + H5C__trace_write_move_entry_log_msg, + H5C__trace_write_pin_entry_log_msg, + H5C__trace_write_create_fd_log_msg, + H5C__trace_write_protect_entry_log_msg, + H5C__trace_write_resize_entry_log_msg, + H5C__trace_write_unpin_entry_log_msg, + H5C__trace_write_destroy_fd_log_msg, + H5C__trace_write_unprotect_entry_log_msg, + H5C__trace_write_set_cache_config_log_msg, + H5C__trace_write_remove_entry_log_msg}; /*------------------------------------------------------------------------- * Function: H5C__trace_write_log_message diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index c4f4bc3c9ef..16abaead126 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -28,9 +28,9 @@ /*****************/ /* Macros used to "unset" chunk cache configuration parameters */ -#define H5D_CHUNK_CACHE_NSLOTS_DEFAULT ((size_t)-1) -#define H5D_CHUNK_CACHE_NBYTES_DEFAULT ((size_t)-1) -#define H5D_CHUNK_CACHE_W0_DEFAULT (-1.0f) +#define H5D_CHUNK_CACHE_NSLOTS_DEFAULT SIZE_MAX +#define H5D_CHUNK_CACHE_NBYTES_DEFAULT SIZE_MAX +#define H5D_CHUNK_CACHE_W0_DEFAULT (-1.0) /* Bit flags for the H5Pset_chunk_opts() and H5Pget_chunk_opts() */ #define H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS (0x0002u) @@ -46,11 +46,11 @@ typedef enum H5D_layout_t { H5D_LAYOUT_ERROR = -1, - H5D_COMPACT = 0, /**< raw data is very small */ - H5D_CONTIGUOUS = 1, /**< the default */ - H5D_CHUNKED = 2, /**< slow and fancy */ - H5D_VIRTUAL = 3, /**< actual data is stored in other datasets */ - H5D_NLAYOUTS = 4 /**< this one must be last! */ + H5D_COMPACT = 0, /**< raw data is very small */ + H5D_CONTIGUOUS = 1, /**< the default */ + H5D_CHUNKED = 2, /**< slow and fancy */ + H5D_VIRTUAL = 3, /**< actual data is stored in other datasets */ + H5D_NLAYOUTS = 4 /**< this one must be last! */ } H5D_layout_t; //! diff --git a/src/H5E.c b/src/H5E.c index da75edeb28f..8da4a2b6771 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -85,6 +85,7 @@ static H5E_t * H5E__get_current_stack(void); static herr_t H5E__set_current_stack(H5E_t *estack); static herr_t H5E__close_stack(H5E_t *err_stack); static ssize_t H5E__get_num(const H5E_t *err_stack); +static herr_t H5E__print2(hid_t err_stack, FILE *stream); /*********************/ /* Package Variables */ @@ -311,10 +312,10 @@ H5E__set_default_auto(H5E_t *stk) #endif /* H5_USE_16_API_DEFAULT */ stk->auto_op.func1 = stk->auto_op.func1_default = (H5E_auto1_t)H5Eprint1; - stk->auto_op.func2 = stk->auto_op.func2_default = (H5E_auto2_t)H5Eprint2; + stk->auto_op.func2 = stk->auto_op.func2_default = (H5E_auto2_t)H5E__print2; stk->auto_op.is_default = TRUE; #else /* H5_NO_DEPRECATED_SYMBOLS */ - stk->auto_op.func2 = (H5E_auto2_t)H5Eprint2; + stk->auto_op.func2 = (H5E_auto2_t)H5E__print2; #endif /* H5_NO_DEPRECATED_SYMBOLS */ stk->auto_data = NULL; @@ -1462,13 +1463,37 @@ H5Eclear2(hid_t err_stack) herr_t H5Eprint2(hid_t err_stack, FILE *stream) { - H5E_t *estack; /* Error stack to operate on */ herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) /*NO TRACE*/ + /* Print error stack */ + if ((ret_value = H5E__print2(err_stack, stream)) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Eprint2() */ + +/*------------------------------------------------------------------------- + * Function: H5E__print2 + * + * Purpose: Internal helper routine for H5Eprint2. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5E__print2(hid_t err_stack, FILE *stream) +{ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + /* Need to check for errors */ if (err_stack == H5E_DEFAULT) { if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in @@ -1488,8 +1513,8 @@ H5Eprint2(hid_t err_stack, FILE *stream) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") done: - FUNC_LEAVE_API(ret_value) -} /* end H5Eprint2() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E__print2() */ /*------------------------------------------------------------------------- * Function: H5Ewalk2 diff --git a/src/H5EA.c b/src/H5EA.c index 4d6b7c1167f..8f9a4b61cac 100644 --- a/src/H5EA.c +++ b/src/H5EA.c @@ -116,39 +116,40 @@ H5FL_BLK_DEFINE(ea_native_elmt); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, H5EA_t *, NULL, NULL, - H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata)) +static H5EA_t * +H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata) +{ + H5EA_t * ea = NULL; /* Pointer to new extensible array */ + H5EA_hdr_t *hdr = NULL; /* The extensible array header information */ + H5EA_t * ret_value = NULL; - /* Local variables */ - H5EA_t * ea = NULL; /* Pointer to new extensible array */ - H5EA_hdr_t *hdr = NULL; /* The extensible array header information */ + FUNC_ENTER_STATIC - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(ea_addr)); /* Allocate extensible array wrapper */ if (NULL == (ea = H5FL_CALLOC(H5EA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array info") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for extensible array info") /* Lock the array header into memory */ if (NULL == (hdr = H5EA__hdr_protect(f, ea_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, "unable to load extensible array header") /* Check for pending array deletion */ if (from_open && hdr->pending_delete) - H5E_THROW(H5E_CANTOPENOBJ, "can't open extensible array pending deletion") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTOPENOBJ, NULL, "can't open extensible array pending deletion") /* Point extensible array wrapper at header and bump it's ref count */ ea->hdr = hdr; if (H5EA__hdr_incr(ea->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") /* Increment # of files using this array header */ if (H5EA__hdr_fuse_incr(ea->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, + "can't increment file reference count on shared array header") /* Set file pointer for this array open context */ ea->f = f; @@ -156,15 +157,16 @@ BEGIN_FUNC(STATIC, ERR, H5EA_t *, NULL, NULL, /* Set the return value */ ret_value = ea; - CATCH +done: if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, "unable to release extensible array header") if (!ret_value) if (ea && H5EA_close(ea) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") + HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array") -END_FUNC(STATIC) /* end H5EA__new() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__new() */ /*------------------------------------------------------------------------- * Function: H5EA_create @@ -179,16 +181,16 @@ END_FUNC(STATIC) /* end H5EA__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, - H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) - - /* Local variables */ +H5EA_t * +H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata) +{ H5EA_t *ea = NULL; /* Pointer to new extensible array */ haddr_t ea_addr; /* Array header address */ + H5EA_t *ret_value = NULL; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ HDassert(f); HDassert(cparam); @@ -197,22 +199,23 @@ BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, /* Create extensible array header */ if (HADDR_UNDEF == (ea_addr = H5EA__hdr_create(f, cparam, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "can't create extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, "can't create extensible array header") /* Allocate and initialize new extensible array wrapper */ if (NULL == (ea = H5EA__new(f, ea_addr, FALSE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for extensible array wrapper") /* Set the return value */ ret_value = ea; - CATCH - +done: if (!ret_value) if (ea && H5EA_close(ea) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") + HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array") -END_FUNC(PRIV) /* end H5EA_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_create() */ /*------------------------------------------------------------------------- * Function: H5EA_open @@ -227,31 +230,33 @@ END_FUNC(PRIV) /* end H5EA_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) +H5EA_t * +H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata) +{ + H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */ + H5EA_t *ret_value = NULL; - /* Local variables */ - H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */ + FUNC_ENTER_NOAPI(NULL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(ea_addr)); /* Allocate and initialize new extensible array wrapper */ if (NULL == (ea = H5EA__new(f, ea_addr, TRUE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for extensible array wrapper") /* Set the return value */ ret_value = ea; - CATCH - +done: if (!ret_value) if (ea && H5EA_close(ea) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") + HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array") -END_FUNC(PRIV) /* end H5EA_open() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_open() */ /*------------------------------------------------------------------------- * Function: H5EA_get_nelmts @@ -265,20 +270,20 @@ END_FUNC(PRIV) /* end H5EA_open() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts)) - - /* Local variables */ +herr_t +H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(nelmts); /* Retrieve the max. index set */ *nelmts = ea->hdr->stats.stored.max_idx_set; -END_FUNC(PRIV) /* end H5EA_get_nelmts() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA_get_nelmts() */ /*------------------------------------------------------------------------- * Function: H5EA_get_addr @@ -292,13 +297,12 @@ END_FUNC(PRIV) /* end H5EA_get_nelmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_addr(const H5EA_t *ea, haddr_t *addr)) - - /* Local variables */ +herr_t +H5EA_get_addr(const H5EA_t *ea, haddr_t *addr) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(ea->hdr); HDassert(addr); @@ -306,7 +310,8 @@ BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_addr(const H5EA_t *ea, hadd /* Retrieve the address of the extensible array's header */ *addr = ea->hdr->addr; -END_FUNC(PRIV) /* end H5EA_get_addr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA_get_addr() */ /*------------------------------------------------------------------------- * Function: H5EA__lookup_elmt @@ -321,12 +326,11 @@ END_FUNC(PRIV) /* end H5EA_get_addr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned thing_acc, - void **thing, uint8_t **thing_elmt_buf, hsize_t *thing_elmt_idx, - H5EA__unprotect_func_t *thing_unprot_func)) - - /* Local variables */ +static herr_t +H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned thing_acc, void **thing, + uint8_t **thing_elmt_buf, hsize_t *thing_elmt_idx, + H5EA__unprotect_func_t *thing_unprot_func) +{ H5EA_hdr_t * hdr = ea->hdr; /* Header for EA */ H5EA_iblock_t * iblock = NULL; /* Pointer to index block for EA */ H5EA_sblock_t * sblock = NULL; /* Pointer to super block for EA */ @@ -336,10 +340,11 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, unsigned sblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting super block */ hbool_t stats_changed = FALSE; /* Whether array statistics changed */ hbool_t hdr_dirty = FALSE; /* Whether the array header changed */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_STATIC + + /* Check arguments */ HDassert(ea); HDassert(hdr); HDassert(thing); @@ -365,17 +370,18 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Create the index block */ hdr->idx_blk_addr = H5EA__iblock_create(hdr, &stats_changed); if (!H5F_addr_defined(hdr->idx_blk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, "unable to create index block") hdr_dirty = TRUE; } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Protect index block */ if (NULL == (iblock = H5EA__iblock_protect(hdr, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", - (unsigned long long)hdr->idx_blk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Check if element is in index block */ if (idx < hdr->cparam.idx_blk_elmts) { @@ -416,21 +422,23 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, dblk_addr = H5EA__dblock_create(hdr, iblock, &stats_changed, dblk_off, hdr->sblk_info[sblk_idx].dblk_nelmts); if (!H5F_addr_defined(dblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, + "unable to create extensible array data block") /* Set data block address in index block */ iblock->dblk_addrs[dblk_idx] = dblk_addr; iblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Protect data block */ if (NULL == (dblock = H5EA__dblock_protect(hdr, iblock, iblock->dblk_addrs[dblk_idx], hdr->sblk_info[sblk_idx].dblk_nelmts, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", - (unsigned long long)iblock->dblk_addrs[dblk_idx]) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)iblock->dblk_addrs[dblk_idx]) /* Adjust index to offset in data block */ elmt_idx %= hdr->sblk_info[sblk_idx].dblk_nelmts; @@ -438,9 +446,10 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Check if there is already a dependency on the header */ if (will_extend && !dblock->has_hdr_depend) { if (H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTDEPEND, - "unable to create flush dependency between data block and header, index = %llu", - (unsigned long long)idx) + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between data block and header, index = %llu", + (unsigned long long)idx) dblock->has_hdr_depend = TRUE; } /* end if */ @@ -465,21 +474,23 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Create super block */ sblk_addr = H5EA__sblock_create(hdr, iblock, &stats_changed, sblk_idx); if (!H5F_addr_defined(sblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, + "unable to create extensible array super block") /* Set super block address in index block */ iblock->sblk_addrs[sblk_off] = sblk_addr; iblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Protect super block */ if (NULL == (sblock = H5EA__sblock_protect(hdr, iblock, iblock->sblk_addrs[sblk_off], sblk_idx, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", - (unsigned long long)iblock->sblk_addrs[sblk_off]) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array super block, address = %llu", + (unsigned long long)iblock->sblk_addrs[sblk_off]) /* Compute the data block index in super block */ dblk_idx = (size_t)(elmt_idx / sblock->dblk_nelmts); @@ -498,7 +509,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, dblk_addr = H5EA__dblock_create(hdr, sblock, &stats_changed, dblk_off, sblock->dblk_nelmts); if (!H5F_addr_defined(dblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, + "unable to create extensible array data block") /* Set data block address in index block */ sblock->dblk_addrs[dblk_idx] = dblk_addr; @@ -508,8 +520,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, */ if (will_extend && !sblock->has_hdr_depend) { if (H5EA__create_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between super block and header, address " "= %llu", (unsigned long long)sblock->addr) @@ -517,7 +529,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, } /* end if */ } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Adjust index to offset in data block */ @@ -548,29 +560,29 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, if (0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ /* Create the data block page */ if (H5EA__dblk_page_create(hdr, sblock, dblk_page_addr) < 0) - H5E_THROW(H5E_CANTCREATE, "unable to create data block page") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, "unable to create data block page") /* Mark data block page as initialized in super block */ H5VM_bit_set(sblock->page_init, page_init_idx, TRUE); sblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Protect data block page */ if (NULL == (dblk_page = H5EA__dblk_page_protect(hdr, sblock, dblk_page_addr, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, - "unable to protect extensible array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Check if there is already a dependency on the header */ if (will_extend && !dblk_page->has_hdr_depend) { if (H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTDEPEND, - "unable to create flush dependency between data block page and header, " - "index = %llu", - (unsigned long long)idx) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between data block page and header, " + "index = %llu", + (unsigned long long)idx) dblk_page->has_hdr_depend = TRUE; } /* end if */ @@ -584,15 +596,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Protect data block */ if (NULL == (dblock = H5EA__dblock_protect(hdr, sblock, sblock->dblk_addrs[dblk_idx], sblock->dblk_nelmts, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, - "unable to protect extensible array data block, address = %llu", - (unsigned long long)sblock->dblk_addrs[dblk_idx]) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)sblock->dblk_addrs[dblk_idx]) /* Check if there is already a dependency on the header */ if (will_extend && !dblock->has_hdr_depend) { if (H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between data block and header, index = %llu", (unsigned long long)idx) dblock->has_hdr_depend = TRUE; @@ -611,7 +623,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, HDassert(*thing != NULL); HDassert(*thing_unprot_func != NULL); - CATCH +done: /* Reset 'thing' info on error */ if (ret_value < 0) { *thing = NULL; @@ -627,20 +639,22 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Check for header modified */ if (hdr_dirty) if (H5EA__hdr_modified(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as modified") + HDONE_ERROR(H5E_EARRAY, H5E_CANTMARKDIRTY, FAIL, + "unable to mark extensible array header as modified") /* Release resources */ if (iblock && *thing != iblock && H5EA__iblock_unprotect(iblock, iblock_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block") /* (Note: super blocks don't contain elements, so don't have a '*thing != sblock' check) */ if (sblock && H5EA__sblock_unprotect(sblock, sblock_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block") if (dblock && *thing != dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block") if (dblk_page && *thing != dblk_page && H5EA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block page") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block page") -END_FUNC(STATIC) /* end H5EA__lookup_elmt() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__lookup_elmt() */ /*------------------------------------------------------------------------- * Function: H5EA_set @@ -654,9 +668,9 @@ END_FUNC(STATIC) /* end H5EA__lookup_elmt() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt)) - - /* Local variables */ +herr_t +H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt) +{ H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ void * thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ uint8_t *thing_elmt_buf; /* Pointer to the element buffer for the array metadata */ @@ -664,10 +678,11 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t H5EA__unprotect_func_t thing_unprot_func; /* Function pointer for unprotecting the array metadata */ hbool_t will_extend; /* Flag indicating if setting the element will extend the array */ unsigned thing_cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting array metadata */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(ea); HDassert(hdr); @@ -678,7 +693,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t will_extend = (idx >= hdr->stats.stored.max_idx_set); if (H5EA__lookup_elmt(ea, idx, will_extend, H5AC__NO_FLAGS_SET, &thing, &thing_elmt_buf, &thing_elmt_idx, &thing_unprot_func) < 0) - H5E_THROW(H5E_CANTPROTECT, "unable to protect array metadata") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to protect array metadata") /* Sanity check */ HDassert(thing); @@ -695,15 +710,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t /* Update the max index for the array */ hdr->stats.stored.max_idx_set = idx + 1; if (H5EA__hdr_modified(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as modified") - } /* end if */ + HGOTO_ERROR(H5E_EARRAY, H5E_CANTMARKDIRTY, FAIL, + "unable to mark extensible array header as modified") + } - CATCH +done: /* Release resources */ if (thing && (thing_unprot_func)(thing, thing_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array metadata") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array metadata") -END_FUNC(PRIV) /* end H5EA_set() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_set() */ /*------------------------------------------------------------------------- * Function: H5EA_get @@ -717,17 +734,18 @@ END_FUNC(PRIV) /* end H5EA_set() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt)) - - /* Local variables */ +herr_t +H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt) +{ H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ void *thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ H5EA__unprotect_func_t thing_unprot_func = NULL; /* Function pointer for unprotecting the array metadata */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(ea); HDassert(hdr); @@ -735,7 +753,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t if (idx >= hdr->stats.stored.max_idx_set) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") } /* end if */ else { uint8_t *thing_elmt_buf; /* Pointer to the element buffer for the array metadata */ @@ -747,13 +765,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t /* Look up the array metadata containing the element we want to set */ if (H5EA__lookup_elmt(ea, idx, FALSE, H5AC__READ_ONLY_FLAG, &thing, &thing_elmt_buf, &thing_elmt_idx, &thing_unprot_func) < 0) - H5E_THROW(H5E_CANTPROTECT, "unable to protect array metadata") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to protect array metadata") /* Check if the thing holding the element has been created yet */ if (NULL == thing) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") } /* end if */ else /* Get element from thing's element buffer */ @@ -761,12 +779,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t hdr->cparam.cls->nat_elmt_size); } /* end else */ - CATCH +done: /* Release thing */ if (thing && (thing_unprot_func)(thing, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array metadata") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array metadata") -END_FUNC(PRIV) /* end H5EA_get() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_get() */ /*------------------------------------------------------------------------- * Function: H5EA_depend @@ -781,14 +800,15 @@ END_FUNC(PRIV) /* end H5EA_get() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent)) +herr_t +H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent) +{ + H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(hdr); HDassert(parent); @@ -807,13 +827,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_depend(H5EA_t *ea, H5AC_proxy_ /* Add the extensible array as a child of the parent (proxy) */ if (H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array as child of proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, "unable to add extensible array as child of proxy") hdr->parent = parent; - } /* end if */ - - CATCH + } -END_FUNC(PRIV) /* end H5EA_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_depend() */ /*------------------------------------------------------------------------- * Function: H5EA_close @@ -827,15 +847,16 @@ END_FUNC(PRIV) /* end H5EA_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) - - /* Local variables */ +herr_t +H5EA_close(H5EA_t *ea) +{ hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ haddr_t ea_addr = HADDR_UNDEF; /* Address of array (for deletion) */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(ea); /* Close the header, if it was set */ @@ -868,8 +889,8 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) /* Check the header's status in the metadata cache */ if (H5AC_get_entry_status(ea->f, ea_addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, - "unable to check metadata cache status for extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, + "unable to check metadata cache status for extensible array header") /* Sanity checks on header */ HDassert(hdr_status & H5AC_ES__IN_CACHE); @@ -881,7 +902,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) /* Lock the array header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ if (NULL == (hdr = H5EA__hdr_protect(ea->f, ea_addr, NULL, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTLOAD, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTLOAD, FAIL, "unable to load extensible array header") /* Set the shared array header's file context for this operation */ hdr->f = ea->f; @@ -891,11 +912,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) * immediately -QAK) */ if (H5EA__hdr_decr(ea->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") /* Delete array, starting with header (unprotects header) */ if (H5EA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, "unable to delete extensible array") } /* end if */ else { /* Decrement the reference count on the array header */ @@ -903,16 +925,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) * immediately -QAK) */ if (H5EA__hdr_decr(ea->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") } /* end else */ } /* end if */ /* Release the extensible array wrapper */ ea = (H5EA_t *)H5FL_FREE(H5EA_t, ea); - CATCH - -END_FUNC(PRIV) /* end H5EA_close() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_close() */ /*------------------------------------------------------------------------- * Function: H5EA_delete @@ -926,21 +949,22 @@ END_FUNC(PRIV) /* end H5EA_close() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) +herr_t +H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata) +{ + H5EA_hdr_t *hdr = NULL; /* The fractal heap header information */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* The fractal heap header information */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(ea_addr)); /* Lock the array header into memory */ if (NULL == (hdr = H5EA__hdr_protect(f, ea_addr, ctx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", - (unsigned long long)ea_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array header, address = %llu", (unsigned long long)ea_addr) /* Check for files using shared array header */ if (hdr->file_rc) @@ -951,17 +975,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_delete(H5F_t *f, haddr_t ea_ad /* Delete array now, starting with header (unprotects header) */ if (H5EA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, "unable to delete extensible array") hdr = NULL; - } /* end if */ + } - CATCH - - /* Unprotect the header, if an error occurred */ +done: + /* Unprotect the header if an error occurred */ if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PRIV) /* end H5EA_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_delete() */ /*------------------------------------------------------------------------- * Function: H5EA_iterate @@ -975,13 +999,14 @@ END_FUNC(PRIV) /* end H5EA_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, - H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata)) - - /* Local variables */ +int +H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata) +{ uint8_t *elmt = NULL; hsize_t u; - int cb_ret = H5_ITER_CONT; /* Return value from callback */ + int ret_value = H5_ITER_CONT; + + FUNC_ENTER_NOAPI(H5_ITER_ERROR) /* Check arguments */ HDassert(ea); @@ -990,27 +1015,28 @@ BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, /* Allocate space for a native array element */ if (NULL == (elmt = H5FL_BLK_MALLOC(ea_native_elmt, ea->hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array element") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, H5_ITER_ERROR, + "memory allocation failed for extensible array element") /* Iterate over all elements in array */ - for (u = 0; u < ea->hdr->stats.stored.max_idx_set && cb_ret == H5_ITER_CONT; u++) { + for (u = 0; u < ea->hdr->stats.stored.max_idx_set && ret_value == H5_ITER_CONT; u++) { /* Get array element */ if (H5EA_get(ea, u, elmt) < 0) - H5E_THROW(H5E_CANTGET, "unable to delete fixed array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, H5_ITER_ERROR, "unable to delete fixed array") /* Make callback */ - if ((cb_ret = (*op)(u, elmt, udata)) < 0) { - H5E_PRINTF(H5E_BADITER, "iterator function failed"); - H5_LEAVE(cb_ret) - } /* end if */ - } /* end for */ - - CATCH + if ((ret_value = (*op)(u, elmt, udata)) < 0) { + HERROR(H5E_EARRAY, H5E_BADITER, "iteration callback error"); + break; + } + } +done: if (elmt) elmt = H5FL_BLK_FREE(ea_native_elmt, elmt); -END_FUNC(PRIV) /* end H5EA_iterate() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_iterate() */ /*------------------------------------------------------------------------- * Function: H5EA_patch_file @@ -1024,17 +1050,17 @@ END_FUNC(PRIV) /* end H5EA_iterate() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_patch_file(H5EA_t *ea, H5F_t *f)) - - /* Local variables */ +herr_t +H5EA_patch_file(H5EA_t *ea, H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(f); if (ea->f != f || ea->hdr->f != f) ea->f = ea->hdr->f = f; -END_FUNC(PRIV) /* end H5EA_patch_file() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA_patch_file() */ diff --git a/src/H5EAcache.c b/src/H5EAcache.c index 2a3153c6bc9..eeac1a26545 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -221,12 +221,13 @@ const H5AC_class_t H5AC_EARRAY_DBLK_PAGE[1] = {{ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_hdr_cache_ud_t *udata = (H5EA_hdr_cache_ud_t *)_udata; /* User data for callback */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->f); @@ -235,7 +236,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5EA_HEADER_SIZE_FILE(udata->f); -END_FUNC(STATIC) /* end H5EA__cache_hdr_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_hdr_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_verify_chksum @@ -250,13 +252,15 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -267,7 +271,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_hdr_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5EA__cache_hdr_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_deserialize @@ -282,16 +287,17 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ H5EA_cls_id_t id; /* ID of extensible array class, as found in file */ H5EA_hdr_t * hdr = NULL; /* Extensible array info */ H5EA_hdr_cache_ud_t *udata = (H5EA_hdr_cache_ud_t *)_udata; const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(image); @@ -301,24 +307,25 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate space for the extensible array data structure */ if (NULL == (hdr = H5EA__hdr_alloc(udata->f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array shared header") /* Set the extensible array header's address */ hdr->addr = udata->addr; /* Magic number */ if (HDmemcmp(image, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header signature") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5EA_HDR_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array header version") + HGOTO_ERROR(H5E_EARRAY, H5E_VERSION, NULL, "wrong extensible array header version") /* Extensible array class */ id = (H5EA_cls_id_t)*image++; if (id >= H5EA_NUM_CLS_ID) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") hdr->cparam.cls = H5EA_client_class_g[id]; /* General array creation/configuration information */ @@ -379,20 +386,20 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Finish initializing extensible array header */ if (H5EA__hdr_init(hdr, udata->ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, "initialization failed for extensible array header") HDassert(hdr->size == len); /* Set return value */ ret_value = hdr; - CATCH - +done: /* Release resources */ if (!ret_value) if (hdr && H5EA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array header") -END_FUNC(STATIC) /* end H5EA__cache_hdr_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_hdr_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_image_len @@ -406,12 +413,13 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_hdr_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_hdr_image_len(const void *_thing, size_t *image_len) +{ const H5EA_hdr_t *hdr = (const H5EA_hdr_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(hdr); HDassert(image_len); @@ -419,7 +427,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = hdr->size; -END_FUNC(STATIC) /* end H5EA__cache_hdr_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_hdr_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_serialize @@ -433,14 +442,15 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the extensible array header */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + FUNC_ENTER_STATIC_NOERR + /* check arguments */ HDassert(f); HDassert(image); @@ -488,7 +498,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5EA__cache_hdr_serialize() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_hdr_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_notify @@ -502,11 +513,13 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5EA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) +{ + H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Sanity check */ HDassert(hdr); @@ -538,23 +551,24 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Destroy flush dependency on object header proxy */ if (H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, (void *)hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between extensible array and proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between extensible array and proxy") hdr->parent = NULL; } /* end if */ /* Detach from 'top' proxy for extensible array */ if (hdr->top_proxy) { if (H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between header and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between header and " + "extensible array 'top' proxy") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ break; default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ @@ -563,9 +577,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, else HDassert(NULL == hdr->parent); - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_hdr_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_hdr_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_free_icr @@ -580,18 +594,23 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_hdr_free_icr(void *thing)) +static herr_t +H5EA__cache_hdr_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array header */ if (H5EA__hdr_dest((H5EA_hdr_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array header") - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_hdr_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_hdr_free_icr() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_get_initial_load_size @@ -605,13 +624,14 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_hdr_t * hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ H5EA_iblock_t iblock; /* Fake index block for computing size */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(hdr); HDassert(image_len); @@ -626,7 +646,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5EA_IBLOCK_SIZE(&iblock); -END_FUNC(STATIC) /* end H5EA__cache_iblock_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_iblock_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_verify_chksum @@ -641,13 +662,15 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -658,7 +681,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_iblock_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_deserialize @@ -673,17 +697,18 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_iblock_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5EA__cache_iblock_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ H5EA_iblock_t *iblock = NULL; /* Index block info */ H5EA_hdr_t * hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ haddr_t arr_addr; /* Address of array header in the file */ size_t u; /* Local index variable */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(image); @@ -691,28 +716,29 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the extensible array index block */ if (NULL == (iblock = H5EA__iblock_alloc(hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array index block") /* Set the extensible array index block's address */ iblock->addr = hdr->idx_blk_addr; /* Magic number */ if (HDmemcmp(image, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong extensible array index block signature") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array index block signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5EA_IBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array index block version") + HGOTO_ERROR(H5E_EARRAY, H5E_VERSION, NULL, "wrong extensible array index block version") /* Extensible array type */ if (*image++ != (uint8_t)hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(hdr->f, &image, &arr_addr); if (H5F_addr_ne(arr_addr, hdr->addr)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header address") /* Internal information */ @@ -721,7 +747,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Convert from raw elements on disk into native elements in memory */ if ((hdr->cparam.cls->decode)(image, iblock->elmts, (size_t)hdr->cparam.idx_blk_elmts, hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode extensible array index elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDECODE, NULL, "can't decode extensible array index elements") image += (hdr->cparam.idx_blk_elmts * hdr->cparam.raw_elmt_size); } /* end if */ @@ -757,14 +783,14 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = iblock; - CATCH - +done: /* Release resources */ if (!ret_value) if (iblock && H5EA__iblock_dest(iblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array index block") -END_FUNC(STATIC) /* end H5EA__cache_iblock_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_image_len @@ -778,12 +804,13 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_iblock_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_iblock_image_len(const void *_thing, size_t *image_len) +{ const H5EA_iblock_t *iblock = (const H5EA_iblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(iblock); HDassert(image_len); @@ -791,7 +818,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = iblock->size; -END_FUNC(STATIC) /* end H5EA__cache_iblock_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_iblock_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_serialize @@ -805,14 +833,15 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object to serialize */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* check arguments */ HDassert(f); @@ -843,7 +872,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Convert from native elements in memory into raw elements on disk */ if ((iblock->hdr->cparam.cls->encode)(image, iblock->elmts, (size_t)iblock->hdr->cparam.idx_blk_elmts, iblock->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode extensible array index elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTENCODE, FAIL, "can't encode extensible array index elements") image += (iblock->hdr->cparam.idx_blk_elmts * iblock->hdr->cparam.raw_elmt_size); } /* end if */ @@ -874,9 +903,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_iblock_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_notify @@ -890,11 +919,13 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing) +{ + H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Sanity check */ HDassert(iblock); @@ -905,9 +936,10 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on extensible array header */ if (H5EA__create_flush_depend((H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) - H5E_THROW(H5E_CANTDEPEND, - "unable to create flush dependency between index block and header, address = %llu", - (unsigned long long)iblock->addr) + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between index block and header, address = %llu", + (unsigned long long)iblock->addr) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: @@ -923,30 +955,32 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on extensible array header */ if (H5EA__destroy_flush_depend((H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between index block and header, address = %llu", - (unsigned long long)iblock->addr) + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between index block and header, address = %llu", + (unsigned long long)iblock->addr) /* Detach from 'top' proxy for extensible array */ if (iblock->top_proxy) { if (H5AC_proxy_entry_remove_child(iblock->top_proxy, iblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between index block and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between index block and " + "extensible array 'top' proxy") iblock->top_proxy = NULL; } /* end if */ break; default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_free_icr @@ -961,18 +995,23 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_iblock_free_icr(void *thing)) +static herr_t +H5EA__cache_iblock_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array index block */ if (H5EA__iblock_dest((H5EA_iblock_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array index block") - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_iblock_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_free_icr() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_get_initial_load_size @@ -986,13 +1025,14 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_sblock_cache_ud_t *udata = (H5EA_sblock_cache_ud_t *)_udata; /* User data */ H5EA_sblock_t sblock; /* Fake super block for computing size */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -1026,7 +1066,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5EA_SBLOCK_SIZE(&sblock); -END_FUNC(STATIC) /* end H5EA__cache_sblock_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_sblock_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_verify_chksum @@ -1041,13 +1082,15 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_sblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_sblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -1058,7 +1101,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_deserialize @@ -1073,17 +1117,18 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_sblock_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5EA__cache_sblock_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ H5EA_sblock_t * sblock = NULL; /* Super block info */ H5EA_sblock_cache_ud_t *udata = (H5EA_sblock_cache_ud_t *)_udata; /* User data */ const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ haddr_t arr_addr; /* Address of array header in the file */ size_t u; /* Local index variable */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(udata); @@ -1094,28 +1139,29 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the extensible array super block */ if (NULL == (sblock = H5EA__sblock_alloc(udata->hdr, udata->parent, udata->sblk_idx))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array super block") /* Set the extensible array super block's address */ sblock->addr = udata->sblk_addr; /* Magic number */ if (HDmemcmp(image, H5EA_SBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong extensible array super block signature") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array super block signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5EA_SBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array super block version") + HGOTO_ERROR(H5E_EARRAY, H5E_VERSION, NULL, "wrong extensible array super block version") /* Extensible array type */ if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(udata->hdr->f, &image, &arr_addr); if (H5F_addr_ne(arr_addr, udata->hdr->addr)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header address") /* Offset of block within the array's address space */ UINT64DECODE_VAR(image, sblock->block_off, udata->hdr->arr_off_size); @@ -1154,14 +1200,14 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = sblock; - CATCH - +done: /* Release resources */ if (!ret_value) if (sblock && H5EA__sblock_dest(sblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array super block") -END_FUNC(STATIC) /* end H5EA__cache_sblock_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_image_len @@ -1175,12 +1221,13 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_sblock_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_sblock_image_len(const void *_thing, size_t *image_len) +{ const H5EA_sblock_t *sblock = (const H5EA_sblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(sblock); HDassert(image_len); @@ -1188,7 +1235,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = sblock->size; -END_FUNC(STATIC) /* end H5EA__cache_sblock_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_sblock_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_serialize @@ -1202,16 +1250,16 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object to serialize */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ size_t u; /* Local index variable */ + FUNC_ENTER_STATIC_NOERR + /* check arguments */ HDassert(f); HDassert(image); @@ -1260,7 +1308,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5EA__cache_sblock_serialize() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_sblock_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_notify @@ -1274,11 +1323,13 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *_thing) +{ + H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Sanity check */ HDassert(sblock); @@ -1289,8 +1340,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on index block */ if (H5EA__create_flush_depend((H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) break; @@ -1299,8 +1350,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Destroy flush dependency on extensible array header, if set */ if (sblock->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between super block and header, address = %llu", (unsigned long long)sblock->addr) sblock->has_hdr_depend = FALSE; @@ -1310,16 +1361,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on index block */ if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) /* Destroy flush dependency on extensible array header, if set */ if (sblock->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between super block and header, address = %llu", (unsigned long long)sblock->addr) sblock->has_hdr_depend = FALSE; @@ -1328,8 +1379,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Detach from 'top' proxy for extensible array */ if (sblock->top_proxy) { if (H5AC_proxy_entry_remove_child(sblock->top_proxy, sblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between super block and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between super block and " + "extensible array 'top' proxy") sblock->top_proxy = NULL; } /* end if */ break; @@ -1345,15 +1397,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_free_icr @@ -1368,18 +1420,23 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_sblock_free_icr(void *thing)) +static herr_t +H5EA__cache_sblock_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array super block */ if (H5EA__sblock_dest((H5EA_sblock_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array super block") - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_sblock_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_free_icr() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_get_initial_load_size @@ -1393,13 +1450,14 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_dblock_cache_ud_t *udata = (H5EA_dblock_cache_ud_t *)_udata; /* User data */ H5EA_dblock_t dblock; /* Fake data block for computing size */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -1434,7 +1492,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, else *image_len = H5EA_DBLOCK_PREFIX_SIZE(&dblock); -END_FUNC(STATIC) /* end H5EA__cache_dblock_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblock_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_verify_chksum @@ -1449,13 +1508,15 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -1466,7 +1527,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_deserialize @@ -1481,16 +1543,18 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) +{ H5EA_dblock_t * dblock = NULL; /* Data block info */ H5EA_dblock_cache_ud_t *udata = (H5EA_dblock_cache_ud_t *)_udata; /* User data */ const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ haddr_t arr_addr; /* Address of array header in the file */ + void * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(udata); @@ -1501,7 +1565,8 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the extensible array data block */ if (NULL == (dblock = H5EA__dblock_alloc(udata->hdr, udata->parent, udata->nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array data block") HDassert(((!dblock->npages) && (len == H5EA_DBLOCK_SIZE(dblock))) || (len == H5EA_DBLOCK_PREFIX_SIZE(dblock))); @@ -1511,21 +1576,21 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Magic number */ if (HDmemcmp(image, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong extensible array data block signature") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array data block signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5EA_DBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array data block version") + HGOTO_ERROR(H5E_EARRAY, H5E_VERSION, NULL, "wrong extensible array data block version") /* Extensible array type */ if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(udata->hdr->f, &image, &arr_addr); if (H5F_addr_ne(arr_addr, udata->hdr->addr)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header address") /* Offset of block within the array's address space */ UINT64DECODE_VAR(image, dblock->block_off, udata->hdr->arr_off_size); @@ -1537,7 +1602,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Decode elements in data block */ /* Convert from raw elements on disk into native elements in memory */ if ((udata->hdr->cparam.cls->decode)(image, dblock->elmts, udata->nelmts, udata->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode extensible array data elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDECODE, NULL, "can't decode extensible array data elements") image += (udata->nelmts * udata->hdr->cparam.raw_elmt_size); } /* end if */ @@ -1560,14 +1625,15 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = dblock; - CATCH +done: /* Release resources */ if (!ret_value) if (dblock && H5EA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block") -END_FUNC(STATIC) /* end H5EA__cache_dblock_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5EA__cache_dblock_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_image_len @@ -1581,12 +1647,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblock_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_dblock_image_len(const void *_thing, size_t *image_len) +{ const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblock); HDassert(image_len); @@ -1597,7 +1664,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, else *image_len = (size_t)H5EA_DBLOCK_PREFIX_SIZE(dblock); -END_FUNC(STATIC) /* end H5EA__cache_dblock_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblock_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_serialize @@ -1611,14 +1679,15 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object to serialize */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* check arguments */ HDassert(f); @@ -1651,7 +1720,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Convert from native elements in memory into raw elements on disk */ if ((dblock->hdr->cparam.cls->encode)(image, dblock->elmts, dblock->nelmts, dblock->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode extensible array data elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTENCODE, FAIL, "can't encode extensible array data elements") image += (dblock->nelmts * dblock->hdr->cparam.raw_elmt_size); } /* end if */ @@ -1664,9 +1733,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblock_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblock_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_notify @@ -1680,11 +1749,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) +{ + H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Check arguments */ HDassert(dblock); @@ -1695,17 +1766,17 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ if (H5EA__create_flush_depend((H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTDEPEND, - "unable to create flush dependency between data block and parent, address = %llu", - (unsigned long long)dblock->addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between data block and parent, address = %llu", + (unsigned long long)dblock->addr) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: /* Destroy flush dependency on extensible array header, if set */ if (dblock->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between direct block and header, address = %llu", (unsigned long long)dblock->addr) dblock->has_hdr_depend = FALSE; @@ -1715,15 +1786,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between data block and parent, address = %llu", - (unsigned long long)dblock->addr) + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block and parent, address = %llu", + (unsigned long long)dblock->addr) /* Destroy flush dependency on extensible array header, if set */ if (dblock->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between data block and header, address = %llu", (unsigned long long)dblock->addr) dblock->has_hdr_depend = FALSE; @@ -1732,8 +1804,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Detach from 'top' proxy for extensible array */ if (dblock->top_proxy) { if (H5AC_proxy_entry_remove_child(dblock->top_proxy, dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block and " + "extensible array 'top' proxy") dblock->top_proxy = NULL; } /* end if */ break; @@ -1749,15 +1822,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblock_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_free_icr @@ -1772,18 +1845,23 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_dblock_free_icr(void *thing)) +static herr_t +H5EA__cache_dblock_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array data block */ if (H5EA__dblock_dest((H5EA_dblock_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array data block") - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblock_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblock_free_icr() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_fsf_size @@ -1814,12 +1892,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) - - /* Local variables */ +static herr_t +H5EA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) +{ const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblock); HDassert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -1828,7 +1907,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, *fsf_size = dblock->size; -END_FUNC(STATIC) /* end H5EA__cache_dblock_fsf_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblock_fsf_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_get_initial_load_size @@ -1842,12 +1922,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_fsf_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_dblk_page_cache_ud_t *udata = (H5EA_dblk_page_cache_ud_t *)_udata; /* User data */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -1856,7 +1937,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5EA_DBLK_PAGE_SIZE(udata->hdr); -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblk_page_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_verify_chksum @@ -1871,13 +1953,15 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -1888,7 +1972,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_deserialize @@ -1903,16 +1988,17 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ H5EA_dblk_page_t * dblk_page = NULL; /* Data block page info */ H5EA_dblk_page_cache_ud_t *udata = (H5EA_dblk_page_cache_ud_t *)_udata; /* User data for loading data block page */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(udata); @@ -1922,7 +2008,8 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the extensible array data block page */ if (NULL == (dblk_page = H5EA__dblk_page_alloc(udata->hdr, udata->parent))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array data block page") /* Set the extensible array data block page's information */ dblk_page->addr = udata->dblk_page_addr; @@ -1933,7 +2020,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Convert from raw elements on disk into native elements in memory */ if ((udata->hdr->cparam.cls->decode)(image, dblk_page->elmts, udata->hdr->dblk_page_nelmts, udata->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode extensible array data elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDECODE, NULL, "can't decode extensible array data elements") image += (udata->hdr->dblk_page_nelmts * udata->hdr->cparam.raw_elmt_size); /* Sanity check */ @@ -1954,14 +2041,13 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = dblk_page; - CATCH - +done: /* Release resources */ if (!ret_value) if (dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") - -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_deserialize() */ + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block page") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_image_len @@ -1975,12 +2061,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_dblk_page_image_len(const void *_thing, size_t *image_len) +{ const H5EA_dblk_page_t *dblk_page = (const H5EA_dblk_page_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblk_page); HDassert(image_len); @@ -1988,7 +2075,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = dblk_page->size; -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblk_page_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_serialize @@ -2002,14 +2090,16 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, - size_t H5_ATTR_UNUSED len, void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, + void *_thing) +{ H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_thing; /* Pointer to the object to serialize */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(f); @@ -2024,7 +2114,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Convert from native elements in memory into raw elements on disk */ if ((dblk_page->hdr->cparam.cls->encode)(image, dblk_page->elmts, dblk_page->hdr->dblk_page_nelmts, dblk_page->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode extensible array data elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTENCODE, FAIL, "can't encode extensible array data elements") image += (dblk_page->hdr->dblk_page_nelmts * dblk_page->hdr->cparam.raw_elmt_size); /* Compute metadata checksum */ @@ -2036,9 +2126,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_notify @@ -2052,11 +2142,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing) +{ H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(dblk_page); @@ -2067,8 +2159,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ if (H5EA__create_flush_depend((H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) break; @@ -2077,10 +2169,10 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Destroy flush dependency on extensible array header, if set */ if (dblk_page->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->hdr, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between data block page and header, " - "address = %llu", - (unsigned long long)dblk_page->addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block page and header, " + "address = %llu", + (unsigned long long)dblk_page->addr) dblk_page->has_hdr_depend = FALSE; } /* end if */ break; @@ -2088,27 +2180,27 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) /* Destroy flush dependency on extensible array header, if set */ if (dblk_page->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->hdr, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between data block page and header, " - "address = %llu", - (unsigned long long)dblk_page->addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block page and header, " + "address = %llu", + (unsigned long long)dblk_page->addr) dblk_page->has_hdr_depend = FALSE; } /* end if */ /* Detach from 'top' proxy for extensible array */ if (dblk_page->top_proxy) { if (H5AC_proxy_entry_remove_child(dblk_page->top_proxy, dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between data block page and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block page and " + "extensible array 'top' proxy") dblk_page->top_proxy = NULL; } /* end if */ break; @@ -2124,15 +2216,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_free_icr @@ -2147,15 +2239,20 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_dblk_page_free_icr(void *thing)) +static herr_t +H5EA__cache_dblk_page_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array data block page */ if (H5EA__dblk_page_dest((H5EA_dblk_page_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array data block page") - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array data block page") -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_free_icr() */ diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c index 72d2f38cb04..b0e564c64ed 100644 --- a/src/H5EAdbg.c +++ b/src/H5EAdbg.c @@ -79,13 +79,16 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5EA_class_t *cls, haddr_t obj_addr)) - +herr_t +H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, + haddr_t obj_addr) +{ /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ - void * dbg_ctx = NULL; /* Extensible array debugging context */ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + void * dbg_ctx = NULL; /* Extensible array debugging context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -100,11 +103,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to create fixed array debugging context") /* Load the extensible array header */ if (NULL == (hdr = H5EA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to load extensible array header") /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Header...\n", indent, ""); @@ -137,13 +140,14 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Index Block Address:", hdr->idx_blk_addr); - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_debug @@ -157,14 +161,17 @@ END_FUNC(PKG) /* end H5EA__hdr_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent, int fwidth, - const H5EA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr)) - +herr_t +H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent, int fwidth, + const H5EA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr) +{ /* Local variables */ - H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ - void * dbg_ctx = NULL; /* Extensible array context */ + H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + void * dbg_ctx = NULL; /* Extensible array context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -180,19 +187,20 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to create extensible array debugging context") /* Load the extensible array header */ if (NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to load extensible array header") /* Sanity check */ HDassert(H5F_addr_eq(hdr->idx_blk_addr, addr)); /* Protect index block */ if (NULL == (iblock = H5EA__iblock_protect(hdr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", - (unsigned long long)hdr->idx_blk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Index Block...\n", indent, ""); @@ -216,7 +224,7 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)iblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) - H5E_THROW(H5E_CANTGET, "can't get element for debugging") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "can't get element for debugging") } /* end for */ } /* end if */ @@ -250,15 +258,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, } /* end for */ } /* end if */ - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") if (iblock && H5EA__iblock_unprotect(iblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block") if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__iblock_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_debug @@ -272,14 +281,17 @@ END_FUNC(PKG) /* end H5EA__iblock_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5EA_class_t *cls, haddr_t hdr_addr, unsigned sblk_idx, haddr_t obj_addr)) - +herr_t +H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, + haddr_t hdr_addr, unsigned sblk_idx, haddr_t obj_addr) +{ /* Local variables */ - H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ - void * dbg_ctx = NULL; /* Extensible array context */ + H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + void * dbg_ctx = NULL; /* Extensible array context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -295,18 +307,19 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to create extensible array debugging context") /* Load the extensible array header */ if (NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to load extensible array header") /* Protect super block */ /* (Note: setting parent of super block to 'hdr' for this operation should be OK -QAK) */ if (NULL == (sblock = H5EA__sblock_protect(hdr, (H5EA_iblock_t *)hdr, addr, sblk_idx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", - (unsigned long long)addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array super block, address = %llu", + (unsigned long long)addr) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Super Block...\n", indent, ""); @@ -334,15 +347,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, } /* end for */ } /* end if */ - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") if (sblock && H5EA__sblock_unprotect(sblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block") if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__sblock_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_debug @@ -356,16 +370,18 @@ END_FUNC(PKG) /* end H5EA__sblock_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5EA_class_t *cls, haddr_t hdr_addr, size_t dblk_nelmts, - haddr_t obj_addr)) - +herr_t +H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, + haddr_t hdr_addr, size_t dblk_nelmts, haddr_t obj_addr) +{ /* Local variables */ - H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ - void * dbg_ctx = NULL; /* Extensible array context */ - size_t u; /* Local index variable */ + H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + void * dbg_ctx = NULL; /* Extensible array context */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -382,17 +398,17 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to create extensible array debugging context") /* Load the extensible array header */ if (NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to load extensible array header") /* Protect data block */ /* (Note: setting parent of data block to 'hdr' for this operation should be OK -QAK) */ if (NULL == (dblock = H5EA__dblock_protect(hdr, hdr, addr, dblk_nelmts, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %" PRIuHADDR, - addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block, address = %" PRIuHADDR, addr) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array data Block...\n", indent, ""); @@ -407,15 +423,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Call the class's 'debug' callback */ if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) - H5E_THROW(H5E_CANTGET, "can't get element for debugging") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "can't get element for debugging") } /* end for */ - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") if (dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block") if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__dblock_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_debug() */ diff --git a/src/H5EAdblkpage.c b/src/H5EAdblkpage.c index b42599c420a..c0a92f0e695 100644 --- a/src/H5EAdblkpage.c +++ b/src/H5EAdblkpage.c @@ -84,22 +84,25 @@ H5FL_DEFINE_STATIC(H5EA_dblk_page_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, - H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent)) - - /* Local variables */ +H5EA_dblk_page_t * +H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent) +{ H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ + H5EA_dblk_page_t *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); /* Allocate memory for the data block */ if (NULL == (dblk_page = H5FL_CALLOC(H5EA_dblk_page_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array data block page") /* Share common array information */ if (H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") dblk_page->hdr = hdr; /* Set non-zero internal fields */ @@ -107,17 +110,19 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, /* Allocate buffer for elements in data block page */ if (NULL == (dblk_page->elmts = H5EA__hdr_alloc_elmts(hdr, hdr->dblk_page_nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block page element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block page element buffer") /* Set the return value */ ret_value = dblk_page; - CATCH +done: if (!ret_value) if (dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block page") -END_FUNC(PKG) /* end H5EA__dblk_page_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_create @@ -131,19 +136,22 @@ END_FUNC(PKG) /* end H5EA__dblk_page_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t addr)) - - /* Local variables */ +herr_t +H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t addr) +{ H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Allocate the data block page */ if (NULL == (dblk_page = H5EA__dblk_page_alloc(hdr, parent))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, FAIL, + "memory allocation failed for extensible array data block page") /* Set info about data block page on disk */ dblk_page->addr = addr; @@ -151,34 +159,39 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Clear any elements in data block page to fill value */ if ((hdr->cparam.cls->fill)(dblk_page->elmts, (size_t)hdr->dblk_page_nelmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set extensible array data block page elements to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, + "can't set extensible array data block page elements to class's fill value") /* Cache the new extensible array data block page */ if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array data block page to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, FAIL, "can't add extensible array data block page to cache") inserted = TRUE; /* Add data block page as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, + "unable to add extensible array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ - CATCH +done: if (ret_value < 0) if (dblk_page) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(dblk_page) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array data block page from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, FAIL, + "unable to remove extensible array data block page from cache") /* Destroy data block page */ if (H5EA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, + "unable to destroy extensible array data block page") } /* end if */ -END_FUNC(PKG) /* end H5EA__dblk_page_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_create() */ /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_protect @@ -193,13 +206,14 @@ END_FUNC(PKG) /* end H5EA__dblk_page_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, - H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t dblk_page_addr, - unsigned flags)) - - /* Local variables */ +H5EA_dblk_page_t * +H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t dblk_page_addr, unsigned flags) +{ H5EA_dblk_page_t * dblk_page = NULL; /* Extensible array data block page */ H5EA_dblk_page_cache_ud_t udata; /* Information needed for loading data block page */ + H5EA_dblk_page_t * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -216,32 +230,34 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, /* Protect the data block page */ if (NULL == (dblk_page = (H5EA_dblk_page_t *)H5AC_protect(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == dblk_page->top_proxy) { /* Add data block page as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ /* Set return value */ ret_value = dblk_page; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the data block page, if it was protected */ if (dblk_page && H5AC_unprotect(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, - "unable to unprotect extensible array data block page, address = %llu", - (unsigned long long)dblk_page->addr) + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect extensible array data block page, address = %llu", + (unsigned long long)dblk_page->addr) } /* end if */ - -END_FUNC(PKG) /* end H5EA__dblk_page_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_unprotect @@ -256,22 +272,25 @@ END_FUNC(PKG) /* end H5EA__dblk_page_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags)) +herr_t +H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblk_page); /* Unprotect the data block page */ if (H5AC_unprotect(dblk_page->hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block page, address = %llu", - (unsigned long long)dblk_page->addr) - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array data block page, address = %llu", + (unsigned long long)dblk_page->addr) -END_FUNC(PKG) /* end H5EA__dblk_page_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_dest @@ -285,7 +304,12 @@ END_FUNC(PKG) /* end H5EA__dblk_page_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page)) +herr_t +H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblk_page); @@ -297,13 +321,15 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblk_page_dest(H5EA_dblk_page_ if (dblk_page->elmts) { /* Free buffer for data block page elements */ if (H5EA__hdr_free_elmts(dblk_page->hdr, dblk_page->hdr->dblk_page_nelmts, dblk_page->elmts) < 0) - H5E_THROW(H5E_CANTFREE, "unable to free extensible array data block element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, + "unable to free extensible array data block element buffer") dblk_page->elmts = NULL; } /* end if */ /* Decrement reference count on shared info */ if (H5EA__hdr_decr(dblk_page->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") dblk_page->hdr = NULL; } /* end if */ @@ -313,6 +339,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblk_page_dest(H5EA_dblk_page_ /* Free the data block page itself */ dblk_page = H5FL_FREE(H5EA_dblk_page_t, dblk_page); - CATCH - -END_FUNC(PKG) /* end H5EA__dblk_page_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_dest() */ diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c index 45696c7c3b0..f17aae3dffa 100644 --- a/src/H5EAdblock.c +++ b/src/H5EAdblock.c @@ -85,11 +85,13 @@ H5FL_DEFINE_STATIC(H5EA_dblock_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, - H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts)) +H5EA_dblock_t * +H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts) +{ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + H5EA_dblock_t *ret_value = NULL; - /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -98,11 +100,12 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, /* Allocate memory for the data block */ if (NULL == (dblock = H5FL_CALLOC(H5EA_dblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array data block") /* Share common array information */ if (H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") dblock->hdr = hdr; /* Set non-zero internal fields */ @@ -118,18 +121,20 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, else { /* Allocate buffer for elements in data block */ if (NULL == (dblock->elmts = H5EA__hdr_alloc_elmts(hdr, nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block element buffer") } /* end else */ /* Set the return value */ ret_value = dblock; - CATCH +done: if (!ret_value) if (dblock && H5EA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block") -END_FUNC(PKG) /* end H5EA__dblock_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_create @@ -143,14 +148,15 @@ END_FUNC(PKG) /* end H5EA__dblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, hsize_t dblk_off, - size_t nelmts)) +haddr_t +H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, hsize_t dblk_off, size_t nelmts) +{ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + haddr_t dblock_addr; /* Extensible array data block address */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ - haddr_t dblock_addr; /* Extensible array data block address */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -159,7 +165,8 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate the data block */ if (NULL == (dblock = H5EA__dblock_alloc(hdr, parent, nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for extensible array data block") /* Set size of data block on disk */ dblock->size = H5EA_DBLOCK_SIZE(dblock); @@ -169,24 +176,27 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate space for the data block on disk */ if (HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_DBLOCK, (hsize_t)dblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for extensible array data block") dblock->addr = dblock_addr; /* Don't initialize elements if paged */ if (!dblock->npages) /* Clear any elements in data block to fill value */ if ((hdr->cparam.cls->fill)(dblock->elmts, (size_t)dblock->nelmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set extensible array data block elements to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "can't set extensible array data block elements to class's fill value") /* Cache the new extensible array data block */ if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array data block to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, HADDR_UNDEF, "can't add extensible array data block to cache") inserted = TRUE; /* Add data block as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add extensible array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -203,25 +213,29 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Set address of data block to return */ ret_value = dblock_addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (dblock) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(dblock) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array data block from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove extensible array data block from cache") /* Release data block's disk space */ if (H5F_addr_defined(dblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_DBLOCK, dblock->addr, (hsize_t)dblock->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to release extensible array data block") /* Destroy data block */ if (H5EA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy extensible array data block") } /* end if */ -END_FUNC(PKG) /* end H5EA__dblock_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_create() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_sblk_idx @@ -236,10 +250,12 @@ END_FUNC(PKG) /* end H5EA__dblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, unsigned, 0, -, H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx)) +unsigned +H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx) +{ + unsigned sblk_idx = 0; /* Which superblock does this index fall in? */ - /* Local variables */ - unsigned sblk_idx; /* Which superblock does this index fall in? */ + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -252,10 +268,8 @@ BEGIN_FUNC(PKG, NOERR, unsigned, 0, -, H5EA__dblock_sblk_idx(const H5EA_hdr_t *h H5_CHECK_OVERFLOW(idx, /*From:*/ hsize_t, /*To:*/ uint64_t); sblk_idx = H5VM_log2_gen((uint64_t)((idx / hdr->cparam.data_blk_min_elmts) + 1)); - /* Set return value */ - ret_value = sblk_idx; - -END_FUNC(PKG) /* end H5EA__dblock_sblk_idx() */ + FUNC_LEAVE_NOAPI(sblk_idx) +} /* end H5EA__dblock_sblk_idx() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_protect @@ -269,13 +283,14 @@ END_FUNC(PKG) /* end H5EA__dblock_sblk_idx() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, - H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts, - unsigned flags)) - - /* Local variables */ +H5EA_dblock_t * +H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts, unsigned flags) +{ H5EA_dblock_t * dblock; /* Extensible array data block */ H5EA_dblock_cache_ud_t udata; /* Information needed for loading data block */ + H5EA_dblock_t * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -294,32 +309,36 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, /* Protect the data block */ if (NULL == (dblock = (H5EA_dblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_DBLOCK, dblk_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", - (unsigned long long)dblk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)dblk_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == dblock->top_proxy) { /* Add data block as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; - } /* end if */ + } /* Set return value */ ret_value = dblock; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the data block, if it was protected */ if (dblock && H5AC_unprotect(hdr->f, H5AC_EARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block, address = %llu", - (unsigned long long)dblock->addr) - } /* end if */ + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect extensible array data block, address = %llu", + (unsigned long long)dblock->addr) + } -END_FUNC(PKG) /* end H5EA__dblock_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_unprotect @@ -333,22 +352,26 @@ END_FUNC(PKG) /* end H5EA__dblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags)) +herr_t +H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblock); /* Unprotect the data block */ if (H5AC_unprotect(dblock->hdr->f, H5AC_EARRAY_DBLOCK, dblock->addr, dblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block, address = %llu", - (unsigned long long)dblock->addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array data block, address = %llu", + (unsigned long long)dblock->addr) - CATCH +done: -END_FUNC(PKG) /* end H5EA__dblock_unprotect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_delete @@ -362,11 +385,13 @@ END_FUNC(PKG) /* end H5EA__dblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts)) +herr_t +H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts) +{ + H5EA_dblock_t *dblock = NULL; /* Pointer to data block */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Pointer to data block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -376,8 +401,9 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Protect data block */ if (NULL == (dblock = H5EA__dblock_protect(hdr, parent, dblk_addr, dblk_nelmts, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", - (unsigned long long)dblk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)dblk_addr) /* Check if this is a paged data block */ if (dblk_nelmts > hdr->dblk_page_nelmts) { @@ -395,20 +421,22 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Evict the data block page from the metadata cache */ /* (OK to call if it doesn't exist in the cache) */ if (H5AC_expunge_entry(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page_addr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTEXPUNGE, "unable to remove array data block page from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTEXPUNGE, FAIL, + "unable to remove array data block page from metadata cache") /* Advance to next page address */ dblk_page_addr += dblk_page_size; } /* end for */ } /* end if */ - CATCH +done: /* Finished deleting data block in metadata cache */ if (dblock && H5EA__dblock_unprotect(dblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block") -END_FUNC(PKG) /* end H5EA__dblock_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_delete() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_dest @@ -422,7 +450,12 @@ END_FUNC(PKG) /* end H5EA__dblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblock_dest(H5EA_dblock_t *dblock)) +herr_t +H5EA__dblock_dest(H5EA_dblock_t *dblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblock); @@ -435,14 +468,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblock_dest(H5EA_dblock_t *dbl /* Free buffer for data block elements */ HDassert(dblock->nelmts > 0); if (H5EA__hdr_free_elmts(dblock->hdr, dblock->nelmts, dblock->elmts) < 0) - H5E_THROW(H5E_CANTFREE, "unable to free extensible array data block element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, + "unable to free extensible array data block element buffer") dblock->elmts = NULL; dblock->nelmts = 0; } /* end if */ /* Decrement reference count on shared info */ if (H5EA__hdr_decr(dblock->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") dblock->hdr = NULL; } /* end if */ @@ -452,6 +487,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblock_dest(H5EA_dblock_t *dbl /* Free the data block itself */ dblock = H5FL_FREE(H5EA_dblock_t, dblock); - CATCH - -END_FUNC(PKG) /* end H5EA__dblock_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_dest() */ diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index 7f142af3684..2c689497301 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -102,17 +102,21 @@ H5FL_SEQ_DEFINE_STATIC(H5EA_sblk_info_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, H5EA__hdr_alloc(H5F_t *f)) +H5EA_hdr_t * +H5EA__hdr_alloc(H5F_t *f) +{ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + H5EA_hdr_t *ret_value = NULL; - /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); /* Allocate space for the shared information */ if (NULL == (hdr = H5FL_CALLOC(H5EA_hdr_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; @@ -126,12 +130,13 @@ BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, H5EA__hdr_alloc(H5F_t *f)) /* Set the return value */ ret_value = hdr; - CATCH +done: if (!ret_value) if (hdr && H5EA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_init @@ -168,12 +173,15 @@ END_FUNC(PKG) /* end H5EA__hdr_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata)) - - /* Local variables */ +herr_t +H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata) +{ hsize_t start_idx; /* First element index for each super block */ hsize_t start_dblk; /* First data block index for each super block */ size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -188,7 +196,7 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void /* Allocate information for each super block */ if (NULL == (hdr->sblk_info = H5FL_SEQ_MALLOC(H5EA_sblk_info_t, hdr->nsblks))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for super block info array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, FAIL, "memory allocation failed for super block info array") /* Compute information about each super block */ start_idx = 0; @@ -202,7 +210,7 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void /* Advance starting indices for next super block */ start_idx += (hsize_t)hdr->sblk_info[u].ndblks * (hsize_t)hdr->sblk_info[u].dblk_nelmts; start_dblk += (hsize_t)hdr->sblk_info[u].ndblks; - } /* end for */ + } /* Set size of header on disk (locally and in statistics) */ hdr->stats.computed.hdr_size = hdr->size = H5EA_HEADER_SIZE_HDR(hdr); @@ -210,12 +218,13 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void /* Create the callback context, if there's one */ if (hdr->cparam.cls->crt_context) { if (NULL == (hdr->cb_ctx = (*hdr->cparam.cls->crt_context)(ctx_udata))) - H5E_THROW(H5E_CANTCREATE, "unable to create extensible array client callback context") - } /* end if */ - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, + "unable to create extensible array client callback context") + } -END_FUNC(PKG) /* end H5EA__hdr_init() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_init() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_alloc_elmts @@ -229,11 +238,14 @@ END_FUNC(PKG) /* end H5EA__hdr_init() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, void *, NULL, NULL, H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts)) - - /* Local variables */ +void * +H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts) +{ void * elmts = NULL; /* Element buffer allocated */ unsigned idx; /* Index of element buffer factory in header */ + void * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -251,8 +263,8 @@ BEGIN_FUNC(PKG, ERR, void *, NULL, NULL, H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, /* Re-allocate array of element factories */ if (NULL == (new_fac = H5FL_SEQ_REALLOC(H5FL_fac_head_ptr_t, hdr->elmt_fac.fac, new_nalloc))) - H5E_THROW(H5E_CANTALLOC, - "memory allocation failed for data block data element buffer factory array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block data element buffer factory array") /* Zero out new elements allocated */ HDmemset(new_fac + hdr->elmt_fac.nalloc, 0, @@ -266,22 +278,24 @@ BEGIN_FUNC(PKG, ERR, void *, NULL, NULL, H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, /* Check for un-initialized factory at index */ if (NULL == hdr->elmt_fac.fac[idx]) { if (NULL == (hdr->elmt_fac.fac[idx] = H5FL_fac_init(nelmts * (size_t)hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTINIT, "can't create data block data element buffer factory") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, "can't create data block data element buffer factory") } /* end if */ /* Allocate buffer for elements in index block */ if (NULL == (elmts = H5FL_FAC_MALLOC(hdr->elmt_fac.fac[idx]))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block data element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block data element buffer") /* Set the return value */ ret_value = elmts; - CATCH +done: if (!ret_value) if (elmts) elmts = H5FL_FAC_FREE(hdr->elmt_fac.fac[idx], elmts); -END_FUNC(PKG) /* end H5EA__hdr_alloc_elmts() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_alloc_elmts() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_free_elmts @@ -295,11 +309,13 @@ END_FUNC(PKG) /* end H5EA__hdr_alloc_elmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts)) - - /* Local variables */ +herr_t +H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts) +{ unsigned idx; /* Index of element buffer factory in header */ + FUNC_ENTER_PACKAGE_NOERR + /* Check arguments */ HDassert(hdr); HDassert(nelmts > 0); @@ -314,26 +330,30 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, HDassert(hdr->elmt_fac.fac[idx]); elmts = H5FL_FAC_FREE(hdr->elmt_fac.fac[idx], elmts); -END_FUNC(PKG) /* end H5EA__hdr_free_elmts() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__hdr_free_elmts() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_create * * Purpose: Creates a new extensible array header in the file * - * Return: SUCCEED/FAIL + * Return: Success: Address of new header in the file + * Failure: HADDR_UNDEF * * Programmer: Quincey Koziol * Jun 17 2008 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) +haddr_t +H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata) +{ + H5EA_hdr_t *hdr = NULL; /* Extensible array header */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Extensible array header */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -347,39 +367,45 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Check for valid parameters */ if (cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, "element size must be greater than zero") if (cparam->max_nelmts_bits == 0) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "max. # of elements bits must be greater than zero") if (cparam->max_nelmts_bits > H5EA_MAX_NELMTS_IDX_MAX) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be <= %u", - (unsigned)H5EA_MAX_NELMTS_IDX_MAX) + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, "max. # of elements bits must be <= %u", + (unsigned)H5EA_MAX_NELMTS_IDX_MAX) if (cparam->sup_blk_min_data_ptrs < 2) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be >= two") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "min # of data block pointers in super block must be >= two") if (!POWER_OF_TWO(cparam->sup_blk_min_data_ptrs)) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be power of two") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "min # of data block pointers in super block must be power of two") if (!POWER_OF_TWO(cparam->data_blk_min_elmts)) - H5E_THROW(H5E_BADVALUE, "min # of elements per data block must be power of two") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "min # of elements per data block must be power of two") dblk_page_nelmts = (size_t)1 << cparam->max_dblk_page_nelmts_bits; if (dblk_page_nelmts < cparam->idx_blk_elmts) - H5E_THROW(H5E_BADVALUE, - "# of elements per data block page must be greater than # of elements in index block") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "# of elements per data block page must be greater than # of elements in index block") /* Compute the number of elements in data blocks for first actual super block */ sblk_idx = H5EA_SBLK_FIRST_IDX(cparam->sup_blk_min_data_ptrs); dblk_nelmts = H5EA_SBLK_DBLK_NELMTS(sblk_idx, cparam->data_blk_min_elmts); if (dblk_page_nelmts < dblk_nelmts) - H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be > # of elements in " - "first data block from super block") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "max. # of elements per data block page bits must be > # of elements in " + "first data block from super block") if (cparam->max_dblk_page_nelmts_bits > cparam->max_nelmts_bits) - H5E_THROW(H5E_BADVALUE, - "max. # of elements per data block page bits must be <= max. # of elements bits") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "max. # of elements per data block page bits must be <= max. # of elements bits") } #endif /* NDEBUG */ /* Allocate space for the shared information */ if (NULL == (hdr = H5EA__hdr_alloc(f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for extensible array shared header") /* Set the internal parameters for the array */ hdr->idx_blk_addr = HADDR_UNDEF; @@ -389,49 +415,55 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Finish initializing extensible array header */ if (H5EA__hdr_init(hdr, ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, HADDR_UNDEF, + "initialization failed for extensible array header") /* Allocate space for the header on disk */ if (HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_EARRAY_HDR, (hsize_t)hdr->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for extensible array header") /* Create 'top' proxy for extensible array entries */ if (hdr->swmr_write) if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) - H5E_THROW(H5E_CANTCREATE, "can't create extensible array entry proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, HADDR_UNDEF, "can't create extensible array entry proxy") /* Cache the new extensible array header */ if (H5AC_insert_entry(f, H5AC_EARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array header to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, HADDR_UNDEF, "can't add extensible array header to cache") inserted = TRUE; /* Add header as child of 'top' proxy */ if (hdr->top_proxy) if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add extensible array entry as child of array proxy") /* Set address of array header to return */ ret_value = hdr->addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (hdr) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(hdr) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array header from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove extensible array header from cache") /* Release header's disk space */ if (H5F_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_EARRAY_HDR, hdr->addr, (hsize_t)hdr->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to free extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to free extensible array header") /* Destroy header */ if (H5EA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy extensible array header") } /* end if */ -END_FUNC(PKG) /* end H5EA__hdr_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_create() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_incr @@ -445,7 +477,12 @@ END_FUNC(PKG) /* end H5EA__hdr_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_incr(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_incr(H5EA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -453,14 +490,14 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_incr(H5EA_hdr_t *hdr)) /* Mark header as un-evictable when something is depending on it */ if (hdr->rc == 0) if (H5AC_pin_protected_entry(hdr) < 0) - H5E_THROW(H5E_CANTPIN, "unable to pin extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPIN, FAIL, "unable to pin extensible array header") /* Increment reference count on shared header */ hdr->rc++; - CATCH - -END_FUNC(PKG) /* end H5EA__hdr_incr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_incr() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_decr @@ -474,7 +511,12 @@ END_FUNC(PKG) /* end H5EA__hdr_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_decr(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_decr(H5EA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -487,12 +529,12 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_decr(H5EA_hdr_t *hdr)) if (hdr->rc == 0) { HDassert(hdr->file_rc == 0); if (H5AC_unpin_entry(hdr) < 0) - H5E_THROW(H5E_CANTUNPIN, "unable to unpin extensible array header") - } /* end if */ - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPIN, FAIL, "unable to unpin extensible array header") + } -END_FUNC(PKG) /* end H5EA__hdr_decr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_decr() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_fuse_incr @@ -506,7 +548,10 @@ END_FUNC(PKG) /* end H5EA__hdr_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr) +{ + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -514,21 +559,28 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr)) /* Increment file reference count on shared header */ hdr->file_rc++; -END_FUNC(PKG) /* end H5EA__hdr_fuse_incr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__hdr_fuse_incr() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_fuse_decr * * Purpose: Decrement file reference count on shared array header * - * Return: Non-negative on success/Negative on failure + * Return: Success: The reference count of the header + * Failure: Can't fail * * Programmer: Quincey Koziol * Aug 26 2008 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr)) +size_t +H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr) +{ + size_t ret_value = 0; + + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -540,7 +592,8 @@ BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr)) /* Set return value */ ret_value = hdr->file_rc; -END_FUNC(PKG) /* end H5EA__hdr_fuse_decr() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_fuse_decr() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_modified @@ -554,7 +607,12 @@ END_FUNC(PKG) /* end H5EA__hdr_fuse_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_modified(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_modified(H5EA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -562,11 +620,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_modified(H5EA_hdr_t *hdr)) /* Mark header as dirty in cache */ if (H5AC_mark_entry_dirty(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as dirty") - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTMARKDIRTY, FAIL, "unable to mark extensible array header as dirty") -END_FUNC(PKG) /* end H5EA__hdr_modified() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_modified() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_protect @@ -580,12 +638,14 @@ END_FUNC(PKG) /* end H5EA__hdr_modified() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, - H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, void *ctx_udata, unsigned flags)) - - /* Local variables */ +H5EA_hdr_t * +H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, void *ctx_udata, unsigned flags) +{ H5EA_hdr_t * hdr; /* Extensible array header */ H5EA_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5EA_hdr_t * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(f); @@ -601,27 +661,28 @@ BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, /* Protect the header */ if (NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, H5AC_EARRAY_HDR, ea_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", - (unsigned long long)ea_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array header, address = %llu", (unsigned long long)ea_addr) hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ /* Create top proxy, if it doesn't exist */ if (hdr->swmr_write && NULL == hdr->top_proxy) { /* Create 'top' proxy for extensible array entries */ if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) - H5E_THROW(H5E_CANTCREATE, "can't create extensible array entry proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, NULL, "can't create extensible array entry proxy") /* Add header as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") } /* end if */ /* Set return value */ ret_value = hdr; - CATCH - -END_FUNC(PKG) /* end H5EA__hdr_protect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_unprotect @@ -635,21 +696,24 @@ END_FUNC(PKG) /* end H5EA__hdr_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags)) +herr_t +H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Unprotect the header */ if (H5AC_unprotect(hdr->f, H5AC_EARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array hdr, address = %llu", - (unsigned long long)hdr->addr) - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array hdr, address = %llu", (unsigned long long)hdr->addr) -END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_delete @@ -663,46 +727,48 @@ END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_delete(H5EA_hdr_t *hdr)) - - /* Local variables */ +herr_t +H5EA__hdr_delete(H5EA_hdr_t *hdr) +{ unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); HDassert(!hdr->file_rc); #ifndef NDEBUG - { - unsigned hdr_status = 0; /* Array header's status in the metadata cache */ + unsigned hdr_status = 0; /* Array header's status in the metadata cache */ - /* Check the array header's status in the metadata cache */ - if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for array header") + /* Check the array header's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to check metadata cache status for array header") - /* Sanity checks on array header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PROTECTED); - } /* end block */ + /* Sanity checks on array header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PROTECTED); #endif /* NDEBUG */ /* Check for index block */ if (H5F_addr_defined(hdr->idx_blk_addr)) { /* Delete index block */ if (H5EA__iblock_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, "unable to delete extensible array index block") } /* end if */ /* Set flags to finish deleting header on unprotect */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; - CATCH +done: /* Unprotect the header, deleting it if an error hasn't occurred */ if (H5EA__hdr_unprotect(hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_delete() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_dest @@ -716,7 +782,12 @@ END_FUNC(PKG) /* end H5EA__hdr_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_dest(H5EA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -725,7 +796,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Destroy the callback context */ if (hdr->cb_ctx) { if ((*hdr->cparam.cls->dst_context)(hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array client callback context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, + "unable to destroy extensible array client callback context") } /* end if */ hdr->cb_ctx = NULL; @@ -741,7 +813,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Check if this factory has been initialized */ if (hdr->elmt_fac.fac[u]) { if (H5FL_fac_term(hdr->elmt_fac.fac[u]) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array header factory") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, + "unable to destroy extensible array header factory") hdr->elmt_fac.fac[u] = NULL; } /* end if */ } /* end for */ @@ -757,13 +830,13 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Destroy the 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_dest(hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to destroy extensible array 'top' proxy") hdr->top_proxy = NULL; } /* end if */ /* Free the shared info itself */ hdr = H5FL_FREE(H5EA_hdr_t, hdr); - CATCH - -END_FUNC(PKG) /* end H5EA__hdr_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_dest() */ diff --git a/src/H5EAiblock.c b/src/H5EAiblock.c index 1ef7980ad25..5afb28a4212 100644 --- a/src/H5EAiblock.c +++ b/src/H5EAiblock.c @@ -91,21 +91,25 @@ H5FL_SEQ_DEFINE_STATIC(haddr_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_alloc(H5EA_hdr_t *hdr)) +H5EA_iblock_t * +H5EA__iblock_alloc(H5EA_hdr_t *hdr) +{ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + H5EA_iblock_t *ret_value = NULL; - /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); /* Allocate memory for the index block */ if (NULL == (iblock = H5FL_CALLOC(H5EA_iblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array index block") /* Share common array information */ if (H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") iblock->hdr = hdr; /* Set non-zero internal fields */ @@ -121,27 +125,30 @@ BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_alloc(H5EA_hdr_t if (NULL == (iblock->elmts = H5FL_BLK_MALLOC( idx_blk_elmt_buf, (size_t)(hdr->cparam.idx_blk_elmts * hdr->cparam.cls->nat_elmt_size)))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block data element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for index block data element buffer") /* Allocate buffer for data block addresses in index block */ if (iblock->ndblk_addrs > 0) if (NULL == (iblock->dblk_addrs = H5FL_SEQ_MALLOC(haddr_t, iblock->ndblk_addrs))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block data block addresses") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for index block data block addresses") /* Allocate buffer for super block addresses in index block */ if (iblock->nsblk_addrs > 0) if (NULL == (iblock->sblk_addrs = H5FL_SEQ_MALLOC(haddr_t, iblock->nsblk_addrs))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block super block addresses") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for index block super block addresses") /* Set the return value */ ret_value = iblock; - CATCH +done: if (!ret_value) if (iblock && H5EA__iblock_dest(iblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") - -END_FUNC(PKG) /* end H5EA__iblock_alloc() */ + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array index block") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_create @@ -155,13 +162,15 @@ END_FUNC(PKG) /* end H5EA__iblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed)) +haddr_t +H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed) +{ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + haddr_t iblock_addr; /* Extensible array index block address */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ - haddr_t iblock_addr; /* Extensible array index block address */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -169,21 +178,24 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate the index block */ if (NULL == (iblock = H5EA__iblock_alloc(hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for extensible array index block") /* Set size of index block on disk */ iblock->size = H5EA_IBLOCK_SIZE(iblock); /* Allocate space for the index block on disk */ if (HADDR_UNDEF == (iblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_IBLOCK, (hsize_t)iblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for extensible array index block") iblock->addr = iblock_addr; /* Clear any elements in index block to fill value */ if (hdr->cparam.idx_blk_elmts > 0) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(iblock->elmts, (size_t)hdr->cparam.idx_blk_elmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set extensible array index block elements to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "can't set extensible array index block elements to class's fill value") } /* end if */ /* Reset any data block addresses in the index block */ @@ -204,13 +216,15 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Cache the new extensible array index block */ if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_IBLOCK, iblock_addr, iblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array index block to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, HADDR_UNDEF, + "can't add extensible array index block to cache") inserted = TRUE; /* Add index block as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, iblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add extensible array entry as child of array proxy") iblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -229,25 +243,29 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Set address of index block to return */ ret_value = iblock_addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (iblock) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(iblock) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array index block from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove extensible array index block from cache") /* Release index block's disk space */ if (H5F_addr_defined(iblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to release file space for extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to release file space for extensible array index block") /* Destroy index block */ if (H5EA__iblock_dest(iblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy extensible array index block") } /* end if */ -END_FUNC(PKG) /* end H5EA__iblock_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_create() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_protect @@ -261,10 +279,13 @@ END_FUNC(PKG) /* end H5EA__iblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags)) +H5EA_iblock_t * +H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags) +{ + H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + H5EA_iblock_t *ret_value = NULL; - /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -275,31 +296,35 @@ BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_protect(H5EA_hdr_ /* Protect the index block */ if (NULL == (iblock = (H5EA_iblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_IBLOCK, hdr->idx_blk_addr, hdr, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", - (unsigned long long)hdr->idx_blk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == iblock->top_proxy) { /* Add index block as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, iblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") iblock->top_proxy = hdr->top_proxy; } /* end if */ /* Set return value */ ret_value = iblock; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the index block, if it was protected */ if (iblock && H5AC_unprotect(hdr->f, H5AC_EARRAY_IBLOCK, iblock->addr, iblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array index block, address = %llu", - (unsigned long long)iblock->addr) + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect extensible array index block, address = %llu", + (unsigned long long)iblock->addr) } /* end if */ -END_FUNC(PKG) /* end H5EA__iblock_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_unprotect @@ -313,22 +338,25 @@ END_FUNC(PKG) /* end H5EA__iblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags)) +herr_t +H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(iblock); /* Unprotect the index block */ if (H5AC_unprotect(iblock->hdr->f, H5AC_EARRAY_IBLOCK, iblock->addr, iblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array index block, address = %llu", - (unsigned long long)iblock->addr) - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array index block, address = %llu", + (unsigned long long)iblock->addr) -END_FUNC(PKG) /* end H5EA__iblock_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_delete @@ -342,10 +370,13 @@ END_FUNC(PKG) /* end H5EA__iblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr)) +herr_t +H5EA__iblock_delete(H5EA_hdr_t *hdr) +{ + H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -353,8 +384,9 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr) /* Protect index block */ if (NULL == (iblock = H5EA__iblock_protect(hdr, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", - (unsigned long long)hdr->idx_blk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Check for index block having data block pointers */ if (iblock->ndblk_addrs > 0) { @@ -370,7 +402,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr) /* Delete data block */ if (H5EA__dblock_delete(hdr, iblock, iblock->dblk_addrs[u], hdr->sblk_info[sblk_idx].dblk_nelmts) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, + "unable to delete extensible array data block") iblock->dblk_addrs[u] = HADDR_UNDEF; } /* end if */ @@ -396,19 +429,21 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr) /* Delete super block */ if (H5EA__sblock_delete(hdr, iblock, iblock->sblk_addrs[u], (unsigned)(u + iblock->nsblks)) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, + "unable to delete extensible array super block") iblock->sblk_addrs[u] = HADDR_UNDEF; - } /* end if */ - } /* end for */ - } /* end if */ + } + } + } - CATCH +done: /* Finished deleting index block in metadata cache */ if (iblock && H5EA__iblock_unprotect(iblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block") -END_FUNC(PKG) /* end H5EA__iblock_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_delete() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_dest @@ -422,7 +457,12 @@ END_FUNC(PKG) /* end H5EA__iblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_dest(H5EA_iblock_t *iblock)) +herr_t +H5EA__iblock_dest(H5EA_iblock_t *iblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(iblock); @@ -454,7 +494,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_dest(H5EA_iblock_t *ibl /* Decrement reference count on shared info */ if (H5EA__hdr_decr(iblock->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") iblock->hdr = NULL; } /* end if */ @@ -464,6 +505,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_dest(H5EA_iblock_t *ibl /* Free the index block itself */ iblock = H5FL_FREE(H5EA_iblock_t, iblock); - CATCH - -END_FUNC(PKG) /* end H5EA__iblock_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_dest() */ diff --git a/src/H5EAint.c b/src/H5EAint.c index 472cfb4e617..af7ff4c8fee 100644 --- a/src/H5EAint.c +++ b/src/H5EAint.c @@ -79,8 +79,12 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +herr_t +H5EA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(parent_entry); @@ -88,11 +92,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Create a flush dependency between parent and child entry */ if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency") - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") -END_FUNC(PKG) /* end H5EA__create_flush_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__create_flush_depend() */ /*------------------------------------------------------------------------- * Function: H5EA__destroy_flush_depend @@ -106,8 +110,12 @@ END_FUNC(PKG) /* end H5EA__create_flush_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +herr_t +H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(parent_entry); @@ -115,8 +123,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Destroy a flush dependency between parent and child entry */ if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") -END_FUNC(PKG) /* end H5EA__destroy_flush_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__destroy_flush_depend() */ diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c index 86392179674..30cb2209265 100644 --- a/src/H5EAsblock.c +++ b/src/H5EAsblock.c @@ -91,22 +91,25 @@ H5FL_BLK_DEFINE(page_init); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, - H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx)) +H5EA_sblock_t * +H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx) +{ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + H5EA_sblock_t *ret_value = NULL; - /* Local variables */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); /* Allocate memory for the index block */ if (NULL == (sblock = H5FL_CALLOC(H5EA_sblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array super block") /* Share common array information */ if (H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") sblock->hdr = hdr; /* Set non-zero internal fields */ @@ -121,7 +124,8 @@ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, /* Allocate buffer for data block addresses in super block */ if (NULL == (sblock->dblk_addrs = H5FL_SEQ_MALLOC(haddr_t, sblock->ndblks))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for super block data block addresses") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for super block data block addresses") /* Check if # of elements in data blocks requires paging */ if (sblock->dblk_nelmts > hdr->dblk_page_nelmts) { @@ -141,7 +145,8 @@ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, /* Allocate buffer for all 'page init' bitmasks in super block */ if (NULL == (sblock->page_init = H5FL_BLK_CALLOC(page_init, sblock->ndblks * sblock->dblk_page_init_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for super block page init bitmask") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for super block page init bitmask") /* Compute data block page size */ sblock->dblk_page_size = (hdr->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5EA_SIZEOF_CHKSUM; @@ -150,12 +155,13 @@ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, /* Set the return value */ ret_value = sblock; - CATCH +done: if (!ret_value) if (sblock && H5EA__sblock_dest(sblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array super block") -END_FUNC(PKG) /* end H5EA__sblock_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_create @@ -169,15 +175,16 @@ END_FUNC(PKG) /* end H5EA__sblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_changed, - unsigned sblk_idx)) +haddr_t +H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_changed, unsigned sblk_idx) +{ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + haddr_t sblock_addr; /* Extensible array super block address */ + haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ - haddr_t sblock_addr; /* Extensible array super block address */ - haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -185,7 +192,8 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate the super block */ if (NULL == (sblock = H5EA__sblock_alloc(hdr, parent, sblk_idx))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for extensible array super block") /* Set size of super block on disk */ sblock->size = H5EA_SBLOCK_SIZE(sblock); @@ -195,7 +203,8 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate space for the super block on disk */ if (HADDR_UNDEF == (sblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_SBLOCK, (hsize_t)sblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for extensible array super block") sblock->addr = sblock_addr; /* Reset data block addresses to "undefined" address value */ @@ -203,13 +212,15 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Cache the new extensible array super block */ if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_SBLOCK, sblock_addr, sblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array super block to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, HADDR_UNDEF, + "can't add extensible array super block to cache") inserted = TRUE; /* Add super block as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, sblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add extensible array entry as child of array proxy") sblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -223,25 +234,29 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Set address of super block to return */ ret_value = sblock_addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (sblock) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(sblock) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array super block from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove extensible array super block from cache") /* Release super block's disk space */ if (H5F_addr_defined(sblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_SBLOCK, sblock->addr, (hsize_t)sblock->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to release extensible array super block") /* Destroy super block */ if (H5EA__sblock_dest(sblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy extensible array super block") } /* end if */ -END_FUNC(PKG) /* end H5EA__sblock_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_create() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_protect @@ -255,13 +270,15 @@ END_FUNC(PKG) /* end H5EA__sblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, - H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx, - unsigned flags)) - - /* Local variables */ +H5EA_sblock_t * +H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx, + unsigned flags) +{ H5EA_sblock_t * sblock = NULL; /* Pointer to super block */ H5EA_sblock_cache_ud_t udata; /* Information needed for loading super block */ + H5EA_sblock_t * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -279,31 +296,35 @@ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, /* Protect the super block */ if (NULL == (sblock = (H5EA_sblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_SBLOCK, sblk_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", - (unsigned long long)sblk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array super block, address = %llu", + (unsigned long long)sblk_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == sblock->top_proxy) { /* Add super block as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, sblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") sblock->top_proxy = hdr->top_proxy; - } /* end if */ + } /* Set return value */ ret_value = sblock; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the super block, if it was protected */ if (sblock && H5AC_unprotect(hdr->f, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array super block, address = %llu", - (unsigned long long)sblock->addr) - } /* end if */ + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect extensible array super block, address = %llu", + (unsigned long long)sblock->addr) + } -END_FUNC(PKG) /* end H5EA__sblock_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_unprotect @@ -317,22 +338,25 @@ END_FUNC(PKG) /* end H5EA__sblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags)) +herr_t +H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(sblock); /* Unprotect the super block */ if (H5AC_unprotect(sblock->hdr->f, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array super block, address = %llu", - (unsigned long long)sblock->addr) - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array super block, address = %llu", + (unsigned long long)sblock->addr) -END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_delete @@ -346,12 +370,14 @@ END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__sblock_delete(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx)) - - /* Local variables */ +herr_t +H5EA__sblock_delete(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx) +{ H5EA_sblock_t *sblock = NULL; /* Pointer to super block */ size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -359,8 +385,9 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Protect super block */ if (NULL == (sblock = H5EA__sblock_protect(hdr, parent, sblk_addr, sblk_idx, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", - (unsigned long long)sblk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array super block, address = %llu", + (unsigned long long)sblk_addr) /* Iterate over data blocks */ for (u = 0; u < sblock->ndblks; u++) { @@ -368,18 +395,19 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (H5F_addr_defined(sblock->dblk_addrs[u])) { /* Delete data block */ if (H5EA__dblock_delete(hdr, sblock, sblock->dblk_addrs[u], sblock->dblk_nelmts) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, "unable to delete extensible array data block") sblock->dblk_addrs[u] = HADDR_UNDEF; } /* end if */ } /* end for */ - CATCH +done: /* Finished deleting super block in metadata cache */ if (sblock && H5EA__sblock_unprotect(sblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block") -END_FUNC(PKG) /* end H5EA__sblock_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_delete() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_dest @@ -393,7 +421,12 @@ END_FUNC(PKG) /* end H5EA__sblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__sblock_dest(H5EA_sblock_t *sblock)) +herr_t +H5EA__sblock_dest(H5EA_sblock_t *sblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(sblock); @@ -413,7 +446,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__sblock_dest(H5EA_sblock_t *sbl /* Decrement reference count on shared info */ if (H5EA__hdr_decr(sblock->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") sblock->hdr = NULL; } /* end if */ @@ -423,6 +457,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__sblock_dest(H5EA_sblock_t *sbl /* Free the super block itself */ sblock = H5FL_FREE(H5EA_sblock_t, sblock); - CATCH - -END_FUNC(PKG) /* end H5EA__sblock_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_dest() */ diff --git a/src/H5EAstat.c b/src/H5EAstat.c index 47b9a869dbe..5705cb8d928 100644 --- a/src/H5EAstat.c +++ b/src/H5EAstat.c @@ -80,17 +80,17 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats)) +herr_t +H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats) +{ + FUNC_ENTER_NOAPI_NOERR - /* Local variables */ - - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(stats); /* Copy extensible array statistics */ H5MM_memcpy(stats, &ea->hdr->stats, sizeof(ea->hdr->stats)); -END_FUNC(PRIV) /* end H5EA_get_stats() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA_get_stats() */ diff --git a/src/H5EAtest.c b/src/H5EAtest.c index dd669fc44d7..7924eaab235 100644 --- a/src/H5EAtest.c +++ b/src/H5EAtest.c @@ -119,17 +119,19 @@ H5FL_DEFINE_STATIC(H5EA__ctx_cb_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5EA__test_crt_context(void *_udata)) +static void * +H5EA__test_crt_context(void *_udata) +{ + H5EA__test_ctx_t *ctx; /* Context for callbacks */ + H5EA__ctx_cb_t * udata = (H5EA__ctx_cb_t *)_udata; /* User data for context */ + void * ret_value = NULL; - /* Local variables */ - H5EA__test_ctx_t *ctx; /* Context for callbacks */ - H5EA__ctx_cb_t * udata = (H5EA__ctx_cb_t *)_udata; /* User data for context */ - - /* Sanity checks */ + FUNC_ENTER_STATIC /* Allocate new context structure */ if (NULL == (ctx = H5FL_MALLOC(H5EA__test_ctx_t))) - H5E_THROW(H5E_CANTALLOC, "can't allocate extensible array client callback context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "can't allocate extensible array client callback context") /* Initialize the context */ ctx->bogus = H5EA__TEST_BOGUS_VAL; @@ -138,9 +140,9 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5EA__test_crt_context(void *_udata) /* Set return value */ ret_value = ctx; - CATCH - -END_FUNC(STATIC) /* end H5EA__test_crt_context() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__test_crt_context() */ /*------------------------------------------------------------------------- * Function: H5EA__test_dst_context @@ -155,18 +157,21 @@ END_FUNC(STATIC) /* end H5EA__test_crt_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_dst_context(void *_ctx)) - - /* Local variables */ +static herr_t +H5EA__test_dst_context(void *_ctx) +{ H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(H5EA__TEST_BOGUS_VAL == ctx->bogus); /* Release context structure */ ctx = H5FL_FREE(H5EA__test_ctx_t, ctx); -END_FUNC(STATIC) /* end H5EA__test_dst_context() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_dst_context() */ /*------------------------------------------------------------------------- * Function: H5EA__test_fill @@ -181,18 +186,21 @@ END_FUNC(STATIC) /* end H5EA__test_dst_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_fill(void *nat_blk, size_t nelmts)) - - /* Local variables */ +static herr_t +H5EA__test_fill(void *nat_blk, size_t nelmts) +{ uint64_t fill_val = H5EA_TEST_FILL; /* Value to fill elements with */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(nat_blk); HDassert(nelmts); H5VM_array_fill(nat_blk, &fill_val, sizeof(uint64_t), nelmts); -END_FUNC(STATIC) /* end H5EA__test_fill() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_fill() */ /*------------------------------------------------------------------------- * Function: H5EA__test_encode @@ -207,12 +215,14 @@ END_FUNC(STATIC) /* end H5EA__test_fill() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) +static herr_t +H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) +{ + H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ + const uint64_t * elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ - const uint64_t * elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(raw); @@ -223,13 +233,12 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Check for callback action */ if (ctx->cb) { if ((*ctx->cb->encode)(elmt, nelmts, ctx->cb->udata) < 0) - H5E_THROW(H5E_BADVALUE, "extensible array testing callback action failed") - } /* end if */ + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "extensible array testing callback action failed") + } /* Encode native elements into raw elements */ while (nelmts) { - /* Encode element */ - /* (advances 'raw' pointer) */ + /* Encode element - advances 'raw' pointer */ UINT64ENCODE(raw, *elmt); /* Advance native element pointer */ @@ -237,11 +246,11 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Decrement # of elements to encode */ nelmts--; - } /* end while */ + } - CATCH - -END_FUNC(STATIC) /* end H5EA__test_encode() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__test_encode() */ /*------------------------------------------------------------------------- * Function: H5EA__test_decode @@ -256,16 +265,17 @@ END_FUNC(STATIC) /* end H5EA__test_encode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDEBUG_UNUSED *_ctx)) - -/* Local variables */ +static herr_t +H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDEBUG_UNUSED *_ctx) +{ #ifndef NDEBUG H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ #endif /* NDEBUG */ uint64_t * elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(raw); HDassert(elmt); @@ -274,8 +284,7 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Decode raw elements into native elements */ while (nelmts) { - /* Decode element */ - /* (advances 'raw' pointer) */ + /* Decode element - advances 'raw' pointer */ UINT64DECODE(raw, *elmt); /* Advance native element pointer */ @@ -283,9 +292,10 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Decrement # of elements to decode */ nelmts--; - } /* end while */ + } -END_FUNC(STATIC) /* end H5EA__test_decode() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_decode() */ /*------------------------------------------------------------------------- * Function: H5EA__test_debug @@ -300,12 +310,13 @@ END_FUNC(STATIC) /* end H5EA__test_decode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt)) - - /* Local variables */ +static herr_t +H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt) +{ char temp_str[128]; /* Temporary string, for formatting */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(stream); HDassert(elmt); @@ -315,7 +326,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str, (unsigned long long)*(const uint64_t *)elmt); -END_FUNC(STATIC) /* end H5EA__test_debug() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__test_crt_dbg_context @@ -329,22 +341,25 @@ END_FUNC(STATIC) /* end H5EA__test_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr)) - - /* Local variables */ +static void * +H5EA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr) +{ H5EA__ctx_cb_t *ctx; /* Context for callbacks */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Allocate new context structure */ if (NULL == (ctx = H5FL_MALLOC(H5EA__ctx_cb_t))) - H5E_THROW(H5E_CANTALLOC, "can't allocate extensible array client callback context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "can't allocate extensible array client callback context") /* Set return value */ ret_value = ctx; - CATCH - -END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__test_crt_dbg_context() */ /*------------------------------------------------------------------------- * Function: H5EA__test_dst_dbg_context @@ -358,17 +373,20 @@ END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_dst_dbg_context(void *_ctx)) - - /* Local variables */ +static herr_t +H5EA__test_dst_dbg_context(void *_ctx) +{ H5EA__ctx_cb_t *ctx = (H5EA__ctx_cb_t *)_ctx; /* Callback context to destroy */ + FUNC_ENTER_STATIC_NOERR + HDassert(_ctx); /* Release context structure */ ctx = H5FL_FREE(H5EA__ctx_cb_t, ctx); -END_FUNC(STATIC) /* end H5EA__test_dst_dbg_context() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_dst_dbg_context() */ /*------------------------------------------------------------------------- * Function: H5EA__get_cparam_test @@ -383,7 +401,10 @@ END_FUNC(STATIC) /* end H5EA__test_dst_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam)) +herr_t +H5EA__get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam) +{ + FUNC_ENTER_PACKAGE_NOERR /* Check arguments. */ HDassert(ea); @@ -397,7 +418,8 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__get_cparam_test(const H5EA_t *e cparam->data_blk_min_elmts = ea->hdr->cparam.data_blk_min_elmts; cparam->max_dblk_page_nelmts_bits = ea->hdr->cparam.max_dblk_page_nelmts_bits; -END_FUNC(PKG) /* end H5EA__get_cparam_test() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__get_cparam_test() */ /*------------------------------------------------------------------------- * Function: H5EA__cmp_cparam_test @@ -412,39 +434,48 @@ END_FUNC(PKG) /* end H5EA__get_cparam_test() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, - H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2)) +int +H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2) +{ + int ret_value = 0; - /* Check arguments. */ + FUNC_ENTER_PACKAGE_NOERR + + /* Check arguments */ HDassert(cparam1); HDassert(cparam2); /* Compare creation parameters for array */ if (cparam1->raw_elmt_size < cparam2->raw_elmt_size) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->raw_elmt_size > cparam2->raw_elmt_size) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->max_nelmts_bits < cparam2->max_nelmts_bits) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->max_nelmts_bits > cparam2->max_nelmts_bits) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->idx_blk_elmts < cparam2->idx_blk_elmts) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->idx_blk_elmts > cparam2->idx_blk_elmts) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->sup_blk_min_data_ptrs < cparam2->sup_blk_min_data_ptrs) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->sup_blk_min_data_ptrs > cparam2->sup_blk_min_data_ptrs) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->data_blk_min_elmts < cparam2->data_blk_min_elmts) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->data_blk_min_elmts > cparam2->data_blk_min_elmts) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->max_dblk_page_nelmts_bits < cparam2->max_dblk_page_nelmts_bits) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->max_dblk_page_nelmts_bits > cparam2->max_dblk_page_nelmts_bits) - H5_LEAVE(1) - - CATCH + HGOTO_DONE(1) -END_FUNC(PKG) /* end H5EA__cmp_cparam_test() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cmp_cparam_test() */ diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index c3c440ff635..ae86f92facd 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -185,53 +185,6 @@ extern int H5E_mpi_error_str_len; } #endif /* H5_HAVE_PARALLEL */ -/******************************************************************************/ -/* Revisions to Error Macros, to go with Revisions to FUNC_ENTER/LEAVE Macros */ -/******************************************************************************/ - -/* - * H5E_PRINTF macro, used to facilitate error reporting between a BEGIN_FUNC() - * and an END_FUNC() within a function body. The arguments are the minor - * error number, a description of the error (as a printf-like format string), - * and an optional set of arguments for the printf format arguments. - */ -#define H5E_PRINTF(...) \ - H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, H5_MY_PKG_ERR, __VA_ARGS__) - -/* - * H5_LEAVE macro, used to facilitate control flow between a - * BEGIN_FUNC() and an END_FUNC() within a function body. The argument is - * the return value. - * The return value is assigned to a variable `ret_value' and control branches - * to the `catch_except' label, if we're not already past it. - */ -#define H5_LEAVE(v) \ - { \ - ret_value = v; \ - if (!past_catch) \ - goto catch_except; \ - } - -/* - * H5E_THROW macro, used to facilitate error reporting between a - * FUNC_ENTER() and a FUNC_LEAVE() within a function body. The arguments are - * the minor error number, and an error string. - * The return value is assigned to a variable `ret_value' and control branches - * to the `catch_except' label, if we're not already past it. - */ -#define H5E_THROW(...) \ - { \ - H5E_PRINTF(__VA_ARGS__); \ - H5_LEAVE(fail_value) \ - } - -/* Macro for "catching" flow of control when an error occurs. Note that the - * H5_LEAVE macro won't jump back here once it's past this point. - */ -#define CATCH \ -catch_except:; \ - past_catch = TRUE; - /* Library-private functions defined in H5E package */ H5_DLL herr_t H5E_init(void); H5_DLL herr_t H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, diff --git a/src/H5Epublic.h b/src/H5Epublic.h index 2f529b330b9..1c7055aed1b 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -24,7 +24,7 @@ #include "H5Ipublic.h" /* Value for the default error stack */ -#define H5E_DEFAULT (hid_t)0 +#define H5E_DEFAULT 0 /* (hid_t) */ /** * Different kinds of error information diff --git a/src/H5FA.c b/src/H5FA.c index 05b0bd8a1e8..ad69ee23108 100644 --- a/src/H5FA.c +++ b/src/H5FA.c @@ -105,39 +105,40 @@ H5FL_BLK_DEFINE(fa_native_elmt); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, H5FA_t *, NULL, NULL, - H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata)) +static H5FA_t * +H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata) +{ + H5FA_t * fa = NULL; /* Pointer to new fixed array */ + H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + H5FA_t * ret_value = NULL; - /* Local variables */ - H5FA_t * fa = NULL; /* Pointer to new fixed array */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + FUNC_ENTER_STATIC - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(fa_addr)); /* Allocate fixed array wrapper */ if (NULL == (fa = H5FL_CALLOC(H5FA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for fixed array info") /* Lock the array header into memory */ if (NULL == (hdr = H5FA__hdr_protect(f, fa_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, "unable to load fixed array header") /* Check for pending array deletion */ if (from_open && hdr->pending_delete) - H5E_THROW(H5E_CANTOPENOBJ, "can't open fixed array pending deletion") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTOPENOBJ, NULL, "can't open fixed array pending deletion") /* Point fixed array wrapper at header and bump it's ref count */ fa->hdr = hdr; if (H5FA__hdr_incr(fa->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") /* Increment # of files using this array header */ if (H5FA__hdr_fuse_incr(fa->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, + "can't increment file reference count on shared array header") /* Set file pointer for this array open context */ fa->f = f; @@ -145,15 +146,15 @@ BEGIN_FUNC(STATIC, ERR, H5FA_t *, NULL, NULL, /* Set the return value */ ret_value = fa; - CATCH - +done: if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, "unable to release fixed array header") if (!ret_value) if (fa && H5FA_close(fa) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") -END_FUNC(STATIC) /* end H5FA__new() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__new() */ /*------------------------------------------------------------------------- * Function: H5FA_create @@ -168,16 +169,16 @@ END_FUNC(STATIC) /* end H5FA__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, - H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) - - /* Local variables */ +H5FA_t * +H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata) +{ H5FA_t *fa = NULL; /* Pointer to new fixed array */ haddr_t fa_addr; /* Fixed array header address */ + H5FA_t *ret_value = NULL; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ HDassert(f); HDassert(cparam); @@ -186,22 +187,23 @@ BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, /* Create fixed array header */ if (HADDR_UNDEF == (fa_addr = H5FA__hdr_create(f, cparam, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "can't create fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, "can't create fixed array header") /* Allocate and initialize new fixed array wrapper */ if (NULL == (fa = H5FA__new(f, fa_addr, FALSE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; - CATCH - +done: if (!ret_value) if (fa && H5FA_close(fa) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") -END_FUNC(PRIV) /* end H5FA_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_create() */ /*------------------------------------------------------------------------- * Function: H5FA_open @@ -216,31 +218,33 @@ END_FUNC(PRIV) /* end H5FA_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) +H5FA_t * +H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata) +{ + H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ + H5FA_t *ret_value = NULL; - /* Local variables */ - H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ + FUNC_ENTER_NOAPI(NULL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(fa_addr)); /* Allocate and initialize new fixed array wrapper */ if (NULL == (fa = H5FA__new(f, fa_addr, TRUE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; - CATCH - +done: if (!ret_value) if (fa && H5FA_close(fa) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") -END_FUNC(PRIV) /* end H5FA_open() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_open() */ /*------------------------------------------------------------------------- * Function: H5FA_get_nelmts @@ -254,20 +258,20 @@ END_FUNC(PRIV) /* end H5FA_open() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts)) - - /* Local variables */ +herr_t +H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(nelmts); /* Retrieve the current number of elements in the fixed array */ *nelmts = fa->hdr->stats.nelmts; -END_FUNC(PRIV) /* end H5FA_get_nelmts() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_get_nelmts() */ /*------------------------------------------------------------------------- * Function: H5FA_get_addr @@ -281,13 +285,12 @@ END_FUNC(PRIV) /* end H5FA_get_nelmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_addr(const H5FA_t *fa, haddr_t *addr)) - - /* Local variables */ +herr_t +H5FA_get_addr(const H5FA_t *fa, haddr_t *addr) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(fa->hdr); HDassert(addr); @@ -295,7 +298,8 @@ BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_addr(const H5FA_t *fa, hadd /* Retrieve the address of the fixed array's header */ *addr = fa->hdr->addr; -END_FUNC(PRIV) /* end H5FA_get_addr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_get_addr() */ /*------------------------------------------------------------------------- * Function: H5FA_set @@ -309,9 +313,9 @@ END_FUNC(PRIV) /* end H5FA_get_addr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt)) - - /* Local variables */ +herr_t +H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt) +{ H5FA_hdr_t * hdr = fa->hdr; /* Header for fixed array */ H5FA_dblock_t * dblock = NULL; /* Pointer to fixed array Data block */ H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to fixed array Data block page */ @@ -319,10 +323,11 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t unsigned dblk_page_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting FIxed Array Data block page */ hbool_t hdr_dirty = FALSE; /* Whether header information changed */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(fa); HDassert(fa->hdr); @@ -334,15 +339,16 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t /* Create the data block */ hdr->dblk_addr = H5FA__dblock_create(hdr, &hdr_dirty); if (!H5F_addr_defined(hdr->dblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create fixed array data block") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, FAIL, "unable to create fixed array data block") + } HDassert(idx < hdr->cparam.nelmts); /* Protect data block */ if (NULL == (dblock = H5FA__dblock_protect(hdr, hdr->dblk_addr, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)hdr->dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", + (unsigned long long)hdr->dblk_addr) /* Check for paging data block */ if (!dblock->npages) { @@ -375,7 +381,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t if (!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { /* Create the data block page */ if (H5FA__dblk_page_create(hdr, dblk_page_addr, dblk_page_nelmts) < 0) - H5E_THROW(H5E_CANTCREATE, "unable to create data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, FAIL, "unable to create data block page") /* Mark data block page as initialized in data block */ H5VM_bit_set(dblock->dblk_page_init, page_idx, TRUE); @@ -385,8 +391,9 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t /* Protect the data block page */ if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Set the element in the data block page */ H5MM_memcpy(((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, @@ -394,19 +401,20 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t dblk_page_cache_flags |= H5AC__DIRTIED_FLAG; } /* end else */ - CATCH +done: /* Check for header modified */ if (hdr_dirty) if (H5FA__hdr_modified(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark fixed array header as modified") + HDONE_ERROR(H5E_FARRAY, H5E_CANTMARKDIRTY, FAIL, "unable to mark fixed array header as modified") /* Release resources */ if (dblock && H5FA__dblock_unprotect(dblock, dblock_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") if (dblk_page && H5FA__dblk_page_unprotect(dblk_page, dblk_page_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block page") -END_FUNC(PRIV) /* end H5FA_set() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_set() */ /*------------------------------------------------------------------------- * Function: H5FA_get @@ -420,16 +428,17 @@ END_FUNC(PRIV) /* end H5FA_set() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt)) - - /* Local variables */ +herr_t +H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt) +{ H5FA_hdr_t * hdr = fa->hdr; /* Header for FA */ H5FA_dblock_t * dblock = NULL; /* Pointer to data block for FA */ H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to data block page for FA */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(fa); HDassert(fa->hdr); @@ -440,14 +449,15 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t if (!H5F_addr_defined(hdr->dblk_addr)) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") } /* end if */ else { /* Get the data block */ HDassert(H5F_addr_defined(hdr->dblk_addr)); if (NULL == (dblock = H5FA__dblock_protect(hdr, hdr->dblk_addr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)hdr->dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", + (unsigned long long)hdr->dblk_addr) /* Check for paged data block */ if (!dblock->npages) @@ -464,10 +474,10 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t if (!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") /* We've retrieved the value, leave now */ - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ else { /* get the page */ size_t dblk_page_nelmts; /* # of elements in a data block page */ @@ -490,9 +500,9 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t /* Protect the data block page */ if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, - "unable to protect fixed array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Retrieve element from data block */ H5MM_memcpy(elmt, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), @@ -501,13 +511,14 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t } /* end else */ } /* end else */ - CATCH +done: if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") if (dblk_page && H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block page") -END_FUNC(PRIV) /* end H5FA_get() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_get() */ /*------------------------------------------------------------------------- * Function: H5FA_close @@ -521,18 +532,19 @@ END_FUNC(PRIV) /* end H5FA_get() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) - - /* Local variables */ +herr_t +H5FA_close(H5FA_t *fa) +{ hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ haddr_t fa_addr = HADDR_UNDEF; /* Address of array (for deletion) */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(fa); - /* Close the header, if it was set */ + /* Close the header if it was set */ if (fa->hdr) { /* Decrement file reference & check if this is the last open fixed array using the shared array header */ @@ -562,7 +574,8 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) /* Check the header's status in the metadata cache */ if (H5AC_get_entry_status(fa->f, fa_addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, + "unable to check metadata cache status for fixed array header") /* Sanity checks on header */ HDassert(hdr_status & H5AC_ES__IN_CACHE); @@ -574,7 +587,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) /* Lock the array header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ if (NULL == (hdr = H5FA__hdr_protect(fa->f, fa_addr, NULL, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTLOAD, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTLOAD, FAIL, "unable to load fixed array header") /* Set the shared array header's file context for this operation */ hdr->f = fa->f; @@ -584,11 +597,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) * immediately -QAK) */ if (H5FA__hdr_decr(fa->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") /* Delete array, starting with header (unprotects header) */ if (H5FA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDELETE, FAIL, "unable to delete fixed array") } /* end if */ else { /* Decrement the reference count on the array header */ @@ -596,16 +610,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) * immediately -QAK) */ if (H5FA__hdr_decr(fa->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") } /* end else */ } /* end if */ /* Release the fixed array wrapper */ fa = H5FL_FREE(H5FA_t, fa); - CATCH - -END_FUNC(PRIV) /* end H5FA_close() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_close() */ /*------------------------------------------------------------------------- * Function: H5FA_delete @@ -619,21 +634,22 @@ END_FUNC(PRIV) /* end H5FA_close() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) +herr_t +H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata) +{ + H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(fa_addr)); /* Lock the array header into memory */ if (NULL == (hdr = H5FA__hdr_protect(f, fa_addr, ctx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", - (unsigned long long)fa_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, "unable to protect fixed array header, address = %llu", + (unsigned long long)fa_addr) /* Check for files using shared array header */ if (hdr->file_rc) @@ -644,17 +660,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_delete(H5F_t *f, haddr_t fa_ad /* Delete array now, starting with header (unprotects header) */ if (H5FA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDELETE, FAIL, "unable to delete fixed array") hdr = NULL; - } /* end if */ - - CATCH + } - /* Unprotect the header, if an error occurred */ +done: + /* Unprotect the header if an error occurred */ if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PRIV) /* end H5FA_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_delete() */ /*------------------------------------------------------------------------- * Function: H5FA_iterate @@ -671,44 +687,44 @@ END_FUNC(PRIV) /* end H5FA_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, - H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata)) - - /* Local variables */ +int +H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata) +{ uint8_t *elmt = NULL; hsize_t u; - int cb_ret = H5_ITER_CONT; /* Return value from callback */ + int ret_value = H5_ITER_CONT; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(H5_ITER_ERROR) + + /* Check arguments */ HDassert(fa); HDassert(op); HDassert(udata); /* Allocate space for a native array element */ if (NULL == (elmt = H5FL_BLK_MALLOC(fa_native_elmt, fa->hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array element") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, H5_ITER_ERROR, + "memory allocation failed for fixed array element") /* Iterate over all elements in array */ - for (u = 0; u < fa->hdr->stats.nelmts && cb_ret == H5_ITER_CONT; u++) { + for (u = 0; u < fa->hdr->stats.nelmts && ret_value == H5_ITER_CONT; u++) { /* Get array element */ if (H5FA_get(fa, u, elmt) < 0) - H5E_THROW(H5E_CANTGET, "unable to delete fixed array") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, H5_ITER_ERROR, "unable to delete fixed array") - /* Make callback */ - if ((cb_ret = (*op)(u, elmt, udata)) < 0) { - H5E_PRINTF(H5E_BADITER, "iterator function failed"); - H5_LEAVE(cb_ret) - } /* end if */ - } /* end for */ - - CATCH + /* Invoke callback */ + if ((ret_value = (*op)(u, elmt, udata)) < 0) { + HERROR(H5E_FARRAY, H5E_BADITER, "iteration callback error"); + break; + } + } +done: if (elmt) elmt = H5FL_BLK_FREE(fa_native_elmt, elmt); -END_FUNC(PRIV) /* end H5FA_iterate() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_iterate() */ /*------------------------------------------------------------------------- * Function: H5FA_depend @@ -723,14 +739,15 @@ END_FUNC(PRIV) /* end H5FA_iterate() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent)) +herr_t +H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent) +{ + H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(hdr); HDassert(parent); @@ -749,13 +766,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_depend(H5FA_t *fa, H5AC_proxy_ /* Add the fixed array as a child of the parent (proxy) */ if (H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array as child of proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "unable to add fixed array as child of proxy") hdr->parent = parent; - } /* end if */ - - CATCH + } -END_FUNC(PRIV) /* end H5FA_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_depend() */ /*------------------------------------------------------------------------- * Function: H5FA_patch_file @@ -769,17 +786,17 @@ END_FUNC(PRIV) /* end H5FA_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_patch_file(H5FA_t *fa, H5F_t *f)) +herr_t +H5FA_patch_file(H5FA_t *fa, H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOERR - /* Local variables */ - - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(f); if (fa->f != f || fa->hdr->f != f) fa->f = fa->hdr->f = f; -END_FUNC(PRIV) /* end H5FA_patch_file() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_patch_file() */ diff --git a/src/H5FAcache.c b/src/H5FAcache.c index 1b127c73a07..367b4b0f317 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -167,12 +167,13 @@ const H5AC_class_t H5AC_FARRAY_DBLK_PAGE[1] = {{ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) +{ H5FA_hdr_cache_ud_t *udata = (H5FA_hdr_cache_ud_t *)_udata; /* User data for callback */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->f); @@ -181,7 +182,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5FA_HEADER_SIZE_FILE(udata->f); -END_FUNC(STATIC) /* end H5FA__cache_hdr_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_hdr_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_verify_chksum @@ -196,13 +198,15 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5FA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5FA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -213,7 +217,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_hdr_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_deserialize @@ -228,16 +233,18 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) +{ H5FA_cls_id_t id; /* ID of fixed array class, as found in file */ H5FA_hdr_t * hdr = NULL; /* Fixed array info */ H5FA_hdr_cache_ud_t *udata = (H5FA_hdr_cache_ud_t *)_udata; const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(udata); @@ -246,24 +253,24 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate space for the fixed array data structure */ if (NULL == (hdr = H5FA__hdr_alloc(udata->f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array shared header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for fixed array shared header") /* Set the fixed array header's address */ hdr->addr = udata->addr; /* Magic number */ if (HDmemcmp(image, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong fixed array header signature") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, NULL, "wrong fixed array header signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5FA_HDR_VERSION) - H5E_THROW(H5E_VERSION, "wrong fixed array header version") + HGOTO_ERROR(H5E_FARRAY, H5E_VERSION, NULL, "wrong fixed array header version") /* Fixed array class */ id = (H5FA_cls_id_t)*image++; if (id >= H5FA_NUM_CLS_ID) - H5E_THROW(H5E_BADTYPE, "incorrect fixed array class") + HGOTO_ERROR(H5E_FARRAY, H5E_BADTYPE, NULL, "incorrect fixed array class") hdr->cparam.cls = H5FA_client_class_g[id]; /* General array creation/configuration information */ @@ -311,20 +318,20 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Finish initializing fixed array header */ if (H5FA__hdr_init(hdr, udata->ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, "initialization failed for fixed array header") HDassert(hdr->size == len); /* Set return value */ ret_value = hdr; - CATCH - +done: /* Release resources */ if (!ret_value) if (hdr && H5FA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array header") -END_FUNC(STATIC) /* end H5FA__cache_hdr_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_hdr_deserialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_image_len @@ -338,12 +345,13 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_hdr_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_hdr_image_len(const void *_thing, size_t *image_len) +{ const H5FA_hdr_t *hdr = (const H5FA_hdr_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(hdr); HDassert(image_len); @@ -351,7 +359,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = hdr->size; -END_FUNC(STATIC) /* end H5FA__cache_hdr_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_hdr_image_len() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_serialize @@ -365,15 +374,16 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing)) - - /* Local variables */ +static herr_t +H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the fixed array header */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ - /* check arguments */ + FUNC_ENTER_STATIC_NOERR + + /* Check arguments */ HDassert(f); HDassert(image); HDassert(hdr); @@ -410,7 +420,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_hdr_serialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_notify @@ -424,11 +435,13 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) +{ + H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Sanity check */ HDassert(hdr); @@ -460,16 +473,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Destroy flush dependency on object header proxy */ if (H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, (void *)hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between fixed array and proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between fixed array and proxy") hdr->parent = NULL; } /* end if */ /* Detach from 'top' proxy for fixed array */ if (hdr->top_proxy) { if (H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between header and fixed array 'top' proxy") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ @@ -477,7 +490,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ @@ -486,9 +499,10 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, else HDassert(NULL == hdr->parent); - CATCH +done: -END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_hdr_notify() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_free_icr @@ -503,18 +517,23 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_hdr_free_icr(void *thing)) +static herr_t +H5FA__cache_hdr_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array header */ if (H5FA__hdr_dest((H5FA_hdr_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free fixed array header") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "can't free fixed array header") -END_FUNC(STATIC) /* end H5FA__cache_hdr_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_hdr_free_icr() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_get_initial_load_size @@ -528,14 +547,15 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len) +{ H5FA_dblock_cache_ud_t *udata = (H5FA_dblock_cache_ud_t *)_udata; /* User data */ H5FA_dblock_t dblock; /* Fake data block for computing size */ size_t dblk_page_nelmts; /* # of elements per data block page */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -564,7 +584,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, else *image_len = (size_t)H5FA_DBLOCK_PREFIX_SIZE(&dblock); -END_FUNC(STATIC) /* end H5FA__cache_dblock_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblock_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_verify_chksum @@ -579,13 +600,15 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5FA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5FA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -596,7 +619,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_deserialize @@ -611,16 +635,18 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5FA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5FA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) +{ H5FA_dblock_t * dblock = NULL; /* Data block info */ H5FA_dblock_cache_ud_t *udata = (H5FA_dblock_cache_ud_t *)_udata; /* User data for loading data block */ const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ haddr_t arr_addr; /* Address of array header in the file */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(udata); @@ -628,7 +654,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the fixed array data block */ if (NULL == (dblock = H5FA__dblock_alloc(udata->hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for fixed array data block") HDassert(((!dblock->npages) && (len == (size_t)H5FA_DBLOCK_SIZE(dblock))) || (len == (size_t)H5FA_DBLOCK_PREFIX_SIZE(dblock))); @@ -638,27 +664,27 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Magic number */ if (HDmemcmp(image, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong fixed array data block signature") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, NULL, "wrong fixed array data block signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5FA_DBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong fixed array data block version") + HGOTO_ERROR(H5E_FARRAY, H5E_VERSION, NULL, "wrong fixed array data block version") /* Fixed array type */ if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect fixed array class") + HGOTO_ERROR(H5E_FARRAY, H5E_BADTYPE, NULL, "incorrect fixed array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(udata->hdr->f, &image, &arr_addr); if (H5F_addr_ne(arr_addr, udata->hdr->addr)) - H5E_THROW(H5E_BADVALUE, "wrong fixed array header address") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, NULL, "wrong fixed array header address") /* Page initialization flags */ if (dblock->npages > 0) { H5MM_memcpy(dblock->dblk_page_init, image, dblock->dblk_page_init_size); image += dblock->dblk_page_init_size; - } /* end if */ + } /* Only decode elements if the data block is not paged */ if (!dblock->npages) { @@ -666,9 +692,9 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Convert from raw elements on disk into native elements in memory */ if ((udata->hdr->cparam.cls->decode)(image, dblock->elmts, (size_t)udata->hdr->cparam.nelmts, udata->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode fixed array data elements") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDECODE, NULL, "can't decode fixed array data elements") image += (udata->hdr->cparam.nelmts * udata->hdr->cparam.raw_elmt_size); - } /* end if */ + } /* Sanity check */ /* (allow for checksum not decoded yet) */ @@ -688,14 +714,14 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = dblock; - CATCH - +done: /* Release resources */ if (!ret_value) if (dblock && H5FA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block") -END_FUNC(STATIC) /* end H5FA__cache_dblock_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_deserialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_image_len @@ -709,12 +735,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblock_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_dblock_image_len(const void *_thing, size_t *image_len) +{ const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblock); HDassert(image_len); @@ -725,7 +752,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, else *image_len = H5FA_DBLOCK_PREFIX_SIZE(dblock); -END_FUNC(STATIC) /* end H5FA__cache_dblock_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblock_image_len() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_serialize @@ -739,14 +767,15 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) - - /* Local variables */ +static herr_t +H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object to serialize */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(f); @@ -773,7 +802,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Store the 'page init' bitmasks */ H5MM_memcpy(image, dblock->dblk_page_init, dblock->dblk_page_init_size); image += dblock->dblk_page_init_size; - } /* end if */ + } /* Only encode elements if the data block is not paged */ if (!dblock->npages) { @@ -783,9 +812,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5_CHECK_OVERFLOW(dblock->hdr->cparam.nelmts, /* From: */ hsize_t, /* To: */ size_t); if ((dblock->hdr->cparam.cls->encode)(image, dblock->elmts, (size_t)dblock->hdr->cparam.nelmts, dblock->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode fixed array data elements") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTENCODE, FAIL, "can't encode fixed array data elements") image += (dblock->hdr->cparam.nelmts * dblock->hdr->cparam.raw_elmt_size); - } /* end if */ + } /* Compute metadata checksum */ metadata_chksum = H5_checksum_metadata(_image, (size_t)(image - (uint8_t *)_image), 0); @@ -796,9 +825,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblock_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_serialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_notify @@ -812,11 +841,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) +{ + H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; + FUNC_ENTER_STATIC /* Sanity check */ HDassert(dblock); @@ -829,8 +860,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ if (H5FA__create_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_FARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between data block and header, address = %llu", (unsigned long long)dblock->addr) break; @@ -842,35 +873,35 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ if (H5FA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") /* Detach from 'top' proxy for fixed array */ if (dblock->top_proxy) { if (H5AC_proxy_entry_remove_child(dblock->top_proxy, dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block " - "and fixed array 'top' proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block " + "and fixed array 'top' proxy") dblock->top_proxy = NULL; - } /* end if */ + } break; default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") +#else HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif } /* end switch */ } /* end if */ - CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_notify() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_free_icr @@ -885,20 +916,24 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_dblock_free_icr(void *_thing)) +static herr_t +H5FA__cache_dblock_free_icr(void *_thing) +{ + H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Check arguments */ HDassert(dblock); /* Release the fixed array data block */ if (H5FA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "can't free fixed array data block") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "can't free fixed array data block") -END_FUNC(STATIC) /* end H5FA__cache_dblock_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_free_icr() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_fsf_size @@ -929,11 +964,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) - +static herr_t +H5FA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) +{ const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblock); HDassert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -942,7 +979,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, *fsf_size = dblock->size; -END_FUNC(STATIC) /* end H5FA__cache_dblock_fsf_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblock_fsf_size() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_get_initial_load_size @@ -956,12 +994,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_fsf_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len) +{ H5FA_dblk_page_cache_ud_t *udata = (H5FA_dblk_page_cache_ud_t *)_udata; /* User data */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -971,7 +1010,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5FA_DBLK_PAGE_SIZE(udata->hdr, udata->nelmts); -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblk_page_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_verify_chksum @@ -986,13 +1026,15 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5FA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5FA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -1003,7 +1045,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_deserialize @@ -1018,18 +1061,19 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ H5FA_dblk_page_t * dblk_page = NULL; /* Data block page info */ H5FA_dblk_page_cache_ud_t *udata = (H5FA_dblk_page_cache_ud_t *)_udata; /* User data for loading data block page */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ + void * ret_value = NULL; /* Sanity check */ + FUNC_ENTER_STATIC + HDassert(udata); HDassert(udata->hdr); HDassert(udata->nelmts > 0); @@ -1037,7 +1081,8 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the fixed array data block page */ if (NULL == (dblk_page = H5FA__dblk_page_alloc(udata->hdr, udata->nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for fixed array data block page") /* Set the fixed array data block's information */ dblk_page->addr = udata->dblk_page_addr; @@ -1047,7 +1092,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Decode elements in data block page */ /* Convert from raw elements on disk into native elements in memory */ if ((udata->hdr->cparam.cls->decode)(image, dblk_page->elmts, udata->nelmts, udata->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode fixed array data elements") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDECODE, NULL, "can't decode fixed array data elements") image += (udata->nelmts * udata->hdr->cparam.raw_elmt_size); /* Sanity check */ @@ -1068,14 +1113,15 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = dblk_page; - CATCH +done: /* Release resources */ if (!ret_value) if (dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block page") -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_deserialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_image_len @@ -1089,12 +1135,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_dblk_page_image_len(const void *_thing, size_t *image_len) +{ const H5FA_dblk_page_t *dblk_page = (const H5FA_dblk_page_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblk_page); HDassert(image_len); @@ -1102,7 +1149,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = dblk_page->size; -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblk_page_image_len() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_serialize @@ -1116,14 +1164,16 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, - size_t H5_ATTR_UNUSED len, void *_thing)) - - /* Local variables */ +static herr_t +H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, + void *_thing) +{ H5FA_dblk_page_t *dblk_page = (H5FA_dblk_page_t *)_thing; /* Pointer to the object to serialize */ uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(f); @@ -1138,7 +1188,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Convert from native elements in memory into raw elements on disk */ if ((dblk_page->hdr->cparam.cls->encode)(image, dblk_page->elmts, dblk_page->nelmts, dblk_page->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode fixed array data elements") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTENCODE, FAIL, "can't encode fixed array data elements") image += (dblk_page->nelmts * dblk_page->hdr->cparam.raw_elmt_size); /* Compute metadata checksum */ @@ -1150,9 +1200,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_serialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_notify @@ -1166,11 +1216,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) - - /* Local variables */ +static herr_t +H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing) +{ H5FA_dblk_page_t *dblk_page = (H5FA_dblk_page_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(dblk_page); @@ -1187,8 +1239,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Detach from 'top' proxy for fixed array */ if (dblk_page->top_proxy) { if (H5AC_proxy_entry_remove_child(dblk_page->top_proxy, dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block page " - "and fixed array 'top' proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block page " + "and fixed array 'top' proxy") dblk_page->top_proxy = NULL; } /* end if */ break; @@ -1204,15 +1257,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_notify() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_free_icr @@ -1227,15 +1280,20 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_dblk_page_free_icr(void *thing)) +static herr_t +H5FA__cache_dblk_page_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the fixed array data block page */ if (H5FA__dblk_page_dest((H5FA_dblk_page_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free fixed array data block page") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "can't free fixed array data block page") -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_free_icr() */ diff --git a/src/H5FAdbg.c b/src/H5FAdbg.c index 8c2c9a8b1e2..a69c078ff5f 100644 --- a/src/H5FAdbg.c +++ b/src/H5FAdbg.c @@ -79,13 +79,16 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5FA_class_t *cls, haddr_t obj_addr)) - +herr_t +H5FA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5FA_class_t *cls, + haddr_t obj_addr) +{ /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */ - void * dbg_ctx = NULL; /* Fixed array debugging context */ + H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */ + void * dbg_ctx = NULL; /* Fixed array debugging context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -100,11 +103,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "unable to create fixed array debugging context") /* Load the fixed array header */ if (NULL == (hdr = H5FA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, "unable to load fixed array header") /* Print opening message */ HDfprintf(stream, "%*sFixed Array Header...\n", indent, ""); @@ -126,13 +129,14 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Fixed Array Data Block Address:", hdr->dblk_addr); - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context") + HDONE_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to release fixed array debugging context") if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__hdr_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_debug() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_debug @@ -146,15 +150,18 @@ END_FUNC(PKG) /* end H5FA__hdr_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5FA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr)) - +herr_t +H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5FA_class_t *cls, + haddr_t hdr_addr, haddr_t obj_addr) +{ /* Local variables */ - H5FA_hdr_t * hdr = NULL; /* Shared fixed array header */ - H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ - void * dbg_ctx = NULL; /* Fixed array context */ - size_t u; /* Local index variable */ + H5FA_hdr_t * hdr = NULL; /* Shared fixed array header */ + H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ + void * dbg_ctx = NULL; /* Fixed array context */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -170,16 +177,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "unable to create fixed array debugging context") /* Load the fixed array header */ if (NULL == (hdr = H5FA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, "unable to load fixed array header") /* Protect data block */ if (NULL == (dblock = H5FA__dblock_protect(hdr, addr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", (unsigned long long)addr) /* Print opening message */ HDfprintf(stream, "%*sFixed Array data Block...\n", indent, ""); @@ -222,9 +229,9 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, - "unable to protect fixed array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) HDfprintf(stream, "%*sElements in page %zu:\n", indent, "", page_idx); for (u = 0; u < dblk_page_nelmts; u++) { @@ -232,10 +239,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) - H5E_THROW(H5E_CANTGET, "can't get element for debugging") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "can't get element for debugging") } /* end for */ if (H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to release fixed array data block page") /* Advance to next page address */ dblk_page_addr += dblock->dblk_page_size; @@ -250,16 +258,17 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) - H5E_THROW(H5E_CANTGET, "can't get element for debugging") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "can't get element for debugging") } /* end for */ } /* end else */ - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context") + HDONE_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to release fixed array debugging context") if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__dblock_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_debug() */ diff --git a/src/H5FAdblkpage.c b/src/H5FAdblkpage.c index 0f5ee292d01..1dca0fb00fd 100644 --- a/src/H5FAdblkpage.c +++ b/src/H5FAdblkpage.c @@ -84,21 +84,25 @@ H5FL_BLK_DEFINE(page_elmts); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts)) - - /* Local variables */ +H5FA_dblk_page_t * +H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts) +{ H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ + H5FA_dblk_page_t *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); /* Allocate memory for the data block */ if (NULL == (dblk_page = H5FL_CALLOC(H5FA_dblk_page_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for fixed array data block page") /* Share common array information */ if (H5FA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") dblk_page->hdr = hdr; /* Set non-zero internal fields */ @@ -106,37 +110,41 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, H5FA__dblk_page_alloc(H5FA_ /* Allocate buffer for elements in data block page */ if (NULL == (dblk_page->elmts = H5FL_BLK_MALLOC(page_elmts, nelmts * hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block page element buffer") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block page element buffer") /* Set the return value */ ret_value = dblk_page; - CATCH +done: if (!ret_value) if (dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block page") -END_FUNC(PKG) /* end H5FA__dblk_page_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_alloc() */ /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_create * * Purpose: Creates a new fixed array data block page in the file * - * Return: Valid file address on success/HADDR_UNDEF on failure + * Return: SUCCEED/FAIL * * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts)) - - /* Local variables */ +herr_t +H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts) +{ H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE #ifdef H5FA_DEBUG HDfprintf(stderr, "%s: Called, addr = %a\n", FUNC, addr); @@ -147,7 +155,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Allocate the data block page */ if (NULL == (dblk_page = H5FA__dblk_page_alloc(hdr, nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, FAIL, + "memory allocation failed for fixed array data block page") /* Set info about data block page on disk */ dblk_page->addr = addr; @@ -158,34 +167,38 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Clear any elements in data block page to fill value */ if ((hdr->cparam.cls->fill)(dblk_page->elmts, nelmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set fixed array data block page elements to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, + "can't set fixed array data block page elements to class's fill value") /* Cache the new fixed array data block page */ if (H5AC_insert_entry(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add fixed array data block page to cache") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINSERT, FAIL, "can't add fixed array data block page to cache") inserted = TRUE; /* Add data block page as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, + "unable to add fixed array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ - CATCH +done: if (ret_value < 0) if (dblk_page) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(dblk_page) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array data block page from cache") + HDONE_ERROR(H5E_FARRAY, H5E_CANTREMOVE, FAIL, + "unable to remove fixed array data block page from cache") /* Destroy data block page */ if (H5FA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "unable to destroy fixed array data block page") } /* end if */ -END_FUNC(PKG) /* end H5FA__dblk_page_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_create() */ /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_protect @@ -200,13 +213,14 @@ END_FUNC(PKG) /* end H5FA__dblk_page_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, - H5FA__dblk_page_protect(H5FA_hdr_t *hdr, haddr_t dblk_page_addr, size_t dblk_page_nelmts, - unsigned flags)) - - /* Local variables */ +H5FA_dblk_page_t * +H5FA__dblk_page_protect(H5FA_hdr_t *hdr, haddr_t dblk_page_addr, size_t dblk_page_nelmts, unsigned flags) +{ H5FA_dblk_page_t * dblk_page = NULL; /* Fixed array data block page */ H5FA_dblk_page_cache_ud_t udata; /* Information needed for loading data block page */ + H5FA_dblk_page_t * ret_value = NULL; + + FUNC_ENTER_PACKAGE #ifdef H5FA_DEBUG HDfprintf(stderr, "%s: Called\n", FUNC); @@ -227,32 +241,36 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, /* Protect the data block page */ if (NULL == (dblk_page = (H5FA_dblk_page_t *)H5AC_protect(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == dblk_page->top_proxy) { /* Add data block page as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, NULL, + "unable to add fixed array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ /* Set return value */ ret_value = dblk_page; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the data block page, if it was protected */ if (dblk_page && H5AC_unprotect(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block page, address = %llu", - (unsigned long long)dblk_page->addr) + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect fixed array data block page, address = %llu", + (unsigned long long)dblk_page->addr) } /* end if */ -END_FUNC(PKG) /* end H5FA__dblk_page_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_protect() */ /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_unprotect @@ -267,10 +285,12 @@ END_FUNC(PKG) /* end H5FA__dblk_page_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags)) +herr_t +H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; -/* Local variables */ + FUNC_ENTER_PACKAGE #ifdef H5FA_DEBUG HDfprintf(stderr, "%s: Called\n", FUNC); @@ -281,12 +301,13 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Unprotect the data block page */ if (H5AC_unprotect(dblk_page->hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block page, address = %llu", - (unsigned long long)dblk_page->addr) - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect fixed array data block page, address = %llu", + (unsigned long long)dblk_page->addr) -END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_unprotect() */ /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_dest @@ -300,7 +321,12 @@ END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page)) +herr_t +H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblk_page); @@ -315,7 +341,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblk_page_dest(H5FA_dblk_page_ /* Decrement reference count on shared info */ if (H5FA__hdr_decr(dblk_page->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") dblk_page->hdr = NULL; } /* end if */ @@ -325,6 +352,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblk_page_dest(H5FA_dblk_page_ /* Free the data block page itself */ dblk_page = H5FL_FREE(H5FA_dblk_page_t, dblk_page); - CATCH - -END_FUNC(PKG) /* end H5FA__dblk_page_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_dest() */ diff --git a/src/H5FAdblock.c b/src/H5FAdblock.c index 21e2e03166e..1ccc97d6897 100644 --- a/src/H5FAdblock.c +++ b/src/H5FAdblock.c @@ -88,10 +88,13 @@ H5FL_BLK_DEFINE(fa_page_init); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t *hdr)) +H5FA_dblock_t * +H5FA__dblock_alloc(H5FA_hdr_t *hdr) +{ + H5FA_dblock_t *dblock = NULL; /* fixed array data block */ + H5FA_dblock_t *ret_value = NULL; - /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* fixed array data block */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -99,11 +102,11 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t /* Allocate memory for the data block */ if (NULL == (dblock = H5FL_CALLOC(H5FA_dblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for fixed array data block") /* Share common array information */ if (H5FA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") dblock->hdr = hdr; /* Set non-zero internal fields */ @@ -126,7 +129,7 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t /* Allocate space for 'page init' flags */ if (NULL == (dblock->dblk_page_init = H5FL_BLK_CALLOC(fa_page_init, dblock->dblk_page_init_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for page init bitmask") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for page init bitmask") /* Compute data block page size */ dblock->dblk_page_size = (dblock->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5FA_SIZEOF_CHKSUM; @@ -143,19 +146,20 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t /* Allocate buffer for elements in data block */ H5_CHECK_OVERFLOW(dblk_size, /* From: */ hsize_t, /* To: */ size_t); if (NULL == (dblock->elmts = H5FL_BLK_MALLOC(chunk_elmts, (size_t)dblk_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block element buffer") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block element buffer") } /* end else */ /* Set the return value */ ret_value = dblock; - CATCH - +done: if (!ret_value) if (dblock && H5FA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block") -END_FUNC(PKG) /* end H5FA__dblock_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_alloc() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_create @@ -169,13 +173,15 @@ END_FUNC(PKG) /* end H5FA__dblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty)) +haddr_t +H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty) +{ + H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ + haddr_t dblock_addr; /* Fixed array data block address */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ - haddr_t dblock_addr; /* Fixed array data block address */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -183,31 +189,35 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate the data block */ if (NULL == (dblock = H5FA__dblock_alloc(hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for fixed array data block") /* Set size of data block on disk */ hdr->stats.dblk_size = dblock->size = H5FA_DBLOCK_SIZE(dblock); /* Allocate space for the data block on disk */ if (HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_FARRAY_DBLOCK, (hsize_t)dblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for fixed array data block") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for fixed array data block") dblock->addr = dblock_addr; /* Don't initialize elements if paged */ if (!dblock->npages) /* Clear any elements in data block to fill value */ if ((hdr->cparam.cls->fill)(dblock->elmts, (size_t)hdr->cparam.nelmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set fixed array data block elements to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, HADDR_UNDEF, + "can't set fixed array data block elements to class's fill value") /* Cache the new fixed array data block */ if (H5AC_insert_entry(hdr->f, H5AC_FARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add fixed array data block to cache") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINSERT, HADDR_UNDEF, "can't add fixed array data block to cache") inserted = TRUE; /* Add data block as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add fixed array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -217,26 +227,28 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Set address of data block to return */ ret_value = dblock_addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (dblock) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(dblock) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array data block from cache") + HDONE_ERROR(H5E_FARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove fixed array data block from cache") /* Release data block's disk space */ if (H5F_addr_defined(dblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_FARRAY_DBLOCK, dblock->addr, (hsize_t)dblock->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to release fixed array data block") /* Destroy data block */ if (H5FA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy fixed array data block") } /* end if */ -END_FUNC(PKG) /* end H5FA__dblock_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_create() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_protect @@ -250,12 +262,14 @@ END_FUNC(PKG) /* end H5FA__dblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, - H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags)) +H5FA_dblock_t * +H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags) +{ + H5FA_dblock_t * dblock = NULL; /* Fixed array data block */ + H5FA_dblock_cache_ud_t udata; /* Information needed for loading data block */ + H5FA_dblock_t * ret_value = NULL; - /* Local variables */ - H5FA_dblock_t * dblock; /* Fixed array data block */ - H5FA_dblock_cache_ud_t udata; /* Information needed for loading data block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -271,31 +285,33 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, /* Protect the data block */ if (NULL == (dblock = (H5FA_dblock_t *)H5AC_protect(hdr->f, H5AC_FARRAY_DBLOCK, dblk_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, + "unable to protect fixed array data block, address = %llu", (unsigned long long)dblk_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == dblock->top_proxy) { /* Add data block as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, NULL, + "unable to add fixed array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ /* Set return value */ ret_value = dblock; - CATCH - +done: /* Clean up on error */ if (!ret_value) /* Release the data block, if it was protected */ if (dblock && H5AC_unprotect(hdr->f, H5AC_FARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block, address = %llu", - (unsigned long long)dblock->addr) + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect fixed array data block, address = %llu", + (unsigned long long)dblock->addr) -END_FUNC(PKG) /* end H5FA__dblock_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_protect() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_unprotect @@ -309,22 +325,25 @@ END_FUNC(PKG) /* end H5FA__dblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags)) +herr_t +H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblock); /* Unprotect the data block */ if (H5AC_unprotect(dblock->hdr->f, H5AC_FARRAY_DBLOCK, dblock->addr, dblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block, address = %llu", - (unsigned long long)dblock->addr) - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect fixed array data block, address = %llu", + (unsigned long long)dblock->addr) -END_FUNC(PKG) /* end H5FA__dblock_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_unprotect() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_delete @@ -338,10 +357,13 @@ END_FUNC(PKG) /* end H5FA__dblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_delete(H5FA_hdr_t *hdr, haddr_t dblk_addr)) +herr_t +H5FA__dblock_delete(H5FA_hdr_t *hdr, haddr_t dblk_addr) +{ + H5FA_dblock_t *dblock = NULL; /* Pointer to data block */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* Pointer to data block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -349,8 +371,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_delete(H5FA_hdr_t *hdr, /* Protect data block */ if (NULL == (dblock = H5FA__dblock_protect(hdr, dblk_addr, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", (unsigned long long)dblk_addr) /* Check if data block is paged */ if (dblock->npages) { @@ -365,21 +387,22 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_delete(H5FA_hdr_t *hdr, /* Evict the data block page from the metadata cache */ /* (OK to call if it doesn't exist in the cache) */ if (H5AC_expunge_entry(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page_addr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTEXPUNGE, "unable to remove array data block page from metadata cache") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTEXPUNGE, FAIL, + "unable to remove array data block page from metadata cache") /* Advance to next page address */ dblk_page_addr += dblock->dblk_page_size; } /* end for */ } /* end if */ - CATCH - +done: /* Finished deleting data block in metadata cache */ if (dblock && H5FA__dblock_unprotect(dblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") -END_FUNC(PKG) /* end H5FA__dblock_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_delete() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_dest @@ -393,7 +416,12 @@ END_FUNC(PKG) /* end H5FA__dblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_dest(H5FA_dblock_t *dblock)) +herr_t +H5FA__dblock_dest(H5FA_dblock_t *dblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblock); @@ -417,7 +445,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_dest(H5FA_dblock_t *dbl /* Decrement reference count on shared info */ if (H5FA__hdr_decr(dblock->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") dblock->hdr = NULL; } /* end if */ @@ -427,6 +456,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_dest(H5FA_dblock_t *dbl /* Free the data block itself */ dblock = H5FL_FREE(H5FA_dblock_t, dblock); - CATCH - -END_FUNC(PKG) /* end H5FA__dblock_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_dest() */ diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index 867160fc0fe..aeb3fb1ca92 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -82,17 +82,20 @@ H5FL_DEFINE_STATIC(H5FA_hdr_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, H5FA__hdr_alloc(H5F_t *f)) +H5FA_hdr_t * +H5FA__hdr_alloc(H5F_t *f) +{ + H5FA_hdr_t *hdr = NULL; /* Shared Fixed Array header */ + H5FA_hdr_t *ret_value = NULL; - /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Shared Fixed Array header */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); /* Allocate space for the shared information */ if (NULL == (hdr = H5FL_CALLOC(H5FA_hdr_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for Fixed Array shared header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for Fixed Array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; @@ -106,13 +109,12 @@ BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, H5FA__hdr_alloc(H5F_t *f)) /* Set the return value */ ret_value = hdr; - CATCH - +done: if (!ret_value) if (hdr && H5FA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array header") - -END_FUNC(PKG) /* end H5FA__hdr_alloc() */ + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array header") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_alloc() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_init @@ -126,9 +128,12 @@ END_FUNC(PKG) /* end H5FA__hdr_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata)) +herr_t +H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -140,33 +145,36 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_init(H5FA_hdr_t *hdr, void hdr->stats.nelmts = hdr->cparam.nelmts; /* Create the callback context, if there's one */ - if (hdr->cparam.cls->crt_context) { + if (hdr->cparam.cls->crt_context) if (NULL == (hdr->cb_ctx = (*hdr->cparam.cls->crt_context)(ctx_udata))) - H5E_THROW(H5E_CANTCREATE, "unable to create fixed array client callback context") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, FAIL, + "unable to create fixed array client callback context") - CATCH - -END_FUNC(PKG) /* end H5FA__hdr_init() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_init() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_create * * Purpose: Creates a new Fixed Array header in the file * - * Return: SUCCEED/FAIL + * Return: Success: Address of new header in the file + * Failure: HADDR_UNDEF * * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) +haddr_t +H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata) +{ + H5FA_hdr_t *hdr = NULL; /* Fixed array header */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Fixed array header */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -176,17 +184,19 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, { /* Check for valid parameters */ if (cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, HADDR_UNDEF, "element size must be greater than zero") if (cparam->max_dblk_page_nelmts_bits == 0) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, HADDR_UNDEF, + "max. # of elements bits must be greater than zero") if (cparam->nelmts == 0) - H5E_THROW(H5E_BADVALUE, "# of elements must be greater than zero") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, HADDR_UNDEF, "# of elements must be greater than zero") } #endif /* NDEBUG */ /* Allocate space for the shared information */ if (NULL == (hdr = H5FA__hdr_alloc(f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for Fixed Array shared header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for Fixed Array shared header") hdr->dblk_addr = HADDR_UNDEF; @@ -195,50 +205,52 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Finish initializing fixed array header */ if (H5FA__hdr_init(hdr, ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, HADDR_UNDEF, "initialization failed for fixed array header") /* Allocate space for the header on disk */ if (HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_FARRAY_HDR, (hsize_t)hdr->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for Fixed Array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for Fixed Array header") /* Create 'top' proxy for extensible array entries */ if (hdr->swmr_write) if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) - H5E_THROW(H5E_CANTCREATE, "can't create fixed array entry proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, HADDR_UNDEF, "can't create fixed array entry proxy") /* Cache the new Fixed Array header */ if (H5AC_insert_entry(f, H5AC_FARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add fixed array header to cache") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINSERT, HADDR_UNDEF, "can't add fixed array header to cache") inserted = TRUE; /* Add header as child of 'top' proxy */ if (hdr->top_proxy) if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add fixed array entry as child of array proxy") /* Set address of array header to return */ ret_value = hdr->addr; - CATCH - +done: if (!H5F_addr_defined(ret_value)) if (hdr) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(hdr) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array header from cache") + HDONE_ERROR(H5E_FARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove fixed array header from cache") /* Release header's disk space */ if (H5F_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_FARRAY_HDR, hdr->addr, (hsize_t)hdr->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to free Fixed Array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to free Fixed Array header") /* Destroy header */ if (H5FA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy Fixed Array header") - } /* end if */ + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy Fixed Array header") + } -END_FUNC(PKG) /* end H5FA__hdr_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_create() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_incr @@ -252,7 +264,12 @@ END_FUNC(PKG) /* end H5FA__hdr_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_incr(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_incr(H5FA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -260,14 +277,14 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_incr(H5FA_hdr_t *hdr)) /* Mark header as un-evictable when something is depending on it */ if (hdr->rc == 0) if (H5AC_pin_protected_entry(hdr) < 0) - H5E_THROW(H5E_CANTPIN, "unable to pin fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPIN, FAIL, "unable to pin fixed array header") /* Increment reference count on shared header */ hdr->rc++; - CATCH - -END_FUNC(PKG) /* end H5FA__hdr_incr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_incr() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_decr @@ -281,7 +298,12 @@ END_FUNC(PKG) /* end H5FA__hdr_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_decr(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_decr(H5FA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -294,12 +316,12 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_decr(H5FA_hdr_t *hdr)) if (hdr->rc == 0) { HDassert(hdr->file_rc == 0); if (H5AC_unpin_entry(hdr) < 0) - H5E_THROW(H5E_CANTUNPIN, "unable to unpin fixed array header") - } /* end if */ - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPIN, FAIL, "unable to unpin fixed array header") + } -END_FUNC(PKG) /* end H5FA__hdr_decr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_decr() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_fuse_incr @@ -313,7 +335,10 @@ END_FUNC(PKG) /* end H5FA__hdr_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr) +{ + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -321,21 +346,28 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr)) /* Increment file reference count on shared header */ hdr->file_rc++; -END_FUNC(PKG) /* end H5FA__hdr_fuse_incr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__hdr_fuse_incr() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_fuse_decr * * Purpose: Decrement file reference count on shared array header * - * Return: SUCCEED/FAIL + * Return: Success: The reference count of the header + * Failure: Can't fail * * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr)) +size_t +H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr) +{ + size_t ret_value = 0; + + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -347,7 +379,8 @@ BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr)) /* Set return value */ ret_value = hdr->file_rc; -END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_fuse_decr() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_modified @@ -361,18 +394,23 @@ END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_modified(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_modified(H5FA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Mark header as dirty in cache */ if (H5AC_mark_entry_dirty(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark fixed array header as dirty") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTMARKDIRTY, FAIL, "unable to mark fixed array header as dirty") -END_FUNC(PKG) /* end H5FA__hdr_modified() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_modified() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_protect @@ -386,12 +424,14 @@ END_FUNC(PKG) /* end H5FA__hdr_modified() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, - H5FA__hdr_protect(H5F_t *f, haddr_t fa_addr, void *ctx_udata, unsigned flags)) - - /* Local variables */ +H5FA_hdr_t * +H5FA__hdr_protect(H5F_t *f, haddr_t fa_addr, void *ctx_udata, unsigned flags) +{ H5FA_hdr_t * hdr; /* Fixed array header */ H5FA_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5FA_hdr_t * ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(f); @@ -407,27 +447,28 @@ BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, /* Protect the header */ if (NULL == (hdr = (H5FA_hdr_t *)H5AC_protect(f, H5AC_FARRAY_HDR, fa_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", - (unsigned long long)fa_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, "unable to protect fixed array header, address = %llu", + (unsigned long long)fa_addr) hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ /* Create top proxy, if it doesn't exist */ if (hdr->swmr_write && NULL == hdr->top_proxy) { /* Create 'top' proxy for fixed array entries */ if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) - H5E_THROW(H5E_CANTCREATE, "can't create fixed array entry proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, NULL, "can't create fixed array entry proxy") /* Add header as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, NULL, + "unable to add fixed array entry as child of array proxy") + } /* Set return value */ ret_value = hdr; - CATCH - -END_FUNC(PKG) /* end H5FA__hdr_protect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_protect() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_unprotect @@ -441,21 +482,24 @@ END_FUNC(PKG) /* end H5FA__hdr_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags)) +herr_t +H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Unprotect the header */ if (H5AC_unprotect(hdr->f, H5AC_FARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array hdr, address = %llu", - (unsigned long long)hdr->addr) - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect fixed array hdr, address = %llu", (unsigned long long)hdr->addr) -END_FUNC(PKG) /* end H5FA__hdr_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_unprotect() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_delete @@ -469,46 +513,49 @@ END_FUNC(PKG) /* end H5FA__hdr_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_delete(H5FA_hdr_t *hdr)) - - /* Local variables */ +herr_t +H5FA__hdr_delete(H5FA_hdr_t *hdr) +{ unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); HDassert(!hdr->file_rc); #ifndef NDEBUG - { - unsigned hdr_status = 0; /* Array header's status in the metadata cache */ - /* Check the array header's status in the metadata cache */ - if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for array header") + unsigned hdr_status = 0; /* Array header's status in the metadata cache */ + + /* Check the array header's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "unable to check metadata cache status for array header") + + /* Sanity checks on array header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PROTECTED); - /* Sanity checks on array header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PROTECTED); - } /* end block */ #endif /* NDEBUG */ /* Check for Fixed Array Data block */ if (H5F_addr_defined(hdr->dblk_addr)) { /* Delete Fixed Array Data block */ if (H5FA__dblock_delete(hdr, hdr->dblk_addr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array data block") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDELETE, FAIL, "unable to delete fixed array data block") + } /* Set flags to finish deleting header on unprotect */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; - CATCH - +done: /* Unprotect the header, deleting it if an error hasn't occurred */ if (H5AC_unprotect(hdr->f, H5AC_FARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__hdr_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_delete() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_dest @@ -522,7 +569,12 @@ END_FUNC(PKG) /* end H5FA__hdr_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_dest(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_dest(H5FA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -531,20 +583,21 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_dest(H5FA_hdr_t *hdr)) /* Destroy the callback context */ if (hdr->cb_ctx) { if ((*hdr->cparam.cls->dst_context)(hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy fixed array client callback context") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, + "unable to destroy fixed array client callback context") + } hdr->cb_ctx = NULL; /* Destroy the 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_dest(hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy fixed array 'top' proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to destroy fixed array 'top' proxy") hdr->top_proxy = NULL; - } /* end if */ + } /* Free the shared info itself */ hdr = H5FL_FREE(H5FA_hdr_t, hdr); - CATCH - -END_FUNC(PKG) /* end H5FA__hdr_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_dest() */ diff --git a/src/H5FAint.c b/src/H5FAint.c index 864c7ee8149..220690191bd 100644 --- a/src/H5FAint.c +++ b/src/H5FAint.c @@ -79,8 +79,12 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +herr_t +H5FA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(parent_entry); @@ -88,11 +92,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Create a flush dependency between parent and child entry */ if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") -END_FUNC(PKG) /* end H5FA__create_flush_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__create_flush_depend() */ /*------------------------------------------------------------------------- * Function: H5FA__destroy_flush_depend @@ -106,8 +110,12 @@ END_FUNC(PKG) /* end H5FA__create_flush_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +herr_t +H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(parent_entry); @@ -115,8 +123,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Destroy a flush dependency between parent and child entry */ if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") -END_FUNC(PKG) /* end H5FA__destroy_flush_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__destroy_flush_depend() */ diff --git a/src/H5FAstat.c b/src/H5FAstat.c index 1fdf47fc913..98f7195afc6 100644 --- a/src/H5FAstat.c +++ b/src/H5FAstat.c @@ -78,21 +78,21 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_stats(const H5FA_t *fa, H5FA_stat_t *stats)) - -/* Local variables */ +herr_t +H5FA_get_stats(const H5FA_t *fa, H5FA_stat_t *stats) +{ + FUNC_ENTER_NOAPI_NOERR #ifdef H5FA_DEBUG HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* H5FA_DEBUG */ - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(stats); /* Copy fixed array statistics */ H5MM_memcpy(stats, &fa->hdr->stats, sizeof(fa->hdr->stats)); -END_FUNC(PRIV) /* end H5FA_get_stats() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_get_stats() */ diff --git a/src/H5FAtest.c b/src/H5FAtest.c index 6dd6e00c5b1..384a657e908 100644 --- a/src/H5FAtest.c +++ b/src/H5FAtest.c @@ -112,14 +112,17 @@ H5FL_DEFINE_STATIC(H5FA__test_ctx_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5FA__test_crt_context(void H5_ATTR_UNUSED *udata)) - - /* Local variables */ +static void * +H5FA__test_crt_context(void H5_ATTR_UNUSED *udata) +{ H5FA__test_ctx_t *ctx; /* Context for callbacks */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Allocate new context structure */ if (NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) - H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "can't allocate fixed array client callback context") /* Initialize the context */ ctx->bogus = H5FA__TEST_BOGUS_VAL; @@ -127,9 +130,9 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5FA__test_crt_context(void H5_ATTR_ /* Set return value */ ret_value = ctx; - CATCH - -END_FUNC(STATIC) /* end H5FA__test_crt_context() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__test_crt_context() */ /*------------------------------------------------------------------------- * Function: H5FA__test_dst_context @@ -143,18 +146,21 @@ END_FUNC(STATIC) /* end H5FA__test_crt_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5FA__test_dst_context(void *_ctx)) - - /* Local variables */ +static herr_t +H5FA__test_dst_context(void *_ctx) +{ H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(H5FA__TEST_BOGUS_VAL == ctx->bogus); /* Release context structure */ ctx = H5FL_FREE(H5FA__test_ctx_t, ctx); -END_FUNC(STATIC) /* end H5FA__test_dst_context() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_dst_context() */ /*------------------------------------------------------------------------- * Function: H5FA__test_fill @@ -168,18 +174,21 @@ END_FUNC(STATIC) /* end H5FA__test_dst_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5FA__test_fill(void *nat_blk, size_t nelmts)) - - /* Local variables */ +static herr_t +H5FA__test_fill(void *nat_blk, size_t nelmts) +{ uint64_t fill_val = H5FA_TEST_FILL; /* Value to fill elements with */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(nat_blk); HDassert(nelmts); H5VM_array_fill(nat_blk, &fill_val, sizeof(uint64_t), nelmts); -END_FUNC(STATIC) /* end H5FA__test_fill() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_fill() */ /*------------------------------------------------------------------------- * Function: H5FA__test_encode @@ -193,14 +202,15 @@ END_FUNC(STATIC) /* end H5FA__test_fill() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx)) - -/* Local variables */ +static herr_t +H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx) +{ #ifndef NDEBUG H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ -#endif /* NDEBUG */ - const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ +#endif + const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ + + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(raw); @@ -221,7 +231,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, nelmts--; } /* end while */ -END_FUNC(STATIC) /* end H5FA__test_encode() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_encode() */ /*------------------------------------------------------------------------- * Function: H5FA__test_decode @@ -235,15 +246,16 @@ END_FUNC(STATIC) /* end H5FA__test_encode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx)) - -/* Local variables */ +static herr_t +H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx) +{ #ifndef NDEBUG H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ -#endif /* NDEBUG */ - uint64_t * elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ - const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ +#endif + uint64_t * elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ + const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(raw); @@ -264,7 +276,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, nelmts--; } /* end while */ -END_FUNC(STATIC) /* end H5FA__test_decode() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_decode() */ /*------------------------------------------------------------------------- * Function: H5FA__test_debug @@ -278,12 +291,13 @@ END_FUNC(STATIC) /* end H5FA__test_decode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt)) - - /* Local variables */ +static herr_t +H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt) +{ char temp_str[128]; /* Temporary string, for formatting */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(stream); HDassert(elmt); @@ -293,7 +307,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str, (unsigned long long)*(const uint64_t *)elmt); -END_FUNC(STATIC) /* end H5FA__test_debug() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_debug() */ /*------------------------------------------------------------------------- * Function: H5FA__test_crt_dbg_context @@ -308,15 +323,17 @@ END_FUNC(STATIC) /* end H5FA__test_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5FA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr)) - - /* Local variables */ +static void * +H5FA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr) +{ H5FA__test_ctx_t *ctx; /* Context for callbacks */ + void * ret_value = NULL; + + FUNC_ENTER_STATIC /* Allocate new context structure */ if (NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) - H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "can't allocate fixed array client callback context") /* Initialize the context */ ctx->bogus = H5FA__TEST_BOGUS_VAL; @@ -324,9 +341,9 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = ctx; - CATCH - -END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */ +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5FA__test_crt_dbg_context() */ /*------------------------------------------------------------------------- * Function: H5FA__get_cparam_test @@ -340,7 +357,10 @@ END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__get_cparam_test(const H5FA_t *fa, H5FA_create_t *cparam)) +herr_t +H5FA__get_cparam_test(const H5FA_t *fa, H5FA_create_t *cparam) +{ + FUNC_ENTER_PACKAGE_NOERR /* Check arguments. */ HDassert(fa); @@ -350,22 +370,27 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__get_cparam_test(const H5FA_t *f cparam->raw_elmt_size = fa->hdr->cparam.raw_elmt_size; cparam->nelmts = fa->hdr->cparam.nelmts; -END_FUNC(PKG) /* end H5FA__get_cparam_test() */ + FUNC_LEAVE_NOAPI(SUCCEED); +} /* end H5FA__get_cparam_test() */ /*------------------------------------------------------------------------- * Function: H5FA__cmp_cparam_test * * Purpose: Compare the parameters used to create the fixed array * - * Return: SUCCEED/FAIL + * Return: An integer value like strcmp * * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, - H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2)) +int +H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2) +{ + int ret_value = 0; + + FUNC_ENTER_PACKAGE_NOERR /* Check arguments. */ HDassert(cparam1); @@ -373,10 +398,10 @@ BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, /* Compare creation parameters for array */ if (cparam1->raw_elmt_size < cparam2->raw_elmt_size) - H5_LEAVE(-1) + ret_value = -1; else if (cparam1->raw_elmt_size > cparam2->raw_elmt_size) - H5_LEAVE(1) + ret_value = 1; - CATCH + FUNC_LEAVE_NOAPI(ret_value) -END_FUNC(PKG) /* end H5FA__cmp_cparam_test() */ +} /* end H5FA__cmp_cparam_test() */ diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index de0e7623c01..2fe1c9f34a3 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -84,7 +84,7 @@ (0x0020u) /**< Restrict search to objects opened through current file ID \ (as opposed to objects opened through any file ID accessing this file) */ -#define H5F_FAMILY_DEFAULT (hsize_t)0 +#define H5F_FAMILY_DEFAULT 0 /* (hsize_t) */ #ifdef H5_HAVE_PARALLEL /** @@ -108,7 +108,7 @@ typedef enum H5F_scope_t { /** * Unlimited file size for H5Pset_external() */ -#define H5F_UNLIMITED ((hsize_t)(-1L)) +#define H5F_UNLIMITED HSIZE_UNDEF /** * How does file close behave? diff --git a/src/H5HL.c b/src/H5HL.c index ca8344526e4..2ea66195ad0 100644 --- a/src/H5HL.c +++ b/src/H5HL.c @@ -98,11 +98,15 @@ H5FL_BLK_DEFINE(lheap_chunk); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr_p /*out*/)) - +herr_t +H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr_p /*out*/) +{ H5HL_t * heap = NULL; /* Heap created */ H5HL_prfx_t *prfx = NULL; /* Heap prefix */ hsize_t total_size = 0; /* Total heap size on disk */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) /* check arguments */ HDassert(f); @@ -115,12 +119,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_create(H5F_t *f, size_t size_h /* Allocate new heap structure */ if (NULL == (heap = H5HL__new(H5F_SIZEOF_SIZE(f), H5F_SIZEOF_ADDR(f), H5HL_SIZEOF_HDR(f)))) - H5E_THROW(H5E_CANTALLOC, "can't allocate new heap struct"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate new heap struct"); /* Allocate file space */ total_size = heap->prfx_size + size_hint; if (HADDR_UNDEF == (heap->prfx_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, total_size))) - H5E_THROW(H5E_CANTALLOC, "unable to allocate file memory"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate file memory"); /* Initialize info */ heap->single_cache_obj = TRUE; @@ -128,52 +132,52 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_create(H5F_t *f, size_t size_h heap->dblk_size = size_hint; if (size_hint) if (NULL == (heap->dblk_image = H5FL_BLK_CALLOC(lheap_chunk, size_hint))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* free list */ if (size_hint) { if (NULL == (heap->freelist = H5FL_MALLOC(H5HL_free_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); heap->freelist->offset = 0; heap->freelist->size = size_hint; heap->freelist->prev = heap->freelist->next = NULL; heap->free_block = 0; - } /* end if */ + } else { heap->freelist = NULL; heap->free_block = H5HL_FREE_NULL; - } /* end else */ + } /* Allocate the heap prefix */ if (NULL == (prfx = H5HL__prfx_new(heap))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* Add to cache */ if (FAIL == H5AC_insert_entry(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) - H5E_THROW(H5E_CANTINIT, "unable to cache local heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to cache local heap prefix"); /* Set address to return */ *addr_p = heap->prfx_addr; - CATCH +done: if (ret_value < 0) { *addr_p = HADDR_UNDEF; if (prfx) { if (FAIL == H5HL__prfx_dest(prfx)) - H5E_THROW(H5E_CANTFREE, "unable to destroy local heap prefix"); - } /* end if */ + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap prefix"); + } else { if (heap) { if (H5F_addr_defined(heap->prfx_addr)) if (FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, heap->prfx_addr, total_size)) - H5E_THROW(H5E_CANTFREE, "can't release heap data?"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't release heap data?"); if (FAIL == H5HL__dest(heap)) - H5E_THROW(H5E_CANTFREE, "unable to destroy local heap"); - } /* end if */ - } /* end else */ - } /* end if */ - -END_FUNC(PRIV) /* end H5HL_create() */ + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap"); + } + } + } + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_create() */ /*------------------------------------------------------------------------- * Function: H5HL__minimize_heap_space @@ -188,16 +192,19 @@ END_FUNC(PRIV) /* end H5HL_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) - +static herr_t +H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap) +{ size_t new_heap_size = heap->dblk_size; /* New size of heap */ + herr_t ret_value = SUCCEED; - /* check args */ + FUNC_ENTER_STATIC + + /* Check args */ HDassert(f); HDassert(heap); - /* - * Check to see if we can reduce the size of the heap in memory by + /* Check to see if we can reduce the size of the heap in memory by * eliminating free blocks at the tail of the buffer before flushing the * buffer out. */ @@ -211,29 +218,25 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t * if (tmp_fl->offset + tmp_fl->size == heap->dblk_size) { last_fl = tmp_fl; break; - } /* end if */ + } - /* - * Found free block at the end of the buffer, decide what to do + /* Found free block at the end of the buffer, decide what to do * about it */ if (last_fl) { - /* - * If the last free block's size is more than half the memory + /* If the last free block's size is more than half the memory * buffer size (and the memory buffer is larger than the * minimum size), reduce or eliminate it. */ if (last_fl->size >= (heap->dblk_size / 2) && heap->dblk_size > H5HL_MIN_HEAP) { - /* - * Reduce size of buffer until it's too small or would + /* Reduce size of buffer until it's too small or would * eliminate the free block */ while (new_heap_size > H5HL_MIN_HEAP && new_heap_size >= (last_fl->offset + H5HL_SIZEOF_FREE(f))) new_heap_size /= 2; - /* - * Check if reducing the memory buffer size would + /* Check if reducing the memory buffer size would * eliminate the free block */ if (new_heap_size < (last_fl->offset + H5HL_SIZEOF_FREE(f))) { @@ -246,31 +249,29 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t * last_fl->size = H5HL_ALIGN(new_heap_size - last_fl->offset); new_heap_size = last_fl->offset + last_fl->size; HDassert(last_fl->size >= H5HL_SIZEOF_FREE(f)); - } /* end if */ + } else { - /* - * Set the size of the memory buffer to the start + /* Set the size of the memory buffer to the start * of the free list */ new_heap_size = last_fl->offset; /* Eliminate the free block from the list */ last_fl = H5HL__remove_free(heap, last_fl); - } /* end else */ - } /* end if */ + } + } else { /* Truncate the free block */ last_fl->size = H5HL_ALIGN(new_heap_size - last_fl->offset); new_heap_size = last_fl->offset + last_fl->size; HDassert(last_fl->size >= H5HL_SIZEOF_FREE(f)); HDassert(last_fl->size == H5HL_ALIGN(last_fl->size)); - } /* end else */ - } /* end if */ - } /* end if */ - } /* end if */ + } + } + } + } - /* - * If the heap grew smaller than disk storage then move the + /* If the heap grew smaller than disk storage then move the * data segment of the heap to another contiguous block of disk * storage. */ @@ -279,17 +280,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t * /* Resize the memory buffer */ if (NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, new_heap_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* Reallocate data block in file */ if (FAIL == H5HL__dblk_realloc(f, heap, new_heap_size)) - H5E_THROW(H5E_CANTRESIZE, "reallocating data block failed"); - } /* end if */ - - CATCH - /* No special processing on errors */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "reallocating data block failed"); + } -END_FUNC(STATIC) /* H5HL__minimize_heap_space() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HL__minimize_heap_space() */ /*------------------------------------------------------------------------- * Function: H5HL_protect @@ -304,20 +304,24 @@ END_FUNC(STATIC) /* H5HL__minimize_heap_space() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags)) - +H5HL_t * +H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags) +{ H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ H5HL_dblk_t * dblk = NULL; /* Local heap data block */ H5HL_t * heap = NULL; /* Heap data structure */ unsigned prfx_cache_flags = H5AC__NO_FLAGS_SET; /* Cache flags for unprotecting prefix entry */ unsigned dblk_cache_flags = H5AC__NO_FLAGS_SET; /* Cache flags for unprotecting data block entry */ + H5HL_t * ret_value = NULL; - /* check arguments */ + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); - /* only the H5AC__READ_ONLY_FLAG may appear in flags */ + /* Only the H5AC__READ_ONLY_FLAG may appear in flags */ HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Construct the user data for protect callback */ @@ -328,7 +332,7 @@ BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, /* Protect the local heap prefix */ if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; @@ -344,12 +348,12 @@ BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, /* Protect the local heap data block */ if (NULL == (dblk = (H5HL_dblk_t *)H5AC_protect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, heap, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to load heap data block"); /* Set the flag for pinning the data block when unprotecting it */ dblk_cache_flags |= H5AC__PIN_ENTRY_FLAG; - } /* end if */ - } /* end if */ + } + } /* Increment # of times heap is protected */ heap->prots++; @@ -357,16 +361,17 @@ BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, /* Set return value */ ret_value = heap; - CATCH +done: /* Release the prefix from the cache, now pinned */ if (prfx && heap && H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, prfx_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release local heap prefix"); /* Release the data block from the cache, now pinned */ if (dblk && heap && H5AC_unprotect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, dblk, dblk_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap data block"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release local heap data block"); -END_FUNC(PRIV) /* end H5HL_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_protect() */ /*------------------------------------------------------------------------- * Function: H5HL_offset_into @@ -374,26 +379,31 @@ END_FUNC(PRIV) /* end H5HL_protect() */ * Purpose: Called directly after the call to H5HL_protect so that * a pointer to the object in the heap can be obtained. * - * Return: Success: Valid pointer. - * Failure: Can't fail + * Return: Success: Valid pointer + * Failure: NULL * * Programmer: Bill Wendling * Sept. 17, 2003 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, void *, NULL, NULL, H5HL_offset_into(const H5HL_t *heap, size_t offset)) +void * +H5HL_offset_into(const H5HL_t *heap, size_t offset) +{ + void *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) /* Sanity check */ HDassert(heap); if (offset >= heap->dblk_size) - H5E_THROW(H5E_CANTGET, "unable to offset into local heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, NULL, "unable to offset into local heap data block"); ret_value = heap->dblk_image + offset; - CATCH -/* No special processing on errors */ -END_FUNC(PRIV) /* end H5HL_offset_into() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_offset_into() */ /*------------------------------------------------------------------------- * Function: H5HL_unprotect @@ -407,9 +417,14 @@ END_FUNC(PRIV) /* end H5HL_offset_into() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_unprotect(H5HL_t *heap)) +herr_t +H5HL_unprotect(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; - /* check arguments */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(heap); /* Decrement # of times heap is protected */ @@ -421,8 +436,8 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_unprotect(H5HL_t *heap)) if (heap->single_cache_obj) { /* Mark local heap prefix as evictable again */ if (FAIL == H5AC_unpin_entry(heap->prfx)) - H5E_THROW(H5E_CANTUNPIN, "unable to unpin local heap data block"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap data block"); + } else { /* Sanity check */ HDassert(heap->dblk); @@ -430,14 +445,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_unprotect(H5HL_t *heap)) /* Mark local heap data block as evictable again */ /* (data block still pins prefix) */ if (FAIL == H5AC_unpin_entry(heap->dblk)) - H5E_THROW(H5E_CANTUNPIN, "unable to unpin local heap data block"); - } /* end else */ - } /* end if */ - - CATCH - /* No special processing on errors */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap data block"); + } + } -END_FUNC(PRIV) /* end H5HL_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_unprotect() */ /*------------------------------------------------------------------------- * Function: H5HL__remove_free @@ -452,7 +466,12 @@ END_FUNC(PRIV) /* end H5HL_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, H5HL_free_t *, NULL, -, H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl)) +static H5HL_free_t * +H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl) +{ + H5HL_free_t *ret_value = NULL; + + FUNC_ENTER_STATIC_NOERR if (fl->prev) fl->prev->next = fl->next; @@ -465,7 +484,8 @@ BEGIN_FUNC(STATIC, NOERR, H5HL_free_t *, NULL, -, H5HL__remove_free(H5HL_t *heap /* H5FL_FREE always returns NULL so we can't check for errors */ ret_value = (H5HL_free_t *)H5FL_FREE(H5HL_free_t, fl); -END_FUNC(STATIC) /* end H5HL__remove_free() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__remove_free() */ /*------------------------------------------------------------------------- * Function: H5HL__dirty @@ -479,9 +499,14 @@ END_FUNC(STATIC) /* end H5HL__remove_free() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__dirty(H5HL_t *heap)) +static herr_t +H5HL__dirty(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; - /* check arguments */ + FUNC_ENTER_STATIC + + /* Check arguments */ HDassert(heap); HDassert(heap->prfx); @@ -491,17 +516,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__dirty(H5HL_t *heap)) HDassert(heap->dblk); if (FAIL == H5AC_mark_entry_dirty(heap->dblk)) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap data block as dirty"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap data block as dirty"); + } /* Mark heap prefix as dirty */ if (FAIL == H5AC_mark_entry_dirty(heap->prfx)) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap prefix as dirty"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap prefix as dirty"); - CATCH - /* No special processing on errors */ - -END_FUNC(STATIC) /* end H5HL__dirty() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dirty() */ /*------------------------------------------------------------------------- * Function: H5HL_insert @@ -519,13 +543,16 @@ END_FUNC(STATIC) /* end H5HL__dirty() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, - H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf, size_t *offset_out)) +H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf, size_t *offset_out) +{ H5HL_free_t *fl = NULL, *last_fl = NULL; size_t need_size; size_t offset = 0; hbool_t found; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) /* Check arguments */ HDassert(f); @@ -541,7 +568,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, * if an error occurs -QAK) */ if (FAIL == H5HL__dirty(heap)) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap as dirty"); /* In order to keep the free list descriptors aligned on word boundaries, * whatever that might mean, we round the size up to the next multiple of @@ -574,7 +601,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, /* Track free space that's closest to end of heap */ last_fl = fl; } - } /* end for */ + } /* If no free chunk was large enough, then allocate more space and * add it to the free list. If the heap ends with a free chunk, we @@ -612,7 +639,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, was_extended = H5MF_try_extend(f, H5FD_MEM_LHEAP, heap->dblk_addr, (hsize_t)(heap->dblk_size), (hsize_t)need_more); if (FAIL == was_extended) - H5E_THROW(H5E_CANTEXTEND, "error trying to extend heap"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "error trying to extend heap"); /* Check if we extended the heap data block in file */ if (was_extended == TRUE) { @@ -620,22 +647,22 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, if (heap->single_cache_obj) { /* Resize prefix+data block */ if (FAIL == H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_dblk_size))) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap prefix in cache"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap prefix in cache"); + } else { /* Resize 'standalone' data block */ if (FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_dblk_size)) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap data block in cache"); - } /* end else */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap data block in cache"); + } /* Note new size */ heap->dblk_size = new_dblk_size; - } /* end if */ + } else { /* ...if we can't, allocate a new chunk & release the old */ /* Reallocate data block in file */ if (FAIL == H5HL__dblk_realloc(f, heap, new_dblk_size)) - H5E_THROW(H5E_CANTRESIZE, "reallocating data block failed"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "reallocating data block failed"); + } /* If the last free list in the heap is at the end of the heap, extend it */ if (last_fl && last_fl->offset + last_fl->size == old_dblk_size) { @@ -657,7 +684,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, #endif last_fl = H5HL__remove_free(heap, last_fl); } - } /* end if */ + } else { /* Create a new free list element large enough that we can * take some space out of it right away. @@ -665,7 +692,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, offset = old_dblk_size; if (need_more - need_size >= H5HL_SIZEOF_FREE(f)) { if (NULL == (fl = H5FL_MALLOC(H5HL_free_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); fl->offset = old_dblk_size + need_size; fl->size = need_more - need_size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); @@ -682,7 +709,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, (unsigned long)(need_more - need_size), __LINE__); #endif } - } /* end else */ + } #ifdef H5HL_DEBUG if (H5DEBUG(HL)) { @@ -691,22 +718,21 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, } #endif if (NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, heap->dblk_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* Clear new section so junk doesn't appear in the file */ /* (Avoid clearing section which will be overwritten with newly inserted data) */ HDmemset(heap->dblk_image + offset + buf_size, 0, (new_dblk_size - (offset + buf_size))); - } /* end if */ + } /* Copy the data into the heap */ H5MM_memcpy(heap->dblk_image + offset, buf, buf_size); *offset_out = offset; - CATCH - /* No special processing on exit */ - -END_FUNC(PRIV) /* H5HL_insert() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HL_insert() */ /*------------------------------------------------------------------------- * Function: H5HL_remove @@ -731,11 +757,15 @@ END_FUNC(PRIV) /* H5HL_insert() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) +herr_t +H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size) +{ + H5HL_free_t *fl = NULL; + herr_t ret_value = SUCCEED; - H5HL_free_t *fl = NULL; + FUNC_ENTER_NOAPI(FAIL) - /* check arguments */ + /* Check arguments */ HDassert(f); HDassert(heap); HDassert(size > 0); @@ -746,17 +776,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, HDassert(offset < heap->dblk_size); HDassert(offset + size <= heap->dblk_size); - /* Mark heap as dirty in cache */ - /* (A bit early in the process, but it's difficult to determine in the + /* Mark heap as dirty in cache + * + * (A bit early in the process, but it's difficult to determine in the * code below where to mark the heap as dirty, especially in error cases, * so we just accept that an extra flush of the heap info could occur * if an error occurs -QAK) */ if (FAIL == H5HL__dirty(heap)) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap as dirty"); - /* - * Check if this chunk can be prepended or appended to an already + /* Check if this chunk can be prepended or appended to an already * free chunk. It might also fall between two chunks in such a way * that all three chunks can be combined into one. */ @@ -779,17 +809,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, fl2 = H5HL__remove_free(heap, fl2); if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); } - H5_LEAVE(SUCCEED); + HGOTO_DONE(SUCCEED) } fl2 = fl2->next; } if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); } - H5_LEAVE(SUCCEED); + HGOTO_DONE(SUCCEED) } else if (fl->offset + fl->size == offset) { fl->size += size; @@ -802,20 +832,20 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, fl2 = H5HL__remove_free(heap, fl2); if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); - } /* end if */ - H5_LEAVE(SUCCEED); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); + } + HGOTO_DONE(SUCCEED) + } fl2 = fl2->next; - } /* end while */ + } if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); - } /* end if */ - H5_LEAVE(SUCCEED); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); + } + HGOTO_DONE(SUCCEED) + } fl = fl->next; - } /* end while */ + } /* * The amount which is being removed must be large enough to @@ -828,14 +858,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, HDfprintf(H5DEBUG(HL), "H5HL: lost %lu bytes\n", (unsigned long)size); } #endif - H5_LEAVE(SUCCEED); - } /* end if */ + HGOTO_DONE(SUCCEED) + } - /* - * Add an entry to the free list. - */ + /* Add an entry to the free list */ if (NULL == (fl = H5FL_MALLOC(H5HL_free_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); fl->offset = offset; fl->size = size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); @@ -848,12 +876,11 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); - - CATCH - /* No special processing on exit */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); -END_FUNC(PRIV) /* end H5HL_remove() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_remove() */ /*------------------------------------------------------------------------- * Function: H5HL_delete @@ -867,15 +894,19 @@ END_FUNC(PRIV) /* end H5HL_remove() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_delete(H5F_t *f, haddr_t addr)) - +herr_t +H5HL_delete(H5F_t *f, haddr_t addr) +{ H5HL_t * heap = NULL; /* Local heap to delete */ H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ H5HL_dblk_t * dblk = NULL; /* Local heap data block */ unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */ + herr_t ret_value = SUCCEED; - /* check arguments */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); @@ -888,7 +919,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_delete(H5F_t *f, haddr_t addr) /* Protect the local heap prefix */ if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; @@ -898,21 +929,22 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_delete(H5F_t *f, haddr_t addr) /* Protect the local heap data block */ if (NULL == (dblk = (H5HL_dblk_t *)H5AC_protect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, heap, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap data block"); /* Set the flags for releasing the prefix and data block */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; - CATCH +done: /* Release the data block from the cache, now deleted */ if (dblk && heap && H5AC_unprotect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, dblk, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap data block"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap data block"); /* Release the prefix from the cache, now deleted */ if (prfx && heap && H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix"); -END_FUNC(PRIV) /* end H5HL_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_delete() */ /*------------------------------------------------------------------------- * Function: H5HL_get_size @@ -926,13 +958,17 @@ END_FUNC(PRIV) /* end H5HL_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size)) +herr_t +H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size) +{ + H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ + H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ + H5HL_t * heap = NULL; /* Heap data structure */ + herr_t ret_value = SUCCEED; - H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ - H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ - H5HL_t * heap = NULL; /* Heap data structure */ + FUNC_ENTER_NOAPI(FAIL) - /* check arguments */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); HDassert(size); @@ -946,7 +982,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_get_size(H5F_t *f, haddr_t add /* Protect the local heap prefix */ if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; @@ -954,11 +990,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_get_size(H5F_t *f, haddr_t add /* Set the size to return */ *size = heap->dblk_size; - CATCH +done: if (prfx && FAIL == H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix"); -END_FUNC(PRIV) /* end H5HL_get_size() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_get_size() */ /*------------------------------------------------------------------------- * Function: H5HL_heapsize @@ -973,13 +1010,17 @@ END_FUNC(PRIV) /* end H5HL_get_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size)) +herr_t +H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size) +{ + H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ + H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ + H5HL_t * heap = NULL; /* Heap data structure */ + herr_t ret_value = SUCCEED; - H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ - H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ - H5HL_t * heap = NULL; /* Heap data structure */ + FUNC_ENTER_NOAPI(FAIL) - /* check arguments */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); HDassert(heap_size); @@ -993,7 +1034,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_heapsize(H5F_t *f, haddr_t add /* Protect the local heap prefix */ if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; @@ -1001,8 +1042,9 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_heapsize(H5F_t *f, haddr_t add /* Accumulate the size of the local heap */ *heap_size += (hsize_t)(heap->prfx_size + heap->dblk_size); - CATCH +done: if (prfx && FAIL == H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix"); -END_FUNC(PRIV) /* end H5HL_heapsize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_heapsize() */ diff --git a/src/H5HLcache.c b/src/H5HLcache.c index b46280ef79b..9eb390bf243 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -250,7 +250,7 @@ H5HL__fl_deserialize(H5HL_t *heap) heap->freelist = fl; tail = fl; fl = NULL; - } /* end while */ + } done: if (ret_value < 0) @@ -296,7 +296,7 @@ H5HL__fl_serialize(const H5HL_t *heap) H5F_ENCODE_LENGTH_LEN(image, H5HL_FREE_NULL, heap->sizeof_size) H5F_ENCODE_LENGTH_LEN(image, fl->size, heap->sizeof_size) - } /* end for */ + } FUNC_LEAVE_NOAPI_VOID @@ -450,13 +450,13 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* Build free list */ if (H5HL__fl_deserialize(heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list") - } /* end if */ + } else /* Note that the heap should _NOT_ be a single * object in the cache */ heap->single_cache_obj = FALSE; - } /* end if */ + } /* Set return value */ ret_value = prfx; @@ -467,12 +467,12 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED if (prfx) { if (FAIL == H5HL__prfx_dest(prfx)) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap prefix"); - } /* end if */ + } else { if (heap && FAIL == H5HL__dest(heap)) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap"); - } /* end else */ - } /* end if */ + } + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_prefix_deserialize() */ @@ -588,7 +588,7 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, gap = heap->prfx_size - (size_t)(image - (uint8_t *)_image); HDmemset(image, 0, gap); image += gap; - } /* end if */ + } /* Serialize the free list into the heap data's image */ H5HL__fl_serialize(heap); @@ -598,14 +598,14 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) + heap->dblk_size == len); - } /* end if */ + } else { /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) <= len); /* Clear rest of local heap */ HDmemset(image, 0, len - (size_t)(image - (uint8_t *)_image)); - } /* end else */ + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_prefix_serialize() */ @@ -736,7 +736,7 @@ H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata, h /* Build free list */ if (FAIL == H5HL__fl_deserialize(heap)) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list"); - } /* end if */ + } /* Set return value */ ret_value = dblk; @@ -892,7 +892,7 @@ H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing) default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown action from metadata cache") break; - } /* end switch */ + } done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index 76e4ec09cbb..305014bc7aa 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -44,14 +44,17 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, - H5HL_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth)) - +herr_t +H5HL_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) +{ H5HL_t * h = NULL; int free_block; H5HL_free_t *freelist; uint8_t * marker = NULL; size_t amount_free = 0; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) /* check arguments */ HDassert(f); @@ -61,7 +64,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, HDassert(fwidth >= 0); if (NULL == (h = (H5HL_t *)H5HL_protect(f, addr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load/protect local heap"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load/protect local heap") HDfprintf(stream, "%*sLocal Heap...\n", indent, ""); HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Header size (in bytes):", h->prfx_size); @@ -73,7 +76,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, * the heap. */ if (NULL == (marker = (uint8_t *)H5MM_calloc(h->dblk_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") HDfprintf(stream, "%*sFree Blocks (offset, size):\n", indent, ""); for (free_block = 0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) { @@ -92,13 +95,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, if (marker[freelist->offset + i]) overlap++; marker[freelist->offset + i] = 1; - } /* end for */ + } if (overlap) HDfprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS ONE!\n"); else amount_free += freelist->size; - } /* end else */ - } /* end for */ + } + } if (h->dblk_size) HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, "Percent of heap used:", @@ -107,11 +110,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, /* Print the data in a VMS-style octal dump */ H5_buffer_dump(stream, indent, h->dblk_image, marker, (size_t)0, h->dblk_size); - CATCH +done: if (h && FAIL == H5HL_unprotect(h)) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release/unprotect local heap"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release/unprotect local heap") if (marker && NULL != (marker = (uint8_t *)H5MM_xfree(marker))) - H5E_THROW(H5E_CANTFREE, "can't free marker buffer"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't free marker buffer") -END_FUNC(PRIV) /* end H5HL_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_debug() */ diff --git a/src/H5HLdblk.c b/src/H5HLdblk.c index f771de522c5..9e6fc4ad3e6 100644 --- a/src/H5HLdblk.c +++ b/src/H5HLdblk.c @@ -81,20 +81,24 @@ H5FL_DEFINE_STATIC(H5HL_dblk_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5HL_dblk_t *, NULL, NULL, H5HL__dblk_new(H5HL_t *heap)) +H5HL_dblk_t * +H5HL__dblk_new(H5HL_t *heap) +{ + H5HL_dblk_t *dblk = NULL; /* New local heap data block */ + H5HL_dblk_t *ret_value = NULL; - H5HL_dblk_t *dblk = NULL; /* New local heap data block */ + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(heap); /* Allocate new local heap data block */ if (NULL == (dblk = H5FL_CALLOC(H5HL_dblk_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for local heap data block") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed for local heap data block") /* Increment ref. count on heap data structure */ if (FAIL == H5HL__inc_rc(heap)) - H5E_THROW(H5E_CANTINC, "can't increment heap ref. count") + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment heap ref. count") /* Link the heap & the data block */ dblk->heap = heap; @@ -103,13 +107,14 @@ BEGIN_FUNC(PKG, ERR, H5HL_dblk_t *, NULL, NULL, H5HL__dblk_new(H5HL_t *heap)) /* Set the return value */ ret_value = dblk; - CATCH +done: /* Ensure that the data block memory is deallocated on errors */ if (!ret_value && dblk != NULL) /* H5FL_FREE always returns NULL so we can't check for errors */ dblk = H5FL_FREE(H5HL_dblk_t, dblk); -END_FUNC(PKG) /* end H5HL__dblk_new() */ + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5HL__dblk_new() */ /*------------------------------------------------------------------------- * Function: H5HL__dblk_dest @@ -123,7 +128,12 @@ END_FUNC(PKG) /* end H5HL__dblk_new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_dest(H5HL_dblk_t *dblk)) +herr_t +H5HL__dblk_dest(H5HL_dblk_t *dblk) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(dblk); @@ -135,18 +145,19 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_dest(H5HL_dblk_t *dblk)) /* Decrement ref. count on heap data structure */ if (FAIL == H5HL__dec_rc(dblk->heap)) - H5E_THROW(H5E_CANTDEC, "can't decrement heap ref. count") + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement heap ref. count") /* Unlink heap from data block */ dblk->heap = NULL; - } /* end if */ + } - CATCH +done: /* Free local heap data block */ /* H5FL_FREE always returns NULL so we can't check for errors */ dblk = H5FL_FREE(H5HL_dblk_t, dblk); -END_FUNC(PKG) /* end H5HL__dblk_dest() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dblk_dest() */ /*------------------------------------------------------------------------- * Function: H5HL__dblk_realloc @@ -160,14 +171,18 @@ END_FUNC(PKG) /* end H5HL__dblk_dest() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size)) - +herr_t +H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size) +{ H5HL_dblk_t *dblk; /* Local heap data block */ haddr_t old_addr; /* Old location of heap data block */ haddr_t new_addr; /* New location of heap data block */ size_t old_heap_size; /* Old size of heap data block */ + herr_t ret_value = SUCCEED; - /* check arguments */ + FUNC_ENTER_PACKAGE + + /* Check arguments */ HDassert(heap); HDassert(new_heap_size > 0); @@ -176,12 +191,12 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t old_heap_size = heap->dblk_size; H5_CHECK_OVERFLOW(old_heap_size, size_t, hsize_t); if (FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, old_addr, (hsize_t)old_heap_size)) - H5E_THROW(H5E_CANTFREE, "can't free old local heap data"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't free old local heap data"); /* Allocate new space on disk */ H5_CHECK_OVERFLOW(new_heap_size, size_t, hsize_t); if (HADDR_UNDEF == (new_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, (hsize_t)new_heap_size))) - H5E_THROW(H5E_CANTALLOC, "unable to allocate file space for local heap"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate file space for local heap"); /* Update heap info*/ heap->dblk_addr = new_addr; @@ -197,8 +212,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t /* Resize the heap prefix in the cache */ if (FAIL == H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_heap_size))) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap in cache"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap in cache"); + } else { /* Sanity check */ HDassert(H5F_addr_ne(heap->prfx_addr + heap->prfx_size, old_addr)); @@ -206,50 +221,49 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t /* Resize the heap data block in the cache */ if (H5AC_resize_entry(heap->dblk, (size_t)new_heap_size) < 0) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap (data block) in cache"); - } /* end else */ - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap (data block) in cache"); + } + } else { /* Check if heap data block was contiguous w/prefix previously */ if (heap->single_cache_obj) { /* Create new heap data block */ if (NULL == (dblk = H5HL__dblk_new(heap))) - H5E_THROW(H5E_CANTALLOC, "unable to allocate local heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate local heap data block"); /* Resize current heap prefix */ heap->prfx_size = H5HL_SIZEOF_HDR(f); if (FAIL == H5AC_resize_entry(heap->prfx, (size_t)heap->prfx_size)) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap prefix in cache"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap prefix in cache"); /* Insert data block into cache (pinned) */ if (FAIL == H5AC_insert_entry(f, H5AC_LHEAP_DBLK, new_addr, dblk, H5AC__PIN_ENTRY_FLAG)) - H5E_THROW(H5E_CANTINIT, "unable to cache local heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to cache local heap data block"); dblk = NULL; /* Reset 'single cache object' flag */ heap->single_cache_obj = FALSE; - } /* end if */ + } else { /* Resize the heap data block in the cache */ /* (ignore [unlikely] case where heap data block ends up * contiguous w/heap prefix again. */ if (FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_heap_size)) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap data block in cache"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap data block in cache"); /* Relocate the heap data block in the cache */ if (FAIL == H5AC_move_entry(f, H5AC_LHEAP_DBLK, old_addr, new_addr)) - H5E_THROW(H5E_CANTMOVE, "unable to move heap data block in cache"); - - } /* end else */ - } /* end else */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTMOVE, FAIL, "unable to move heap data block in cache"); + } + } - CATCH +done: /* Restore old heap address & size on errors */ if (FAIL == ret_value) { heap->dblk_addr = old_addr; heap->dblk_size = old_heap_size; - } /* end if */ - -END_FUNC(PKG) /* end H5HL__dblk_realloc() */ + } + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dblk_realloc() */ diff --git a/src/H5HLint.c b/src/H5HLint.c index 069bad80761..42d67448a93 100644 --- a/src/H5HLint.c +++ b/src/H5HLint.c @@ -80,10 +80,13 @@ H5FL_DEFINE_STATIC(H5HL_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5HL_t *, NULL, NULL, - H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)) +H5HL_t * +H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size) +{ + H5HL_t *heap = NULL; /* New local heap */ + H5HL_t *ret_value = NULL; - H5HL_t *heap = NULL; /* New local heap */ + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(sizeof_size > 0); @@ -92,7 +95,7 @@ BEGIN_FUNC(PKG, ERR, H5HL_t *, NULL, NULL, /* Allocate new local heap structure */ if (NULL == (heap = H5FL_CALLOC(H5HL_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") /* Initialize non-zero fields */ heap->sizeof_size = sizeof_size; @@ -102,12 +105,13 @@ BEGIN_FUNC(PKG, ERR, H5HL_t *, NULL, NULL, /* Set the return value */ ret_value = heap; - CATCH +done: if (!ret_value && heap != NULL) if (NULL == (heap = H5FL_FREE(H5HL_t, heap))) - H5E_THROW(H5E_CANTFREE, "can't free heap memory"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "can't free heap memory") -END_FUNC(PKG) /* end H5HL__new() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__new() */ /*------------------------------------------------------------------------- * Function: H5HL__inc_rc @@ -121,7 +125,10 @@ END_FUNC(PKG) /* end H5HL__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5HL__inc_rc(H5HL_t *heap)) +herr_t +H5HL__inc_rc(H5HL_t *heap) +{ + FUNC_ENTER_PACKAGE_NOERR /* check arguments */ HDassert(heap); @@ -129,7 +136,8 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5HL__inc_rc(H5HL_t *heap)) /* Increment heap's ref. count */ heap->rc++; -END_FUNC(PKG) /* end H5HL__inc_rc() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5HL__inc_rc() */ /*------------------------------------------------------------------------- * Function: H5HL__dec_rc @@ -143,7 +151,12 @@ END_FUNC(PKG) /* end H5HL__inc_rc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dec_rc(H5HL_t *heap)) +herr_t +H5HL__dec_rc(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(heap); @@ -151,12 +164,13 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dec_rc(H5HL_t *heap)) /* Decrement heap's ref. count */ heap->rc--; - CATCH /* Check if we should destroy the heap */ if (heap->rc == 0 && FAIL == H5HL__dest(heap)) - H5E_THROW(H5E_CANTFREE, "unable to destroy local heap"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap"); -END_FUNC(PKG) /* end H5HL__dec_rc() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dec_rc() */ /*------------------------------------------------------------------------- * Function: H5HL__dest @@ -170,7 +184,12 @@ END_FUNC(PKG) /* end H5HL__dec_rc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dest(H5HL_t *heap)) +herr_t +H5HL__dest(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(heap); @@ -181,20 +200,21 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dest(H5HL_t *heap)) HDassert(heap->prfx == NULL); HDassert(heap->dblk == NULL); - CATCH + /* Use DONE errors here to try to free as much as possible */ if (heap->dblk_image) if (NULL != (heap->dblk_image = H5FL_BLK_FREE(lheap_chunk, heap->dblk_image))) - H5E_THROW(H5E_CANTFREE, "unable to free local heap data block image"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap data block image"); while (heap->freelist) { H5HL_free_t *fl; fl = heap->freelist; heap->freelist = fl->next; if (NULL != (fl = H5FL_FREE(H5HL_free_t, fl))) - H5E_THROW(H5E_CANTFREE, "unable to free local heap free list"); - } /* end while */ + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap free list"); + } if (NULL != (heap = H5FL_FREE(H5HL_t, heap))) - H5E_THROW(H5E_CANTFREE, "unable to free local heap"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap"); -END_FUNC(PKG) /* end H5HL__dest() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dest() */ diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h index dbac1b9f3fd..0ba3b1c5a77 100644 --- a/src/H5HLpkg.h +++ b/src/H5HLpkg.h @@ -54,7 +54,7 @@ H5FL_BLK_EXTERN(lheap_chunk); #define H5_MY_PKG H5HL #define H5_MY_PKG_ERR H5E_HEAP #define H5_MY_PKG_INIT NO -#endif /* H5HL_PACKAGE */ +#endif #define H5HL_SIZEOF_HDR(F) \ H5HL_ALIGN(H5_SIZEOF_MAGIC + /* heap signature */ \ diff --git a/src/H5HLprfx.c b/src/H5HLprfx.c index 90f6c741c0a..03e399911c7 100644 --- a/src/H5HLprfx.c +++ b/src/H5HLprfx.c @@ -80,20 +80,24 @@ H5FL_DEFINE_STATIC(H5HL_prfx_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5HL_prfx_t *, NULL, NULL, H5HL__prfx_new(H5HL_t *heap)) +H5HL_prfx_t * +H5HL__prfx_new(H5HL_t *heap) +{ + H5HL_prfx_t *prfx = NULL; /* New local heap prefix */ + H5HL_prfx_t *ret_value = NULL; - H5HL_prfx_t *prfx = NULL; /* New local heap prefix */ + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(heap); /* Allocate new local heap prefix */ if (NULL == (prfx = H5FL_CALLOC(H5HL_prfx_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for local heap prefix") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed for local heap prefix") /* Increment ref. count on heap data structure */ if (FAIL == H5HL__inc_rc(heap)) - H5E_THROW(H5E_CANTINC, "can't increment heap ref. count") + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment heap ref. count") /* Link the heap & the prefix */ prfx->heap = heap; @@ -102,13 +106,14 @@ BEGIN_FUNC(PKG, ERR, H5HL_prfx_t *, NULL, NULL, H5HL__prfx_new(H5HL_t *heap)) /* Set the return value */ ret_value = prfx; - CATCH +done: /* Ensure that the prefix memory is deallocated on errors */ if (!ret_value && prfx != NULL) /* H5FL_FREE always returns NULL so we can't check for errors */ prfx = H5FL_FREE(H5HL_prfx_t, prfx); -END_FUNC(PKG) /* end H5HL__prfx_new() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__prfx_new() */ /*------------------------------------------------------------------------- * Function: H5HL__prfx_dest @@ -122,7 +127,12 @@ END_FUNC(PKG) /* end H5HL__prfx_new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__prfx_dest(H5HL_prfx_t *prfx)) +herr_t +H5HL__prfx_dest(H5HL_prfx_t *prfx) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(prfx); @@ -134,15 +144,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__prfx_dest(H5HL_prfx_t *prfx)) /* Decrement ref. count on heap data structure */ if (FAIL == H5HL__dec_rc(prfx->heap)) - H5E_THROW(H5E_CANTDEC, "can't decrement heap ref. count") + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement heap ref. count") /* Unlink heap from prefix */ prfx->heap = NULL; - } /* end if */ + } - CATCH +done: /* Free prefix memory */ /* H5FL_FREE always returns NULL so we can't check for errors */ prfx = H5FL_FREE(H5HL_prfx_t, prfx); -END_FUNC(PKG) /* end H5HL__prfx_dest() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__prfx_dest() */ diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h index 5c9884629db..02e07eb8e10 100644 --- a/src/H5HLprivate.h +++ b/src/H5HLprivate.h @@ -66,4 +66,4 @@ H5_DLL herr_t H5HL_unprotect(H5HL_t *heap); /* Debugging routines for dumping file structures */ H5_DLL herr_t H5HL_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); -#endif +#endif /* H5HLprivate_H */ diff --git a/src/H5Lpublic.h b/src/H5Lpublic.h index 5eaab49b56b..a87edfe2619 100644 --- a/src/H5Lpublic.h +++ b/src/H5Lpublic.h @@ -38,12 +38,12 @@ * * The maximum length of a link's name is encoded in a 32-bit unsigned integer. */ -#define H5L_MAX_LINK_NAME_LEN ((uint32_t)(-1)) /* (4GB - 1) */ +#define H5L_MAX_LINK_NAME_LEN UINT32_MAX /** * \brief Macro to indicate operation occurs on same location */ -#define H5L_SAME_LOC (hid_t)0 +#define H5L_SAME_LOC 0 /* (hid_t) */ /** * \brief Current version of the H5L_class_t struct diff --git a/src/H5MF.c b/src/H5MF.c index 339bbc9243b..f7f3be29eb6 100644 --- a/src/H5MF.c +++ b/src/H5MF.c @@ -1450,13 +1450,13 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, hsi htri_t H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) { - H5MF_free_section_t * node = NULL; /* Free space section pointer */ - H5MF_sect_ud_t udata; /* User data for callback */ - H5FS_section_class_t *sect_cls; /* Section class */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ - H5F_mem_page_t fs_type; /* Free space type */ - htri_t ret_value = FALSE; /* Return value */ + H5MF_free_section_t * node = NULL; /* Free space section pointer */ + H5MF_sect_ud_t udata; /* User data for callback */ + const H5FS_section_class_t *sect_cls; /* Section class */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ + H5F_mem_page_t fs_type; /* Free space type */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) #ifdef H5MF_ALLOC_DEBUG diff --git a/src/H5MFpkg.h b/src/H5MFpkg.h index 54ae1bcc893..c0e9698e64b 100644 --- a/src/H5MFpkg.h +++ b/src/H5MFpkg.h @@ -168,9 +168,9 @@ typedef struct H5MF_fs_t { /*****************************/ /* H5MF single section inherits serializable properties from H5FS_section_class_t */ -H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1]; -H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1]; -H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1]; +H5_DLLVAR const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1]; +H5_DLLVAR const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1]; +H5_DLLVAR const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1]; /******************************/ /* Package Private Prototypes */ diff --git a/src/H5MFsection.c b/src/H5MFsection.c index 8d4704ea074..bf5b88892cb 100644 --- a/src/H5MFsection.c +++ b/src/H5MFsection.c @@ -81,7 +81,7 @@ static herr_t H5MF__sect_large_shrink(H5FS_section_info_t **_sect, void *udata); /*********************/ /* Class info for "simple" free space sections */ -H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1] = {{ +const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1] = {{ /* Class variables */ H5MF_FSPACE_SECT_SIMPLE, /* Section type */ 0, /* Extra serialized size */ @@ -107,7 +107,7 @@ H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1] = {{ }}; /* Class info for "small" free space sections */ -H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1] = {{ +const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1] = {{ /* Class variables */ H5MF_FSPACE_SECT_SMALL, /* Section type */ 0, /* Extra serialized size */ @@ -133,7 +133,7 @@ H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1] = {{ }}; /* Class info for "large" free space sections */ -H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1] = {{ +const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1] = {{ /* Class variables */ H5MF_FSPACE_SECT_LARGE, /* Section type */ 0, /* Extra serialized size */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index fea8a39d41b..ca794949911 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -92,7 +92,7 @@ #define H5P_CRT_ORDER_INDEXED 0x0002 /* Default value for all property list classes */ -#define H5P_DEFAULT (hid_t)0 +#define H5P_DEFAULT 0 /* (hid_t) */ #ifdef __cplusplus extern "C" { diff --git a/src/H5Spublic.h b/src/H5Spublic.h index 2b619d61a49..e3fe37e8360 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -22,7 +22,7 @@ #include "H5Ipublic.h" /* Define atomic datatypes */ -#define H5S_ALL (hid_t)0 +#define H5S_ALL 0 /* (hid_t) */ #define H5S_UNLIMITED HSIZE_UNDEF /* Define user-level maximum number of dimensions */ diff --git a/src/H5T.c b/src/H5T.c index 739c8b285a8..31857743531 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -3251,8 +3251,8 @@ H5T__create(H5T_class_t type, size_t size) * Note: Common code for both H5T_copy and H5T_copy_reopen, as part of * the const-correct datatype copying routines. * - * Programmer: David Young - * January 18, 2020 + * Programmer: David Young + * January 18, 2020 * *------------------------------------------------------------------------- */ @@ -3295,8 +3295,8 @@ H5T__initiate_copy(const H5T_t *old_dt) * Return: Success: Pointer to a new copy of the OLD_DT argument. * Failure: NULL * - * Programmer: David Young - * January 18, 2020 + * Programmer: David Young + * January 18, 2020 * *------------------------------------------------------------------------- */ @@ -3323,8 +3323,8 @@ H5T__copy_transient(H5T_t *old_dt) * Return: Success: Pointer to a new copy of the OLD_DT argument. * Failure: NULL * - * Programmer: David Young - * January 18, 2020 + * Programmer: David Young + * January 18, 2020 * *------------------------------------------------------------------------- */ @@ -3354,8 +3354,8 @@ H5T__copy_all(H5T_t *old_dt) * * Note: Common code for both H5T_copy and H5T_copy_reopen. * - * Programmer: David Young - * January 18, 2020 + * Programmer: David Young + * January 18, 2020 * *------------------------------------------------------------------------- */ @@ -3625,8 +3625,8 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) * Return: Success: Pointer to a new copy of the OLD_DT argument. * Failure: NULL * - * Programmer: David Young - * January 18, 2020 + * Programmer: David Young + * January 18, 2020 * *------------------------------------------------------------------------- */ @@ -5096,7 +5096,10 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, H5T_co } /* end else-if */ /* Set the flag to indicate both source and destination types are compound types - * for the optimization of data reading (in H5Dio.c). */ + * for the optimization of data reading (in H5Dio.c). + * Make sure that path->are_compounds is only TRUE for compound types. + */ + path->are_compounds = FALSE; if (H5T_COMPOUND == H5T_get_class(src, TRUE) && H5T_COMPOUND == H5T_get_class(dst, TRUE)) path->are_compounds = TRUE; diff --git a/src/H5Tbit.c b/src/H5Tbit.c index 9f0c061b37d..04e2a979b35 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -268,7 +268,6 @@ H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size) /* Set return value */ ret_value = val; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__bit_get_d() */ diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index dad322f4ca8..3b757faaf4a 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -245,7 +245,7 @@ typedef struct { * Indicate that a string is variable length (null-terminated in C, instead of * fixed length) */ -#define H5T_VARIABLE ((size_t)(-1)) +#define H5T_VARIABLE SIZE_MAX /* Opaque information */ /** diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 650bca6fcea..7d55efd3d1c 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -13,12 +13,12 @@ #include "H5Zmodule.h" /* This source code file is part of the H5Z module */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* H5VM_array_fill */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* H5VM_array_fill */ +#include "H5Zpkg.h" /* Data filters */ /* Token types */ typedef enum { @@ -993,12 +993,12 @@ H5Z__new_node(H5Z_token_type type) /*------------------------------------------------------------------------- * Function: H5Z_xform_eval - * Purpose: If the transform is trivial, this function applies it. - * Otherwise, it calls H5Z__xform_eval_full to do the full - * transform. + * Purpose: If the transform is trivial, this function applies it. + * Otherwise, it calls H5Z__xform_eval_full to do the full + * transform. * Return: SUCCEED if transform applied successfully, FAIL otherwise * Programmer: Leon Arber - * 5/1/04 + * 5/1/04 * *------------------------------------------------------------------------- */ @@ -1109,8 +1109,8 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void *array, size_t array_size /*------------------------------------------------------------------------- * Function: H5Z__xform_eval_full * - * Purpose: Does a full evaluation of the parse tree contained in tree - * and applies this transform to array. + * Purpose: Does a full evaluation of the parse tree contained in tree + * and applies this transform to array. * * Notes: In the case of a polynomial data transform (ie, the left and right * subtree are both of type H5Z_XFORM_SYMBOL), the convention is @@ -1120,7 +1120,7 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void *array, size_t array_size * Return: Nothing * * Programmer: Leon Arber - * 5/1/04 + * 5/1/04 * *------------------------------------------------------------------------- */ @@ -1538,10 +1538,20 @@ H5Z_xform_create(const char *expr) "unable to allocate memory for data transform expression") /* Find the number of times "x" is used in this equation, and allocate room for storing that many points + * A more sophisticated check is needed to support scientific notation. */ - for (i = 0; i < HDstrlen(expr); i++) - if (HDisalpha(expr[i])) + for (i = 0; i < HDstrlen(expr); i++) { + if (HDisalpha(expr[i])) { + if ((i > 0) && (i < (HDstrlen(expr) - 1))) { + if (((expr[i] == 'E') || (expr[i] == 'e')) && + (HDisdigit(expr[i - 1]) || (expr[i - 1] == '.')) && + (HDisdigit(expr[i + 1]) || (expr[i + 1] == '-') || (expr[i + 1] == '+'))) + continue; + } + count++; + } + } /* When there are no "x"'s in the equation (ie, simple transform case), * we don't need to allocate any space since no array will have to be @@ -1752,7 +1762,7 @@ H5Z_xform_noop(const H5Z_data_xform_t *data_xform_prop) * Function: H5Z_xform_extract_xform_str * * Purpose: Extracts the pointer to the data transform strings from the - * data transform property.` + * data transform property.` * Return: * Pointer to a copy of the string in the data_xform property. * diff --git a/src/H5private.h b/src/H5private.h index 6100b6d57bc..162fae4051a 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -2464,257 +2464,26 @@ H5_DLL herr_t H5CX_pop(void); return (ret_value); \ } /*end scope from beginning of FUNC_ENTER*/ -/****************************************/ -/* Revisions to FUNC_ENTER/LEAVE Macros */ -/****************************************/ - -/* Macros to check if a package is initialized */ -#define H5_CHECK_PACKAGE_INIT_REG_YES(asrt) HDassert(H5_PACKAGE_INIT_VAR(pkg)); -#define H5_CHECK_PACKAGE_INIT_REG_NO(asrt) -#define H5_CHECK_PACKAGE_INIT_INIT_YES(asrt) -#define H5_CHECK_PACKAGE_INIT_INIT_NO(asrt) -#define H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) H5_GLUE4(H5_CHECK_PACKAGE_INIT_, init, _, pkg_init)(pkg) - -/* Macros to initialize package, if a package initialization routine is defined */ -#define H5_PKG_YES_INIT(pkg) \ - if (!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) { \ - H5_PACKAGE_INIT_VAR(pkg) = TRUE; \ - if (H5_PACKAGE_INIT_FUNC(pkg)() < 0) { \ - H5_PACKAGE_INIT_VAR(pkg) = FALSE; \ - /* (Can't use H5E_THROW here) */ \ - H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ - ret_value = fail_value; \ - goto func_init_failed; \ - } /* end if */ \ - } /* end if */ -#define H5_PKG_NO_INIT(pkg) \ - if (!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) \ - H5_PACKAGE_INIT_VAR(pkg) = TRUE; -#define H5_PKG_INIT(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT)(pkg) - /* Macros to declare package initialization function, if a package initialization routine is defined */ #ifdef H5_PKG_SINGLE_SOURCE #define H5_PKG_DECLARE_YES_FUNC(pkg) static herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); -#else /* H5_PKG_SINGLE_SOURCE */ +#else #define H5_PKG_DECLARE_YES_FUNC(pkg) extern herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); -#endif /* H5_PKG_SINGLE_SOURCE */ +#endif #define H5_PKG_DECLARE_NO_FUNC(pkg) /* Declare package initialization symbols (if in a package) */ #ifdef H5_PKG_SINGLE_SOURCE #define H5_PKG_DECLARE_VAR(pkg) static hbool_t H5_PACKAGE_INIT_VAR(pkg); -#else /* H5_PKG_SINGLE_SOURCE */ +#else #define H5_PKG_DECLARE_VAR(pkg) extern hbool_t H5_PACKAGE_INIT_VAR(pkg); -#endif /* H5_PKG_SINGLE_SOURCE */ +#endif #define H5_PKG_DECLARE_FUNC(pkg_init, pkg) H5_GLUE3(H5_PKG_DECLARE_, pkg_init, _FUNC)(pkg) + #ifdef H5_MY_PKG H5_PKG_DECLARE_VAR(H5_MY_PKG) H5_PKG_DECLARE_FUNC(H5_MY_PKG_INIT, H5_MY_PKG) -#endif /* H5_MY_PKG */ - -/* API re-entrance variable */ -extern hbool_t H5_api_entered_g; /* Has library already been entered through API? */ - -/* Macros for entering different scopes of routines */ -#define H5_PACKAGE_ENTER(pkg, pkg_init, init) \ - FUNC_ENTER_CHECK_NAME(H5_IS_PKG(FUNC)) \ - \ - /* The library should be initialized already */ \ - HDassert(H5_INIT_GLOBAL); \ - \ - /* This interface should be initialized already */ \ - /* (except for package initialization routines :-) */ \ - H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ - { - -#define H5_PRIVATE_ENTER(pkg, pkg_init) \ - FUNC_ENTER_CHECK_NAME(H5_IS_PRIV(FUNC)) \ - \ - /* The library should be initialized already */ \ - HDassert(H5_INIT_GLOBAL); \ - \ - /* Initialize this interface if desired */ \ - H5_PKG_INIT(pkg_init, pkg) \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ - { \ - { - -#define H5_PUBLIC_ENTER(pkg, pkg_init) \ - FUNC_ENTER_API_VARS \ - FUNC_ENTER_API_THREADSAFE; \ - FUNC_ENTER_CHECK_NAME(H5_IS_PUB(FUNC)) \ - \ - /* Clear thread error stack when entering public functions */ \ - H5E_clear_stack(NULL); \ - \ - /* Initialize the library or bust */ \ - if (!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ - H5_INIT_GLOBAL = TRUE; \ - if (H5_init_library() < 0) { \ - /* (Can't use H5E_THROW here) */ \ - H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ - ret_value = fail_value; \ - goto func_init_failed; \ - } /* end if */ \ - } /* end if */ \ - \ - /* Initialize this interface if desired */ \ - H5_PKG_INIT(pkg_init, pkg) \ - \ - /* Check for re-entering API routine */ \ - HDassert(!H5_api_entered_g); \ - H5_api_entered_g = TRUE; \ - \ - /* Start logging MPI's MPE information */ \ - BEGIN_MPE_LOG \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ - { \ - { \ - { - -/* Macros for substituting the package name */ -#define FUNC_ENT_STATIC(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, REG) -#define FUNC_ENT_PKGINIT(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, INIT) -#define FUNC_ENT_PKG(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, REG) -#define FUNC_ENT_PRIV(pkg, pkg_init) H5_PRIVATE_ENTER(pkg, pkg_init) -#define FUNC_ENT_PUB(pkg, pkg_init) H5_PUBLIC_ENTER(pkg, pkg_init) - -/* Macros for substituting a function prefix */ -#define FUNC_PREFIX_STATIC static -#define FUNC_PREFIX_PKGINIT -#define FUNC_PREFIX_PKG -#define FUNC_PREFIX_PRIV -#define FUNC_PREFIX_PUB - -/* Macros for declaring error variables */ -/* Function can detect errors and has a specific error return value */ -#define FUNC_ERR_VAR_ERR(ret_typ, err) \ - hbool_t past_catch = FALSE; \ - ret_typ fail_value = err; -/* Function can detect errors but cannot return an error value (Cleanup only) */ -#define FUNC_ERR_VAR_ERRCATCH(ret_typ, err) hbool_t past_catch = FALSE; -/* Function has no need to detect or clean up from errors */ -#define FUNC_ERR_VAR_NOERR(ret_typ, err) - -/* Use this macro when entering all functions */ -#define BEGIN_FUNC(scope, use_err, ret_typ, ret_init, err, func) \ - H5_GLUE(FUNC_PREFIX_, scope) \ - ret_typ func \ - /* Open function */ \ - { \ - ret_typ ret_value = ret_init; \ - H5_GLUE(FUNC_ERR_VAR_, use_err)(ret_typ, err) H5_GLUE(FUNC_ENT_, scope)(H5_MY_PKG, H5_MY_PKG_INIT) - -/* Use this macro when entering functions that have no return value */ -#define BEGIN_FUNC_VOID(scope, use_err, func) \ - H5_GLUE(FUNC_PREFIX_, scope) \ - void func \ - /* Open function */ \ - { \ - H5_GLUE(FUNC_ERR_VAR_, use_err)(void, -, -) H5_GLUE(FUNC_ENT_, scope) - -/* Macros for label when a function initialization can fail */ -#define H5_PRIV_YES_FUNC_INIT_FAILED \ -func_init_failed: -#define H5_PRIV_NO_FUNC_INIT_FAILED -#define H5_PRIV_FUNC_INIT_FAILED(pkg_init) H5_GLUE3(H5_PRIV_, pkg_init, _FUNC_INIT_FAILED) - -/* Macros for leaving different scopes of routines */ -#define FUNC_LEAVE_PKGINIT \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC - -#define FUNC_LEAVE_STATIC \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC - -#define FUNC_LEAVE_PKG \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC - -#define FUNC_LEAVE_PRIV \ - /* Leave scope for this type of function */ \ - } \ - } \ - \ - /* Label for errors during FUNC_ENTER */ \ - H5_PRIV_FUNC_INIT_FAILED(H5_MY_PKG_INIT) \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC - -#define FUNC_LEAVE_PUB \ - /* Leave scope for this type of function */ \ - } \ - } \ - } \ - \ - /* Label for errors during FUNC_ENTER */ \ -func_init_failed: \ - \ - /* Dump error stack if an error occurred during API routine */ \ - if (ret_value == fail_value) \ - (void)H5E_dump_api_stack(TRUE); \ - \ - /* Finish the API tracing info */ \ - H5TRACE_RETURN(ret_value); \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC \ - \ - /* Finish the MPE tracing info */ \ - FINISH_MPE_LOG \ - \ - /* Check for leaving API routine */ \ - HDassert(H5_api_entered_g); \ - H5_api_entered_g = FALSE; \ - \ - /* Release thread-safety semaphore */ \ - FUNC_LEAVE_API_THREADSAFE - -/* Use this macro when leaving all functions */ -#define END_FUNC(scope) \ - /* Scope-specific function conclusion */ \ - H5_GLUE(FUNC_LEAVE_, scope) \ - \ - /* Leave routine */ \ - return (ret_value); \ - \ - /* Close Function */ \ - } - -/* Use this macro when leaving void functions */ -#define END_FUNC_VOID(scope) \ - /* Scope-specific function conclusion */ \ - H5_GLUE(FUNC_LEAVE_, scope) \ - \ - /* Leave routine */ \ - return; \ - \ - /* Close Function */ \ - } +#endif /* Macro to begin/end tagging (when FUNC_ENTER_*TAG macros are insufficient). * Make sure to use HGOTO_ERROR_TAG and HGOTO_DONE_TAG between these macros! */ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 09ee97bd122..ecfef575f5c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -285,6 +285,7 @@ set (H5_TESTS swmr thread_id # special link timer + cmpd_dtransform version_bounds_1_10 ) diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 1461648e75f..4cf11f5b3b1 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -919,7 +919,7 @@ if (BUILD_SHARED_LIBS) ############################################################################## endif () -option (TEST_SHELL_SCRIPTS "Enable shell script tests" OFF) +option (TEST_SHELL_SCRIPTS "Enable shell script tests" ON) if (TEST_SHELL_SCRIPTS) include (ShellTests.cmake) endif() diff --git a/test/Makefile.am b/test/Makefile.am index d78cbe38e1e..b67792764f9 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -60,7 +60,7 @@ TEST_PROG= testhdf5 \ cache cache_api cache_image cache_tagging lheap ohdr \ stab gheap evict_on_close farray earray btree2 fheap \ pool accum hyperslab istore bittests dt_arith page_buffer \ - dtypes dsets chunk_info cmpd_dset filter_fail extend direct_chunk \ + dtypes dsets chunk_info cmpd_dset cmpd_dtransform filter_fail extend direct_chunk \ external efc objcopy links unlink twriteorder big mtime fillval mount \ flush1 flush2 app_ref enum set_extent ttsafe enc_dec_plist \ enc_dec_plist_cross_platform getname vfd ros3 s3comms hdfs ntypes \ diff --git a/test/ShellTests.cmake b/test/ShellTests.cmake index b28bbd60717..812121e453a 100644 --- a/test/ShellTests.cmake +++ b/test/ShellTests.cmake @@ -17,7 +17,7 @@ if (UNIX) - find_program (SH_PROGRAM sh) + find_program (SH_PROGRAM bash) if (SH_PROGRAM) ############################################################################## diff --git a/test/cmpd_dtransform.c b/test/cmpd_dtransform.c new file mode 100644 index 00000000000..ef5ad750285 --- /dev/null +++ b/test/cmpd_dtransform.c @@ -0,0 +1,136 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Jan-Willem Blokland + * December 1, 2020 + * + * Purpose: Test writing compounded attribute followed by + * writing data with a data transform function. + */ + +#include "h5test.h" + +#define FILENAME "cmpd_dtransform.h5" +#define LENGTH 11 + +typedef struct { + char name[64]; + char unit[64]; +} att_t; + +int +main(void) +{ + hsize_t dima[] = {1}; + hsize_t dims[] = {LENGTH}; + hid_t str_dtyp_id, att_dtyp_id, file_id, fspace_id, dset_id, att_dspc_id, att_attr_id, dxpl_id; + + /* Compound datatype */ + att_t *atts = HDmalloc(sizeof(att_t)); + HDstrcpy(atts[0].name, "Name"); + HDstrcpy(atts[0].unit, "Unit"); + + /* String type */ + if ((str_dtyp_id = H5Tcopy(H5T_C_S1)) < 0) + TEST_ERROR; + H5Tset_size(str_dtyp_id, 64); + + /* Attribute type */ + if ((att_dtyp_id = H5Tcreate(H5T_COMPOUND, sizeof(att_t))) < 0) + TEST_ERROR; + H5Tinsert(att_dtyp_id, "NAME", HOFFSET(att_t, name), str_dtyp_id); + H5Tinsert(att_dtyp_id, "UNIT", HOFFSET(att_t, unit), str_dtyp_id); + + /* Create file. */ + if ((file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Create file dataspace. */ + if ((fspace_id = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR; + + /* Create dataset. */ + if ((dset_id = H5Dcreate2(file_id, "test_dset", H5T_NATIVE_INT, fspace_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Write the attribute (compound) to the dataset */ + if ((att_dspc_id = H5Screate_simple(1, dima, NULL)) < 0) + TEST_ERROR; + if ((att_attr_id = + H5Acreate2(dset_id, "ATTRIBUTES", att_dtyp_id, att_dspc_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Awrite(att_attr_id, att_dtyp_id, atts) < 0) + TEST_ERROR; + + /* Create dataset transfer property list */ + const char *expr = "2*x"; + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR; + if (H5Pset_data_transform(dxpl_id, expr) < 0) { + HDprintf("**** ERROR: H5Pset_data_transform (expression: %s) ****\n", expr); + TEST_ERROR; + } + + int *data = HDmalloc(LENGTH * sizeof(int)); + int *data_res = HDmalloc(LENGTH * sizeof(int)); + for (unsigned i = 0; i < LENGTH; i++) { + data[i] = 10; + data_res[i] = 2 * data[i]; + } + + /* Write the data */ + if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, data) < 0) + TEST_ERROR; + + /* Read attribute */ + att_t *atts_res = HDmalloc(sizeof(att_t)); + if (H5Aread(att_attr_id, att_dtyp_id, atts_res) < 0) + TEST_ERROR; + + /* Verify attribute */ + if (HDstrcmp(atts_res[0].name, atts[0].name) != 0) + TEST_ERROR; + if (HDstrcmp(atts_res[0].unit, atts[0].unit) != 0) + TEST_ERROR; + + /* Read the data */ + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + TEST_ERROR; + + /* Verify data */ + for (unsigned idx = 0; idx < LENGTH; idx++) { + if (data[idx] != data_res[idx]) + TEST_ERROR; + } + + HDfree(atts); + HDfree(atts_res); + HDfree(data); + HDfree(data_res); + + /* Close all identifiers. */ + H5Pclose(dxpl_id); + H5Aclose(att_attr_id); + H5Sclose(att_dspc_id); + H5Dclose(dset_id); + H5Sclose(fspace_id); + H5Fclose(file_id); + H5Tclose(att_dtyp_id); + H5Tclose(str_dtyp_id); + + return 0; + +error: + return 1; +} diff --git a/test/dtransform.c b/test/dtransform.c index c679d30a74b..9445d83eb17 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -581,6 +581,7 @@ test_specials(hid_t file) const char *special3 = "1000/x"; const char *special4 = "-x"; const char *special5 = "+x"; + const char *special6 = "2e+1*x"; TESTING("data transform of some special cases") @@ -702,6 +703,29 @@ test_specials(hid_t file) COMPARE_INT(read_buf, data_res) + if (H5Dclose(dset_id) < 0) + TEST_ERROR + + /*----------------------------- + * Operation 6: 2e+1*x + *----------------------------*/ + if (H5Pset_data_transform(dxpl_id, special6) < 0) + TEST_ERROR; + + for (row = 0; row < ROWS; row++) + for (col = 0; col < COLS; col++) + data_res[row][col] = transformData[row][col] * 20; + + if ((dset_id = H5Dcreate2(file, "/special6", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, transformData) < 0) + TEST_ERROR + if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) < 0) + TEST_ERROR + + COMPARE_INT(read_buf, data_res) + if (H5Dclose(dset_id) < 0) TEST_ERROR diff --git a/test/err_compat.c b/test/err_compat.c index 53c866784a5..6ad69d8161d 100644 --- a/test/err_compat.c +++ b/test/err_compat.c @@ -39,7 +39,6 @@ int * ipoints2_data = NULL; int * icheck2_data = NULL; #define DSET_NAME "a_dataset" -#define FAKE_ID (hid_t) - 1 herr_t custom_print_cb1(int n, H5E_error1_t *err_desc, void *client_data); herr_t custom_print_cb2(int n, H5E_error2_t *err_desc, void *client_data); @@ -47,13 +46,13 @@ herr_t custom_print_cb2(int n, H5E_error2_t *err_desc, void *client_data); /*------------------------------------------------------------------------- * Function: user_print1 * - * Purpose: This function is a user-defined old-style printing function. + * Purpose: This function is a user-defined old-style printing function. * This is just a convenience function for H5Ewalk1() with a * function that prints error messages. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * 4 October 2010 * *------------------------------------------------------------------------- @@ -66,22 +65,22 @@ user_print1(FILE *stream) if (H5Ewalk1(H5E_WALK_UPWARD, (H5E_walk1_t)custom_print_cb1, stream) < 0) TEST_ERROR; - return 0; + return SUCCEED; error: - return -1; + return FAIL; } /*------------------------------------------------------------------------- * Function: user_print2 * - * Purpose: This function is a user-defined new-style printing function. + * Purpose: This function is a user-defined new-style printing function. * This is just a convenience function for H5Ewalk2() with a * function that prints error messages. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * 4 October 2010 * *------------------------------------------------------------------------- @@ -94,27 +93,23 @@ user_print2(hid_t err_stack, FILE *stream) if (H5Ewalk2(err_stack, H5E_WALK_UPWARD, (H5E_walk2_t)custom_print_cb2, stream) < 0) TEST_ERROR; - return 0; + return SUCCEED; error: - return -1; + return FAIL; } /*------------------------------------------------------------------------- * Function: custom_print_cb1 * - * Purpose: Callback function to print error stack in customized way - * for H5Ewalk1. + * Purpose: Callback function to print error stack in customized way + * for H5Ewalk1 * - * Return: Success: 0 + * Return: SUCCEED/FAIL * - * Failure: -1 - * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * 4 October 2010 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -140,7 +135,7 @@ custom_print_cb1(int n, H5E_error1_t *err_desc, void *client_data) H5free_memory(maj); H5free_memory(min); - return 0; + return SUCCEED; error: if (maj) @@ -148,24 +143,20 @@ custom_print_cb1(int n, H5E_error1_t *err_desc, void *client_data) if (min) H5free_memory(min); - return -1; + return FAIL; } /*------------------------------------------------------------------------- * Function: custom_print_cb2 * - * Purpose: Callback function to print error stack in customized way - * for H5Ewalk1. - * - * Return: Success: 0 + * Purpose: Callback function to print error stack in customized way + * for H5Ewalk1 * - * Failure: -1 + * Return: SUCCEED/FAIL * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * 4 October 2010 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -191,7 +182,7 @@ custom_print_cb2(int n, H5E_error2_t *err_desc, void *client_data) H5free_memory(maj); H5free_memory(min); - return 0; + return SUCCEED; error: if (maj) @@ -199,62 +190,59 @@ custom_print_cb2(int n, H5E_error2_t *err_desc, void *client_data) if (min) H5free_memory(min); - return -1; + return FAIL; } /*------------------------------------------------------------------------- - * Function: test_error1 - * - * Purpose: Test the backward compatibility of H5Eset/get_auto. - * - * Return: Success: 0 + * Function: test_error_compat * - * Failure: -1 - * - * Programmer: Raymond Lu - * 17 September 2010 + * Purpose: Test the backward compatibility of H5Eset/get_auto * + * Return: SUCCEED/FAIL * - * Modifications: + * Programmer: Raymond Lu + * 17 September 2010 * *------------------------------------------------------------------------- */ static herr_t -test_error1(void) +test_error_compat(void) { - hid_t dataset, space; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; hsize_t dims[2]; H5E_auto1_t old_func1; H5E_auto2_t old_func2; - void * old_data; + void * old_data = NULL; herr_t ret; TESTING("error API H5Eset/get_auto"); - HDfprintf(stderr, "\n"); - /* Create the data space */ + /* Add a newline and flush so the output file looks nicer */ + HDprintf("\n"); + HDfflush(stdout); + + /* Create the dataspace */ dims[0] = DIM0; dims[1] = DIM1; - if ((space = H5Screate_simple(2, dims, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; - /* Use H5Eget_auto2 to query the default printing function. The library - *should indicate H5Eprint2 as the default. */ + /* Use H5Eget_auto2 to query the default printing function. */ if (H5Eget_auto2(H5E_DEFAULT, &old_func2, &old_data) < 0) TEST_ERROR; if (old_data != NULL) TEST_ERROR; - if (!old_func2 || (H5E_auto2_t)H5Eprint2 != old_func2) + if (old_func2 == NULL) TEST_ERROR; - /* This function sets the default printing function to be H5Eprint2. */ if (H5Eset_auto2(H5E_DEFAULT, old_func2, old_data) < 0) TEST_ERROR; /* Try the printing function. Dataset creation should fail because the file * doesn't exist. */ - dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (dataset >= 0) + did = H5Dcreate2(H5I_INVALID_HID, DSET_NAME, H5T_STD_I32BE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (did >= 0) TEST_ERROR; /* This call should work. It simply returns H5Eprint1. */ @@ -271,8 +259,8 @@ test_error1(void) /* Try the printing function. Dataset creation should fail because the file * doesn't exist. */ - dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (dataset >= 0) + did = H5Dcreate2(H5I_INVALID_HID, DSET_NAME, H5T_STD_I32BE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (did >= 0) TEST_ERROR; /* This call should fail because the test mixes H5Eget_auto2 with H5Eset_auto1. @@ -288,16 +276,16 @@ test_error1(void) /* Try the printing function. Dataset creation should fail because the file * doesn't exist. */ - dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (dataset >= 0) + did = H5Dcreate2(H5I_INVALID_HID, DSET_NAME, H5T_STD_I32BE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (did >= 0) TEST_ERROR; - /* This function changes the new-style printing function back to the default H5Eprint2. */ - if (H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)H5Eprint2, NULL) < 0) + /* This function changes the new-style printing function to the original. */ + if (H5Eset_auto2(H5E_DEFAULT, old_func2, NULL) < 0) TEST_ERROR; - /* This call should work because the H5Eset_auto2 above restored the default printing - * function H5Eprint2. It simply returns user_print1. */ + /* This call should work because the H5Eset_auto2 above set the default printing + * function to H5Eprint2. It simply returns user_print1. */ if ((ret = H5Eget_auto1(&old_func1, &old_data)) < 0) TEST_ERROR; if (old_data != NULL) @@ -315,69 +303,77 @@ test_error1(void) TEST_ERROR; if (old_data != NULL) TEST_ERROR; - if (!old_func2 || (H5E_auto2_t)H5Eprint2 != old_func2) + if (old_func2 == NULL) TEST_ERROR; /* Try the printing function. Dataset creation should fail because the file * doesn't exist. */ - dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (dataset >= 0) + did = H5Dcreate2(H5I_INVALID_HID, DSET_NAME, H5T_STD_I32BE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (did >= 0) TEST_ERROR; - return 0; + if (H5Sclose(sid) < 0) + TEST_ERROR; + + return SUCCEED; error: - return -1; + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Sclose(sid); + } + H5E_END_TRY + + return FAIL; } /*------------------------------------------------------------------------- - * Function: test_error2 - * - * Purpose: Test error API functions, mainly on H5Epush1. + * Function: test_h5epush1 * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Raymond Lu - * July 10, 2003 + * Purpose: Test error API functions, mainly H5Epush1 * + * Return: SUCCEED/FAIL * - * Modifications: + * Programmer: Raymond Lu + * July 10, 2003 * *------------------------------------------------------------------------- */ static herr_t -test_error2(hid_t file) +test_h5epush1(hid_t file) { - hid_t dataset, space; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t estack_id = H5I_INVALID_HID; hsize_t dims[2]; - const char *FUNC_test_error = "test_error2"; + const char *FUNC_test_error = "test_h5epush1"; TESTING("error API based on data I/O"); - HDfprintf(stderr, "\n"); - /* Create the data space */ + /* Add a newline and flush so the output file looks nicer */ + HDprintf("\n"); + HDfflush(stdout); + + /* Create the dataspace */ dims[0] = DIM0; dims[1] = DIM1; - if ((space = H5Screate_simple(2, dims, NULL)) < 0) + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; /* Test H5E_BEGIN_TRY */ H5E_BEGIN_TRY { - dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + did = + H5Dcreate2(H5I_INVALID_HID, DSET_NAME, H5T_STD_I32BE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY; /* Create the dataset */ - if ((dataset = H5Dcreate2(file, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < - 0) { - H5Epush1(__FILE__, FUNC_test_error, __LINE__, H5E_ERROR, H5E_CANTCREATE, "H5Dcreate2 failed"); - goto error; - } + if ((did = H5Dcreate2(file, DSET_NAME, H5T_STD_I32BE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; - /* Disable the library's default printing function */ + /* Disable the library's default printing function */ #ifdef H5_USE_16_API_DEFAULT if (H5Eset_auto(NULL, NULL) < 0) #else @@ -386,36 +382,48 @@ test_error2(hid_t file) TEST_ERROR; /* Make H5Dwrite fail, verify default print is disabled */ - if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) < 0) { - H5Epush1(__FILE__, FUNC_test_error, __LINE__, H5E_ERROR, H5E_WRITEERROR, - "H5Dwrite shouldn't succeed"); - goto error; - } + if (H5Dwrite(H5I_INVALID_HID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) < 0) + H5Epush1(__FILE__, FUNC_test_error, __LINE__, H5E_ERROR, H5E_WRITEERROR, "expected H5Dwrite error"); + else + TEST_ERROR; + + /* Save the error stack so the close calls don't interfere with it */ + if ((estack_id = H5Eget_current_stack()) < 0) + TEST_ERROR; - /* In case program comes to this point, close dataset */ - if (H5Dclose(dataset) < 0) + /* Close open identifiers */ + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Sclose(sid) < 0) + TEST_ERROR; + + /* Restore the stack containing errors */ + if (H5Eset_current_stack(estack_id) < 0) TEST_ERROR; - TEST_ERROR; + return SUCCEED; error: - return -1; + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Sclose(sid); + H5Eclose_stack(estack_id); + } + H5E_END_TRY + + return FAIL; } /*------------------------------------------------------------------------- * Function: dump_error * - * Purpose: Prints error stack in default and customized ways. + * Purpose: Prints error stack in default and customized ways * - * Return: Success: 0 + * Return: SUCCEED/FAIL * - * Failure: -1 - * - * Programmer: Raymond Lu - * July 17, 2003 - * - * - * Modifications: + * Programmer: Raymond Lu + * July 17, 2003 * *------------------------------------------------------------------------- */ @@ -432,35 +440,34 @@ dump_error(void) if (H5Ewalk1(H5E_WALK_UPWARD, custom_print_cb1, stderr) < 0) TEST_ERROR; - return 0; + return SUCCEED; error: - return -1; + return FAIL; } /*------------------------------------------------------------------------- * Function: main * - * Purpose: Test error API. - * - * Programmer: Raymond Lu - * July 10, 2003 + * Purpose: Test error API * - * Modifications: + * Programmer: Raymond Lu + * July 10, 2003 * *------------------------------------------------------------------------- */ int main(void) { - hid_t file, fapl; + hid_t fid = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; char filename[1024]; const char *FUNC_main = "main"; int i; HDfprintf(stderr, " This program tests the Error API compatible with HDF5 v1.6. There are supposed to " "be some error messages\n"); - fapl = h5_fileaccess(); + fapl_id = h5_fileaccess(); /* Set up data arrays */ if (NULL == (ipoints2_data = (int *)HDcalloc(DIM0 * DIM1, sizeof(int)))) @@ -477,14 +484,14 @@ main(void) for (i = 0; i < DIM0; i++) icheck2[i] = icheck2_data + (i * DIM1); - h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename)); + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR; /* Test error stack */ /* Push an error onto error stack */ - H5Epush1(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADVALUE, "Error test failed"); + H5Epush1(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADVALUE, "fake error message 1"); /* Print out the errors on stack */ dump_error(); @@ -493,17 +500,24 @@ main(void) H5Eclear1(); /* Test error API */ - if (test_error1() < 0) + if (test_error_compat() < 0) TEST_ERROR; - if (test_error2(file) < 0) { - H5Epush1(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADMESG, "Error test failed"); + /* Test H5Epush1 + * + * On success, there will be errors on the stack to print. + */ + if (test_h5epush1(fid) < 0) { + TEST_ERROR; + } + else { + H5Epush1(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADMESG, "fake error message 2"); H5Eprint1(stderr); } - if (H5Fclose(file) < 0) + if (H5Fclose(fid) < 0) TEST_ERROR; - h5_clean_files(FILENAME, fapl); + h5_clean_files(FILENAME, fapl_id); HDfree(ipoints2); HDfree(ipoints2_data); @@ -511,7 +525,7 @@ main(void) HDfree(icheck2_data); HDprintf("All error API tests passed.\n"); - return 0; + return EXIT_SUCCESS; error: HDfree(ipoints2); @@ -519,7 +533,14 @@ main(void) HDfree(icheck2); HDfree(icheck2_data); + H5E_BEGIN_TRY + { + H5Fclose(fid); + H5Pclose(fapl_id); + } + H5E_END_TRY + HDprintf("***** ERROR TEST FAILED! *****\n"); - return 1; + return EXIT_FAILURE; } #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/test/error_test.c b/test/error_test.c index c8205ff817c..f47031832c9 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -129,7 +129,7 @@ test_error(hid_t file) TEST_ERROR; if (old_data != NULL) TEST_ERROR; - if (old_func != (H5E_auto2_t)H5Eprint2) + if (old_func == NULL) TEST_ERROR; if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) diff --git a/test/testfiles/err_compat_1 b/test/testfiles/err_compat_1 index d81dba1ea16..4c32d430419 100644 --- a/test/testfiles/err_compat_1 +++ b/test/testfiles/err_compat_1 @@ -1,8 +1,10 @@ -Testing error API H5Eset/get_auto Testing error API based on data I/O All error API tests passed. +Testing error API H5Eset/get_auto +Testing error API based on data I/O +All error API tests passed. This program tests the Error API compatible with HDF5 version (number). There are supposed to be some error messages ********* Print error stack in HDF5 default way ********* HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in main(): Error test failed + #000: (file name) line (number) in main(): fake error message 1 major: Error API minor: Bad value @@ -10,7 +12,6 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): error #000: (file name) in main(): line (number) major: Error API minor: Bad value - HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Dcreate2(): not a location ID major: Invalid arguments to routine @@ -46,12 +47,11 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #001: (file name) line (number) in H5G_loc(): invalid location ID major: Invalid arguments to routine minor: Bad value - HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in main(): Error test failed + #000: (file name) line (number) in main(): fake error message 2 major: Error API minor: Unrecognized message - #001: (file name) line (number) in test_error2(): H5Dwrite shouldn't succeed + #001: (file name) line (number) in test_h5epush1(): expected H5Dwrite error major: Error API minor: Write failed #002: (file name) line (number) in H5Dwrite(): dset_id is not a dataset ID diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h index 8fd33bb2340..5840a9896bc 100644 --- a/tools/lib/h5tools_error.h +++ b/tools/lib/h5tools_error.h @@ -220,22 +220,22 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_dbg_id_g; /* Macro for "catching" flow of control when an error occurs. Note that the * H5_LEAVE macro won't jump back here once it's past this point. */ -/* #define CATCH catch_except:; past_catch = TRUE; defined in H5Eprivate.h */ +#define CATCH \ +catch_except:; \ + past_catch = TRUE; /* - * H5_LEAVE macro, used to facilitate control flow between a - * BEGIN_FUNC() and an END_FUNC() within a function body. The argument is - * the return value. - * The return value is assigned to a variable `ret_value' and control branches - * to the `catch_except' label, if we're not already past it. + * H5_LEAVE macro, used to facilitate control flow in a function. The argument + * is the return value. The return value is assigned to a variable `ret_value' + * and control branches to the `catch_except' label, if we're not already past + * it. */ -/* - * #define H5_LEAVE(v) { \ - * ret_value = v; \ - * if(!past_catch) \ - * goto catch_except; \ - * } - * defined in H5Eprivate.h */ +#define H5_LEAVE(v) \ + { \ + ret_value = v; \ + if (!past_catch) \ + goto catch_except; \ + } /* * H5TOOLS_THROW macro, used to facilitate error reporting within a function body. diff --git a/tools/test/h5jam/h5jamgentest.c b/tools/test/h5jam/h5jamgentest.c index 45ff0b027ba..1da6b630ca6 100644 --- a/tools/test/h5jam/h5jamgentest.c +++ b/tools/test/h5jam/h5jamgentest.c @@ -277,7 +277,7 @@ gent_ub(const char *filename, size_t ub_size, size_t ub_fill) for (u = 0; u < ub_fill; u++) *bp++ = pattern[u % 10]; - HDwrite(fd, buf, ub_size); + (void)HDwrite(fd, buf, ub_size); HDclose(fd); } @@ -301,7 +301,7 @@ create_textfile(const char *name, size_t size) for (i = 0; i < size; i++) *bp++ = pattern[i % 10]; - HDwrite(fd, buf, size); + (void)HDwrite(fd, buf, size); HDfree(buf); @@ -329,7 +329,7 @@ create_binfile(char *name, off_t size) for (i = 0; i < size; i++) *bp++ = (char)i & 0xff; - HDwrite(fd, buf, size); + (void)HDwrite(fd, buf, size); HDclose(fd); } diff --git a/tools/test/h5stat/h5stat_gentest.c b/tools/test/h5stat/h5stat_gentest.c index b55cd0649a0..a9813e7eb2e 100644 --- a/tools/test/h5stat/h5stat_gentest.c +++ b/tools/test/h5stat/h5stat_gentest.c @@ -497,7 +497,7 @@ gen_err_refcount(const char *fname) attribute message */ if ((fd = HDopen(fname, O_RDWR, 0633)) >= 0) { HDlseek(fd, 4520 + 24, SEEK_SET); - HDwrite(fd, &val, 2); + (void)HDwrite(fd, &val, 2); HDclose(fd); } From 628fcaed0f4d2a9fcf906c7667c687935042e664 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Wed, 21 Jul 2021 15:13:37 -0500 Subject: [PATCH 12/13] Revert references to SIZE_MAX to ((size_t)(-1)) in C header defines used by c++ code that fail on centos7 when -std=c++11 is not set. --- src/H5Dpublic.h | 4 ++-- src/H5Tpublic.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 16abaead126..b708422b939 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -28,8 +28,8 @@ /*****************/ /* Macros used to "unset" chunk cache configuration parameters */ -#define H5D_CHUNK_CACHE_NSLOTS_DEFAULT SIZE_MAX -#define H5D_CHUNK_CACHE_NBYTES_DEFAULT SIZE_MAX +#define H5D_CHUNK_CACHE_NSLOTS_DEFAULT ((size_t)-1) +#define H5D_CHUNK_CACHE_NBYTES_DEFAULT ((size_t)-1) #define H5D_CHUNK_CACHE_W0_DEFAULT (-1.0) /* Bit flags for the H5Pset_chunk_opts() and H5Pget_chunk_opts() */ diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 3b757faaf4a..b18a107acef 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -245,7 +245,7 @@ typedef struct { * Indicate that a string is variable length (null-terminated in C, instead of * fixed length) */ -#define H5T_VARIABLE SIZE_MAX +#define H5T_VARIABLE ((size_t)-1) /* Opaque information */ /** From 1d152aa08f3392b3649bb79cce43fa9435e508aa Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Wed, 18 Aug 2021 10:00:52 -0500 Subject: [PATCH 13/13] Fix issue #924, ${HDF5_CXXLINKER} does not work in h5c++. 2 instances of CLINKER corrected to CXXLINKER comment border aligned --- c++/src/h5c++.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/c++/src/h5c++.in b/c++/src/h5c++.in index cf993b98755..573d20d55ce 100644 --- a/c++/src/h5c++.in +++ b/c++/src/h5c++.in @@ -35,10 +35,10 @@ HL="@HL@" ## (Advanced usage - know what you're doing - you're on your own here.) ## ## The four variables below can be used to insert paths and flags in ## ## CPPFLAGS, CXXFLAGS, LDFLAGS, or LIBS in the h5cc compile line: ## -## $CLINKER $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CXXFLAGS $CXXFLAGS ## +## $CXXLINKER $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CXXFLAGS $CXXFLAGS ## ## $LDFLAGS $LIBS $clibpath $link_objs $link_args $shared_link ## ## ## -## These settings can be overridden by setting HDF5_CXXFLAGS, ## +## These settings can be overridden by setting HDF5_CXXFLAGS, ## ## HDF5_CPPFLAGS, HDF5_LDFLAGS, or HDF5_LIBS in the environment. ## ## ## ############################################################################ @@ -93,7 +93,7 @@ H5BLD_LDFLAGS="@AM_LDFLAGS@ @LDFLAGS@" H5BLD_LIBS="@LIBS@" CXX="${HDF5_CXX:-$CXXBASE}" -CXXLINKER="${HDF5_CLINKER:-$CXXLINKERBASE}" +CXXLINKER="${HDF5_CXXLINKER:-$CXXLINKERBASE}" CXXFLAGS="${HDF5_CXXFLAGS:-$CXXFLAGSBASE}" CPPFLAGS="${HDF5_CPPFLAGS:-$CPPFLAGSBASE}" LDFLAGS="${HDF5_LDFLAGS:-$LDFLAGSBASE}"