[svn-r151] Changes since 19980105

----------------------

./config/freebsd2.2.1
./config/linux
        Added -UH5O_DEBUG to the debug flags.  Turn this on to get
        lots of lines on stderr to show what objects are opened and
        closed.

./src/H5C.o
./src/H5Cpublic.h
./test/dsets.c
./test/tfile.c
        Split H5Cget_prop() and H5Cset_prop() into functions for each
        property.

./src/H5D.c
./src/H5Dpublic.h
./src/H5Gstab.c
./src/H5O.c
./src/H5Ocont.c
./src/H5Ocstore.c
./src/H5Odtype.c
./src/H5Oefl.c
./src/H5Oistore.c
./src/H5Oname.c
./src/H5Onull.c
./src/H5Oprivate.h
./src/H5Osdspace.c
./src/H5Ostab.c
./src/H5P.c
./src/istore.c
./test/tohdr.c
        Object header functions now understand constant
        vs. non-constant messages.

./src/H5F.c
./src/H5Fprivate.h
        The file OID can be closed before other OID's.

./src/H5Flow.c
        H5F_addr_defined() is a macro in this file.

./src/H5G.c
./src/H5Gpublic.h
./test/tstab.c
        A current working group cannot be deleted.

./src/H5Gent.c
./src/H5Gpkg.h
        Removed unused functionality.

./src/H5public.h
        Includes <sys/types.h> for size_t.
This commit is contained in:
Robb Matzke 1998-01-07 12:14:26 -05:00
parent 1d17defdfc
commit 159fa7a232
33 changed files with 1098 additions and 1198 deletions

View File

@ -41,7 +41,7 @@ warn="-Wall -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings -Wstrict-protot
profile="-pg"
debug="-g -DH5AC_DEBUG -DH5B_DEBUG -DH5F_DEBUG -DH5G_DEBUG -DH5F_OPT_SEEK=0 -fverbose-asm"
debug="-g -DH5AC_DEBUG -DH5B_DEBUG -DH5F_DEBUG -DH5G_DEBUG -UH5O_DEBUG -DH5F_OPT_SEEK=0 -fverbose-asm"
production="-O3 -DNDEBUG -finline-functions -funroll-loops -malign-double -fomit-frame-pointer"

View File

@ -41,7 +41,7 @@ warn="-Wall -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings -Wstrict-protot
profile="-pg"
debug="-g -DH5AC_DEBUG -DH5B_DEBUG -DH5F_DEBUG -DH5G_DEBUG -DH5F_OPT_SEEK=0 -fverbose-asm"
debug="-g -DH5AC_DEBUG -DH5B_DEBUG -DH5F_DEBUG -DH5G_DEBUG -UH5O_DEBUG -DH5F_OPT_SEEK=0 -fverbose-asm"
production="-O3 -DNDEBUG -finline-functions -funroll-loops -malign-double -fomit-frame-pointer"

