Skip to content

Commit

Permalink
Remove API routine calls from within the library
Browse files Browse the repository at this point in the history
Also fix the H5TS package init

Signed-off-by: Quincey Koziol <[email protected]>
  • Loading branch information
qkoziol committed Oct 26, 2024
1 parent 94b1b77 commit 4426f03
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 128 deletions.
6 changes: 3 additions & 3 deletions src/H5.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ H5_term_library(void)
H5CX_push(&api_ctx);

/* Check if we should display error output */
(void)H5Eget_auto2(H5E_DEFAULT, &func, NULL);
(void)H5E_get_default_auto_func(&func);

/* Iterate over the list of 'atclose' callbacks that have been registered */
if (H5_atclose_head) {
Expand Down Expand Up @@ -1063,11 +1063,11 @@ H5close(void)
* whole library just to release it all right away. It is safe to call
* this function for an uninitialized library.
*/
FUNC_ENTER_API_NOINIT_NOERR
FUNC_ENTER_API_NAMECHECK_ONLY

H5_term_library();

FUNC_LEAVE_API_NOERR(SUCCEED)
FUNC_LEAVE_API_NAMECHECK_ONLY(SUCCEED)
} /* end H5close() */

/*-------------------------------------------------------------------------
Expand Down
34 changes: 34 additions & 0 deletions src/H5Eint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,40 @@ H5E__get_auto(const H5E_stack_t *estack, H5E_auto_op_t *op, void **client_data)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5E__get_auto() */

/*-------------------------------------------------------------------------
* Function: H5E_get_default_auto_func
*
* Purpose: Private function to retrieve the default error stack's
* reporting function.
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5E_get_default_auto_func(H5E_auto2_t *func)
{
H5E_stack_t *estack; /* Error stack to operate on */
H5E_auto_op_t op; /* Error stack function */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_NOAPI(FAIL)

/* Retrieve default error stack */
if (NULL == (estack = H5E__get_my_stack()))
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack");

/* Get the automatic error reporting information */
if (H5E__get_auto(estack, &op, NULL) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info");

/* Retrieve error output function */
*func = op.func2;

done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5E_get_default_auto_func() */

/*-------------------------------------------------------------------------
* Function: H5E__set_auto
*
Expand Down
1 change: 1 addition & 0 deletions src/H5Eprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ typedef struct H5E_user_cb_state_t {
/* Library Private Prototypes */
/******************************/
H5_DLL herr_t H5E_init(void);
H5_DLL herr_t H5E_get_default_auto_func(H5E_auto2_t *func);
H5_DLL herr_t H5E_printf_stack(const char *file, const char *func, unsigned line, hid_t maj_idx,
hid_t min_idx, const char *fmt, ...) H5_ATTR_FORMAT(printf, 6, 7);
H5_DLL herr_t H5E_clear_stack(void);
Expand Down
120 changes: 55 additions & 65 deletions src/H5Odeprec.c

Large diffs are not rendered by default.

65 changes: 52 additions & 13 deletions src/H5Pdeprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
/********************/
/* Local Prototypes */
/********************/
static herr_t H5P__get_file_space(H5P_genplist_t *plist, H5F_file_space_type_t *strategy, hsize_t *threshold);

/*********************/
/* Package Variables */
Expand Down Expand Up @@ -514,16 +515,17 @@ H5Pencode1(hid_t plist_id, void *buf, size_t *nalloc)
/*-------------------------------------------------------------------------
* Function: H5Pset_file_space
*
* Purpose: It is mapped to H5Pset_file_space_strategy().
* Purpose: Mapped to H5Pset_file_space_strategy().
*
* Return: Non-negative on success/Negative on failure
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t threshold)
{
H5P_genplist_t *plist; /* Property list pointer */
H5F_fspace_strategy_t new_strategy; /* File space strategy type */
bool new_persist = H5F_FREE_SPACE_PERSIST_DEF; /* Persisting free-space or not */
hsize_t new_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; /* Free-space section threshold */
Expand All @@ -533,8 +535,14 @@ H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t thresh
FUNC_ENTER_API(FAIL)
/* Check args */
if ((unsigned)in_strategy >= H5F_FILE_SPACE_NTYPES)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid strategy");
/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE)))
HGOTO_ERROR(H5E_PLIST, H5E_BADID, FAIL, "can't find object for ID");

