diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-01-07 17:14:26 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-01-07 17:14:26 (GMT) |
commit | 159fa7a232e1961940b83f035f4c27338d26337e (patch) | |
tree | b7344e9cfaadbbec3bc3a0576df8c264debb8239 | |
parent | 1d17defdfc977c063c7ff20b5868bef9a76e5d9a (diff) | |
download | hdf5-159fa7a232e1961940b83f035f4c27338d26337e.zip hdf5-159fa7a232e1961940b83f035f4c27338d26337e.tar.gz hdf5-159fa7a232e1961940b83f035f4c27338d26337e.tar.bz2 |
[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.
-rw-r--r-- | config/freebsd2.2.1 | 2 | ||||
-rw-r--r-- | config/linux | 2 | ||||
-rw-r--r-- | src/H5C.c | 929 | ||||
-rw-r--r-- | src/H5Cpublic.h | 59 | ||||
-rw-r--r-- | src/H5D.c | 53 | ||||
-rw-r--r-- | src/H5Dpublic.h | 2 | ||||
-rw-r--r-- | src/H5F.c | 22 | ||||
-rw-r--r-- | src/H5Flow.c | 27 | ||||
-rw-r--r-- | src/H5Fprivate.h | 4 | ||||
-rw-r--r-- | src/H5G.c | 118 | ||||
-rw-r--r-- | src/H5Gent.c | 103 | ||||
-rw-r--r-- | src/H5Gpkg.h | 9 | ||||
-rw-r--r-- | src/H5Gprivate.h | 28 | ||||
-rw-r--r-- | src/H5Gpublic.h | 4 | ||||
-rw-r--r-- | src/H5Gstab.c | 44 | ||||
-rw-r--r-- | src/H5O.c | 351 | ||||
-rw-r--r-- | src/H5Ocont.c | 3 | ||||
-rw-r--r-- | src/H5Ocstore.c | 3 | ||||
-rw-r--r-- | src/H5Odtype.c | 3 | ||||
-rw-r--r-- | src/H5Oefl.c | 3 | ||||
-rw-r--r-- | src/H5Oistore.c | 3 | ||||
-rw-r--r-- | src/H5Oname.c | 3 | ||||
-rw-r--r-- | src/H5Onull.c | 3 | ||||
-rw-r--r-- | src/H5Oprivate.h | 27 | ||||
-rw-r--r-- | src/H5Osdspace.c | 118 | ||||
-rw-r--r-- | src/H5Ostab.c | 76 | ||||
-rw-r--r-- | src/H5P.c | 4 | ||||
-rw-r--r-- | src/H5public.h | 1 | ||||
-rw-r--r-- | test/dsets.c | 8 | ||||
-rw-r--r-- | test/istore.c | 14 | ||||
-rw-r--r-- | test/tfile.c | 156 | ||||
-rw-r--r-- | test/tohdr.c | 37 | ||||
-rw-r--r-- | test/tstab.c | 49 |
33 files changed, 1084 insertions, 1184 deletions
diff --git a/config/freebsd2.2.1 b/config/freebsd2.2.1 index f3bd304..b4bbae6 100644 --- a/config/freebsd2.2.1 +++ b/config/freebsd2.2.1 @@ -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" diff --git a/config/linux b/config/linux index f3bd304..b4bbae6 100644 --- a/config/linux +++ b/config/linux @@ -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" @@ -242,7 +242,6 @@ H5Cclose (hid_t template) FUNC_LEAVE (SUCCEED); } - /*------------------------------------------------------------------------- * Function: H5Cget_class @@ -282,473 +281,595 @@ H5Cget_class (hid_t template) /*------------------------------------------------------------------------- - * Function: H5Cget_prop - * - * Purpose: Retrieves a property value from a template. The value is - * returned through an argument, BUF, of the appropriate pointer - * type. - * - * Properties of H5C_FILE_CREATE templates and the type for the - * return argument(s): - * - * H5F_USERBLOCK_SIZE (size_t*) - * Size of the initial part of the file that is not used - * by HDF5 and may contain user-defined data. - * - * H5F_SIZEOF_ADDR (size_t*) - * Size in bytes of addresses stored in the file. This - * is similar in nature to the `off_t' type in memory. - * - * H5F_SIZEOF_SIZE (size_t*) - * Size in bytes of fields that contains object sizes in - * the file. This is similar in nature to the `size_t' - * type in memory. - * - * H5F_SYM_LEAF_K (int*) - * One half of the number of symbols that can be stored - * in a symbol table node. A symbol table node is the - * leaf of a symbol table tree which is used to store a - * group. When symbols are insterted randomly into a - * group, the group's symbol table nodes are 75% full on - * average. That is, they contain 1.5 times the number - * of symbols specified by this property. - * - * H5F_SYM_INTERN_K (int*) - * One half the rank of a tree that stores a symbol - * table. Internal nodes of the symbol table are on - * average 75% full. That is, the average rank of the - * tree is 1.5 times the value specified for this - * property. - * - * H5F_ISTORE_K (int*) - * One half the rank of a tree that stores chunked raw - * data. On average, such a tree will be 75% full, or - * have an average rank of 1.5 times the value specified - * for this property. - * - * H5F_BOOTBLOCK_VER (int*) - * The version number of the file boot block. This is a - * read-only property. - * - * H5F_SMALLOBJECT_VER (int*) - * The version number of the global heap. This is a - * read-only property. - * - * H5F_FREESPACE_VER (int*) - * The version number of the free list. This is a - * read-only property. - * - * H5F_OBJECTDIR_VER (int*) - * The version number of the root symbol table entry. - * This is a read-only property. - * - * H5F_SHAREDHEADER_VER (int*) - * The version number for shared object header messages. - * This is a read-only property. - * - * Properties of H5C_FILE_ACCESS templates and the type for the - * return argument(s): - * - * ** None defined yet ** - * - * Properties of H5C_DATASET_CREATE templates and the type for - * the return argument(s): - * - * H5D_LAYOUT (H5D_layout_t*) - * The layout of raw data on disk. - * - * H5D_CHUNK_NDIMS (int*) - * The number of dimensions per chunk. This is actually - * one less than the real number of dimensions since the - * real chunk dimensions also include the data type - * itself. The number of dimensions returned here - * should be the same as the number of dimensions - * returned by H5Pget_ndims(). - * - * H5D_CHUNK_SIZE (size_t[]) - * An array that specifies the chunk size in each - * dimension. The actual dimension list omits the final - * dimension corresponding to the data type and returns - * only the dimensions corresponding to the data space. - * The array should be large enough to hold at least the - * number of dimension sizes returned by the - * H5D_CHUNK_NDIMS property. - * - * H5D_COMPRESS (H5D_compress_t*) - * The raw data compression algorithm. - * - * H5D_PRE_OFFSET (double*) - * The value which is added to each data point before - * compression or subtracted from each data point after - * uncompression. - * - * H5D_PRE_SCALE (double*) - * The value by which each data point is multiplied - * before compression or divided after uncompression. - * - * Properties of H5C_DATASET_XFER templates and the type for - * the return argument(s): - * - * ** None defined yet ** + * Function: H5Cget_version * - * Return: Success: SUCCEED + * Purpose: Retrieves version information for various parts of a file. + * + * BOOT: The file boot block. + * HEAP: The global heap. + * FREELIST: The global free list. + * STAB: The root symbol table entry. + * SHHDR: Shared object headers. + * + * Any (or even all) of the output arguments can be null + * pointers. + * + * Return: Success: SUCCEED, version information is returned + * through the arguments. * * Failure: FAIL * - * Errors: - * ARGS BADRANGE Unknown property for dataset create - * template. - * ARGS BADRANGE Unknown property for dataset transfer - * template. - * ARGS BADRANGE Unknown property for file access - * template. - * ARGS BADRANGE Unknown property for file create - * template. - * ARGS BADRANGE Unknown template class. - * ARGS BADTYPE Not a template. - * INTERNAL UNSUPPORTED Not implemented yet. - * TEMPLATE UNINITIALIZED Chunk dimensionality is not initialized - * TEMPLATE UNINITIALIZED Chunk size is not initialized. + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cget_version (hid_t template, int *boot/*out*/, int *heap/*out*/, + int *freelist/*out*/, int *stab/*out*/, int *shhdr/*out*/) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER (H5Cget_version, FAIL); + + /* Check arguments */ + if (H5C_FILE_CREATE!=H5Cget_class (template) || + NULL==(tmpl=H5Aatom_object (template))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + + /* Get values */ + if (boot) *boot = tmpl->bootblock_ver; + if (heap) *heap = tmpl->smallobject_ver; + if (freelist) *freelist = tmpl->freespace_ver; + if (stab) *stab = tmpl->objectdir_ver; + if (shhdr) *shhdr = tmpl->sharedheader_ver; + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Cset_userblock + * + * Purpose: Sets the userblock size field of a file creation template. + * + * Return: Success: SUCCEED + * + * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, December 11, 1997 + * Tuesday, January 6, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t -H5Cget_prop (hid_t template, H5C_prop_t prop, void *buf/*out*/) +H5Cset_userblock (hid_t template, size_t size) { - const void *tmpl = NULL; - const H5F_create_t *file_create = NULL; - const H5D_create_t *dset_create = NULL; - H5C_class_t type; - intn i; + intn i; + H5F_create_t *tmpl = NULL; - FUNC_ENTER (H5Cget_prop, FAIL); - H5ECLEAR; + FUNC_ENTER (H5Cset_userblock, FAIL); + + /* Check arguments */ + if (H5C_FILE_CREATE!=H5Cget_class (template) || + NULL==(tmpl=H5Aatom_object (template))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + for (i=8; i<8*sizeof(int); i++) { + uintn p2 = 8==i ? 0 :1<<i; + if (size==p2) break; + } + if (i>=8*sizeof(int)) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "userblock size is not valid"); + } + + /* Set value */ + tmpl->userblock_size = size; + + FUNC_LEAVE (SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Cget_userblock + * + * Purpose: Queries the size of a user block in a file creation template. + * + * Return: Success: SUCCEED, size returned through SIZE argument. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cget_userblock (hid_t template, size_t *size) +{ + H5F_create_t *tmpl = NULL; - /* check args */ - if ((type=H5Cget_class (template))<0 || + FUNC_ENTER (H5Cget_userblock, FAIL); + + /* Check args */ + if (H5C_FILE_CREATE!=H5Cget_class (template) || NULL==(tmpl=H5Aatom_object (template))) { - HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a template"); + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); } - /* Handle each class of template */ - switch (type) { - case H5C_FILE_CREATE: - file_create = (const H5F_create_t *)tmpl; - - switch (prop) { - case H5F_SIZEOF_USERBLOCK: - *(size_t *)buf = file_create->userblock_size; - break; + /* Get value */ + if (size) *size = tmpl->userblock_size; - case H5F_SIZEOF_ADDR: - *(size_t *)buf = file_create->sizeof_addr; - break; + FUNC_LEAVE (SUCCEED); +} - case H5F_SIZEOF_SIZE: - *(size_t *)buf = file_create->sizeof_size; - break; + +/*------------------------------------------------------------------------- + * Function: H5Cset_sizes + * + * Purpose: Sets file size-of addresses and sizes. TEMPLATE + * should be a file creation template. A value of zero causes + * the property to not change. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cset_sizes (hid_t template, size_t sizeof_addr, size_t sizeof_size) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER (H5Cset_sizeof_addr, FAIL); + + /* Check arguments */ + if (H5C_FILE_CREATE!=H5Cget_class (template) || + NULL==(tmpl=H5Aatom_object (template))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + if (sizeof_addr) { + if (sizeof_addr!=2 && sizeof_addr!=4 && + sizeof_addr!=8 && sizeof_addr!=16) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "file haddr_t size is not valid"); + } + } + if (sizeof_size) { + if (sizeof_size!=2 && sizeof_size!=4 && + sizeof_size!=8 && sizeof_size!=16) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "file size_t size is not valid"); + } + } - case H5F_SYM_LEAF_K: - *(int *)buf=file_create->sym_leaf_k; - break; + /* Set value */ + if (sizeof_addr) tmpl->sizeof_addr = sizeof_addr; + if (sizeof_size) tmpl->sizeof_size = sizeof_size; - case H5F_SYM_INTERN_K: - *(int *)buf = file_create->btree_k[H5B_SNODE_ID]; - break; + FUNC_LEAVE (SUCCEED); +} - case H5F_ISTORE_K: - *(int *)buf = file_create->btree_k[H5B_ISTORE_ID]; - break; + +/*------------------------------------------------------------------------- + * Function: H5Cget_sizes + * + * Purpose: Returns the size of address and size quantities stored in a + * file according to a file creation template. Either (or even + * both) SIZEOF_ADDR and SIZEOF_SIZE may be null pointers. + * + * Return: Success: SUCCEED, sizes returned through arguments. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cget_sizes (hid_t template, + size_t *sizeof_addr/*out*/, size_t *sizeof_size/*out*/) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER (H5Cget_sizes, FAIL); + + /* Check args */ + if (H5C_FILE_CREATE!=H5Cget_class (template) || + NULL==(tmpl=H5Aatom_object (template))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } - case H5F_BOOTBLOCK_VER: - *(int *)buf=file_create->bootblock_ver; - break; + /* Get values */ + if (sizeof_addr) *sizeof_addr = tmpl->sizeof_addr; + if (sizeof_size) *sizeof_size = tmpl->sizeof_size; - case H5F_SMALLOBJECT_VER: - *(int *)buf=file_create->smallobject_ver; - break; + FUNC_LEAVE (SUCCEED); +} - case H5F_FREESPACE_VER: - *(int *)buf=file_create->freespace_ver; - break; + +/*------------------------------------------------------------------------- + * Function: H5Cset_sym_k + * + * Purpose: IK is one half the rank of a tree that stores a symbol + * table for a group. Internal nodes of the symbol table are on + * average 75% full. That is, the average rank of the tree is + * 1.5 times the value of IK. + * + * LK is one half of the number of symbols that can be stored in + * a symbol table node. A symbol table node is the leaf of a + * symbol table tree which is used to store a group. When + * symbols are inserted randomly into a group, the group's + * symbol table nodes are 75% full on average. That is, they + * contain 1.5 times the number of symbols specified by LK. + * + * Either (or even both) of IK and LK can be zero in which case + * that value is left unchanged. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cset_sym_k (hid_t template, int ik, int lk) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER (H5Cset_sym_k, FAIL); + + /* Check arguments */ + if (H5C_FILE_CREATE!=H5Cget_class (template) || + NULL==(tmpl=H5Aatom_object (template))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } - case H5F_OBJECTDIR_VER: - *(int *)buf=file_create->objectdir_ver; - break; + /* Set values */ + if (ik>0) { + tmpl->btree_k[H5B_SNODE_ID] = ik; + } + if (lk>0) { + tmpl->sym_leaf_k = lk; + } + - case H5F_SHAREDHEADER_VER: - *(int *)buf=file_create->sharedheader_ver; - break; + FUNC_LEAVE (SUCCEED); +} - default: - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "unknown property for file create template"); - } - break; + +/*------------------------------------------------------------------------- + * Function: H5Cget_sym_k + * + * Purpose: Retrieves the symbol table B-tree 1/2 rank (IK) and the + * symbol table leaf node 1/2 size (LK). See H5Cset_sym_k() for + * details. Either (or even both) IK and LK may be null + * pointers. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cget_sym_k (hid_t template, int *ik/*out*/, int *lk/*out*/) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER (H5Cget_sym_k, FAIL); + + /* Check arguments */ + if (H5C_FILE_CREATE!=H5Cget_class (template) || + NULL==(tmpl=H5Aatom_object (template))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } - case H5C_FILE_ACCESS: - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "unknown property for file access template"); - - case H5C_DATASET_CREATE: - dset_create = (const H5D_create_t *)tmpl; - switch (prop) { - case H5D_LAYOUT: - *(H5D_layout_t*)buf = dset_create->layout; - break; - - case H5D_CHUNK_NDIMS: - if (H5D_CHUNKED==dset_create->layout) { - *(int*)buf = dset_create->chunk_ndims; - } else { - HRETURN_ERROR (H5E_TEMPLATE, H5E_UNINITIALIZED, FAIL, - "chunk dimensionality is not initialized"); - } - break; - - case H5D_CHUNK_SIZE: - if (H5D_CHUNKED==dset_create->layout) { - for (i=0; i<dset_create->chunk_ndims; i++) { - ((size_t*)buf)[i] = dset_create->chunk_size[i]; - } - } else { - HRETURN_ERROR (H5E_TEMPLATE, H5E_UNINITIALIZED, FAIL, - "chunk size is not initialized"); - } - break; - - case H5D_COMPRESS: - case H5D_PRE_OFFSET: - case H5D_PRE_SCALE: - HRETURN_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, - "not implemented yet"); - - default: - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "unknown property for dataset create template"); - } - break; - - case H5C_DATASET_XFER: - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "unknown property for dataset transfer template"); + /* Get values */ + if (ik) *ik = tmpl->btree_k[H5B_SNODE_ID]; + if (lk) *lk = tmpl->sym_leaf_k; - default: - HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "unknown template class"); + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Cset_istore_k + * + * Purpose: IK is one half the rank of a tree that stores chunked raw + * data. On average, such a tree will be 75% full, or have an + * average rank of 1.5 times the value of IK. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cset_istore_k (hid_t template, int ik) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER (H5Cset_istore_k, FAIL); + + /* Check arguments */ + if (H5C_FILE_CREATE!=H5Cget_class (template) || + NULL==(tmpl=H5Aatom_object (template))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + if (ik<=0) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "istore IK value must be positive"); } + + /* Set value */ + tmpl->btree_k[H5B_ISTORE_ID] = ik; + FUNC_LEAVE (SUCCEED); } /*------------------------------------------------------------------------- - * Function: H5Cset_prop + * Function: H5Cget_istore_k + * + * Purpose: Queries the 1/2 rank of an indexed storage B-tree. See + * H5Cset_istore_k() for details. The argument IK may be the + * null pointer. + * + * Return: Success: SUCCEED, size returned through IK + * + * Failure: * - * Purpose: Sets a property, PROP, to a specified value in a TEMPLATE. - * The value data type depends on the property being set and is - * documented in H5Cget_prop(). The data type does not include - * the pointer (that is, property values are passed by value, - * not reference). + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cget_istore_k (hid_t template, int *ik/*out*/) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER (H5Cget_istore_k, FAIL); + + /* Check arguments */ + if (H5C_FILE_CREATE!=H5Cget_class (template) || + NULL==(tmpl=H5Aatom_object (template))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + + /* Get value */ + if (ik) *ik = tmpl->btree_k[H5B_ISTORE_ID]; + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Cset_layout * - * Note: Not all properties that can be queried with H5Cget_prop() can - * be set to a value with H5Cset_prop(). Such properties are - * documented as read-only in H5Cget_prop(). + * Purpose: Sets the layout of raw data in the file. * * Return: Success: SUCCEED * * Failure: FAIL * * Programmer: Robb Matzke - * Thursday, December 11, 1997 + * Tuesday, January 6, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t -H5Cset_prop (hid_t template, H5C_prop_t prop, ...) +H5Cset_layout (hid_t template, H5D_layout_t layout) { - void *tmpl = NULL; - H5F_create_t *file_create = NULL; - H5D_create_t *dset_create = NULL; - H5C_class_t type; - H5D_layout_t layout; - size_t size, *dims = NULL; - intn i, n; - va_list ap; - herr_t ret_value = FAIL; - - FUNC_ENTER (H5Cset_prop, FAIL); - H5ECLEAR; + H5D_create_t *tmpl = NULL; + + FUNC_ENTER (H5Cset_layout, FAIL); + + /* Check arguments */ + if (H5C_DATASET_CREATE!=H5Cget_class (template) || + NULL==(tmpl=H5Aatom_object (template))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation template"); + } + if (layout<0 || layout>=H5D_NLAYOUTS) { + HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, + "raw data layout method is not valid"); + } + + /* Set value */ + tmpl->layout = layout; - va_start (ap, prop); + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Cget_layout + * + * Purpose: Retrieves layout type of a dataset creation template. + * + * Return: Success: The layout type + * + * Failure: H5D_LAYOUT_ERROR (-1, same as FAIL) + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +H5D_layout_t +H5Cget_layout (hid_t template) +{ + H5D_create_t *tmpl = NULL; - if ((type=H5Cget_class (template))<0 || + FUNC_ENTER (H5Cget_layout, H5D_LAYOUT_ERROR); + + /* Check arguments */ + if (H5C_DATASET_CREATE!=H5Cget_class (template) || NULL==(tmpl=H5Aatom_object (template))) { - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a template"); + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, H5D_LAYOUT_ERROR, + "not a dataset creation template"); } - /* Handle each class of template */ - switch (type) { - case H5C_FILE_CREATE: - file_create = (H5F_create_t *)tmpl; - - switch (prop) { - case H5F_SIZEOF_USERBLOCK: - size = va_arg (ap, size_t); - for (i=8; i<8*sizeof(int); i++) { - uintn p2 = 8==i ? 0 :1<<i; - if (size==p2) break; - } - if (i>=8*sizeof(int)) { - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, - "userblock size is not valid"); - } - file_create->userblock_size = size; - break; - - case H5F_SIZEOF_ADDR: - size = va_arg (ap, size_t); - if (size!=2 && size!=4 && size!=8 && size!=16) { - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, - "file haddr_t size is not valid"); - } - file_create->sizeof_addr = size; - break; - - case H5F_SIZEOF_SIZE: - size = va_arg (ap, size_t); - if (size!=2 && size!=4 && size!=8 && size!=16) { - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, - "file size_t size is not valid"); - } - file_create->sizeof_size = size; - break; - - case H5F_SYM_LEAF_K: - n = va_arg (ap, int); - if (n<2) { - HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "symbol leaf node 1/2 rank is not valid"); - } - file_create->sym_leaf_k = n; - break; - - case H5F_SYM_INTERN_K: - n = va_arg (ap, int); - if (n<2) { - HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "symbol internal node 1/2 rank is not valid"); - } - file_create->btree_k[H5B_SNODE_ID] = n; - break; - - case H5F_ISTORE_K: - n = va_arg (ap, int); - if (n<2) { - HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "indexed storage internal node 1/2 rank not valid"); - } - file_create->btree_k[H5B_ISTORE_ID] = n; - break; - - case H5F_BOOTBLOCK_VER: - case H5F_SMALLOBJECT_VER: - case H5F_FREESPACE_VER: - case H5F_OBJECTDIR_VER: - case H5F_SHAREDHEADER_VER: - HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "this is a read-only property"); - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, - "unknown file creation property"); - } - break; + FUNC_LEAVE (tmpl->layout); +} - case H5C_FILE_ACCESS: - HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "unknown property for file access template"); - - case H5C_DATASET_CREATE: - dset_create = (H5D_create_t *)tmpl; - - switch (prop) { - case H5D_LAYOUT: - layout = va_arg (ap, H5D_layout_t); - if (layout<0 || layout>=H5D_NLAYOUTS) { - HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "raw data layout method is not valid"); - } - dset_create->layout = layout; - break; - - case H5D_CHUNK_NDIMS: - n = va_arg (ap, int); - if (H5D_CHUNKED!=dset_create->layout) { - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, - "not a chunked layout template"); - } - if (n<=0 || n>NELMTS (dset_create->chunk_size)) { - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, - "invalid number of dimensions"); - } - dset_create->chunk_ndims = n; - for (i=0; i<n; i++) dset_create->chunk_size[i] = 1; - break; - - case H5D_CHUNK_SIZE: - dims = va_arg (ap, size_t*); - if (H5D_CHUNKED!=dset_create->layout) { - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, - "not a chunked layout template"); - } - if (!dims) { - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no dims"); - } - for (i=0; i<dset_create->chunk_ndims; i++) { - if (dims[i]<=0) { - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, - "invalid dimension size"); - } - } - for (i=0; i<dset_create->chunk_ndims; i++) { - dset_create->chunk_size[i] = dims[i]; - } - break; - - case H5D_COMPRESS: - case H5D_PRE_OFFSET: - case H5D_PRE_SCALE: - HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, - "not implemented yet"); - - default: - HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "unknown property for dataset create template"); + +/*------------------------------------------------------------------------- + * Function: H5Cset_chunk + * + * Purpose: Sets the number of dimensions and the size of each chunk to + * the values specified. The dimensionality of the chunk should + * match the dimensionality of the data space. + * + * As a side effect, the layout method is changed to + * H5D_CHUNKED. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Cset_chunk (hid_t template, int ndims, size_t dim[]) +{ + int i; + H5D_create_t *tmpl = NULL; + + FUNC_ENTER (H5Cset_chunk, FAIL); + + /* Check arguments */ + if (H5C_DATASET_CREATE!=H5Cget_class (template) || + NULL==(tmpl=H5Aatom_object (template))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation template"); + } + if (ndims<=0) { + HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, + "chunk dimensionality must be positive"); + } + if (ndims>NELMTS (tmpl->chunk_size)) { + HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, + "chunk dimensionality is too large"); + } + if (!dim) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "no chunk dimensions specified"); + } + for (i=0; i<ndims; i++) { + if (dim[i]<=0) { + HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, + "all chunk dimensions must be positive"); } - break; - - case H5C_DATASET_XFER: - HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "unknown property for dataset transfer template"); + } - default: - HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, - "unknown template class"); + /* Set value */ + tmpl->layout = H5D_CHUNKED; + tmpl->chunk_ndims = ndims; + for (i=0; i<ndims; i++) tmpl->chunk_size[i] = dim[i]; + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Cget_chunk + * + * Purpose: Retrieves the chunk size of chunked layout. The chunk + * dimensionality is returned and the chunk size in each + * dimension is returned through the DIM argument. At most + * MAX_NDIMS elements of DIM will be initialized. + * + * Return: Success: Positive Chunk dimensionality. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +H5Cget_chunk (hid_t template, int max_ndims, size_t dim[]/*out*/) +{ + int i; + H5D_create_t *tmpl = NULL; + + FUNC_ENTER (H5Cget_chunk, FAIL); + + /* Check arguments */ + if (H5C_DATASET_CREATE!=H5Cget_class (template) || + NULL==(tmpl=H5Aatom_object (template))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation template"); + } + if (H5D_CHUNKED!=tmpl->layout) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "not a chunked storage layout"); } - ret_value = SUCCEED; + for (i=0; i<tmpl->chunk_ndims && i<max_ndims && dim; i++) { + dim[i] = tmpl->chunk_size[i]; + } - done: - va_end (ap); - FUNC_LEAVE (ret_value); + FUNC_LEAVE (tmpl->chunk_ndims); } /*-------------------------------------------------------------------------- diff --git a/src/H5Cpublic.h b/src/H5Cpublic.h index c4188f9..b7c5dcf 100644 --- a/src/H5Cpublic.h +++ b/src/H5Cpublic.h @@ -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 @@ -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"); } diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 9606bb4..417146b 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -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 */ @@ -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); diff --git a/src/H5Flow.c b/src/H5Flow.c index 9cfb51f..3871aca 100644 --- a/src/H5Flow.c +++ b/src/H5Flow.c @@ -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*/ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 4e1abb1..8ec0ab6 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -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; @@ -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"); } } @@ -996,14 +1010,6 @@ H5G_set (H5F_t *f, H5G_t *grp) 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"); } diff --git a/src/H5Gent.c b/src/H5Gent.c index cc33d4c..8575dd8 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -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"); diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 5b8bbe5..08e8156 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -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. diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 0ee5e17..69b2ef9 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -52,21 +52,20 @@ */ 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 */ } stab; @@ -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, diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 2d6b55c..c7de680 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -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 diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 1cf36ec..40ac893 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -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]); } @@ -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); + /* Check args */ + assert (obj_ent); + assert (obj_ent->file); + assert (obj_ent->file->nopen>0); + + /* Decrement open-lock counters */ + --obj_ent->file->nopen; + /* - * 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. + * 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"); @@ -778,60 +871,14 @@ H5O_find_in_ohdr (H5F_t *f, const haddr_t *addr, const H5O_class_t **type_p, /*------------------------------------------------------------------------- - * 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); } diff --git a/src/H5Ocont.c b/src/H5Ocont.c index 14b1517..b5b3715 100644 --- a/src/H5Ocont.c +++ b/src/H5Ocont.c @@ -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 */ diff --git a/src/H5Ocstore.c b/src/H5Ocstore.c index 5e69d48..5cc3215 100644 --- a/src/H5Ocstore.c +++ b/src/H5Ocstore.c @@ -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 */ diff --git a/src/H5Odtype.c b/src/H5Odtype.c index e6f4c03..be401c1 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -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 */ diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 2e10e91..70e156e 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -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 */ diff --git a/src/H5Oistore.c b/src/H5Oistore.c index 3c04c17..ea65578 100644 --- a/src/H5Oistore.c +++ b/src/H5Oistore.c @@ -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 */ diff --git a/src/H5Oname.c b/src/H5Oname.c index 379b179..58fc849 100644 --- a/src/H5Oname.c +++ b/src/H5Oname.c @@ -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 */ diff --git a/src/H5Onull.c b/src/H5Onull.c index 25579f0..8c3919a 100644 --- a/src/H5Onull.c +++ b/src/H5Onull.c @@ -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 */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index da682c6..108fb30 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -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); diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 3bc1e04..7797ae3 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -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 */ @@ -180,118 +174,6 @@ H5O_sdspace_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg) /*-------------------------------------------------------------------------- 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 PURPOSE Copies a message from MESG to DEST, allocating DEST if necessary. diff --git a/src/H5Ostab.c b/src/H5Ostab.c index db5ccdd..60aaa1d 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -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); } @@ -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 { diff --git a/src/H5public.h b/src/H5public.h index 277d853..07188cd 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -19,6 +19,7 @@ #ifndef _H5public_H #define _H5public_H #include <H5config.h> /* From configure */ +#include <sys/types.h> /* * Data types diff --git a/test/dsets.c b/test/dsets.c index f6d4df8..c5ad49c 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -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; diff --git a/test/istore.c b/test/istore.c index 81ae8c2..74154fc 100644 --- a/test/istore.c +++ b/test/istore.c @@ -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 */ diff --git a/test/tfile.c b/test/tfile.c index 8827d87..b72e037 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -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"); - - parm2=F2_OFFSET_SIZE; - ret = H5Cset_prop (tmpl1, H5F_SIZEOF_ADDR, parm2); - CHECK(ret,FAIL,"H5Cset_prop"); + ret = H5Cset_userblock (tmpl1, F2_USERBLOCK_SIZE); + CHECK(ret,FAIL,"H5Cset_userblock"); - parm2=F2_LENGTH_SIZE; - ret = H5Cset_prop (tmpl1, H5F_SIZEOF_SIZE, parm2); - CHECK(ret,FAIL,"H5Cset_prop"); + ret = H5Cset_sizes (tmpl1, F2_OFFSET_SIZE, F2_LENGTH_SIZE); + CHECK(ret,FAIL,"H5Cset_sizes"); - ret = H5Cset_prop (tmpl1, H5F_SYM_LEAF_K, F2_SYM_LEAF_K); - 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_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_prop (tmpl1, H5F_SIZEOF_SIZE, &parm2); - CHECK(ret,FAIL,"H5Cget_prop"); - VERIFY(parm2,F2_LENGTH_SIZE,"H5Cget_prop"); - - ret = H5Cget_prop (tmpl1, H5F_SIZEOF_ADDR, &parm2); - CHECK(ret,FAIL,"H5Cget_prop"); - VERIFY(parm2,F2_OFFSET_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_SYM_LEAF_K, &iparm); - CHECK(ret,FAIL,"H5Cget_prop"); - VERIFY(iparm,F2_SYM_LEAF_K,"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_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_prop (tmpl1, H5F_SIZEOF_ADDR, &parm2); - CHECK(ret,FAIL,"H5Cget_prop"); - VERIFY(parm2,F2_OFFSET_SIZE,"H5Cget_prop"); - - 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_userblock (tmpl1, &parm); + CHECK(ret,FAIL,"H5Cget_userblock"); + VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cget_userblock"); + + 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_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); diff --git a/test/tohdr.c b/test/tohdr.c index 9965092..dd65eff 100644 --- a/test/tohdr.c +++ b/test/tohdr.c @@ -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); } diff --git a/test/tstab.c b/test/tstab.c index c5542ee..f16d8f5 100644 --- a/test/tstab.c +++ b/test/tstab.c @@ -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"); |