summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-02-04 07:37:15 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-02-04 07:37:15 (GMT)
commit0a8bba91530eb333e7d3f17e18aac12db44eda63 (patch)
tree9b6cf88bc5113878ddeca5facadc1c3347ba0654 /src
parentf555ac654b71f0bcaab99775f8c2fe1dac26bfab (diff)
downloadhdf5-0a8bba91530eb333e7d3f17e18aac12db44eda63.zip
hdf5-0a8bba91530eb333e7d3f17e18aac12db44eda63.tar.gz
hdf5-0a8bba91530eb333e7d3f17e18aac12db44eda63.tar.bz2
[svn-r13232] Description:
Remove the "scaffolding" for shared message method invocation and simplify the way shared messages are dealt with in general. Tested on: FreeBSD/32 6.2 (duty) Mac OS X/32 10.4.8 (amazon)
Diffstat (limited to 'src')
-rw-r--r--src/H5Adense.c13
-rw-r--r--src/H5Apkg.h2
-rw-r--r--src/H5Atest.c4
-rw-r--r--src/H5O.c8
-rw-r--r--src/H5Oattr.c221
-rw-r--r--src/H5Oattribute.c16
-rw-r--r--src/H5Obogus.c17
-rw-r--r--src/H5Ocache.c17
-rw-r--r--src/H5Ocont.c45
-rw-r--r--src/H5Ocopy.c78
-rw-r--r--src/H5Odbg.c28
-rw-r--r--src/H5Odtype.c96
-rw-r--r--src/H5Oefl.c142
-rw-r--r--src/H5Ofill.c127
-rw-r--r--src/H5Oginfo.c15
-rw-r--r--src/H5Olayout.c70
-rw-r--r--src/H5Olinfo.c18
-rw-r--r--src/H5Olink.c30
-rw-r--r--src/H5Omessage.c568
-rw-r--r--src/H5Omtime.c24
-rw-r--r--src/H5Oname.c13
-rw-r--r--src/H5Onull.c3
-rw-r--r--src/H5Opkg.h58
-rw-r--r--src/H5Opline.c111
-rw-r--r--src/H5Oprivate.h4
-rw-r--r--src/H5Osdspace.c157
-rw-r--r--src/H5Oshared.c618
-rw-r--r--src/H5Oshared.h75
-rw-r--r--src/H5Ostab.c38
-rw-r--r--src/H5S.c16
-rw-r--r--src/H5T.c76
31 files changed, 621 insertions, 2087 deletions
diff --git a/src/H5Adense.c b/src/H5Adense.c
index 30229f4..b630166 100644
--- a/src/H5Adense.c
+++ b/src/H5Adense.c
@@ -388,7 +388,6 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, H5A_t *attr)
H5A_bt2_ud_ins_t udata; /* User data for v2 B-tree insertion */
H5HF_t *fheap = NULL; /* Fractal heap handle for attributes */
H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */
- H5O_shared_t sh_mesg; /* Shared object header message */
uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing message */
void *attr_ptr = NULL; /* Pointer to serialized message */
unsigned mesg_flags = 0; /* Flags for storing message */
@@ -414,7 +413,7 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, H5A_t *attr)
htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */
/* Check if message is already shared */
- if((shared_mesg = H5O_attr_is_shared(attr)) < 0)
+ if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error determining if message is shared")
else if(shared_mesg > 0)
/* Mark the message as shared */
@@ -449,12 +448,8 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, H5A_t *attr)
/* Sanity check */
HDassert(attr_sharable);
- /* Get the shared information for the attribute */
- if(NULL == H5O_attr_get_share(attr, &sh_mesg))
- HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't get shared message")
-
/* Use heap ID for shared message heap */
- udata.id = sh_mesg.u.heap_id;
+ udata.id = attr->sh_loc.u.heap_id;
} /* end if */
else {
size_t attr_size; /* Size of serialized attribute in the heap */
@@ -805,7 +800,7 @@ H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, const char *old_name,
HDassert(attr_copy);
/* Check if message is already shared */
- if((shared_mesg = H5O_attr_is_shared(attr_copy)) < 0)
+ if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr_copy)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error determining if message is shared")
else if(shared_mesg > 0) {
/* Reset shared status of copy */
@@ -823,7 +818,7 @@ H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, const char *old_name,
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to add to dense storage")
/* Was this attribute shared? */
- if((shared_mesg = H5O_attr_is_shared(attr_copy)) > 0) {
+ if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr_copy)) > 0) {
hsize_t attr_rc; /* Attribute's ref count in shared message storage */
/* Retrieve ref count for shared attribute */
diff --git a/src/H5Apkg.h b/src/H5Apkg.h
index 3194494..9ac95cb 100644
--- a/src/H5Apkg.h
+++ b/src/H5Apkg.h
@@ -195,8 +195,6 @@ H5_DLL herr_t H5A_attr_release_table(H5A_attr_table_t *atable);
H5_DLL herr_t H5O_attr_reset(void *_mesg);
H5_DLL herr_t H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
H5_DLL herr_t H5O_attr_link(H5F_t *f, hid_t dxpl_id, const void *_mesg);
-H5_DLL void *H5O_attr_get_share(const void *_mesg, H5O_shared_t *sh);
-H5_DLL htri_t H5O_attr_is_shared(const void *_mesg);
/* Attribute operations */
H5_DLL herr_t H5O_attr_update_shared(H5F_t *f, hid_t dxpl_id, H5A_t *attr,
diff --git a/src/H5Atest.c b/src/H5Atest.c
index 13d13f1..3c1cfab 100644
--- a/src/H5Atest.c
+++ b/src/H5Atest.c
@@ -102,7 +102,7 @@ H5A_is_shared_test(hid_t attr_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
/* Check if attribute is shared */
- ret_value = H5O_attr_is_shared(attr);
+ ret_value = H5O_msg_is_shared(H5O_ATTR_ID, attr);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -135,7 +135,7 @@ H5A_get_shared_rc_test(hid_t attr_id, hsize_t *ref_count)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
/* Sanity check */
- HDassert(H5O_attr_is_shared(attr));
+ HDassert(H5O_msg_is_shared(H5O_ATTR_ID, attr));
/* Retrieve ref count for shared attribute */
if(H5SM_get_refcount(attr->oloc.file, H5AC_ind_dxpl_id, H5O_ATTR_ID,
diff --git a/src/H5O.c b/src/H5O.c
index f1b579c..be16c6a 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -88,16 +88,16 @@ const H5O_msg_class_t *const H5O_msg_class_g[] = {
H5O_MSG_EFL, /*0x0007 Data storage -- external data files */
H5O_MSG_LAYOUT, /*0x0008 Data Layout */
#ifdef H5O_ENABLE_BOGUS
- H5O_MSG_BOGUS, /*0x0009 "Bogus" */
+ H5O_MSG_BOGUS, /*0x0009 "Bogus" (for testing) */
#else /* H5O_ENABLE_BOGUS */
- NULL, /*0x0009 "Bogus" */
+ NULL, /*0x0009 "Bogus" (for testing) */
#endif /* H5O_ENABLE_BOGUS */
H5O_MSG_GINFO, /*0x000A Group Information */
H5O_MSG_PLINE, /*0x000B Data storage -- filter pipeline */
H5O_MSG_ATTR, /*0x000C Attribute list */
H5O_MSG_NAME, /*0x000D Object name */
H5O_MSG_MTIME, /*0x000E Object modification date and time */
- H5O_MSG_SHARED, /*0x000F Shared header message (shouldn't be in file) */
+ NULL, /*0x000F UNUSED (used to be "Shared" */
H5O_MSG_CONT, /*0x0010 Object header continuation */
H5O_MSG_STAB, /*0x0011 Symbol table */
H5O_MSG_MTIME_NEW, /*0x0012 New Object modification date and time */
@@ -1114,7 +1114,7 @@ H5O_touch_oh(H5F_t *f,
if(!force)
HGOTO_DONE(SUCCEED); /*nothing to do*/
- size = (H5O_MSG_MTIME_NEW->raw_size)(f, &now);
+ size = (H5O_MSG_MTIME_NEW->raw_size)(f, FALSE, &now);
if((idx = H5O_alloc(f, dxpl_id, oh, H5O_MSG_MTIME_NEW, size, oh_flags_ptr)) == UFAIL)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for modification time message")
} /* end if */
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 2997705..35c52ef 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -33,12 +33,11 @@ static void *H5O_attr_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const
static void *H5O_attr_copy(const void *_mesg, void *_dest);
static size_t H5O_attr_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_attr_free(void *mesg);
-static herr_t H5O_attr_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_attr_pre_copy_file(H5F_t *file_src, const void *mesg_src,
+ hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata);
static void *H5O_attr_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info,
void *udata);
-static herr_t H5O_attr_set_share(void *_mesg, const H5O_shared_t *sh);
static herr_t H5O_attr_get_crt_index(const void *_mesg, H5O_crt_idx_t *crt_idx);
static herr_t H5O_attr_set_crt_index(void *_mesg, H5O_crt_idx_t crt_idx);
static herr_t H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
@@ -58,6 +57,8 @@ static herr_t H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
#define H5O_SHARED_LINK_REAL H5O_attr_link
#define H5O_SHARED_COPY_FILE H5O_attr_shared_copy_file
#define H5O_SHARED_COPY_FILE_REAL H5O_attr_copy_file
+#define H5O_SHARED_DEBUG H5O_attr_shared_debug
+#define H5O_SHARED_DEBUG_REAL H5O_attr_debug
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
/* This message derives from H5O message class */
@@ -65,24 +66,23 @@ const H5O_msg_class_t H5O_MSG_ATTR[1] = {{
H5O_ATTR_ID, /* message id number */
"attribute", /* message name for debugging */
sizeof(H5A_t), /* native message size */
- H5O_attr_shared_decode, /* decode message */
- H5O_attr_shared_encode, /* encode message */
+ TRUE, /* messages are sharable? */
+ H5O_attr_shared_decode, /* decode message */
+ H5O_attr_shared_encode, /* encode message */
H5O_attr_copy, /* copy the native value */
- H5O_attr_shared_size, /* size of raw message */
+ H5O_attr_shared_size, /* size of raw message */
H5O_attr_reset, /* reset method */
H5O_attr_free, /* free method */
- H5O_attr_shared_delete, /* file delete method */
- H5O_attr_shared_link, /* link method */
- H5O_attr_get_share, /* get share method */
- H5O_attr_set_share, /* set share method */
+ H5O_attr_shared_delete, /* file delete method */
+ H5O_attr_shared_link, /* link method */
+ H5O_shared_copy, /* set share method */
NULL, /*can share method */
- H5O_attr_is_shared, /*is shared method */
H5O_attr_pre_copy_file, /* pre copy native value to file */
- H5O_attr_shared_copy_file, /* copy native value to file */
+ H5O_attr_shared_copy_file, /* copy native value to file */
NULL, /* post copy native value to file */
- NULL /* H5O_attr_get_crt_index */, /* get creation index */
- NULL /* H5O_attr_set_crt_index */, /* set creation index */
- H5O_attr_debug /* debug the message */
+ H5O_attr_get_crt_index, /* get creation index */
+ H5O_attr_set_crt_index, /* set creation index */
+ H5O_attr_shared_debug /* debug the message */
}};
/* This is the initial version, which does not have support for shared datatypes */
@@ -132,7 +132,7 @@ H5FL_EXTERN(H5S_extent_t);
function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
static void *
-H5O_attr_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags,
+H5O_attr_decode(H5F_t *f, hid_t dxpl_id, unsigned UNUSED mesg_flags,
const uint8_t *p)
{
H5A_t *attr = NULL;
@@ -263,7 +263,7 @@ done:
* Added a version number at the beginning.
*
* Raymond Lu, 8 April 2004
- * For data space, changed the operation on H5S_simple_t to
+ * For dataspace, changed the operation on H5S_simple_t to
* H5S_extent_t
*
* James Laird, 15 November 2005
@@ -279,9 +279,8 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
unsigned version; /* Attribute version */
hbool_t type_shared; /* Flag to indicate that a shared datatype is used for this attribute */
hbool_t space_shared; /* Flag to indicate that a shared dataspace is used for this attribute */
- H5O_shared_t sh_mesg; /* Shared message location */
hbool_t use_latest_format; /* Flag indicating the newest file format should be used */
- unsigned flags=0; /* Attribute flags */
+ unsigned flags = 0; /* Attribute flags */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_attr_encode)
@@ -359,23 +358,8 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
p += name_len;
/* encode the attribute datatype */
- if(type_shared) {
- /* Reset shared message information */
- HDmemset(&sh_mesg, 0, sizeof(H5O_shared_t));
-
- /* Get shared message information from datatype */
- if(NULL == (H5O_MSG_DTYPE->get_share)(attr->dt, &sh_mesg/*out*/))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode shared attribute datatype")
-
- /* Encode shared message information for datatype */
- if((H5O_MSG_SHARED->encode)(f, p, &sh_mesg) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode shared attribute datatype")
- } /* end if */
- else {
- /* Encode datatype information */
- if((H5O_MSG_DTYPE->encode)(f, p, attr->dt) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute datatype")
- } /* end else */
+ if((H5O_MSG_DTYPE->encode)(f, FALSE, p, attr->dt) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute datatype")
if(version < H5O_ATTR_VERSION_2) {
HDmemset(p + attr->dt_size, 0, H5O_ALIGN_OLD(attr->dt_size) - attr->dt_size);
@@ -385,23 +369,8 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
p += attr->dt_size;
/* encode the attribute dataspace */
- if(space_shared) {
- /* Reset shared message information */
- HDmemset(&sh_mesg, 0, sizeof(H5O_shared_t));
-
- /* Get shared message information from dataspace */
- if(NULL == (H5O_MSG_SDSPACE->get_share)(attr->ds, &sh_mesg/*out*/))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode shared attribute dataspace")
-
- /* Encode shared message information for dataspace */
- if((H5O_MSG_SHARED->encode)(f, p, &sh_mesg) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode shared attribute dataspace")
- } /* end if */
- else {
- /* Encode non-shared dataspace information */
- if((H5O_MSG_SDSPACE->encode)(f, p, &(attr->ds->extent)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute dataspace")
- } /* end else */
+ if((H5O_MSG_SDSPACE->encode)(f, FALSE, p, &(attr->ds->extent)) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute dataspace")
if(version < H5O_ATTR_VERSION_2) {
HDmemset(p + attr->ds_size, 0, H5O_ALIGN_OLD(attr->ds_size) - attr->ds_size);
@@ -527,19 +496,19 @@ H5O_attr_size(const H5F_t *f, const void *_mesg)
/* Version-specific size information */
if(version == H5O_ATTR_VERSION_1)
ret_value += H5O_ALIGN_OLD(name_len) + /*attribute name */
- H5O_ALIGN_OLD(attr->dt_size) + /*data type */
- H5O_ALIGN_OLD(attr->ds_size) + /*data space */
+ H5O_ALIGN_OLD(attr->dt_size) + /*datatype */
+ H5O_ALIGN_OLD(attr->ds_size) + /*dataspace */
attr->data_size; /*the data itself */
else if(version == H5O_ATTR_VERSION_2)
ret_value += name_len + /*attribute name */
- attr->dt_size + /*data type */
- attr->ds_size + /*data space */
+ attr->dt_size + /*datatype */
+ attr->ds_size + /*dataspace */
attr->data_size; /*the data itself */
else if(version == H5O_ATTR_VERSION_3 || version == H5O_ATTR_VERSION_4)
ret_value += 1 + /*character encoding */
name_len + /*attribute name */
- attr->dt_size + /*data type */
- attr->ds_size + /*data space */
+ attr->dt_size + /*datatype */
+ attr->ds_size + /*dataspace */
attr->data_size; /*the data itself */
else
HDassert(0 && "Bad attribute version");
@@ -685,96 +654,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_attr_get_share
- *
- * Purpose: Gets sharing information from the message
- *
- * Return: Shared message on success/NULL on failure
- *
- * Programmer: James Laird
- * Tuesday, October 17, 2006
- *
- *-------------------------------------------------------------------------
- */
-void *
-H5O_attr_get_share(const void *_mesg, H5O_shared_t *sh /*out*/)
-{
- const H5A_t *mesg = (const H5A_t *)_mesg;
- void *ret_value = NULL;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_get_share)
-
- HDassert(mesg);
-
- ret_value = H5O_msg_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh);
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_attr_get_share() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_attr_set_share
- *
- * Purpose: Sets sharing information for the message
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: James Laird
- * Tuesday, October 10, 2006
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_attr_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh)
-{
- H5A_t *mesg = (H5A_t *)_mesg;
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_set_share)
-
- HDassert(mesg);
- HDassert(sh);
-
- if(NULL == H5O_msg_copy(H5O_SHARED_ID, sh, &(mesg->sh_loc)))
- ret_value = FAIL;
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_attr_set_share() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_attr_is_shared
- *
- * Purpose: Determines if this attribute is shared (committed or a SOHM)
- * or not.
- *
- * Return: TRUE if attribute is shared
- * FALSE if attribute is not shared
- * Negative on failure
- *
- * Programmer: James Laird
- * Tuesday, October 17, 2006
- *
- *-------------------------------------------------------------------------
- */
-htri_t
-H5O_attr_is_shared(const void *_mesg)
-{
- const H5A_t *mesg = (const H5A_t *)_mesg;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_is_shared)
-
- HDassert(mesg);
-
- /* Attributes can't currently be committed, but this should let the
- * library read a "committed attribute" if we ever create one in
- * the future.
- */
- FUNC_LEAVE_NOAPI(H5O_IS_SHARED(mesg->sh_loc.flags))
-} /* end H5O_attr_is_shared */
-
-
-/*-------------------------------------------------------------------------
* Function: H5O_attr_pre_copy_file
*
* Purpose: Perform any necessary actions before copying message between
@@ -790,9 +669,8 @@ H5O_attr_is_shared(const void *_mesg)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_attr_pre_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *type,
- const void UNUSED *native_src, hbool_t *deleted, const H5O_copy_t *cpy_info,
- void UNUSED *udata)
+H5O_attr_pre_copy_file(H5F_t UNUSED *file_src, const void UNUSED *native_src,
+ hbool_t *deleted, const H5O_copy_t *cpy_info, void UNUSED *udata)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_pre_copy_file)
@@ -1174,9 +1052,6 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in
int fwidth)
{
const H5A_t *mesg = (const H5A_t *)_mesg;
- H5O_shared_t sh_mesg; /* Shared message information */
- void *dt_mesg; /* Pointer to datatype message to dump */
- herr_t (*debug)(H5F_t*, hid_t, const void*, FILE*, int, int)=NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_attr_debug)
@@ -1200,39 +1075,19 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in
"Object:",
mesg->oloc.addr);
- fprintf(stream, "%*sData type...\n", indent, "");
+ fprintf(stream, "%*sDatatype...\n", indent, "");
fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0,fwidth-3),
- "Size:",
+ "Encoded Size:",
(unsigned long)(mesg->dt_size));
- fprintf (stream, "%*s%-*s %s\n", indent+3, "", MAX(0,fwidth-3),
- "Shared:",
- (H5T_committed(mesg->dt) ? "Yes" : "No")
- );
- if(H5T_committed(mesg->dt)) {
- /* Reset shared message information */
- HDmemset(&sh_mesg, 0, sizeof(H5O_shared_t));
-
- /* Get shared message information from datatype */
- if(NULL == (H5O_MSG_DTYPE->get_share)(mesg->dt, &sh_mesg/*out*/))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't retrieve shared message information")
-
- debug = H5O_MSG_SHARED->debug;
- dt_mesg = &sh_mesg;
- } /* end if */
- else {
- debug = H5O_MSG_DTYPE->debug;
- dt_mesg = mesg->dt;
- } /* end else */
- if(debug)
- (debug)(f, dxpl_id, dt_mesg, stream, indent+3, MAX(0, fwidth-3));
- else
- fprintf(stream, "%*s<No info for this message>\n", indent + 6, "");
+ if((H5O_MSG_DTYPE->debug)(f, dxpl_id, mesg->dt, stream, indent + 3, MAX(0, fwidth - 3)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display datatype message info")
- fprintf(stream, "%*sData space...\n", indent, "");
+ fprintf(stream, "%*sDataspace...\n", indent, "");
fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0, fwidth - 3),
- "Size:",
+ "Encoded Size:",
(unsigned long)(mesg->ds_size));
- H5S_debug(f, dxpl_id, mesg->ds, stream, indent+3, MAX(0, fwidth - 3));
+ if(H5S_debug(f, dxpl_id, mesg->ds, stream, indent+3, MAX(0, fwidth - 3)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display dataspace message info")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index 5d6d1aa..5e2c4df 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -263,7 +263,7 @@ H5O_attr_create(const H5O_loc_t *loc, hid_t dxpl_id, H5A_t *attr)
} /* end else */
/* Was new attribugte shared? */
- if((shared_mesg = H5O_attr_is_shared(attr)) > 0) {
+ if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr)) > 0) {
hsize_t attr_rc; /* Attribute's ref count in shared message storage */
/* Retrieve ref count for shared attribute */
@@ -524,8 +524,8 @@ H5O_attr_update_shared(H5F_t *f, hid_t dxpl_id, H5A_t *attr,
HDassert(attr);
/* Extract shared message info from current attribute (for later use) */
- if(NULL == H5O_attr_get_share(attr, &sh_mesg))
- HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't get shared info")
+ if(H5O_shared_copy(&sh_mesg, &(attr->sh_loc)) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "can't get shared message")
/* Store new version of message as a SOHM */
/* (should always work, since we're not changing the size of the attribute) */
@@ -557,8 +557,8 @@ H5O_attr_update_shared(H5F_t *f, hid_t dxpl_id, H5A_t *attr,
/* Extract updated shared message info from modified attribute, if requested */
if(update_sh_mesg)
- if(NULL == H5O_attr_get_share(attr, update_sh_mesg))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared info")
+ if(H5O_shared_copy(update_sh_mesg, &(attr->sh_loc)) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "can't get shared message")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -785,7 +785,7 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
} /* end if */
else {
/* Sanity check */
- HDassert(H5O_attr_is_shared((H5A_t *)mesg->native) == FALSE);
+ HDassert(H5O_msg_is_shared(H5O_ATTR_ID, (H5A_t *)mesg->native) == FALSE);
/* Check for attribute message changing size */
if(HDstrlen(udata->new_name) != HDstrlen(udata->old_name)) {
@@ -831,7 +831,7 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to relocate renamed attribute in header")
/* Sanity check */
- HDassert(H5O_attr_is_shared(attr) == FALSE);
+ HDassert(H5O_msg_is_shared(H5O_ATTR_ID, attr) == FALSE);
/* Release the local copy of the attribute */
H5O_msg_free_real(H5O_MSG_ATTR, attr);
@@ -1164,7 +1164,7 @@ H5O_attr_remove(const H5O_loc_t *loc, const char *name, hid_t dxpl_id)
htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */
/* Check if attribute is shared */
- if((shared_mesg = H5O_attr_is_shared(&(atable.attrs[u]))) < 0)
+ if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, &(atable.attrs[u]))) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error determining if message is shared")
else if(shared_mesg == 0) {
/* Increment reference count on attribute components */
diff --git a/src/H5Obogus.c b/src/H5Obogus.c
index 93475cd..39ba18f 100644
--- a/src/H5Obogus.c
+++ b/src/H5Obogus.c
@@ -37,9 +37,9 @@
#ifdef H5O_ENABLE_BOGUS
/* PRIVATE PROTOTYPES */
-static void *H5O_bogus_decode(H5F_t *f, hid_t dxpl_id, unsigned UNUSED mesg_flags, const uint8_t *p);
-static herr_t H5O_bogus_encode(H5F_t *f, uint8_t *p, const void *_mesg);
-static size_t H5O_bogus_size(const H5F_t *f, const void *_mesg);
+static void *H5O_bogus_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
+static herr_t H5O_bogus_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
+static size_t H5O_bogus_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
static herr_t H5O_bogus_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
@@ -48,6 +48,7 @@ const H5O_msg_class_t H5O_MSG_BOGUS[1] = {{
H5O_BOGUS_ID, /*message id number */
"bogus", /*message name for debugging */
0, /*native message size */
+ FALSE, /* messages are sharable? */
H5O_bogus_decode, /*decode message */
H5O_bogus_encode, /*encode message */
NULL, /*copy the native value */
@@ -56,8 +57,8 @@ const H5O_msg_class_t H5O_MSG_BOGUS[1] = {{
NULL, /*free method */
NULL, /* file delete method */
NULL, /* link method */
- NULL, /*get share method */
NULL, /*set share method */
+ NULL, /*can share method */
NULL, /* pre copy native value to file */
NULL, /* copy native value to file */
NULL, /* post copy native value to file */
@@ -129,12 +130,10 @@ done:
* koziol@ncsa.uiuc.edu
* Jan 21 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_bogus_encode(H5F_t UNUSED *f, uint8_t *p, const void UNUSED *mesg)
+H5O_bogus_encode(H5F_t UNUSED *f, hbool_t UNUSED disable_shared, uint8_t *p, const void UNUSED *mesg)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_bogus_encode);
@@ -166,12 +165,10 @@ H5O_bogus_encode(H5F_t UNUSED *f, uint8_t *p, const void UNUSED *mesg)
* koziol@ncsa.uiuc.edu
* Jan 21 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static size_t
-H5O_bogus_size(const H5F_t UNUSED *f, const void UNUSED *mesg)
+H5O_bogus_size(const H5F_t UNUSED *f, hbool_t UNUSED disable_shared, const void UNUSED *mesg)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_bogus_size);
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index 02c8975..64f23d5 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -156,10 +156,6 @@ H5O_flush_msgs(H5F_t *f, H5O_t *oh)
/* Encode the message itself */
if(curr_msg->native) {
- herr_t (*encode)(H5F_t*, uint8_t*, const void*);
-
- HDassert(curr_msg->type->encode);
-
/*
* Encode the message. If the message is shared then we
* encode a Shared Object message instead of the object
@@ -169,21 +165,18 @@ H5O_flush_msgs(H5F_t *f, H5O_t *oh)
HDassert(curr_msg->raw_size == H5O_ALIGN_OH(oh, curr_msg->raw_size));
HDassert(curr_msg->raw + curr_msg->raw_size <=
oh->chunk[curr_msg->chunkno].image + (oh->chunk[curr_msg->chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh)));
- if((curr_msg->flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(curr_msg->type))
- encode = H5O_MSG_SHARED->encode;
- else
- encode = curr_msg->type->encode;
#ifndef NDEBUG
/* Sanity check that the message won't overwrite past it's allocated space */
-if(!(curr_msg->flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(curr_msg->type)) {
+{
size_t msg_size;
- msg_size = curr_msg->type->raw_size(f, curr_msg->native);
+ msg_size = curr_msg->type->raw_size(f, FALSE, curr_msg->native);
msg_size = H5O_ALIGN_OH(oh, msg_size);
HDassert(msg_size <= curr_msg->raw_size);
-} /* end if */
+}
#endif /* NDEBUG */
- if((encode)(f, curr_msg->raw, curr_msg->native) < 0)
+ HDassert(curr_msg->type->encode);
+ if((curr_msg->type->encode)(f, FALSE, curr_msg->raw, curr_msg->native) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message")
} /* end if */
diff --git a/src/H5Ocont.c b/src/H5Ocont.c
index 6146df8..f378611 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -37,8 +37,8 @@
/* PRIVATE PROTOTYPES */
static void *H5O_cont_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
-static herr_t H5O_cont_encode(H5F_t *f, uint8_t *p, const void *_mesg);
-static size_t H5O_cont_size(const H5F_t *f, const void *_mesg);
+static herr_t H5O_cont_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
+static size_t H5O_cont_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
static herr_t H5O_cont_free(void *mesg);
static herr_t H5O_cont_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
static herr_t H5O_cont_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
@@ -49,6 +49,7 @@ const H5O_msg_class_t H5O_MSG_CONT[1] = {{
H5O_CONT_ID, /*message id number */
"hdr continuation", /*message name for debugging */
sizeof(H5O_cont_t), /*native message size */
+ FALSE, /* messages are sharable? */
H5O_cont_decode, /*decode message */
H5O_cont_encode, /*encode message */
NULL, /*no copy method */
@@ -57,10 +58,8 @@ const H5O_msg_class_t H5O_MSG_CONT[1] = {{
H5O_cont_free, /* free method */
H5O_cont_delete, /* file delete method */
NULL, /* link method */
- NULL, /*get share method */
- NULL, /*can share method */
NULL, /*set share method */
- NULL, /*is shared method */
+ NULL, /*can share method */
NULL, /* pre copy native value to file */
NULL, /* copy native value to file */
NULL, /* post copy native value to file */
@@ -129,12 +128,10 @@ done:
* matzke@llnl.gov
* Aug 7 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_cont_encode(H5F_t *f, uint8_t *p, const void *_mesg)
+H5O_cont_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
const H5O_cont_t *cont = (const H5O_cont_t *) _mesg;
@@ -170,12 +167,10 @@ H5O_cont_encode(H5F_t *f, uint8_t *p, const void *_mesg)
* koziol@ncsa.uiuc.edu
* Sep 6 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static size_t
-H5O_cont_size(const H5F_t *f, const void UNUSED *_mesg)
+H5O_cont_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void UNUSED *_mesg)
{
size_t ret_value; /* Return value */
@@ -199,20 +194,18 @@ H5O_cont_size(const H5F_t *f, const void UNUSED *_mesg)
* Programmer: Quincey Koziol
* Monday, November 15, 2004
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_cont_free (void *mesg)
+H5O_cont_free(void *mesg)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_cont_free);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_cont_free)
- assert (mesg);
+ HDassert(mesg);
- H5FL_FREE(H5O_cont_t,mesg);
+ H5FL_FREE(H5O_cont_t, mesg);
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_cont_free() */
@@ -270,14 +263,14 @@ H5O_cont_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *
{
const H5O_cont_t *cont = (const H5O_cont_t *) _mesg;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_cont_debug);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_cont_debug)
/* check args */
- assert(f);
- assert(cont);
- assert(stream);
- assert(indent >= 0);
- assert(fwidth >= 0);
+ HDassert(f);
+ HDassert(cont);
+ HDassert(stream);
+ HDassert(indent >= 0);
+ HDassert(fwidth >= 0);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
"Continuation address:", cont->addr);
@@ -289,5 +282,5 @@ H5O_cont_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *
"Points to chunk number:",
(int) (cont->chunkno));
- FUNC_LEAVE_NOAPI(SUCCEED);
-}
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_cont_debug() */
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index a93b321..b50ecd9 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -357,7 +357,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
} /* end if */
else {
oh_dst->nattrs = oh_src->nattrs;
- /* XXX: Bail out for now, if the source object has densely stored attributes */
+/* XXX: Bail out for now, if the source object has densely stored attributes */
if(H5F_addr_defined(oh_src->attr_fheap_addr))
HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "densely stored attributes not supported yet")
else {
@@ -396,11 +396,8 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
/* Sanity check */
HDassert(!mesg_src->dirty); /* Should be cleared by earlier call to flush messages */
- /* Check for shared message to operate on */
- if((mesg_src->flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(mesg_src->type))
- copy_type = H5O_MSG_SHARED;
- else
- copy_type = mesg_src->type;
+ /* Get message class to operate on */
+ copy_type = mesg_src->type;
/* Check for continuation message; these are converted to NULL
* messages because the destination OH will have only one chunk
@@ -409,30 +406,21 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
deleted[mesgno] = TRUE;
++null_msgs;
copy_type = H5O_MSG_NULL;
- }
+ } /* end if */
HDassert(copy_type);
if(copy_type->pre_copy_file) {
- /*
- * Decode the message if necessary. If the message is shared then do
- * a shared message, ignoring the message type.
- */
- if(NULL == mesg_src->native) {
- /* Decode the message if necessary */
- HDassert(copy_type->decode);
- if(NULL == (mesg_src->native = (copy_type->decode)(oloc_src->file, dxpl_id, mesg_src->flags, mesg_src->raw)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode a message")
- } /* end if (NULL == mesg_src->native) */
+ /* Decode the message if necessary. */
+ H5O_LOAD_NATIVE(oloc_src->file, dxpl_id, mesg_src, FAIL)
/* Perform "pre copy" operation on message */
- if((copy_type->pre_copy_file)(oloc_src->file, mesg_src->type, mesg_src->native, &(deleted[mesgno]), cpy_info, udata) < 0)
+ if((copy_type->pre_copy_file)(oloc_src->file, mesg_src->native, &(deleted[mesgno]), cpy_info, udata) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to perform 'pre copy' operation on message")
/* Check if the message should be deleted in the destination */
- if(deleted[mesgno]) {
+ if(deleted[mesgno])
/* Mark message as deleted */
++null_msgs;
- } /* end if(deleted) */
} /* end if(copy_type->pre_copy_file) */
} /* end for */
@@ -459,8 +447,8 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
while(deleted[mesgno + null_msgs]) {
++null_msgs;
HDassert(mesgno + null_msgs < oh_src->nmesgs);
- }
- }
+ } /* end while */
+ } /* end if */
/* Set up convenience variables */
mesg_src = &(oh_src->mesg[mesgno + null_msgs]);
@@ -482,33 +470,22 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
mesg_dst->type = H5O_MSG_NULL;
mesg_dst->flags = 0;
mesg_dst->dirty = 1;
- }
+ } /* end if */
- /* Check for shared message to operate on */
+ /* Check for message class to operate on */
/* (Use destination message, in case the message has been removed (i.e
- * converted to a nil message) in the destination -QAK)
- */
- if((mesg_dst->flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(mesg_dst->type))
- copy_type = H5O_MSG_SHARED;
- else
- copy_type = mesg_dst->type;
+ * converted to a nil message) in the destination -QAK)
+ */
+ copy_type = mesg_dst->type;
HDassert(copy_type);
/* copy this message into destination file */
if(copy_type->copy_file) {
- /*
- * Decode the message if necessary. If the message is shared then do
- * a shared message, ignoring the message type.
- */
- if(NULL == mesg_src->native) {
- /* Decode the message if necessary */
- HDassert(copy_type->decode);
- if(NULL == (mesg_src->native = (copy_type->decode)(oloc_src->file, dxpl_id, mesg_dst->flags, mesg_src->raw)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode a message")
- } /* end if (NULL == mesg_src->native) */
+ /* Decode the message if necessary. */
+ H5O_LOAD_NATIVE(oloc_src->file, dxpl_id, mesg_src, FAIL)
/* Copy the source message */
- if((mesg_dst->native = H5O_msg_copy_file(copy_type, mesg_dst->type,
+ if((mesg_dst->native = H5O_msg_copy_file(copy_type,
oloc_src->file, mesg_src->native, oloc_dst->file, dxpl_id,
&shared, cpy_info, udata)) == NULL)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object header message")
@@ -522,21 +499,17 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
mesg_dst->flags |= H5O_MSG_FLAG_SHARED;
/* Recompute shared message size (mesg_dst->native is really
- * an H5O_shared_t)
+ * shared)
*/
- if(H5O_NEW_SHARED(mesg_dst->type))
- mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst,
- H5O_msg_raw_size(oloc_dst->file, mesg_dst->type->id, FALSE, mesg_dst->native));
- else
- mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst,
- H5O_msg_raw_size(oloc_dst->file, H5O_SHARED_ID, FALSE, mesg_dst->native));
+ mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst,
+ H5O_msg_raw_size(oloc_dst->file, mesg_dst->type->id, FALSE, mesg_dst->native));
} /* end if */
else if(shared == FALSE && (mesg_dst->flags & H5O_MSG_FLAG_SHARED)) {
/* Unset shared flag */
mesg_dst->flags &= ~H5O_MSG_FLAG_SHARED;
/* Recompute native message size (msg_dest->native is no longer
- * an H5O_shared_t)
+ * shared)
*/
mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst,
H5O_msg_raw_size(oloc_dst->file, mesg_dst->type->id, FALSE, mesg_dst->native));
@@ -661,14 +634,11 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
mesg_src = &(oh_src->mesg[mesgno + null_msgs]);
mesg_dst = &(oh_dst->mesg[mesgno]);
- /* Check for shared message to operate on */
+ /* Check for message class to operate on */
/* (Use destination message, in case the message has been removed (i.e
* converted to a nil message) in the destination -QAK)
*/
- if((mesg_dst->flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(mesg_dst->type))
- copy_type = H5O_MSG_SHARED;
- else
- copy_type = mesg_dst->type;
+ copy_type = mesg_dst->type;
HDassert(copy_type);
if(copy_type->post_copy_file && mesg_src->native) {
diff --git a/src/H5Odbg.c b/src/H5Odbg.c
index 13428cf..a53493e 100644
--- a/src/H5Odbg.c
+++ b/src/H5Odbg.c
@@ -247,8 +247,7 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i
{
unsigned i, chunkno;
size_t mesg_total = 0, chunk_total = 0;
- int *sequence;
- const H5O_msg_class_t *debug_type; /* Type of message to use for callbacks */
+ unsigned *sequence;
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(H5O_debug_real, FAIL)
@@ -356,9 +355,11 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i
} /* end for */
/* debug each message */
- if(NULL == (sequence = H5MM_calloc(NELMTS(H5O_msg_class_g) * sizeof(int))))
+ if(NULL == (sequence = H5MM_calloc(NELMTS(H5O_msg_class_g) * sizeof(unsigned))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
for(i = 0, mesg_total = 0; i < oh->nmesgs; i++) {
+ const H5O_msg_class_t *debug_type; /* Type of message to use for callbacks */
+
mesg_total += H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[i].raw_size;
HDfprintf(stream, "%*sMessage %d...\n", indent, "", i);
@@ -410,13 +411,9 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i
HDfprintf(stream, "*** BAD MESSAGE RAW ADDRESS\n");
/* decode the message */
- if((oh->mesg[i].flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(oh->mesg[i].type)) {
- debug_type = H5O_MSG_SHARED;
- } else {
- debug_type = oh->mesg[i].type;
- } /* end else */
- if(NULL==oh->mesg[i].native && debug_type->decode)
- oh->mesg[i].native = (debug_type->decode)(f, dxpl_id, oh->mesg[i].flags, oh->mesg[i].raw);
+ debug_type = oh->mesg[i].type;
+ if(NULL == oh->mesg[i].native && debug_type->decode)
+ H5O_LOAD_NATIVE(f, dxpl_id, &oh->mesg[i], FAIL)
/* print the message */
HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3),
@@ -425,17 +422,6 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i
(debug_type->debug)(f, dxpl_id, oh->mesg[i].native, stream, indent + 6, MAX(0, fwidth - 6));
else
HDfprintf(stream, "%*s<No info for this message>\n", indent + 6, "");
-
- /* If the message is shared then also print the pointed-to message */
- if((oh->mesg[i].flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(oh->mesg[i].type)) {
- H5O_shared_t *shared = (H5O_shared_t*)(oh->mesg[i].native);
- void *mesg;
-
- mesg = H5O_shared_read(f, dxpl_id, shared, oh->mesg[i].type, NULL);
- if(oh->mesg[i].type->debug)
- (oh->mesg[i].type->debug)(f, dxpl_id, mesg, stream, indent + 3, MAX (0, fwidth - 3));
- H5O_msg_free_real(oh->mesg[i].type, mesg);
- } /* end if */
} /* end for */
sequence = H5MM_xfree(sequence);
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 31de559..c060ad5 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -33,12 +33,10 @@ static void *H5O_dtype_copy(const void *_mesg, void *_dest);
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 void *H5O_dtype_get_share(const void *_mesg, H5O_shared_t *sh);
static herr_t H5O_dtype_set_share(void *_mesg, const H5O_shared_t *sh);
static htri_t H5O_dtype_can_share(const void *_mesg);
-static htri_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_pre_copy_file(H5F_t *file_src, const void *mesg_src,
+ hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
static void *H5O_dtype_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata);
@@ -59,6 +57,8 @@ static herr_t H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
#undef H5O_SHARED_LINK_REAL
#define H5O_SHARED_COPY_FILE H5O_dtype_shared_copy_file
#define H5O_SHARED_COPY_FILE_REAL H5O_dtype_copy_file
+#define H5O_SHARED_DEBUG H5O_dtype_shared_debug
+#define H5O_SHARED_DEBUG_REAL H5O_dtype_debug
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
/* This message derives from H5O message class */
@@ -66,6 +66,7 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{
H5O_DTYPE_ID, /* message id number */
"datatype", /* message name for debugging */
sizeof(H5T_t), /* native message size */
+ TRUE, /* messages are sharable? */
H5O_dtype_shared_decode, /* decode message */
H5O_dtype_shared_encode, /* encode message */
H5O_dtype_copy, /* copy the native value */
@@ -74,16 +75,14 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{
H5O_dtype_free, /* free method */
H5O_dtype_shared_delete, /* file delete method */
H5O_dtype_shared_link, /* link method */
- H5O_dtype_get_share, /* get share method */
H5O_dtype_set_share, /* set share method */
H5O_dtype_can_share, /* can share method */
- H5O_dtype_is_shared, /* is shared method */
H5O_dtype_pre_copy_file, /* pre copy native value to file */
H5O_dtype_shared_copy_file, /* copy native value to file */
NULL, /* post copy native value to file */
NULL, /* get creation index */
NULL, /* set creation index */
- H5O_dtype_debug /* debug the message */
+ H5O_dtype_shared_debug /* debug the message */
}};
/* This is the version to create all datatypes which don't contain
@@ -1274,49 +1273,6 @@ H5O_dtype_free(void *mesg)
/*-------------------------------------------------------------------------
- * Function: H5O_dtype_get_share
- *
- * Purpose: Returns information about where the shared message is located
- * by filling in the SH shared message struct.
- *
- * Return: Shared message on success/NULL on failure
- *
- * Programmer: Robb Matzke
- * Monday, June 1, 1998
- *
- *-------------------------------------------------------------------------
- */
-static void *
-H5O_dtype_get_share(const void *_mesg, H5O_shared_t *sh/*out*/)
-{
- const H5T_t *dt = (const H5T_t *)_mesg;
- void *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_get_share)
-
- HDassert(dt);
-
- /* Make sure the shared struct is initialized to some reasonable value */
- HDassert((dt->sh_loc.flags & (H5O_SHARED_IN_HEAP_FLAG | H5O_COMMITTED_FLAG)) || dt->sh_loc.flags == H5O_NOT_SHARED);
-
-#ifndef NDEBUG
- /* Make sure datatype state is correct: committed datatypes must have
- * state NAMED or OPEN and neither unshared datatypes nor datatypes
- * shared in the heap can be NAMED or OPEN. */
- if(dt->sh_loc.flags & H5O_COMMITTED_FLAG)
- HDassert(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state);
- else
- HDassert(! (H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state));
-#endif /* NDEBUG */
-
- /* Do actual copy of shared information */
- ret_value = H5O_msg_copy(H5O_SHARED_ID, &(dt->sh_loc), sh);
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_dtype_get_share() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5O_dtype_set_share
*
* Purpose: Copies sharing information from SH into the message.
@@ -1334,7 +1290,7 @@ H5O_dtype_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh)
H5T_t *dt = (H5T_t *)_mesg;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_set_share)
+ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_set_share)
HDassert(dt);
HDassert(sh);
@@ -1349,13 +1305,14 @@ H5O_dtype_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh)
(dt->shared->state != H5T_STATE_OPEN && dt->shared->state != H5T_STATE_NAMED));
/* Copy the shared information */
- if(NULL == H5O_msg_copy(H5O_SHARED_ID, sh, &(dt->sh_loc)))
- ret_value = FAIL;
+ if(H5O_shared_copy(&(dt->sh_loc), sh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy shared message info")
/* If this is now a committed datatype, set its state properly. */
if(sh->flags & H5O_COMMITTED_FLAG)
dt->shared->state = H5T_STATE_NAMED;
+done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_dtype_set_share() */
@@ -1403,35 +1360,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_dtype_can_share() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_dtype_is_shared
- *
- * Purpose: Determines if this datatype is shared (committed or a SOHM)
- * or not.
- *
- * Return: TRUE if datatype is shared
- * FALSE if datatype is not shared
- * Negative on failure
- *
- * Programmer: James Laird
- * Monday, October 16, 2006
- *
- *-------------------------------------------------------------------------
- */
-static htri_t
-H5O_dtype_is_shared(const void *_mesg)
-{
- const H5T_t *mesg = (const H5T_t *)_mesg;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_is_shared)
-
- HDassert(mesg);
-
- FUNC_LEAVE_NOAPI(H5O_IS_SHARED(mesg->sh_loc.flags))
-} /* end H5O_dtype_is_shared() */
-
/*-------------------------------------------------------------------------
* Function: H5O_dtype_pre_copy_file
@@ -1449,8 +1377,8 @@ H5O_dtype_is_shared(const void *_mesg)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_dtype_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *type,
- const void *mesg_src, hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info,
+H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src,
+ hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info,
void *_udata)
{
const H5T_t *dt_src = (const H5T_t *)mesg_src; /* Source datatype */
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index ce6a9e5..fbf3806 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -29,12 +29,12 @@
/* PRIVATE PROTOTYPES */
static void *H5O_efl_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
-static herr_t H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg);
+static herr_t H5O_efl_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
static void *H5O_efl_copy(const void *_mesg, void *_dest);
-static size_t H5O_efl_size(const H5F_t *f, const void *_mesg);
+static size_t H5O_efl_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
static herr_t H5O_efl_reset(void *_mesg);
-static void *H5O_efl_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
- void *mesg_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata);
+static void *H5O_efl_copy_file(H5F_t *file_src, void *mesg_src,
+ H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata);
static herr_t H5O_efl_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
@@ -43,6 +43,7 @@ const H5O_msg_class_t H5O_MSG_EFL[1] = {{
H5O_EFL_ID, /*message id number */
"external file list", /*message name for debugging */
sizeof(H5O_efl_t), /*native message size */
+ FALSE, /* messages are sharable? */
H5O_efl_decode, /*decode message */
H5O_efl_encode, /*encode message */
H5O_efl_copy, /*copy native value */
@@ -51,10 +52,8 @@ const H5O_msg_class_t H5O_MSG_EFL[1] = {{
NULL, /* free method */
NULL, /* file delete method */
NULL, /* link method */
- NULL, /*get share method */
NULL, /*set share method */
NULL, /*can share method */
- NULL, /*is shared method */
NULL, /* pre copy native value to file */
H5O_efl_copy_file, /* copy native value to file */
NULL, /* post copy native value to file */
@@ -183,29 +182,20 @@ done:
* Programmer: Robb Matzke
* Tuesday, November 25, 1997
*
- * Modifications:
- * Robb Matzke, 1998-07-20
- * Rearranged the message to add a version number near the beginning.
- *
- * Robb Matzke, 1999-10-14
- * Entering the name into the local heap happens when the dataset is
- * created. Otherwise we could end up in infinite recursion if the heap
- * happens to hash to the same cache slot as the object header.
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg)
+H5O_efl_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
size_t u; /* Local index variable */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_encode);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_encode)
/* check args */
- assert(f);
- assert(mesg);
- assert(p);
+ HDassert(f);
+ HDassert(mesg);
+ HDassert(p);
/* Version */
*p++ = H5O_EFL_VERSION;
@@ -216,29 +206,29 @@ H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg)
*p++ = 0;
/* Number of slots */
- assert (mesg->nalloc>0);
+ HDassert(mesg->nalloc > 0);
UINT16ENCODE(p, mesg->nused); /*yes, twice*/
- assert (mesg->nused>0 && mesg->nused<=mesg->nalloc);
+ HDassert(mesg->nused > 0 && mesg->nused <= mesg->nalloc);
UINT16ENCODE(p, mesg->nused);
/* Heap address */
- assert (H5F_addr_defined(mesg->heap_addr));
+ HDassert(H5F_addr_defined(mesg->heap_addr));
H5F_addr_encode(f, &p, mesg->heap_addr);
/* Encode file list */
- for (u=0; u<mesg->nused; u++) {
+ for(u = 0; u < mesg->nused; u++) {
/*
* The name should have been added to the heap when the dataset was
* created.
*/
- assert(mesg->slot[u].name_offset);
- H5F_ENCODE_LENGTH (f, p, mesg->slot[u].name_offset);
- H5F_ENCODE_LENGTH (f, p, mesg->slot[u].offset);
- H5F_ENCODE_LENGTH (f, p, mesg->slot[u].size);
- }
+ HDassert(mesg->slot[u].name_offset);
+ H5F_ENCODE_LENGTH(f, p, mesg->slot[u].name_offset);
+ H5F_ENCODE_LENGTH(f, p, mesg->slot[u].offset);
+ H5F_ENCODE_LENGTH(f, p, mesg->slot[u].size);
+ } /* end for */
- FUNC_LEAVE_NOAPI(SUCCEED);
-}
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_efl_encode() */
/*-------------------------------------------------------------------------
@@ -254,8 +244,6 @@ H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg)
* Programmer: Robb Matzke
* Tuesday, November 25, 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void *
@@ -311,21 +299,19 @@ done:
* Programmer: Robb Matzke
* Tuesday, November 25, 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static size_t
-H5O_efl_size(const H5F_t *f, const void *_mesg)
+H5O_efl_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg)
{
const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
size_t ret_value = 0;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_size);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_size)
/* check args */
- assert(f);
- assert(mesg);
+ HDassert(f);
+ HDassert(mesg);
ret_value = H5F_SIZEOF_ADDR(f) + /*heap address */
2 + /*slots allocated*/
@@ -335,8 +321,8 @@ H5O_efl_size(const H5F_t *f, const void *_mesg)
H5F_SIZEOF_SIZE(f) + /*file offset */
H5F_SIZEOF_SIZE(f)); /*file size */
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_efl_size() */
/*-------------------------------------------------------------------------
@@ -350,8 +336,6 @@ H5O_efl_size(const H5F_t *f, const void *_mesg)
* Programmer: Robb Matzke
* Tuesday, November 25, 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -360,21 +344,21 @@ H5O_efl_reset(void *_mesg)
H5O_efl_t *mesg = (H5O_efl_t *) _mesg;
size_t u; /* Local index variable */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_reset);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_reset)
/* check args */
- assert(mesg);
+ HDassert(mesg);
/* reset */
- for (u=0; u<mesg->nused; u++)
- mesg->slot[u].name = H5MM_xfree (mesg->slot[u].name);
+ for(u = 0; u < mesg->nused; u++)
+ mesg->slot[u].name = H5MM_xfree(mesg->slot[u].name);
mesg->heap_addr = HADDR_UNDEF;
mesg->nused = mesg->nalloc = 0;
if(mesg->slot)
mesg->slot = H5MM_xfree(mesg->slot);
- FUNC_LEAVE_NOAPI(SUCCEED);
-}
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_efl_reset() */
/*-------------------------------------------------------------------------
@@ -390,8 +374,6 @@ H5O_efl_reset(void *_mesg)
* Programmer: Robb Matzke
* Tuesday, March 3, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
hsize_t
@@ -399,24 +381,23 @@ H5O_efl_total_size (H5O_efl_t *efl)
{
hsize_t ret_value = 0, tmp;
- FUNC_ENTER_NOAPI_NOINIT(H5O_efl_total_size);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_efl_total_size)
- if (efl->nused>0 &&
- H5O_EFL_UNLIMITED==efl->slot[efl->nused-1].size) {
+ if(efl->nused > 0 && H5O_EFL_UNLIMITED == efl->slot[efl->nused - 1].size)
ret_value = H5O_EFL_UNLIMITED;
- } else {
+ else {
size_t u; /* Local index variable */
- for (u=0; u<efl->nused; u++, ret_value=tmp) {
+ for(u = 0; u < efl->nused; u++, ret_value = tmp) {
tmp = ret_value + efl->slot[u].size;
- if (tmp<=ret_value)
- HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, 0, "total external storage size overflowed");
- }
- }
+ if(tmp <= ret_value)
+ HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, 0, "total external storage size overflowed");
+ } /* end for */
+ } /* end else */
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_efl_total_size() */
/*-------------------------------------------------------------------------
@@ -431,14 +412,11 @@ done:
* Programmer: Peter Cao
* September 29, 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void *
-H5O_efl_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *mesg_type,
- void *mesg_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t UNUSED *cpy_info,
- void UNUSED *_udata)
+H5O_efl_copy_file(H5F_t UNUSED *file_src, void *mesg_src, H5F_t *file_dst,
+ hid_t dxpl_id, H5O_copy_t UNUSED *cpy_info, void UNUSED *_udata)
{
H5O_efl_t *efl_src = (H5O_efl_t *) mesg_src;
H5O_efl_t *efl_dst = NULL;
@@ -479,14 +457,14 @@ H5O_efl_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *mesg_typ
/* copy content from the source. Need to update later */
HDmemcpy(efl_dst->slot, efl_src->slot, size);
- }
+ } /* end if */
/* copy the name from the source */
for(idx = 0; idx < efl_src->nused; idx++) {
efl_dst->slot[idx].name = H5MM_xstrdup(efl_src->slot[idx].name);
efl_dst->slot[idx].name_offset = H5HL_insert(file_dst, dxpl_id, efl_dst->heap_addr,
- HDstrlen(efl_dst->slot[idx].name)+1, efl_dst->slot[idx].name);
- }
+ HDstrlen(efl_dst->slot[idx].name) + 1, efl_dst->slot[idx].name);
+ } /* end for */
/* Set return value */
ret_value = efl_dst;
@@ -497,7 +475,7 @@ done:
H5MM_xfree(efl_dst);
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5O_efl_copy_file() */
/*-------------------------------------------------------------------------
@@ -510,8 +488,6 @@ done:
* Programmer: Robb Matzke
* Tuesday, November 25, 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -522,14 +498,14 @@ H5O_efl_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * s
char buf[64];
size_t u;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_debug);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_efl_debug)
/* check args */
- assert(f);
- assert(mesg);
- assert(stream);
- assert(indent >= 0);
- assert(fwidth >= 0);
+ HDassert(f);
+ HDassert(mesg);
+ HDassert(stream);
+ HDassert(indent >= 0);
+ HDassert(fwidth >= 0);
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
"Heap address:", mesg->heap_addr);
@@ -538,7 +514,7 @@ H5O_efl_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * s
"Slots used/allocated:",
mesg->nused, mesg->nalloc);
- for (u = 0; u < mesg->nused; u++) {
+ for(u = 0; u < mesg->nused; u++) {
sprintf (buf, "File %u", (unsigned)u);
HDfprintf (stream, "%*s%s:\n", indent, "", buf);
@@ -557,8 +533,8 @@ H5O_efl_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * s
HDfprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0),
"Bytes reserved for data:",
(unsigned long)(mesg->slot[u].size));
- }
+ } /* end for */
- FUNC_LEAVE_NOAPI(SUCCEED);
-}
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_efl_debug() */
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 091f810..b68967b 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -41,9 +41,6 @@ static void *H5O_fill_new_copy(const void *_mesg, void *_dest);
static size_t H5O_fill_new_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_fill_new_reset(void *_mesg);
static herr_t H5O_fill_new_free(void *_mesg);
-static void *H5O_fill_new_get_share(const void *_mesg, H5O_shared_t *sh);
-static herr_t H5O_fill_new_set_share(void *_mesg, const H5O_shared_t *sh);
-static htri_t H5O_fill_new_is_shared(const void *_mesg);
static herr_t H5O_fill_new_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
int indent, int fwidth);
@@ -61,6 +58,8 @@ static herr_t H5O_fill_new_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FIL
#undef H5O_SHARED_LINK_REAL
#define H5O_SHARED_COPY_FILE H5O_fill_shared_copy_file
#undef H5O_SHARED_COPY_FILE_REAL
+#define H5O_SHARED_DEBUG H5O_fill_shared_debug
+#define H5O_SHARED_DEBUG_REAL H5O_fill_debug
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
/* Set up & include shared message "interface" info */
@@ -88,6 +87,10 @@ static herr_t H5O_fill_new_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FIL
#undef H5O_SHARED_COPY_FILE
#define H5O_SHARED_COPY_FILE H5O_fill_new_shared_copy_file
#undef H5O_SHARED_COPY_FILE_REAL
+#undef H5O_SHARED_DEBUG
+#define H5O_SHARED_DEBUG H5O_fill_new_shared_debug
+#undef H5O_SHARED_DEBUG_REAL
+#define H5O_SHARED_DEBUG_REAL H5O_fill_new_debug
#undef H5Oshared_H
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
@@ -96,24 +99,23 @@ const H5O_msg_class_t H5O_MSG_FILL[1] = {{
H5O_FILL_ID, /*message id number */
"fill", /*message name for debugging */
sizeof(H5O_fill_t), /*native message size */
- H5O_fill_shared_decode, /*decode message */
- H5O_fill_shared_encode, /*encode message */
+ TRUE, /* messages are sharable? */
+ H5O_fill_shared_decode, /*decode message */
+ H5O_fill_shared_encode, /*encode message */
H5O_fill_new_copy, /*copy the native value */
- H5O_fill_shared_size, /*raw message size */
+ H5O_fill_shared_size, /*raw message size */
H5O_fill_new_reset, /*free internal memory */
H5O_fill_new_free, /* free method */
H5O_fill_shared_delete, /* file delete method */
H5O_fill_shared_link, /* link method */
- H5O_fill_new_get_share, /* get share method */
- H5O_fill_new_set_share, /* set share method */
+ H5O_shared_copy, /* set share method */
NULL, /*can share method */
- H5O_fill_new_is_shared, /* is shared method */
NULL, /* pre copy native value to file */
H5O_fill_shared_copy_file, /* copy native value to file */
NULL, /* post copy native value to file */
NULL, /* get creation index */
NULL, /* set creation index */
- H5O_fill_debug /*debug the message */
+ H5O_fill_shared_debug /*debug the message */
}};
/* This message derives from H5O message class, for new fill value after version 1.4 */
@@ -121,6 +123,7 @@ const H5O_msg_class_t H5O_MSG_FILL_NEW[1] = {{
H5O_FILL_NEW_ID, /*message id number */
"fill_new", /*message name for debugging */
sizeof(H5O_fill_t), /*native message size */
+ TRUE, /* messages are sharable? */
H5O_fill_new_shared_decode, /*decode message */
H5O_fill_new_shared_encode, /*encode message */
H5O_fill_new_copy, /*copy the native value */
@@ -129,16 +132,14 @@ const H5O_msg_class_t H5O_MSG_FILL_NEW[1] = {{
H5O_fill_new_free, /* free method */
H5O_fill_new_shared_delete, /* file delete method */
H5O_fill_new_shared_link, /* link method */
- H5O_fill_new_get_share, /* get share method */
- H5O_fill_new_set_share, /* set share method */
+ H5O_shared_copy, /* set share method */
NULL, /*can share method */
- H5O_fill_new_is_shared, /* is shared method */
NULL, /* pre copy native value to file */
H5O_fill_new_shared_copy_file, /* copy native value to file */
NULL, /* post copy native value to file */
NULL, /* get creation index */
NULL, /* set creation index */
- H5O_fill_new_debug /*debug the message */
+ H5O_fill_new_shared_debug /*debug the message */
}};
/* Initial version of the "old" fill value information */
@@ -600,96 +601,6 @@ H5O_fill_new_free(void *mesg)
/*-------------------------------------------------------------------------
- * Function: H5O_fill_new_get_share
- *
- * Purpose: Gets sharing information from the message
- *
- * Return: Shared message on success/NULL on failure
- *
- * Programmer: James Laird
- * Tuesday, October 10, 2006
- *
- *-------------------------------------------------------------------------
- */
-static void *
-H5O_fill_new_get_share(const void *_mesg, H5O_shared_t *sh /*out*/)
-{
- const H5O_fill_t *mesg = (const H5O_fill_t *)_mesg;
- void *ret_value;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_get_share)
-
- HDassert(mesg);
-
- ret_value = H5O_msg_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh);
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_fill_new_get_share() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_fill_new_set_share
- *
- * Purpose: Sets sharing information for the message
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: James Laird
- * Tuesday, October 10, 2006
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_fill_new_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh)
-{
- H5O_fill_t *mesg = (H5O_fill_t *)_mesg;
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_set_share)
-
- HDassert(mesg);
- HDassert(sh);
-
- if(NULL == H5O_msg_copy(H5O_SHARED_ID, sh, &(mesg->sh_loc)))
- ret_value = FAIL;
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_fill_new_set_share() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_fill_new_is_shared
- *
- * Purpose: Determines if this fill value is shared (committed or a SOHM)
- * or not.
- *
- * Return: TRUE if fill value is shared
- * FALSE if fill value is not shared
- * Negative on failure
- *
- * Programmer: James Laird
- * Monday, October 16, 2006
- *
- *-------------------------------------------------------------------------
- */
-static htri_t
-H5O_fill_new_is_shared(const void *_mesg)
-{
- const H5O_fill_t *mesg = (const H5O_fill_t *)_mesg;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_is_shared)
-
- HDassert(mesg);
-
- /* Fill values can't currently be committed, but this should let the
- * library read a "committed fill value" if we ever create one in
- * the future.
- */
- FUNC_LEAVE_NOAPI(H5O_IS_SHARED(mesg->sh_loc.flags))
-} /* end H5O_fill_new_is_shared() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5O_fill_new_debug
*
* Purpose: Prints debugging info for the message.
@@ -707,7 +618,7 @@ static herr_t
H5O_fill_new_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *stream,
int indent, int fwidth)
{
- const H5O_fill_t *mesg = (const H5O_fill_t *)_mesg;
+ const H5O_fill_t *mesg = (const H5O_fill_t *)_mesg;
H5D_fill_value_t fill_status; /* Whether the fill value is defined */
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_debug)
@@ -715,8 +626,8 @@ H5O_fill_new_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FIL
HDassert(f);
HDassert(mesg);
HDassert(stream);
- HDassert(indent>=0);
- HDassert(fwidth>=0);
+ HDassert(indent >= 0);
+ HDassert(fwidth >= 0);
HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
"Version:", (unsigned)H5O_FILL_VERSION);
@@ -847,8 +758,6 @@ H5O_fill_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *s
* Programmer: Robb Matzke
* Thursday, October 1, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
diff --git a/src/H5Oginfo.c b/src/H5Oginfo.c
index d0fb5da..12a4646 100644
--- a/src/H5Oginfo.c
+++ b/src/H5Oginfo.c
@@ -33,9 +33,9 @@
/* PRIVATE PROTOTYPES */
static void *H5O_ginfo_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
-static herr_t H5O_ginfo_encode(H5F_t *f, uint8_t *p, const void *_mesg);
+static herr_t H5O_ginfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
static void *H5O_ginfo_copy(const void *_mesg, void *_dest);
-static size_t H5O_ginfo_size(const H5F_t *f, const void *_mesg);
+static size_t H5O_ginfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
static herr_t H5O_ginfo_free(void *_mesg);
static herr_t H5O_ginfo_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
@@ -45,6 +45,7 @@ const H5O_msg_class_t H5O_MSG_GINFO[1] = {{
H5O_GINFO_ID, /*message id number */
"ginfo", /*message name for debugging */
sizeof(H5O_ginfo_t), /*native message size */
+ FALSE, /* messages are sharable? */
H5O_ginfo_decode, /*decode message */
H5O_ginfo_encode, /*encode message */
H5O_ginfo_copy, /*copy the native value */
@@ -53,10 +54,8 @@ const H5O_msg_class_t H5O_MSG_GINFO[1] = {{
H5O_ginfo_free, /* free method */
NULL, /* file delete method */
NULL, /* link method */
- NULL, /*get share method */
NULL, /*set share method */
NULL, /*can share method */
- NULL, /*is shared method */
NULL, /* pre copy native value to file */
NULL, /* copy native value to file */
NULL, /* post copy native value to file */
@@ -149,12 +148,10 @@ done:
* koziol@ncsa.uiuc.edu
* Aug 30 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_ginfo_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg)
+H5O_ginfo_encode(H5F_t UNUSED *f, hbool_t UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *) _mesg;
unsigned char flags; /* Flags for encoding group info */
@@ -199,8 +196,6 @@ H5O_ginfo_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg)
* koziol@ncsa.uiuc.edu
* Aug 30 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void *
@@ -248,7 +243,7 @@ done:
*-------------------------------------------------------------------------
*/
static size_t
-H5O_ginfo_size(const H5F_t UNUSED *f, const void UNUSED *_mesg)
+H5O_ginfo_size(const H5F_t UNUSED *f, hbool_t UNUSED disable_shared, const void UNUSED *_mesg)
{
size_t ret_value; /* Return value */
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 6e9a71f..a542a7d 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -33,15 +33,15 @@
/* PRIVATE PROTOTYPES */
static void *H5O_layout_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
-static herr_t H5O_layout_encode(H5F_t *f, uint8_t *p, const void *_mesg);
+static herr_t H5O_layout_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
static void *H5O_layout_copy(const void *_mesg, void *_dest);
-static size_t H5O_layout_size(const H5F_t *f, const void *_mesg);
+static size_t H5O_layout_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
static herr_t H5O_layout_reset(void *_mesg);
static herr_t H5O_layout_free(void *_mesg);
static herr_t H5O_layout_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg,
hbool_t adj_link);
-static void *H5O_layout_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
- void *mesg_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata);
+static void *H5O_layout_copy_file(H5F_t *file_src, void *mesg_src,
+ H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata);
static herr_t H5O_layout_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
@@ -50,6 +50,7 @@ const H5O_msg_class_t H5O_MSG_LAYOUT[1] = {{
H5O_LAYOUT_ID, /*message id number */
"layout", /*message name for debugging */
sizeof(H5O_layout_t), /*native message size */
+ FALSE, /* messages are sharable? */
H5O_layout_decode, /*decode message */
H5O_layout_encode, /*encode message */
H5O_layout_copy, /*copy the native value */
@@ -58,10 +59,8 @@ const H5O_msg_class_t H5O_MSG_LAYOUT[1] = {{
H5O_layout_free, /*free the struct */
H5O_layout_delete, /* file delete method */
NULL, /* link method */
- NULL, /*get share method */
NULL, /*set share method */
NULL, /*can share method */
- NULL, /*is shared method */
NULL, /* pre copy native value to file */
H5O_layout_copy_file, /* copy native value to file */
NULL, /* post copy native value to file */
@@ -261,7 +260,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_layout_encode(H5F_t *f, uint8_t *p, const void *_mesg)
+H5O_layout_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
unsigned u;
@@ -319,7 +318,7 @@ H5O_layout_encode(H5F_t *f, uint8_t *p, const void *_mesg)
} /* end switch */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_layout_encode() */
@@ -336,8 +335,6 @@ done:
* Programmer: Robb Matzke
* Wednesday, October 8, 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void *
@@ -347,32 +344,32 @@ H5O_layout_copy(const void *_mesg, void *_dest)
H5O_layout_t *dest = (H5O_layout_t *) _dest;
void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_layout_copy);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_layout_copy)
/* check args */
- assert(mesg);
- if (!dest && NULL==(dest=H5FL_MALLOC(H5O_layout_t)))
+ HDassert(mesg);
+ if(!dest && NULL == (dest = H5FL_MALLOC(H5O_layout_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* copy */
*dest = *mesg;
/* Deep copy the buffer for compact datasets also */
- if(mesg->type==H5D_COMPACT) {
+ if(mesg->type == H5D_COMPACT) {
/* Allocate memory for the raw data */
- if (NULL==(dest->u.compact.buf=H5MM_malloc(dest->u.compact.size)))
+ if(NULL == (dest->u.compact.buf = H5MM_malloc(dest->u.compact.size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset")
/* Copy over the raw data */
- HDmemcpy(dest->u.compact.buf,mesg->u.compact.buf,dest->u.compact.size);
+ HDmemcpy(dest->u.compact.buf, mesg->u.compact.buf, dest->u.compact.size);
} /* end if */
/* Set return value */
- ret_value=dest;
+ ret_value = dest;
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_layout_copy() */
/*-------------------------------------------------------------------------
@@ -389,8 +386,6 @@ done:
* Programmer: Raymond Lu
* August 14, 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
size_t
@@ -399,11 +394,11 @@ H5O_layout_meta_size(const H5F_t *f, const void *_mesg)
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
size_t ret_value;
- FUNC_ENTER_NOAPI_NOINIT(H5O_layout_meta_size);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_layout_meta_size)
/* check args */
- assert(f);
- assert(mesg);
+ HDassert(f);
+ HDassert(mesg);
ret_value = 1 + /* Version number */
1; /* layout class type */
@@ -436,8 +431,8 @@ H5O_layout_meta_size(const H5F_t *f, const void *_mesg)
} /* end switch */
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_layout_meta_size() */
/*-------------------------------------------------------------------------
@@ -454,28 +449,26 @@ done:
* Programmer: Robb Matzke
* Wednesday, October 8, 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static size_t
-H5O_layout_size(const H5F_t *f, const void *_mesg)
+H5O_layout_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
size_t ret_value;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_layout_size);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_layout_size)
/* check args */
- assert(f);
- assert(mesg);
+ HDassert(f);
+ HDassert(mesg);
ret_value = H5O_layout_meta_size(f, mesg);
- if(mesg->type==H5D_COMPACT)
+ if(mesg->type == H5D_COMPACT)
ret_value += mesg->u.compact.size;/* data for compact dataset */
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_layout_size() */
/*-------------------------------------------------------------------------
@@ -612,14 +605,11 @@ done:
* Programmer: Peter Cao
* July 23, 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void *
-H5O_layout_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *mesg_type,
- void *mesg_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info,
- void *_udata)
+H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
+ hid_t dxpl_id, H5O_copy_t *cpy_info, void *_udata)
{
H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
H5O_layout_t *layout_src = (H5O_layout_t *) mesg_src;
diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c
index 6b286d9..b5c4041 100644
--- a/src/H5Olinfo.c
+++ b/src/H5Olinfo.c
@@ -35,12 +35,12 @@
/* PRIVATE PROTOTYPES */
static void *H5O_linfo_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
-static herr_t H5O_linfo_encode(H5F_t *f, uint8_t *p, const void *_mesg);
+static herr_t H5O_linfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
static void *H5O_linfo_copy(const void *_mesg, void *_dest);
-static size_t H5O_linfo_size(const H5F_t *f, const void *_mesg);
+static size_t H5O_linfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
static herr_t H5O_linfo_free(void *_mesg);
static herr_t H5O_linfo_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
-static void *H5O_linfo_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
+static void *H5O_linfo_copy_file(H5F_t *file_src,
void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info,
void *udata);
static herr_t H5O_linfo_post_copy_file(const H5O_loc_t *parent_src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc,
@@ -53,6 +53,7 @@ const H5O_msg_class_t H5O_MSG_LINFO[1] = {{
H5O_LINFO_ID, /*message id number */
"linfo", /*message name for debugging */
sizeof(H5O_linfo_t), /*native message size */
+ FALSE, /* messages are sharable? */
H5O_linfo_decode, /*decode message */
H5O_linfo_encode, /*encode message */
H5O_linfo_copy, /*copy the native value */
@@ -61,10 +62,8 @@ const H5O_msg_class_t H5O_MSG_LINFO[1] = {{
H5O_linfo_free, /* free method */
H5O_linfo_delete, /* file delete method */
NULL, /* link method */
- NULL, /*get share method */
NULL, /*set share method */
NULL, /*can share method */
- NULL, /*is shared method */
NULL, /* pre copy native value to file */
H5O_linfo_copy_file, /* copy native value to file */
H5O_linfo_post_copy_file, /* post copy native value to file */
@@ -181,7 +180,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_linfo_encode(H5F_t *f, uint8_t *p, const void *_mesg)
+H5O_linfo_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg;
unsigned char index_flags; /* Flags for encoding link index info */
@@ -283,7 +282,7 @@ done:
*-------------------------------------------------------------------------
*/
static size_t
-H5O_linfo_size(const H5F_t *f, const void *_mesg)
+H5O_linfo_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg)
{
const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg;
size_t ret_value; /* Return value */
@@ -378,9 +377,8 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_linfo_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *mesg_type,
- void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info,
- void UNUSED *udata)
+H5O_linfo_copy_file(H5F_t UNUSED *file_src, void *native_src, H5F_t *file_dst,
+ hid_t dxpl_id, H5O_copy_t *cpy_info, void UNUSED *udata)
{
H5O_linfo_t *linfo_src = (H5O_linfo_t *) native_src;
H5O_linfo_t *linfo_dst = NULL;
diff --git a/src/H5Olink.c b/src/H5Olink.c
index b77446e..47ebfdb 100644
--- a/src/H5Olink.c
+++ b/src/H5Olink.c
@@ -38,17 +38,16 @@
/* PRIVATE PROTOTYPES */
static void *H5O_link_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
-static herr_t H5O_link_encode(H5F_t *f, uint8_t *p, const void *_mesg);
+static herr_t H5O_link_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
static void *H5O_link_copy(const void *_mesg, void *_dest);
-static size_t H5O_link_size(const H5F_t *f, const void *_mesg);
+static size_t H5O_link_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
static herr_t H5O_link_reset(void *_mesg);
static herr_t H5O_link_free(void *_mesg);
/* static herr_t H5O_link_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link); */
-static herr_t H5O_link_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 void *H5O_link_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
- void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info,
- void *udata);
+static herr_t H5O_link_pre_copy_file(H5F_t *file_src, const void *mesg_src,
+ hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata);
+static void *H5O_link_copy_file(H5F_t *file_src, void *native_src,
+ H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata);
static herr_t H5O_link_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc,
void *mesg_dst, hid_t dxpl_id, H5O_copy_t *cpy_info);
static herr_t H5O_link_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
@@ -59,6 +58,7 @@ const H5O_msg_class_t H5O_MSG_LINK[1] = {{
H5O_LINK_ID, /*message id number */
"link", /*message name for debugging */
sizeof(H5O_link_t), /*native message size */
+ FALSE, /* messages are sharable? */
H5O_link_decode, /*decode message */
H5O_link_encode, /*encode message */
H5O_link_copy, /*copy the native value */
@@ -67,10 +67,8 @@ const H5O_msg_class_t H5O_MSG_LINK[1] = {{
H5O_link_free, /* free method */
H5O_link_delete, /* file delete method */
NULL, /* link method */
- NULL, /*get share method */
NULL, /*set share method */
NULL, /*can share method */
- NULL, /*is shared method */
H5O_link_pre_copy_file, /* pre copy native value to file */
H5O_link_copy_file, /* copy native value to file */
H5O_link_post_copy_file, /* post copy native value to file */
@@ -232,7 +230,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_link_encode(H5F_t *f, uint8_t *p, const void *_mesg)
+H5O_link_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
const H5O_link_t *lnk = (const H5O_link_t *) _mesg;
size_t len; /* Length of a string in the message */
@@ -381,7 +379,7 @@ done:
*-------------------------------------------------------------------------
*/
static size_t
-H5O_link_size(const H5F_t *f, const void *_mesg)
+H5O_link_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg)
{
const H5O_link_t *lnk = (const H5O_link_t *)_mesg;
size_t ret_value; /* Return value */
@@ -573,9 +571,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_link_pre_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *type,
- const void UNUSED *native_src, hbool_t *deleted, const H5O_copy_t *cpy_info,
- void UNUSED *udata)
+H5O_link_pre_copy_file(H5F_t UNUSED *file_src, const void UNUSED *native_src,
+ hbool_t *deleted, const H5O_copy_t *cpy_info, void UNUSED *udata)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_link_pre_copy_file)
@@ -610,9 +607,8 @@ H5O_link_pre_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *typ
*-------------------------------------------------------------------------
*/
static void *
-H5O_link_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *mesg_type,
- void *native_src, H5F_t UNUSED *file_dst, hid_t UNUSED dxpl_id,
- H5O_copy_t UNUSED *cpy_info, void UNUSED *udata)
+H5O_link_copy_file(H5F_t UNUSED *file_src, void *native_src, H5F_t UNUSED *file_dst,
+ hid_t UNUSED dxpl_id, H5O_copy_t UNUSED *cpy_info, void UNUSED *udata)
{
H5O_link_t *link_src = (H5O_link_t *)native_src;
H5O_link_t *link_dst = NULL;
diff --git a/src/H5Omessage.c b/src/H5Omessage.c
index 1c9235e..99cbed6 100644
--- a/src/H5Omessage.c
+++ b/src/H5Omessage.c
@@ -45,31 +45,6 @@
/* Local Macros */
/****************/
-/* Load native information for a message, if it's not already present */
-/* (Only works for messages with decode callback) */
-#define H5O_LOAD_NATIVE(F, DXPL, MSG, ERR) \
- if(NULL == (MSG)->native) { \
- const H5O_msg_class_t *decode_type; \
- \
- /* Check for shared message */ \
- if(((MSG)->flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED((MSG)->type)) \
- decode_type = H5O_MSG_SHARED; \
- else \
- decode_type = (MSG)->type; \
- \
- /* Decode the message */ \
- HDassert(decode_type->decode); \
- if(NULL == ((MSG)->native = (decode_type->decode)((F), (DXPL), (MSG)->flags, (MSG)->raw))) \
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, ERR, "unable to decode message") \
- \
- /* Set the message's "creation index", if it has one */ \
- if((MSG)->type->set_crt_index) { \
- /* Set the creation index for the message */ \
- if(((MSG)->type->set_crt_index)((MSG)->native, (MSG)->crt_idx) < 0) \
- HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, ERR, "unable to set creation index") \
- } /* end if */ \
- } /* end if */
-
/******************/
/* Local Typedefs */
@@ -100,16 +75,12 @@ static herr_t H5O_msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *typ
unsigned overwrite, unsigned mesg_flags, unsigned update_flags,
void *mesg, hid_t dxpl_id, unsigned *oh_flags_ptr);
static herr_t H5O_msg_reset_real(const H5O_msg_class_t *type, void *native);
-static void *H5O_msg_copy_real(const H5O_msg_class_t *type, const void *mesg,
- void *dst);
static herr_t H5O_msg_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_msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
unsigned sequence, unsigned *oh_flags_ptr, void *_udata/*in,out*/);
static unsigned H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *flags,
- const H5O_msg_class_t *orig_type, void *orig_mesg, H5O_shared_t *sh_mesg,
- const H5O_msg_class_t **new_type, void **new_mesg, hid_t dxpl_id,
- unsigned *oh_flags_ptr);
+ const H5O_msg_class_t *type, void *mesg, hid_t dxpl_id, unsigned *oh_flags_ptr);
static herr_t H5O_copy_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);
@@ -220,24 +191,6 @@ H5O_msg_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned type_id,
HDassert(mesg);
HDassert(oh_flags_ptr);
- /* Should this message be written as a SOHM? */
- if(!(mesg_flags & H5O_MSG_FLAG_DONTSHARE) && !H5O_NEW_SHARED(type)) {
- htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */
-
- /* Check if message is already shared */
- if((shared_mesg = H5O_msg_is_shared(type_id, mesg)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "error determining if message is shared")
- else if(shared_mesg > 0)
- mesg_flags |= H5O_MSG_FLAG_SHARED;
- else {
- 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_mesg < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "error determining if message should be shared")
- } /* end else */
- } /* end if */
-
/* Append new message to object header */
if(H5O_msg_append_real(f, dxpl_id, oh, type, mesg_flags, update_flags, mesg, oh_flags_ptr) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to create new message in header")
@@ -264,12 +217,8 @@ done:
*/
herr_t
H5O_msg_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type,
- unsigned mesg_flags, unsigned update_flags, void *mesg,
- unsigned *oh_flags_ptr)
+ unsigned mesg_flags, unsigned update_flags, void *mesg, unsigned *oh_flags_ptr)
{
- const H5O_msg_class_t *new_type; /* Actual H5O class type for the ID */
- void *new_mesg; /* Actual message to write */
- H5O_shared_t sh_mesg; /* Shared object header info */
unsigned idx; /* Index of message to modify */
herr_t ret_value = SUCCEED; /* Return value */
@@ -284,11 +233,11 @@ H5O_msg_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *t
HDassert(oh_flags_ptr);
/* Create a new message */
- if((idx = H5O_new_mesg(f, oh, &mesg_flags, type, mesg, &sh_mesg, &new_type, &new_mesg, dxpl_id, oh_flags_ptr)) == UFAIL)
+ if((idx = H5O_new_mesg(f, oh, &mesg_flags, type, mesg, dxpl_id, oh_flags_ptr)) == UFAIL)
HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "unable to create new message")
/* Copy the information for the message */
- if(H5O_copy_mesg(f, dxpl_id, oh, idx, new_type, new_mesg, mesg_flags, update_flags, oh_flags_ptr) < 0)
+ if(H5O_copy_mesg(f, dxpl_id, oh, idx, type, mesg, mesg_flags, update_flags, oh_flags_ptr) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to write message")
#ifdef H5O_DEBUG
H5O_assert(oh);
@@ -350,19 +299,6 @@ H5O_msg_write(H5O_loc_t *loc, unsigned type_id, unsigned overwrite,
if(0 == (H5F_INTENT(loc->file) & H5F_ACC_RDWR))
HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file")
- if(!H5O_NEW_SHARED(type)) {
- /* Should this message be written as a SOHM? */
- if(!(mesg_flags & H5O_MSG_FLAG_DONTSHARE)) {
- htri_t shared_mesg; /* Whether the message should be shared */
-
- 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_mesg < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "error while trying to share message")
- } /* end if */
- } /* end if */
-
/* Protect the object header */
if(NULL == (oh = (H5O_t *)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")
@@ -409,12 +345,9 @@ H5O_msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
unsigned overwrite, unsigned mesg_flags, unsigned update_flags,
void *mesg, hid_t dxpl_id, unsigned *oh_flags_ptr)
{
+ H5O_mesg_t *idx_msg; /* Pointer to message to modify */
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; /* Shared message to store */
- 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_msg_write_real)
@@ -440,9 +373,9 @@ H5O_msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message not found")
/* Check for modifying a constant message */
- if(idx_msg->flags & H5O_MSG_FLAG_CONSTANT) {
+ if(idx_msg->flags & H5O_MSG_FLAG_CONSTANT)
HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify constant message")
- } else if(idx_msg->flags & H5O_MSG_FLAG_SHARED) {
+ else if(idx_msg->flags & H5O_MSG_FLAG_SHARED) {
/* This message is shared, but it's being modified. This is valid if
* it's shared in the heap .
* First, make sure it's not a committed message; these can't ever
@@ -454,46 +387,22 @@ H5O_msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
if(H5SM_try_delete(f, dxpl_id, idx_msg->type->id, (H5O_shared_t *)idx_msg->native) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to delete message from SOHM table")
- if(H5O_NEW_SHARED(type)) {
- /* Should this message be written as a SOHM? */
- if(!(mesg_flags & H5O_MSG_FLAG_DONTSHARE)) {
- htri_t shared_mesg; /* Whether the message should be shared */
+ /* Should this message be written as a SOHM? */
+ if(!(mesg_flags & H5O_MSG_FLAG_DONTSHARE)) {
+ htri_t shared_mesg; /* Whether the message should be shared */
/* XXX: Maybe this should be before the "try_delete" call? */
/* (and the try_delete would need to use a copy of the message's shared info) */
- if((shared_mesg = H5SM_try_share(f, dxpl_id, idx_msg->type->id, mesg)) > 0)
- /* Mark the message as shared */
- mesg_flags |= H5O_MSG_FLAG_SHARED;
- else if(shared_mesg < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "error while trying to share message")
- } /* end if */
+ if((shared_mesg = H5SM_try_share(f, dxpl_id, idx_msg->type->id, mesg)) > 0)
+ /* Mark the message as shared */
+ mesg_flags |= H5O_MSG_FLAG_SHARED;
+ else if(shared_mesg < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "error while trying to share message")
} /* end if */
- else {
- /* 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
- * really a shared pointer, not a real message).
- *
- * Note that this only works when shared messages are replaced by other
- * shared messages. Currently, messages can't shrink once they've
- * been written to object headers so this is a safe assumption (for
- * now).
- */
- HDassert(H5O_msg_is_shared(type->id, mesg) > 0);
-
- /* Extract shared message info from current message */
- if(NULL == H5O_msg_get_share(type->id, mesg, &sh_mesg))
- 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_SHARED;
- write_mesg = &sh_mesg;
- } /* end else */
} /* end if */
/* Copy the information for the message */
- if(H5O_copy_mesg(f, dxpl_id, oh, idx, write_type, write_mesg, mesg_flags, update_flags, oh_flags_ptr) < 0)
+ if(H5O_copy_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);
@@ -611,30 +520,18 @@ H5O_msg_read_real(H5F_t *f, H5O_t *oh, unsigned type_id, int sequence,
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "unable to find object header message")
/*
- * Decode the message if necessary. If the message is shared then decode
- * a shared message, ignoring the message type.
+ * Decode the message if necessary. If the message is shared then retrieve
+ * native message through the shared interface.
*/
H5O_LOAD_NATIVE(f, dxpl_id, &(oh->mesg[idx]), NULL)
- /* Read the message in */
- if((oh->mesg[idx].flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(type)) {
- /*
- * If the message is shared then then the native pointer points to an
- * H5O_MSG_SHARED message. We use that information to look up the real
- * message in the global heap or some other object header.
- */
- if(NULL == (ret_value = H5O_shared_read(f, dxpl_id, (const H5O_shared_t *)oh->mesg[idx].native, type, mesg)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space")
- } else {
- /*
- * The message is not shared, but rather exists in the object
- * header. The object header caches the native message (along with
- * the raw message) so we must copy the native message before
- * returning.
- */
- if(NULL == (ret_value = (type->copy)(oh->mesg[idx].native, mesg)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space")
- } /* end else */
+ /*
+ * The object header caches the native message (along with
+ * the raw message) so we must copy the native message before
+ * returning.
+ */
+ if(NULL == (ret_value = (type->copy)(oh->mesg[idx].native, mesg)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -772,10 +669,7 @@ H5O_msg_free_mesg(H5O_mesg_t *mesg)
HDassert(mesg);
/* Free any native information */
- if((mesg->flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(mesg->type))
- mesg->native = H5O_msg_free_real(H5O_MSG_SHARED, mesg->native);
- else
- mesg->native = H5O_msg_free_real(mesg->type, mesg->native);
+ mesg->native = H5O_msg_free_real(mesg->type, mesg->native);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_msg_free_mesg() */
@@ -840,13 +734,14 @@ H5O_msg_copy(unsigned type_id, const void *mesg, void *dst)
FUNC_ENTER_NOAPI(H5O_msg_copy, NULL)
/* check args */
+ HDassert(mesg);
HDassert(type_id < NELMTS(H5O_msg_class_g));
type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
HDassert(type);
- /* Call the "real" copy routine */
- if((ret_value = H5O_msg_copy_real(type, mesg, dst)) == NULL)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy object header message")
+ /* Call the message class's copy routine */
+ if(NULL == (ret_value = (type->copy)(mesg, dst)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy object header message")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -854,41 +749,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_msg_copy_real
- *
- * Purpose: Copies a message. If MESG is is the null pointer then a null
- * pointer is returned with no error.
- *
- * Return: Success: Ptr to the new message
- *
- * Failure: NULL
- *
- * Programmer: Robb Matzke
- * Thursday, May 21, 1998
- *
- *-------------------------------------------------------------------------
- */
-static void *
-H5O_msg_copy_real(const H5O_msg_class_t *type, const void *mesg, void *dst)
-{
- void *ret_value = NULL;
-
- FUNC_ENTER_NOAPI_NOINIT(H5O_msg_copy_real)
-
- /* check args */
- HDassert(type);
- HDassert(type->copy);
-
- if(mesg)
- if(NULL == (ret_value = (type->copy)(mesg, dst)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy object header message")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_msg_copy_real() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5O_msg_count
*
* Purpose: Counts the number of messages in an object header which are a
@@ -1370,11 +1230,9 @@ H5O_msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
hbool_t internal, H5O_mesg_operator_t op, void *op_data, hid_t dxpl_id,
unsigned *oh_flags_ptr)
{
+ H5O_mesg_t *idx_msg; /* Pointer to current message */
unsigned idx; /* Absolute index of current message in all messages */
unsigned sequence; /* Relative index of current message for messages of type */
- H5O_mesg_t *idx_msg; /* Pointer to current message */
- void *native_mesg=NULL; /* Native, readable message */
- hbool_t native_mesg_alloc = FALSE; /* True if native_mesg needs to be freed */
herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_msg_iterate_real)
@@ -1393,31 +1251,14 @@ H5O_msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
H5O_LOAD_NATIVE(f, dxpl_id, idx_msg, FAIL)
/* Check for making an "internal" (i.e. within the H5O package) callback */
- if(internal) {
- /* Call the "internal" iterator callback */
- if((ret_value = (op.lib_op)(oh, idx_msg, sequence, oh_flags_ptr, op_data)) != 0)
- break;
- } /* end if */
- else {
- /* If the message is shared, get the real message it points to */
- if((idx_msg->flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(idx_msg->type)) {
- if(NULL == (native_mesg = H5O_shared_read(f, dxpl_id, (const H5O_shared_t *)idx_msg->native, idx_msg->type, NULL)))
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "unable to read shared message")
- native_mesg_alloc = TRUE;
- } /* end if */
- else
- native_mesg = idx_msg->native;
-
- /* Call the iterator callback */
- if((ret_value = (op.app_op)(native_mesg, sequence, op_data)) != 0)
- break;
-
- /* Free the "real" message if it was allocated */
- if(native_mesg_alloc) {
- H5O_msg_free(idx_msg->type->id, native_mesg);
- native_mesg_alloc = FALSE;
- } /* end if */
- } /* end else */
+ if(internal)
+ ret_value = (op.lib_op)(oh, idx_msg, sequence, oh_flags_ptr, op_data);
+ else
+ ret_value = (op.app_op)(idx_msg->native, sequence, op_data);
+
+ /* Check for iterator callback indicating to get out of loop */
+ if(ret_value != 0)
+ break;
/* Increment sequence value for message type */
sequence++;
@@ -1429,10 +1270,6 @@ H5O_msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
HERROR(H5E_OHDR, H5E_CANTLIST, "iterator function failed");
done:
- /* Free the native message if it was allocated */
- if(native_mesg_alloc)
- H5O_msg_free(idx_msg->type->id, native_mesg);
-
/* Check if object message was modified */
if(*oh_flags_ptr & H5AC__DIRTIED_FLAG) {
/* Try to condense object header info */
@@ -1470,7 +1307,6 @@ H5O_msg_raw_size(const H5F_t *f, unsigned type_id, hbool_t disable_shared,
const void *mesg)
{
const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
- unsigned old_sh_mesg_flags = 0; /* Message's current shared message flags */
size_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_msg_raw_size, 0)
@@ -1483,32 +1319,10 @@ H5O_msg_raw_size(const H5F_t *f, unsigned type_id, hbool_t disable_shared,
HDassert(f);
HDassert(mesg);
- /* Check for disabling shared message encoding, to encode the "base" type */
- if(disable_shared) {
- H5O_shared_t *sh_mesg = (H5O_shared_t *)mesg; /* Pointer to message's shared message info */
-
- /* Try to make certain that this routine doesn't get invoked for
- * unsharable message classes
- */
- HDassert(type->is_shared);
-
- /* Preserve message's shared message info while getting the
- * "real" encoded size & buffer (*ick* - QAK)
- * (XXX: Harmless but ugly for message classes that aren't using shared
- * message method interface yet - QAK)
- */
- old_sh_mesg_flags = sh_mesg->flags;
- sh_mesg->flags = 0;
- } /* end if */
-
/* Compute the raw data size for the mesg */
- if((ret_value = (type->raw_size)(f, mesg)) == 0)
+ if((ret_value = (type->raw_size)(f, disable_shared, mesg)) == 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, 0, "unable to determine size of message")
- /* Restore message's shared message info, if appropriate (*ick* - QAK) */
- if(disable_shared)
- ((H5O_shared_t *)mesg)->flags = old_sh_mesg_flags;
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_msg_raw_size() */
@@ -1548,7 +1362,7 @@ H5O_msg_mesg_size(const H5F_t *f, unsigned type_id, const void *mesg, size_t ext
HDassert(mesg);
/* Compute the raw data size for the mesg */
- if((ret_value = (type->raw_size)(f, mesg)) == 0)
+ if((ret_value = (type->raw_size)(f, FALSE, mesg)) == 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, 0, "unable to determine size of message")
/* Add in "extra" raw space */
@@ -1566,53 +1380,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_msg_get_share
- *
- * Purpose: Call the 'get_share' method for a
- * particular class of object header. Fills SHARE
- * with the shared object, or allocated an H5O_shared_t
- * message and returns it.
- *
- * If SHARE is NULL, the return value must be freed
- * with H5O_msg_free.
- *
- * Return: Success: H5O_shared_t describing the shared information
- * for the message.
- *
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Oct 2 2003
- *
- *-------------------------------------------------------------------------
- */
-void *
-H5O_msg_get_share(unsigned type_id, const void *mesg, H5O_shared_t *share)
-{
- const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
- void *ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(H5O_msg_get_share, NULL)
-
- /* Check args */
- HDassert(type_id < NELMTS(H5O_msg_class_g));
- HDassert(type_id != H5O_SHARED_ID);
- type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
- HDassert(type);
- HDassert(type->get_share);
- HDassert(mesg);
-
- /* Get shared data for the mesg */
- if((ret_value = (type->get_share)(mesg, share)) == NULL)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to retrieve shared message information")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_msg_get_share() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5O_msg_can_share
*
* Purpose: Call the 'can share' method for a
@@ -1644,9 +1411,6 @@ H5O_msg_can_share(unsigned type_id, const void *mesg)
HDassert(type);
HDassert(mesg);
- /* If the message doesn't have an is_shared callback, it's not sharable
- * and thus can't be shared.
- */
/* If there is a can_share callback, use it */
if((type->can_share))
ret_value = (type->can_share)(mesg);
@@ -1658,7 +1422,7 @@ H5O_msg_can_share(unsigned type_id, const void *mesg)
ret_value = TRUE;
else
ret_value = FALSE;
- }
+ } /* end else */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_msg_can_share() */
@@ -1694,11 +1458,11 @@ H5O_msg_is_shared(unsigned type_id, const void *mesg)
HDassert(type);
HDassert(mesg);
- /* If there is no is_shared function, then obviously it's not a shared message! */
- if(!(type->is_shared))
+ /* If message class isn't sharable, then obviously it's not a shared message! */
+ if(!(type->is_sharable))
ret_value = FALSE;
else
- ret_value = (type->is_shared)(mesg);
+ ret_value = H5O_IS_SHARED(((const H5O_shared_t *)mesg)->flags);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_msg_is_shared() */
@@ -1813,7 +1577,6 @@ H5O_msg_encode(H5F_t *f, unsigned type_id, hbool_t disable_shared,
unsigned char *buf, const void *mesg)
{
const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
- unsigned old_sh_mesg_flags = 0; /* Message's current shared message flags */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_msg_encode,FAIL)
@@ -1824,32 +1587,10 @@ H5O_msg_encode(H5F_t *f, unsigned type_id, hbool_t disable_shared,
type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
HDassert(type);
- /* Check for disabling shared message encoding, to encode the "base" type */
- if(disable_shared) {
- H5O_shared_t *sh_mesg = (H5O_shared_t *)mesg; /* Pointer to message's shared message info */
-
- /* Try to make certain that this routine doesn't get invoked for
- * unsharable message classes
- */
- HDassert(type->is_shared);
-
- /* Preserve message's shared message info while getting the
- * "real" encoded size & buffer (*ick* - QAK)
- * (XXX: Harmless but ugly for message classes that aren't using shared
- * message method interface yet - QAK)
- */
- old_sh_mesg_flags = sh_mesg->flags;
- sh_mesg->flags = 0;
- } /* end if */
-
/* Encode */
- if((type->encode)(f, buf, mesg) < 0)
+ if((type->encode)(f, disable_shared, buf, mesg) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode message")
- /* Restore message's shared message info, if appropriate (*ick* - QAK) */
- if(disable_shared)
- ((H5O_shared_t *)mesg)->flags = old_sh_mesg_flags;
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_msg_encode() */
@@ -1916,98 +1657,41 @@ done:
*-------------------------------------------------------------------------
*/
void *
-H5O_msg_copy_file(const H5O_msg_class_t *copy_type, const H5O_msg_class_t *mesg_type,
- H5F_t *file_src, void *native_src, H5F_t *file_dst, hid_t dxpl_id,
+H5O_msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src,
+ void *native_src, H5F_t *file_dst, hid_t dxpl_id,
hbool_t *shared, H5O_copy_t *cpy_info, void *udata)
{
+ htri_t is_shared; /* Whether message is shared */
void *native_mesg = NULL;
- void *shared_mesg = NULL;
- hbool_t committed; /* TRUE if message is a committed message */
void *ret_value;
FUNC_ENTER_NOAPI_NOINIT(H5O_msg_copy_file)
/* check args */
- HDassert(copy_type);
- HDassert(copy_type->copy_file);
- HDassert(mesg_type);
+ HDassert(type);
+ HDassert(type->copy_file);
HDassert(file_src);
HDassert(native_src);
HDassert(file_dst);
HDassert(cpy_info);
- /* Check if this message is committed. We'll need to know this later. */
- committed = FALSE;
- if(copy_type->id == H5O_SHARED_ID) {
- H5O_shared_t *tmp_shared_mesg = (H5O_shared_t *)native_src;
-
- if(tmp_shared_mesg->flags & H5O_COMMITTED_FLAG) {
- HDassert(!(tmp_shared_mesg->flags & H5O_SHARED_IN_HEAP_FLAG));
- committed = TRUE;
- } /* end if */
- } /* end if */
-
/* The copy_file callback will return an H5O_shared_t only if the message
* to be copied is a committed datatype.
*/
- if(NULL == (native_mesg = (copy_type->copy_file)(file_src, mesg_type, native_src, file_dst, dxpl_id, cpy_info, udata)))
+ if(NULL == (native_mesg = (type->copy_file)(file_src, native_src, file_dst, dxpl_id, cpy_info, udata)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy object header message to file")
- /* Committed messages are always committed in the destination. Messages in
- * the heap are not shared by default--they need to be "re-shared" in the
- * destination.
- */
- if(committed == TRUE)
- *shared = TRUE;
- else {
- if(!H5O_NEW_SHARED(copy_type)) {
- *shared = FALSE;
-
- /* If message isn't committed but can be shared, handle with implicit sharing. */
- if(mesg_type->set_share) {
- htri_t try_share_ret; /* Value returned from H5SM_try_share */
-
- /* Try to share it in the destination file. */
- if((try_share_ret = H5SM_try_share(file_dst, dxpl_id, mesg_type->id, native_mesg)) < 0)
- HGOTO_ERROR(H5E_SOHM, H5E_WRITEERROR, NULL, "unable to determine if message should be shared")
-
- /* If it isn't shared, reset its sharing information. If it is
- * shared, its sharing information will have been overwritten by
- * H5SM_try_share.
- */
- if(try_share_ret == FALSE) {
- if(H5O_msg_reset_share(mesg_type->id, native_mesg) < 0)
- HGOTO_ERROR(H5E_SOHM, H5E_WRITEERROR, NULL, "unable to reset sharing information in message")
- } /* end if */
- else {
- /* Get shared message from native message */
- if(NULL == (shared_mesg = H5O_msg_get_share(mesg_type->id, native_mesg, NULL)))
- HGOTO_ERROR(H5E_SOHM, H5E_READERROR, NULL, "unable to get shared location from message")
-
- /* Free native message; the shared message is all we need to return */
- H5O_msg_free(mesg_type->id, native_mesg);
-
- native_mesg = shared_mesg;
- *shared = TRUE;
- } /* end else */
- } /* end if */
- } /* end if */
- else {
- htri_t is_shared; /* Whether new message is shared */
-
- /* Check if new message is shared */
- if((is_shared = H5O_msg_is_shared(copy_type->id, native_mesg)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to query message's shared status")
- *shared = is_shared;
- } /* end else */
- } /* end else */
+ /* Check if new message is shared */
+ if((is_shared = H5O_msg_is_shared(type->id, native_mesg)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to query message's shared status")
+ *shared = is_shared;
/* Set return value */
ret_value = native_mesg;
done:
- if(NULL == ret_value)
- H5O_msg_free(mesg_type->id, native_mesg);
+ if(NULL == ret_value && native_mesg)
+ H5O_msg_free(type->id, native_mesg);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_msg_copy_file() */
@@ -2027,11 +1711,11 @@ done:
*-------------------------------------------------------------------------
*/
static unsigned
-H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *mesg_flags, const H5O_msg_class_t *orig_type,
- void *orig_mesg, H5O_shared_t *sh_mesg, const H5O_msg_class_t **new_type,
- void **new_mesg, hid_t dxpl_id, unsigned *oh_flags_ptr)
+H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *mesg_flags, const H5O_msg_class_t *type,
+ void *mesg, hid_t dxpl_id, unsigned *oh_flags_ptr)
{
size_t size; /* Size of space allocated for object header */
+ htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */
unsigned ret_value = UFAIL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_new_mesg)
@@ -2040,93 +1724,47 @@ H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *mesg_flags, const H5O_msg_class_t *o
HDassert(f);
HDassert(oh);
HDassert(mesg_flags);
- HDassert(orig_type);
- HDassert(orig_mesg);
- HDassert(sh_mesg);
- HDassert(new_type);
- HDassert(new_mesg);
+ HDassert(!(*mesg_flags & H5O_MSG_FLAG_SHARED));
+ HDassert(type);
+ HDassert(mesg);
HDassert(oh_flags_ptr);
- /* Check for shared message */
- if((*mesg_flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(orig_type)) {
- htri_t is_shared; /* Is this a shared message? */
-
- 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 */
- HDmemset(sh_mesg, 0, sizeof(H5O_shared_t));
- if(NULL == (orig_type->get_share)(orig_mesg, sh_mesg/*out*/))
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, UFAIL, "can't get shared message")
-
- *new_type = H5O_MSG_SHARED;
- *new_mesg = sh_mesg;
- } else {
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, UFAIL, "can't determine if message is shared")
- } /* end else */
+ /* Check if message is already shared */
+ if((shared_mesg = H5O_msg_is_shared(type->id, mesg)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, UFAIL, "error determining if message is shared")
+ else if(shared_mesg > 0) {
+ /* Increment message's reference count */
+ if(type->link && (type->link)(f, dxpl_id, mesg) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, UFAIL, "unable to adjust shared message ref count")
+ *mesg_flags |= H5O_MSG_FLAG_SHARED;
} /* end if */
else {
- *new_type = orig_type;
- *new_mesg = orig_mesg;
- } /* end else */
-
- if(H5O_NEW_SHARED(orig_type)) {
- htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */
-
- HDassert(!(*mesg_flags & H5O_MSG_FLAG_SHARED));
-
- /* Check if message is already shared */
- if((shared_mesg = H5O_msg_is_shared((*new_type)->id, (*new_mesg))) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, UFAIL, "error determining if message is shared")
- else if(shared_mesg > 0) {
- /* Increment message's reference count */
- if((*new_type)->link && ((*new_type)->link)(f, dxpl_id, (*new_mesg)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, UFAIL, "unable to adjust shared message ref count")
- *mesg_flags |= H5O_MSG_FLAG_SHARED;
+ /* Avoid unsharable messages */
+ if(!(*mesg_flags & H5O_MSG_FLAG_DONTSHARE)) {
+ /* Attempt to share message */
+ 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_mesg < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, UFAIL, "error determining if message should be shared")
} /* end if */
- else {
- /* Avoid unsharable messages */
- if(!(*mesg_flags & H5O_MSG_FLAG_DONTSHARE)) {
- /* Attempt to share message */
- if((shared_mesg = H5SM_try_share(f, dxpl_id, (*new_type)->id, (*new_mesg))) > 0)
- /* Mark the message as shared */
- *mesg_flags |= H5O_MSG_FLAG_SHARED;
- else if(shared_mesg < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, UFAIL, "error determining if message should be shared")
- } /* end if */
- } /* end else */
- } /* end if */
+ } /* end else */
/* Compute the size needed to store the message on disk */
- if((size = ((*new_type)->raw_size)(f, *new_mesg)) >= H5O_MESG_MAX_SIZE)
+ if((size = (type->raw_size)(f, FALSE, mesg)) >= H5O_MESG_MAX_SIZE)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, UFAIL, "object header message is too large")
/* Allocate space in the object header for the message */
- if((ret_value = H5O_alloc(f, dxpl_id, oh, orig_type, size, oh_flags_ptr)) == UFAIL)
+ if((ret_value = H5O_alloc(f, dxpl_id, oh, type, size, oh_flags_ptr)) == UFAIL)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, UFAIL, "unable to allocate space for message")
/* Get the message's "creation index", if it has one */
- if(orig_type->get_crt_index) {
+ if(type->get_crt_index) {
/* Retrieve the creation index for the message */
- if((orig_type->get_crt_index)(orig_mesg, &oh->mesg[ret_value].crt_idx) < 0)
+ if((type->get_crt_index)(mesg, &oh->mesg[ret_value].crt_idx) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, UFAIL, "unable to retrieve creation index")
} /* end if */
- if(!H5O_NEW_SHARED(orig_type)) {
- /* Increment any links in message */
- if((*new_type)->link && ((*new_type)->link)(f, dxpl_id, (*new_mesg)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, UFAIL, "unable to adjust shared object link count")
- } /* end if */
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_new_mesg() */
@@ -2150,8 +1788,8 @@ H5O_copy_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 */
+ H5O_mesg_t *idx_msg = &oh->mesg[idx]; /* Pointer to message to modify */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_copy_mesg)
@@ -2162,9 +1800,6 @@ H5O_copy_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx,
HDassert(mesg);
HDassert(oh_flags_ptr);
- /* Set pointer to the correct message */
- idx_msg = &oh->mesg[idx];
-
/* Reset existing native information for the header's message */
H5O_msg_reset_real(type, idx_msg->native);
@@ -2248,7 +1883,7 @@ done:
herr_t
H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_mesg_t *mesg, hbool_t adj_link)
{
- const H5O_msg_class_t *type; /* Type of object to free */
+ const H5O_msg_class_t *type = mesg->type; /* Type of object to free */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_delete_mesg, FAIL)
@@ -2257,35 +1892,10 @@ H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_mesg_t *mesg, hbool_t adj_link)
HDassert(f);
HDassert(mesg);
- /* Get the message to free's type */
- if((mesg->flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(mesg->type))
- type = H5O_MSG_SHARED;
- else
- type = mesg->type;
-
/* Check if there is a file space deletion callback for this type of message */
if(type->del) {
/* Decode the message if necessary. */
- if(NULL == mesg->native) {
- HDassert(type->decode);
- if(NULL == (mesg->native = (type->decode)(f, dxpl_id, mesg->flags, mesg->raw)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode message")
-
- /* Set the message's "creation index", if it has one */
- if(mesg->type->set_crt_index) {
- /* Set the creation index for the message */
- if((mesg->type->set_crt_index)(mesg->native, mesg->crt_idx) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set creation index")
- } /* end if */
- } /* end if */
-
- /* Check if this message needs to be removed from the SOHM table if
- * it's a shared message.
- */
- if(type == H5O_MSG_SHARED) {
- if(H5SM_try_delete(f, dxpl_id, mesg->type->id, (H5O_shared_t *)mesg->native) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to delete message from SOHM table")
- } /* end if */
+ H5O_LOAD_NATIVE(f, dxpl_id, mesg, FAIL)
if((type->del)(f, dxpl_id, mesg->native, adj_link) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message")
diff --git a/src/H5Omtime.c b/src/H5Omtime.c
index 5015264..d180cc6 100644
--- a/src/H5Omtime.c
+++ b/src/H5Omtime.c
@@ -33,13 +33,13 @@
static void *H5O_mtime_new_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
-static herr_t H5O_mtime_new_encode(H5F_t *f, uint8_t *p, const void *_mesg);
-static size_t H5O_mtime_new_size(const H5F_t *f, const void *_mesg);
+static herr_t H5O_mtime_new_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
+static size_t H5O_mtime_new_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
static void *H5O_mtime_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
-static herr_t H5O_mtime_encode(H5F_t *f, uint8_t *p, const void *_mesg);
+static herr_t H5O_mtime_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
static void *H5O_mtime_copy(const void *_mesg, void *_dest);
-static size_t H5O_mtime_size(const H5F_t *f, const void *_mesg);
+static size_t H5O_mtime_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
static herr_t H5O_mtime_reset(void *_mesg);
static herr_t H5O_mtime_free(void *_mesg);
static herr_t H5O_mtime_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
@@ -50,6 +50,7 @@ const H5O_msg_class_t H5O_MSG_MTIME[1] = {{
H5O_MTIME_ID, /*message id number */
"mtime", /*message name for debugging */
sizeof(time_t), /*native message size */
+ FALSE, /* messages are sharable? */
H5O_mtime_decode, /*decode message */
H5O_mtime_encode, /*encode message */
H5O_mtime_copy, /*copy the native value */
@@ -58,10 +59,8 @@ const H5O_msg_class_t H5O_MSG_MTIME[1] = {{
H5O_mtime_free, /* free method */
NULL, /* file delete method */
NULL, /* link method */
- NULL, /*get share method */
NULL, /*set share method */
NULL, /*can share method */
- NULL, /*is shared method */
NULL, /* pre copy native value to file */
NULL, /* copy native value to file */
NULL, /* post copy native value to file */
@@ -76,6 +75,7 @@ const H5O_msg_class_t H5O_MSG_MTIME_NEW[1] = {{
H5O_MTIME_NEW_ID, /*message id number */
"mtime_new", /*message name for debugging */
sizeof(time_t), /*native message size */
+ FALSE, /* messages are sharable? */
H5O_mtime_new_decode, /*decode message */
H5O_mtime_new_encode, /*encode message */
H5O_mtime_copy, /*copy the native value */
@@ -84,10 +84,8 @@ const H5O_msg_class_t H5O_MSG_MTIME_NEW[1] = {{
H5O_mtime_free, /* free method */
NULL, /* file delete method */
NULL, /* link method */
- NULL, /*get share method */
NULL, /*set share method */
NULL, /*can share method */
- NULL, /*is shared method */
NULL, /* pre copy native value to file */
NULL, /* copy native value to file */
NULL, /* post copy native value to file */
@@ -302,12 +300,10 @@ done:
* koziol@ncsa.uiuc.edu
* Jan 3 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_mtime_new_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg)
+H5O_mtime_new_encode(H5F_t UNUSED *f, hbool_t UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
const time_t *mesg = (const time_t *) _mesg;
@@ -349,7 +345,7 @@ H5O_mtime_new_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_mtime_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg)
+H5O_mtime_encode(H5F_t UNUSED *f, hbool_t UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
const time_t *mesg = (const time_t *) _mesg;
struct tm *tm;
@@ -435,7 +431,7 @@ done:
*-------------------------------------------------------------------------
*/
static size_t
-H5O_mtime_new_size(const H5F_t UNUSED * f, const void UNUSED * mesg)
+H5O_mtime_new_size(const H5F_t UNUSED * f, hbool_t UNUSED disable_shared, const void UNUSED * mesg)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mtime_new_size);
@@ -468,7 +464,7 @@ H5O_mtime_new_size(const H5F_t UNUSED * f, const void UNUSED * mesg)
*-------------------------------------------------------------------------
*/
static size_t
-H5O_mtime_size(const H5F_t UNUSED * f, const void UNUSED * mesg)
+H5O_mtime_size(const H5F_t UNUSED * f, hbool_t UNUSED disable_shared, const void UNUSED * mesg)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mtime_size);
diff --git a/src/H5Oname.c b/src/H5Oname.c
index 4b528b8..3402690 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -33,9 +33,9 @@
/* PRIVATE PROTOTYPES */
static void *H5O_name_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
-static herr_t H5O_name_encode(H5F_t *f, uint8_t *p, const void *_mesg);
+static herr_t H5O_name_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
static void *H5O_name_copy(const void *_mesg, void *_dest);
-static size_t H5O_name_size(const H5F_t *f, const void *_mesg);
+static size_t H5O_name_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
static herr_t H5O_name_reset(void *_mesg);
static herr_t H5O_name_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
@@ -45,18 +45,17 @@ const H5O_msg_class_t H5O_MSG_NAME[1] = {{
H5O_NAME_ID, /*message id number */
"name", /*message name for debugging */
sizeof(H5O_name_t), /*native message size */
+ FALSE, /* messages are sharable? */
H5O_name_decode, /*decode message */
H5O_name_encode, /*encode message */
H5O_name_copy, /*copy the native value */
H5O_name_size, /*raw message size */
H5O_name_reset, /*free internal memory */
- NULL, /* free method */
+ NULL, /* free method */
NULL, /* file delete method */
NULL, /* link method */
- NULL, /*get share method */
NULL, /*set share method */
NULL, /*can share method */
- NULL, /*is shared method */
NULL, /* pre copy native value to file */
NULL, /* copy native value to file */
NULL, /* post copy native value to file */
@@ -130,7 +129,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_name_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg)
+H5O_name_encode(H5F_t UNUSED *f, hbool_t UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
const H5O_name_t *mesg = (const H5O_name_t *) _mesg;
@@ -214,7 +213,7 @@ done:
*-------------------------------------------------------------------------
*/
static size_t
-H5O_name_size(const H5F_t UNUSED *f, const void *_mesg)
+H5O_name_size(const H5F_t UNUSED *f, hbool_t UNUSED disable_shared, const void *_mesg)
{
const H5O_name_t *mesg = (const H5O_name_t *) _mesg;
size_t ret_value;
diff --git a/src/H5Onull.c b/src/H5Onull.c
index 914d8be..98049d8 100644
--- a/src/H5Onull.c
+++ b/src/H5Onull.c
@@ -34,6 +34,7 @@ const H5O_msg_class_t H5O_MSG_NULL[1] = {{
H5O_NULL_ID, /*message id number */
"null", /*message name for debugging */
0, /*native message size */
+ FALSE, /*messages are sharable? */
NULL, /*no decode method */
NULL, /*no encode method */
NULL, /*no copy method */
@@ -42,10 +43,8 @@ const H5O_msg_class_t H5O_MSG_NULL[1] = {{
NULL, /*no free method */
NULL, /*no file delete method */
NULL, /*no link method */
- NULL, /*no get share method */
NULL, /*no set share method */
NULL, /*no can share method */
- NULL, /*no is_shared method */
NULL, /*no pre copy native value to file */
NULL, /*no copy native value to file */
NULL, /*no post copy native value to file */
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index 0a0310d..0f5a7ae 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -157,10 +157,24 @@
#define H5O_SIZEOF_CHKSUM_OH(O) \
H5O_SIZEOF_CHKSUM_VERS((O)->version)
-/* Temporary macro to define which message classes are using the "new"
- * shared message "interface" for their methods.
- */
-#define H5O_NEW_SHARED(T) ((T) == H5O_MSG_PLINE || (T) == H5O_MSG_FILL_NEW || (T) == H5O_MSG_FILL || (T) == H5O_MSG_SDSPACE || (T) == H5O_MSG_DTYPE || (T) == H5O_MSG_ATTR)
+/* Load native information for a message, if it's not already present */
+/* (Only works for messages with decode callback) */
+#define H5O_LOAD_NATIVE(F, DXPL, MSG, ERR) \
+ if(NULL == (MSG)->native) { \
+ const H5O_msg_class_t *decode_type = (MSG)->type; \
+ \
+ /* Decode the message */ \
+ HDassert(decode_type->decode); \
+ if(NULL == ((MSG)->native = (decode_type->decode)((F), (DXPL), (MSG)->flags, (MSG)->raw))) \
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, ERR, "unable to decode message") \
+ \
+ /* Set the message's "creation index", if it has one */ \
+ if((MSG)->type->set_crt_index) { \
+ /* Set the creation index for the message */ \
+ if((decode_type->set_crt_index)((MSG)->native, (MSG)->crt_idx) < 0) \
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, ERR, "unable to set creation index") \
+ } /* end if */ \
+ } /* end if */
/* The "message class" type */
@@ -168,20 +182,19 @@ struct H5O_msg_class_t {
unsigned id; /*message type ID on disk */
const char *name; /*for debugging */
size_t native_size; /*size of native message */
+ hbool_t is_sharable; /*are messages of this class sharable? */
void *(*decode)(H5F_t*, hid_t, unsigned, const uint8_t *);
- herr_t (*encode)(H5F_t*, uint8_t*, const void *);
+ herr_t (*encode)(H5F_t*, hbool_t, uint8_t*, const void *);
void *(*copy)(const void *, void *); /*copy native value */
- size_t (*raw_size)(const H5F_t *, const void *);/*sizeof encoded message */
+ size_t (*raw_size)(const H5F_t *, hbool_t, const void *);/*sizeof encoded message */
herr_t (*reset)(void *); /*free nested data structs */
herr_t (*free)(void *); /*free main data struct */
herr_t (*del)(H5F_t *, hid_t, const void *, hbool_t); /* Delete space in file referenced by this message */
herr_t (*link)(H5F_t *, hid_t, const void *); /* Increment any links in file reference by this message */
- void *(*get_share)(const void*, struct H5O_shared_t*); /* Get shared information */
- herr_t (*set_share)(void*, const struct H5O_shared_t*); /* Set shared information */
+ herr_t (*set_share)(void*, const H5O_shared_t*); /* Set shared information */
htri_t (*can_share)(const void *); /* Is message allowed to be shared? */
- htri_t (*is_shared)(const void *); /* Is message shared? */
- herr_t (*pre_copy_file)(H5F_t *, const H5O_msg_class_t *, const void *, hbool_t *, const H5O_copy_t *, void *); /*"pre copy" action when copying native value to file */
- void *(*copy_file)(H5F_t *, const H5O_msg_class_t *, void *, H5F_t *, hid_t, H5O_copy_t *, void *); /*copy native value to file */
+ herr_t (*pre_copy_file)(H5F_t *, const void *, hbool_t *, const H5O_copy_t *, void *); /*"pre copy" action when copying native value to file */
+ void *(*copy_file)(H5F_t *, void *, H5F_t *, hid_t, H5O_copy_t *, void *); /*copy native value to file */
herr_t (*post_copy_file)(const H5O_loc_t *, const void *, H5O_loc_t *, void *, hid_t, H5O_copy_t *); /*"post copy" action when copying native value to file */
herr_t (*get_crt_index)(const void *, H5O_crt_idx_t *); /* Get message's creation index */
herr_t (*set_crt_index)(void *, H5O_crt_idx_t); /* Set message's creation index */
@@ -418,9 +431,9 @@ H5_DLL void *H5O_msg_read_real(H5F_t *f, H5O_t *oh, unsigned type_id,
H5_DLL void *H5O_msg_free_real(const H5O_msg_class_t *type, void *mesg);
H5_DLL herr_t H5O_msg_free_mesg(H5O_mesg_t *mesg);
H5_DLL htri_t H5O_msg_exists_oh(struct H5O_t *oh, unsigned type_id, int sequence);
-H5_DLL void * H5O_msg_copy_file(const H5O_msg_class_t *copy_type,
- const H5O_msg_class_t *mesg_type, H5F_t *file_src, void *mesg_src,
- H5F_t *file_dst, hid_t dxpl_id, hbool_t *shared, H5O_copy_t *cpy_info, void *udata);
+H5_DLL void *H5O_msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src,
+ void *mesg_src, H5F_t *file_dst, hid_t dxpl_id, hbool_t *shared,
+ H5O_copy_t *cpy_info, void *udata);
H5_DLL herr_t H5O_msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
hbool_t internal, H5O_mesg_operator_t op, void *op_data, hid_t dxpl_id,
unsigned *oh_flags_ptr);
@@ -433,19 +446,18 @@ H5_DLL herr_t H5O_release_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
H5O_mesg_t *mesg, hbool_t delete_mesg, hbool_t adj_link);
/* Shared object operators */
-H5_DLL void * H5O_shared_read(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared,
- const H5O_msg_class_t *type, void *mesg);
-H5_DLL void * H5O_shared_decode_new(H5F_t *f, hid_t dxpl_id, const uint8_t *buf, const H5O_msg_class_t *type);
-H5_DLL herr_t H5O_shared_encode_new(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_mesg);
-H5_DLL size_t H5O_shared_size_new(const H5F_t *f, const H5O_shared_t *sh_mesg);
-H5_DLL herr_t H5O_shared_delete_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
+H5_DLL void * H5O_shared_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *buf, const H5O_msg_class_t *type);
+H5_DLL herr_t H5O_shared_encode(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_mesg);
+H5_DLL size_t H5O_shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg);
+H5_DLL herr_t H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
const H5O_msg_class_t *mesg_type, hbool_t adj_link);
-H5_DLL herr_t H5O_shared_link_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
+H5_DLL herr_t H5O_shared_link(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
const H5O_msg_class_t *mesg_type);
-H5_DLL herr_t H5O_shared_copy_file_new(H5F_t *file_src, H5F_t *file_dst, hid_t dxpl_id,
+H5_DLL herr_t H5O_shared_copy_file(H5F_t *file_src, H5F_t *file_dst, hid_t dxpl_id,
const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst,
H5O_copy_t *cpy_info, void *udata);
-
+H5_DLL herr_t H5O_shared_debug(const H5O_shared_t *mesg, FILE *stream,
+ int indent, int fwidth);
/* Attribute operations */
H5_DLL herr_t H5O_attr_create(const H5O_loc_t *loc, hid_t dxpl_id, H5A_t *attr);
diff --git a/src/H5Opline.c b/src/H5Opline.c
index d87c781..c2201c1 100644
--- a/src/H5Opline.c
+++ b/src/H5Opline.c
@@ -35,10 +35,7 @@ static void *H5O_pline_copy(const void *_mesg, void *_dest);
static size_t H5O_pline_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_pline_reset(void *_mesg);
static herr_t H5O_pline_free(void *_mesg);
-static void *H5O_pline_get_share(const void *_mesg, H5O_shared_t *sh);
-static herr_t H5O_pline_set_share(void *_mesg, const H5O_shared_t *sh);
-static htri_t H5O_pline_is_shared(const void *_mesg);
-static herr_t H5O_pline_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
+static herr_t H5O_pline_pre_copy_file(H5F_t *file_src,
const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
static herr_t H5O_pline_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
@@ -57,6 +54,8 @@ static herr_t H5O_pline_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
#undef H5O_SHARED_LINK_REAL
#define H5O_SHARED_COPY_FILE H5O_pline_shared_copy_file
#undef H5O_SHARED_COPY_FILE_REAL
+#define H5O_SHARED_DEBUG H5O_pline_shared_debug
+#define H5O_SHARED_DEBUG_REAL H5O_pline_debug
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
/* This message derives from H5O message class */
@@ -64,6 +63,7 @@ const H5O_msg_class_t H5O_MSG_PLINE[1] = {{
H5O_PLINE_ID, /* message id number */
"filter pipeline", /* message name for debugging */
sizeof(H5O_pline_t), /* native message size */
+ TRUE, /* messages are sharable? */
H5O_pline_shared_decode, /* decode message */
H5O_pline_shared_encode, /* encode message */
H5O_pline_copy, /* copy the native value */
@@ -72,16 +72,14 @@ const H5O_msg_class_t H5O_MSG_PLINE[1] = {{
H5O_pline_free, /* free method */
H5O_pline_shared_delete, /* file delete method */
H5O_pline_shared_link, /* link method */
- H5O_pline_get_share, /* get share method */
- H5O_pline_set_share, /* set share method */
+ H5O_shared_copy, /* set share method */
NULL, /*can share method */
- H5O_pline_is_shared, /* is shared method */
H5O_pline_pre_copy_file, /* pre copy native value to file */
H5O_pline_shared_copy_file, /* copy native value to file */
NULL, /* post copy native value to file */
NULL, /* get creation index */
NULL, /* set creation index */
- H5O_pline_debug /* debug the message */
+ H5O_pline_shared_debug /* debug the message */
}};
@@ -588,9 +586,8 @@ H5O_pline_free(void *mesg)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_pline_pre_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *type,
- const void *mesg_src, hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info,
- void *_udata)
+H5O_pline_pre_copy_file(H5F_t UNUSED *file_src, const void *mesg_src,
+ hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info, void *_udata)
{
const H5O_pline_t *pline_src = (const H5O_pline_t *)mesg_src; /* Source datatype */
H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
@@ -615,98 +612,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_pline_get_share
- *
- * Purpose: Gets sharing information from the message
- *
- * Return: Shared message on success/NULL on failure
- *
- * Programmer: James Laird
- * Tuesday, October 10, 2006
- *
- *-------------------------------------------------------------------------
- */
-static void *
-H5O_pline_get_share(const void *_mesg, H5O_shared_t *sh /*out*/)
-{
- const H5O_pline_t *mesg = (const H5O_pline_t *)_mesg;
- void *ret_value = NULL;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_get_share)
-
- HDassert (mesg);
-
- ret_value = H5O_msg_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh);
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_pline_get_share() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_pline_set_share
- *
- * Purpose: Sets sharing information for the message
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: James Laird
- * Tuesday, October 10, 2006
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_pline_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh)
-{
- H5O_pline_t *mesg = (H5O_pline_t *)_mesg;
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_set_share)
-
- HDassert (mesg);
- HDassert (sh);
-
- if(NULL == H5O_msg_copy(H5O_SHARED_ID, sh, &(mesg->sh_loc)))
- ret_value = FAIL;
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_pline_set_share() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_pline_is_shared
- *
- * Purpose: Determines if this fill value is shared (committed or a SOHM)
- * or not.
- *
- * Return: TRUE if fill value is shared
- * FALSE if fill value is not shared
- * Negative on failure
- *
- * Programmer: James Laird
- * Monday, October 16, 2006
- *
- *-------------------------------------------------------------------------
- */
-static htri_t
-H5O_pline_is_shared(const void *_mesg)
-{
- const H5O_pline_t *mesg = (const H5O_pline_t *)_mesg;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_is_shared)
-
- HDassert(mesg);
-
- /* I/O pipelines can't currently be committed, but this should let the
- * library read a "committed I/O pipeline" if we ever create one in
- * the future.
- */
- FUNC_LEAVE_NOAPI(H5O_IS_SHARED(mesg->sh_loc.flags))
-} /* end H5O_pline_is_shared() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5O_pline_debug
*
* Purpose: Prints debugging information for filter pipeline message MESG
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 62285e1..76d5dd0 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -426,7 +426,6 @@ H5_DLL size_t H5O_msg_raw_size(const H5F_t *f, unsigned type_id,
hbool_t disable_shared, const void *mesg);
H5_DLL size_t H5O_msg_mesg_size(const H5F_t *f, unsigned type_id, const void *mesg,
size_t extra_raw);
-H5_DLL void *H5O_msg_get_share(unsigned type_id, const void *mesg, H5O_shared_t *share);
H5_DLL htri_t H5O_msg_is_shared(unsigned type_id, const void *mesg);
H5_DLL htri_t H5O_msg_can_share(unsigned type_id, const void *mesg);
H5_DLL herr_t H5O_msg_set_share(unsigned type_id, H5O_shared_t *share, void *mesg);
@@ -468,5 +467,8 @@ H5_DLL herr_t H5O_fill_convert(H5O_fill_t *fill, H5T_t *type, hbool_t *fill_chan
/* Link operators */
H5_DLL herr_t H5O_link_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
+/* Shared message operators */
+H5_DLL herr_t H5O_shared_copy(void *dst, const H5O_shared_t *src);
+
#endif /* _H5Oprivate_H */
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 1d406d9..c111824 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -31,11 +31,8 @@ static void *H5O_sdspace_copy(const void *_mesg, void *_dest);
static size_t H5O_sdspace_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_sdspace_reset(void *_mesg);
static herr_t H5O_sdspace_free(void *_mesg);
-static void *H5O_sdspace_get_share(const void *_mesg, H5O_shared_t *sh);
-static herr_t H5O_sdspace_set_share(void *_mesg, const H5O_shared_t *sh);
-static htri_t H5O_sdspace_is_shared(const void *_mesg);
-static herr_t H5O_sdspace_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_sdspace_pre_copy_file(H5F_t *file_src, const void *mesg_src,
+ hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
static herr_t H5O_sdspace_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
@@ -53,6 +50,8 @@ static herr_t H5O_sdspace_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
#undef H5O_SHARED_LINK_REAL
#define H5O_SHARED_COPY_FILE H5O_sdspace_shared_copy_file
#undef H5O_SHARED_COPY_FILE_REAL
+#define H5O_SHARED_DEBUG H5O_sdspace_shared_debug
+#define H5O_SHARED_DEBUG_REAL H5O_sdspace_debug
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
/* This message derives from H5O message class */
@@ -60,6 +59,7 @@ const H5O_msg_class_t H5O_MSG_SDSPACE[1] = {{
H5O_SDSPACE_ID, /* message id number */
"dataspace", /* message name for debugging */
sizeof(H5S_extent_t), /* native message size */
+ TRUE, /* messages are sharable? */
H5O_sdspace_shared_decode, /* decode message */
H5O_sdspace_shared_encode, /* encode message */
H5O_sdspace_copy, /* copy the native value */
@@ -68,16 +68,14 @@ const H5O_msg_class_t H5O_MSG_SDSPACE[1] = {{
H5O_sdspace_free, /* free method */
H5O_sdspace_shared_delete, /* file delete method */
H5O_sdspace_shared_link, /* link method */
- H5O_sdspace_get_share, /* get share method */
- H5O_sdspace_set_share, /* set share method */
+ H5O_shared_copy, /* set share method */
NULL, /*can share method */
- H5O_sdspace_is_shared, /* is shared method */
H5O_sdspace_pre_copy_file, /* pre copy native value to file */
H5O_sdspace_shared_copy_file,/* copy native value to file */
NULL, /* post copy native value to file */
NULL, /* get creation index */
NULL, /* set creation index */
- H5O_sdspace_debug /* debug the message */
+ H5O_sdspace_shared_debug /* debug the message */
}};
/* Initial version of the dataspace information */
@@ -437,111 +435,19 @@ H5O_sdspace_reset(void *_mesg)
* Programmer: Quincey Koziol
* Thursday, March 30, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_sdspace_free (void *mesg)
+H5O_sdspace_free(void *mesg)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_free)
- assert (mesg);
+ HDassert(mesg);
- H5FL_FREE(H5S_extent_t,mesg);
+ H5FL_FREE(H5S_extent_t, mesg);
FUNC_LEAVE_NOAPI(SUCCEED)
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_sdspace_get_share
- *
- * Purpose: Gets sharing information from the message
- *
- * Return: Shared message on success/NULL on failure
- *
- * Programmer: James Laird
- * Tuesday, October 10, 2006
- *
- *-------------------------------------------------------------------------
- */
-static void *
-H5O_sdspace_get_share(const void *_mesg, H5O_shared_t *sh /*out*/)
-{
- const H5S_extent_t *mesg = (const H5S_extent_t *)_mesg;
- void *ret_value = NULL;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_get_share)
-
- HDassert (mesg);
-
- ret_value = H5O_msg_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh);
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_sdspace_get_share() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_sdspace_set_share
- *
- * Purpose: Sets sharing information for the message
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: James Laird
- * Tuesday, October 10, 2006
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_sdspace_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh)
-{
- H5S_extent_t *mesg = (H5S_extent_t *)_mesg;
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_set_share)
-
- HDassert (mesg);
- HDassert (sh);
-
- if(NULL == H5O_msg_copy(H5O_SHARED_ID, sh, &(mesg->sh_loc)))
- ret_value = FAIL;
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_sdspace_set_share() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_sdspace_is_shared
- *
- * Purpose: Determines if this dataspace is shared (committed or a SOHM)
- * or not.
- *
- * Return: TRUE if dataspace is shared
- * FALSE if dataspace is not shared
- * Negative on failure
- *
- * Programmer: James Laird
- * Monday, October 16, 2006
- *
- *-------------------------------------------------------------------------
- */
-static htri_t
-H5O_sdspace_is_shared(const void *_mesg)
-{
- const H5S_extent_t *mesg = (const H5S_extent_t *)_mesg;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_is_shared)
-
- HDassert(mesg);
-
- /* Dataspaces can't currently be committed, but this should let the
- * library read a "committed dataspace" if we ever create one in
- * the future.
- */
- FUNC_LEAVE_NOAPI(H5O_IS_SHARED(mesg->sh_loc.flags))
-} /* end H5O_sdspace_is_shared() */
+} /* end H5O_sdspace_free() */
/*-------------------------------------------------------------------------
@@ -560,9 +466,8 @@ H5O_sdspace_is_shared(const void *_mesg)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_sdspace_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *type,
- const void *mesg_src, hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info,
- void *_udata)
+H5O_sdspace_pre_copy_file(H5F_t *file_src, const void *mesg_src,
+ hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info, void *_udata)
{
const H5S_extent_t *src_space_extent = (const H5S_extent_t *)mesg_src; /* Source dataspace extent */
H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
@@ -617,44 +522,44 @@ static herr_t
H5O_sdspace_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg,
FILE * stream, int indent, int fwidth)
{
- const H5S_extent_t *sdim = (const H5S_extent_t *) mesg;
- unsigned u; /* local counting variable */
+ const H5S_extent_t *sdim = (const H5S_extent_t *)mesg;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_debug)
/* check args */
- assert(f);
- assert(sdim);
- assert(stream);
- assert(indent >= 0);
- assert(fwidth >= 0);
+ HDassert(f);
+ HDassert(sdim);
+ HDassert(stream);
+ HDassert(indent >= 0);
+ HDassert(fwidth >= 0);
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
"Rank:",
(unsigned long) (sdim->rank));
- if(sdim->rank>0) {
+ if(sdim->rank > 0) {
+ unsigned u; /* local counting variable */
+
HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:");
- for (u = 0; u < sdim->rank; u++)
+ for(u = 0; u < sdim->rank; u++)
HDfprintf (stream, "%s%Hu", u?", ":"", sdim->size[u]);
HDfprintf (stream, "}\n");
HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Dim Max:");
- if (sdim->max) {
+ if(sdim->max) {
HDfprintf (stream, "{");
- for (u = 0; u < sdim->rank; u++) {
- if (H5S_UNLIMITED==sdim->max[u]) {
+ for(u = 0; u < sdim->rank; u++) {
+ if(H5S_UNLIMITED==sdim->max[u])
HDfprintf (stream, "%sINF", u?", ":"");
- } else {
+ else
HDfprintf (stream, "%s%Hu", u?", ":"", sdim->max[u]);
- }
- }
+ } /* end for */
HDfprintf (stream, "}\n");
- } else {
+ } /* end if */
+ else
HDfprintf (stream, "CONSTANT\n");
- }
} /* end if */
FUNC_LEAVE_NOAPI(SUCCEED)
-}
+} /* end H5O_sdspace_debug() */
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index 8a77744..dafe3d2 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -39,44 +39,6 @@
#include "H5Opkg.h" /* Object headers */
#include "H5SMprivate.h" /* Shared object header messages */
-static void *H5O_shared_decode(H5F_t*, hid_t dxpl_id, unsigned mesg_flags, const uint8_t*);
-static herr_t H5O_shared_encode(H5F_t*, uint8_t*, const void*);
-static void *H5O_shared_copy(const void *_mesg, void *_dest);
-static size_t H5O_shared_size(const H5F_t*, const void *_mesg);
-static herr_t H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg,
- hbool_t adj_link);
-static herr_t H5O_shared_link(H5F_t *f, hid_t dxpl_id, const void *_mesg);
-static herr_t H5O_shared_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 void *H5O_shared_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
- void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata);
-static herr_t H5O_shared_debug(H5F_t*, hid_t dxpl_id, const void*, FILE*, int, int);
-
-/* This message derives from H5O message class */
-const H5O_msg_class_t H5O_MSG_SHARED[1] = {{
- H5O_SHARED_ID, /*message id number */
- "shared", /*message name for debugging */
- sizeof(H5O_shared_t), /*native message size */
- H5O_shared_decode, /*decode method */
- H5O_shared_encode, /*encode method */
- H5O_shared_copy, /*copy the native value */
- H5O_shared_size, /*size method */
- NULL, /*no reset method */
- NULL, /*no free method */
- H5O_shared_delete, /*file delete method */
- H5O_shared_link, /*link method */
- NULL, /*get share method */
- NULL, /*set share method */
- NULL, /*can share method */
- NULL, /*is shared method */
- H5O_shared_pre_copy_file, /* pre copy native value to file */
- H5O_shared_copy_file, /* copy native value to file */
- NULL, /* post copy native value to file */
- NULL, /* get creation index */
- NULL, /* set creation index */
- H5O_shared_debug /*debug method */
-}};
-
/* First version, with full symbol table entry as link for object header sharing */
#define H5O_SHARED_VERSION_1 1
@@ -113,14 +75,13 @@ H5FL_BLK_DEFINE(ser_mesg);
*
*-------------------------------------------------------------------------
*/
-void *
+static void *
H5O_shared_read(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared,
- const H5O_msg_class_t *type, void *mesg)
+ const H5O_msg_class_t *type)
{
H5HF_t *fheap = NULL;
uint8_t mesg_buf[H5O_MESG_BUF_SIZE]; /* Buffer for deserializing messages */
uint8_t *buf = NULL; /* Pointer to raw message in heap */
- void *native_mesg = NULL; /* Used for messages shared in heap */
void *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_shared_read)
@@ -166,39 +127,25 @@ H5O_shared_read(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared,
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "can't read message from fractal heap.")
/* Decode the message */
- if(NULL == (native_mesg = H5O_msg_decode(f, dxpl_id, type->id, buf)))
+ if(NULL == (ret_value = H5O_msg_decode(f, dxpl_id, type->id, buf)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't decode shared message.")
-
- /* Check if there is a user buffer to fill */
- if(mesg) {
- /* Copy this message to the user's buffer */
- if(NULL == (ret_value = (type->copy)(native_mesg, mesg)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space")
- } /* end if */
- else {
- /* Otherwise, take ownership of the decoded native message */
- ret_value = native_mesg;
- native_mesg = NULL;
- } /* end else */
} /* end if */
else {
HDassert(shared->flags & H5O_COMMITTED_FLAG);
/* Get the shared message from an object header */
- if(NULL == (ret_value = H5O_msg_read(&(shared->u.oloc), type->id, 0, mesg, dxpl_id)))
+ if(NULL == (ret_value = H5O_msg_read(&(shared->u.oloc), type->id, 0, NULL, dxpl_id)))
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read message")
} /* end else */
/* Mark the message as shared */
- if(type->set_share && (type->set_share)(ret_value, shared) < 0)
+ if((type->set_share)(ret_value, shared) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to set sharing information")
done:
/* Release resources */
if(buf && buf != mesg_buf)
buf = H5FL_BLK_FREE(ser_mesg, buf);
- if(native_mesg)
- H5O_msg_free(type->id, native_mesg);
if(fheap && H5HF_close(fheap, dxpl_id) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "can't close fractal heap")
@@ -207,7 +154,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_shared_link_adj_new
+ * Function: H5O_shared_link_adj
*
* Purpose: Changes the link count for the object referenced by a shared
* message.
@@ -228,12 +175,12 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_shared_link_adj_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared,
+H5O_shared_link_adj(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared,
const H5O_msg_class_t *type, int adjust)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_link_adj_new)
+ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_link_adj)
/* check args */
HDassert(f);
@@ -270,70 +217,11 @@ H5O_shared_link_adj_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared,
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_shared_link_adj_new() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_shared_link_adj
- *
- * Purpose: Changes the link count for the object referenced by a shared
- * message.
- *
- * This function changes the object header link count and is
- * only relevant for committed messages. Messages shared in
- * the heap are re-shared each time they're written, so their
- * reference count is stored in the file-wide shared message
- * index and is changed in a different place in the code.
- *
- * Return: Success: New link count, or 1 for messages in heap
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Sep 26 2003
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-H5O_shared_link_adj(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared, int adjust)
-{
- int ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_link_adj)
-
- /* check args */
- HDassert(f);
- HDassert(shared);
-
- /*
- * The shared message is stored in some other object header.
- * The other object header must be in the same file as the
- * new object header. Adjust the reference count on that
- * object header.
- */
- if(shared->flags & H5O_COMMITTED_FLAG) {
- if(shared->u.oloc.file->shared != f->shared)
- HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "interfile hard links are not allowed")
- if((ret_value = H5O_link(&(shared->u.oloc), adjust, dxpl_id)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count")
- } /* end if */
- else {
- /* Messages in the heap don't have file object ref counts; they
- * return 1 as a dummy value.
- */
- HDassert(shared->flags & H5O_SHARED_IN_HEAP_FLAG);
- ret_value = 1;
- } /* end else */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_shared_link_adj() */
/*-------------------------------------------------------------------------
- * Function: H5O_shared_decode_new
+ * Function: H5O_shared_decode
*
* Purpose: Decodes a shared object message
*
@@ -345,13 +233,13 @@ done:
*-------------------------------------------------------------------------
*/
void *
-H5O_shared_decode_new(H5F_t *f, hid_t dxpl_id, const uint8_t *buf, const H5O_msg_class_t *type)
+H5O_shared_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *buf, const H5O_msg_class_t *type)
{
H5O_shared_t sh_mesg; /* Shared message info */
unsigned version; /* Shared message version */
void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_decode_new)
+ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_decode)
/* Check args */
HDassert(f);
@@ -404,104 +292,16 @@ H5O_shared_decode_new(H5F_t *f, hid_t dxpl_id, const uint8_t *buf, const H5O_msg
} /* end else if */
/* Retrieve actual message, through decoded shared message info */
- if(NULL == (ret_value = H5O_shared_read(f, dxpl_id, &sh_mesg, type, NULL)))
+ if(NULL == (ret_value = H5O_shared_read(f, dxpl_id, &sh_mesg, type)))
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to retrieve native message")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_shared_decode_new() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_shared_decode
- *
- * Purpose: Decodes a shared object message and returns it.
- *
- * Return: Success: Ptr to a new shared object message.
- *
- * Failure: NULL
- *
- * Programmer: Robb Matzke
- * Thursday, April 2, 1998
- *
- *-------------------------------------------------------------------------
- */
-static void *
-H5O_shared_decode(H5F_t *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_flags,
- const uint8_t *buf)
-{
- H5O_shared_t *mesg = NULL;
- unsigned version;
- void *ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_decode)
-
- /* Check args */
- HDassert(f);
- HDassert(buf);
-
- /* Decode */
- if(NULL == (mesg = (H5O_shared_t *)H5MM_calloc(sizeof(H5O_shared_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
-
- /* Version */
- version = *buf++;
- if(version < H5O_SHARED_VERSION_1 || version > H5O_SHARED_VERSION_LATEST)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for shared object message")
-
- /* Get the shared information flags
- * Flags are unused before version 3.
- */
- if(version >= H5O_SHARED_VERSION_2)
- mesg->flags = *buf++;
- else {
- mesg->flags = H5O_COMMITTED_FLAG;
- buf++;
- } /* end else */
-
- /* Skip reserved bytes (for version 1) */
- if(version == H5O_SHARED_VERSION_1)
- buf += 6;
-
- /* Body */
- if(version == H5O_SHARED_VERSION_1)
- H5G_obj_ent_decode(f, &buf, &(mesg->u.oloc));
- else if (version >= H5O_SHARED_VERSION_2) {
- /* If this message is in the heap, copy a heap ID.
- * Otherwise, it is a named datatype, so copy an H5O_loc_t.
- */
- if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG) {
- HDassert(version >= H5O_SHARED_VERSION_3 );
- HDmemcpy(&(mesg->u.heap_id), buf, sizeof(mesg->u.heap_id));
- }
- else {
- /* The H5O_COMMITTED_FLAG should be set if this message
- * is from an older version before the flag existed.
- */
- if(version < H5O_SHARED_VERSION_3)
- mesg->flags = H5O_COMMITTED_FLAG;
-
- HDassert(mesg->flags & H5O_COMMITTED_FLAG);
-
- H5F_addr_decode(f, &buf, &(mesg->u.oloc.addr));
- mesg->u.oloc.file = f;
- } /* end else */
- } /* end else if */
-
- /* Set return value */
- ret_value = mesg;
-
-done:
- if(ret_value == NULL)
- if(mesg != NULL)
- H5MM_xfree(mesg);
-
- FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_shared_decode() */
/*-------------------------------------------------------------------------
- * Function: H5O_shared_encode_new
+ * Function: H5O_shared_encode
*
* Purpose: Encodes message _MESG into buffer BUF.
*
@@ -513,11 +313,11 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_shared_encode_new(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_mesg)
+H5O_shared_encode(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_mesg)
{
unsigned version;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_encode_new)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_encode)
/* Check args */
HDassert(f);
@@ -546,60 +346,6 @@ H5O_shared_encode_new(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *s
H5F_addr_encode(f, &buf, sh_mesg->u.oloc.addr);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5O_shared_encode_new() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_shared_encode
- *
- * Purpose: Encodes message _MESG into buffer BUF.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * Thursday, April 2, 1998
- *
- * Modifications:
- * Robb Matzke, 1998-07-20
- * Added a version number to the beginning of the message.
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_shared_encode(H5F_t *f, uint8_t *buf/*out*/, const void *_mesg)
-{
- const H5O_shared_t *mesg = (const H5O_shared_t *)_mesg;
- unsigned version;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_encode)
-
- /* Check args */
- HDassert(f);
- HDassert(buf);
- HDassert(mesg);
-
- /* If this message is shared in the heap, we need to use version 3 of the
- * encoding and encode the SHARED_IN_HEAP flag.
- */
- if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG || H5F_USE_LATEST_FORMAT(f))
- version = H5O_SHARED_VERSION_LATEST;
- else {
- HDassert(mesg->flags & H5O_COMMITTED_FLAG);
- version = H5O_SHARED_VERSION_2; /* version 1 is no longer used */
- } /* end else */
-
- *buf++ = version;
- *buf++ = (unsigned)mesg->flags;
-
- /* Encode either the heap ID of the message or the address of the
- * object header that holds it.
- */
- if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG)
- HDmemcpy(buf, &(mesg->u.heap_id), sizeof(mesg->u.heap_id));
- else
- H5F_addr_encode(f, &buf, mesg->u.oloc.addr);
-
- FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_shared_encode() */
@@ -619,40 +365,33 @@ H5O_shared_encode(H5F_t *f, uint8_t *buf/*out*/, const void *_mesg)
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_shared_copy(const void *_mesg, void *_dest)
+herr_t
+H5O_shared_copy(void *_dst, const H5O_shared_t *src)
{
- const H5O_shared_t *mesg = (const H5O_shared_t *) _mesg;
- H5O_shared_t *dest = (H5O_shared_t *) _dest;
- void *ret_value; /* Return value */
+ H5O_shared_t *dst = (H5O_shared_t *)_dst;
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_copy)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_copy)
/* check args */
- HDassert(mesg);
- if(!dest && NULL == (dest = (H5O_shared_t *)H5MM_malloc(sizeof(H5O_shared_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HDassert(dst);
+ HDassert(src);
/* copy */
- dest->flags = mesg->flags;
- if(mesg->flags & H5O_COMMITTED_FLAG)
- H5O_loc_copy(&(dest->u.oloc), &(mesg->u.oloc), H5_COPY_DEEP);
- else if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG)
- dest->u.heap_id = mesg->u.heap_id;
+ dst->flags = src->flags;
+ if(src->flags & H5O_COMMITTED_FLAG)
+ H5O_loc_copy(&(dst->u.oloc), &(src->u.oloc), H5_COPY_DEEP);
+ else if(src->flags & H5O_SHARED_IN_HEAP_FLAG)
+ dst->u.heap_id = src->u.heap_id;
else
/* This message's sharing information is being reset */
- HDassert(mesg->flags == H5O_NOT_SHARED);
-
- /* Set return value */
- ret_value = dest;
+ HDassert(src->flags == H5O_NOT_SHARED);
-done:
- FUNC_LEAVE_NOAPI(ret_value)
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_shared_copy() */
/*-------------------------------------------------------------------------
- * Function: H5O_shared_size_new
+ * Function: H5O_shared_size
*
* Purpose: Returns the length of a shared object message.
*
@@ -665,11 +404,11 @@ done:
*-------------------------------------------------------------------------
*/
size_t
-H5O_shared_size_new(const H5F_t *f, const H5O_shared_t *sh_mesg)
+H5O_shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg)
{
size_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_size_new)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_size)
if(sh_mesg->flags & H5O_COMMITTED_FLAG) {
ret_value = 1 + /*version */
@@ -684,49 +423,11 @@ H5O_shared_size_new(const H5F_t *f, const H5O_shared_t *sh_mesg)
} /* end else */
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_shared_size_new() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_shared_size
- *
- * Purpose: Returns the length of a shared object message.
- *
- * Return: Success: Length
- *
- * Failure: 0
- *
- * Programmer: Robb Matzke
- * Thursday, April 2, 1998
- *
- *-------------------------------------------------------------------------
- */
-static size_t
-H5O_shared_size(const H5F_t *f, const void *_mesg)
-{
- const H5O_shared_t *shared = (const H5O_shared_t *)_mesg;
- size_t ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_size)
-
- if(shared->flags & H5O_COMMITTED_FLAG) {
- ret_value = 1 + /*version */
- 1 + /*the flags field */
- H5F_SIZEOF_ADDR(f); /*sharing by another obj hdr */
- } /* end if */
- else {
- HDassert(shared->flags & H5O_SHARED_IN_HEAP_FLAG);
- ret_value = 1 + /*version */
- 1 + /*the flags field */
- H5O_FHEAP_ID_LEN; /* Shared in the heap */
- } /* end else */
-
- FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_shared_size() */
/*-------------------------------------------------------------------------
- * Function: H5O_shared_delete_new
+ * Function: H5O_shared_delete
*
* Purpose: Free file space referenced by message
*
@@ -738,61 +439,16 @@ H5O_shared_size(const H5F_t *f, const void *_mesg)
*-------------------------------------------------------------------------
*/
herr_t
-H5O_shared_delete_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
+H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
const H5O_msg_class_t *type, hbool_t adj_link)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_delete_new)
-
- /* check args */
- HDassert(f);
- HDassert(sh_mesg);
-
- /*
- * Committed datatypes increment the OH of the original message when they
- * 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_msg_append
- * or H5O_msg_write). Their refcount in the SOHM indexes still needs to
- * be decremented when they're deleted (in H5O_shared_link_adj).
- */
-
- /* Decrement the reference count on the shared object, if requested */
- if(adj_link)
- if(H5O_shared_link_adj_new(f, dxpl_id, sh_mesg, type, -1) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_shared_delete_new() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_shared_delete
- *
- * Purpose: Free file space referenced by message
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * Friday, September 26, 2003
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
-{
- const H5O_shared_t *shared = (const H5O_shared_t *) _mesg;
- herr_t ret_value = SUCCEED; /* Return value */
-
FUNC_ENTER_NOAPI_NOINIT(H5O_shared_delete)
/* check args */
HDassert(f);
- HDassert(shared);
+ HDassert(sh_mesg);
/*
* Committed datatypes increment the OH of the original message when they
@@ -805,7 +461,7 @@ H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
/* Decrement the reference count on the shared object, if requested */
if(adj_link)
- if(H5O_shared_link_adj(f, dxpl_id, shared, -1) < 0)
+ if(H5O_shared_link_adj(f, dxpl_id, sh_mesg, type, -1) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count")
done:
@@ -814,7 +470,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_shared_link_new
+ * Function: H5O_shared_link
*
* Purpose: Increment reference count on any objects referenced by
* message
@@ -827,53 +483,19 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_shared_link_new(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
+H5O_shared_link(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *sh_mesg,
const H5O_msg_class_t *type)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_link_new)
-
- /* check args */
- HDassert(f);
- HDassert(sh_mesg);
-
- /* Increment the reference count on the shared object */
- if(H5O_shared_link_adj_new(f, dxpl_id, sh_mesg, type, 1) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_shared_link_new() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_shared_link
- *
- * Purpose: Increment reference count on any objects referenced by
- * message
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * Friday, September 26, 2003
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_shared_link(H5F_t *f, hid_t dxpl_id, const void *_mesg)
-{
- const H5O_shared_t *shared = (const H5O_shared_t *) _mesg;
- herr_t ret_value = SUCCEED; /* Return value */
-
FUNC_ENTER_NOAPI_NOINIT(H5O_shared_link)
/* check args */
HDassert(f);
- HDassert(shared);
+ HDassert(sh_mesg);
/* Increment the reference count on the shared object */
- if(H5O_shared_link_adj(f, dxpl_id, shared, 1) < 0)
+ if(H5O_shared_link_adj(f, dxpl_id, sh_mesg, type, 1) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count")
done:
@@ -882,55 +504,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_shared_pre_copy_file
- *
- * Purpose: Perform any necessary actions before copying message between
- * files for shared messages.
- *
- * Return: Success: Non-negative
- *
- * Failure: Negative
- *
- * Programmer: Peter Cao
- * Saturday, February 11, 2006
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_shared_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
- const void *native_src, hbool_t *deleted, const H5O_copy_t *cpy_info,
- void *udata)
-{
- const H5O_shared_t *shared_src = (const H5O_shared_t *)native_src;
- void *mesg_native = NULL;
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_pre_copy_file)
-
- /* check args */
- HDassert(file_src);
- HDassert(type);
-
- if(type->pre_copy_file) {
- /* Go get the actual shared message */
- if(NULL == (mesg_native = H5O_shared_read(file_src, H5AC_dxpl_id, shared_src, type, NULL)))
- HGOTO_ERROR(H5E_OHDR, H5E_READERROR, FAIL, "unable to load object header")
-
- /* Perform "pre copy" operation on messge */
- if((type->pre_copy_file)(file_src, type, mesg_native, deleted, cpy_info, udata) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to perform 'pre copy' operation on message")
- } /* end of if */
-
-done:
- if(mesg_native)
- H5O_msg_free_real(type, mesg_native);
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_shared_pre_copy_file() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_shared_copy_file_new
+ * Function: H5O_shared_copy_file
*
* Purpose: Copies a message from _MESG to _DEST in file
*
@@ -943,7 +517,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_shared_copy_file_new(H5F_t *file_src, H5F_t *file_dst, hid_t dxpl_id,
+H5O_shared_copy_file(H5F_t *file_src, H5F_t *file_dst, hid_t dxpl_id,
const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst,
H5O_copy_t *cpy_info, void UNUSED *udata)
{
@@ -951,7 +525,7 @@ H5O_shared_copy_file_new(H5F_t *file_src, H5F_t *file_dst, hid_t dxpl_id,
H5O_shared_t *shared_dst = (H5O_shared_t *)_native_dst; /* Alias to shared info in native destination message */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_copy_file_new)
+ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_copy_file)
/* check args */
HDassert(file_src);
@@ -983,90 +557,6 @@ H5O_shared_copy_file_new(H5F_t *file_src, H5F_t *file_dst, hid_t dxpl_id,
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5O_shared_copy_file_new() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_shared_copy_file
- *
- * Purpose: Copies a message from _MESG to _DEST in file
- *
- * Return: Success: Ptr to _DEST
- *
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * November 1, 2005
- *
- *-------------------------------------------------------------------------
- */
-static void *
-H5O_shared_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
- void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info,
- void *udata)
-{
- H5O_shared_t *shared_src = (H5O_shared_t *)native_src;
- H5O_shared_t *shared_dst = NULL; /* The destination message if
- * it is a shared message */
- void *dst_mesg = NULL; /* The destination message if
- * it's an unshared message */
- void *ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_copy_file)
-
- /* check args */
- HDassert(shared_src);
- HDassert(file_dst);
- HDassert(cpy_info);
-
- /* Committed shared messages create a shared message at the destination
- * and also copy the committed object that they point to.
- * SOHMs actually write a non-shared message at the destination.
- */
- if(shared_src->flags & H5O_COMMITTED_FLAG) {
- /* Allocate space for the destination message */
- if(NULL == (shared_dst = (H5O_shared_t *)H5MM_malloc(sizeof(H5O_shared_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
-
- /* Reset group entry for new object */
- H5O_loc_reset(&(shared_dst->u.oloc));
- shared_dst->u.oloc.file = file_dst;
-
- /* Set flags for new shared object */
- shared_dst->flags = shared_src->flags;
-
- /* Copy the shared object from source to destination */
- if(H5O_copy_header_map(&(shared_src->u.oloc), &(shared_dst->u.oloc), dxpl_id, cpy_info, FALSE) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy object")
-
- /* Set return value */
- ret_value = shared_dst;
- } /* end if */
- else {
- HDassert(shared_src->flags & H5O_SHARED_IN_HEAP_FLAG);
-
- /* Read the shared message to get the original message */
- if(NULL == (dst_mesg = H5O_shared_read(file_src, dxpl_id, shared_src, mesg_type, NULL)))
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL, "unable to read shared message")
-
- if(mesg_type->copy_file) {
- /* Copy the original, un-shared message and return it */
- ret_value = (mesg_type->copy_file)(file_src, mesg_type, dst_mesg, file_dst, dxpl_id, cpy_info, udata);
- H5O_msg_free(mesg_type->id, dst_mesg);
- } /* end else */
- else
- ret_value = dst_mesg;
- } /* end else */
-
-done:
- if(!ret_value) {
- if(shared_dst)
- H5O_msg_free(H5O_SHARED_ID, shared_dst);
- if(dst_mesg)
- H5O_msg_free(mesg_type->id, dst_mesg);
- } /* end if */
-
- FUNC_LEAVE_NOAPI(ret_value)
} /* H5O_shared_copy_file() */
@@ -1080,43 +570,39 @@ done:
* Programmer: Robb Matzke
* Thursday, April 2, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-static herr_t
-H5O_shared_debug (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg,
- FILE *stream, int indent, int fwidth)
+herr_t
+H5O_shared_debug(const H5O_shared_t *mesg, FILE *stream, int indent, int fwidth)
{
- const H5O_shared_t *mesg = (const H5O_shared_t *)_mesg;
-
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_debug)
/* Check args */
- HDassert(f);
HDassert(mesg);
HDassert(stream);
HDassert(indent >= 0);
HDassert(fwidth >= 0);
- if(mesg->flags & H5O_COMMITTED_FLAG)
- {
+ HDfprintf(stream, "%*s%-*s %x\n", indent, "", fwidth,
+ "Shared Message Flags:",
+ mesg->flags);
+ if(mesg->flags & H5O_COMMITTED_FLAG) {
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Sharing method:",
"Obj Hdr");
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
"Object address:",
mesg->u.oloc.addr);
- }
- else
- {
+ } /* end if */
+ else {
+ HDassert(mesg->flags & H5O_SHARED_IN_HEAP_FLAG);
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Sharing method:",
"SOHM Heap");
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
"Heap ID:",
mesg->u.heap_id);
- }
+ } /* end else */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_shared_debug() */
diff --git a/src/H5Oshared.h b/src/H5Oshared.h
index 70049c7..96fb938 100644
--- a/src/H5Oshared.h
+++ b/src/H5Oshared.h
@@ -66,7 +66,7 @@ H5O_SHARED_DECODE(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p
/* Check for shared message */
if(mesg_flags & H5O_MSG_FLAG_SHARED) {
/* Retrieve native message info indirectly through shared message */
- if(NULL == (ret_value = H5O_shared_decode_new(f, dxpl_id, p, H5O_SHARED_TYPE)))
+ if(NULL == (ret_value = H5O_shared_decode(f, dxpl_id, p, H5O_SHARED_TYPE)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode shared message")
} /* end if */
else {
@@ -98,7 +98,7 @@ done:
*-------------------------------------------------------------------------
*/
static H5_inline herr_t
-H5O_SHARED_ENCODE(H5F_t *f, uint8_t *p, const void *_mesg)
+H5O_SHARED_ENCODE(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg)
{
const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */
herr_t ret_value = SUCCEED; /* Return value */
@@ -116,9 +116,9 @@ H5O_SHARED_ENCODE(H5F_t *f, uint8_t *p, const void *_mesg)
#endif /* H5O_SHARED_ENCODE_REAL */
/* Check for shared message */
- if(H5O_IS_SHARED(sh_mesg->flags)) {
+ if(H5O_IS_SHARED(sh_mesg->flags) && !disable_shared) {
/* Encode shared message into buffer */
- if(H5O_shared_encode_new(f, p, sh_mesg) < 0)
+ if(H5O_shared_encode(f, p, sh_mesg) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode shared message")
} /* end if */
else {
@@ -150,7 +150,7 @@ done:
*-------------------------------------------------------------------------
*/
static H5_inline size_t
-H5O_SHARED_SIZE(const H5F_t *f, const void *_mesg)
+H5O_SHARED_SIZE(const H5F_t *f, hbool_t disable_shared, const void *_mesg)
{
const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */
size_t ret_value; /* Return value */
@@ -168,9 +168,9 @@ H5O_SHARED_SIZE(const H5F_t *f, const void *_mesg)
#endif /* H5O_SHARED_SIZE_REAL */
/* Check for shared message */
- if(H5O_IS_SHARED(sh_mesg->flags)) {
+ if(H5O_IS_SHARED(sh_mesg->flags) && !disable_shared) {
/* Retrieve encoded size of shared message */
- if(0 == (ret_value = H5O_shared_size_new(f, sh_mesg)))
+ if(0 == (ret_value = H5O_shared_size(f, sh_mesg)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, 0, "unable to retrieve encoded size of shared message")
} /* end if */
else {
@@ -220,7 +220,7 @@ H5O_SHARED_DELETE(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
/* Check for shared message */
if(H5O_IS_SHARED(sh_mesg->flags)) {
/* Decrement the reference count on the shared message/object */
- if(H5O_shared_delete_new(f, dxpl_id, sh_mesg, H5O_SHARED_TYPE, adj_link) < 0)
+ if(H5O_shared_delete(f, dxpl_id, sh_mesg, H5O_SHARED_TYPE, adj_link) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for shared message")
} /* end if */
#ifdef H5O_SHARED_DELETE_REAL
@@ -272,7 +272,7 @@ H5O_SHARED_LINK(H5F_t *f, hid_t dxpl_id, const void *_mesg)
/* Check for shared message */
if(H5O_IS_SHARED(sh_mesg->flags)) {
/* Increment the reference count on the shared message/object */
- if(H5O_shared_link_new(f, dxpl_id, sh_mesg, H5O_SHARED_TYPE) < 0)
+ if(H5O_shared_link(f, dxpl_id, sh_mesg, H5O_SHARED_TYPE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "unable to increment ref count for shared message")
} /* end if */
#ifdef H5O_SHARED_LINK_REAL
@@ -306,7 +306,7 @@ done:
*-------------------------------------------------------------------------
*/
static H5_inline void *
-H5O_SHARED_COPY_FILE(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
+H5O_SHARED_COPY_FILE(H5F_t *file_src,
void *_native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info,
void *udata)
{
@@ -336,7 +336,7 @@ H5O_SHARED_COPY_FILE(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
HDmemset(dst_mesg, 0, sizeof(H5O_shared_t));
/* Handle sharing destination message */
- if(H5O_shared_copy_file_new(file_src, file_dst, dxpl_id, H5O_SHARED_TYPE,
+ if(H5O_shared_copy_file(file_src, file_dst, dxpl_id, H5O_SHARED_TYPE,
_native_src, dst_mesg, cpy_info, udata) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, NULL, "unable to determine if message should be shared")
@@ -351,5 +351,58 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_SHARED_COPY_FILE() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_SHARED_DEBUG
+ *
+ * Purpose: Prints debugging info for a potentially shared message.
+ *
+ * Note: The actual name of this routine can be different in each source
+ * file that this header file is included in, and must be defined
+ * prior to including this header file.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, February 3, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static H5_inline herr_t
+H5O_SHARED_DEBUG(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
+ int indent, int fwidth)
+{
+ const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_SHARED_DEBUG)
+
+#ifndef H5O_SHARED_TYPE
+#error "Need to define H5O_SHARED_TYPE macro!"
+#endif /* H5O_SHARED_TYPE */
+#ifndef H5O_SHARED_DEBUG
+#error "Need to define H5O_SHARED_DEBUG macro!"
+#endif /* H5O_SHARED_DEBUG */
+#ifndef H5O_SHARED_DEBUG_REAL
+#error "Need to define H5O_SHARED_DEBUG_REAL macro!"
+#endif /* H5O_SHARED_DEBUG_REAL */
+
+ /* Check for shared message */
+ if(H5O_IS_SHARED(sh_mesg->flags)) {
+ /* Print shared message information */
+ if(H5O_shared_debug(sh_mesg, stream, indent, fwidth) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display shared message info")
+ } /* end if */
+
+ /* Call native message's debug callback */
+ if(H5O_SHARED_DEBUG_REAL(f, dxpl_id, _mesg, stream, indent, fwidth) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display native message info")
+
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_SHARED_DEBUG() */
+
#endif /* H5Oshared_H */
diff --git a/src/H5Ostab.c b/src/H5Ostab.c
index eb04b95..822e7a3 100644
--- a/src/H5Ostab.c
+++ b/src/H5Ostab.c
@@ -36,13 +36,13 @@
/* PRIVATE PROTOTYPES */
static void *H5O_stab_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
-static herr_t H5O_stab_encode(H5F_t *f, uint8_t *p, const void *_mesg);
+static herr_t H5O_stab_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
static void *H5O_stab_copy(const void *_mesg, void *_dest);
-static size_t H5O_stab_size(const H5F_t *f, const void *_mesg);
+static size_t H5O_stab_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
static herr_t H5O_stab_free(void *_mesg);
static herr_t H5O_stab_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
-static void *H5O_stab_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
- void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata);
+static void *H5O_stab_copy_file(H5F_t *file_src, void *native_src,
+ H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata);
static herr_t H5O_stab_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc,
void *mesg_dst, hid_t dxpl_id, H5O_copy_t *cpy_info);
static herr_t H5O_stab_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
@@ -53,6 +53,7 @@ const H5O_msg_class_t H5O_MSG_STAB[1] = {{
H5O_STAB_ID, /*message id number */
"stab", /*message name for debugging */
sizeof(H5O_stab_t), /*native message size */
+ FALSE, /* messages are sharable? */
H5O_stab_decode, /*decode message */
H5O_stab_encode, /*encode message */
H5O_stab_copy, /*copy the native value */
@@ -61,10 +62,8 @@ const H5O_msg_class_t H5O_MSG_STAB[1] = {{
H5O_stab_free, /* free method */
H5O_stab_delete, /* file delete method */
NULL, /* link method */
- NULL, /*get share method */
NULL, /*set share method */
NULL, /*can share method */
- NULL, /*is shared method */
NULL, /* pre copy native value to file */
H5O_stab_copy_file, /* copy native value to file */
H5O_stab_post_copy_file, /* post copy native value to file */
@@ -136,12 +135,10 @@ done:
* matzke@llnl.gov
* Aug 6 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_stab_encode(H5F_t *f, uint8_t *p, const void *_mesg)
+H5O_stab_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
const H5O_stab_t *stab = (const H5O_stab_t *) _mesg;
@@ -174,8 +171,6 @@ H5O_stab_encode(H5F_t *f, uint8_t *p, const void *_mesg)
* matzke@llnl.gov
* Aug 6 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void *
@@ -185,22 +180,22 @@ H5O_stab_copy(const void *_mesg, void *_dest)
H5O_stab_t *dest = (H5O_stab_t *) _dest;
void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_stab_copy);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_stab_copy)
/* check args */
- assert(stab);
- if (!dest && NULL==(dest = H5FL_MALLOC(H5O_stab_t)))
+ HDassert(stab);
+ if(!dest && NULL == (dest = H5FL_MALLOC(H5O_stab_t)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* copy */
*dest = *stab;
/* Set return value */
- ret_value=dest;
+ ret_value = dest;
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_stab_copy() */
/*-------------------------------------------------------------------------
@@ -218,12 +213,10 @@ done:
* matzke@llnl.gov
* Aug 6 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static size_t
-H5O_stab_size(const H5F_t *f, const void UNUSED *_mesg)
+H5O_stab_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void UNUSED *_mesg)
{
size_t ret_value; /* Return value */
@@ -310,9 +303,8 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_stab_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *mesg_type,
- void *native_src, H5F_t *file_dst, hid_t dxpl_id,
- H5O_copy_t UNUSED *cpy_info, void UNUSED *udata)
+H5O_stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst,
+ hid_t dxpl_id, H5O_copy_t UNUSED *cpy_info, void UNUSED *udata)
{
H5O_stab_t *stab_src = (H5O_stab_t *) native_src;
H5O_stab_t *stab_dst = NULL;
diff --git a/src/H5S.c b/src/H5S.c
index 8604750..6cfb635 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -641,7 +641,7 @@ H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src)
} /* end switch */
/* Copy the shared object info */
- if(NULL == H5O_msg_copy(H5O_SHARED_ID, &(src->sh_loc), &(dst->sh_loc)))
+ if(H5O_shared_copy(&(dst->sh_loc), &(src->sh_loc)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy shared information")
done:
@@ -2326,11 +2326,10 @@ herr_t
H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth)
{
const H5S_t *mesg = (const H5S_t*)_mesg;
- herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5S_debug, FAIL);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_debug)
- switch (H5S_GET_EXTENT_TYPE(mesg)) {
+ switch(H5S_GET_EXTENT_TYPE(mesg)) {
case H5S_NULL:
fprintf(stream, "%*s%-*s H5S_NULL\n", indent, "", fwidth,
"Space class:");
@@ -2345,16 +2344,15 @@ H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent,
fprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth,
"Space class:");
H5O_debug_id(H5O_SDSPACE_ID, f, dxpl_id, &(mesg->extent), stream,
- indent+3, MAX(0, fwidth-3));
+ indent + 3, MAX(0, fwidth - 3));
break;
default:
fprintf(stream, "%*s%-*s **UNKNOWN-%ld**\n", indent, "", fwidth,
"Space class:", (long)(H5S_GET_EXTENT_TYPE(mesg)));
break;
- }
+ } /* end switch */
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5S_debug() */
diff --git a/src/H5T.c b/src/H5T.c
index b3395de..f0cea46 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -3057,28 +3057,28 @@ done:
H5T_t *
H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
{
- H5T_t *new_dt=NULL, *tmp=NULL;
+ H5T_t *new_dt = NULL, *tmp = NULL;
H5T_shared_t *reopened_fo;
unsigned i;
char *s;
H5T_t *ret_value;
- FUNC_ENTER_NOAPI(H5T_copy, NULL);
+ FUNC_ENTER_NOAPI(H5T_copy, NULL)
/* check args */
- assert(old_dt);
+ HDassert(old_dt);
/* Allocate space */
- if (NULL==(new_dt = H5FL_MALLOC(H5T_t)))
+ if(NULL == (new_dt = H5FL_MALLOC(H5T_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- if (NULL==(new_dt->shared = H5FL_MALLOC(H5T_shared_t)))
+ if(NULL == (new_dt->shared = H5FL_MALLOC(H5T_shared_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Copy shared information (entry information is copied last) */
*(new_dt->shared) = *(old_dt->shared);
/* Copy parent information */
- if (new_dt->shared->parent)
+ if(new_dt->shared->parent)
new_dt->shared->parent = H5T_copy(new_dt->shared->parent, method);
/* Check what sort of copy we are making */
@@ -3095,11 +3095,10 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
* Return a transient type (locked or unlocked) or an unopened named
* type. Immutable transient types are degraded to read-only.
*/
- if (H5T_STATE_OPEN==old_dt->shared->state) {
+ if(H5T_STATE_OPEN==old_dt->shared->state)
new_dt->shared->state = H5T_STATE_NAMED;
- } else if (H5T_STATE_IMMUTABLE==old_dt->shared->state) {
+ else if(H5T_STATE_IMMUTABLE==old_dt->shared->state)
new_dt->shared->state = H5T_STATE_RDONLY;
- }
break;
case H5T_COPY_REOPEN:
@@ -3109,7 +3108,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
*/
if(old_dt->sh_loc.flags & H5O_COMMITTED_FLAG) {
/* Check if the object is already open */
- if((reopened_fo=H5FO_opened(old_dt->sh_loc.u.oloc.file, old_dt->sh_loc.u.oloc.addr))==NULL) {
+ if((reopened_fo = H5FO_opened(old_dt->sh_loc.u.oloc.file, old_dt->sh_loc.u.oloc.addr)) == NULL) {
/* Clear any errors from H5FO_opened() */
H5E_clear_stack(NULL);
@@ -3125,7 +3124,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
if(H5FO_top_incr(old_dt->sh_loc.u.oloc.file, old_dt->sh_loc.u.oloc.addr) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count")
- new_dt->shared->fo_count=1;
+ new_dt->shared->fo_count = 1;
} else {
/* The object is already open. Free the H5T_shared_t struct
* we had been using and use the one that already exists.
@@ -3145,9 +3144,9 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
/* Increment object count for the object in the top file */
if(H5FO_top_incr(old_dt->sh_loc.u.oloc.file, old_dt->sh_loc.u.oloc.addr) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count")
- }
+ } /* end else */
new_dt->shared->state = H5T_STATE_OPEN;
- } else if (H5T_STATE_IMMUTABLE==old_dt->shared->state) {
+ } else if(H5T_STATE_IMMUTABLE == old_dt->shared->state) {
new_dt->shared->state = H5T_STATE_RDONLY;
}
break;
@@ -3156,7 +3155,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
switch(new_dt->shared->type) {
case H5T_COMPOUND:
{
- int accum_change=0; /* Amount of change in the offset of the fields */
+ int accum_change = 0; /* Amount of change in the offset of the fields */
/*
* Copy all member fields to new type, then overwrite the
@@ -3171,7 +3170,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
HDmemcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb,
new_dt->shared->u.compnd.nmembs * sizeof(H5T_cmemb_t));
- for (i=0; i<new_dt->shared->u.compnd.nmembs; i++) {
+ for(i = 0; i < new_dt->shared->u.compnd.nmembs; i++) {
unsigned j;
int old_match;
@@ -3185,20 +3184,19 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
new_dt->shared->u.compnd.memb[i].offset += accum_change;
if(old_dt->shared->u.compnd.sorted != H5T_SORT_VALUE) {
- for (old_match=-1, j=0; j<old_dt->shared->u.compnd.nmembs; j++) {
- if(!HDstrcmp(new_dt->shared->u.compnd.memb[i].name,old_dt->shared->u.compnd.memb[j].name)) {
- old_match=j;
+ for(old_match = -1, j = 0; j < old_dt->shared->u.compnd.nmembs; j++) {
+ if(!HDstrcmp(new_dt->shared->u.compnd.memb[i].name, old_dt->shared->u.compnd.memb[j].name)) {
+ old_match = j;
break;
} /* end if */
} /* end for */
/* check if we couldn't find a match */
- if(old_match<0)
+ if(old_match < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "fields in datatype corrupted");
} /* end if */
- else {
- old_match=i;
- } /* end else */
+ else
+ old_match = i;
/* If the field changed size, add that change to the accumulated size change */
if(new_dt->shared->u.compnd.memb[i].type->shared->size != old_dt->shared->u.compnd.memb[old_match].type->shared->size) {
@@ -3225,23 +3223,23 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
sizeof(char*));
new_dt->shared->u.enumer.value = H5MM_malloc(new_dt->shared->u.enumer.nalloc *
new_dt->shared->size);
- if (NULL==new_dt->shared->u.enumer.value)
+ if(NULL == new_dt->shared->u.enumer.value)
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++) {
+ for(i = 0; i < new_dt->shared->u.enumer.nmembs; i++) {
s = old_dt->shared->u.enumer.name[i];
new_dt->shared->u.enumer.name[i] = H5MM_xstrdup(s);
- }
+ } /* end for */
break;
case H5T_VLEN:
case H5T_REFERENCE:
- if(method==H5T_COPY_TRANSIENT || method==H5T_COPY_REOPEN) {
+ 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)
+ if(H5T_set_loc(new_dt, NULL, H5T_LOC_MEMORY) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location");
- }
+ } /* end if */
break;
case H5T_OPAQUE:
@@ -3269,33 +3267,33 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
if(new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) {
if(H5G_name_copy(&(new_dt->path), &(old_dt->path), H5_COPY_DEEP) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to copy path")
- }
+ } /* end if */
/* Copy shared location information if the new type is named or if it is
* shared in the heap.
*/
if(old_dt->sh_loc.flags & H5O_SHARED_IN_HEAP_FLAG ||
- new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN)
+ new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN)
{
- if(NULL == H5O_msg_copy(H5O_SHARED_ID, &(old_dt->sh_loc), &(new_dt->sh_loc)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to copy shared location")
- }
+ if(H5O_shared_copy(&(new_dt->sh_loc), &(old_dt->sh_loc)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy shared information")
+ } /* end if */
else
new_dt->sh_loc.flags = H5O_NOT_SHARED;
/* Set return value */
- ret_value=new_dt;
+ ret_value = new_dt;
done:
- if(ret_value==NULL) {
+ if(ret_value == NULL) {
if(new_dt->shared != NULL)
H5FL_FREE(H5T_shared_t, new_dt->shared);
- if(new_dt!=NULL)
- H5FL_FREE (H5T_t,new_dt);
+ if(new_dt != NULL)
+ H5FL_FREE(H5T_t, new_dt);
} /* end if */
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_copy() */
/*-------------------------------------------------------------------------