/*
* For 1.10.0 H5Pset_file_space:
* If strategy is zero, the property is not changed;
Expand All @@ -543,9 +551,11 @@ H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t thresh
* the existing threshold is retained.
*/
if (!in_strategy)
H5Pget_file_space(plist_id, &in_strategy, NULL);
if (H5P__get_file_space(plist, &in_strategy, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy");
if (!in_threshold)
H5Pget_file_space(plist_id, NULL, &in_threshold);
if (H5P__get_file_space(plist, NULL, &in_threshold) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space threshold");

switch (in_strategy) {
case H5F_FILE_SPACE_ALL_PERSIST:
Expand Down Expand Up @@ -573,35 +583,35 @@ H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t thresh
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file space strategy");
}

if (H5Pset_file_space_strategy(plist_id, new_strategy, new_persist, new_threshold) < 0)
if (H5P__set_file_space_strategy(plist, new_strategy, new_persist, new_threshold) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file space strategy");

done:
FUNC_LEAVE_API(ret_value)
} /* H5Pset_file_space() */

/*-------------------------------------------------------------------------
* Function: H5Pget_file_space
* Function: H5P__get_file_space
*
* Purpose: It is mapped to H5Pget_file_space_strategy().
* Purpose: Mapped to H5Pget_file_space_strategy().
*
* Return: Non-negative on success/Negative on failure
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy /*out*/, hsize_t *threshold /*out*/)
static herr_t
H5P__get_file_space(H5P_genplist_t *plist, H5F_file_space_type_t *strategy, hsize_t *threshold)
{
H5F_fspace_strategy_t new_strategy; /* File space strategy type */
bool new_persist; /* Persisting free-space or not */
hsize_t new_threshold; /* Free-space section threshold */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
FUNC_ENTER_PACKAGE

/* Get current file space info */
if (H5Pget_file_space_strategy(plist_id, &new_strategy, &new_persist, &new_threshold) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy");
if (H5P__get_file_space_strategy(plist, &new_strategy, &new_persist, &new_threshold) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy values");

/* Get value(s) */
if (strategy) {
Expand Down Expand Up @@ -632,6 +642,35 @@ H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy /*out*/, hsize
if (threshold)
*threshold = new_threshold;

done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5P__get_file_space() */

/*-------------------------------------------------------------------------
* Function: H5Pget_file_space
*
* Purpose: It is mapped to H5Pget_file_space_strategy().
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy /*out*/, hsize_t *threshold /*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)

/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE)))
HGOTO_ERROR(H5E_PLIST, H5E_BADID, FAIL, "can't find object for ID");

/* Get current file space info */
if (H5P__get_file_space(plist, strategy, threshold) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy");

done:
FUNC_LEAVE_API(ret_value)
} /* H5Pget_file_space() */
Expand Down
97 changes: 74 additions & 23 deletions src/H5Pfcpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,32 +1165,20 @@ H5Pget_shared_mesg_phase_change(hid_t plist_id, unsigned *max_list /*out*/, unsi
} /* end H5Pget_shared_mesg_phase_change() */

/*-------------------------------------------------------------------------
* Function: H5Pset_file_space_strategy
* Function: H5P__set_file_space_strategy
*
* Purpose: Sets the "strategy" that the library employs in managing file space
* Sets the "persist" value as to persist free-space or not
* Sets the "threshold" value that the free space manager(s) will use to track free space
*sections. Ignore "persist" and "threshold" for strategies that do not use free-space managers
* Purpose: Internal routine to set file space strategy properties.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold)
H5P__set_file_space_strategy(H5P_genplist_t *plist, H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)

/* Check arguments */
if (strategy >= H5F_FSPACE_STRATEGY_NTYPES)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid strategy");

/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
FUNC_ENTER_PACKAGE

/* Set value(s), if non-zero */
if (H5P_set(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &strategy) < 0)
Expand All @@ -1206,32 +1194,64 @@ H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool
} /* end if */

done:
FUNC_LEAVE_API(ret_value)
} /* H5Pset_file_space_strategy() */
FUNC_LEAVE_NOAPI(ret_value)
} /* H5P__set_file_space_strategy() */

/*-------------------------------------------------------------------------
* Function: H5Pget_file_space_strategy
* Function: H5Pset_file_space_strategy
*
* Purpose: Retrieves the strategy, persist, and threshold that the library
* uses in managing file space.
* Purpose: Sets the "strategy" that the library employs in managing file space
* Sets the "persist" value as to persist free-space or not
* Sets the "threshold" value that the free space manager(s) will
* use to track free space sections. Ignore "persist" and
* "threshold" for strategies that do not use free-space managers.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy /*out*/, hbool_t *persist /*out*/,
hsize_t *threshold /*out*/)
H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)

/* Check arguments */
if (strategy >= H5F_FSPACE_STRATEGY_NTYPES)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid strategy");

/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");

/* Set value(s) */
if (H5P__set_file_space_strategy(plist, strategy, persist, threshold) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file space strategy values");

done:
FUNC_LEAVE_API(ret_value)
} /* H5Pset_file_space_strategy() */

/*-------------------------------------------------------------------------
* Function: H5P__get_file_space_strategy
*
* Purpose: Retrieves the strategy, persist, and threshold that the library
* uses in managing file space.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5P__get_file_space_strategy(H5P_genplist_t *plist, H5F_fspace_strategy_t *strategy /*out*/, hbool_t *persist /*out*/,
hsize_t *threshold /*out*/)
{
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_PACKAGE

/* Get value(s) */
if (strategy)
if (H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, strategy) < 0)
Expand All @@ -1243,6 +1263,37 @@ H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy /*out
if (H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, threshold) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space threshold");

done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5P__get_file_space_strategy() */

