diff options
-rw-r--r-- | src/H5A.c | 6 | ||||
-rw-r--r-- | src/H5D.c | 38 | ||||
-rw-r--r-- | src/H5Gcompact.c | 2 | ||||
-rw-r--r-- | src/H5Gdeprec.c | 2 | ||||
-rw-r--r-- | src/H5Gobj.c | 30 | ||||
-rw-r--r-- | src/H5Gstab.c | 2 | ||||
-rw-r--r-- | src/H5O.c | 287 | ||||
-rw-r--r-- | src/H5Odtype.c | 8 | ||||
-rw-r--r-- | src/H5Olayout.c | 7 | ||||
-rw-r--r-- | src/H5Oprivate.h | 12 | ||||
-rw-r--r-- | src/H5Oshared.c | 2 | ||||
-rw-r--r-- | src/H5S.c | 30 | ||||
-rwxr-xr-x | src/H5SM.c | 7 | ||||
-rw-r--r-- | src/H5Sprivate.h | 2 | ||||
-rw-r--r-- | src/H5Tcommit.c | 2 | ||||
-rw-r--r-- | test/dsets.c | 52 | ||||
-rw-r--r-- | test/ohdr.c | 12 |
17 files changed, 266 insertions, 235 deletions
@@ -417,7 +417,7 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, attr->obj_opened = TRUE; /* Create the attribute message and save the attribute index */ - if(H5O_modify(&(attr->oloc), H5O_ATTR_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, attr, dxpl_id) < 0) + if(H5O_msg_create(&(attr->oloc), H5O_ATTR_ID, 0, H5O_UPDATE_TIME, attr, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to update attribute header messages") /* Register the new attribute and get an ID for it */ @@ -828,7 +828,7 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, FAIL, "attribute not found") /* Modify the attribute data */ - if(H5O_modify(&(attr->oloc), H5O_ATTR_ID, idx, 0, H5O_UPDATE_DATA_ONLY|H5O_UPDATE_TIME, attr, dxpl_id) < 0) + if(H5O_write(&(attr->oloc), H5O_ATTR_ID, idx, 0, H5O_UPDATE_DATA_ONLY|H5O_UPDATE_TIME, attr, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to update attribute header messages") } /* end if */ @@ -1380,7 +1380,7 @@ H5A_rename(H5O_loc_t *loc, const char *old_name, const char *new_name, hid_t dxp found_attr.initialized = TRUE; /* Modify the attribute message */ - if(H5O_modify(loc, H5O_ATTR_ID, idx, 0, H5O_UPDATE_TIME, &found_attr, dxpl_id) < 0) + if(H5O_write(loc, H5O_ATTR_ID, idx, 0, H5O_UPDATE_TIME, &found_attr, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to update attribute header messages") /* Close the attribute */ @@ -1302,7 +1302,7 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to protect dataset object header") /* Write new fill value message */ - if(H5O_append(file, dxpl_id, oh, H5O_FILL_NEW_ID, H5O_MSG_FLAG_CONSTANT, &fill, &oh_flags) < 0) + if(H5O_append(file, dxpl_id, oh, H5O_FILL_NEW_ID, H5O_MSG_FLAG_CONSTANT, 0, &fill, &oh_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update fill value header message") /* If there is valid information for the old fill value struct, update it */ @@ -1317,7 +1317,7 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT,FAIL,"unable to copy fill value") /* Write old fill value */ - if(fill_prop->buf && H5O_append(file, dxpl_id, oh, H5O_FILL_ID, H5O_MSG_FLAG_CONSTANT, fill_prop, &oh_flags) < 0) + if(fill_prop->buf && H5O_append(file, dxpl_id, oh, H5O_FILL_ID, H5O_MSG_FLAG_CONSTANT, 0, fill_prop, &oh_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update fill value header message") /* Update dataset creation property */ @@ -1327,7 +1327,7 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) } /* end if */ /* Update the type and space header messages */ - if(H5O_append(file, dxpl_id, oh, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_SHARED, type, &oh_flags) < 0 || + if(H5O_append(file, dxpl_id, oh, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_SHARED, 0, type, &oh_flags) < 0 || H5S_append(file, dxpl_id, oh, dset->shared->space, &oh_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update type or space header messages") @@ -1338,7 +1338,7 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve pipeline filter") - if(pline.nused > 0 && H5O_append(file, dxpl_id, oh, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, &pline, &oh_flags) < 0) + if(pline.nused > 0 && H5O_append(file, dxpl_id, oh, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, 0, &pline, &oh_flags) < 0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update filter header message") } /* end if */ @@ -1351,7 +1351,7 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") /* Update external storage message */ - if (efl->nused > 0) { + if(efl->nused > 0) { size_t heap_size = H5HL_ALIGN(1); size_t u; @@ -1362,7 +1362,7 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) H5HL_insert(file, dxpl_id, efl->heap_addr, (size_t)1, "") == (size_t)(-1)) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create external file list name heap") - for (u = 0; u < efl->nused; ++u) { + for(u = 0; u < efl->nused; ++u) { size_t offset = H5HL_insert(file, dxpl_id, efl->heap_addr, HDstrlen(efl->slot[u].name) + 1, efl->slot[u].name); @@ -1372,16 +1372,16 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, FAIL, "unable to insert URL into name heap") efl->slot[u].name_offset = offset; - } + } /* end for */ - if (H5O_append(file, dxpl_id, oh, H5O_EFL_ID, H5O_MSG_FLAG_CONSTANT, efl, &oh_flags) < 0) + if(H5O_append(file, dxpl_id, oh, H5O_EFL_ID, H5O_MSG_FLAG_CONSTANT, 0, efl, &oh_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update external file list message") - } + } /* end if */ - /* Update layout message */ + /* Create layout message */ /* (Don't make layout message constant unless allocation time is early, since space may not be allocated) */ - /* Note: this is relying on H5D_alloc_storage not calling H5O_modify during dataset creation */ - if (H5D_COMPACT != layout->type && H5O_append(file, dxpl_id, oh, H5O_LAYOUT_ID, (alloc_time == H5D_ALLOC_TIME_EARLY ? H5O_MSG_FLAG_CONSTANT : 0), layout, &oh_flags) < 0) + /* Note: this is relying on H5D_alloc_storage not calling H5O_write during dataset creation */ + if(H5O_append(file, dxpl_id, oh, H5O_LAYOUT_ID, ((alloc_time == H5D_ALLOC_TIME_EARLY && H5D_COMPACT != layout->type) ? H5O_MSG_FLAG_CONSTANT : 0), 0, layout, &oh_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout") #ifdef H5O_ENABLE_BOGUS @@ -1393,7 +1393,7 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) #endif /* H5O_ENABLE_BOGUS */ /* Add a modification time message. */ - if (H5O_touch_oh(file, dxpl_id, oh, TRUE, &oh_flags) < 0) + if(H5O_touch_oh(file, dxpl_id, oh, TRUE, &oh_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time message") done: @@ -2170,7 +2170,7 @@ H5D_close(H5D_t *dataset) case H5D_COMPACT: /* Update header message of layout for compact dataset. */ if(dataset->shared->layout.u.compact.dirty) { - if(H5O_modify(&(dataset->oloc), H5O_LAYOUT_ID, 0, 0, H5O_UPDATE_TIME, &(dataset->shared->layout), H5AC_dxpl_id)<0) + if(H5O_write(&(dataset->oloc), H5O_LAYOUT_ID, 0, 0, H5O_UPDATE_TIME, &(dataset->shared->layout), H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to update layout message") dataset->shared->layout.u.compact.dirty = FALSE; } /* end if */ @@ -2305,7 +2305,7 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) if (changed>0){ /* Save the new dataspace in the file if necessary */ - if(H5S_modify (&(dataset->oloc), space, TRUE, dxpl_id) < 0) + if(H5S_write(&(dataset->oloc), space, TRUE, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace") /* Update the index values for the cached chunks for this dataset */ @@ -2438,7 +2438,7 @@ H5D_get_file (const H5D_t *dset) *------------------------------------------------------------------------- */ herr_t -H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_alloc_t time_alloc, +H5D_alloc_storage(H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_alloc_t time_alloc, hbool_t update_time, hbool_t full_overwrite) { struct H5O_layout_t *layout; /* The dataset's layout information */ @@ -2563,7 +2563,7 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo * set the address. (this is improves forward compatibility). */ if(time_alloc != H5D_ALLOC_CREATE && addr_set) - if(H5O_modify(&(dset->oloc), H5O_LAYOUT_ID, 0, H5O_MSG_FLAG_CONSTANT, update_time, &(dset->shared->layout), dxpl_id) < 0) + if(H5O_write(&(dset->oloc), H5O_LAYOUT_ID, 0, H5O_MSG_FLAG_CONSTANT, update_time, &(dset->shared->layout), dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout message") } /* end if */ @@ -3353,7 +3353,7 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) *------------------------------------------------------------------------- */ /* Save the new dataspace in the file if necessary */ - if(H5S_modify(&(dset->oloc), space, TRUE, dxpl_id) < 0) + if(H5S_write(&(dset->oloc), space, TRUE, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace") /* Update the index values for the cached chunks for this dataset */ @@ -3468,7 +3468,7 @@ H5D_flush(const H5F_t *f, hid_t dxpl_id, unsigned flags) case H5D_COMPACT: if(dataset->shared->layout.u.compact.dirty) { - if(H5O_modify(&(dataset->oloc), H5O_LAYOUT_ID, 0, 0, H5O_UPDATE_TIME, &(dataset->shared->layout), dxpl_id)<0) + if(H5O_write(&(dataset->oloc), H5O_LAYOUT_ID, 0, 0, H5O_UPDATE_TIME, &(dataset->shared->layout), dxpl_id)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message") dataset->shared->layout.u.compact.dirty = FALSE; } /* end if */ diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index 7e7266a..e321155 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -194,7 +194,7 @@ H5G_compact_insert(H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk, HDassert(obj_lnk); /* Insert link message into group */ - if(H5O_modify(grp_oloc, H5O_LINK_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, obj_lnk, dxpl_id) < 0) + if(H5O_msg_create(grp_oloc, H5O_LINK_ID, 0, H5O_UPDATE_TIME, obj_lnk, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") done: diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 3be71a8..5163748 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -619,7 +619,7 @@ H5G_set_comment(H5G_loc_t *loc, const char *name, const char *buf, hid_t dxpl_id if(buf && *buf) { /* Casting away const OK -QAK */ comment.s = (char *)buf; - if(H5O_modify(obj_loc.oloc, H5O_NAME_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, &comment, dxpl_id) < 0) + if(H5O_msg_create(obj_loc.oloc, H5O_NAME_ID, 0, H5O_UPDATE_TIME, &comment, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to set comment object header message") } /* end if */ diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 32febfc..8a223a7 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -194,11 +194,11 @@ H5G_obj_create(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, /* Check for format of group to create */ if(use_latest_format) { /* Insert link info message */ - if(H5O_modify(oloc, H5O_LINFO_ID, H5O_NEW_MESG, 0, 0, linfo, dxpl_id) < 0) + if(H5O_msg_create(oloc, H5O_LINFO_ID, 0, 0, linfo, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") /* Insert group info message */ - if(H5O_modify(oloc, H5O_GINFO_ID, H5O_NEW_MESG, H5O_MSG_FLAG_CONSTANT, H5O_UPDATE_TIME, ginfo, dxpl_id) < 0) + if(H5O_msg_create(oloc, H5O_GINFO_ID, H5O_MSG_FLAG_CONSTANT, H5O_UPDATE_TIME, ginfo, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") } /* end if */ else { @@ -482,11 +482,11 @@ H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, /* Convert group to "new format" group, in order to hold the information */ /* Insert link info message */ - if(H5O_modify(grp_oloc, H5O_LINFO_ID, H5O_NEW_MESG, 0, 0, &new_linfo, dxpl_id) < 0) + if(H5O_msg_create(grp_oloc, H5O_LINFO_ID, 0, 0, &new_linfo, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") /* Insert group info message */ - if(H5O_modify(grp_oloc, H5O_GINFO_ID, H5O_NEW_MESG, H5O_MSG_FLAG_CONSTANT, 0, &new_ginfo, dxpl_id) < 0) + if(H5O_msg_create(grp_oloc, H5O_GINFO_ID, H5O_MSG_FLAG_CONSTANT, H5O_UPDATE_TIME, &new_ginfo, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") /* Set up user data for iteration */ @@ -541,7 +541,7 @@ H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, /* Increment the number of objects in this group */ if(!use_old_format) { linfo.nlinks++; - if(H5O_modify(grp_oloc, H5O_LINFO_ID, 0, 0, H5O_UPDATE_TIME, &linfo, dxpl_id) < 0) + if(H5O_write(grp_oloc, H5O_LINFO_ID, 0, 0, H5O_UPDATE_TIME, &linfo, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update link info message") } /* end if */ @@ -906,10 +906,26 @@ H5G_obj_remove_update_linfo(H5O_loc_t *oloc, H5O_linfo_t *linfo, hid_t dxpl_id) /* If ok, insert links as link messages */ if(can_convert) { + struct H5O_t *oh = NULL; /* Pointer to group's object header */ + unsigned oh_flags = H5AC__DIRTIED_FLAG; + + /* Get a pointer to the object header itself */ + if((oh = H5O_protect(oloc, dxpl_id)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to protect dataset object header") + /* Insert link messages into group */ for(u = 0; u < linfo->nlinks; u++) - if(H5O_modify(oloc, H5O_LINK_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, &(ltable.lnks[u]), dxpl_id) < 0) + if(H5O_append(oloc->file, dxpl_id, oh, H5O_LINK_ID, 0, H5O_UPDATE_TIME, &(ltable.lnks[u]), &oh_flags) < 0) { + /* Release object header */ + if(H5O_unprotect(oloc, oh, dxpl_id, oh_flags) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to unprotect dataset object header") + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") + } /* end if */ + + /* Release object header */ + if(H5O_unprotect(oloc, oh, dxpl_id, oh_flags) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to unprotect dataset object header") /* Remove the dense storage */ if(H5G_dense_delete(oloc->file, dxpl_id, linfo, FALSE) < 0) @@ -924,7 +940,7 @@ H5G_obj_remove_update_linfo(H5O_loc_t *oloc, H5O_linfo_t *linfo, hid_t dxpl_id) } /* end if */ /* Update link info in the object header */ - if(H5O_modify(oloc, H5O_LINFO_ID, 0, 0, H5O_UPDATE_TIME, linfo, dxpl_id) < 0) + if(H5O_write(oloc, H5O_LINFO_ID, 0, 0, H5O_UPDATE_TIME, linfo, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update link info message") done: diff --git a/src/H5Gstab.c b/src/H5Gstab.c index c617d6e..2e41dc5 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -186,7 +186,7 @@ H5G_stab_create(H5O_loc_t *grp_oloc, hid_t dxpl_id, const H5O_ginfo_t *ginfo, * Insert the symbol table message into the object header and the symbol * table entry. */ - if(H5O_modify(grp_oloc, H5O_STAB_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, stab, dxpl_id) < 0) + if(H5O_msg_create(grp_oloc, H5O_STAB_ID, 0, H5O_UPDATE_TIME, stab, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") done: @@ -54,7 +54,7 @@ const H5O_msg_class_t *decode_type; \ \ /* Check for shared message */ \ - if ((MSG)->flags & H5O_MSG_FLAG_SHARED) \ + if((MSG)->flags & H5O_MSG_FLAG_SHARED) \ decode_type = H5O_MSG_SHARED; \ else \ decode_type = (MSG)->type; \ @@ -123,12 +123,12 @@ static void *H5O_read_real(H5F_t *f, H5O_t *oh, unsigned type_id, int sequence, void *mesg, hid_t dxpl_id); static unsigned H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t **type_p, int sequence); -static int H5O_modify_real(H5O_loc_t *loc, const H5O_msg_class_t *type, - int overwrite, unsigned flags, unsigned update_flags, const void *mesg, +static herr_t H5O_write_real(H5O_loc_t *loc, const H5O_msg_class_t *type, + unsigned overwrite, unsigned flags, unsigned update_flags, const void *mesg, hid_t dxpl_id); -static int H5O_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, - const H5O_msg_class_t *type, unsigned flags, const void *mesg, - unsigned * oh_flags_ptr); +static herr_t H5O_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, + const H5O_msg_class_t *type, unsigned mesg_flags, unsigned update_flags, + const void *mesg, unsigned * oh_flags_ptr); static herr_t H5O_remove_real(const H5O_loc_t *loc, const H5O_msg_class_t *type, int sequence, H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id); static herr_t H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh); @@ -136,9 +136,9 @@ static unsigned H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *flags, const H5O_msg_class_t *orig_type, const void *orig_mesg, H5O_shared_t *sh_mesg, const H5O_msg_class_t **new_type, const void **new_mesg, hid_t dxpl_id, unsigned * oh_flags_ptr); -static herr_t H5O_write_mesg(H5O_t *oh, unsigned idx, const H5O_msg_class_t *type, - const void *mesg, unsigned flags, unsigned update_flags, - unsigned * oh_flags_ptr); +static herr_t H5O_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx, + const H5O_msg_class_t *type, const void *mesg, unsigned flags, + unsigned update_flags, unsigned * oh_flags_ptr); static herr_t H5O_iterate_real(const H5O_loc_t *loc, const H5O_msg_class_t *type, H5AC_protect_t prot, hbool_t internal, H5O_mesg_operator_t op, void *op_data, hid_t dxpl_id); static const H5O_obj_class_t *H5O_obj_class(H5O_loc_t *loc, hid_t dxpl_id); @@ -1724,30 +1724,21 @@ done: /*------------------------------------------------------------------------- - * Function: H5O_modify + * Function: H5O_write * * Purpose: Modifies an existing message or creates a new message. - * The cache fields in that symbol table entry ENT are *not* - * updated, you must do that separately because they often - * depend on multiple object header messages. Besides, we - * don't know which messages will be constant and which will - * not. - * - * The OVERWRITE argument is either a sequence number of a - * message to overwrite (usually zero) or the constant - * H5O_NEW_MESG (-1) to indicate that a new message is to - * be created. If the message to overwrite doesn't exist then - * it is created (but only if it can be inserted so its sequence - * number is OVERWRITE; that is, you can create a message with - * the sequence number 5 if there is no message with sequence - * number 4). - * - * The UPDATE_TIME argument is a boolean that allows the caller - * to skip updating the modification time. This is useful when - * several calls to H5O_modify will be made in a sequence. * - * Return: Success: The sequence number of the message that - * was modified or created. + * The OVERWRITE argument is a sequence number of a + * message to overwrite (usually zero). + * If the message to overwrite doesn't exist then this routine + * fails. + * + * The UPDATE_FLAGS argument are flags that allow the caller + * to skip updating the modification time or reseting the message + * data. This is useful when several calls to H5O_write will be + * made in a sequence. + * + * Return: Success: Non-negative * * Failure: Negative * @@ -1759,15 +1750,15 @@ done: */ /* JAMES: this will probably get put through its paces when extending shared * dataspaces */ -int -H5O_modify(H5O_loc_t *loc, unsigned type_id, int overwrite, +herr_t +H5O_write(H5O_loc_t *loc, unsigned type_id, unsigned overwrite, unsigned mesg_flags, unsigned update_flags, void *mesg, hid_t dxpl_id) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - htri_t shared_mess; - int ret_value; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + htri_t shared_mesg; /* Whether the message should be shared */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5O_modify, FAIL) + FUNC_ENTER_NOAPI(H5O_write, FAIL) /* check args */ HDassert(loc); @@ -1780,48 +1771,37 @@ H5O_modify(H5O_loc_t *loc, unsigned type_id, int overwrite, HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); /* Should this message be written as a SOHM? */ - if((shared_mess = H5SM_try_share(loc->file, dxpl_id, type_id, mesg)) >0) - { + if((shared_mesg = H5SM_try_share(loc->file, dxpl_id, type_id, mesg)) > 0) /* Mark the message as shared */ mesg_flags |= H5O_MSG_FLAG_SHARED; - - } else if(shared_mess < 0) + else if(shared_mesg < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "error while trying to share message"); /* Call the "real" modify routine */ - if((ret_value = H5O_modify_real(loc, type, overwrite, mesg_flags, update_flags, mesg, dxpl_id)) < 0) + if(H5O_write_real(loc, type, overwrite, mesg_flags, update_flags, mesg, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header message") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_modify() */ +} /* end H5O_write() */ /*------------------------------------------------------------------------- - * Function: H5O_modify_real + * Function: H5O_write_real * * Purpose: Modifies an existing message or creates a new message. - * The cache fields in that symbol table entry ENT are *not* - * updated, you must do that separately because they often - * depend on multiple object header messages. Besides, we - * don't know which messages will be constant and which will - * not. - * - * The OVERWRITE argument is either a sequence number of a - * message to overwrite (usually zero) or the constant - * H5O_NEW_MESG (-1) to indicate that a new message is to - * be created. If the message to overwrite doesn't exist then - * it is created (but only if it can be inserted so its sequence - * number is OVERWRITE; that is, you can create a message with - * the sequence number 5 if there is no message with sequence - * number 4). - * - * The UPDATE_TIME argument is a boolean that allows the caller - * to skip updating the modification time. This is useful when - * several calls to H5O_modify will be made in a sequence. * - * Return: Success: The sequence number of the message that - * was modified or created. + * The OVERWRITE argument is a sequence number of a + * message to overwrite (usually zero). + * If the message to overwrite doesn't exist then this routine + * fails. + * + * The UPDATE_FLAGS argument are flags that allow the caller + * to skip updating the modification time or reseting the message + * data. This is useful when several calls to H5O_write will be + * made in a sequence. + * + * Return: Success: Non-negative * * Failure: Negative * @@ -1831,21 +1811,21 @@ done: * *------------------------------------------------------------------------- */ -static int -H5O_modify_real(H5O_loc_t *loc, const H5O_msg_class_t *type, int overwrite, +static herr_t +H5O_write_real(H5O_loc_t *loc, const H5O_msg_class_t *type, unsigned overwrite, unsigned mesg_flags, unsigned update_flags, const void *mesg, hid_t dxpl_id) { H5O_t *oh = NULL; unsigned oh_flags = H5AC__NO_FLAGS_SET; - int sequence; + int sequence; /* Sequence # of message type to modify */ unsigned idx; /* Index of message to modify */ H5O_mesg_t *idx_msg; /* Pointer to message to modify */ H5O_shared_t sh_mesg; - const H5O_msg_class_t *write_type = type; /* Type of message to be written */ - const void *write_mesg = mesg; /* Actual message being written */ - int ret_value; + const H5O_msg_class_t *write_type = type; /* Type of message to be written */ + const void *write_mesg = mesg; /* Actual message being written */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5O_modify_real) + FUNC_ENTER_NOAPI_NOINIT(H5O_write_real) /* check args */ HDassert(loc); @@ -1864,33 +1844,19 @@ H5O_modify_real(H5O_loc_t *loc, const H5O_msg_class_t *type, int overwrite, HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") /* Count similar messages */ - for(idx = 0, sequence = -1, idx_msg=&oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) { + for(idx = 0, sequence = -1, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) { if(type->id != idx_msg->type->id) continue; - if(++sequence == overwrite) + if(++sequence == (int)overwrite) break; } /* end for */ /* Was the right message found? */ - if(overwrite >= 0 && (idx >= oh->nmesgs || sequence != overwrite)) { - /* No, but can we insert a new one with this sequence number? */ - if(overwrite == sequence + 1) - overwrite = -1; - else - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message not found") - } /* end if */ + if(sequence != (int)overwrite) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message not found") - /* Check for creating new message */ - if(overwrite < 0) { - /* Create a new message */ - /* JAMES: why is sh_mesg passed in here? Is it ever used? */ - if((idx = H5O_new_mesg(loc->file, oh, &mesg_flags, type, mesg, &sh_mesg, &write_type, &write_mesg, dxpl_id, &oh_flags)) == UFAIL) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create new message") - - /* Set the correct sequence number for the message created */ - sequence++; - - } else if(oh->mesg[idx].flags & H5O_MSG_FLAG_CONSTANT) { + /* Check for modifying a constant message */ + if(oh->mesg[idx].flags & H5O_MSG_FLAG_CONSTANT) { HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify constant message") } else if(oh->mesg[idx].flags & H5O_MSG_FLAG_SHARED) { /* This message is shared, but it's being modified. This is valid if @@ -1898,54 +1864,97 @@ H5O_modify_real(H5O_loc_t *loc, const H5O_msg_class_t *type, int overwrite, * First, make sure it's not a committed message; these can't ever * be modified. */ - if(((H5O_shared_t*) oh->mesg[idx].native)->flags & H5O_COMMITTED_FLAG) + if(((H5O_shared_t*)oh->mesg[idx].native)->flags & H5O_COMMITTED_FLAG) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify committed message") /* Remove the old message from the SOHM index */ if(H5SM_try_delete(loc->file, dxpl_id, oh->mesg[idx].type->id, oh->mesg[idx].native) < 0) HGOTO_ERROR (H5E_OHDR, H5E_CANTFREE, FAIL, "unable to delete message from SOHM table") - /* Now this message is no longer shared and we can safely overwrite - * it. + /* Now this message is no longer shared and we can safely overwrite it. * We need to make sure that the message we're writing is shared, * though, and that the library doesn't try to reset the current * message like it would in a normal overwrite (this message is - * realy a shared pointer, not a real - * message). + * realy a shared pointer, not a real message). * JAMES: will this break if a shared message is overwritten with a larger * non-shared message? */ HDassert(H5O_is_shared(type->id, mesg) > 0); /* JAMES: this should work with * replacement messages that aren't shared, too. */ - if(H5O_get_share(type->id, loc->file, mesg, &sh_mesg)<0) + if(H5O_get_share(type->id, loc->file, mesg, &sh_mesg) < 0) HGOTO_ERROR (H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message") /* Instead of writing the original message, write a shared message */ - write_type = H5O_msg_class_g[H5O_SHARED_ID]; + write_type = H5O_MSG_SHARED; write_mesg = &sh_mesg; - } + } /* end if */ /* Write the information to the message */ - if(H5O_write_mesg(oh, idx, write_type, write_mesg, mesg_flags, update_flags, &oh_flags) < 0) + if(H5O_write_mesg(loc->file, dxpl_id, oh, idx, write_type, write_mesg, mesg_flags, update_flags, &oh_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to write message") - - /* Update the modification time message if any */ - if(update_flags & H5O_UPDATE_TIME) - H5O_touch_oh(loc->file, dxpl_id, oh, FALSE, &oh_flags); #ifdef H5O_DEBUG H5O_assert(oh); #endif /* H5O_DEBUG */ - /* Set return value */ - ret_value = sequence; +done: + if(oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, oh_flags) < 0) + HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_write_real() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_msg_create + * + * Purpose: Create a new object header message + * + * Return: Success: The sequence number of the message that + * was created. + * + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 1 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_msg_create(H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, + unsigned update_flags, void *mesg, hid_t dxpl_id) +{ + H5O_t *oh = NULL; /* Object header */ + unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Metadata cache flags for object header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5O_msg_create, FAIL) + + /* check args */ + HDassert(loc); + HDassert(type_id < NELMTS(H5O_msg_class_g)); + HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); + HDassert(mesg); + + /* Check for write access on the file */ + if(0 == (loc->file->intent & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file") + + /* Protect the object header */ + if(NULL == (oh = H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") + + /* Go append message to object header */ + if(H5O_append(loc->file, dxpl_id, oh, type_id, mesg_flags, update_flags, mesg, &oh_flags) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to append to object header") done: if(oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, oh_flags) < 0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_modify_real() */ +} /* end H5O_msg_create() */ /*------------------------------------------------------------------------- @@ -2033,8 +2042,9 @@ done: /*------------------------------------------------------------------------- * Function: H5O_append * - * Purpose: Simplified version of H5O_modify, used when creating a new - * object header message (usually during object creation) + * Purpose: Simplified version of H5O_msg_create, used when creating a new + * object header message (usually during object creation) and + * several messages will be added to the object header at once. * * Return: Success: The sequence number of the message that * was created. @@ -2047,13 +2057,13 @@ done: * *------------------------------------------------------------------------- */ -int +herr_t H5O_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned type_id, unsigned mesg_flags, - void *mesg, unsigned * oh_flags_ptr) + unsigned update_flags, void *mesg, unsigned * oh_flags_ptr) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - htri_t shared_mess; /* Should this message be stored in the Shared Message table? */ - int ret_value; /* Return value */ + htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_append, FAIL) @@ -2068,15 +2078,13 @@ H5O_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned type_id, unsigned mesg_f HDassert(oh_flags_ptr); /* Should this message be written as a SOHM? */ - if((shared_mess = H5SM_try_share(f, dxpl_id, type_id, mesg)) >0) - { + if((shared_mesg = H5SM_try_share(f, dxpl_id, type_id, mesg)) > 0) /* Mark the message as shared */ mesg_flags |= H5O_MSG_FLAG_SHARED; - } - else if(shared_mess < 0) + else if(shared_mesg < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "error determining if message should be shared"); - if((ret_value = H5O_append_real( f, dxpl_id, oh, type, mesg_flags, mesg, oh_flags_ptr)) < 0) + if(H5O_append_real(f, dxpl_id, oh, type, mesg_flags, update_flags, mesg, oh_flags_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to append to object header") done: @@ -2087,8 +2095,9 @@ done: /*------------------------------------------------------------------------- * Function: H5O_append_real * - * Purpose: Simplified version of H5O_modify, used when creating a new - * object header message (usually during object creation) + * Purpose: Simplified version of H5O_msg_create, used when creating a new + * object header message (usually during object creation) and + * several messages will be added to the object header at once. * * Return: Success: The sequence number of the message that * was created. @@ -2101,13 +2110,13 @@ done: * *------------------------------------------------------------------------- */ -static int +static herr_t H5O_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, - unsigned mesg_flags, const void *mesg, unsigned * oh_flags_ptr) + unsigned mesg_flags, unsigned update_flags, const void *mesg, unsigned * oh_flags_ptr) { unsigned idx; /* Index of message to modify */ H5O_shared_t sh_mesg; - int ret_value; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_append_real) @@ -2124,15 +2133,12 @@ H5O_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create new message") /* Write the information to the message */ - if(H5O_write_mesg(oh, idx, type, mesg, mesg_flags, 0, oh_flags_ptr) < 0) + if(H5O_write_mesg(f, dxpl_id, oh, idx, type, mesg, mesg_flags, update_flags, oh_flags_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to write message") #ifdef H5O_DEBUG H5O_assert(oh); #endif /* H5O_DEBUG */ - /* Set return value */ - ret_value = idx; - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_append_real () */ @@ -2175,20 +2181,21 @@ H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *mesg_flags, const H5O_msg_class_t *o /* Check for shared message */ if(*mesg_flags & H5O_MSG_FLAG_SHARED) { - HDmemset(sh_mesg, 0, sizeof(H5O_shared_t)); - - if ((NULL == orig_type->is_shared) || (NULL == orig_type->get_share)) - HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, UFAIL, "message class is not sharable"); - if ((is_shared = (orig_type->is_shared)(orig_mesg)) == FALSE) { + if((NULL == orig_type->is_shared) || (NULL == orig_type->get_share)) + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, UFAIL, "message class is not sharable") + if((is_shared = (orig_type->is_shared)(orig_mesg)) == FALSE) { /* * If the message isn't shared then turn off the shared bit * and treat it as an unshared message. */ *mesg_flags &= ~H5O_MSG_FLAG_SHARED; + *new_type = orig_type; + *new_mesg = orig_mesg; } else if(is_shared > 0) { /* Message is shared. Get shared message, change message type, * and use shared information */ - if ((orig_type->get_share)(f, orig_mesg, sh_mesg/*out*/) < 0) + HDmemset(sh_mesg, 0, sizeof(H5O_shared_t)); + if((orig_type->get_share)(f, orig_mesg, sh_mesg/*out*/) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, UFAIL, "can't get shared message") *new_type = H5O_MSG_SHARED; @@ -2232,9 +2239,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_write_mesg(H5O_t *oh, unsigned idx, const H5O_msg_class_t *type, - const void *mesg, unsigned mesg_flags, unsigned update_flags, - unsigned * oh_flags_ptr) +H5O_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx, + const H5O_msg_class_t *type, const void *mesg, unsigned mesg_flags, + unsigned update_flags, unsigned *oh_flags_ptr) { H5O_mesg_t *idx_msg; /* Pointer to message to modify */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2242,6 +2249,7 @@ H5O_write_mesg(H5O_t *oh, unsigned idx, const H5O_msg_class_t *type, FUNC_ENTER_NOAPI_NOINIT(H5O_write_mesg) /* check args */ + HDassert(f); HDassert(oh); HDassert(type); HDassert(mesg); @@ -2258,8 +2266,15 @@ H5O_write_mesg(H5O_t *oh, unsigned idx, const H5O_msg_class_t *type, if(NULL == (idx_msg->native = (type->copy)(mesg, idx_msg->native, update_flags))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy message to object header") + /* Update the message flags and mark the message as modified */ idx_msg->flags = mesg_flags; idx_msg->dirty = TRUE; + + /* Update the modification time message if any */ + if(update_flags & H5O_UPDATE_TIME) + H5O_touch_oh(f, dxpl_id, oh, FALSE, oh_flags_ptr); + + /* Mark the object header as modified */ *oh_flags_ptr |= H5AC__DIRTIED_FLAG; done: @@ -2613,7 +2628,7 @@ done: */ static herr_t H5O_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned sequence, unsigned * oh_flags_ptr, void *_udata/*in,out*/) + unsigned sequence, unsigned *oh_flags_ptr, void *_udata/*in,out*/) { H5O_iter_ud1_t *udata = (H5O_iter_ud1_t *)_udata; /* Operator user data */ htri_t try_remove = FALSE; /* Whether to try removing a message */ diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 1a3fd4c..feae7e7 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -33,11 +33,9 @@ static void *H5O_dtype_copy(const void *_mesg, void *_dest, unsigned update_flag static size_t H5O_dtype_size(const H5F_t *f, const void *_mesg); static herr_t H5O_dtype_reset(void *_mesg); static herr_t H5O_dtype_free(void *_mesg); -static herr_t H5O_dtype_get_share(H5F_t *f, const void *_mesg, - H5O_shared_t *sh); -static herr_t H5O_dtype_set_share(H5F_t *f, void *_mesg, - const H5O_shared_t *sh); -static herr_t H5O_dtype_is_shared (const void *_mesg); +static herr_t H5O_dtype_get_share(H5F_t *f, const void *_mesg, H5O_shared_t *sh); +static herr_t H5O_dtype_set_share(H5F_t *f, void *_mesg, const H5O_shared_t *sh); +static herr_t H5O_dtype_is_shared(const void *_mesg); static herr_t H5O_dtype_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type, const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata); static herr_t H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 88a41e7..f8ec192 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -315,8 +315,11 @@ H5O_layout_encode(H5F_t *f, uint8_t *p, const void *_mesg) UINT16ENCODE(p, mesg->u.compact.size); /* Raw data */ - if(mesg->u.compact.size > 0 && mesg->u.compact.buf) { - HDmemcpy(p, mesg->u.compact.buf, mesg->u.compact.size); + if(mesg->u.compact.size > 0) { + if(mesg->u.compact.buf) + HDmemcpy(p, mesg->u.compact.buf, mesg->u.compact.size); + else + HDmemset(p, 0, mesg->u.compact.size); p += mesg->u.compact.size; } /* end if */ break; diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index dcddfa2..acb291f 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -63,7 +63,6 @@ typedef uint64_t H5SM_fheap_id_t; /* Object header macros */ #define H5O_MESG_MAX_SIZE 65536 /*max obj header message size */ -#define H5O_NEW_MESG (-1) /*new message */ #define H5O_ALL (-1) /* Operate on all messages of type */ #define H5O_FIRST (-2) /* Operate on first message of type */ @@ -389,15 +388,18 @@ H5_DLL int H5O_count(H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id); H5_DLL htri_t H5O_exists(H5O_loc_t *loc, unsigned type_id, int sequence, hid_t dxpl_id); H5_DLL htri_t H5O_exists_oh(struct H5O_t *oh, unsigned type_id, int sequence); +H5_DLL herr_t H5O_msg_create(H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, + unsigned update_flags, void *mesg, hid_t dxpl_id); H5_DLL void *H5O_read(const H5O_loc_t *loc, unsigned type_id, int sequence, void *mesg, hid_t dxpl_id); -H5_DLL int H5O_modify(H5O_loc_t *loc, unsigned type_id, - int overwrite, unsigned flags, unsigned update_flags, void *mesg, hid_t dxpl_id); +H5_DLL herr_t H5O_write(H5O_loc_t *loc, unsigned type_id, unsigned overwrite, + unsigned flags, unsigned update_flags, void *mesg, hid_t dxpl_id); H5_DLL struct H5O_t *H5O_protect(H5O_loc_t *loc, hid_t dxpl_id); H5_DLL herr_t H5O_unprotect(H5O_loc_t *loc, struct H5O_t *oh, hid_t dxpl_id, unsigned oh_flags); -H5_DLL int H5O_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, unsigned type_id, - unsigned flags, void *mesg, unsigned * oh_flags_ptr); +H5_DLL herr_t H5O_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, unsigned type_id, + unsigned mesg_flags, unsigned update_flags, void *mesg, + unsigned *oh_flags_ptr); H5_DLL herr_t H5O_touch(H5O_loc_t *loc, hbool_t force, hid_t dxpl_id); H5_DLL herr_t H5O_touch_oh(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, hbool_t force, unsigned *oh_flags_ptr); diff --git a/src/H5Oshared.c b/src/H5Oshared.c index 032e2b0..108e74e 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -531,7 +531,7 @@ H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, * are written (in H5O_shared_link) and decrement it here. * SOHMs in the heap behave differently; their refcount is incremented * during H5SM_share when they are going to be written (in H5O_append - * or H5O_modify). Their refcount in the SOHM indexes still needs to + * or H5O_write). Their refcount in the SOHM indexes still needs to * be decremented when they're deleted (in H5O_shared_link_adj). */ @@ -1029,7 +1029,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5S_modify + * Function: H5S_write * * Purpose: Updates a data space by writing a message to an object * header. @@ -1042,11 +1042,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5S_modify(H5O_loc_t *loc, const H5S_t *ds, hbool_t update_time, hid_t dxpl_id) +H5S_write(H5O_loc_t *loc, const H5S_t *ds, hbool_t update_time, hid_t dxpl_id) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5S_modify, FAIL) + FUNC_ENTER_NOAPI(H5S_write, FAIL) HDassert(loc); HDassert(ds); @@ -1055,7 +1055,7 @@ H5S_modify(H5O_loc_t *loc, const H5S_t *ds, hbool_t update_time, hid_t dxpl_id) case H5S_NULL: case H5S_SCALAR: case H5S_SIMPLE: - if(H5O_modify(loc, H5O_SDSPACE_ID, 0, 0, update_time, &(ds->extent), dxpl_id) < 0) + if(H5O_write(loc, H5O_SDSPACE_ID, 0, 0, update_time, &(ds->extent), dxpl_id) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update simple dataspace message") break; @@ -1066,7 +1066,7 @@ H5S_modify(H5O_loc_t *loc, const H5S_t *ds, hbool_t update_time, hid_t dxpl_id) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_modify() */ +} /* end H5S_write() */ /*------------------------------------------------------------------------- @@ -1091,23 +1091,23 @@ done: */ herr_t H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, const H5S_t *ds, - unsigned * oh_flags_ptr) + unsigned *oh_flags_ptr) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5S_append, FAIL); + FUNC_ENTER_NOAPI(H5S_append, FAIL) - assert(f); - assert(oh); - assert(ds); - assert(oh_flags_ptr); + HDassert(f); + HDassert(oh); + HDassert(ds); + HDassert(oh_flags_ptr); switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_NULL: case H5S_SCALAR: case H5S_SIMPLE: - if (H5O_append(f, dxpl_id, oh, H5O_SDSPACE_ID, 0, &(ds->extent), oh_flags_ptr)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update simple data space message"); + if(H5O_append(f, dxpl_id, oh, H5O_SDSPACE_ID, 0, 0, &(ds->extent), oh_flags_ptr) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update simple data space message") break; default: @@ -1116,7 +1116,7 @@ H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, const H5S_t *ds, } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_append() */ @@ -519,6 +519,9 @@ H5SM_try_share(H5F_t *f, hid_t dxpl_id, unsigned type_id, void *mesg) /* Type-specific checks */ /* JAMES: should this go here? Should there be a "can share" callback? */ + /* QAK: Yes, a "can share" callback would be very good here, this chunk of + * code is really violating the encapsulation of the datatype class + */ if(type_id == H5O_DTYPE_ID) { /* Don't share immutable datatypes */ @@ -573,12 +576,12 @@ H5SM_try_share(H5F_t *f, hid_t dxpl_id, unsigned type_id, void *mesg) done: /* Release the master SOHM table */ if (table && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_TABLE, f->shared->sohm_addr, table, cache_flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "unable to close SOHM master table") + HDONE_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI(ret_value) } - + /*------------------------------------------------------------------------- * Function: H5SM_write_mesg * diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index bdcd60a..7538cbd 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -202,7 +202,7 @@ H5_DLL hbool_t H5S_has_extent(const H5S_t *ds); H5_DLL int H5S_get_simple_extent_ndims(const H5S_t *ds); H5_DLL int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[]/*out*/, hsize_t max_dims[]/*out*/); -H5_DLL herr_t H5S_modify(struct H5O_loc_t *loc, const H5S_t *space, +H5_DLL herr_t H5S_write(struct H5O_loc_t *loc, const H5S_t *space, hbool_t update_time, hid_t dxpl_id); H5_DLL herr_t H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, const H5S_t *ds, unsigned * oh_flags_ptr); diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 025aca3..efe1d92 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -281,7 +281,7 @@ H5T_commit(H5F_t *file, H5T_t *type, hid_t dxpl_id, hid_t tcpl_id, hid_t UNUSED */ if(H5O_create(file, dxpl_id, dtype_size, tcpl_id, &temp_oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header") - if(H5O_modify(&temp_oloc, H5O_DTYPE_ID, 0, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSOHM, H5O_UPDATE_TIME, type, dxpl_id) < 0) + if(H5O_msg_create(&temp_oloc, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSOHM, H5O_UPDATE_TIME, type, dxpl_id) < 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 */ diff --git a/test/dsets.c b/test/dsets.c index 9e79b41..b6182f1 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -542,61 +542,54 @@ test_compact_io(hid_t fapl) TESTING("compact dataset I/O"); /* Initialize data */ - n=0; - for(i=0; i<16; i++) { - for(j=0; j<8; j++) { + n = 0; + for(i = 0; i < 16; i++) + for(j = 0; j < 8; j++) wbuf[i][j] = n++; - } - } /* Create a small data space for compact dataset */ dims[0] = 16; dims[1] = 8; - space = H5Screate_simple(2, dims, NULL); - assert(space>=0); + if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create a file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) - goto error; + TEST_ERROR /* Create property list for compact dataset creation */ - plist = H5Pcreate(H5P_DATASET_CREATE); - assert(plist >= 0); - status = H5Pset_layout(plist, H5D_COMPACT); - assert(status >= 0); - status = H5Pset_alloc_time(plist, H5D_ALLOC_TIME_EARLY); - assert(status >= 0); + if((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR + if(H5Pset_layout(plist, H5D_COMPACT) < 0) TEST_ERROR + if(H5Pset_alloc_time(plist, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR /* Create and write to a compact dataset */ - if((dataset = H5Dcreate(file, DSET_COMPACT_IO_NAME, H5T_NATIVE_INT, space, - plist))<0) - goto error; + if((dataset = H5Dcreate(file, DSET_COMPACT_IO_NAME, H5T_NATIVE_INT, space, plist))<0) + TEST_ERROR /* Test dataset address. Should be undefined. */ - if(H5Dget_offset(dataset)!=HADDR_UNDEF) goto error; + if(H5Dget_offset(dataset)!=HADDR_UNDEF) TEST_ERROR if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf)<0) - goto error; + TEST_ERROR /* Test dataset address. Should be undefined. */ - if(H5Dget_offset(dataset)!=HADDR_UNDEF) goto error; + if(H5Dget_offset(dataset)!=HADDR_UNDEF) TEST_ERROR /* Close file */ - H5Sclose(space); - H5Pclose(plist); - H5Dclose(dataset); - H5Fclose(file); + if(H5Sclose(space) < 0) TEST_ERROR + if(H5Pclose(plist) < 0) TEST_ERROR + if(H5Dclose(dataset) < 0) TEST_ERROR + if(H5Fclose(file) < 0) TEST_ERROR /* * Open the file and check data */ if((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) - goto error; + TEST_ERROR if((dataset = H5Dopen(file, DSET_COMPACT_IO_NAME))<0) - goto error; + TEST_ERROR if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf)<0) - goto error; + TEST_ERROR /* Check that the values read are the same as the values written */ for (i = 0; i < 16; i++) { @@ -612,8 +605,9 @@ test_compact_io(hid_t fapl) } } - H5Dclose(dataset); - H5Fclose(file); + if(H5Dclose(dataset) < 0) TEST_ERROR + if(H5Fclose(file) < 0) TEST_ERROR + PASSED(); return 0; diff --git a/test/ohdr.c b/test/ohdr.c index cc8841e..bd220d5 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -95,7 +95,7 @@ main(void) /* create a new message */ TESTING("message creation"); time_new = 11111111; - if (H5O_modify(&oh_loc, H5O_MTIME_NEW_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { + if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) { H5_FAILED(); H5Eprint_stack(H5E_DEFAULT, stdout); goto error; @@ -123,7 +123,7 @@ main(void) */ TESTING("message modification"); time_new = 33333333; - if (H5O_modify(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { + if (H5O_write(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); H5Eprint_stack(H5E_DEFAULT, stdout); goto error; @@ -152,7 +152,7 @@ main(void) */ TESTING("duplicate message creation"); time_new = 55555555; - if (H5O_modify(&oh_loc, H5O_MTIME_NEW_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { + if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) { H5_FAILED(); H5Eprint_stack(H5E_DEFAULT, stdout); goto error; @@ -180,7 +180,7 @@ main(void) */ TESTING("duplicate message modification"); time_new = 77777777; - if (H5O_modify(&oh_loc, H5O_MTIME_NEW_ID, 1, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { + if (H5O_write(&oh_loc, H5O_MTIME_NEW_ID, 1, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); H5Eprint_stack(H5E_DEFAULT, stdout); goto error; @@ -214,7 +214,7 @@ main(void) TESTING("object header overflow in memory"); for (i=0; i<40; i++) { time_new = (i+1)*1000+1; - if (H5O_modify(&oh_loc, H5O_MTIME_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { + if(H5O_msg_create(&oh_loc, H5O_MTIME_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) { H5_FAILED(); H5Eprint_stack(H5E_DEFAULT, stdout); goto error; @@ -234,7 +234,7 @@ main(void) TESTING("object header overflow on disk"); for (i=0; i<10; i++) { time_new = (i + 1) * 1000 + 10; - if (H5O_modify(&oh_loc, H5O_MTIME_NEW_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { + if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) { H5_FAILED(); H5Eprint_stack(H5E_DEFAULT, stdout); goto error; |