[svn-r407] ./src/H5A.c

./src/H5D.c
./src/H5Tconv.c
./src/H5detect.c
	Updated to work with new internal H5T functions.  Fixed some
	data type memory leaks during error recovery.

./src/H5Dprivate.h
	Added H5D_typeof() similar to H5D_entof() that returns a
	pointer directly to the dataset's type.  This is used by
	H5Tcopy() when invoked on a dataset (see below).

./src/H5Epublic.h
	Fixed typos in H5E_BEGIN_TRY and H5E_END_TRY macros.

./src/H5F.c
	Closing a file with objects still open reports the file name
	in the warning message.  Removed unnecessary invalidation of
	shared data types.

./src/H5Gent.c
./src/H5Gpkg.h
./src/H5Gprivate.h
	Added `const' to some arguments.

./src/H5O.c
./src/H5Oprivate.h
./src/H5Oshared.c
	An object header message can now be a pointer to a message in
	some other object header.  The pointer is to the first message
	of the appropriate type in the other object header and hard
	link counts are maintained automatically to prevent dangling
	pointers.  The old global heap method of message sharing is
	also supported although nothing actually uses it.

./src/H5Oattr.c
./src/H5Ocomp.c
./src/H5Ocont.c
./src/H5Odtype.c
./src/H5Oefl.c
./src/H5Olayout.c
./src/H5Oname.c
./src/H5Osdspace.c
./src/H5Oshare.c
./src/H5Ostab.c
	Changed the data type for the shared message info struct to
	H5O_shared_t and added an extra initializer to the class
	methods struct for the set_share method.

./src/H5Odtype.c
	Added the ability to share data type messages by pointing to
	other object headers.

./src/H5T.c
./src/H5Tpkg.h
./src/H5Tprivate.h
./src/H5Tpublic.h
	Added named data types and changed the functionality of some
	API functions as follows:

	* The term `read-only' means that a type handle cannot be
	  modified with functions like H5Tset_*() or H5Tinsert().

	* The term `immutable' means the same as `read-only' with the
	  added restriction that H5Tclose() cannot be called for the
	  type. A transient type is made immutable by calling
	  H5Tlock().

	* Handles to named types are always read-only.

	* Handles to predefined types are immutable.

	* A transient type can be converted to a named type by calling
	  H5Tcommit().  This function will fail if the type is already
	  named or is immutable.

	* The API function H5Tcommitted() returns an indication of
	  whether a data type has been commited (or is named).  If
	  H5Tcommitted() returns TRUE for a data type obtained by
	  calling H5Dget_type() on a dataset, then the dataset is
	  using a shared data type.

	* H5Topen() returns a handle to a named type.

	* H5Tcopy() always returns a handle to a modifiable transient
	  type even when invoked on a named type.  Also, when invoked
	  on a dataset it returns a modifiable transient type which is
	  a copy of the dataset's data type.

	* Using a named data type in the call to H5Dcreate() causes
	  the dataset object header to point to the named data type,
	  but using a transient type causes the type to be copied into
	  the dataset's object header.

	* The data type returned from H5Dget_type() is a named data
	  type or a read-only transient data type depending on whether
	  the dataset points to a named data type.   The old behavior,
	  to return a modifiable transient type, is accomplished by
	  overloading H5Tcopy() to operate on datasets (see above).

	* H5Tshare(), H5Tunshare(), and H5Tis_shared() have been
	  removed from the API.

	The following features were *not* implemented because they
	need more discussion:

	* A named data type can be opened by applying H5Topen() to a
	  dataset in which case the data type is the data type of the
	  dataset (or the data type to which the dataset points if the
	  dataset has a shared data type).

	* A named data type can have attributes like groups or
	  datasets.

	* The members of a compound data type can point to named data
	  types.

