summaryrefslogtreecommitdiffstats
path: root/src/H5VLint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5VLint.c')
-rw-r--r--src/H5VLint.c201
1 files changed, 90 insertions, 111 deletions
diff --git a/src/H5VLint.c b/src/H5VLint.c
index 70c8112..391bd91 100644
--- a/src/H5VLint.c
+++ b/src/H5VLint.c
@@ -32,6 +32,7 @@
#include "H5CXprivate.h" /* API Contexts */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
+#include "H5ESprivate.h" /* Event sets */
#include "H5Fprivate.h" /* Files */
#include "H5FLprivate.h" /* Free lists */
#include "H5Gprivate.h" /* Groups */
@@ -69,11 +70,7 @@ typedef struct H5VL_wrap_ctx_t {
*/
typedef struct {
/* IN */
- H5VL_get_connector_kind_t kind; /* Which kind of connector search to make */
- union {
- const char * name; /* The name of the VOL connector to check */
- H5VL_class_value_t value; /* The value of the VOL connector to check */
- } u;
+ H5PL_vol_key_t key;
/* OUT */
hid_t found_id; /* The connector ID, if we found a match */
@@ -98,9 +95,6 @@ static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx);
/* Package Variables */
/*********************/
-/* Package initialization variable */
-hbool_t H5_PKG_INIT_VAR = FALSE;
-
/*****************************/
/* Library Private Variables */
/*****************************/
@@ -153,7 +147,9 @@ H5VL_init_phase1(void)
FUNC_ENTER_NOAPI(FAIL)
- /* FUNC_ENTER() does all the work */
+ /* Initialize the ID group for the VL IDs */
+ if (H5I_register_type(H5I_VOL_CLS) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize H5VL interface")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -175,23 +171,38 @@ done:
herr_t
H5VL_init_phase2(void)
{
+ size_t i;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
+ /* clang-format off */
+ struct {
+ herr_t (*func)(void);
+ const char *descr;
+ } initializer[] = {
+ {H5T_init, "datatype"}
+ , {H5O_init, "object header"}
+ , {H5D_init, "dataset"}
+ , {H5F_init, "file"}
+ , {H5G_init, "group"}
+ , {H5A_init, "attribute"}
+ , {H5M_init, "map"}
+ , {H5CX_init, "context"}
+ , {H5ES_init, "event set"}
+ , {H5Z_init, "transform"}
+ , {H5R_init, "reference"}
+ };
+
/* Initialize all packages for VOL-managed objects */
- if (H5T_init() < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize datatype interface")
- if (H5D_init() < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize dataset interface")
- if (H5F_init() < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize file interface")
- if (H5G_init() < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize group interface")
- if (H5A_init() < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize attribute interface")
- if (H5M_init() < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize map interface")
+ for (i = 0; i < NELMTS(initializer); i++) {
+ if (initializer[i].func() < 0) {
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL,
+ "unable to initialize %s interface", initializer[i].descr)
+ }
+ }
+
+ /* clang-format on */
/* Sanity check default VOL connector */
HDassert(H5VL_def_conn_s.connector_id == (-1));
@@ -206,32 +217,6 @@ done:
} /* end H5VL_init_phase2() */
/*-------------------------------------------------------------------------
- * Function: H5VL__init_package
- *
- * Purpose: Initialize interface-specific information
- *
- * Return: Success: Non-negative
- *
- * Failure: Negative
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5VL__init_package(void)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_PACKAGE
-
- /* Initialize the ID group for the VL IDs */
- if (H5I_register_type(H5I_VOL_CLS) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize H5VL interface")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL__init_package() */
-
-/*-------------------------------------------------------------------------
* Function: H5VL_term_package
*
* Purpose: Terminate various H5VL objects
@@ -249,37 +234,31 @@ H5VL_term_package(void)
FUNC_ENTER_NOAPI_NOINIT_NOERR
- if (H5_PKG_INIT_VAR) {
- if (H5VL_def_conn_s.connector_id > 0) {
- /* Release the default VOL connector */
- (void)H5VL_conn_free(&H5VL_def_conn_s);
- H5VL_def_conn_s.connector_id = -1;
- H5VL_def_conn_s.connector_info = NULL;
+ if (H5VL_def_conn_s.connector_id > 0) {
+ /* Release the default VOL connector */
+ (void)H5VL_conn_free(&H5VL_def_conn_s);
+ H5VL_def_conn_s.connector_id = -1;
+ H5VL_def_conn_s.connector_info = NULL;
+ n++;
+ } /* end if */
+ else {
+ if (H5I_nmembers(H5I_VOL) > 0) {
+ /* Unregister all VOL connectors */
+ (void)H5I_clear_type(H5I_VOL, TRUE, FALSE);
n++;
} /* end if */
else {
- if (H5I_nmembers(H5I_VOL) > 0) {
- /* Unregister all VOL connectors */
- (void)H5I_clear_type(H5I_VOL, TRUE, FALSE);
+ if (H5VL__num_opt_operation() > 0) {
+ /* Unregister all dynamically registered optional operations */
+ (void)H5VL__term_opt_operation();
n++;
} /* end if */
else {
- if (H5VL__num_opt_operation() > 0) {
- /* Unregister all dynamically registered optional operations */
- (void)H5VL__term_opt_operation();
- n++;
- } /* end if */
- else {
- /* Destroy the VOL connector ID group */
- n += (H5I_dec_type_ref(H5I_VOL) > 0);
-
- /* Mark interface as closed */
- if (0 == n)
- H5_PKG_INIT_VAR = FALSE;
- } /* end else */
- } /* end else */
- } /* end else */
- } /* end if */
+ /* Destroy the VOL connector ID group */
+ n += (H5I_dec_type_ref(H5I_VOL) > 0);
+ } /* end else */
+ } /* end else */
+ } /* end else */
FUNC_LEAVE_NOAPI(n)
} /* end H5VL_term_package() */
@@ -341,15 +320,15 @@ H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data)
FUNC_ENTER_STATIC_NOERR
- if (H5VL_GET_CONNECTOR_BY_NAME == op_data->kind) {
- if (0 == HDstrcmp(cls->name, op_data->u.name)) {
+ if (H5VL_GET_CONNECTOR_BY_NAME == op_data->key.kind) {
+ if (0 == HDstrcmp(cls->name, op_data->key.u.name)) {
op_data->found_id = id;
ret_value = H5_ITER_STOP;
} /* end if */
} /* end if */
else {
- HDassert(H5VL_GET_CONNECTOR_BY_VALUE == op_data->kind);
- if (cls->value == op_data->u.value) {
+ HDassert(H5VL_GET_CONNECTOR_BY_VALUE == op_data->key.kind);
+ if (cls->value == op_data->key.u.value) {
op_data->found_id = id;
ret_value = H5_ITER_STOP;
} /* end if */
@@ -398,7 +377,7 @@ H5VL__set_def_conn(void)
} /* end if */
/* Check for environment variable set */
- env_var = HDgetenv("HDF5_VOL_CONNECTOR");
+ env_var = HDgetenv(HDF5_VOL_CONNECTOR);
/* Only parse the string if it's set */
if (env_var && *env_var) {
@@ -976,7 +955,7 @@ H5VL_conn_inc_rc(H5VL_t *connector)
{
int64_t ret_value = -1;
- FUNC_ENTER_NOAPI(-1)
+ FUNC_ENTER_NOAPI_NOERR
/* Check arguments */
HDassert(connector);
@@ -986,7 +965,6 @@ H5VL_conn_inc_rc(H5VL_t *connector)
ret_value = connector->nrefs;
-done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_conn_inc_rc() */
@@ -1299,9 +1277,9 @@ H5VL__register_connector_by_class(const H5VL_class_t *cls, hbool_t app_ref, hid_
"callback is provided")
/* Set up op data for iteration */
- op_data.kind = H5VL_GET_CONNECTOR_BY_NAME;
- op_data.u.name = cls->name;
- op_data.found_id = H5I_INVALID_HID;
+ op_data.key.kind = H5VL_GET_CONNECTOR_BY_NAME;
+ op_data.key.u.name = cls->name;
+ op_data.found_id = H5I_INVALID_HID;
/* Check if connector is already registered */
if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
@@ -1350,15 +1328,15 @@ H5VL__register_connector_by_name(const char *name, hbool_t app_ref, hid_t vipl_i
FUNC_ENTER_PACKAGE
/* Set up op data for iteration */
- op_data.kind = H5VL_GET_CONNECTOR_BY_NAME;
- op_data.u.name = name;
- op_data.found_id = H5I_INVALID_HID;
+ op_data.key.kind = H5VL_GET_CONNECTOR_BY_NAME;
+ op_data.key.u.name = name;
+ op_data.found_id = H5I_INVALID_HID;
/* Check if connector is already registered */
if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, app_ref) < 0)
HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids")
- /* If connector alread registered, increment ref count on ID and return ID */
+ /* If connector already registered, increment ref count on ID and return ID */
if (op_data.found_id != H5I_INVALID_HID) {
if (H5I_inc_ref(op_data.found_id, app_ref) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID,
@@ -1410,15 +1388,15 @@ H5VL__register_connector_by_value(H5VL_class_value_t value, hbool_t app_ref, hid
FUNC_ENTER_PACKAGE
/* Set up op data for iteration */
- op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE;
- op_data.u.value = value;
- op_data.found_id = H5I_INVALID_HID;
+ op_data.key.kind = H5VL_GET_CONNECTOR_BY_VALUE;
+ op_data.key.u.value = value;
+ op_data.found_id = H5I_INVALID_HID;
/* Check if connector is already registered */
- if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
+ if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, app_ref) < 0)
HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids")
- /* If connector alread registered, increment ref count on ID and return ID */
+ /* If connector already registered, increment ref count on ID and return ID */
if (op_data.found_id != H5I_INVALID_HID) {
if (H5I_inc_ref(op_data.found_id, app_ref) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID,
@@ -1449,8 +1427,9 @@ done:
*
* Purpose: Checks if a connector with a particular name is registered.
*
- * Return: Success: 0
- * Failure: -1
+ * Return: >0 if a VOL connector with that name has been registered
+ * 0 if a VOL connector with that name has NOT been registered
+ * <0 on errors
*
* Programmer: Dana Robinson
* June 17, 2017
@@ -1466,9 +1445,9 @@ H5VL__is_connector_registered_by_name(const char *name)
FUNC_ENTER_PACKAGE
/* Set up op data for iteration */
- op_data.kind = H5VL_GET_CONNECTOR_BY_NAME;
- op_data.u.name = name;
- op_data.found_id = H5I_INVALID_HID;
+ op_data.key.kind = H5VL_GET_CONNECTOR_BY_NAME;
+ op_data.key.u.name = name;
+ op_data.found_id = H5I_INVALID_HID;
/* Find connector with name */
if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
@@ -1488,8 +1467,9 @@ done:
* Purpose: Checks if a connector with a particular value (ID) is
* registered.
*
- * Return: Success: 0
- * Failure: -1
+ * Return: >0 if a VOL connector with that value has been registered
+ * 0 if a VOL connector with that value hasn't been registered
+ * <0 on errors
*
*-------------------------------------------------------------------------
*/
@@ -1502,9 +1482,9 @@ H5VL__is_connector_registered_by_value(H5VL_class_value_t value)
FUNC_ENTER_PACKAGE
/* Set up op data for iteration */
- op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE;
- op_data.u.value = value;
- op_data.found_id = H5I_INVALID_HID;
+ op_data.key.kind = H5VL_GET_CONNECTOR_BY_VALUE;
+ op_data.key.u.value = value;
+ op_data.found_id = H5I_INVALID_HID;
/* Find connector with value */
if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
@@ -1635,9 +1615,9 @@ H5VL__peek_connector_id_by_name(const char *name)
FUNC_ENTER_PACKAGE
/* Set up op data for iteration */
- op_data.kind = H5VL_GET_CONNECTOR_BY_NAME;
- op_data.u.name = name;
- op_data.found_id = H5I_INVALID_HID;
+ op_data.key.kind = H5VL_GET_CONNECTOR_BY_NAME;
+ op_data.key.u.name = name;
+ op_data.found_id = H5I_INVALID_HID;
/* Find connector with name */
if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
@@ -1671,9 +1651,9 @@ H5VL__peek_connector_id_by_value(H5VL_class_value_t value)
FUNC_ENTER_PACKAGE
/* Set up op data for iteration */
- op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE;
- op_data.u.value = value;
- op_data.found_id = H5I_INVALID_HID;
+ op_data.key.kind = H5VL_GET_CONNECTOR_BY_VALUE;
+ op_data.key.u.value = value;
+ op_data.found_id = H5I_INVALID_HID;
/* Find connector with value */
if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0)
@@ -1757,7 +1737,7 @@ H5VL__get_connector_name(hid_t id, char *name /*out*/, size_t size)
len = HDstrlen(cls->name);
if (name) {
- HDstrncpy(name, cls->name, MIN(len + 1, size));
+ HDstrncpy(name, cls->name, size);
if (len >= size)
name[size - 1] = '\0';
} /* end if */
@@ -2006,7 +1986,7 @@ H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_clas
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI_NOERR
/* Sanity checks */
HDassert(cls1);
@@ -2534,7 +2514,7 @@ H5VL_check_plugin_load(const H5VL_class_t *cls, const H5PL_key_t *key, hbool_t *
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI_NOERR
/* Sanity checks */
HDassert(cls);
@@ -2560,7 +2540,6 @@ H5VL_check_plugin_load(const H5VL_class_t *cls, const H5PL_key_t *key, hbool_t *
if (*success && cls->version != H5VL_VERSION)
*success = FALSE;
-done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_check_plugin_load() */