From ce653ff82b7dd52b8e36a5eff7b1728c4b75d9f7 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Thu, 12 Dec 2019 15:17:25 -0600 Subject: Modify H5VL initialization routines to initialize all VOL-managed object types. Modify H5VLwrap_register() to reject non-VOL-managed object types. Also fix overisights in h5trace.c from previous changes. --- src/H5A.c | 23 +++++++++++++++++++++++ src/H5Aprivate.h | 1 + src/H5F.c | 24 ++++++++++++++++++++++++ src/H5Fprivate.h | 1 + src/H5G.c | 23 +++++++++++++++++++++++ src/H5Gprivate.h | 1 + src/H5M.c | 23 +++++++++++++++++++++++ src/H5Mprivate.h | 1 + src/H5VL.c | 33 +++++++++++++++++++++++++++++++-- src/H5VLint.c | 19 +++++++++++++++++++ src/H5trace.c | 6 ++++++ 11 files changed, 153 insertions(+), 2 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index abf8694..dcb013f 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -100,6 +100,29 @@ static hbool_t H5A_top_package_initialize_s = FALSE; +/*------------------------------------------------------------------------- + * Function: H5A_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * + * Failure: negative + *------------------------------------------------------------------------- + */ +herr_t +H5A_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 H5A_init() */ + + /*-------------------------------------------------------------------------- NAME H5A__init_package -- Initialize interface-specific information diff --git a/src/H5Aprivate.h b/src/H5Aprivate.h index 342ffc8..b288228 100644 --- a/src/H5Aprivate.h +++ b/src/H5Aprivate.h @@ -73,6 +73,7 @@ typedef struct H5A_attr_iter_op_t { /***************************************/ /* General attribute routines */ +H5_DLL herr_t H5A_init(void); H5_DLL struct H5O_loc_t *H5A_oloc(H5A_t *attr); H5_DLL H5G_name_t *H5A_nameof(H5A_t *attr); H5_DLL H5T_t *H5A_type(const H5A_t *attr); diff --git a/src/H5F.c b/src/H5F.c index 9eebaee..4b0b508 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -113,6 +113,30 @@ static const H5I_class_t H5I_FILE_CLS[1] = {{ (H5I_free_t)H5F__close_cb /* Callback routine for closing objects of this class */ }}; + + +/*------------------------------------------------------------------------- + * Function: H5F_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * + * Failure: negative + *------------------------------------------------------------------------- + */ +herr_t +H5F_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 H5F_init() */ + /*-------------------------------------------------------------------------- NAME diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index cfb796c..4008eb8 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -730,6 +730,7 @@ typedef enum H5F_prefix_open_t { /***************************************/ /* Private functions */ +H5_DLL herr_t H5F_init(void); H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed/*out*/); H5_DLL hid_t H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref); diff --git a/src/H5G.c b/src/H5G.c index 85515d3..d194469 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -144,6 +144,29 @@ static hbool_t H5G_top_package_initialize_s = FALSE; /*------------------------------------------------------------------------- + * Function: H5G_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * + * Failure: negative + *------------------------------------------------------------------------- + */ +herr_t +H5G_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 H5G_init() */ + + +/*------------------------------------------------------------------------- * Function: H5G__init_package * * Purpose: Initializes the H5G interface. diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index f149f29..b735dbd 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -186,6 +186,7 @@ typedef struct H5G_entry_t H5G_entry_t; * Library prototypes... These are the ones that other packages routinely * call. */ +H5_DLL herr_t H5G_init(void); H5_DLL struct H5O_loc_t *H5G_oloc(H5G_t *grp); H5_DLL H5G_name_t * H5G_nameof(const H5G_t *grp); H5_DLL H5F_t *H5G_fileof(H5G_t *grp); diff --git a/src/H5M.c b/src/H5M.c index adb4df0..ef5b4d9 100644 --- a/src/H5M.c +++ b/src/H5M.c @@ -78,6 +78,29 @@ static hbool_t H5M_top_package_initialize_s = FALSE; /*------------------------------------------------------------------------- + * Function: H5M_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * + * Failure: negative + *------------------------------------------------------------------------- + */ +herr_t +H5M_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 H5M_init() */ + + +/*------------------------------------------------------------------------- NAME H5M__init_package -- Initialize interface-specific information USAGE diff --git a/src/H5Mprivate.h b/src/H5Mprivate.h index c841e75..3d0e8cc 100644 --- a/src/H5Mprivate.h +++ b/src/H5Mprivate.h @@ -65,6 +65,7 @@ /****************************/ /* Library Private Typedefs */ /****************************/ +H5_DLL herr_t H5M_init(void); /*****************************/ diff --git a/src/H5VL.c b/src/H5VL.c index 6790465..df05396 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -477,6 +477,9 @@ done: * iteration routine callbacks (i.e. the callbacks from H5Aiterate*, * H5Literate* / H5Lvisit*, and H5Ovisit* ). * + * type must be a VOL-managed object class (H5I_FILE, + * H5I_GROUP, H5I_DATATYPE, H5I_DATASET, H5I_MAP, or H5I_ATTR). + * * Return: Success: Non-negative hid_t for the object. * Failure: Negative (H5I_INVALID_HID) * @@ -492,8 +495,34 @@ H5VLwrap_register(void *obj, H5I_type_t type) H5TRACE2("i", "*xIt", obj, type); /* Check args */ - if(type <= H5I_BADID || type >= H5I_NTYPES) - HGOTO_ERROR(H5E_VOL, H5E_BADRANGE, H5I_INVALID_HID, "invalid type number") + /* Use a switch here for (hopefully) better performance than a series of + * equality checks. We could also group these types together in H5I_type_t, + * make some assertions here to guarantee that, then just check the range. + */ + switch(type) { + case H5I_FILE: + case H5I_GROUP: + case H5I_DATATYPE: + case H5I_DATASET: + case H5I_MAP: + case H5I_ATTR: + /* VOL-managed objects, call is valid */ + break; + case H5I_UNINIT: + case H5I_BADID: + case H5I_DATASPACE: + case H5I_VFL: + case H5I_VOL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_SPACE_SEL_ITER: + case H5I_NTYPES: + default: + HGOTO_ERROR(H5E_VOL, H5E_BADRANGE, H5I_INVALID_HID, "invalid type number") + } /* end switch */ if(NULL == obj) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, "obj is NULL") diff --git a/src/H5VLint.c b/src/H5VLint.c index 284b266..bc50a38 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -30,10 +30,15 @@ /***********/ #include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ #include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ #include "H5FLprivate.h" /* Free lists */ +#include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ +#include "H5Mprivate.h" /* Maps */ #include "H5MMprivate.h" /* Memory management */ #include "H5PLprivate.h" /* Plugins */ #include "H5Tprivate.h" /* Datatypes */ @@ -189,6 +194,20 @@ H5VL_init_phase2(void) FUNC_ENTER_NOAPI(FAIL) + /* 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") + /* Set up the default VOL connector in the default FAPL */ if(H5VL__set_def_conn() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set default VOL connector") diff --git a/src/H5trace.c b/src/H5trace.c index 65e267e..2fcf82f 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -2841,6 +2841,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...) H5VL_file_specific_t specific = (H5VL_file_specific_t)HDva_arg(ap, int); switch(specific) { + case H5VL_FILE_POST_OPEN: + HDfprintf(out, "H5VL_FILE_POST_OPEN"); + break; case H5VL_FILE_FLUSH: HDfprintf(out, "H5VL_FILE_FLUSH"); break; @@ -2859,6 +2862,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5VL_FILE_DELETE: HDfprintf(out, "H5VL_FILE_DELETE"); break; + case H5VL_FILE_IS_EQUAL: + HDfprintf(out, "H5VL_FILE_IS_EQUAL"); + break; default: HDfprintf(out, "%ld", (long)specific); break; -- cgit v0.12