./src/h5ls.c
	Reports `Data type' for named data type objects in the file.
This commit is contained in:
Robb Matzke 1998-06-04 17:27:11 -05:00
parent 412b58f524
commit b4c5e3e009
27 changed files with 950 additions and 552 deletions

View File

@ -237,7 +237,7 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type, const H5
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
"unable to allocate space for attribute info");
attr->name=HDstrdup(name);
attr->dt=H5T_copy(type);
attr->dt=H5T_copy(type, H5T_COPY_ALL);
attr->ds=H5S_copy(space);
attr->initialized = TRUE; /*for now, set to false later*/
@ -638,8 +638,10 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, void *buf)
HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL,
"unable to convert between src and dest data types");
} else if (H5T_conv_noop!=tconv_func) {
if ((src_id = H5I_register(H5_DATATYPE, H5T_copy(mem_type)))<0 ||
(dst_id = H5I_register(H5_DATATYPE, H5T_copy(attr->dt)))<0) {
if ((src_id = H5I_register(H5_DATATYPE,
H5T_copy(mem_type, H5T_COPY_ALL)))<0 ||
(dst_id = H5I_register(H5_DATATYPE,
H5T_copy(attr->dt, H5T_COPY_ALL)))<0) {
HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL,
"unable to register types for conversion");
}
@ -803,8 +805,10 @@ H5A_read(H5A_t *attr, const H5T_t *mem_type, void *buf)
HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL,
"unable to convert between src and dest data types");
} else if (H5T_conv_noop!=tconv_func) {
if ((src_id = H5I_register(H5_DATATYPE, H5T_copy(attr->dt)))<0 ||
(dst_id = H5I_register(H5_DATATYPE, H5T_copy(mem_type)))<0) {
if ((src_id = H5I_register(H5_DATATYPE,
H5T_copy(attr->dt, H5T_COPY_ALL)))<0 ||
(dst_id = H5I_register(H5_DATATYPE,
H5T_copy(mem_type, H5T_COPY_ALL)))<0) {
HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL,
"unable to register types for conversion");
}
@ -908,6 +912,14 @@ H5Aget_space(hid_t attr_id)
This function retrieves a copy of the datatype for an attribute.
The datatype ID returned from this function must be released with H5Tclose
or resource leaks will develop.
*
* Modifications:
* Robb Matzke, 4 Jun 1998
* The data type is reopened if it's a named type before returning it to
* the application. If the data type of the attribute is read-only then
* it is returned to the application as a read-only type. If an error
* occurs when atomizing the return data type then the data type is
* closed.
--------------------------------------------------------------------------*/
hid_t
H5Aget_type(hid_t attr_id)
@ -924,14 +936,18 @@ H5Aget_type(hid_t attr_id)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
}
/* Copy the attribute's dataspace */
if (NULL==(dst=H5T_copy (attr->dt))) {
/*
* Copy the attribute's data type. If the type is a named type then
* reopen the type before returning it to the user.
*/
if (NULL==(dst=H5T_copy (attr->dt, H5T_COPY_REOPEN))) {
HRETURN_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL,
"unable to copy datatype");
}
/* Atomize */
if ((ret_value=H5I_register (H5_DATATYPE, dst))<0) {
H5T_close (dst);
HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
"unable to register datatype atom");
}
@ -1278,7 +1294,7 @@ H5A_copy(const H5A_t *old_attr)
/* Copy the guts of the attribute */
new_attr->name=HDstrdup(old_attr->name);
new_attr->dt=H5T_copy(old_attr->dt);
new_attr->dt=H5T_copy(old_attr->dt, H5T_COPY_ALL);
new_attr->ds=H5S_copy(old_attr->ds);
if(old_attr->data) {
new_attr->data=H5MM_xmalloc(old_attr->data_size);

121
src/H5D.c
View File

@ -393,6 +393,11 @@ H5Dget_space (hid_t dataset_id)
*
* Modifications:
*
* Robb Matzke, 1 Jun 1998
* If the dataset has a named data type then a handle to the opened data
* type is returned. Otherwise the returned data type is read-only. If
* atomization of the data type fails then the data type is closed.
*
*-------------------------------------------------------------------------
*/
hid_t
@ -411,20 +416,27 @@ H5Dget_type (hid_t dataset_id)
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
}
/* Copy the data type */
if (NULL==(copied_type=H5T_copy (dataset->type))) {
/* Copy the data type and mark it read-only */
if (NULL==(copied_type=H5T_copy (dataset->type, H5T_COPY_REOPEN))) {
HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL,
"unable to copy the data type");
}
if (H5T_lock (copied_type, FALSE)<0) {
H5T_close (copied_type);
HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL,
"unable to lock transient data type");
}
/* Create an atom */
if ((ret_value=H5I_register (H5_DATATYPE, copied_type))<0) {
H5T_close (copied_type);
HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
"unable to register data type");
}
FUNC_LEAVE (ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Dget_create_plist
@ -758,7 +770,7 @@ H5D_create(H5G_t *loc, const char *name, const H5T_t *type, const H5S_t *space,
/* Initialize the dataset object */
new_dset = H5MM_xcalloc(1, sizeof(H5D_t));
H5F_addr_undef(&(new_dset->ent.header));
new_dset->type = H5T_copy(type);
new_dset->type = H5T_copy(type, H5T_COPY_ALL);
new_dset->space = H5S_copy(space);
new_dset->create_parms = H5P_copy (H5P_DATASET_CREATE, create_parms);
efl = &(new_dset->create_parms->efl);
@ -781,35 +793,37 @@ H5D_create(H5G_t *loc, const char *name, const H5T_t *type, const H5S_t *space,
"unable to initialize contiguous storage");
}
/* Don't go through all these checks for scalar dataspaces */
if(ndims>0) {
for (i=1; i<ndims; i++) {
if (max_dim[i]>new_dset->layout.dim[i]) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"only the first dimension can be extendible");
}
}
if (efl->nused>0) {
hsize_t max_points = H5S_get_npoints_max (space);
hsize_t max_storage = H5O_efl_total_size (efl);
/* Don't go through all these checks for scalar dataspaces */
if(ndims>0) {
for (i=1; i<ndims; i++) {
if (max_dim[i]>new_dset->layout.dim[i]) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"only the first dimension can be extendible");
}
}
if (efl->nused>0) {
hsize_t max_points = H5S_get_npoints_max (space);
hsize_t max_storage = H5O_efl_total_size (efl);
if (H5S_UNLIMITED==max_points) {
if (H5O_EFL_UNLIMITED!=max_storage) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"unlimited data space but finite storage");
}
} else if (max_points * H5T_get_size (type) < max_points) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"data space * type size overflowed");
} else if (max_points * H5T_get_size (type) > max_storage) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"data space size exceeds external storage size");
}
} else if (max_dim[0]>new_dset->layout.dim[0]) {
HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL,
"extendible contiguous non-external dataset");
}
}
if (H5S_UNLIMITED==max_points) {
if (H5O_EFL_UNLIMITED!=max_storage) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"unlimited data space but finite "
"storage");
}
} else if (max_points * H5T_get_size (type) < max_points) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"data space * type size overflowed");
} else if (max_points * H5T_get_size (type) > max_storage) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"data space size exceeds external storage "
"size");
}
} else if (max_dim[0]>new_dset->layout.dim[0]) {
HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL,
"extendible contiguous non-external dataset");
}
}
break;
case H5D_CHUNKED:
@ -842,8 +856,7 @@ H5D_create(H5G_t *loc, const char *name, const H5T_t *type, const H5S_t *space,
/* Update the type and space header messages */
if (H5O_modify(&(new_dset->ent), H5O_DTYPE, 0,
(H5O_FLAG_CONSTANT|H5O_FLAG_SHARED),
new_dset->type) < 0 ||
H5O_FLAG_CONSTANT|H5O_FLAG_SHARED, new_dset->type)<0 ||
H5S_modify(&(new_dset->ent), new_dset->space) < 0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
"unable to update type or space header messages");
@ -1215,8 +1228,10 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
"unable to convert between src and dest data types");
} else if (H5T_conv_noop!=tconv_func) {
if ((src_id=H5I_register(H5_DATATYPE, H5T_copy(dataset->type)))<0 ||
(dst_id=H5I_register(H5_DATATYPE, H5T_copy(mem_type)))<0) {
if ((src_id=H5I_register(H5_DATATYPE,
H5T_copy(dataset->type, H5T_COPY_ALL)))<0 ||
(dst_id=H5I_register(H5_DATATYPE,
H5T_copy(mem_type, H5T_COPY_ALL)))<0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
"unable to register types for conversion");
}
@ -1520,8 +1535,10 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
"unable to convert between src and dest data types");
} else if (H5T_conv_noop!=tconv_func) {
if ((src_id = H5I_register(H5_DATATYPE, H5T_copy(mem_type)))<0 ||
(dst_id = H5I_register(H5_DATATYPE, H5T_copy(dataset->type)))<0) {
if ((src_id = H5I_register(H5_DATATYPE,
H5T_copy(mem_type, H5T_COPY_ALL)))<0 ||
(dst_id = H5I_register(H5_DATATYPE,
H5T_copy(dataset->type, H5T_COPY_ALL)))<0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
"unable to register types for conversion");
}
@ -1793,3 +1810,31 @@ H5D_entof (H5D_t *dataset)
{
return dataset ? &(dataset->ent) : NULL;
}
/*-------------------------------------------------------------------------
* Function: H5D_typeof
*
* Purpose: Returns a pointer to the dataset's data type. The data type
* is not copied.
*
* Return: Success: Ptr to the dataset's data type, uncopied.
*
* Failure: NULL
*
* Programmer: Robb Matzke
* Thursday, June 4, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_t *
H5D_typeof (H5D_t *dset)
{
FUNC_ENTER (H5D_typeof, NULL);
assert (dset);
assert (dset->type);
FUNC_LEAVE (dset->type);
}

View File

@ -78,5 +78,6 @@ herr_t H5D_write (H5D_t *dataset, const H5T_t *mem_type,
hid_t H5D_find_name (hid_t file_id, H5I_group_t UNUSED, const char *name);
herr_t H5D_extend (H5D_t *dataset, const hsize_t *size);
H5G_entry_t *H5D_entof (H5D_t *dataset);
H5T_t *H5D_typeof (H5D_t *dset);
#endif

View File

@ -31,20 +31,20 @@
* like:
* H5E_BEGIN_TRY {
* ...stuff here that's likely to fail...
* } H5E_END_TRY
* } H5E_END_TRY;
*
* Warning: don't break, return, or longjmp() from the body of the loop or
* the error reporting won't be properly restored!
*/
#define H5T_BEGIN_TRY do { \
#define H5E_BEGIN_TRY do { \
herr_t (*H5E_saved_efunc)(void*); \
void *H5E_saved_edata; \
H5Eget_auto (&H5E_saved_efunc, &H5E_saved_edata); \
H5Eset_auto (NULL, NULL);
#define H5T_END_TRY \
#define H5E_END_TRY \
H5Eset_auto (H5E_saved_efunc, H5E_saved_edata); \
}
} while(0)
/*

View File

@ -1384,8 +1384,9 @@ H5F_close(H5F_t *f)
*/
if (f->nopen>0) {
#ifndef NDEBUG
fprintf(stderr, "H5F: H5F_close: %u object header%s still "
fprintf(stderr, "H5F: H5F_close(%s): %u object header%s still "
"open (file close will complete when %s closed)\n",
f->name,
f->nopen,
1 == f->nopen ? " is" : "s are",
1 == f->nopen ? "that header is" : "those headers are");
@ -1398,9 +1399,6 @@ H5F_close(H5F_t *f)
#endif
}
/* Invalidate shared data types since they depend on the H5F_t pointer */
H5I_search (H5_DATATYPE, H5T_invalidate_cb, f);
/*
* If this is the last reference to the shared part of the file then
* close it also.

View File

@ -240,7 +240,7 @@ H5G_ent_decode(H5F_t *f, const uint8 **pp, H5G_entry_t *ent)
*-------------------------------------------------------------------------
*/
herr_t
H5G_ent_encode_vec(H5F_t *f, uint8 **pp, H5G_entry_t *ent, intn n)
H5G_ent_encode_vec(H5F_t *f, uint8 **pp, const H5G_entry_t *ent, intn n)
{
intn i;
@ -288,7 +288,7 @@ H5G_ent_encode_vec(H5F_t *f, uint8 **pp, H5G_entry_t *ent, intn n)
*-------------------------------------------------------------------------
*/
herr_t
H5G_ent_encode(H5F_t *f, uint8 **pp, H5G_entry_t *ent)
H5G_ent_encode(H5F_t *f, uint8 **pp, const H5G_entry_t *ent)
{
uint8 *p_ret = *pp + H5G_SIZEOF_ENTRY(f);
@ -358,7 +358,7 @@ H5G_ent_encode(H5F_t *f, uint8 **pp, H5G_entry_t *ent)
*-------------------------------------------------------------------------
*/
herr_t
H5G_ent_debug(H5F_t __unused__ *f, H5G_entry_t *ent, FILE * stream,
H5G_ent_debug(H5F_t __unused__ *f, const H5G_entry_t *ent, FILE * stream,
intn indent, intn fwidth, const haddr_t *heap)
{
const char *lval = NULL;

View File

@ -130,5 +130,6 @@ herr_t H5G_stab_insert (H5G_entry_t *grp_ent, const char *name,
*/
herr_t H5G_ent_decode_vec (H5F_t *f, const uint8 **pp, H5G_entry_t *ent,
intn n);
herr_t H5G_ent_encode_vec (H5F_t *f, uint8 **pp, H5G_entry_t *ent, intn n);
herr_t H5G_ent_encode_vec (H5F_t *f, uint8 **pp, const H5G_entry_t *ent,
intn n);
#endif

View File

@ -122,7 +122,7 @@ herr_t H5G_find (H5G_t *cwg, const char *name, H5G_entry_t *grp_ent/*out*/,
herr_t H5G_traverse_slink (H5G_entry_t *grp_ent/*in,out*/,
H5G_entry_t *obj_ent/*in,out*/,
intn *nlinks/*in,out*/);
herr_t H5G_ent_encode (H5F_t *f, uint8 **pp, H5G_entry_t *ent);
herr_t H5G_ent_encode (H5F_t *f, uint8 **pp, const H5G_entry_t *ent);
herr_t H5G_ent_decode (H5F_t *f, const uint8 **pp, H5G_entry_t *ent/*out*/);
/*
@ -139,7 +139,7 @@ herr_t H5G_node_debug (H5F_t *f, const haddr_t *addr, FILE * stream,
H5G_entry_t *H5G_ent_calloc (H5G_entry_t *init);
H5G_cache_t *H5G_ent_cache (H5G_entry_t *ent, H5G_type_t *cache_type);
herr_t H5G_ent_modified (H5G_entry_t *ent, H5G_type_t cache_type);
herr_t H5G_ent_debug (H5F_t *f, H5G_entry_t *ent, FILE * stream, intn indent,
intn fwidth, const haddr_t *heap);
herr_t H5G_ent_debug (H5F_t *f, const H5G_entry_t *ent, FILE * stream,
intn indent, intn fwidth, const haddr_t *heap);
#endif

View File

@ -916,27 +916,37 @@ H5O_read(H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg)
/*
* If the message is shared then then the native pointer points to an
* H5O_SHARED message. We use that information to look up the real
* message in the global heap.
* message in the global heap or some other object header.
*/
H5O_shared_t *shared;
void *tmp_buf, *tmp_mesg;
shared = (H5O_shared_t *)(oh->mesg[idx].native);
if (NULL==(tmp_buf = H5HG_read (ent->file, shared, NULL))) {
HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
"unable to read shared message from global heap");
}
tmp_mesg = (type->decode)(ent->file, tmp_buf, shared);
tmp_buf = H5MM_xfree (tmp_buf);
if (!tmp_mesg) {
HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
"unable to decode object header shared message");
}
if (mesg) {
HDmemcpy (mesg, tmp_mesg, type->native_size);
H5MM_xfree (tmp_mesg);
if (shared->in_gh) {
if (NULL==(tmp_buf = H5HG_read (ent->file, &(shared->u.gh),
NULL))) {
HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
"unable to read shared message from global heap");
}
tmp_mesg = (type->decode)(ent->file, tmp_buf, shared);
tmp_buf = H5MM_xfree (tmp_buf);
if (!tmp_mesg) {
HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
"unable to decode object header shared message");
}
if (mesg) {
HDmemcpy (mesg, tmp_mesg, type->native_size);
H5MM_xfree (tmp_mesg);
} else {
ret_value = tmp_mesg;
}
} else {
ret_value = tmp_mesg;
ret_value = H5O_read (&(shared->u.ent), type, 0, mesg);
if (type->set_share &&
(type->set_share)(ent->file, ret_value, shared)<0) {
HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL,
"unable to set sharing information");
}
}
} else {
/*
@ -1124,12 +1134,12 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
if (overwrite < 0) {
/* Allocate space for the new message */
if (flags & H5O_FLAG_SHARED) {
if (NULL==type->share) {
if (NULL==type->get_share) {
HGOTO_ERROR (H5E_OHDR, H5E_UNSUPPORTED, FAIL,
"message class is not sharable");
}
sh_mesg = H5MM_xcalloc (1, sizeof *sh_mesg);
if ((type->share)(ent->file, mesg, sh_mesg/*out*/)<0) {
if ((type->get_share)(ent->file, mesg, sh_mesg/*out*/)<0) {
/*
* If the message isn't shared then turn off the shared bit
* and treat it as an unshared message.
@ -1137,8 +1147,22 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
H5E_clear ();
flags &= ~H5O_FLAG_SHARED;
H5MM_xfree (sh_mesg);
} else if (sh_mesg->in_gh) {
/*
* The shared message is stored in the global heap.
* Increment the reference count on the global heap message.
*/
if (H5HG_link (ent->file, &(sh_mesg->u.gh), 1)<0) {
HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL,
"unable to adjust shared object link count");
}
size = (H5O_SHARED->raw_size)(ent->file, sh_mesg);
} else {
if (H5HG_link (ent->file, sh_mesg, 1)<0) {
/*
* The shared message is stored in some other object header.
* Increment the reference count on that object header.
*/
if (H5O_link (&(sh_mesg->u.ent), 1)<0) {
HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL,
"unable to adjust shared object link count");
}
@ -1269,10 +1293,18 @@ H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
"unable to decode shared message info");
}
}
if (H5HG_link (ent->file, sh_mesg, -1)<0) {
HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL,
"unable to decrement link count on shared "
"message");
if (sh_mesg->in_gh) {
if (H5HG_link (ent->file, &(sh_mesg->u.gh), -1)<0) {
HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL,
"unable to decrement link count on "
"shared message");
}
} else {
if (H5O_link (&(sh_mesg->u.ent), -1)<0) {
HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL,
"unable to decrement link count on "
"shared message");
}
}
}
@ -1526,7 +1558,8 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
oh->mesg = H5MM_xrealloc(oh->mesg,
oh->alloc_nmesgs * sizeof(H5O_mesg_t));
/* Set new object header info to zeros */
HDmemset(&oh->mesg[old_alloc],0,(oh->alloc_nmesgs-old_alloc)*sizeof(H5O_mesg_t));
HDmemset(&oh->mesg[old_alloc], 0,
(oh->alloc_nmesgs-old_alloc)*sizeof(H5O_mesg_t));
}
/*
@ -1779,7 +1812,7 @@ H5O_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
int *sequence;
haddr_t tmp_addr;
herr_t ret_value = FAIL;
void *(*decode)(H5F_t*, const uint8*, H5HG_t*);
void *(*decode)(H5F_t*, const uint8*, H5O_shared_t*);
herr_t (*debug)(H5F_t*, const void*, FILE*, intn, intn)=NULL;
FUNC_ENTER(H5O_debug, FAIL);
@ -1912,14 +1945,20 @@ H5O_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
/* If the message is shared then also print the pointed-to message */
if (oh->mesg[i].flags & H5O_FLAG_SHARED) {
void *p = H5HG_read (f, oh->mesg[i].native, NULL);
void *mesg = (oh->mesg[i].type->decode)(f, p, oh->mesg[i].native);
H5O_shared_t *shared = (H5O_shared_t*)(oh->mesg[i].native);
void *mesg = NULL;
if (shared->in_gh) {
void *p = H5HG_read (f, oh->mesg[i].native, NULL);
mesg = (oh->mesg[i].type->decode)(f, p, oh->mesg[i].native);
H5MM_xfree (p);
} else {
mesg = H5O_read (&(shared->u.ent), oh->mesg[i].type, 0, NULL);
}
if (oh->mesg[i].type->debug) {
(oh->mesg[i].type->debug)(f, mesg, stream, indent+3,
MAX (0, fwidth-3));
}
H5O_free (oh->mesg[i].type, mesg);
H5MM_xfree (p);
}
}
sequence = H5MM_xfree(sequence);

View File

@ -29,24 +29,25 @@ static char RcsId[] = "@(#)$Revision$";
/* PRIVATE PROTOTYPES */
static herr_t H5O_attr_encode (H5F_t *f, uint8 *p, const void *mesg);
static void *H5O_attr_decode (H5F_t *f, const uint8 *p, H5HG_t *hobj);
static void *H5O_attr_decode (H5F_t *f, const uint8 *p, H5O_shared_t *sh);
static void *H5O_attr_copy (const void *_mesg, void *_dest);
static size_t H5O_attr_size (H5F_t *f, const void *_mesg);
static herr_t H5O_attr_reset (void *_mesg);
static herr_t H5O_attr_debug (H5F_t *f, const void *_mesg,
FILE * stream, intn indent, intn fwidth);
FILE * stream, intn indent, intn fwidth);
/* This message derives from H5O */
const H5O_class_t H5O_ATTR[1] = {{
H5O_ATTR_ID, /* message id number */
"attribute", /* message name for debugging */
sizeof(H5A_t), /* native message size */
H5O_attr_decode, /* decode message */
H5O_attr_encode, /* encode message */
H5O_attr_decode, /* decode message */
H5O_attr_encode, /* encode message */
H5O_attr_copy, /* copy the native value */
H5O_attr_size, /* size of raw message */
H5O_attr_reset, /* reset method */
NULL, /* no share method (currently) */
NULL, /* get share method */
NULL, /* set share method */
H5O_attr_debug, /* debug the message */
}};
@ -73,7 +74,7 @@ static hbool_t interface_initialize_g = FALSE;
function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
static void *
H5O_attr_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
{
H5A_t *attr = NULL;
H5S_simple_t *simple; /*simple dimensionality information */

View File

@ -16,7 +16,7 @@
/* PRIVATE PROTOTYPES */
static herr_t H5O_comp_encode (H5F_t *f, uint8 *p, const void *mesg);
static void *H5O_comp_decode (H5F_t *f, const uint8 *p, H5HG_t *hobj);
static void *H5O_comp_decode (H5F_t *f, const uint8 *p, H5O_shared_t *sh);
static void *H5O_comp_copy (const void *_mesg, void *_dest);
static size_t H5O_comp_size (H5F_t *f, const void *_mesg);
static herr_t H5O_comp_reset (void *_mesg);
@ -33,7 +33,8 @@ const H5O_class_t H5O_COMPRESS[1] = {{
H5O_comp_copy, /* copy the native value */
H5O_comp_size, /* size of raw message */
H5O_comp_reset, /* reset method */
NULL, /* share method */
NULL, /* get share method */
NULL, /* set share method */
H5O_comp_debug, /* debug the message */
}};
@ -59,7 +60,8 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
static void *
H5O_comp_decode(H5F_t __unused__ *f, const uint8 *p, H5HG_t __unused__ *hobj)
H5O_comp_decode(H5F_t __unused__ *f, const uint8 *p,
H5O_shared_t __unused__ *sh)
{
H5O_compress_t *comp = NULL;

View File

@ -25,23 +25,24 @@
#define PABLO_MASK H5O_cont_mask
/* PRIVATE PROTOTYPES */
static void *H5O_cont_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
static void *H5O_cont_decode(H5F_t *f, const uint8 *p, H5O_shared_t *sh);
static herr_t H5O_cont_encode(H5F_t *f, uint8 *p, const void *_mesg);
static herr_t H5O_cont_debug(H5F_t *f, const void *_mesg, FILE * stream,
intn indent, intn fwidth);
/* This message derives from H5O */
const H5O_class_t H5O_CONT[1] = {{
H5O_CONT_ID, /*message id number */
"hdr continuation", /*message name for debugging */
sizeof(H5O_cont_t), /*native message size */
H5O_cont_decode, /*decode message */
H5O_cont_encode, /*encode message */
NULL, /*no copy method */
NULL, /*no size method */
NULL, /*default reset method */
NULL, /*no share method */
H5O_cont_debug, /*debugging */
H5O_CONT_ID, /*message id number */
"hdr continuation", /*message name for debugging */
sizeof(H5O_cont_t), /*native message size */
H5O_cont_decode, /*decode message */
H5O_cont_encode, /*encode message */
NULL, /*no copy method */
NULL, /*no size method */
NULL, /*default reset method */
NULL, /*get share method */
NULL, /*set share method */
H5O_cont_debug, /*debugging */
}};
/* Interface initialization */
@ -66,7 +67,7 @@ static intn interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
static void *
H5O_cont_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
H5O_cont_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
{
H5O_cont_t *cont = NULL;
@ -75,7 +76,7 @@ H5O_cont_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
/* check args */
assert(f);
assert(p);
assert (!hobj || !H5HG_defined (hobj));
assert (!sh);
/* decode */
cont = H5MM_xcalloc(1, sizeof(H5O_cont_t));

View File

@ -29,13 +29,16 @@ static char RcsId[] = "@(#)$Revision$";
/* PRIVATE PROTOTYPES */
static herr_t H5O_dtype_encode (H5F_t *f, uint8 *p, const void *mesg);
static void *H5O_dtype_decode (H5F_t *f, const uint8 *p, H5HG_t *hobj);
static void *H5O_dtype_decode (H5F_t *f, const uint8 *p, H5O_shared_t *sh);
static void *H5O_dtype_copy (const void *_mesg, void *_dest);
static size_t H5O_dtype_size (H5F_t *f, const void *_mesg);
static herr_t H5O_dtype_reset (void *_mesg);
static herr_t H5O_dtype_get_share (H5F_t *f, const void *_mesg,
H5O_shared_t *sh);
static herr_t H5O_dtype_set_share (H5F_t *f, void *_mesg,
const H5O_shared_t *sh);
static herr_t H5O_dtype_debug (H5F_t *f, const void *_mesg,
FILE * stream, intn indent, intn fwidth);
static herr_t H5O_dtype_share (H5F_t *f, const void *_mesg, H5HG_t *hobj);
/* This message derives from H5O */
const H5O_class_t H5O_DTYPE[1] = {{
@ -47,7 +50,8 @@ const H5O_class_t H5O_DTYPE[1] = {{
H5O_dtype_copy, /* copy the native value */
H5O_dtype_size, /* size of raw message */
H5O_dtype_reset, /* reset method */
H5O_dtype_share, /* share method */
H5O_dtype_get_share, /* get share method */
H5O_dtype_set_share, /* set share method */
H5O_dtype_debug, /* debug the message */
}};
@ -174,6 +178,7 @@ H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt)
dt->u.compnd.memb[i].perm[2] = (perm_word >> 16) & 0xff;
dt->u.compnd.memb[i].perm[3] = (perm_word >> 24) & 0xff;
dt->u.compnd.memb[i].type = H5MM_xcalloc (1, sizeof(H5T_t));
H5F_addr_undef (&(dt->u.compnd.memb[i].type->ent.header));
if (H5O_dtype_decode_helper(pp, dt->u.compnd.memb[i].type) < 0 ||
H5T_COMPOUND == dt->u.compnd.memb[i].type->type) {
for (j = 0; j <= i; j++)
@ -436,7 +441,7 @@ H5O_dtype_encode_helper(uint8 **pp, const H5T_t *dt)
function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
static void *
H5O_dtype_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj)
H5O_dtype_decode(H5F_t *f, const uint8 *p, H5O_shared_t *sh)
{
H5T_t *dt = NULL;
@ -445,19 +450,16 @@ H5O_dtype_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj)
/* check args */
assert(f);
assert(p);
assert (!sh);
dt = H5MM_xcalloc(1, sizeof(H5T_t));
H5F_addr_undef (&(dt->ent.header));
if (H5O_dtype_decode_helper(&p, dt) < 0) {
H5MM_xfree(dt);
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL,
"can't decode type");
}
if (hobj) {
dt->sh_heap = *hobj;
dt->sh_file = f;
}
FUNC_LEAVE(dt);
}
@ -515,7 +517,7 @@ H5O_dtype_encode(H5F_t __unused__ *f, uint8 *p, const void *mesg)
This function copies a native (memory) simple datatype message,
allocating the destination structure if necessary.
--------------------------------------------------------------------------*/
static void *
static void *
H5O_dtype_copy(const void *_src, void *_dst)
{
const H5T_t *src = (const H5T_t *) _src;
@ -527,7 +529,7 @@ H5O_dtype_copy(const void *_src, void *_dst)
assert(src);
/* copy */
if (NULL == (dst = H5T_copy(src))) {
if (NULL == (dst = H5T_copy(src, H5T_COPY_ALL))) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't copy type");
}
/* was result already allocated? */
@ -627,43 +629,78 @@ H5O_dtype_reset(void *_mesg)
/*-------------------------------------------------------------------------
* Function: H5O_dtype_share
* Function: H5O_dtype_get_share
*
* Purpose: Returns, through argument HOBJ, whether a data type is shared
* in the specified file.
* Purpose: Returns information about where the shared message is located
* by filling in the SH shared message struct.
*
* Return: Success: SUCCEED if the data type is shared in file F,
* and HOBJ is set to the global heap address.
* Return: Success: SUCCEED
*
* Failure: FAIL if the data type is not shared, or
* shared but not in file F. The value of HOBJ
* is undefined.
* Failure: FAIL
*
* Programmer: Robb Matzke
* Thursday, April 2, 1998
* Monday, June 1, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O_dtype_share (H5F_t *f, const void *_mesg, H5HG_t *hobj/*out*/)
H5O_dtype_get_share (H5F_t *f, const void *_mesg, H5O_shared_t *sh/*out*/)
{
const H5T_t *dt = (const H5T_t *)_mesg;
const H5T_t *dt = (const H5T_t *)_mesg;
FUNC_ENTER (H5O_dtype_share, FAIL);
if (!H5HG_defined (&(dt->sh_heap)) ||
NULL==dt->sh_file ||
dt->sh_file->shared != f->shared) {
FUNC_ENTER (H5O_dtype_get_share, FAIL);
assert (f);
assert (dt);
assert (sh);
if (H5F_addr_defined (&(dt->ent.header))) {
assert (H5T_STATE_NAMED==dt->state || H5T_STATE_OPEN==dt->state);
sh->in_gh = FALSE;
sh->u.ent = dt->ent;
} else {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"data type is not shared");
"data type is not sharable");
}
*hobj = dt->sh_heap;
FUNC_LEAVE (SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5O_dtype_set_share
*
* Purpose: Copies sharing information from SH into the message.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Thursday, June 4, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O_dtype_set_share (H5F_t *f, void *_mesg/*in,out*/, const H5O_shared_t *sh)
{
H5T_t *dt = (H5T_t *)_mesg;
FUNC_ENTER (H5O_dtype_set_share, FAIL);
assert (f);
assert (dt);
assert (sh);
assert (!sh->in_gh);
dt->ent = sh->u.ent;
dt->state = H5T_STATE_NAMED;
FUNC_LEAVE (SUCCEED);
}
/*--------------------------------------------------------------------------
NAME
H5O_dtype_debug

View File

@ -14,7 +14,7 @@
#define PABLO_MASK H5O_efl_mask
/* PRIVATE PROTOTYPES */
static void *H5O_efl_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
static void *H5O_efl_decode(H5F_t *f, const uint8 *p, H5O_shared_t *sh);
static herr_t H5O_efl_encode(H5F_t *f, uint8 *p, const void *_mesg);
static void *H5O_efl_copy(const void *_mesg, void *_dest);
static size_t H5O_efl_size(H5F_t *f, const void *_mesg);
@ -24,16 +24,17 @@ static herr_t H5O_efl_debug(H5F_t *f, const void *_mesg, FILE * stream,
/* This message derives from H5O */
const H5O_class_t H5O_EFL[1] = {{
H5O_EFL_ID, /*message id number */
"external file list", /*message name for debugging */
sizeof(H5O_efl_t), /*native message size */
H5O_efl_decode, /*decode message */
H5O_efl_encode, /*encode message */
H5O_efl_copy, /*copy native value */
H5O_efl_size, /*size of message on disk */
H5O_efl_reset, /*reset method */
NULL, /*no share method */
H5O_efl_debug, /*debug the message */
H5O_EFL_ID, /*message id number */
"external file list", /*message name for debugging */
sizeof(H5O_efl_t), /*native message size */
H5O_efl_decode, /*decode message */
H5O_efl_encode, /*encode message */
H5O_efl_copy, /*copy native value */
H5O_efl_size, /*size of message on disk */
H5O_efl_reset, /*reset method */
NULL, /*get share method */
NULL, /*set share method */
H5O_efl_debug, /*debug the message */
}};
/* Interface initialization */
@ -59,7 +60,7 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
static void *
H5O_efl_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
H5O_efl_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
{
H5O_efl_t *mesg = NULL;
int i;
@ -70,7 +71,7 @@ H5O_efl_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
/* Check args */
assert(f);
assert(p);
assert (!hobj || !H5HG_defined (hobj));
assert (!sh);
/* Decode the header */
mesg = H5MM_xcalloc(1, sizeof(H5O_efl_t));

View File

@ -14,7 +14,7 @@
#include <H5Oprivate.h>
/* PRIVATE PROTOTYPES */
static void *H5O_layout_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
static void *H5O_layout_decode(H5F_t *f, const uint8 *p, H5O_shared_t *sh);
static herr_t H5O_layout_encode(H5F_t *f, uint8 *p, const void *_mesg);
static void *H5O_layout_copy(const void *_mesg, void *_dest);
static size_t H5O_layout_size(H5F_t *f, const void *_mesg);
@ -23,16 +23,17 @@ static herr_t H5O_layout_debug(H5F_t *f, const void *_mesg, FILE * stream,
/* This message derives from H5O */
const H5O_class_t H5O_LAYOUT[1] = {{
H5O_LAYOUT_ID, /*message id number */
"layout", /*message name for debugging */
sizeof(H5O_layout_t), /*native message size */
H5O_layout_decode, /*decode message */
H5O_layout_encode, /*encode message */
H5O_layout_copy, /*copy the native value */
H5O_layout_size, /*size of message on disk */
NULL, /*reset method */
NULL, /*no share method */
H5O_layout_debug, /*debug the message */
H5O_LAYOUT_ID, /*message id number */
"layout", /*message name for debugging */
sizeof(H5O_layout_t), /*native message size */
H5O_layout_decode, /*decode message */
H5O_layout_encode, /*encode message */
H5O_layout_copy, /*copy the native value */
H5O_layout_size, /*size of message on disk */
NULL, /*reset method */
NULL, /*get share method */
NULL, /*set share method */
H5O_layout_debug, /*debug the message */
}};
/* Interface initialization */
@ -59,7 +60,7 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
static void *
H5O_layout_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
H5O_layout_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
{
H5O_layout_t *mesg = NULL;
intn i;
@ -69,7 +70,7 @@ H5O_layout_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
/* check args */
assert(f);
assert(p);
assert (!hobj || !H5HG_defined (hobj));
assert (!sh);
/* decode */
mesg = H5MM_xcalloc(1, sizeof(H5O_layout_t));

View File

@ -22,7 +22,7 @@
#define PABLO_MASK H5O_name_mask
/* PRIVATE PROTOTYPES */
static void *H5O_name_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
static void *H5O_name_decode(H5F_t *f, const uint8 *p, H5O_shared_t *sh);
static herr_t H5O_name_encode(H5F_t *f, uint8 *p, const void *_mesg);
static void *H5O_name_copy(const void *_mesg, void *_dest);
static size_t H5O_name_size(H5F_t *f, const void *_mesg);
@ -32,16 +32,17 @@ static herr_t H5O_name_debug(H5F_t *f, const void *_mesg, FILE * stream,
/* This message derives from H5O */
const H5O_class_t H5O_NAME[1] = {{
H5O_NAME_ID, /*message id number */
"name", /*message name for debugging */
sizeof(H5O_name_t), /*native message size */
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, /*no share method */
H5O_name_debug, /*debug the message */
H5O_NAME_ID, /*message id number */
"name", /*message name for debugging */
sizeof(H5O_name_t), /*native message size */
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, /*get share method */
NULL, /*set share method */
H5O_name_debug, /*debug the message */
}};
/* Interface initialization */
@ -68,7 +69,8 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
static void *
H5O_name_decode(H5F_t __unused__ *f, const uint8 *p, H5HG_t __unused__ *hobj)
H5O_name_decode(H5F_t __unused__ *f, const uint8 *p,
H5O_shared_t __unused__ *sh)
{
H5O_name_t *mesg;
@ -77,7 +79,7 @@ H5O_name_decode(H5F_t __unused__ *f, const uint8 *p, H5HG_t __unused__ *hobj)
/* check args */
assert(f);
assert(p);
assert (!hobj || !H5HG_defined (hobj));
assert (!sh);
/* decode */
mesg = H5MM_xcalloc(1, sizeof(H5O_name_t));

View File

@ -66,16 +66,18 @@
2 + /*sizeof message data */ \
4) /*reserved */
struct H5O_shared_t;
typedef struct H5O_class_t {
intn id; /*message type ID on disk */
const char *name; /*for debugging */
size_t native_size; /*size of native message */
void *(*decode)(H5F_t*, const uint8*, H5HG_t*);
void *(*decode)(H5F_t*, const uint8*, struct H5O_shared_t*);
herr_t (*encode)(H5F_t*, uint8*, const void*);
void *(*copy)(const void*, void*); /*copy native value */
size_t (*raw_size)(H5F_t*, const void*);/*sizeof raw val */
herr_t (*reset)(void *); /*free nested data structs */
herr_t (*share)(H5F_t*, const void*, H5HG_t*);
herr_t (*get_share)(H5F_t*, const void*, struct H5O_shared_t*);
herr_t (*set_share)(H5F_t*, void*, const struct H5O_shared_t*);
herr_t (*debug)(H5F_t*, const void*, FILE*, intn, intn);
} H5O_class_t;
@ -205,7 +207,13 @@ typedef struct H5O_name_t {
#define H5O_SHARED_ID 0x000f
extern const H5O_class_t H5O_SHARED[1];
typedef H5HG_t H5O_shared_t;
typedef struct H5O_shared_t {
hbool_t in_gh; /*shared by global heap? */
union {
H5HG_t gh; /*global heap info */
H5G_entry_t ent; /*symbol table entry info */
} u;
} H5O_shared_t;
/*
* Object header continuation message.

View File

@ -25,7 +25,7 @@ static char RcsId[] = "@(#)$Revision$";
#define PABLO_MASK H5O_sdspace_mask
/* PRIVATE PROTOTYPES */
static void *H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
static void *H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t *sh);
static herr_t H5O_sdspace_encode(H5F_t *f, uint8 *p, const void *_mesg);
static void *H5O_sdspace_copy(const void *_mesg, void *_dest);
static size_t H5O_sdspace_size(H5F_t *f, const void *_mesg);
@ -35,16 +35,17 @@ static herr_t H5O_sdspace_reset(void *_mesg);
/* This message derives from H5O */
const H5O_class_t H5O_SDSPACE[1] = {{
H5O_SDSPACE_ID, /* message id number */
"simple_dspace", /* message name for debugging */
sizeof(H5S_simple_t), /* native message size */
H5O_sdspace_decode, /* decode message */
H5O_sdspace_encode, /* encode message */
H5O_sdspace_copy, /* copy the native value */
H5O_sdspace_size, /* size of symbol table entry */
H5O_sdspace_reset, /* default reset method */
NULL, /* no share method */
H5O_sdspace_debug, /* debug the message */
H5O_SDSPACE_ID, /* message id number */
"simple_dspace", /* message name for debugging */
sizeof(H5S_simple_t), /* native message size */
H5O_sdspace_decode, /* decode message */
H5O_sdspace_encode, /* encode message */
H5O_sdspace_copy, /* copy the native value */
H5O_sdspace_size, /* size of symbol table entry */
H5O_sdspace_reset, /* default reset method */
NULL, /* get share method */
NULL, /* set share method */
H5O_sdspace_debug, /* debug the message */
}};
/* Is the interface initialized? */
@ -75,7 +76,7 @@ static hbool_t interface_initialize_g = FALSE;
instead of just four bytes.
--------------------------------------------------------------------------*/
static void *
H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
{
H5S_simple_t *sdim = NULL;/* New simple dimensionality structure */
intn u; /* local counting variable */
@ -86,7 +87,7 @@ H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
/* check args */
assert(f);
assert(p);
assert (!hobj || !H5HG_defined (hobj));
assert (!sh);
/* decode */
if ((sdim = H5MM_xcalloc(1, sizeof(H5S_simple_t))) != NULL) {

View File

@ -18,7 +18,7 @@
#include <H5MMprivate.h>
#include <H5Oprivate.h>
static void *H5O_shared_decode (H5F_t*, const uint8*, H5HG_t *hobj);
static void *H5O_shared_decode (H5F_t*, const uint8*, H5O_shared_t *sh);
static herr_t H5O_shared_encode (H5F_t*, uint8*, const void*);
static size_t H5O_shared_size (H5F_t*, const void*);
static herr_t H5O_shared_debug (H5F_t*, const void*, FILE*, intn, intn);
@ -33,7 +33,8 @@ const H5O_class_t H5O_SHARED[1] = {{
NULL, /*no copy method */
H5O_shared_size, /*size method */
NULL, /*no reset method */
NULL, /*no share method */
NULL, /*get share method */
NULL, /*set share method */
H5O_shared_debug, /*debug method */
}};
@ -60,7 +61,7 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
static void *
H5O_shared_decode (H5F_t *f, const uint8 *buf, H5HG_t __unused__ *hobj)
H5O_shared_decode (H5F_t *f, const uint8 *buf, H5O_shared_t __unused__ *sh)
{
H5O_shared_t *mesg;
@ -69,12 +70,17 @@ H5O_shared_decode (H5F_t *f, const uint8 *buf, H5HG_t __unused__ *hobj)
/* Check args */
assert (f);
assert (buf);
assert (!hobj || !H5HG_defined (hobj));
assert (!sh);
/* Decode */
mesg = H5MM_xcalloc (1, sizeof *mesg);
H5F_addr_decode (f, &buf, &(mesg->addr));
INT32DECODE (buf, mesg->idx);
UINT32DECODE (buf, mesg->in_gh);
if (mesg->in_gh) {
H5F_addr_decode (f, &buf, &(mesg->u.gh.addr));
INT32DECODE (buf, mesg->u.gh.idx);
} else {
H5G_ent_decode (f, &buf, &(mesg->u.ent));
}
FUNC_LEAVE (mesg);
}
@ -109,8 +115,13 @@ H5O_shared_encode (H5F_t *f, uint8 *buf/*out*/, const void *_mesg)
assert (mesg);
/* Encode */
H5F_addr_encode (f, &buf, &(mesg->addr));
INT32ENCODE (buf, mesg->idx);
INT32ENCODE (buf, mesg->in_gh);
if (mesg->in_gh) {
H5F_addr_encode (f, &buf, &(mesg->u.gh.addr));
INT32ENCODE (buf, mesg->u.gh.idx);
} else {
H5G_ent_encode (f, &buf, &(mesg->u.ent));
}
FUNC_LEAVE (SUCCEED);
}
@ -135,8 +146,15 @@ H5O_shared_encode (H5F_t *f, uint8 *buf/*out*/, const void *_mesg)
static size_t
H5O_shared_size (H5F_t *f, const void __unused__ *_mesg)
{
size_t size;
FUNC_ENTER (H5O_shared_size, 0);
FUNC_LEAVE (H5F_SIZEOF_ADDR(f)+4);
size = 4 + /*the flags field */
MAX (H5F_SIZEOF_ADDR(f)+4, /*sharing via global heap */
H5G_SIZEOF_ENTRY(f)); /*sharing by another obj hdr */
FUNC_LEAVE (size);
}
@ -171,14 +189,22 @@ H5O_shared_debug (H5F_t __unused__ *f, const void *_mesg,
assert (indent>=0);
assert (fwidth>=0);
fprintf (stream, "%*s%-*s ", indent, "", fwidth,
"Collection address:");
H5F_addr_print (stream, &(mesg->addr));
fprintf (stream, "\n");
fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
"Object ID within collection:",
mesg->idx);
if (mesg->in_gh) {
HDfprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
"Sharing method",
"Global heap");
HDfprintf (stream, "%*s%-*s %a\n", indent, "", fwidth,
"Collection address:",
&(mesg->u.gh.addr));
HDfprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
"Object ID within collection:",
mesg->u.gh.idx);
} else {
HDfprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
"Sharing method",
"Obj Hdr");
H5G_ent_debug (f, &(mesg->u.ent), stream, indent, fwidth, NULL);
}
FUNC_LEAVE (SUCCEED);
}

View File

@ -23,7 +23,7 @@
#define PABLO_MASK H5O_stab_mask
/* PRIVATE PROTOTYPES */
static void *H5O_stab_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
static void *H5O_stab_decode(H5F_t *f, const uint8 *p, H5O_shared_t *sh);
static herr_t H5O_stab_encode(H5F_t *f, uint8 *p, const void *_mesg);
static void *H5O_stab_copy(const void *_mesg, void *_dest);
static size_t H5O_stab_size(H5F_t *f, const void *_mesg);
@ -32,16 +32,17 @@ static herr_t H5O_stab_debug(H5F_t *f, const void *_mesg,
/* This message derives from H5O */
const H5O_class_t H5O_STAB[1] = {{
H5O_STAB_ID, /*message id number */
"stab", /*message name for debugging */
sizeof(H5O_stab_t), /*native message size */
H5O_stab_decode, /*decode message */
H5O_stab_encode, /*encode message */
H5O_stab_copy, /*copy the native value */
H5O_stab_size, /*size of symbol table entry */
NULL, /*default reset method */
NULL, /*no share method */
H5O_stab_debug, /*debug the message */
H5O_STAB_ID, /*message id number */
"stab", /*message name for debugging */
sizeof(H5O_stab_t), /*native message size */
H5O_stab_decode, /*decode message */
H5O_stab_encode, /*encode message */
H5O_stab_copy, /*copy the native value */
H5O_stab_size, /*size of symbol table entry */
NULL, /*default reset method */
NULL, /*get share method */
NULL, /*set share method */
H5O_stab_debug, /*debug the message */
}};
/* Interface initialization */
@ -67,7 +68,7 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
static void *
H5O_stab_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
H5O_stab_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
{
H5O_stab_t *stab;
@ -76,7 +77,7 @@ H5O_stab_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
/* check args */
assert(f);
assert(p);
assert (!hobj || !H5HG_defined (hobj));
assert (!sh);
/* decode */
stab = H5MM_xcalloc(1, sizeof(H5O_stab_t));

823
src/H5T.c

File diff suppressed because it is too large Load Diff

View File

@ -243,12 +243,13 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
}
}
if (priv->src2dst[i]>=0) {
type = H5T_copy (src->u.compnd.memb[i].type);
type = H5T_copy (src->u.compnd.memb[i].type, H5T_COPY_ALL);
tid = H5I_register (H5_DATATYPE, type);
assert (tid>=0);
priv->src_memb_id[priv->src2dst[i]] = tid;
type = H5T_copy (dst->u.compnd.memb[priv->src2dst[i]].type);
type = H5T_copy (dst->u.compnd.memb[priv->src2dst[i]].type,
H5T_COPY_ALL);
tid = H5I_register (H5_DATATYPE, type);
assert (tid>=0);
priv->dst_memb_id[priv->src2dst[i]] = tid;

View File

@ -63,10 +63,18 @@ typedef struct H5T_compnd_t {
struct H5T_member_t *memb; /*array of struct members */
} H5T_compnd_t;
typedef enum H5T_state_t {
H5T_STATE_TRANSIENT, /*type is a modifiable transient */
H5T_STATE_RDONLY, /*transient, not modifiable, closable*/
H5T_STATE_IMMUTABLE, /*constant, not closable */
H5T_STATE_NAMED, /*named constant, not open */
H5T_STATE_OPEN /*named constant, open object header */
} H5T_state_t;
struct H5T_t {
hbool_t locked; /*if locked, then can't be modified */
H5HG_t sh_heap; /*if defined, type is in global heap */
H5F_t *sh_file; /*file pointer if this is a shared type */
H5T_state_t state; /*current state of the type */
H5G_entry_t ent; /*the type is a named type */
H5F_t *sh_file;/*file pointer if this is a shared type */
H5T_class_t type; /*which class of type is this? */
size_t size; /*total size of an instance of this type */
union {

View File

@ -34,16 +34,22 @@ typedef struct H5T_stats_t {
#endif
} H5T_stats_t;
/* How to copy a data type */
typedef enum H5T_copy_t {
H5T_COPY_TRANSIENT,
H5T_COPY_ALL,
H5T_COPY_REOPEN
} H5T_copy_t;
/* Private functions */
herr_t H5T_init (void);
herr_t H5T_init_interface (void);
H5T_t *H5T_open (H5G_t *loc, const char *name);
H5T_t *H5T_create (H5T_class_t type, size_t size);
H5T_t *H5T_copy (const H5T_t *old_dt);
H5T_t *H5T_copy (const H5T_t *old_dt, H5T_copy_t method);
herr_t H5T_commit (H5G_t *loc, const char *name, H5T_t *type);
herr_t H5T_lock (H5T_t *dt, hbool_t immutable);
herr_t H5T_close (H5T_t *dt);
herr_t H5T_share (H5F_t *f, H5T_t *dt);
herr_t H5T_unshare (H5T_t *dt);
intn H5T_invalidate_cb (void *obj, const void *call_data);
size_t H5T_get_size (const H5T_t *dt);
intn H5T_cmp (const H5T_t *dt1, const H5T_t *dt2);
hbool_t H5T_is_atomic (const H5T_t *dt);

View File

@ -178,13 +178,14 @@ extern hid_t H5T_NATIVE_BITFIELD_g;
extern hid_t H5T_NATIVE_OPAQUE_g;
/* Operations defined on all data types */
hid_t H5Topen (hid_t loc_id, const char *name);
hid_t H5Tcreate (H5T_class_t type, size_t size);
hid_t H5Tcopy (hid_t type_id);
herr_t H5Tclose (hid_t type_id);
hbool_t H5Tequal (hid_t type1_id, hid_t type2_id);
herr_t H5Tlock (hid_t type_id);
herr_t H5Tshare (hid_t location_id, hid_t type_id);
hbool_t H5Tis_shared (hid_t location_id, hid_t type_id);
herr_t H5Tcommit (hid_t loc_id, const char *name, hid_t type_id);
hbool_t H5Tcommitted (hid_t type_id);
/* Operations defined on compound data types */
herr_t H5Tinsert (hid_t parent_id, const char *name, size_t offset,

View File

@ -306,7 +306,8 @@ H5T_init (void)\n\
/* The part common to fixed and floating types */
printf("\
dt = H5MM_xcalloc (1, sizeof(H5T_t));\n\
dt->locked = TRUE;\n\
dt->state = H5T_STATE_IMMUTABLE;\n\
H5F_addr_undef (&(dt->ent.header));\n\
dt->type = H5T_%s;\n\
dt->size = %d;\n\
dt->u.atomic.order = H5T_ORDER_%s;\n\

View File

@ -89,6 +89,9 @@ list (hid_t group, const char *name, void __unused__ *op_data)
strcpy (buf+sizeof(buf)-4, "...");
}
printf (" -> %s\n", buf);
} else if ((obj=H5Topen (group, name))>=0) {
printf ("Data type\n");
H5Tclose (obj);
} else {
printf ("Unknown Type\n");
}