summaryrefslogtreecommitdiffstats
path: root/src/H5R.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-03-15 21:54:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-03-15 21:54:30 (GMT)
commit4a17aff4085ad6ee265b95730aca3f493056dec8 (patch)
tree8bfb665c6d95a2e3520fa1bb0ff54d95aff3923f /src/H5R.c
parent853ae26333592faf69cd8c454ef92ffea8549df5 (diff)
downloadhdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.zip
hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.gz
hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.bz2
Add API context interface and use it throughout the library.
Diffstat (limited to 'src/H5R.c')
-rw-r--r--src/H5R.c94
1 files changed, 68 insertions, 26 deletions
diff --git a/src/H5R.c b/src/H5R.c
index 8b42b35..86a94bf 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -23,6 +23,7 @@
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5ACprivate.h" /* Metadata cache */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h" /* Error handling */
#include "H5Gprivate.h" /* Groups */
#include "H5Iprivate.h" /* IDs */
@@ -92,6 +93,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t
{
H5G_loc_t loc; /* File location */
H5S_t *space = NULL; /* Pointer to dataspace containing region */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -113,11 +115,21 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t
if (space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set API context")
+api_ctx_pushed = TRUE;
+/* Set up collective metadata if appropriate */
+if(H5CX_set_loc(loc_id, TRUE) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access property list info")
+
/* Create reference */
- if ((ret_value = H5R_create(ref, &loc, name, ref_type, space, H5AC_ind_read_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to create reference")
+ if((ret_value = H5R__create(ref, &loc, name, ref_type, space)) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference")
done:
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_REFERENCE, H5E_CANTRESET, FAIL, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* end H5Rcreate() */
@@ -154,34 +166,40 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r
{
H5G_loc_t loc; /* Group location */
H5F_t *file = NULL; /* File object */
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
- hid_t ret_value;
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE4("i", "iiRt*x", obj_id, oapl_id, ref_type, _ref);
/* Check args */
if (H5G_loc(obj_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location")
if (oapl_id < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list")
if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type")
if (_ref == NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer")
- /* Verify access property list and get correct dxpl */
- if (H5P_verify_apl_and_dxpl(&oapl_id, H5P_CLS_DACC, &dxpl_id, obj_id, FALSE) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set API context")
+api_ctx_pushed = TRUE;
+/* Verify access property list and set up collective metadata if appropriate */
+if(H5CX_set_apl(&oapl_id, H5P_CLS_DACC, obj_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access property list info")
/* Get the file pointer from the entry */
file = loc.oloc->file;
/* Create reference */
- if ((ret_value = H5R_dereference(file, oapl_id, dxpl_id, ref_type, _ref, TRUE)) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to dereference object")
+ if((ret_value = H5R__dereference(file, oapl_id, ref_type, _ref)) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to dereference object")
done:
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_REFERENCE, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* end H5Rdereference2() */
@@ -214,28 +232,36 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref)
{
H5G_loc_t loc; /* Object's group location */
H5S_t *space = NULL; /* Dataspace object */
- hid_t ret_value;
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE3("i", "iRt*x", id, ref_type, ref);
/* Check args */
if (H5G_loc(id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location")
if (ref_type != H5R_DATASET_REGION)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type")
if (ref == NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer")
+
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set API context")
+api_ctx_pushed = TRUE;
/* Get the dataspace with the correct region selected */
- if ((space = H5R_get_region(loc.oloc->file, H5AC_ind_read_dxpl_id, ref)) == NULL)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create dataspace")
+ if(NULL == (space = H5R__get_region(loc.oloc->file, ref)))
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve dataspace")
/* Atomize */
if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom")
done:
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_REFERENCE, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* end H5Rget_region() */
@@ -268,6 +294,7 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref,
H5O_type_t *obj_type)
{
H5G_loc_t loc; /* Object location */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -281,11 +308,18 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref,
if (ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set API context")
+api_ctx_pushed = TRUE;
+
/* Get the object information */
- if (H5R_get_obj_type(loc.oloc->file, H5AC_ind_read_dxpl_id, ref_type, ref, obj_type) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object type")
+ if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, obj_type) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type")
done:
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_REFERENCE, H5E_CANTRESET, FAIL, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* end H5Rget_obj_type2() */
@@ -329,6 +363,7 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name,
{
H5G_loc_t loc; /* Group location */
H5F_t *file; /* File object */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
ssize_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -342,14 +377,21 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name,
if (_ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set API context")
+api_ctx_pushed = TRUE;
+
/* Get the file pointer from the entry */
file = loc.oloc->file;
/* Get name */
- if ((ret_value = H5R_get_name(file, H5P_DEFAULT, H5AC_ind_read_dxpl_id, id, ref_type, _ref, name, size)) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object path")
+ if((ret_value = H5R__get_name(file, id, ref_type, _ref, name, size)) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object path")
done:
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_REFERENCE, H5E_CANTRESET, FAIL, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* end H5Rget_name() */