/*-------------------------------------------------------------------------
* Function: H5Pget_file_space_strategy
*
* Purpose: Retrieves the strategy, persist, and threshold that the library
* uses in managing file space.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy /*out*/, hbool_t *persist /*out*/,
hsize_t *threshold /*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)

/* Get the plist structure */
if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE)))
HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");

/* Get value(s) */
if (H5P__get_file_space_strategy(plist, strategy, persist, threshold) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy values");

done:
FUNC_LEAVE_API(ret_value)
} /* H5Pget_file_space_strategy() */
Expand Down
4 changes: 4 additions & 0 deletions src/H5Ppkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ H5_DLL herr_t H5P__decode_coll_md_read_flag_t(const void **_pp, void *value);
/* Private FAPL routines */
H5_DLL herr_t H5P__facc_set_def_driver(void);

/* Private FCPL routines */
H5_DLL herr_t H5P__get_file_space_strategy(H5P_genplist_t *plist, H5F_fspace_strategy_t *strategy, hbool_t *persist, hsize_t *threshold);
H5_DLL herr_t H5P__set_file_space_strategy(H5P_genplist_t *plist, H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold);

/* Private OCPL routines */
H5_DLL herr_t H5P__get_filter(const struct H5Z_filter_info_t *filter, unsigned int *flags, size_t *cd_nelmts,
unsigned cd_values[], size_t namelen, char name[], unsigned *filter_config);
Expand Down
21 changes: 0 additions & 21 deletions src/H5TSint.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,6 @@ static uint64_t H5TS_next_thrd_id_s = 0;
/* Mutex for access to H5TS_tinfo_next_free_s and H5TS_next_thrd_id_s */
static H5TS_mutex_t H5TS_tinfo_mtx_s;

/*-------------------------------------------------------------------------
* Function: H5TS_init
*
* Purpose: Initialize the H5TS interface
*
* Return: Non-negative on success / Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5TS_init(void)
{
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_NOAPI(FAIL)
/* FUNC_ENTER() does all the work */

done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5TS_init() */

/*--------------------------------------------------------------------------
NAME
H5TS__init_package -- Initialize interface-specific information
Expand Down
Loading

0 comments on commit 4426f03

Please sign in to comment.