957
src/H5C.c

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,7 @@
/* Public headers needed by this file */
#include <H5public.h>
#include <H5Apublic.h>
#include <H5Dpublic.h>
/* Template classes */
typedef enum H5C_class_t {
@ -35,37 +36,6 @@ typedef enum H5C_class_t {
H5C_NCLASSES =4 /* This must be last! */
} H5C_class_t;
/* Template properties, grouped by class */
typedef enum H5C_prop_t {
/* File Creation Properties */
H5F_SIZEOF_USERBLOCK,/* Size of the user block in the file in bytes */
H5F_SIZEOF_ADDR, /* Number of bytes for addresses */
H5F_SIZEOF_SIZE, /* Number of bytes for sizes */
H5F_SYM_LEAF_K, /* 1/2 rank for symbol table leaf nodes */
H5F_SYM_INTERN_K, /* 1/2 rank for symbol table internal nodes */
H5F_ISTORE_K, /* 1/2 rank for indexed storage nodes */
H5F_BOOTBLOCK_VER, /* Version # of the boot-block format */
H5F_SMALLOBJECT_VER, /* Version # of the small-object heap format */
H5F_FREESPACE_VER, /* Version # of the free-space info format */
H5F_OBJECTDIR_VER, /* Version # of the object-directory format */
H5F_SHAREDHEADER_VER,/* Version # of the shared-header format */
/* File Access Properties */
/* None defined yet */
/* Dataset Creation Properties */
H5D_LAYOUT, /* Storage layout */
H5D_CHUNK_NDIMS, /* Chunk dimensionality */
H5D_CHUNK_SIZE, /* Chunk size vector */
H5D_COMPRESS, /* Raw data compression */
H5D_PRE_OFFSET, /* Precompression offset */
H5D_PRE_SCALE /* Precompression scale */
/* Dataset Transfer Properties */
/* None defined yet */
} H5C_prop_t;
#ifdef __cplusplus
extern "C" {
@ -75,10 +45,33 @@ extern "C" {
hid_t H5Ccreate (H5C_class_t type);
herr_t H5Cclose (hid_t template);
hid_t H5Ccopy (hid_t template);
herr_t H5Cget_prop (hid_t template, H5C_prop_t prop, void *buf);
herr_t H5Cset_prop (hid_t template, H5C_prop_t prop, ...);
H5C_class_t H5Cget_class (hid_t template);
herr_t H5Cget_version (hid_t template, int *boot/*out*/, int *heap/*out*/,
int *freelist/*out*/, int *stab/*out*/,
int *shhdr/*out*/);
herr_t H5Cset_userblock (hid_t template, size_t size);
herr_t H5Cget_userblock (hid_t template, size_t *size);
herr_t H5Cset_sizes (hid_t template, size_t sizeof_addr, size_t sizeof_size);
herr_t H5Cget_sizes (hid_t template, size_t *sizeof_addr/*out*/,
size_t *sizeof_size/*out*/);
herr_t H5Cset_sym_k (hid_t template, int ik, int lk);
herr_t H5Cget_sym_k (hid_t template, int *ik/*out*/, int *lk/*out*/);
herr_t H5Cset_istore_k (hid_t template, int ik);
herr_t H5Cget_istore_k (hid_t template, int *ik/*out*/);
herr_t H5Cset_layout (hid_t template, H5D_layout_t layout);
H5D_layout_t H5Cget_layout (hid_t template);
herr_t H5Cset_chunk (hid_t template, int ndims, size_t dim[]);
int H5Cget_chunk (hid_t template, int max_ndims, size_t dim[]/*out*/);
#ifdef __cplusplus
}
#endif

View File

@ -36,7 +36,6 @@ static char RcsId[] = "@(#)$Revision$";
* A dataset is the following struct.
*/
struct H5D_t {
H5F_t *file; /*file store for this object */
H5G_entry_t ent; /*cached object header stuff */
H5T_t *type; /*datatype of this dataset */
H5P_t *space; /*dataspace of this dataset */
@ -310,7 +309,7 @@ H5Dclose (hid_t dataset_id)
/* Check args */
if (H5_DATASET!=H5Aatom_group (dataset_id) ||
NULL==(dataset=H5Aatom_object (dataset_id)) ||
NULL==dataset->file) {
NULL==dataset->ent.file) {
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
}
@ -378,7 +377,7 @@ H5Dread (hid_t dataset_id, hid_t type_id, hid_t space_id,
/* check arguments */
if (H5_DATASET!=H5Aatom_group (dataset_id) ||
NULL==(dataset=H5Aatom_object (dataset_id)) ||
NULL==dataset->file) {
NULL==dataset->ent.file) {
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
}
if (H5_DATATYPE!=H5Aatom_group (type_id) ||
@ -458,7 +457,7 @@ H5Dwrite (hid_t dataset_id, hid_t type_id, hid_t space_id,
/* check arguments */
if (H5_DATASET!=H5Aatom_group (dataset_id) ||
NULL==(dataset=H5Aatom_object (dataset_id)) ||
NULL==dataset->file) {
NULL==dataset->ent.file) {
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
}
if (H5_DATATYPE!=H5Aatom_group (type_id) ||
@ -575,7 +574,6 @@ H5D_create (H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
/* Initialize the dataset object */
new_dset = H5MM_xcalloc (1, sizeof(H5D_t));
new_dset->file = f;
H5F_addr_undef (&(new_dset->ent.header));
new_dset->type = H5T_copy (type);
new_dset->space = H5P_copy (space);
@ -590,7 +588,7 @@ H5D_create (H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
}
/* Update the type and space header messages */
if (H5O_modify (f, &(new_dset->ent), H5O_DTYPE, 0, new_dset->type)<0 ||
if (H5O_modify (&(new_dset->ent), H5O_DTYPE, 0, 0, new_dset->type)<0 ||
H5P_modify (f, &(new_dset->ent), new_dset->space)<0) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"can't update type or space header messages");
@ -608,7 +606,7 @@ H5D_create (H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
HGOTO_ERROR (H5E_DATASET, H5E_NOSPACE, NULL,
"can't allocate raw file storage");
}
if (H5O_modify (f, &(new_dset->ent), H5O_CSTORE, 0,
if (H5O_modify (&(new_dset->ent), H5O_CSTORE, 0, 0,
&(new_dset->storage.cstore))<0) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"can't update dataset object header");
@ -635,7 +633,7 @@ H5D_create (H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"can't initialize chunked storage");
}
if (H5O_modify (f, &(new_dset->ent), H5O_ISTORE, 0,
if (H5O_modify (&(new_dset->ent), H5O_ISTORE, 0, 0,
&(new_dset->storage.istore))<0) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"can't update dataset object header");
@ -648,7 +646,7 @@ H5D_create (H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
}
/* Give the dataset a name */
if (H5G_insert (f, name, &(new_dset->ent))<0) {
if (H5G_insert (name, &(new_dset->ent))<0) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset");
}
@ -661,9 +659,9 @@ H5D_create (H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
if (new_dset->type) H5T_close (new_dset->type);
if (new_dset->space) H5P_close (new_dset->space);
if (H5F_addr_defined (&(new_dset->ent.header))) {
H5O_close (f, &(new_dset->ent));
H5O_close (&(new_dset->ent));
}
new_dset->file = NULL;
new_dset->ent.file = NULL;
H5MM_xfree (new_dset);
}
@ -705,7 +703,6 @@ H5D_open (H5F_t *f, const char *name)
assert (name && *name);
dataset = H5MM_xcalloc (1, sizeof(H5D_t));
dataset->file = f;
dataset->create_parms = H5D_create_dflt;
H5F_addr_undef (&(dataset->ent.header));
@ -718,9 +715,8 @@ H5D_open (H5F_t *f, const char *name)
}
/* Get the type and space */
if (NULL==(dataset->type = H5O_read (f, &(dataset->ent), H5O_DTYPE,
0, NULL)) ||
NULL==(dataset->space = H5P_read (f, &(dataset->ent)))) {
if (NULL==(dataset->type=H5O_read (&(dataset->ent), H5O_DTYPE, 0, NULL)) ||
NULL==(dataset->space=H5P_read (f, &(dataset->ent)))) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"can't load type of space info from dataset header");
}
@ -731,12 +727,11 @@ H5D_open (H5F_t *f, const char *name)
* values are copied to the dataset create template so the user can query
* them.
*/
if (H5O_read (dataset->file, &(dataset->ent), H5O_CSTORE, 0,
&(dataset->storage.cstore))) {
if (H5O_read (&(dataset->ent), H5O_CSTORE, 0, &(dataset->storage.cstore))) {
/* Contiguous storage */
dataset->create_parms.layout = H5D_CONTIGUOUS;
} else if (H5O_read (dataset->file, &(dataset->ent), H5O_ISTORE, 0,
} else if (H5O_read (&(dataset->ent), H5O_ISTORE, 0,
&(dataset->storage.istore))) {
/*
* Chunked storage. The creation template's dimension is one less than
@ -763,11 +758,11 @@ H5D_open (H5F_t *f, const char *name)
done:
if (!ret_value && dataset) {
if (H5F_addr_defined (&(dataset->ent.header))) {
H5O_close (f, &(dataset->ent));
H5O_close (&(dataset->ent));
}
if (dataset->type) H5T_close (dataset->type);
if (dataset->space) H5P_close (dataset->space);
dataset->file = NULL;
dataset->ent.file = NULL;
H5MM_xfree (dataset);
}
@ -805,10 +800,10 @@ H5D_close (H5D_t *dataset)
FUNC_ENTER (H5D_close, FAIL);
/* check args */
assert (dataset && dataset->file);
assert (dataset && dataset->ent.file);
/* Close the dataset object */
H5O_close (dataset->file, &(dataset->ent));
H5O_close (&(dataset->ent));
/*
* Release dataset type and space - there isn't much we can do if one of
@ -823,7 +818,7 @@ H5D_close (H5D_t *dataset)
* sure we're not accessing an already freed dataset (see the assert()
* above).
*/
dataset->file = NULL;
dataset->ent.file = NULL;
H5MM_xfree (dataset);
if (free_failed) {
@ -869,7 +864,7 @@ H5D_read (H5D_t *dataset, const H5T_t *type, const H5P_t *space,
FUNC_ENTER (H5D_read, FAIL);
/* check args */
assert (dataset && dataset->file);
assert (dataset && dataset->ent.file);
assert (type);
assert (xfer_parms);
assert (buf);
@ -895,7 +890,7 @@ H5D_read (H5D_t *dataset, const H5T_t *type, const H5P_t *space,
/*
* Read a block of contiguous data.
*/
if (H5F_block_read (dataset->file, &(dataset->storage.cstore.addr),
if (H5F_block_read (dataset->ent.file, &(dataset->storage.cstore.addr),
nbytes, buf)<0) {
HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "read failed");
}
@ -908,7 +903,7 @@ H5D_read (H5D_t *dataset, const H5T_t *type, const H5P_t *space,
for (i=0; i<dataset->storage.istore.ndims; i++) offset[i] = 0;
H5P_get_dims (dataset->space, size);
size[dataset->storage.istore.ndims-1] = H5T_get_size (dataset->type);
if (H5F_istore_read (dataset->file, &(dataset->storage.istore),
if (H5F_istore_read (dataset->ent.file, &(dataset->storage.istore),
offset, size, buf)<0) {
HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "read failed");
}
@ -958,7 +953,7 @@ H5D_write (H5D_t *dataset, const H5T_t *type, const H5P_t *space,
FUNC_ENTER (H5D_write, FAIL);
/* check args */
assert (dataset && dataset->file);
assert (dataset && dataset->ent.file);
assert (type);
assert (xfer_parms);
assert (buf);
@ -985,7 +980,7 @@ H5D_write (H5D_t *dataset, const H5T_t *type, const H5P_t *space,
/*
* Write a contiguous chunk of data.
*/
if (H5F_block_write (dataset->file, &(dataset->storage.cstore.addr),
if (H5F_block_write (dataset->ent.file, &(dataset->storage.cstore.addr),
nbytes, buf)<0) {
HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "write failed");
}
@ -998,7 +993,7 @@ H5D_write (H5D_t *dataset, const H5T_t *type, const H5P_t *space,
for (i=0; i<dataset->storage.istore.ndims; i++) offset[i] = 0;
H5P_get_dims (dataset->space, size);
size[dataset->storage.istore.ndims-1] = H5T_get_size (dataset->type);
if (H5F_istore_write (dataset->file, &(dataset->storage.istore),
if (H5F_istore_write (dataset->ent.file, &(dataset->storage.istore),
offset, size, buf)<0) {
HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "write failed");
}

View File

@ -25,6 +25,8 @@
/* Values for the H5D_LAYOUT property */
typedef enum H5D_layout_t {
H5D_LAYOUT_ERROR =-1,
H5D_COMPACT =0, /*raw data is very small */
H5D_CONTIGUOUS =1, /*the default */
H5D_CHUNKED =2, /*slow and fancy */

View File

@ -1246,6 +1246,28 @@ H5F_close (H5F_t *f)
HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush cache");
}
/*
* If object headers are still open then delay deletion of resources until
* they have all been closed. The file is in a consistent state now, so
* forgetting to close everything is not a major problem.
*/
if (f->nopen>0) {
#ifndef NDEBUG
fprintf (stderr, "HDF5-DIAG: H5F_close: %d object header%s still "
"open (file close will complete when %s closed)\n",
f->nopen,
1==f->nopen?" is":"s are",
1==f->nopen?"that header is":"those headers are");
#endif
f->close_pending = TRUE;
HRETURN (SUCCEED);
} else if (f->close_pending) {
#ifndef NDEBUG
fprintf (stderr, "HDF5-DIAG: H5F_close: operation completed\n");
#endif
}
/* Dump debugging info */
if (f->intent & H5F_ACC_DEBUG) H5AC_debug (f);

View File

@ -18,6 +18,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#define addr_defined(X) (-1!=(X)->offset && (X)->offset>=0)
#define PABLO_MASK H5F_low
static hbool_t interface_initialize_g = FALSE;
@ -167,7 +168,7 @@ H5F_low_read (H5F_low_t *lf, const haddr_t *addr, size_t size,
FUNC_ENTER (H5F_low_read, FAIL);
assert (lf && lf->type);
assert (addr && H5F_addr_defined (addr));
assert (addr && addr_defined (addr));
assert (buf);
if (lf->type->read) {
@ -217,7 +218,7 @@ H5F_low_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
FUNC_ENTER (H5F_low_write, FAIL);
assert (lf && lf->type);
assert (addr && H5F_addr_defined (addr));
assert (addr && addr_defined (addr));
assert (buf);
/* Extend the file eof marker if we write past it */
@ -277,7 +278,7 @@ H5F_low_flush (H5F_low_t *lf)
/* Make sure the last block of the file has been allocated on disk */
H5F_addr_reset (&last_byte);
if (H5F_addr_defined (&(lf->eof)) && H5F_addr_gt (&(lf->eof), &last_byte)) {
if (addr_defined (&(lf->eof)) && H5F_addr_gt (&(lf->eof), &last_byte)) {
last_byte = lf->eof;
last_byte.offset -= 1;
if (H5F_low_read (lf, &last_byte, 1, buf)>=0) {
@ -472,7 +473,7 @@ H5F_low_seteof (H5F_low_t *lf, const haddr_t *addr)
FUNC_ENTER (H5F_low_seteof, FAIL);
assert (lf);
assert (addr && H5F_addr_defined (addr));
assert (addr && addr_defined (addr));
lf->eof = *addr;
@ -503,8 +504,8 @@ H5F_addr_cmp (const haddr_t *a1, const haddr_t *a2)
{
FUNC_ENTER (H5F_addr_cmp, FAIL);
assert (a1 && H5F_addr_defined (a1));
assert (a2 && H5F_addr_defined (a2));
assert (a1 && addr_defined (a1));
assert (a2 && addr_defined (a2));
if (a1->offset<a2->offset) HRETURN (-1);
if (a1->offset>a2->offset) HRETURN (1);
@ -556,7 +557,7 @@ hbool_t
H5F_addr_defined (const haddr_t *addr)
{
FUNC_ENTER (H5F_addr_defined, FAIL);
FUNC_LEAVE (-1!=addr->offset && addr->offset>=0);
FUNC_LEAVE (addr_defined (addr));
}
@ -632,7 +633,7 @@ H5F_addr_encode (H5F_t *f, uint8 **pp, const haddr_t *addr)
assert (pp && *pp);
assert (addr);
if (H5F_addr_defined (addr)) {
if (addr_defined (addr)) {
tmp = *addr;
for (i=0; i<H5F_SIZEOF_ADDR (f); i++) {
*(*pp)++ = tmp.offset & 0xff;
@ -719,7 +720,7 @@ H5F_addr_print (FILE *stream, const haddr_t *addr)
assert (stream);
assert (addr);
if (H5F_addr_defined (addr)) {
if (addr_defined (addr)) {
/*
* It would be nice if we could use the `%Lu', `%llu', or `%qu', but
* we don't know which is supported. So we split the address into a
@ -784,7 +785,7 @@ H5F_addr_pow2 (uintn n, haddr_t *addr/*out*/)
void
H5F_addr_inc (haddr_t *addr/*in,out*/, size_t inc)
{
assert (addr && H5F_addr_defined (addr));
assert (addr && addr_defined (addr));
assert (addr->offset<=addr->offset+inc);
addr->offset += inc;
}
@ -807,8 +808,8 @@ H5F_addr_inc (haddr_t *addr/*in,out*/, size_t inc)
void
H5F_addr_add (haddr_t *a1/*in,out*/, const haddr_t *a2)
{
assert (a1 && H5F_addr_defined (a1));
assert (a2 && H5F_addr_defined (a2));
assert (a1 && addr_defined (a1));
assert (a2 && addr_defined (a2));
a1->offset += a2->offset;
}
@ -833,7 +834,7 @@ H5F_addr_add (haddr_t *a1/*in,out*/, const haddr_t *a2)
uintn
H5F_addr_hash (const haddr_t *addr, uintn mod)
{
assert (addr && H5F_addr_defined (addr));
assert (addr && addr_defined (addr));
assert (mod>0);
return addr->offset % mod; /*ignore file number*/

View File

@ -331,7 +331,7 @@ typedef struct H5F_file_t {
#ifdef LATER
file_access_temp_t file_access_parms; /* File-access template */
#endif
struct H5G_entry_t *root_ent; /* Root symbol table entry */
struct H5G_entry_t *root_ent;/* Root symbol table entry */
} H5F_file_t;
/*
@ -344,6 +344,8 @@ typedef struct H5F_t {
char *name; /* Name used to open file */
H5F_file_t *shared; /* The shared file info */
struct H5G_cwgstk_t *cwg_stack; /* CWG stack for push/pop functions */
uintn nopen; /* Number of open object headers */
hbool_t close_pending; /* File close is pending */
} H5F_t;

118
src/H5G.c
View File

@ -204,8 +204,11 @@ H5Gclose (hid_t grp_id)
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a group");
}
/* close it */
if (H5G_close (grp)<0) {
/*
* Decrement the counter on the group atom. It will be freed if the count
* reaches zero.
*/
if (H5A_dec_ref (grp_id)<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to close group");
}
@ -241,7 +244,7 @@ H5Gclose (hid_t grp_id)
*-------------------------------------------------------------------------
*/
herr_t
H5Gset (hid_t file_id, hid_t grp_id)
H5Gset (hid_t file_id, const char *name)
{
H5F_t *f=NULL;
H5G_t *grp;
@ -254,9 +257,11 @@ H5Gset (hid_t file_id, hid_t grp_id)
NULL==(f=H5Aatom_object (file_id))) {
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
}
if (H5_GROUP!=H5Aatom_group (grp_id) ||
NULL==(grp=H5Aatom_object (grp_id))) {
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a group");
if (!name || !*name) {
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
}
if (NULL==(grp=H5G_open (f, name))) {
HRETURN_ERROR (H5E_ARGS, H5E_NOTFOUND, FAIL, "no such group");
}
/* Set the current working group */
@ -265,6 +270,11 @@ H5Gset (hid_t file_id, hid_t grp_id)
"unable to change current working group");
}
/* Close the handle */
if (H5G_close (grp)<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to close group");
}
FUNC_LEAVE (SUCCEED);
}
@ -297,7 +307,7 @@ H5Gset (hid_t file_id, hid_t grp_id)
*-------------------------------------------------------------------------
*/
herr_t
H5Gpush (hid_t file_id, hid_t grp_id)
H5Gpush (hid_t file_id, const char *name)
{
H5F_t *f=NULL;
H5G_t *grp;
@ -310,9 +320,11 @@ H5Gpush (hid_t file_id, hid_t grp_id)
NULL==(f=H5Aatom_object (file_id))) {
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
}
if (H5_GROUP!=H5Aatom_group (grp_id) ||
NULL==(grp=H5Aatom_object (grp_id))) {
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a group");
if (!name || !*name) {
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
}
if (NULL==(grp=H5G_open (f, name))) {
HRETURN_ERROR (H5E_ARGS, H5E_NOTFOUND, FAIL, "no such group");
}
/* Push group onto stack */
@ -321,6 +333,11 @@ H5Gpush (hid_t file_id, hid_t grp_id)
"can't change current working group");
}
/* Close the handle */
if (H5G_close (grp)<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to close group");
}
FUNC_LEAVE (SUCCEED);
}
@ -610,7 +627,7 @@ H5G_namei (H5F_t *f, H5G_entry_t *cwg, const char *name,
HDmemcpy (comp, name, nchars);
comp[nchars] = '\0';
if (H5G_stab_find (f, grp_ent, comp, obj_ent/*out*/)<0) {
if (H5G_stab_find (grp_ent, comp, obj_ent/*out*/)<0) {
/*
* Component was not found in the current symbol table, possibly
* because GRP_ENT isn't a symbol table. If it is the root symbol
@ -622,7 +639,7 @@ H5G_namei (H5F_t *f, H5G_entry_t *cwg, const char *name,
if (!aside &&
H5F_addr_eq (&(grp_ent->header),
&(f->shared->root_ent->header)) &&
H5O_read (f, grp_ent, H5O_NAME, 0, &mesg) &&
H5O_read (grp_ent, H5O_NAME, 0, &mesg) &&
!HDstrcmp (mesg.s, comp)) {
H5O_reset (H5O_NAME, &mesg);
*obj_ent = *grp_ent;
@ -689,9 +706,9 @@ H5G_mkroot (H5F_t *f, size_t size_hint)
* If we already have a root object, then get it's name.
*/
if (f->shared->root_ent) {
if (H5O_read (f, f->shared->root_ent, H5O_STAB, 0, &stab)) {
if (H5O_read (f->shared->root_ent, H5O_STAB, 0, &stab)) {
HGOTO_ERROR (H5E_SYM, H5E_EXISTS, -2, "root group already exists");
} else if (NULL==H5O_read (f, f->shared->root_ent, H5O_NAME, 0, &name)) {
} else if (NULL==H5O_read (f->shared->root_ent, H5O_NAME, 0, &name)) {
obj_name = "Root Object";
} else {
obj_name = name.s; /*don't reset message until the end!*/
@ -704,7 +721,7 @@ H5G_mkroot (H5F_t *f, size_t size_hint)
if (H5G_stab_create (f, size_hint, &new_root/*out*/)<0) {
HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "cant create root");
}
if (1!=H5O_link (f, &new_root, 1)) {
if (1!=H5O_link (&new_root, 1)) {
HGOTO_ERROR (H5E_SYM, H5E_LINK, FAIL,
"internal error (wrong link count)");
}
@ -715,9 +732,9 @@ H5G_mkroot (H5F_t *f, size_t size_hint)
* new symbol table.
*/
if (f->shared->root_ent) {
assert (1==H5O_link (f, f->shared->root_ent, 0));
assert (1==H5O_link (f->shared->root_ent, 0));
if (H5G_stab_insert (f, &new_root, obj_name, f->shared->root_ent)<0) {
if (H5G_stab_insert (&new_root, obj_name, f->shared->root_ent)<0) {
HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
"can't reinsert old root object");
}
@ -727,17 +744,16 @@ H5G_mkroot (H5F_t *f, size_t size_hint)
* a name message should ever appear is to give the root object a name,
* but the old root object is no longer the root object.
*/
H5O_remove (f, f->shared->root_ent, H5O_NAME, H5O_ALL);
H5O_remove (f->shared->root_ent, H5O_NAME, H5O_ALL);
H5ECLEAR; /*who really cares?*/
*(f->shared->root_ent) = new_root;
} else {
f->shared->root_ent = H5MM_xmalloc (sizeof(H5G_entry_t));
*(f->shared->root_ent) = new_root;
f->shared->root_ent = H5G_ent_calloc (&new_root);
}
H5O_close (f, &new_root);
H5O_close (&new_root);
ret_value = SUCCEED;
done:
@ -822,17 +838,16 @@ H5G_create (H5F_t *f, const char *name, size_t size_hint)
}
}
/* create and open group */
/* create an open group */
grp = H5MM_xcalloc (1, sizeof(H5G_t));
grp->file = f;
if (H5G_stab_create (f, size_hint, &(grp->ent)/*out*/)<0) {
grp = H5MM_xfree (grp);
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, NULL, "can't create grp");
}
/* insert child name into parent */
if (H5G_stab_insert (f, &grp_ent, rest, &(grp->ent))<0) {
H5O_close (f, &(grp->ent));
if (H5G_stab_insert (&grp_ent, rest, &(grp->ent))<0) {
H5O_close (&(grp->ent));
grp = H5MM_xfree (grp);
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, NULL, "can't insert");
}
@ -879,7 +894,6 @@ H5G_open (H5F_t *f, const char *name)
if (H5O_open (f, &(grp->ent))<0) {
HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group");
}
grp->file = f;
grp->nref = 1;
ret_value = grp;
@ -948,7 +962,7 @@ H5G_close (H5G_t *grp)
assert (grp->nref>0);
if (1==grp->nref) {
if (H5O_close (grp->file, &(grp->ent))<0) {
if (H5O_close (&(grp->ent))<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to close");
}
}
@ -995,14 +1009,6 @@ H5G_set (H5F_t *f, H5G_t *grp)
assert (f);
assert (grp);
/*
* Are the group and file compatible?
*/
if (grp->file->shared!=f->shared) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
"group is not compatible with file");
}
/*
* If there is no stack then create one, otherwise close the current
* working group.
@ -1092,14 +1098,6 @@ H5G_push (H5F_t *f, H5G_t *grp)
/* check args */
assert (f);
assert (grp);
/*
* Are the group and file compatible?
*/
if (grp->file->shared!=f->shared) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
"group is not compatible with file");
}
/*
* Push a new entry onto the stack.
@ -1162,7 +1160,8 @@ H5G_pop (H5F_t *f)
/*-------------------------------------------------------------------------
* Function: H5G_insert
*
* Purpose: Inserts a symbol table entry into the group graph.
* Purpose: Inserts a symbol table entry into the group graph. The file
* that is used is contained in the ENT argument.
*
* Errors:
*
@ -1178,7 +1177,7 @@ H5G_pop (H5F_t *f)
*-------------------------------------------------------------------------
*/
herr_t
H5G_insert (H5F_t *f, const char *name, H5G_entry_t *ent)
H5G_insert (const char *name, H5G_entry_t *ent)
{
const char *rest = NULL; /*part of name not existing yet */
H5G_entry_t grp; /*entry for group to contain obj*/
@ -1190,14 +1189,13 @@ H5G_insert (H5F_t *f, const char *name, H5G_entry_t *ent)
FUNC_ENTER (H5G_insert, FAIL);
/* Check args. */
assert (f);
assert (name && *name);
assert (ent);
/*
* Look up the name -- it shouldn't exist yet.
*/
if (H5G_namei (f, NULL, name, &rest, &grp, NULL)>=0) {
if (H5G_namei (ent->file, NULL, name, &rest, &grp, NULL)>=0) {
HRETURN_ERROR (H5E_SYM, H5E_EXISTS, FAIL, "already exists");
}
H5ECLEAR; /*it's OK that we didn't find it*/
@ -1209,15 +1207,14 @@ H5G_insert (H5F_t *f, const char *name, H5G_entry_t *ent)
* doesn't have a name or we shouldn't interfere with the name
* it already has as a message.
*/
if (f->shared->root_ent) {
if (ent->file->shared->root_ent) {
HRETURN_ERROR (H5E_SYM, H5E_EXISTS, FAIL, "root exists");
}
if (1!=H5O_link (f, ent, 1)) {
if (1!=H5O_link (ent, 1)) {
HRETURN_ERROR (H5E_SYM, H5E_LINK, FAIL, "bad link count");
}
f->shared->root_ent = H5MM_xmalloc (sizeof(H5G_entry_t));
ent->name_off = 0;
*(f->shared->root_ent) = *ent;
ent->file->shared->root_ent = H5G_ent_calloc (ent);
HRETURN (SUCCEED);
}
@ -1238,7 +1235,7 @@ H5G_insert (H5F_t *f, const char *name, H5G_entry_t *ent)
}
}
if (!f->shared->root_ent) {
if (!ent->file->shared->root_ent) {
/*
* This will be the only object in the file. Insert it as the root
* object and add a name messaage to the object header (or modify
@ -1246,15 +1243,14 @@ H5G_insert (H5F_t *f, const char *name, H5G_entry_t *ent)
*/
H5O_name_t name_mesg;
name_mesg.s = rest;
if (H5O_modify (f, ent, H5O_NAME, 0, &name_mesg)<0) {
if (H5O_modify (ent, H5O_NAME, 0, 0, &name_mesg)<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
"cannot add/change name message");
}
if (1!=H5O_link (f, ent, 1)) {
if (1!=H5O_link (ent, 1)) {
HRETURN_ERROR (H5E_SYM, H5E_LINK, FAIL, "bad link count");
}
f->shared->root_ent = H5MM_xmalloc (sizeof(H5G_entry_t));
*(f->shared->root_ent) = *ent;
ent->file->shared->root_ent = H5G_ent_calloc (ent);
HRETURN (SUCCEED);
}
@ -1263,22 +1259,22 @@ H5G_insert (H5F_t *f, const char *name, H5G_entry_t *ent)
* because the group already exists.
*/
update_grp = H5F_addr_eq (&(grp.header),
&(f->shared->root_ent->header));
if ((status=H5G_mkroot (f, H5G_SIZE_HINT))<0 && -2!=status) {
&(ent->file->shared->root_ent->header));
if ((status=H5G_mkroot (ent->file, H5G_SIZE_HINT))<0 && -2!=status) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "can't create root group");
}
H5ECLEAR;
if (update_grp) grp = *(f->shared->root_ent);
if (update_grp) grp = *(ent->file->shared->root_ent);
/*
* This is the normal case. The object is just being inserted as a normal
* entry into a symbol table.
*/
if (H5O_link (f, ent, 1)<0) {
if (H5O_link (ent, 1)<0) {
HRETURN_ERROR (H5E_SYM, H5E_LINK, FAIL, "link inc failure");
}
if (H5G_stab_insert (f, &grp, rest, ent)<0) {
if (H5G_stab_insert (&grp, rest, ent)<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "can't insert");
}

View File

@ -34,77 +34,16 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
H5G_entry_t *
H5G_ent_calloc (void)
H5G_ent_calloc (H5G_entry_t *init)
{
H5G_entry_t *ent;
ent = H5MM_xcalloc (1, sizeof(H5G_entry_t));
H5F_addr_undef (&(ent->header));
if (init) *ent = *init;
else H5F_addr_undef (&(ent->header));
return ent;
}
/*-------------------------------------------------------------------------
* Function: H5G_ent_invalidate
*
* Purpose: Invalidates the cache in a symbol table entry.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Friday, September 19, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5G_ent_invalidate (H5G_entry_t *ent)
{
FUNC_ENTER (H5G_ent_invalidate, FAIL);
if (ent && H5G_NOTHING_CACHED!=ent->type) {
ent->dirty = TRUE;
ent->type = H5G_NOTHING_CACHED;
}
FUNC_LEAVE (SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5G_ent_addr
*
* Purpose: Returns the header address associated with a symbol table
* entry.
*
* Return: Success: SUCCED with the address returned in the ADDR
* argument.
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Friday, September 19, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5G_ent_addr (H5G_entry_t *ent, haddr_t *addr/*out*/)
{
FUNC_ENTER (H5G_ent_addr, FAIL);
assert (ent);
*addr = ent->header;
FUNC_LEAVE (SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5G_ent_cache
@ -248,6 +187,8 @@ H5G_ent_decode (H5F_t *f, const uint8 **pp, H5G_entry_t *ent)
assert (pp);
assert (ent);
ent->file = f;
/* decode header */
H5F_decode_length (f, *pp, ent->name_off);
H5F_addr_decode (f, pp, &(ent->header));
@ -258,15 +199,6 @@ H5G_ent_decode (H5F_t *f, const uint8 **pp, H5G_entry_t *ent)
case H5G_NOTHING_CACHED:
break;
case H5G_CACHED_SDSPACE:
assert (5*4 <= H5G_SIZEOF_SCRATCH);
UINT32DECODE (*pp, ent->cache.sdspace.ndim);
UINT32DECODE (*pp, ent->cache.sdspace.dim[0]);
UINT32DECODE (*pp, ent->cache.sdspace.dim[1]);
UINT32DECODE (*pp, ent->cache.sdspace.dim[2]);
UINT32DECODE (*pp, ent->cache.sdspace.dim[3]);
break;
case H5G_CACHED_STAB:
assert (2*H5F_SIZEOF_ADDR (f) <= H5G_SIZEOF_SCRATCH);
H5F_addr_decode (f, pp, &(ent->cache.stab.btree_addr));
@ -376,15 +308,6 @@ H5G_ent_encode (H5F_t *f, uint8 **pp, H5G_entry_t *ent)
case H5G_NOTHING_CACHED:
break;
case H5G_CACHED_SDSPACE:
assert (5*4 <= H5G_SIZEOF_SCRATCH);
UINT32ENCODE (*pp, ent->cache.sdspace.ndim);
UINT32ENCODE (*pp, ent->cache.sdspace.dim[0]);
UINT32ENCODE (*pp, ent->cache.sdspace.dim[1]);
UINT32ENCODE (*pp, ent->cache.sdspace.dim[2]);
UINT32ENCODE (*pp, ent->cache.sdspace.dim[3]);
break;
case H5G_CACHED_STAB:
assert (2*H5F_SIZEOF_ADDR (f) <= H5G_SIZEOF_SCRATCH);
H5F_addr_encode (f, pp, &(ent->cache.stab.btree_addr));
@ -433,9 +356,6 @@ herr_t
H5G_ent_debug (H5F_t *f, H5G_entry_t *ent, FILE *stream, intn indent,
intn fwidth)
{
int i;
char buf[64];
FUNC_ENTER (H5G_ent_debug, FAIL);
fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
@ -457,19 +377,6 @@ H5G_ent_debug (H5F_t *f, H5G_entry_t *ent, FILE *stream, intn indent,
fprintf (stream, "Nothing Cached\n");
break;
case H5G_CACHED_SDSPACE:
fprintf (stream, "Simple data space\n");
fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
"Dimensionality:",
(unsigned)(ent->cache.sdspace.ndim));
for (i=0; i<ent->cache.sdspace.ndim && i<4; i++) {
sprintf (buf, "Dimension %d", i);
fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
buf,
(unsigned)(ent->cache.sdspace.dim[i]));
}
break;
case H5G_CACHED_STAB:
fprintf (stream, "Symbol Table\n");

View File

@ -50,7 +50,6 @@ typedef struct H5G_node_key_t {
* above the H5G layer.
*/
struct H5G_t {
H5F_t *file; /*file containing group */
int nref; /*open reference count */
H5G_entry_t ent; /*info about the group */
};
@ -122,12 +121,12 @@ extern const H5AC_class_t H5AC_SNODE[1];
* the library and appear in H5Gprivate.h.
*/
herr_t H5G_stab_create (H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/);
herr_t H5G_stab_find (H5F_t *f, H5G_entry_t *grp_ent, const char *name,
herr_t H5G_stab_find (H5G_entry_t *grp_ent, const char *name,
H5G_entry_t *obj_ent/*out*/);
herr_t H5G_stab_insert (H5F_t *f, H5G_entry_t *grp_ent, const char *name,
herr_t H5G_stab_insert (H5G_entry_t *grp_ent, const char *name,
H5G_entry_t *obj_ent);
intn H5G_stab_list (H5F_t *f, H5G_entry_t *self, intn maxentries,
char *names[], H5G_entry_t entries[]);
intn H5G_stab_list (H5G_entry_t *self, intn maxentries,
char *names[]/*out*/, H5G_entry_t entries[]/*out*/);
/*
* Functions that understand symbol table entries.

View File

@ -52,20 +52,19 @@
*/
typedef enum H5G_type_t {
H5G_NOTHING_CACHED =0, /*nothing is cached, must be 0 */
H5G_CACHED_SDSPACE =1, /*simple data space */
H5G_CACHED_STAB =2 /*symbol table, `stab' */
H5G_CACHED_STAB =1, /*symbol table, `stab' */
H5G_NCACHED =2 /*THIS MUST BE LAST */
} H5G_type_t;
/*
* A symbol table entry caches these parameters from object header
* messages...
* messages... The values are entered into the symbol table when an object
* header is created (by hand) and are extracted from the symbol table with a
* callback function registered in H5O_init_interface(). Be sure to update
* H5G_ent_decode(), H5G_ent_encode(), and H5G_ent_debug() as well.
*/
typedef union H5G_cache_t {
struct {
uint32 ndim; /*number of dimensions */
uint32 dim[4]; /*dimension sizes */
} sdspace;
struct {
haddr_t btree_addr; /*file address of symbol table B-tree */
haddr_t heap_addr; /*file address of stab name heap */
@ -84,6 +83,7 @@ typedef struct H5G_entry_t {
haddr_t header; /*file address of object header */
H5G_type_t type; /*type of information cached */
H5G_cache_t cache; /*cached data from object header */
H5F_t *file; /*file to which this obj hdr belongs */
} H5G_entry_t;
typedef struct H5G_t H5G_t;
@ -99,11 +99,11 @@ herr_t H5G_close (H5G_t *grp);
herr_t H5G_set (H5F_t *f, H5G_t *grp);
herr_t H5G_push (H5F_t *f, H5G_t *grp);
herr_t H5G_pop (H5F_t *f);
herr_t H5G_insert (H5F_t *f, const char *name, H5G_entry_t *ent);
herr_t H5G_find (H5F_t *f, const char *name, H5G_entry_t *grp_ent,
H5G_entry_t *ent);
herr_t H5G_insert (const char *name, H5G_entry_t *ent);
herr_t H5G_find (H5F_t *f, const char *name, H5G_entry_t *grp_ent/*out*/,
H5G_entry_t *ent/*out*/);
herr_t H5G_ent_encode (H5F_t *f, uint8 **pp, H5G_entry_t *ent);
herr_t H5G_ent_decode (H5F_t *f, const uint8 **pp, H5G_entry_t *ent);
herr_t H5G_ent_decode (H5F_t *f, const uint8 **pp, H5G_entry_t *ent/*out*/);
/*
* These functions operate on symbol table nodes.
@ -116,9 +116,7 @@ herr_t H5G_node_debug (H5F_t *f, const haddr_t *addr, FILE *stream,
* in the H5O package where header messages are cached in symbol table
* entries. The subclasses of H5O probably don't need them though.
*/
H5G_entry_t *H5G_ent_calloc (void);
herr_t H5G_ent_invalidate (H5G_entry_t *ent);
herr_t H5G_ent_addr (H5G_entry_t *ent, haddr_t *retval/*out*/);
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,

View File

@ -31,8 +31,8 @@ hid_t H5Gcreate (hid_t file_id, const char *name, size_t size_hint);
hid_t H5Gopen (hid_t file_id, const char *name);
herr_t H5Gclose (hid_t grp_id);
herr_t H5Gset (hid_t file, hid_t grp_id);
herr_t H5Gpush (hid_t file, hid_t grp_id);
herr_t H5Gset (hid_t file, const char *name);
herr_t H5Gpush (hid_t file, const char *name);
herr_t H5Gpop (hid_t file);
#ifdef __cplusplus

View File

@ -89,11 +89,17 @@ H5G_stab_create (H5F_t *f, size_t init, H5G_entry_t *self/*out*/)
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "can't create header");
}
/* insert the symbol table message */
if (H5O_modify (f, self, H5O_STAB, H5O_NEW_MESG, &stab)<0) {
H5O_close (f, self);
/*
* Insert the symbol table message into the object header and the symbol
* table entry.
*/
if (H5O_modify (self, H5O_STAB, H5O_NEW_MESG, H5O_FLAG_CONSTANT, &stab)<0) {
H5O_close (self);
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "can't create message");
}
self->cache.stab.btree_addr = stab.btree_addr;
self->cache.stab.heap_addr = stab.heap_addr;
self->type = H5G_CACHED_STAB;
FUNC_LEAVE (SUCCEED);
}
@ -121,7 +127,7 @@ H5G_stab_create (H5F_t *f, size_t init, H5G_entry_t *self/*out*/)
*-------------------------------------------------------------------------
*/
herr_t
H5G_stab_find (H5F_t *f, H5G_entry_t *grp_ent, const char *name,
H5G_stab_find (H5G_entry_t *grp_ent, const char *name,
H5G_entry_t *obj_ent/*out*/)
{
H5G_bt_ud1_t udata; /*data to pass through B-tree */
@ -130,12 +136,12 @@ H5G_stab_find (H5F_t *f, H5G_entry_t *grp_ent, const char *name,
FUNC_ENTER (H5G_stab_find, FAIL);
/* Check arguments */
assert (f);
assert (grp_ent);
assert (grp_ent->file);
assert (name && *name);
/* set up the udata */
if (NULL==H5O_read (f, grp_ent, H5O_STAB, 0, &stab)) {
if (NULL==H5O_read (grp_ent, H5O_STAB, 0, &stab)) {
HRETURN_ERROR (H5E_SYM, H5E_BADMESG, FAIL, "can't read message");
}
udata.operation = H5G_OPER_FIND;
@ -143,7 +149,7 @@ H5G_stab_find (H5F_t *f, H5G_entry_t *grp_ent, const char *name,
udata.heap_addr = stab.heap_addr;
/* search the B-tree */
if (H5B_find (f, H5B_SNODE, &(stab.btree_addr), &udata)<0) {
if (H5B_find (grp_ent->file, H5B_SNODE, &(stab.btree_addr), &udata)<0) {
HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
}
@ -174,8 +180,7 @@ H5G_stab_find (H5F_t *f, H5G_entry_t *grp_ent, const char *name,
*-------------------------------------------------------------------------
*/
herr_t
H5G_stab_insert (H5F_t *f, H5G_entry_t *grp_ent, const char *name,
H5G_entry_t *obj_ent)
H5G_stab_insert (H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent)
{
H5O_stab_t stab; /*symbol table message */
H5G_bt_ud1_t udata; /*data to pass through B-tree */
@ -183,13 +188,13 @@ H5G_stab_insert (H5F_t *f, H5G_entry_t *grp_ent, const char *name,
FUNC_ENTER (H5G_stab_insert, FAIL);
/* check arguments */
assert (f);
assert (grp_ent && H5F_addr_defined (&(grp_ent->header)));
assert (grp_ent && grp_ent->file);
assert (name && *name);
assert (obj_ent && H5F_addr_defined (&(obj_ent->header)));
assert (obj_ent && obj_ent->file);
assert (grp_ent->file->shared==obj_ent->file->shared);
/* initialize data to pass through B-tree */
if (NULL==H5O_read (f, grp_ent, H5O_STAB, 0, &stab)) {
if (NULL==H5O_read (grp_ent, H5O_STAB, 0, &stab)) {
HRETURN_ERROR (H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
}
@ -199,7 +204,7 @@ H5G_stab_insert (H5F_t *f, H5G_entry_t *grp_ent, const char *name,
udata.ent = *obj_ent;
/* insert */
if (H5B_insert (f, H5B_SNODE, &(stab.btree_addr), &udata)<0) {
if (H5B_insert (grp_ent->file, H5B_SNODE, &(stab.btree_addr), &udata)<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert entry");
}
@ -241,8 +246,8 @@ H5G_stab_insert (H5F_t *f, H5G_entry_t *grp_ent, const char *name,
*-------------------------------------------------------------------------
*/
intn
H5G_stab_list (H5F_t *f, H5G_entry_t *grp_ent, intn maxentries,
char *names[], H5G_entry_t entries[])
H5G_stab_list (H5G_entry_t *grp_ent, intn maxentries, char *names[]/*out*/,
H5G_entry_t entries[]/*out*/)
{
H5G_bt_ud2_t udata;
H5O_stab_t stab;
@ -251,12 +256,11 @@ H5G_stab_list (H5F_t *f, H5G_entry_t *grp_ent, intn maxentries,
FUNC_ENTER (H5G_stab_list, FAIL);
/* check args */
assert (f);
assert (grp_ent && H5F_addr_defined (&(grp_ent->header)));
assert (grp_ent && grp_ent->file);
assert (maxentries>=0);
/* initialize data to pass through B-tree */
if (NULL==H5O_read (f, grp_ent, H5O_STAB, 0, &stab)) {
if (NULL==H5O_read (grp_ent, H5O_STAB, 0, &stab)) {
HRETURN_ERROR (H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
}
udata.entry = entries;
@ -267,7 +271,7 @@ H5G_stab_list (H5F_t *f, H5G_entry_t *grp_ent, intn maxentries,
if (names) HDmemset (names, 0, maxentries);
/* list */
if (H5B_list (f, H5B_SNODE, &(stab.btree_addr), &udata)<0) {
if (H5B_list (grp_ent->file, H5B_SNODE, &(stab.btree_addr), &udata)<0) {
if (names) {
for (i=0; i<maxentries; i++) H5MM_xfree (names[i]);
}

355
src/H5O.c
View File

@ -45,7 +45,8 @@ static const H5AC_class_t H5AC_OHDR[1] = {{
/* Interface initialization */
static intn interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
#define INTERFACE_INIT H5O_init_interface
static herr_t H5O_init_interface (void);
/* ID to type mapping */
static const H5O_class_t *const message_type_g[] = {
@ -69,6 +70,46 @@ static const H5O_class_t *const message_type_g[] = {
H5O_STAB, /*0x0011 Symbol table */
};
/*
* An array of functions indexed by symbol table entry cache type
* (H5G_type_t) that are called to retrieve constant messages cached in the
* symbol table entry.
*/
static void *(*H5O_fast_g[H5G_NCACHED])(const H5G_cache_t*,
const H5O_class_t *,
void*);
/*-------------------------------------------------------------------------
* Function: H5O_init_interface
*
* Purpose: Initialize the H5O interface.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Tuesday, January 6, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O_init_interface (void)
{
FUNC_ENTER (H5O_init_interface, FAIL);
/*
* Initialize functions that decode messages from symbol table entries.
*/
H5O_fast_g[H5G_CACHED_STAB] = H5O_stab_fast;
FUNC_LEAVE (SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5O_create
@ -185,12 +226,19 @@ H5O_open (H5F_t *f, H5G_entry_t *obj_ent)
{
FUNC_ENTER (H5O_open, FAIL);
/*
* There is nothing to do here now. Opening an object header should
* eventually do something to prevent the object header from being deleted,
* but since object deletion isn't implemented yet, we don't care.
*/
/* Check args */
assert (f);
assert (obj_ent);
#ifdef H5O_DEBUG
fprintf (stderr, ">");
H5F_addr_print (stderr, &(obj_ent->header));
fprintf (stderr, "\n");
#endif
/* Increment open-lock counters */
obj_ent->file = f;
obj_ent->file->nopen++;
FUNC_LEAVE (SUCCEED);
}
@ -212,17 +260,32 @@ H5O_open (H5F_t *f, H5G_entry_t *obj_ent)
*-------------------------------------------------------------------------
*/
herr_t
H5O_close (H5F_t *f, H5G_entry_t *obj_ent)
H5O_close (H5G_entry_t *obj_ent)
{
FUNC_ENTER (H5O_close, FAIL);
/*
* There is nothing to do here now. See H5O_open(). Eventually this
* function will free resources if the object header hard link count is
* zero and this was the last oustanding open for the object. Since
* object deletion isn't implemented yet, we don't care.
*/
/* Check args */
assert (obj_ent);
assert (obj_ent->file);
assert (obj_ent->file->nopen>0);
/* Decrement open-lock counters */
--obj_ent->file->nopen;
/*
* If the file open-lock count has reached zero and the file has a close
* pending then close the file.
*/
if (0==obj_ent->file->nopen && obj_ent->file->close_pending) {
H5F_close (obj_ent->file);
}
#ifdef H5O_DEBUG
fprintf (stderr, "<");
H5F_addr_print (stderr, &(obj_ent->header));
fprintf (stderr, "\n");
#endif
FUNC_LEAVE (SUCCEED);
}
@ -245,6 +308,9 @@ H5O_close (H5F_t *f, H5G_entry_t *obj_ent)
* Robb Matzke, 30 Aug 1997
* Plugged memory leaks that occur during error handling.
*
* Robb Matzke, 7 Jan 1998
* Able to distinguish between constant and variable messages.
*
*-------------------------------------------------------------------------
*/
static H5O_t *
@ -259,6 +325,8 @@ H5O_load (H5F_t *f, const haddr_t *addr, const void *_udata1, void *_udata2)
haddr_t chunk_addr;
size_t chunk_size;
H5O_cont_t *cont=NULL;
hbool_t constant; /*is message a constant mesg? */
FUNC_ENTER (H5O_load, NULL);
@ -337,6 +405,13 @@ H5O_load (H5F_t *f, const haddr_t *addr, const void *_udata1, void *_udata2)
p += mesg_size) {
UINT16DECODE (p, id);
UINT16DECODE (p, mesg_size);
/*
* The message ID field actually contains some bits near the
* high-order end that are not part of the ID.
*/
constant = (id & H5O_FLAG_CONSTANT) ? TRUE : FALSE;
id &= ~H5O_FLAG_BITS;
if (id>=NELMTS(message_type_g) || NULL==message_type_g[id]) {
HGOTO_ERROR (H5E_OHDR, H5E_BADMESG, NULL,
@ -362,6 +437,7 @@ H5O_load (H5F_t *f, const haddr_t *addr, const void *_udata1, void *_udata2)
mesgno = oh->nmesgs++;
oh->mesg[mesgno].type = message_type_g[id];
oh->mesg[mesgno].dirty = FALSE;
oh->mesg[mesgno].constant = constant;
oh->mesg[mesgno].native = NULL;
oh->mesg[mesgno].raw = p;
oh->mesg[mesgno].raw_size = mesg_size;
@ -418,13 +494,16 @@ done:
*
* Modifications:
*
* Robb Matzke, 7 Jan 1998
* Handles constant vs non-constant messages.
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
{
uint8 buf[16], *p;
int i;
intn i, id;
H5O_cont_t *cont = NULL;
FUNC_ENTER (H5O_flush, FAIL);
@ -463,8 +542,13 @@ H5O_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
for (i=0; i<oh->nmesgs; i++) {
if (oh->mesg[i].dirty) {
p = oh->mesg[i].raw - 4;
UINT16ENCODE (p, oh->mesg[i].type->id);
/* The message id has some flags in the high-order bits. */
id = oh->mesg[i].type->id;
id |= oh->mesg[i].constant ? H5O_FLAG_CONSTANT : 0;
UINT16ENCODE (p, id);
UINT16ENCODE (p, oh->mesg[i].raw_size);
if (oh->mesg[i].native) {
assert (oh->mesg[i].type->encode);
@ -569,7 +653,6 @@ H5O_reset (const H5O_class_t *type, void *native)
if (native) {
if (type->reset) {
if ((type->reset)(native)<0) {
/* reset class method failed */
HRETURN_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
"reset method failed");
}
@ -601,43 +684,46 @@ H5O_reset (const H5O_class_t *type, void *native)
*-------------------------------------------------------------------------
*/
intn
H5O_link (H5F_t *f, H5G_entry_t *ent, intn adjust)
H5O_link (H5G_entry_t *ent, intn adjust)
{
H5O_t *oh = NULL;
haddr_t addr;
intn ret_value = FAIL;
FUNC_ENTER (H5O_link, FAIL);
/* check args */
assert (f);
assert (ent);
H5G_ent_addr (ent, &addr);
assert (H5F_addr_defined (&addr));
assert (ent->file);
assert (H5F_addr_defined (&(ent->header)));
/* get header */
if (NULL==(oh=H5AC_find (f, H5AC_OHDR, &addr, NULL, NULL))) {
HRETURN_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
"unable to load object header");
if (NULL==(oh=H5AC_protect (ent->file, H5AC_OHDR, &(ent->header),
NULL, NULL))) {
HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
"unable to load object header");
}
/* adjust link count */
if (adjust<0) {
if (oh->nlink + adjust < 0) {
HRETURN_ERROR (H5E_OHDR, H5E_LINKCOUNT, FAIL,
"link could would be negative");
HGOTO_ERROR (H5E_OHDR, H5E_LINKCOUNT, FAIL,
"link count would be negative");
}
oh->nlink += adjust;
if (1==oh->nlink && ent) {
fprintf (stderr, "H5O_link: no symbol table entry caching "
"(not implemented yet)\n");
}
} else {
oh->nlink += adjust;
if (oh->nlink>1) H5G_ent_invalidate (ent);
}
oh->dirty = TRUE;
FUNC_LEAVE (oh->nlink);
ret_value = oh->nlink;
done:
if (oh && H5AC_unprotect (ent->file, H5AC_OHDR, &(ent->header), oh)<0) {
HRETURN_ERROR (H5E_OHDR, H5E_PROTECT, FAIL,
"unable to release object header");
}
FUNC_LEAVE (ret_value);
}
@ -663,8 +749,7 @@ H5O_link (H5F_t *f, H5G_entry_t *ent, intn adjust)
*-------------------------------------------------------------------------
*/
void *
H5O_read (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type,
intn sequence, void *mesg)
H5O_read (H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg)
{
H5O_t *oh = NULL;
void *retval = NULL;
@ -675,32 +760,40 @@ H5O_read (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type,
FUNC_ENTER (H5O_read, NULL);
/* check args */
assert (f);
assert (ent);
assert (ent->file);
assert (H5F_addr_defined (&(ent->header)));
assert (type);
assert (sequence>=0);
/* can we get it from the symbol table? */
/* can we get it from the symbol table entry? */
cache = H5G_ent_cache (ent, &cache_type);
if (type && cache_type==type->cache_type && type->fast) {
retval = (type->fast)(cache, mesg);
if (H5O_fast_g[cache_type]) {
retval = (H5O_fast_g[cache_type])(cache, type, mesg);
if (retval) HRETURN (retval);
H5ECLEAR;
H5ECLEAR; /*don't care, try reading from header*/
}
/* can we get it from the object header? */
if ((idx = H5O_find_in_ohdr (f, &(ent->header), &type, sequence))<0) {
if ((idx = H5O_find_in_ohdr (ent->file, &(ent->header), &type,
sequence))<0) {
HRETURN_ERROR (H5E_OHDR, H5E_NOTFOUND, NULL,
"unable to find message in object header");
}
/* copy the message to the user-supplied buffer */
if (NULL==(oh=H5AC_find (f, H5AC_OHDR, &(ent->header), NULL, NULL))) {
if (NULL==(oh=H5AC_protect (ent->file, H5AC_OHDR, &(ent->header),
NULL, NULL))) {
HRETURN_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
"unable to load object header");
}
retval = (type->copy)(oh->mesg[idx].native, mesg);
if (H5AC_unprotect (ent->file, H5AC_OHDR, &(ent->header), oh)<0) {
HRETURN_ERROR (H5E_OHDR, H5E_PROTECT, NULL,
"unable to release object header");
}
oh = NULL;
if (!retval) {
HRETURN_ERROR (H5E_OHDR, H5E_CANTINIT, NULL,
"unable to copy object header message to user space");
@ -776,62 +869,16 @@ H5O_find_in_ohdr (H5F_t *f, const haddr_t *addr, const H5O_class_t **type_p,
FUNC_LEAVE (i);
}
/*-------------------------------------------------------------------------
* Function: H5O_peek
*
* Purpose: Returns a pointer to a message stored in native format.
* The returned memory is read-only, and points directly into
* the cache. It is therefore valid only until the next cache
* function is called.
*
* Return: Success: Ptr to read-only message in native format.
* The pointer is guranteed to be valid only
* until the next call (directly or indirectly)
* to an H5AC function.
*
* Failure: NULL
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
const void *
H5O_peek (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type,
intn sequence)
{
intn idx;
H5O_t *oh = NULL;
FUNC_ENTER (H5O_peek, NULL);
/* check args */
assert (f);
assert (ent && H5F_addr_defined (&(ent->header)));
if ((idx = H5O_find_in_ohdr (f, &(ent->header), &type, sequence))<0) {
HRETURN_ERROR (H5E_OHDR, H5E_NOTFOUND, NULL,
"unable to find object header message");
}
if (NULL==(oh=H5AC_find (f, H5AC_OHDR, &(ent->header), NULL, NULL))) {
HRETURN_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
"unable to load object header");
}
FUNC_LEAVE (oh->mesg[idx].native);
}
/*-------------------------------------------------------------------------
* Function: H5O_modify
*
* Purpose: Modifies an existing message or creates a new message.
* The cache fields in that symbol table entry ENT are updated
* as appropriate.
* The cache fields in that symbol table entry ENT are *not*
* updated, you must do that separately because they often
* depend on multiple object header messages. Besides, we
* don't know which messages will be constant and which will
* not.
*
* The OVERWRITE argument is either a sequence number of a
* message to overwrite (usually zero) or the constant
@ -853,28 +900,35 @@ H5O_peek (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type,
*
* Modifications:
*
* Robb Matzke, 7 Jan 1998
* Handles constant vs non-constant messages. Once a message is made
* constant it can never become non-constant. Constant messages cannot
* be modified.
*
*-------------------------------------------------------------------------
*/
intn
H5O_modify (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type,
intn overwrite, const void *mesg)
H5O_modify (H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
uintn flags, const void *mesg)
{
H5O_t *oh = NULL;
intn idx, sequence;
intn ret_value = FAIL;
size_t size;
FUNC_ENTER (H5O_modify, FAIL);
/* check args */
assert (f);
assert (ent);
assert (ent->file);
assert (H5F_addr_defined (&(ent->header)));
assert (type);
assert (mesg);
if (NULL==(oh=H5AC_find (f, H5AC_OHDR, &(ent->header), NULL, NULL))) {
HRETURN_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
"unable to load object header");
if (NULL==(oh=H5AC_protect (ent->file, H5AC_OHDR, &(ent->header),
NULL, NULL))) {
HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
"unable to load object header");
}
/* Count similar messages */
@ -891,41 +945,44 @@ H5O_modify (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type,
if (overwrite==sequence+1) {
overwrite = -1;
} else {
HRETURN_ERROR (H5E_OHDR, H5E_NOTFOUND, FAIL, "message not found");
HGOTO_ERROR (H5E_OHDR, H5E_NOTFOUND, FAIL, "message not found");
}
}
/* Allocate space for the new message */
if (overwrite<0) {
size = (type->raw_size)(f, mesg);
/* Allocate space for the new message */
size = (type->raw_size)(ent->file, mesg);
H5O_ALIGN (size, oh->alignment);
idx = H5O_alloc (f, oh, type, size);
idx = H5O_alloc (ent->file, oh, type, size);
if (idx<0) {
HRETURN_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
"unable to allocate object header space for message");
HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
"unable to allocate object header space for message");
}
sequence++;
} else if (oh->mesg[idx].constant) {
HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL,
"unable to modify constant message");
}
/* Copy the native value into the object header */
oh->mesg[idx].native = (type->copy)(mesg, oh->mesg[idx].native);
if (NULL==oh->mesg[idx].native) {
HRETURN_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
"unable to copy message to object header");
HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
"unable to copy message to object header");
}
oh->mesg[idx].constant = (flags & H5O_FLAG_CONSTANT) ? TRUE : FALSE;
oh->mesg[idx].dirty = TRUE;
oh->dirty = TRUE;
ret_value = sequence;
/* Copy into the symbol table entry */
if (oh->nlink<=1 && type->cache) {
H5G_type_t cache_type;
H5G_cache_t *cache = H5G_ent_cache (ent, &cache_type);
hbool_t modified = (type->cache)(&cache_type, cache, mesg);
if (modified) H5G_ent_modified (ent, cache_type);
done:
if (oh && H5AC_unprotect (ent->file, H5AC_OHDR, &(ent->header), oh)<0) {
HRETURN_ERROR (H5E_OHDR, H5E_PROTECT, FAIL,
"unable to release object header");
}
FUNC_LEAVE (sequence);
FUNC_LEAVE (ret_value);
}
@ -938,12 +995,6 @@ H5O_modify (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type,
* the sequence numbers to change for subsequent messages of
* the same type.
*
* If the messaage was cached in the symbol table entry then
* the type field of the symbol table entry is changed to
* H5G_NOTHING_CACHED and the ENT_MODIFIED argument will point
* to non-zero (the ENT_MODIFIED argument is unchanged if
* the ENT type field doesn't change).
*
* No attempt is made to join adjacent free areas of the
* object header into a single larger free area.
*
@ -957,37 +1008,44 @@ H5O_modify (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type,
*
* Modifications:
*
* Robb Matzke, 7 Jan 1998
* Does not remove constant messages.
*
*-------------------------------------------------------------------------
*/
herr_t
H5O_remove (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
H5O_remove (H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
{
H5O_t *oh = NULL;
intn i, seq;
intn i, seq, nfailed=0;
herr_t ret_value = FAIL;
FUNC_ENTER (H5O_remove, FAIL);
/* check args */
assert (f);
assert (ent);
assert (ent->file);
assert (H5F_addr_defined (&(ent->header)));
assert (type);
/* load the object header */
if (NULL==(oh=H5AC_find (f, H5AC_OHDR, &(ent->header), NULL, NULL))) {
HRETURN_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
"unable to load object header");
if (NULL==(oh=H5AC_protect (ent->file, H5AC_OHDR, &(ent->header),
NULL, NULL))) {
HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
"unable to load object header");
}
for (i=seq=0; i<oh->nmesgs; i++) {
if (type->id != oh->mesg[i].type->id) continue;
if (seq++ == sequence || H5O_ALL==sequence) {
H5G_type_t cache_type;
H5G_ent_cache (ent, &cache_type);
/* clear symbol table entry cache */
if (ent && type->cache && type->cache_type==cache_type) {
H5G_ent_invalidate (ent);
/*
* Keep track of how many times we failed trying to remove constant
* messages.
*/
if (oh->mesg[i].constant) {
nfailed++;
continue;
}
/* change message type to nil and zero it */
@ -1001,7 +1059,21 @@ H5O_remove (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
}
}
FUNC_LEAVE (SUCCEED);
/* Fail if we tried to remove any constant messages */
if (nfailed) {
HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
"unable to remove constant message(s)");
}
ret_value = SUCCEED;
done:
if (oh && H5AC_unprotect (ent->file, H5AC_OHDR, &(ent->header), oh)<0) {
HRETURN_ERROR (H5E_OHDR, H5E_PROTECT, FAIL,
"unable to release object header");
}
FUNC_LEAVE (ret_value);
}
@ -1412,6 +1484,7 @@ H5O_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
size_t mesg_total=0, chunk_total=0;
int *sequence;
haddr_t tmp_addr;
herr_t ret_value = FAIL;
FUNC_ENTER (H5O_debug, FAIL);
@ -1422,8 +1495,8 @@ H5O_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
assert (indent>=0);
assert (fwidth>=0);
if (NULL==(oh=H5AC_find (f, H5AC_OHDR, addr, NULL, NULL))) {
HRETURN_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
if (NULL==(oh=H5AC_protect (f, H5AC_OHDR, addr, NULL, NULL))) {
HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
"unable to load object header");
}
@ -1497,7 +1570,9 @@ H5O_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
fprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (0, fwidth-3),
"Raw size in bytes:",
(unsigned long)(oh->mesg[i].raw_size));
fprintf (stream, "%*s%-*s %s\n", indent+3, "", MAX (0, fwidth-3),
"Constant:",
oh->mesg[i].constant ? "Yes" : "No");
fprintf (stream, "%*s%-*s %d\n", indent+3, "", MAX(0,fwidth-3),
"Chunk number:",
(int)(oh->mesg[i].chunkno));
@ -1534,5 +1609,13 @@ H5O_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
fprintf (stream, "*** TOTAL SIZE DOES NOT MATCH ALLOCATED SIZE!\n");
}
FUNC_LEAVE (SUCCEED);
ret_value = SUCCEED;
done:
if (oh && H5AC_unprotect (f, H5AC_OHDR, addr, oh)<0) {
HRETURN_ERROR (H5E_OHDR, H5E_PROTECT, FAIL,
"unable to release object header");
}
FUNC_LEAVE (ret_value);
}

View File

@ -36,11 +36,8 @@ 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 */
H5G_NOTHING_CACHED, /*symbol table type field */
H5O_cont_decode, /*decode message */
H5O_cont_encode, /*encode message */
NULL, /*no fast method */
NULL, /*no cache method */
NULL, /*no copy method */
NULL, /*no size method */
NULL, /*default reset method */

View File

@ -45,11 +45,8 @@ const H5O_class_t H5O_CSTORE[1] = {{
H5O_CSTORE_ID, /* message id number */
"cstore", /* message name for debugging */
sizeof (H5O_cstore_t), /* native message size */
H5G_NOTHING_CACHED, /* symtab entry `type' field */
H5O_cstore_decode, /* decode message */
H5O_cstore_encode, /* encode message */
NULL, /* get message from stab entry */
NULL, /* put message into stab entry */
H5O_cstore_copy, /* copy the native value */
H5O_cstore_size, /* size of symbol table entry */
NULL, /* default reset method */

View File

@ -42,11 +42,8 @@ const H5O_class_t H5O_DTYPE[1] = {{
H5O_DTYPE_ID, /* message id number */
"data_type", /* message name for debugging */
sizeof (H5T_t), /* native message size */
H5G_NOTHING_CACHED, /* symtab entry `type' field */
H5O_dtype_decode, /* decode message */
H5O_dtype_encode, /* encode message */
NULL, /* get message from stab entry */
NULL, /* put message into stab entry */
H5O_dtype_copy, /* copy the native value */
H5O_dtype_size, /* size of raw message */
H5O_dtype_reset, /* reset method */

View File

@ -27,11 +27,8 @@ 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 */
H5G_NOTHING_CACHED, /*symtab entry `type' field */
H5O_efl_decode, /*decode message */
H5O_efl_encode, /*encode message */
NULL, /*get messaage from stab entry */
NULL, /*put message into stab entry */
H5O_efl_copy, /*copy native value */
H5O_efl_size, /*size of message on disk */
H5O_efl_reset, /*reset method */

View File

@ -26,11 +26,8 @@ const H5O_class_t H5O_ISTORE[1] = {{
H5O_ISTORE_ID, /*message id number */
"istore", /*message name for debugging */
sizeof(H5O_istore_t), /*native message size */
H5G_NOTHING_CACHED, /*symtab entry `type' field */
H5O_istore_decode, /*decode message */
H5O_istore_encode, /*encode message */
NULL, /*get messsage from stab entry */
NULL, /*put message into stab entry */
H5O_istore_copy, /*copy the native value */
H5O_istore_size, /*size of message on disk */
NULL, /*reset method */

View File

@ -36,11 +36,8 @@ 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 */
H5G_NOTHING_CACHED, /*symbol table entry type field */
H5O_name_decode, /*decode message */
H5O_name_encode, /*encode message */
NULL, /*no stab entry fields */
NULL, /*no stab entry fields */
H5O_name_copy, /*copy the native value */
H5O_name_size, /*raw message size */
H5O_name_reset, /*free internal memory */

View File

@ -24,11 +24,8 @@ const H5O_class_t H5O_NULL[1] = {{
H5O_NULL_ID, /*message id number */
"null", /*message name for debugging */
0, /*native message size */
H5G_NOTHING_CACHED, /*symtab entry `type' field */
NULL, /*no decode method */
NULL, /*no encode method */
NULL, /*no fast method */
NULL, /*no cache method */
NULL, /*no copy method */
NULL, /*no size method */
NULL, /*no reset method */

View File

@ -31,6 +31,10 @@
#define H5O_NEW_MESG (-1) /*new message */
#define H5O_ALL (-1) /*delete all messages of type */
/* Flags which are part of the message id */
#define H5O_FLAG_CONSTANT 0x8000
#define H5O_FLAG_BITS 0x8000
#define H5O_VERSION 1
#define H5O_ALIGNMENT 4
#define H5O_ALIGN(X,A) ((X)=(A)*(((X)+(A)-1)/(A)))
@ -46,11 +50,12 @@ typedef struct H5O_class_t {
intn id; /*message type ID on disk */
const char *name; /*message name for debugging */
size_t native_size; /*size of native message */
H5G_type_t cache_type; /*type field in symbol table */
void *(*decode)(H5F_t*,size_t,const uint8*);
herr_t (*encode)(H5F_t*,size_t,uint8*,const void*);
#if 0
void *(*fast)(const H5G_cache_t*, void*);/*get from of entry */
hbool_t (*cache)(H5G_type_t*, H5G_cache_t*,const void*); /*into entry*/
#endif
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 structures */
@ -60,6 +65,7 @@ typedef struct H5O_class_t {
typedef struct H5O_mesg_t {
const H5O_class_t *type; /*type of message */
hbool_t dirty; /*raw out of date wrt native */
hbool_t constant; /*is message constant? */
void *native; /*native format message */
uint8 *raw; /*ptr to raw data */
size_t raw_size; /*size with alignment */
@ -172,6 +178,8 @@ typedef struct H5O_cont_t {
*/
#define H5O_STAB_ID 0x0011
extern const H5O_class_t H5O_STAB[1];
void *H5O_stab_fast (const H5G_cache_t *cache, const H5O_class_t *type,
void *_mesg);
typedef struct H5O_stab_t {
haddr_t btree_addr; /*address of B-tree */
@ -182,16 +190,13 @@ typedef struct H5O_stab_t {
herr_t H5O_create (H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/);
herr_t H5O_open (H5F_t *f, H5G_entry_t *ent);
herr_t H5O_close (H5F_t *f, H5G_entry_t *ent);
intn H5O_link (H5F_t *f, H5G_entry_t *ent, intn adjust);
void *H5O_read (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type,
intn sequence, void *mesg);
const void *H5O_peek (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type,
intn sequence);
intn H5O_modify (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type,
intn overwrite, const void *mesg);
herr_t H5O_remove (H5F_t *f, H5G_entry_t *ent, const H5O_class_t *type,
intn sequence);
herr_t H5O_close (H5G_entry_t *ent);
intn H5O_link ( H5G_entry_t *ent, intn adjust);
void *H5O_read (H5G_entry_t *ent, const H5O_class_t *type, intn sequence,
void *mesg);
intn H5O_modify (H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
uintn flags, const void *mesg);
herr_t H5O_remove (H5G_entry_t *ent, const H5O_class_t *type, intn sequence);
herr_t H5O_reset (const H5O_class_t *type, void *native);
herr_t H5O_debug (H5F_t *f, const haddr_t *addr, FILE *stream,
intn indent, intn fwidth);

View File

@ -28,9 +28,6 @@ static char RcsId[] = "@(#)$Revision$";
static void *H5O_sdspace_decode (H5F_t *f, size_t raw_size, const uint8 *p);
static herr_t H5O_sdspace_encode (H5F_t *f, size_t size, uint8 *p,
const void *_mesg);
static void *H5O_sdspace_fast (const H5G_cache_t *cache, void *_mesg);
static hbool_t H5O_sdspace_cache (H5G_type_t *cache_type, H5G_cache_t *cache,
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);
static herr_t H5O_sdspace_debug (H5F_t *f, const void *_mesg,
@ -41,11 +38,8 @@ const H5O_class_t H5O_SDSPACE[1] = {{
H5O_SDSPACE_ID, /* message id number */
"simple_dspace", /* message name for debugging */
sizeof (H5P_simple_t), /* native message size */
H5G_CACHED_SDSPACE, /* symtab entry `type' field */
H5O_sdspace_decode, /* decode message */
H5O_sdspace_encode, /* encode message */
H5O_sdspace_fast, /* get message from stab entry */
H5O_sdspace_cache, /* put message into stab entry */
H5O_sdspace_copy, /* copy the native value */
H5O_sdspace_size, /* size of symbol table entry */
NULL, /* default reset method */
@ -178,118 +172,6 @@ H5O_sdspace_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
FUNC_LEAVE (SUCCEED);
}
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_fast
PURPOSE
Initializes a new simple dimensionality struct with info from a symbol
table entry.
USAGE
void *H5O_sdspace_fast(ent, mesg)
const H5G_entry_t *ent; IN: pointer to the symbol table entry
const void *mesg; IN: Pointer to the simple dimensionality struct
RETURNS
Pointer to the message structure (allocated if none is supplied) on success,
NULL on failure
DESCRIPTION
This function fills the native memory form of the simple dimensionality
message from a symbol-table entry cache fields. (This method is required
for simple dimensionality, as they can be cached in the symbol-table entry)
--------------------------------------------------------------------------*/
static void *
H5O_sdspace_fast (const H5G_cache_t *cache, void *mesg)
{
H5P_simple_t *sdim = (H5P_simple_t *)mesg;
uintn u; /* local counting variable */
FUNC_ENTER (H5O_sdspace_fast, NULL);
/* check args */
assert (cache);
if (!sdim) sdim = H5MM_xcalloc (1, sizeof(H5P_simple_t));
sdim->rank = cache->sdspace.ndim;
assert (sdim->rank<=NELMTS (cache->sdspace.dim));
sdim->dim_flags = 0;
sdim->size = H5MM_xmalloc (sizeof(uint32) * sdim->rank);
for (u=0; u<sdim->rank; u++) {
sdim->size[u] = cache->sdspace.dim[u];
}
FUNC_LEAVE (sdim);
}
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_cache
PURPOSE
Copies a simple dimensionality message into the cache portion of a symbol
table entry.
USAGE
hbool_t H5O_sdspace_cache(ent, mesg)
const H5G_entry_t *ent; IN: Pointer to the symbol table entry
const void *mesg; IN: Pointer to the simple dimensionality struct
RETURNS
BTRUE if symbol-table modified, BFALSE if not modified, BFAIL on failure.
The new cache type is returned through the CACHE_TYPE argument.
DESCRIPTION
This function is the opposite of the H5O_sdspace_fast method, it
copies a message into the cached portion of a symbol-table entry. (This
method is required for simple dimensionalities, as they can be cached in
the symbol-table entry)
--------------------------------------------------------------------------*/
static hbool_t
H5O_sdspace_cache (H5G_type_t *cache_type, H5G_cache_t *cache,
const void *mesg)
{
const H5P_simple_t *sdim = (const H5P_simple_t *)mesg;
uintn u; /* Local counting variable */
hbool_t modified = BFALSE;
FUNC_ENTER (H5O_sdspace_cache, BFAIL);
/* check args */
assert (cache_type);
assert (cache);
assert (sdim);
if (sdim->rank <= NELMTS (cache->sdspace.dim)) {
if (H5G_CACHED_SDSPACE != *cache_type) {
modified = BTRUE;
*cache_type = H5G_CACHED_SDSPACE;
cache->sdspace.ndim = sdim->rank;
for (u=0; u<=sdim->rank; u++) {
cache->sdspace.dim[u] = sdim->size[u];
}
} else {
if(cache->sdspace.ndim != sdim->rank) {
modified = BTRUE;
cache->sdspace.ndim = sdim->rank;
}
/* Check each dimension */
if (NULL==cache->sdspace.dim) {
modified = BTRUE;
} else {
for (u=0; u<sdim->rank; u++) {
if (cache->sdspace.dim[u] != sdim->size[u]) {
modified = BTRUE;
cache->sdspace.dim[u] = sdim->size[u];
}
}
}
}
} else if (H5G_CACHED_SDSPACE == *cache_type) {
/*
* Number of dimensions is too large to cache.
*/
modified = TRUE;
*cache_type = H5G_NOTHING_CACHED;
}
FUNC_LEAVE (modified);
}
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_copy

View File

@ -26,9 +26,6 @@
static void *H5O_stab_decode (H5F_t *f, size_t raw_size, const uint8 *p);
static herr_t H5O_stab_encode (H5F_t *f, size_t size, uint8 *p,
const void *_mesg);
static void *H5O_stab_fast (const H5G_cache_t *cache, void *_mesg);
static hbool_t H5O_stab_cache (H5G_type_t *cache_type, H5G_cache_t *cache,
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);
static herr_t H5O_stab_debug (H5F_t *f, const void *_mesg,
@ -39,11 +36,8 @@ 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 */
H5G_CACHED_STAB, /*symtab entry `type' field */
H5O_stab_decode, /*decode message */
H5O_stab_encode, /*encode message */
H5O_stab_fast, /*get message from stab entry */
H5O_stab_cache, /*put message into stab entry */
H5O_stab_copy, /*copy the native value */
H5O_stab_size, /*size of symbol table entry */
NULL, /*default reset method */
@ -151,75 +145,25 @@ H5O_stab_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
*
*-------------------------------------------------------------------------
*/
static void *
H5O_stab_fast (const H5G_cache_t *cache, void *_mesg)
void *
H5O_stab_fast (const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg)
{
H5O_stab_t *stab = (H5O_stab_t *)_mesg;
H5O_stab_t *stab = NULL;
FUNC_ENTER (H5O_stab_fast, NULL);
/* check args */
assert (cache);
assert (type);
if (!stab) stab = H5MM_xcalloc (1, sizeof(H5O_stab_t));
stab->btree_addr = cache->stab.btree_addr;
stab->heap_addr = cache->stab.heap_addr;
FUNC_LEAVE (stab);
}
/*-------------------------------------------------------------------------
* Function: H5O_stab_cache
*
* Purpose: Copies a message into the cache portion of a symbol table
* entry.
*
* Return: Success: TRUE if modified; FALSE if not modified.
* In either case, the new cache type is
* returned through the CACHE_TYPE argument.
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static hbool_t
H5O_stab_cache (H5G_type_t *cache_type, H5G_cache_t *cache, const void *_mesg)
{
const H5O_stab_t *stab = (const H5O_stab_t *)_mesg;
hbool_t modified = FALSE;
FUNC_ENTER (H5O_stab_cache, FAIL);
/* check args */
assert (cache_type);
assert (cache);
assert (stab);
if (H5G_CACHED_STAB != *cache_type) {
modified = TRUE;
*cache_type = H5G_CACHED_STAB;
cache->stab.btree_addr = stab->btree_addr;
cache->stab.heap_addr = stab->heap_addr;
} else {
if (H5F_addr_ne (&(cache->stab.btree_addr), &(stab->btree_addr))) {
modified = TRUE;
cache->stab.btree_addr = stab->btree_addr;
}
if (H5F_addr_ne (&(cache->stab.heap_addr), &(stab->heap_addr))) {
modified = TRUE;
cache->stab.heap_addr = stab->heap_addr;
}
if (H5O_STAB==type) {
if (_mesg) stab = (H5O_stab_t *)_mesg;
else stab = H5MM_xcalloc (1, sizeof(H5O_stab_t));
stab->btree_addr = cache->stab.btree_addr;
stab->heap_addr = cache->stab.heap_addr;
}
FUNC_LEAVE (modified);
FUNC_LEAVE (stab);
}

View File

@ -610,7 +610,7 @@ H5P_modify (H5F_t *f, H5G_entry_t *ent, const H5P_t *ds)
"scalar data spaces are not implemented yet");
case H5P_SIMPLE:
if (H5O_modify (f, ent, H5O_SDSPACE, 0, &(ds->u.simple))<0) {
if (H5O_modify (ent, H5O_SDSPACE, 0, 0, &(ds->u.simple))<0) {
HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
"can't update simple data space message");
}
@ -658,7 +658,7 @@ H5P_read (H5F_t *f, H5G_entry_t *ent)
ds = H5MM_xcalloc (1, sizeof(H5P_t));
if (H5O_read (f, ent, H5O_SDSPACE, 0, &(ds->u.simple))) {
if (H5O_read (ent, H5O_SDSPACE, 0, &(ds->u.simple))) {
ds->type = H5P_SIMPLE;
} else {

View File

@ -19,6 +19,7 @@
#ifndef _H5public_H
#define _H5public_H
#include <H5config.h> /* From configure */
#include <sys/types.h>
/*
* Data types

View File

@ -140,13 +140,9 @@ test_create (hid_t file)
*/
create_parms = H5Ccreate (H5C_DATASET_CREATE);
assert (create_parms>=0);
status = H5Cset_prop (create_parms, H5D_LAYOUT, H5D_CHUNKED);
assert (status>=0);
status = H5Cset_prop (create_parms, H5D_CHUNK_NDIMS, 2);
assert (status>=0);
csize[0] = 5;
csize[1] = 100;
status = H5Cset_prop (create_parms, H5D_CHUNK_SIZE, csize);
status = H5Cset_chunk (create_parms, 2, csize);
assert (status>=0);
dataset = H5Dcreate (file, DSET_CHUNKED_NAME, H5T_NATIVE_DOUBLE, space,
@ -270,6 +266,8 @@ test_simple_io (hid_t file)
}
}
H5Dclose (dataset);
puts (" PASSED");
return SUCCEED;

View File

@ -122,7 +122,7 @@ new_object (H5F_t *f, const char *name, size_t ndims, H5G_entry_t *ent/*out*/)
}
}
H5F_istore_create (f, &istore, ndims, alignment);
if (H5O_modify (f, ent, H5O_ISTORE, H5O_NEW_MESG, &istore)<0) {
if (H5O_modify (ent, H5O_ISTORE, H5O_NEW_MESG, 0, &istore)<0) {
printf ("*FAILED*\n");
if (!isatty (1)) {
AT();
@ -132,7 +132,7 @@ new_object (H5F_t *f, const char *name, size_t ndims, H5G_entry_t *ent/*out*/)
}
/* Give the object header a name */
if (H5G_insert (f, name, ent)<0) {
if (H5G_insert (name, ent)<0) {
printf ("*FAILED*\n");
if (!isatty (1)) {
AT ();
@ -142,7 +142,7 @@ new_object (H5F_t *f, const char *name, size_t ndims, H5G_entry_t *ent/*out*/)
}
/* Close the header */
H5O_close (f, ent);
H5O_close (ent);
return 0;
}
@ -250,7 +250,7 @@ test_extend (H5F_t *f, const char *prefix,
}
goto error;
}
if (NULL==H5O_read (f, &handle, H5O_ISTORE, 0, &istore)) {
if (NULL==H5O_read (&handle, H5O_ISTORE, 0, &istore)) {
puts ("*FAILED*");
if (!isatty (1)) {
AT ();
@ -458,7 +458,7 @@ test_sparse (H5F_t *f, const char *prefix, size_t nblocks,
}
goto error;
}
if (NULL==H5O_read (f, &handle, H5O_ISTORE, 0, &istore)) {
if (NULL==H5O_read (&handle, H5O_ISTORE, 0, &istore)) {
puts ("*FAILED*");
if (!isatty (1)) {
AT ();
@ -534,7 +534,6 @@ main (int argc, char *argv[])
herr_t status;
int nerrors = 0;
uintn size_of_test;
size_t offset_size;
hid_t template_id;
H5F_create_t *creation_template = NULL;
H5G_t *dir = NULL;
@ -568,9 +567,8 @@ main (int argc, char *argv[])
/*
* Use larger file addresses...
*/
offset_size = 8;
template_id = H5Ccreate (H5C_FILE_CREATE);
H5Cset_prop (template_id, H5F_SIZEOF_ADDR, offset_size);
H5Cset_sizes (template_id, 8, 0);
creation_template = H5Aatom_object (template_id);
/* Create the test file */

View File

@ -63,7 +63,7 @@ static void test_file_create(void)
hid_t tmpl1,tmpl2; /* File creation templates */
size_t parm; /* File-creation parameters */
size_t parm2; /* File-creation parameters */
int iparm;
int iparm, iparm2;
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@ -82,25 +82,19 @@ static void test_file_create(void)
CHECK(tmpl1,FAIL,"H5Fget_create_template");
/* Get the file-creation parameters */
ret = H5Cget_prop (tmpl1, H5F_SIZEOF_USERBLOCK, &parm);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(parm,F1_USERBLOCK_SIZE,"H5Cget_prop");
ret = H5Cget_userblock (tmpl1, &parm);
CHECK(ret,FAIL,"H5Cget_userblock");
VERIFY(parm,F1_USERBLOCK_SIZE,"H5Cget_userblock");
ret = H5Cget_prop (tmpl1, H5F_SIZEOF_ADDR, &parm2);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(parm2,F1_OFFSET_SIZE,"H5Cget_prop");
ret = H5Cget_sizes (tmpl1, &parm, &parm2);
CHECK(ret,FAIL,"H5Cget_sizes");
VERIFY (parm, F1_OFFSET_SIZE, "H5Cget_sizes");
VERIFY(parm2,F1_LENGTH_SIZE,"H5Cget_sizes");
ret = H5Cget_prop (tmpl1, H5F_SIZEOF_SIZE, &parm2);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(parm2,F1_LENGTH_SIZE,"H5Cget_prop");
ret = H5Cget_prop (tmpl1, H5F_SYM_LEAF_K, &iparm);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(iparm,F1_SYM_LEAF_K,"H5Cget_prop");
ret =H5Cget_prop (tmpl1, H5F_SYM_INTERN_K, &iparm);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(iparm,F1_SYM_INTERN_K,"H5Cget_prop");
ret = H5Cget_sym_k (tmpl1, &iparm, &iparm2);
CHECK(ret,FAIL,"H5Cget_sym_k");
VERIFY (iparm, F1_SYM_INTERN_K, "H5Cget_sym_k");
VERIFY(iparm2,F1_SYM_LEAF_K,"H5Cget_sym_k");
/* Release file-creation template */
ret=H5Mclose(tmpl1);
@ -115,25 +109,19 @@ static void test_file_create(void)
CHECK(tmpl1,FAIL,"H5Cnew");
/* Set the new file-creation parameters */
parm=F2_USERBLOCK_SIZE;
ret = H5Cset_prop (tmpl1, H5F_SIZEOF_USERBLOCK, parm);
CHECK(ret,FAIL,"H5Cset_prop");
ret = H5Cset_userblock (tmpl1, F2_USERBLOCK_SIZE);
CHECK(ret,FAIL,"H5Cset_userblock");
parm2=F2_OFFSET_SIZE;
ret = H5Cset_prop (tmpl1, H5F_SIZEOF_ADDR, parm2);
CHECK(ret,FAIL,"H5Cset_prop");
ret = H5Cset_sizes (tmpl1, F2_OFFSET_SIZE, F2_LENGTH_SIZE);
CHECK(ret,FAIL,"H5Cset_sizes");
parm2=F2_LENGTH_SIZE;
ret = H5Cset_prop (tmpl1, H5F_SIZEOF_SIZE, parm2);
CHECK(ret,FAIL,"H5Cset_prop");
ret = H5Cset_sym_k (tmpl1, F2_SYM_INTERN_K, F2_SYM_LEAF_K);
CHECK(ret,FAIL,"H5Cset_sym_k");
ret = H5Cset_prop (tmpl1, H5F_SYM_LEAF_K, F2_SYM_LEAF_K);
CHECK(ret,FAIL,"H5Cset_prop");
ret = H5Cset_prop (tmpl1, H5F_SYM_INTERN_K, F2_SYM_INTERN_K);
CHECK(ret,FAIL,"H5Cset_prop");
/* Try to create second file, with non-standard file-creation template params */
/*
* Try to create second file, with non-standard file-creation template
* params.
*/
fid2=H5Fcreate(FILE2,H5ACC_OVERWRITE,tmpl1,0);
CHECK(fid2,FAIL,"H5Fcreate");
@ -146,25 +134,19 @@ static void test_file_create(void)
CHECK(tmpl1,FAIL,"H5Fget_create_template");
/* Get the file-creation parameters */
ret = H5Cget_prop (tmpl1, H5F_SIZEOF_USERBLOCK, &parm);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cget_prop");
ret = H5Cget_userblock (tmpl1, &parm);
CHECK(ret,FAIL,"H5Cget_userblock");
VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cget_userblock");
ret = H5Cget_prop (tmpl1, H5F_SIZEOF_SIZE, &parm2);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(parm2,F2_LENGTH_SIZE,"H5Cget_prop");
ret = H5Cget_sizes (tmpl1, &parm, &parm2);
CHECK(ret,FAIL,"H5Cget_sizes");
VERIFY (parm, F2_OFFSET_SIZE, "H5Cget_sizes");
VERIFY(parm2,F2_LENGTH_SIZE,"H5Cget_sizes");
ret = H5Cget_prop (tmpl1, H5F_SIZEOF_ADDR, &parm2);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(parm2,F2_OFFSET_SIZE,"H5Cget_prop");
ret = H5Cget_prop (tmpl1, H5F_SYM_LEAF_K, &iparm);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(iparm,F2_SYM_LEAF_K,"H5Cget_prop");
ret = H5Cget_prop (tmpl1, H5F_SYM_INTERN_K, &iparm);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(iparm,F2_SYM_INTERN_K,"H5Cget_prop");
ret = H5Cget_sym_k (tmpl1, &iparm, &iparm2);
CHECK(ret,FAIL,"H5Cget_sym_k");
VERIFY (iparm, F2_SYM_INTERN_K, "H5Cget_sym_k");
VERIFY(iparm2,F2_SYM_LEAF_K,"H5Cget_sym_k");
/* Clone the file-creation template */
tmpl2=H5Mcopy(tmpl1);
@ -175,11 +157,13 @@ static void test_file_create(void)
CHECK(ret,FAIL,"H5Mrelease");
/* Set the new file-creation parameter */
parm=F3_USERBLOCK_SIZE;
ret = H5Cset_prop (tmpl2, H5F_SIZEOF_USERBLOCK, parm);
CHECK(ret,FAIL,"H5Cset_prop");
ret = H5Cset_userblock (tmpl2, F3_USERBLOCK_SIZE);
CHECK(ret,FAIL,"H5Cset_userblock");
/* Try to create second file, with non-standard file-creation template params */
/*
* Try to create second file, with non-standard file-creation template
* params
*/
fid3=H5Fcreate(FILE3,H5ACC_OVERWRITE,tmpl2,0);
CHECK(fid3,FAIL,"H5Fcreate");
@ -192,25 +176,19 @@ static void test_file_create(void)
CHECK(tmpl1,FAIL,"H5Fget_create_template");
/* Get the file-creation parameters */
ret = H5Cget_prop (tmpl1, H5F_SIZEOF_USERBLOCK, &parm);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(parm,F3_USERBLOCK_SIZE,"H5Cget_prop");
ret = H5Cget_userblock (tmpl1, &parm);
CHECK(ret,FAIL,"H5Cget_userblock");
VERIFY(parm,F3_USERBLOCK_SIZE,"H5Cget_userblock");
ret = H5Cget_prop (tmpl1, H5F_SIZEOF_ADDR, &parm2);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(parm2,F3_LENGTH_SIZE,"H5Cget_prop");
ret = H5Cget_sizes (tmpl1, &parm, &parm2);
CHECK(ret,FAIL,"H5Cget_sizes");
VERIFY (parm, F3_OFFSET_SIZE, "H5Cget_sizes");
VERIFY(parm2,F3_LENGTH_SIZE,"H5Cget_sizes");
ret = H5Cget_prop (tmpl1, H5F_SIZEOF_SIZE, &parm2);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(parm2,F3_OFFSET_SIZE,"H5Cget_prop");
ret = H5Cget_prop (tmpl1, H5F_SYM_LEAF_K, &iparm);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(iparm,F3_SYM_LEAF_K,"H5Cget_prop");
ret = H5Cget_prop (tmpl1, H5F_SYM_INTERN_K, &iparm);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(iparm,F3_SYM_INTERN_K,"H5Cget_prop");
ret = H5Cget_sym_k (tmpl1, &iparm, &iparm2);
CHECK(ret,FAIL,"H5Cget_sym_k");
VERIFY (iparm, F3_SYM_INTERN_K, "H5Cget_sym_k");
VERIFY(iparm2,F3_SYM_LEAF_K,"H5Cget_sym_k");
/* Release file-creation template */
ret=H5Mclose(tmpl1);
@ -241,7 +219,7 @@ static void test_file_open(void)
hid_t tmpl1; /* File creation templates */
size_t parm; /* File-creation parameters */
size_t parm2; /* File-creation parameters */
int iparm;
int iparm, iparm2;
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@ -256,25 +234,19 @@ static void test_file_open(void)
CHECK(tmpl1,FAIL,"H5Fget_create_template");
/* Get the file-creation parameters */
ret = H5Cget_prop (tmpl1, H5F_SIZEOF_USERBLOCK, &parm);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cget_prop");
ret = H5Cget_userblock (tmpl1, &parm);
CHECK(ret,FAIL,"H5Cget_userblock");
VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cget_userblock");
ret = H5Cget_prop (tmpl1, H5F_SIZEOF_ADDR, &parm2);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(parm2,F2_OFFSET_SIZE,"H5Cget_prop");
ret = H5Cget_sizes (tmpl1, &parm, &parm2);
CHECK(ret,FAIL,"H5Cget_sizes");
VERIFY(parm,F2_OFFSET_SIZE,"H5Cget_sizes");
VERIFY(parm2,F2_LENGTH_SIZE,"H5Cget_sizes");
ret = H5Cget_prop (tmpl1, H5F_SIZEOF_SIZE, &parm2);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(parm2,F2_LENGTH_SIZE,"H5Cget_prop");
ret = H5Cget_prop (tmpl1, H5F_SYM_LEAF_K, &iparm);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(iparm,F2_SYM_LEAF_K,"H5Cget_prop");
ret = H5Cget_prop (tmpl1, H5F_SYM_INTERN_K, &iparm);
CHECK(ret,FAIL,"H5Cget_prop");
VERIFY(iparm,F2_SYM_INTERN_K,"H5Cget_prop");
ret = H5Cget_sym_k (tmpl1, &iparm, &iparm2);
CHECK(ret,FAIL,"H5Cget_sym_k");
VERIFY (iparm, F2_SYM_INTERN_K, "H5Cget_sym_k");
VERIFY(iparm2,F2_SYM_LEAF_K,"H5Cget_sym_k");
/* Release file-creation template */
ret=H5Mclose(tmpl1);

View File

@ -74,11 +74,11 @@ test_ohdr (void)
MESSAGE (8, ("Creating new message...\n"));
stab.btree_addr.offset = 11111111;
stab.heap_addr.offset = 22222222;
status = H5O_modify (f, &oh_ent, H5O_STAB, H5O_NEW_MESG, &stab);
status = H5O_modify (&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab);
VERIFY (status, 0, "H5O_modify");
H5AC_flush (f, NULL, 0, TRUE);
ptr = H5O_read (f, &oh_ent, H5O_STAB, 0, &ro);
ptr = H5O_read (&oh_ent, H5O_STAB, 0, &ro);
CHECK_PTR (ptr, "H5O_read");
VERIFY (ptr, &ro, "H5O_read");
VERIFY (ro.btree_addr.offset, stab.btree_addr.offset, "H5O_read");
@ -90,11 +90,11 @@ test_ohdr (void)
MESSAGE (8, ("Modifying message...\n"));
stab.btree_addr.offset = 33333333;
stab.heap_addr.offset = 44444444;
status = H5O_modify (f, &oh_ent, H5O_STAB, 0, &stab);
status = H5O_modify (&oh_ent, H5O_STAB, 0, 0, &stab);
VERIFY (status, 0, "H5O_modify");
H5AC_flush (f, NULL, 0, TRUE);
ptr = H5O_read (f, &oh_ent, H5O_STAB, 0, &ro);
ptr = H5O_read (&oh_ent, H5O_STAB, 0, &ro);
CHECK_PTR (ptr, "H5O_read");
VERIFY (ptr, &ro, "H5O_read");
VERIFY (ro.btree_addr.offset, stab.btree_addr.offset, "H5O_read");
@ -107,17 +107,11 @@ test_ohdr (void)
MESSAGE (8, ("Creating a duplicate message...\n"));
stab.btree_addr.offset = 55555555;
stab.heap_addr.offset = 66666666;
status = H5O_modify (f, &oh_ent, H5O_STAB, H5O_NEW_MESG, &stab);
status = H5O_modify (&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab);
VERIFY (status, 1, "H5O_modify");
VERIFY (oh_ent.dirty, TRUE, "H5O_modify");
VERIFY (oh_ent.type, H5G_CACHED_STAB, "H5O_modify");
VERIFY (oh_ent.cache.stab.heap_addr.offset, stab.heap_addr.offset,
"H5O_modify");
VERIFY (oh_ent.cache.stab.btree_addr.offset, stab.btree_addr.offset,
"H5O_modify");
H5AC_flush (f, NULL, 0, TRUE);
ptr = H5O_read (f, &oh_ent, H5O_STAB, 1, &ro);
ptr = H5O_read (&oh_ent, H5O_STAB, 1, &ro);
CHECK_PTR (ptr, "H5O_read");
VERIFY (ptr, &ro, "H5O_read");
VERIFY (ro.btree_addr.offset, stab.btree_addr.offset, "H5O_read");
@ -129,17 +123,11 @@ test_ohdr (void)
MESSAGE (8, ("Modifying the duplicate message...\n"));
stab.btree_addr.offset = 77777777;
stab.heap_addr.offset = 88888888;
status = H5O_modify (f, &oh_ent, H5O_STAB, 1, &stab);
status = H5O_modify (&oh_ent, H5O_STAB, 1, 0, &stab);
VERIFY (status, 1, "H5O_modify");
VERIFY (oh_ent.dirty, TRUE, "H5O_modify");
VERIFY (oh_ent.type, H5G_CACHED_STAB, "H5O_modify");
VERIFY (oh_ent.cache.stab.heap_addr.offset, stab.heap_addr.offset,
"H5O_modify");
VERIFY (oh_ent.cache.stab.btree_addr.offset, stab.btree_addr.offset,
"H5O_modify");
H5AC_flush (f, NULL, 0, TRUE);
ptr = H5O_read (f, &oh_ent, H5O_STAB, 1, &ro);
ptr = H5O_read (&oh_ent, H5O_STAB, 1, &ro);
CHECK_PTR (ptr, "H5O_read");
VERIFY (ptr, &ro, "H5O_read");
VERIFY (ro.btree_addr.offset, stab.btree_addr.offset, "H5O_read");
@ -153,7 +141,7 @@ test_ohdr (void)
for (i=0; i<40; i++) {
stab.btree_addr.offset = (i+1)*1000 + 1;
stab.heap_addr.offset = (i+1)*1000 + 2;
status = H5O_modify (f, &oh_ent, H5O_STAB, H5O_NEW_MESG, &stab);
status = H5O_modify (&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab);
VERIFY (status, 2+i, "H5O_modify");
}
H5AC_flush (f, NULL, 0, TRUE);
@ -166,7 +154,7 @@ test_ohdr (void)
for (i=0; i<10; i++) {
stab.btree_addr.offset = (i+1)*1000 + 10;
stab.heap_addr.offset = (i+1)*1000 + 20;
status = H5O_modify (f, &oh_ent, H5O_STAB, H5O_NEW_MESG, &stab);
status = H5O_modify (&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab);
VERIFY (status, 42+i, "H5O_modify");
H5AC_flush (f, NULL, 0, TRUE);
}
@ -174,9 +162,10 @@ test_ohdr (void)
/*
* Delete all symbol table messages.
*/
status = H5O_remove (f, &oh_ent, H5O_STAB, H5O_ALL);
status = H5O_remove (&oh_ent, H5O_STAB, H5O_ALL);
CHECK_I (status, "H5O_remove");
/* close the file */
/* release resources */
H5O_close (&oh_ent);
H5Fclose (fid);
}

View File

@ -75,11 +75,13 @@ test_1 (void)
/* create the object */
status = H5O_create (f, 0, &ent1);
CHECK_I (status, "H5O_create");
status = H5G_insert (f, "/", &ent1);
status = H5G_insert ("/", &ent1);
CHECK_I (status, "H5G_insert");
status = H5O_close (&ent1);
CHECK_I (status, "H5O_close");
/* look for a name message -- it shouldn't be present */
status_ptr = H5O_read (f, &ent1, H5O_NAME, 0, &name_mesg);
status_ptr = H5O_read (&ent1, H5O_NAME, 0, &name_mesg);
VERIFY (status_ptr, NULL, "H5O_read [didn't fail but should have]");
/*
@ -105,8 +107,10 @@ test_1 (void)
/* create the object */
status = H5O_create (f, 0, &ent2);
CHECK_I (status, "H5O_create");
status = H5G_insert (f, "/second", &ent2);
status = H5G_insert ("/second", &ent2);
CHECK_I (status, "H5G_insert");
status = H5O_close (&ent2);
CHECK_I (status, "H5O_close");
/* try to read the first object */
HDmemset (&obj_ent, 0xff, sizeof(H5G_entry_t));
@ -137,11 +141,13 @@ test_1 (void)
/* create the object */
status = H5O_create (f, 0, &ent1);
CHECK_I (status, "H5O_create");
status = H5G_insert (f, "/foo", &ent1);
status = H5G_insert ("/foo", &ent1);
CHECK_I (status, "H5G_insert");
status = H5O_close (&ent1);
CHECK_I (status, "H5O_close");
/* does it have the correct name message? */
status_ptr = H5O_read (f, &ent1, H5O_NAME, 0, &name_mesg);
status_ptr = H5O_read (&ent1, H5O_NAME, 0, &name_mesg);
CHECK_PTR (status_ptr, "H5O_read");
CHECK_PTR (name_mesg.s, "H5O_read");
VERIFY (strcmp(name_mesg.s, "foo"), 0, "H5G_insert");
@ -179,8 +185,10 @@ test_1 (void)
/* create the object */
status = H5O_create (f, 0, &ent2);
CHECK_I (status, "H5O_create");
status = H5G_insert (f, "/second", &ent2);
status = H5G_insert ("/second", &ent2);
CHECK_I (status, "H5G_insert");
status = H5O_close (&ent2);
CHECK_I (status, "H5O_close");
/* try to read the first object */
HDmemset (&obj_ent, 0, sizeof(H5G_entry_t));
@ -190,7 +198,7 @@ test_1 (void)
VERIFY (b, TRUE, "H5G_insert");
/* the first object should not have a name message */
status_ptr = H5O_read (f, &ent1, H5O_NAME, 0, &name_mesg);
status_ptr = H5O_read (&ent1, H5O_NAME, 0, &name_mesg);
VERIFY (status_ptr, NULL, "H5O_read [didn't fail but should have]");
/* close the file */
@ -217,13 +225,12 @@ test_1 (void)
static void
test_2 (void)
{
hid_t fid, props;
hid_t fid, props, dir;
H5F_t *f;
int i;
char name[256];
herr_t status;
int nsyms = 5000;
H5G_t *dir = NULL;
MESSAGE (2, ("........large directories\n"));
@ -233,8 +240,7 @@ test_2 (void)
*/
props = H5Ccreate (H5C_FILE_CREATE);
#if 1
H5Cset_prop (props, H5F_SYM_LEAF_K, 16);
H5Cset_prop (props, H5F_SYM_INTERN_K, 16);
H5Cset_sym_k (props, 16, 16);
#endif
/* create the file */
@ -248,20 +254,23 @@ test_2 (void)
* Create a directory that has so many entries that the root
* of the B-tree ends up splitting.
*/
dir = H5G_create (f, "/big", nsyms*12+2);
CHECK_PTR (dir, "H5G_mkdir");
status = H5G_close (dir);
CHECK_I (status, "H5G_close");
dir = H5Gcreate (fid, "/big", nsyms*16+2);
CHECK_I (dir, "H5Gcreate");
status = H5Gclose (dir);
CHECK_I (status, "H5Gclose");
status = H5Gset (fid, "/big");
CHECK_I (status, "H5Gset");
for (i=0; i<nsyms; i++) {
sprintf (name, "/big/%05d%05d", rand()%100000, i);
sprintf (name, "%05d%05d", rand()%100000, i);
MESSAGE (8, ("%s\n", name));
dir = H5G_create (f, name, 0);
CHECK_PTR (dir, "H5G_create");
H5G_close (dir);
dir = H5Gcreate (fid, name, 0);
CHECK_I (dir, "H5Gcreate");
status = H5Gclose (dir);
CHECK_I (status, "H5Gclose");
}
/* close the file */
status = H5Fclose (fid);
CHECK_I (status, "H5Fclose");