summaryrefslogtreecommitdiffstats
path: root/src/H5Tcommit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Tcommit.c')
-rw-r--r--src/H5Tcommit.c518
1 files changed, 410 insertions, 108 deletions
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index 30fbeeb..57e6271 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -28,6 +28,7 @@
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5ACprivate.h" /* Metadata cache */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h" /* Error handling */
#include "H5FOprivate.h" /* File objects */
#include "H5Iprivate.h" /* IDs */
@@ -55,7 +56,11 @@
/********************/
/* Local Prototypes */
/********************/
-static H5T_t *H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id);
+static herr_t H5T__commit_anon(H5F_t *file, H5T_t *type, hid_t tcpl_id);
+static hid_t H5T__get_create_plist(const H5T_t *type);
+static H5T_t *H5T__open_oid(const H5G_loc_t *loc);
+static herr_t H5T__flush(H5T_t *dt, hid_t type_id);
+static herr_t H5T__refresh(H5T_t *dt, hid_t type_id);
/*********************/
@@ -98,7 +103,7 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id,
{
H5G_loc_t loc; /* Location to create datatype */
H5T_t *type; /* Datatype for ID */
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -126,15 +131,21 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id,
if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list")
- /* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id, loc_id, TRUE) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set API context")
+api_ctx_pushed = TRUE;
+/* Verify access property list and set up collective metadata if appropriate */
+if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info")
/* Commit the type */
- if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, dxpl_id) < 0)
+ if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
done:
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* end H5Tcommit2() */
@@ -154,14 +165,14 @@ done:
*/
herr_t
H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt,
- hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id)
+ hid_t lcpl_id, hid_t tcpl_id)
{
H5O_obj_create_t ocrt_info; /* Information for object creation */
H5T_obj_create_t tcrt_info; /* Information for named datatype creation */
H5T_state_t old_state; /* The state of the datatype before H5T__commit. */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_PACKAGE
+ FUNC_ENTER_PACKAGE_VOL
/* Sanity checks */
HDassert(loc);
@@ -169,8 +180,6 @@ H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt,
HDassert(dt);
HDassert(lcpl_id != H5P_DEFAULT);
HDassert(tcpl_id != H5P_DEFAULT);
- HDassert(tapl_id != H5P_DEFAULT);
- HDassert(dxpl_id != H5P_DEFAULT);
/* Record the type's state so that we can revert to it if linking fails */
old_state = dt->shared->state;
@@ -185,7 +194,7 @@ H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt,
ocrt_info.new_obj = NULL;
/* Create the new named datatype and link it to its parent group */
- if(H5L_link_object(loc, name, &ocrt_info, lcpl_id, tapl_id, dxpl_id) < 0)
+ if(H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create and link to named datatype")
HDassert(ocrt_info.new_obj);
@@ -198,7 +207,7 @@ done:
/* Remove the datatype from the list of opened objects in the file */
if(H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object")
- if(H5FO_delete(dt->sh_loc.file, dxpl_id, dt->sh_loc.u.loc.oh_addr) < 0)
+ if(H5FO_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects")
/* Close the datatype object */
@@ -206,7 +215,7 @@ done:
HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header")
/* Remove the datatype's object header from the file */
- if(H5O_delete(dt->sh_loc.file, dxpl_id, dt->sh_loc.u.loc.oh_addr) < 0)
+ if(H5O_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header")
/* Mark datatype as being back in memory */
@@ -217,7 +226,7 @@ done:
} /* end if */
} /* end if */
- FUNC_LEAVE_NOAPI(ret_value)
+ FUNC_LEAVE_NOAPI_VOL(ret_value)
} /* end H5T__commit_named() */
@@ -245,7 +254,7 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id)
{
H5G_loc_t loc; /* Group location for location */
H5T_t *type = NULL; /* Datatype created */
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -264,30 +273,67 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id)
if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list")
- /* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id, loc_id, TRUE) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set API context")
+api_ctx_pushed = TRUE;
+/* Verify access property list and set up collective metadata if appropriate */
+if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info")
+
+ /* Commit the type */
+ if(H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
+
+done:
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "can't reset API context")
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Tcommit_anon() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__commit_anon
+ *
+ * Purpose: Create an anonymous committed datatype.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, December 12, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5T__commit_anon(H5F_t *file, H5T_t *type, hid_t tcpl_id)
+{
+ H5O_loc_t *oloc; /* Object location for datatype */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC_VOL
+
+ /* Sanity checks */
+ HDassert(file);
+ HDassert(type);
+ HDassert(tcpl_id != H5P_DEFAULT);
/* Commit the type */
- if(H5T__commit(loc.oloc->file, type, tcpl_id, dxpl_id) < 0)
+ if(H5T__commit(file, type, tcpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
/* Release the datatype's object header */
- {
- H5O_loc_t *oloc; /* Object location for datatype */
- /* Get the new committed datatype's object location */
- if(NULL == (oloc = H5T_oloc(type)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get object location of committed datatype")
+ /* Get the new committed datatype's object location */
+ if(NULL == (oloc = H5T_oloc(type)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get object location of committed datatype")
- /* Decrement refcount on committed datatype's object header in memory */
- if(H5O_dec_rc_by_loc(oloc, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object")
- } /* end if */
+ /* Decrement refcount on committed datatype's object header in memory */
+ if(H5O_dec_rc_by_loc(oloc) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object")
done:
- FUNC_LEAVE_API(ret_value)
-} /* end H5Tcommit_anon() */
+ FUNC_LEAVE_NOAPI_VOL(ret_value)
+} /* H5T__commit_anon() */
/*-------------------------------------------------------------------------
@@ -304,7 +350,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id)
+H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id)
{
H5O_loc_t temp_oloc; /* Temporary object header location */
H5G_name_t temp_path; /* Temporary path */
@@ -362,9 +408,9 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id, hid_t dxpl_id)
* Create the object header and open it for write access. Insert the data
* type message and then give the object header a name.
*/
- if(H5O_create(file, dxpl_id, dtype_size, (size_t)1, tcpl_id, &temp_oloc) < 0)
+ if(H5O_create(file, dtype_size, (size_t)1, tcpl_id, &temp_oloc) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header")
- if(H5O_msg_create(&temp_oloc, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, type, dxpl_id) < 0)
+ if(H5O_msg_create(&temp_oloc, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, type) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message")
/* Copy the new object header's location into the datatype, taking ownership of it */
@@ -398,11 +444,11 @@ done:
H5G_name_free(&temp_path);
} /* end if */
if((type->shared->state == H5T_STATE_TRANSIENT || type->shared->state == H5T_STATE_RDONLY) && (type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED)) {
- if(H5O_dec_rc_by_loc(&(type->oloc), dxpl_id) < 0)
+ if(H5O_dec_rc_by_loc(&(type->oloc)) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object")
if(H5O_close(&(type->oloc), NULL) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header")
- if(H5O_delete(file, dxpl_id, type->sh_loc.u.loc.oh_addr) < 0)
+ if(H5O_delete(file, type->sh_loc.u.loc.oh_addr) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header")
type->sh_loc.type = H5O_SHARE_TYPE_UNSHARED;
} /* end if */
@@ -486,7 +532,7 @@ H5T_committed(const H5T_t *type)
*-------------------------------------------------------------------------
*/
int
-H5T_link(const H5T_t *type, int adjust, hid_t dxpl_id)
+H5T_link(const H5T_t *type, int adjust)
{
int ret_value = -1; /* Return value */
@@ -496,7 +542,7 @@ H5T_link(const H5T_t *type, int adjust, hid_t dxpl_id)
HDassert(type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED);
/* Adjust the link count on the named datatype */
- if((ret_value = H5O_link(&type->oloc, adjust, dxpl_id)) < 0)
+ if((ret_value = H5O_link(&type->oloc, adjust)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_LINKCOUNT, FAIL, "unable to adjust named datatype link count")
done:
@@ -521,66 +567,44 @@ done:
hid_t
H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id)
{
- H5T_t *type = NULL; /* Datatype opened in file */
+ H5T_t *type = NULL; /* Datatype opened in file */
H5G_loc_t loc; /* Group location of object to open */
- H5G_name_t path; /* Datatype group hier. path */
- H5O_loc_t oloc; /* Datatype object location */
- H5O_type_t obj_type; /* Type of object at location */
- H5G_loc_t type_loc; /* Group object for datatype */
- hbool_t obj_found = FALSE; /* Object at 'name' found */
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl to use to open datatype */
- hid_t ret_value = FAIL; /* Return 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", "i*si", loc_id, name, tapl_id);
/* Check args */
if(H5G_loc(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(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name")
- /* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id, loc_id, FALSE) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
-
- /* Set up datatype location to fill in */
- type_loc.oloc = &oloc;
- type_loc.path = &path;
- H5G_loc_reset(&type_loc);
-
- /*
- * Find the named datatype object header and read the datatype message
- * from it.
- */
- if(H5G_loc_find(&loc, name, &type_loc/*out*/, tapl_id, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found")
- obj_found = TRUE;
-
- /* Check that the object found is the correct type */
- if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object type")
- if(obj_type != H5O_TYPE_NAMED_DATATYPE)
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a named datatype")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set API context")
+api_ctx_pushed = TRUE;
+/* Verify access property list and set up collective metadata if appropriate */
+if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info")
/* Open it */
- if(NULL == (type = H5T_open(&type_loc, dxpl_id)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype")
+ if(NULL == (type = H5T__open_name(&loc, name)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype")
/* Register the type and return the ID */
if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named datatype")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype")
done:
- if(ret_value < 0) {
+ /* Cleanup on error */
+ if(ret_value < 0)
if(type != NULL)
- H5T_close(type);
- else {
- if(obj_found && H5F_addr_defined(type_loc.oloc->addr))
- H5G_loc_free(&type_loc);
- } /* end else */
- } /* end if */
+ (void)H5T_close(type);
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* end H5Topen2() */
@@ -590,6 +614,9 @@ done:
*
* Purpose: Returns a copy of the datatype creation property list.
*
+ * Note: There are no datatype creation properties currently, just
+ * object creation ones.
+ *
* Return: Success: ID for a copy of the datatype creation
* property list. The property list ID should be
* released by calling H5Pclose().
@@ -604,11 +631,10 @@ done:
hid_t
H5Tget_create_plist(hid_t dtype_id)
{
- H5T_t *type; /* Datatype object for ID */
- H5P_genplist_t *tcpl_plist; /* Existing datatype creation propertty list */
- hid_t new_tcpl_id = FAIL; /* New datatype creation property list */
- herr_t status; /* Generic status value */
- hid_t ret_value; /* Return value */
+ H5T_t *type; /* Datatype object for ID */
+ herr_t status; /* Generic status value */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hid_t ret_value = FAIL; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", dtype_id);
@@ -617,29 +643,169 @@ H5Tget_create_plist(hid_t dtype_id)
if(NULL == (type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- /* Copy the default datatype creation property list */
- if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default creation property list")
- if((new_tcpl_id = H5P_copy_plist(tcpl_plist, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to copy the creation property list")
-
/* Check if the datatype is committed */
if((status = H5T_committed(type)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check whether datatype is committed")
/* Retrieve further information, if the datatype is committed */
if(status > 0) {
- H5P_genplist_t *new_plist; /* New datatype creation property list */
-
- /* Get property list object for new TCPL */
- if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_tcpl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, H5I_INVALID_HID, "can't set API context")
+api_ctx_pushed = TRUE;
- /* Retrieve any object creation properties */
- if(H5O_get_create_plist(&type->oloc, H5AC_ind_read_dxpl_id, new_plist) < 0)
+ /* Retrieve datatype creation properties */
+ if((ret_value = H5T__get_create_plist(type)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info")
} /* end if */
+done:
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context")
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Tget_create_plist() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tflush
+ *
+ * Purpose: Flushes all buffers associated with a named datatype to disk.
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Mike McGreevy
+ * May 19, 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Tflush(hid_t type_id)
+{
+ H5T_t *dt; /* Datatype for this operation */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("e", "i", type_id);
+
+ /* Check args */
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(!H5T_is_named(dt))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype")
+
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set API context")
+api_ctx_pushed = TRUE;
+/* Set up collective metadata if appropriate */
+if(H5CX_set_loc(type_id, TRUE) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info")
+
+ /* Flush metadata for named datatype */
+ if(H5T__flush(dt, type_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype")
+
+done:
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "can't reset API context")
+ FUNC_LEAVE_API(ret_value)
+} /* H5Tflush */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Trefresh
+ *
+ * Purpose: Refreshes all buffers associated with a named datatype.
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Mike McGreevy
+ * July 21, 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Trefresh(hid_t type_id)
+{
+ H5T_t *dt; /* Datatype for this operation */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("e", "i", type_id);
+
+ /* Check args */
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(!H5T_is_named(dt))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype")
+
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set API context")
+api_ctx_pushed = TRUE;
+/* Set up collective metadata if appropriate */
+if(H5CX_set_loc(type_id, TRUE) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info")
+
+ /* Call private function to refresh datatype object */
+ if((H5T__refresh(dt, type_id)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype")
+
+done:
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "can't reset API context")
+ FUNC_LEAVE_API(ret_value)
+} /* H5Trefresh */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__get_create_plist
+ *
+ * Purpose: Returns a copy of the datatype creation property list.
+ *
+ * Note: There are no datatype creation properties currently, just
+ * object creation ones.
+ *
+ * Return: Success: ID for a copy of the datatype creation
+ * property list. The property list ID should be
+ * released by calling H5Pclose().
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, December 13, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static hid_t
+H5T__get_create_plist(const H5T_t *type)
+{
+ H5P_genplist_t *tcpl_plist; /* Existing datatype creation propertty list */
+ H5P_genplist_t *new_plist; /* New datatype creation property list */
+ hid_t new_tcpl_id = FAIL; /* New datatype creation property list */
+ hid_t ret_value = FAIL; /* Return value */
+
+ FUNC_ENTER_STATIC_VOL
+
+ /* Sanity check */
+ HDassert(type);
+
+ /* Copy the default datatype creation property list */
+ if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "can't get default creation property list")
+ if((new_tcpl_id = H5P_copy_plist(tcpl_plist, TRUE)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to copy the creation property list")
+
+ /* Get property list object for new TCPL */
+ if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_tcpl_id)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "can't get property list")
+
+ /* Retrieve any object creation properties */
+ if(H5O_get_create_plist(&type->oloc, new_plist) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info")
+
/* Set the return value */
ret_value = new_tcpl_id;
@@ -649,8 +815,74 @@ done:
if(H5I_dec_app_ref(new_tcpl_id) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to close temporary object")
- FUNC_LEAVE_API(ret_value)
-} /* end H5Tget_create_plist() */
+ FUNC_LEAVE_NOAPI_VOL(ret_value)
+} /* end H5T__get_create_plist() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__open_name
+ *
+ * Purpose: Open a named datatype.
+ *
+ * Return: Success: Ptr to a new datatype.
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, December 13, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_t *
+H5T__open_name(const H5G_loc_t *loc, const char *name)
+{
+ H5T_t *dt = NULL; /* Datatype opened in file */
+ H5G_name_t path; /* Datatype group hier. path */
+ H5O_loc_t oloc; /* Datatype object location */
+ H5G_loc_t type_loc; /* Group object for datatype */
+ H5O_type_t obj_type; /* Type of object at location */
+ hbool_t obj_found = FALSE; /* Object at 'name' found */
+ H5T_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_PACKAGE_VOL
+
+ /* Sanity check */
+ HDassert(loc);
+ HDassert(name);
+
+ /* Set up datatype location to fill in */
+ type_loc.oloc = &oloc;
+ type_loc.path = &path;
+ H5G_loc_reset(&type_loc);
+
+ /*
+ * Find the named datatype object header and read the datatype message
+ * from it.
+ */
+ if(H5G_loc_find(loc, name, &type_loc/*out*/) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found")
+ obj_found = TRUE;
+
+ /* Check that the object found is the correct type */
+ if(H5O_obj_type(&oloc, &obj_type) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "can't get object type")
+ if(obj_type != H5O_TYPE_NAMED_DATATYPE)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "not a named datatype")
+
+ /* Open it */
+ if(NULL == (dt = H5T_open(&type_loc)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype")
+
+ ret_value = dt;
+
+done:
+ /* Error cleanup */
+ if(NULL == ret_value)
+ if(obj_found && H5F_addr_defined(type_loc.oloc->addr))
+ if(H5G_loc_free(&type_loc) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "can't free location")
+
+ FUNC_LEAVE_NOAPI_VOL(ret_value)
+} /* end H5T__open_name() */
/*-------------------------------------------------------------------------
@@ -668,7 +900,7 @@ done:
*-------------------------------------------------------------------------
*/
H5T_t *
-H5T_open(const H5G_loc_t *loc, hid_t dxpl_id)
+H5T_open(const H5G_loc_t *loc)
{
H5T_shared_t *shared_fo = NULL;
H5T_t *dt = NULL;
@@ -684,7 +916,7 @@ H5T_open(const H5G_loc_t *loc, hid_t dxpl_id)
H5E_clear_stack(NULL);
/* Open the datatype object */
- if(NULL == (dt = H5T_open_oid(loc, dxpl_id)))
+ if(NULL == (dt = H5T__open_oid(loc)))
HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found")
/* Add the datatype to the list of opened objects in the file */
@@ -771,7 +1003,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5T_open_oid
+ * Function: H5T__open_oid
*
* Purpose: Open a named datatype.
*
@@ -785,12 +1017,12 @@ done:
*-------------------------------------------------------------------------
*/
static H5T_t *
-H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id)
+H5T__open_oid(const H5G_loc_t *loc)
{
H5T_t *dt = NULL; /* Datatype from the file */
H5T_t *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC_TAG(loc->oloc->addr)
HDassert(loc);
@@ -799,7 +1031,7 @@ H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype")
/* Deserialize the datatype message into a datatype in memory */
- if(NULL == (dt = (H5T_t *)H5O_msg_read(loc->oloc, H5O_DTYPE_ID, NULL, dxpl_id)))
+ if(NULL == (dt = (H5T_t *)H5O_msg_read(loc->oloc, H5O_DTYPE_ID, NULL)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to load type message from object header")
/* Mark the type as named and open */
@@ -824,8 +1056,8 @@ done:
if(dt == NULL)
H5O_close(loc->oloc, NULL);
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5T_open_oid() */
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
+} /* end H5T__open_oid() */
/*-------------------------------------------------------------------------
@@ -853,3 +1085,73 @@ H5T_update_shared(H5T_t *dt)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5T_update_shared() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__flush
+ *
+ * Purpose: Internal routine to flushes a named datatype to disk.
+ *
+ * Note: This routine is needed so that there's a non-API routine
+ * that can set up VOL / SWMR info (which need a DXPL).
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * December 18, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5T__flush(H5T_t *dt, hid_t type_id)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC_VOL
+
+ /* Sanity check */
+ HDassert(dt);
+
+ /* To flush metadata and invoke flush callback if there is */
+ if(H5O_flush_common(&dt->oloc, type_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype and object flush callback")
+
+done:
+ FUNC_LEAVE_NOAPI_VOL(ret_value)
+} /* H5T__flush */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T__refresh
+ *
+ * Purpose: Internal routine to refresh a named datatype.
+ *
+ * Note: This routine is needed so that there's a non-API routine
+ * that can set up VOL / SWMR info (which need a DXPL).
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * December 18, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5T__refresh(H5T_t *dt, hid_t type_id)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC_VOL
+
+ /* Sanity check */
+ HDassert(dt);
+
+ /* Call private function to refresh datatype object */
+ if((H5O_refresh_metadata(type_id, dt->oloc)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype")
+
+done:
+ FUNC_LEAVE_NOAPI_VOL(ret_value)
+} /* H5T__refresh */
+