From 4806d29d9f2274e102c76b8672c47cc211dbf3d6 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 1 Nov 2018 17:02:27 -0500 Subject: Refactor and standardize named datatype VOL callbacks. --- src/H5T.c | 97 ++++++++------- src/H5Tcommit.c | 65 ++-------- src/H5Tdeprec.c | 11 +- src/H5VLcallback.c | 344 ++++++++++++++++++++++++++++++++++++++++++++--------- src/H5VLprivate.h | 18 +-- 5 files changed, 359 insertions(+), 176 deletions(-) diff --git a/src/H5T.c b/src/H5T.c index 08f689c..a6c3847 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -1612,20 +1612,19 @@ H5T__close_cb(H5T_t *dt) * close it through the VOL plugin. */ if(NULL != dt->vol_obj) { - /* Close the plugin-managed datatype data */ - if(H5VL_datatype_close(dt->vol_obj->data, dt->vol_obj->plugin->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype"); + if(H5VL_datatype_close(dt->vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") /* Free the VOL object */ if(H5VL_free_object(dt->vol_obj) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object"); + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") dt->vol_obj = NULL; - } + } /* end if */ /* Close the datatype */ if(H5T_close(dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1745,7 +1744,7 @@ H5Tcopy(hid_t type_id) /* Copy datatype */ if(NULL == (new_dt = H5T_copy(dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy") /* Atomize result */ if((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0) @@ -2264,30 +2263,30 @@ done: * the return value is an integer type. * * Return: Success: Data type for base data type. - * * Failure: NULL * * Programmer: Raymond Lu - * October 9, 2002 + * October 9, 2002 + * *------------------------------------------------------------------------- */ H5T_t * H5T_get_super(const H5T_t *dt) { - H5T_t *ret_value=NULL; + H5T_t *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) HDassert(dt); - if (!dt->shared->parent) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a derived data type"); - if (NULL==(ret_value=H5T_copy(dt->shared->parent, H5T_COPY_ALL))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy parent data type"); + if(!dt->shared->parent) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a derived data type") + if(NULL == (ret_value = H5T_copy(dt->shared->parent, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy parent data type") done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5T_get_super() */ /*------------------------------------------------------------------------- @@ -3108,7 +3107,7 @@ H5T__create(H5T_class_t type, size_t size) /* Copy the default string datatype */ if(NULL == (dt = H5T_copy(origin_dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy") /* Modify the datatype */ if(H5T__set_size(dt, size) < 0) @@ -3230,9 +3229,9 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) /* Allocate space */ if(NULL == (new_dt = H5FL_MALLOC(H5T_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if(NULL == (new_dt->shared = H5FL_MALLOC(H5T_shared_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy shared information (entry information is copied last) */ *(new_dt->shared) = *(old_dt->shared); @@ -3273,7 +3272,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) /* Open named datatype again */ if(H5O_open(&old_dt->oloc) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type") /* Insert opened named datatype into opened object list for the file */ if(H5FO_insert(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr, new_dt->shared, FALSE)<0) @@ -3337,7 +3336,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) new_dt->shared->u.compnd.memb = (H5T_cmemb_t *)H5MM_malloc(new_dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t)); if (NULL == new_dt->shared->u.compnd.memb) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDmemcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb, new_dt->shared->u.compnd.nmembs * sizeof(H5T_cmemb_t)); @@ -3355,7 +3354,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) /* Range check against compound member's offset */ if ((accum_change < 0) && ((ssize_t) new_dt->shared->u.compnd.memb[i].offset < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, "invalid field size in datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, "invalid field size in datatype") /* Apply the accumulated size change to the offset of the field */ new_dt->shared->u.compnd.memb[i].offset += (size_t) accum_change; @@ -3370,7 +3369,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) /* check if we couldn't find a match */ if(old_match < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "fields in datatype corrupted"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "fields in datatype corrupted") } /* end if */ else old_match = (int) i; @@ -3386,7 +3385,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) /* Range check against datatype size */ if ((accum_change < 0) && ((ssize_t) new_dt->shared->size < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, "invalid field size in datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, "invalid field size in datatype") /* Apply the accumulated size change to the size of the compound struct */ new_dt->shared->size += (size_t) accum_change; @@ -3404,7 +3403,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) new_dt->shared->u.enumer.value = (uint8_t *)H5MM_malloc(new_dt->shared->u.enumer.nalloc * new_dt->shared->size); if(NULL == new_dt->shared->u.enumer.value) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDmemcpy(new_dt->shared->u.enumer.value, old_dt->shared->u.enumer.value, new_dt->shared->u.enumer.nmembs * new_dt->shared->size); for(i = 0; i < new_dt->shared->u.enumer.nmembs; i++) { @@ -3418,7 +3417,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) if(method == H5T_COPY_TRANSIENT || method == H5T_COPY_REOPEN) { /* H5T_copy converts any type into a memory type */ if(H5T_set_loc(new_dt, NULL, H5T_LOC_MEMORY) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") } /* end if */ break; @@ -3694,7 +3693,7 @@ H5T_close_real(H5T_t *dt) /* Clean up resources, depending on shared state */ if(dt->shared->state != H5T_STATE_OPEN) { if(H5T__free(dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype") dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); } /* end if */ @@ -3788,7 +3787,7 @@ H5T_close(H5T_t *dt) /* Clean up resources */ if(H5T_close_real(dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to free datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to free datatype") done: FUNC_LEAVE_NOAPI(ret_value) @@ -3837,7 +3836,7 @@ H5T__set_size(H5T_t *dt, size_t size) if(dt->shared->parent) { if(H5T__set_size(dt->shared->parent, size) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type") /* Adjust size of datatype appropriately */ if(dt->shared->type==H5T_ARRAY) @@ -3879,7 +3878,7 @@ H5T__set_size(H5T_t *dt, size_t size) size_t max_size; if((num_membs = H5T_get_nmembers(dt)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to get number of members"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to get number of members") if(num_membs) { for(i = 0; i < (unsigned)num_membs; i++) { @@ -3893,7 +3892,7 @@ H5T__set_size(H5T_t *dt, size_t size) max_size = H5T__get_member_size(dt, max_index); if(size < (max_offset + max_size)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size shrinking will cut off last member "); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size shrinking will cut off last member ") } /* end if */ /* Compound must not have been packed previously */ @@ -3913,7 +3912,7 @@ H5T__set_size(H5T_t *dt, size_t size) /* Get a copy of unsigned char type as the base/parent type */ if(NULL == (base = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype") dt->shared->parent=H5T_copy(base,H5T_COPY_ALL); /* change this datatype into a VL string */ @@ -3939,7 +3938,7 @@ H5T__set_size(H5T_t *dt, size_t size) /* Set up VL information */ if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") } /* end if */ else { prec = 8 * size; @@ -3955,7 +3954,7 @@ H5T__set_size(H5T_t *dt, size_t size) if(dt->shared->u.atomic.u.f.sign >= prec+offset || dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec+offset || dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec+offset) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first") } break; @@ -4095,7 +4094,7 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) /* Build an index for each type so the names are sorted */ if(NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) || NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.compnd.nmembs * sizeof(unsigned)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed") for(u = 0; u < dt1->shared->u.compnd.nmembs; u++) idx1[u] = idx2[u] = u; if(dt1->shared->u.enumer.nmembs > 1) { @@ -4181,7 +4180,7 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) /* Build an index for each type so the names are sorted */ if(NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.enumer.nmembs * sizeof(unsigned))) || NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.enumer.nmembs * sizeof(unsigned)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed") for(u=0; ushared->u.enumer.nmembs; u++) idx1[u] = u; if(dt1->shared->u.enumer.nmembs > 1) { @@ -5190,21 +5189,21 @@ H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to reset path") /* If the datatype is committed through the VOL, close it */ - if (NULL != dt->vol_obj) { + if(NULL != dt->vol_obj) { H5VL_object_t *vol_obj = dt->vol_obj; /* Close the datatype through the VOL*/ - if ((ret_value = H5VL_datatype_close(vol_obj->data, vol_obj->plugin->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype"); + if(H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") /* Free the datatype and set the VOL object pointer to NULL */ - if (H5VL_free_object(vol_obj) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object"); + if(H5VL_free_object(vol_obj) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") dt->vol_obj = NULL; - } + } /* end if */ dt->shared->state = H5T_STATE_TRANSIENT; - } + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -5349,7 +5348,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Mark the VL, compound or array type */ if((changed=H5T_set_loc(dt->shared->parent,f,loc))<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") if(changed>0) ret_value=changed; @@ -5373,7 +5372,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Range check against compound member's offset */ if ((accum_change < 0) && ((ssize_t) dt->shared->u.compnd.memb[i].offset < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") /* Apply the accumulated size change to the offset of the field */ dt->shared->u.compnd.memb[i].offset += (size_t) accum_change; @@ -5389,7 +5388,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Mark the VL, compound, enum or array type */ if((changed = H5T_set_loc(memb_type,f,loc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") if(changed > 0) ret_value = changed; @@ -5398,7 +5397,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Fail if the old_size is zero */ if (0 == old_size) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "old_size of zero would cause division by zero"); + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "old_size of zero would cause division by zero") /* Adjust the size of the member */ dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].size*memb_type->shared->size)/old_size; @@ -5411,7 +5410,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Range check against datatype size */ if ((accum_change < 0) && ((ssize_t) dt->shared->size < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") /* Apply the accumulated size change to the datatype */ dt->shared->size += (size_t) accum_change; @@ -5423,14 +5422,14 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { if((changed = H5T_set_loc(dt->shared->parent,f,loc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") if(changed > 0) ret_value = changed; } /* end if */ /* Mark this VL sequence */ if((changed = H5T__vlen_set_loc(dt, f, loc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") if(changed > 0) ret_value = changed; break; diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 3eb9cd7..0e609ff 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -108,7 +108,6 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -150,15 +149,8 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->plugin) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Commit the type */ - if(NULL == (data = H5VL_datatype_commit(vol_obj->data, loc_params, vol_obj->plugin->cls, - name, type_id, lcpl_id, tcpl_id, tapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (data = H5VL_datatype_commit(vol_obj, loc_params, name, type_id, lcpl_id, tcpl_id, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") /* Set up VOL object */ @@ -172,10 +164,6 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, dt->vol_obj = new_obj; done: - /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't reset VOL wrapper info") - FUNC_LEAVE_API(ret_value) } /* end H5Tcommit2() */ @@ -315,9 +303,7 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Commit the datatype */ - if(NULL == (dt = H5VL_datatype_commit(vol_obj->data, loc_params, vol_obj->plugin->cls, - NULL, type_id, H5P_DEFAULT, tcpl_id, tapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (dt = H5VL_datatype_commit(vol_obj, loc_params, NULL, type_id, H5P_DEFAULT, tcpl_id, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") /* Setup VOL object */ @@ -581,7 +567,6 @@ H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) void *dt = NULL; /* datatype token created by VOL plugin */ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -605,14 +590,8 @@ H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") - /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->plugin) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - /* Open the datatype */ - if(NULL == (dt = H5VL_datatype_open(vol_obj->data, loc_params, vol_obj->plugin->cls, - name, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (dt = H5VL_datatype_open(vol_obj, loc_params, name, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype") /* Register the type and return the ID */ @@ -620,13 +599,9 @@ H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype") done: - /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't reset VOL wrapper info") - /* Cleanup on error */ if(H5I_INVALID_HID == ret_value) - if(dt && H5VL_datatype_close(dt, vol_obj->plugin->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(dt && H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype") FUNC_LEAVE_API(ret_value) @@ -678,16 +653,15 @@ H5Tget_create_plist(hid_t dtype_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get default creation property list") if((ret_value = H5P_copy_plist(tcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list") - } + } /* end if */ /* If the datatype is committed, retrieve further information */ else { H5VL_object_t *vol_obj = type->vol_obj; /* Get the property list through the VOL */ - if(H5VL_datatype_get(vol_obj->data, vol_obj->plugin->cls, H5VL_DATATYPE_GET_TCPL, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_TCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info") - } + } /* end else */ done: FUNC_LEAVE_API(ret_value) @@ -727,8 +701,7 @@ H5Tflush(hid_t type_id) /* Flush metadata for named datatype */ if(dt->vol_obj) - if((ret_value = H5VL_datatype_specific(dt->vol_obj->data, dt->vol_obj->plugin->cls, H5VL_DATATYPE_FLUSH, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id)) < 0) + if(H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") done: @@ -752,7 +725,6 @@ herr_t H5Trefresh(hid_t type_id) { H5T_t *dt; /* Datatype for this operation */ - hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -769,22 +741,11 @@ H5Trefresh(hid_t type_id) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") /* Refresh the datatype's metadata */ - if(dt->vol_obj) { - /* Set wrapper info in API context */ - if(H5VL_set_vol_wrapper(dt->vol_obj->data, dt->vol_obj->plugin) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set VOL wrapper info") - vol_wrapper_set = TRUE; - - if((ret_value = H5VL_datatype_specific(dt->vol_obj->data, dt->vol_obj->plugin->cls, H5VL_DATATYPE_REFRESH, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id)) < 0) + if(dt->vol_obj) + if(H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") - } /* end if */ done: - /* Reset object wrapping info in API context */ - if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset VOL wrapper info") - FUNC_LEAVE_API(ret_value) } /* H5Trefresh */ @@ -1137,8 +1098,7 @@ H5T_construct_datatype(H5VL_object_t *vol_obj) FUNC_ENTER_NOAPI(NULL) /* get required buf size for encoding the datatype */ - if(H5VL_datatype_get(vol_obj->data, vol_obj->plugin->cls, H5VL_DATATYPE_GET_BINARY, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, NULL, 0) < 0) + if(H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, NULL, 0) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get datatype serialized size") /* allocate buffer to store binary description of the datatype */ @@ -1146,8 +1106,7 @@ H5T_construct_datatype(H5VL_object_t *vol_obj) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") /* get binary description of the datatype */ - if(H5VL_datatype_get(vol_obj->data, vol_obj->plugin->cls, H5VL_DATATYPE_GET_BINARY, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, buf, (size_t)nalloc) < 0) + if(H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, buf, (size_t)nalloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get serialized datatype") if(NULL == (dt = H5T_decode((size_t)nalloc, (const unsigned char *)buf))) diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index 4cedbd3..69a52e1 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -137,10 +137,7 @@ H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Commit the datatype */ - if(NULL == (data = H5VL_datatype_commit(vol_obj->data, loc_params, vol_obj->plugin->cls, - name, type_id, H5P_LINK_CREATE_DEFAULT, - H5P_DATATYPE_CREATE_DEFAULT, H5P_DATATYPE_ACCESS_DEFAULT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (data = H5VL_datatype_commit(vol_obj, loc_params, name, type_id, H5P_LINK_CREATE_DEFAULT, H5P_DATATYPE_CREATE_DEFAULT, H5P_DATATYPE_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") /* Set up VOL object */ @@ -197,9 +194,7 @@ H5Topen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the datatype */ - if(NULL == (dt = H5VL_datatype_open(vol_obj->data, loc_params, vol_obj->plugin->cls, - name, H5P_DATATYPE_ACCESS_DEFAULT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (dt = H5VL_datatype_open(vol_obj, loc_params, name, H5P_DATATYPE_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype") /* Register the type and return the ID */ @@ -209,7 +204,7 @@ H5Topen1(hid_t loc_id, const char *name) done: /* Cleanup on error */ if(H5I_INVALID_HID == ret_value) - if(dt && H5VL_datatype_close(dt, vol_obj->plugin->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(dt && H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to close datatype") FUNC_LEAVE_API(ret_value) diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index a820536..a6286c6 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -148,6 +148,21 @@ static herr_t H5VL__object_specific(void *obj, H5VL_loc_params_t loc_params, void **req, va_list arguments); static herr_t H5VL__object_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, va_list arguments); +static void * H5VL__datatype_commit(void *obj, H5VL_loc_params_t loc_params, + const H5VL_class_t *cls, const char *name, hid_t type_id, hid_t lcpl_id, + hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); +static void *H5VL__datatype_open(void *obj, H5VL_loc_params_t loc_params, + const H5VL_class_t *cls, const char *name, hid_t tapl_id, hid_t dxpl_id, + void **req); +static herr_t H5VL__datatype_get(void *obj, const H5VL_class_t *cls, + H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, + H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__datatype_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req); /*********************/ @@ -4929,7 +4944,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL_datatype_commit + * Function: H5VL__datatype_commit * * Purpose: Commits a datatype to the file through the VOL * @@ -4938,14 +4953,14 @@ done: * *------------------------------------------------------------------------- */ -void * -H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, +static void * +H5VL__datatype_commit(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ if(NULL == cls->datatype_cls.commit) @@ -4957,6 +4972,44 @@ H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t done: FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_commit + * + * Purpose: Commits a datatype to the file through the VOL + * + * Return: Success: Pointer to the new datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_datatype_commit(const H5VL_object_t *vol_obj, H5VL_loc_params_t loc_params, + const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, + hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->plugin) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__datatype_commit(vol_obj->data, loc_params, vol_obj->plugin->cls, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "datatype commit failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_commit() */ @@ -4989,7 +5042,7 @@ H5VLdatatype_commit(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL_datatype_commit(obj, loc_params, cls, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) + if(NULL == (ret_value = H5VL__datatype_commit(obj, loc_params, cls, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to commit datatype") done: @@ -4998,7 +5051,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL_datatype_open + * Function: H5VL__datatype_open * * Purpose: Opens a named datatype through the VOL * @@ -5007,24 +5060,61 @@ done: * *------------------------------------------------------------------------- */ -void * -H5VL_datatype_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, +static void * +H5VL__datatype_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ if(NULL == cls->datatype_cls.open) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "no datatype open callback") /* Call the corresponding VOL callback */ - if(NULL == (ret_value = (cls->datatype_cls.open) (obj, loc_params, name, tapl_id, dxpl_id, req))) + if(NULL == (ret_value = (cls->datatype_cls.open)(obj, loc_params, name, tapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") done: FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_open + * + * Purpose: Opens a named datatype through the VOL + * + * Return: Success: Pointer to the datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_datatype_open(const H5VL_object_t *vol_obj, H5VL_loc_params_t loc_params, + const char *name, hid_t tapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->plugin) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__datatype_open(vol_obj->data, loc_params, vol_obj->plugin->cls, name, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_open() */ @@ -5056,7 +5146,7 @@ H5VLdatatype_open(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") /* Call the corresponding internal VOL routine */ - if(NULL == (ret_value = H5VL_datatype_open(obj, loc_params, cls, name, tapl_id, dxpl_id, req))) + if(NULL == (ret_value = H5VL__datatype_open(obj, loc_params, cls, name, tapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open datatype") done: @@ -5065,6 +5155,37 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL__datatype_get + * + * Purpose: Get specific information about the datatype through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->datatype_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL plugin has no 'datatype get' method") + + /* Call the corresponding VOL callback */ + if((cls->datatype_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "datatype get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_get() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_datatype_get * * Purpose: Get specific information about the datatype through the VOL @@ -5075,30 +5196,36 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, +H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, ...) { va_list arguments; /* Argument list passed from the API call */ hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* Check if the corresponding VOL callback exists */ - if(NULL == cls->datatype_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL plugin has no 'datatype get' method") + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->plugin) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; - /* Call the corresponding VOL callback */ + /* Call the corresponding internal VOL routine */ va_start(arguments, req); arg_started = TRUE; - if((cls->datatype_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + if(H5VL__datatype_get(vol_obj->data, vol_obj->plugin->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "datatype get failed") done: /* End access to the va_list, if we started it */ if(arg_started) va_end(arguments); + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_get() */ @@ -5133,8 +5260,8 @@ H5VLdatatype_get(void *obj, hid_t plugin_id, H5VL_datatype_get_t get_type, if(NULL == cls->datatype_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL plugin has no `datatype get' method") - /* Bypass the H5VLint layer, calling the VOL callback directly */ - if((cls->datatype_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + /* Call the corresponding internal VOL routine */ + if(H5VL__datatype_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute datatype get callback") done: @@ -5143,9 +5270,40 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL__datatype_specific + * + * Purpose: Specific operation on datatypes through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->datatype_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL plugin has no 'datatype specific' method") + + /* Call the corresponding VOL callback */ + if((cls->datatype_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_specific() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_datatype_specific * - * Purpose: specific operation on datatypes through the VOL + * Purpose: Specific operation on datatypes through the VOL * * Return: Success: Non-negative * Failure: Negative @@ -5153,23 +5311,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_t specific_type, +H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, ...) { va_list arguments; /* Argument list passed from the API call */ hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* Check if the corresponding VOL callback exists */ - if(NULL == cls->datatype_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL plugin has no 'datatype specific' method") + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->plugin) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; - /* Call the corresponding VOL callback */ + /* Call the corresponding internal VOL routine */ va_start(arguments, req); arg_started = TRUE; - if((cls->datatype_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + if(H5VL__datatype_specific(vol_obj->data, vol_obj->plugin->cls, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") done: @@ -5177,6 +5337,10 @@ done: if(arg_started) va_end(arguments); + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_specific() */ @@ -5208,12 +5372,8 @@ H5VLdatatype_specific(void *obj, hid_t plugin_id, H5VL_datatype_specific_t speci if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") - /* Check if the corresponding VOL callback exists */ - if(NULL == cls->datatype_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL plugin has no `datatype specific' method") - - /* Bypass the H5VLint layer, calling the VOL callback directly */ - if((cls->datatype_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + /* Call the corresponding internal VOL routine */ + if(H5VL__datatype_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") done: @@ -5222,9 +5382,40 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL__datatype_optional + * + * Purpose: Optional operation specific to plugins. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->datatype_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL plugin has no 'datatype optional' method") + + /* Call the corresponding VOL callback */ + if((cls->datatype_cls.optional)(obj, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_optional() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_datatype_optional * - * Purpose: optional operation specific to plugins. + * Purpose: Optional operation specific to plugins. * * Return: Success: Non-negative * Failure: Negative @@ -5232,23 +5423,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_datatype_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, +H5VL_datatype_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...) { va_list arguments; /* Argument list passed from the API call */ hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* Check if the corresponding VOL callback exists */ - if(NULL == cls->datatype_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL plugin has no 'datatype optional' method") + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->plugin) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; - /* Call the corresponding VOL callback */ + /* Call the corresponding internal VOL routine */ va_start(arguments, req); arg_started = TRUE; - if((cls->datatype_cls.optional)(obj, dxpl_id, req, arguments) < 0) + if(H5VL__datatype_optional(vol_obj->data, vol_obj->plugin->cls, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") done: @@ -5256,6 +5449,10 @@ done: if(arg_started) va_end(arguments); + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_optional() */ @@ -5286,12 +5483,8 @@ H5VLdatatype_optional(void *obj, hid_t plugin_id, hid_t dxpl_id, void **req, if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") - /* Check if the corresponding VOL callback exists */ - if(NULL == cls->datatype_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL plugin has no `datatype optional' method") - - /* Bypass the H5VLint layer, calling the VOL callback directly */ - if((cls->datatype_cls.optional)(obj, dxpl_id, req, arguments) < 0) + /* Call the corresponding internal VOL routine */ + if(H5VL__datatype_optional(obj, cls, dxpl_id, req, arguments) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") done: @@ -5300,7 +5493,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL_datatype_close + * Function: H5VL__datatype_close * * Purpose: Closes a datatype through the VOL * @@ -5309,23 +5502,60 @@ done: * *------------------------------------------------------------------------- */ -herr_t -H5VL_datatype_close(void *dt, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +static herr_t +H5VL__datatype_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Check if the corresponding VOL callback exists */ if(NULL == cls->datatype_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL plugin has no 'datatype close' method") /* Call the corresponding VOL callback */ - if((cls->datatype_cls.close)(dt, dxpl_id, req) < 0) + if((cls->datatype_cls.close)(obj, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "datatype close failed") done: FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_close + * + * Purpose: Closes a datatype through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->plugin) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__datatype_close(vol_obj->data, vol_obj->plugin->cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "datatype close failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_close() */ @@ -5340,22 +5570,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLdatatype_close(void *dt, hid_t plugin_id, hid_t dxpl_id, void **req) +H5VLdatatype_close(void *obj, hid_t plugin_id, hid_t dxpl_id, void **req) { H5VL_class_t *cls; /* VOL plugin's class struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - H5TRACE4("e", "*xii**x", dt, plugin_id, dxpl_id, req); + H5TRACE4("e", "*xii**x", obj, plugin_id, dxpl_id, req); /* Check args and get class pointer */ - if(NULL == dt) + if(NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") /* Call the corresponding internal VOL routine */ - if(H5VL_datatype_close(dt, cls, dxpl_id, req) < 0) + if(H5VL__datatype_close(obj, cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close datatype") done: diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 7b2e590..a168b57 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -114,7 +114,7 @@ H5_DLL herr_t H5VL_attr_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void /* Dataset functions */ H5_DLL void *H5VL_dataset_create(const H5VL_object_t *vol_obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL void * H5VL_dataset_open(const H5VL_object_t *vol_obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_dataset_open(const H5VL_object_t *vol_obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL_dataset_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); H5_DLL herr_t H5VL_dataset_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); H5_DLL herr_t H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, ...); @@ -132,7 +132,7 @@ H5_DLL herr_t H5VL_file_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void /* Group functions */ H5_DLL void *H5VL_group_create(const H5VL_object_t *vol_obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL void * H5VL_group_open(const H5VL_object_t *vol_obj, H5VL_loc_params_t loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_group_open(const H5VL_object_t *vol_obj, H5VL_loc_params_t loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, ...); H5_DLL herr_t H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, ...); H5_DLL herr_t H5VL_group_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...); @@ -147,19 +147,19 @@ H5_DLL herr_t H5VL_link_specific(const H5VL_object_t *vol_obj, H5VL_loc_params_t H5_DLL herr_t H5VL_link_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...); /* Object functions */ -H5_DLL void * H5VL_object_open(const H5VL_object_t *vol_obj, H5VL_loc_params_t params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_object_open(const H5VL_object_t *vol_obj, H5VL_loc_params_t params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL_object_copy(const H5VL_object_t *src_obj, H5VL_loc_params_t src_loc_params, const char *src_name, const H5VL_object_t *dst_obj, H5VL_loc_params_t dst_loc_params, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL_object_get(const H5VL_object_t *vol_obj, H5VL_loc_params_t loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, ...); H5_DLL herr_t H5VL_object_specific(const H5VL_object_t *vol_obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...); H5_DLL herr_t H5VL_object_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...); /* Datatype functions */ -H5_DLL void *H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL_datatype_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_datatype_get(void *dt, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_datatype_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_datatype_close(void *dt, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_datatype_commit(const H5VL_object_t *vol_obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_datatype_open(const H5VL_object_t *vol_obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Asynchronous functions */ H5_DLL herr_t H5VL_request_cancel(void **req, const H5VL_class_t *cls, H5ES_status_t *status); -- cgit v0.12