diff options
author | Robb Matzke <matzke@llnl.gov> | 1997-08-09 16:45:59 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1997-08-09 16:45:59 (GMT) |
commit | a260c7849c1ca59bd32cde9d12380e89afd70770 (patch) | |
tree | a4d791e5df2d17b3fd6988ca84e363560b1c87cf /src | |
parent | 0d050fcd579bf1db6db2d8a1d3fec617114bfd1f (diff) | |
download | hdf5-a260c7849c1ca59bd32cde9d12380e89afd70770.zip hdf5-a260c7849c1ca59bd32cde9d12380e89afd70770.tar.gz hdf5-a260c7849c1ca59bd32cde9d12380e89afd70770.tar.bz2 |
[svn-r17] ./src/H5AC.c
Renamed H5AC_find() to H5AC_find_f() which is invoked from the
H5AC_find() macro.
Changed HASH() to H5AC_HASH().
./src/H5ACprivate.h
Increased the number of cache slots from 1033 to 10330 to see
how it affects performance. This should probably be
changeable on a per-file basis.
./src/H5B.c
Fixed some bugs now that symbol tables are actually using the
stuff.
Improved debugging a little.
Fixed uninitialized memory appearing in the file.
./src/H5D.c
Changed a FUNC_ENTER() argument from H5Dset_info to H5Dwrite.
./src/H5F.c
Plugged a memory leak in H5F_dest().
./src/H5G.c
./src/H5Gprivate.h
Many of these functions take a symbol table entry which
describes the symbol table rather than just the symbol table
address.
Moved some functions to make room for the ones that understand
directory names:
H5G_new() -> H5G_stab_new()
H5G_find() -> H5G_stab_find()
H5G_modify() -> H5G_stab_modify()
H5G_insert() -> H5G_stab_insert()
H5G_list() -> H5G_stab_list()
./src/H5Gnode.c
Added more assertions.
Zero new memory so junk doesn't appear in the data file. This
is a problem when one tries to declassify a classified data
file.
H5G_node_debug() can take an extra argument which is the
address of the heap for the symbol table. If supplied, the
symbol names are printed along with the heap offsets.
./src/H5H.c
./src/H5Hprivate.h
Fixed a bug with the free blocks by forcing things to align on
even boundaries. It's still possible to lose heap memory if
the hole is smaller than the free list header. The
alternative is to align heap objects on 12 or 20 byte
boundaries, but this tends to waste to much space.
Zero new memory like with H5Gnode.c.
Fixed a "mispeling" of NDEBUG.
./src/H5Ocont.c
./src/H5Onull.c
Added the pablo mask defn.
./src/H5Ostab.c
Added the pablo mask defn.
Fixed a read from uninitialized memory.
./src/H5Oprivate.h
Tuned some parameters to see how they affect performance.
./src/debug.c
An optional third argument can be supplied which is the
address of a heap to use to display names in a symbol table.
./src/hdf5pabl.h
Changed `int' to `intn'.
Diffstat (limited to 'src')
-rw-r--r-- | src/H5AC.c | 21 | ||||
-rw-r--r-- | src/H5ACprivate.h | 13 | ||||
-rw-r--r-- | src/H5B.c | 37 | ||||
-rw-r--r-- | src/H5D.c | 2 | ||||
-rw-r--r-- | src/H5F.c | 1 | ||||
-rw-r--r-- | src/H5G.c | 124 | ||||
-rw-r--r-- | src/H5Gnode.c | 14 | ||||
-rw-r--r-- | src/H5Gprivate.h | 20 | ||||
-rw-r--r-- | src/H5H.c | 48 | ||||
-rw-r--r-- | src/H5Hprivate.h | 1 | ||||
-rw-r--r-- | src/H5Ocont.c | 2 | ||||
-rw-r--r-- | src/H5Onull.c | 2 | ||||
-rw-r--r-- | src/H5Oprivate.h | 6 | ||||
-rw-r--r-- | src/H5Ostab.c | 26 | ||||
-rw-r--r-- | src/debug.c | 8 | ||||
-rw-r--r-- | src/hdf5.h | 1 | ||||
-rw-r--r-- | src/hdf5pabl.h | 2 | ||||
-rw-r--r-- | src/hdf5plat.h | 4 |
18 files changed, 217 insertions, 115 deletions
@@ -28,7 +28,6 @@ #include "H5MMprivate.h" #define PABLO_MASK H5AC_mask -#define HASH(addr) ((unsigned)(addr) % H5AC_NSLOTS) static int interface_initialize_g = FALSE; /*initialized?*/ @@ -99,7 +98,7 @@ H5AC_dest (hdf5_file_t *f) /*------------------------------------------------------------------------- - * Function: H5AC_find + * Function: H5AC_find_f * * Purpose: Given an object type and the address at which that object * is located in the file, return a pointer to the object. @@ -127,10 +126,10 @@ H5AC_dest (hdf5_file_t *f) *------------------------------------------------------------------------- */ void * -H5AC_find (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, - const void *udata) +H5AC_find_f (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, + const void *udata) { - unsigned idx = HASH(addr); + unsigned idx = H5AC_HASH(addr); herr_t status; void *thing = NULL; herr_t (*flush)(hdf5_file_t*,hbool_t,haddr_t,void*)=NULL; @@ -159,6 +158,10 @@ H5AC_find (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, HRETURN_ERROR (H5E_CACHE, H5E_BADTYPE, NULL); } +#ifdef DO_NOT_CACHE + H5AC_flush (f, NULL, 0, TRUE); +#endif + /* * Load a new thing. If it can't be loaded, then return an error * without preempting anything. @@ -220,7 +223,7 @@ herr_t H5AC_flush (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy) { - uintn i = HASH(addr); + uintn i = H5AC_HASH(addr); herr_t status; herr_t (*flush)(hdf5_file_t*,hbool_t,haddr_t,void*)=NULL; @@ -287,7 +290,7 @@ herr_t H5AC_set (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, void *thing) { herr_t status; - uintn idx = HASH (addr); + uintn idx = H5AC_HASH (addr); herr_t (*flush)(hdf5_file_t*,hbool_t,haddr_t,void*)=NULL; FUNC_ENTER (H5AC_set, NULL, FAIL); @@ -337,8 +340,8 @@ herr_t H5AC_rename (hdf5_file_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr) { - uintn old_idx = HASH (old_addr); - uintn new_idx = HASH (new_addr); + uintn old_idx = H5AC_HASH (old_addr); + uintn new_idx = H5AC_HASH (new_addr); herr_t (*flush)(hdf5_file_t*, hbool_t, haddr_t, void*); herr_t status; diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index d5c8cad..7bee4b6 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -47,7 +47,8 @@ typedef struct H5AC_class_t { * cache entry by hashing the object's file address. Each file has its * own cache, an array of slots. */ -#define H5AC_NSLOTS 1033 /*prime number tend to work best */ +#define H5AC_NSLOTS 10330 /*prime number tend to work best */ +#define H5AC_HASH(ADDR) ((unsigned)(ADDR) % H5AC_NSLOTS) typedef struct H5AC_cache_t { const H5AC_class_t *type; /*type of object stored here */ @@ -59,8 +60,8 @@ typedef struct H5AC_cache_t { * Library prototypes. */ herr_t H5AC_dest (hdf5_file_t *f); -void *H5AC_find (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, - const void *udata); +void *H5AC_find_f (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, + const void *udata); herr_t H5AC_flush (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy); herr_t H5AC_new (hdf5_file_t *f); @@ -69,4 +70,10 @@ herr_t H5AC_rename (hdf5_file_t *f, const H5AC_class_t *type, herr_t H5AC_set (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, void *thing); +#define H5AC_find(F,TYPE,ADDR,UDATA) \ + (((F)->cache[H5AC_HASH(ADDR)].type==(TYPE) && \ + (F)->cache[H5AC_HASH(ADDR)].addr==(ADDR)) ? \ + (F)->cache[H5AC_HASH(ADDR)].thing : \ + H5AC_find_f (F, TYPE, ADDR, UDATA)) + #endif /* !_H5ACprivate_H */ @@ -583,6 +583,7 @@ H5B_split (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, intn anchor) if (NULL==(old=H5AC_find (f, H5AC_BT, addr, type))) { HRETURN_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL); } + assert (old->nchildren == 2*type->k); bt = H5MM_xmalloc (sizeof(H5B_t)); recsize = old->sizeof_rkey + H5F_SIZEOF_OFFSET(f); @@ -591,11 +592,12 @@ H5B_split (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, intn anchor) */ size = H5B_nodesize (f, type, &total_nkey_size, old->sizeof_rkey); bt->dirty = 1; + bt->sizeof_rkey = old->sizeof_rkey; bt->ndirty = BOUND (0, old->ndirty-delta, type->k); bt->type = type; bt->level = old->level; bt->nchildren = type->k; - bt->page = H5MM_xmalloc (size); + bt->page = H5MM_xcalloc (size, 1); /*use calloc() to keep file clean*/ bt->native = H5MM_xmalloc (total_nkey_size); bt->child = H5MM_xmalloc (2*type->k * sizeof(haddr_t)); bt->key = H5MM_xmalloc ((2*type->k+1) * sizeof(H5B_key_t)); @@ -615,7 +617,7 @@ H5B_split (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, intn anchor) /* key */ if (i<=type->k) { bt->key[i].dirty = old->key[delta+i].dirty; - bt->key[i].rkey = bt->native + offset; + bt->key[i].rkey = bt->page + offset; if (old->key[delta+i].nkey) { bt->key[i].nkey = bt->native + i*type->sizeof_nkey; } else { @@ -957,6 +959,11 @@ H5B_insert_child (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, for (i=bt->nchildren; i>=idx; --i) { bt->key[i+1].dirty = bt->key[i].dirty; + if (bt->key[i].nkey) { + bt->key[i+1].nkey = bt->native + (i+1) * type->sizeof_nkey; + } else { + bt->key[i+1].nkey = NULL; + } } bt->key[idx].dirty = 1; bt->key[idx].nkey = bt->native + idx * type->sizeof_nkey; @@ -978,10 +985,14 @@ H5B_insert_child (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, for (i=bt->nchildren; i>idx; --i) { bt->key[i+1].dirty = bt->key[i].dirty; + if (bt->key[i].nkey) { + bt->key[i+1].nkey = bt->native + (i+1) * type->sizeof_nkey; + } else { + bt->key[i+1].nkey = NULL; + } } bt->key[idx+1].dirty = 1; - bt->key[idx+1].nkey = bt->native + - (idx+1) * type->sizeof_nkey; + bt->key[idx+1].nkey = bt->native + (idx+1) * type->sizeof_nkey; memcpy (bt->key[idx+1].nkey, md_key, type->sizeof_nkey); } @@ -1411,6 +1422,7 @@ H5B_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth, const H5B_class_t *type) { H5B_t *bt = NULL; + int i; FUNC_ENTER (H5B_debug, NULL, FAIL); @@ -1455,9 +1467,20 @@ H5B_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth, "Address of right sibling:", (unsigned long)(bt->right)); - fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth, - "Number of children:", - (int)(bt->nchildren)); + fprintf (stream, "%*s%-*s %d (%d)\n", indent, "", fwidth, + "Number of children (max):", + (int)(bt->nchildren), + (int)(2*type->k)); + + /* + * Print the child addresses + */ + for (i=0; i<bt->nchildren; i++) { + fprintf (stream, "%*sChild %d...\n", indent, "", i); + fprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX(0,fwidth-3), + "Address:", + (unsigned long)(bt->child[i])); + } FUNC_LEAVE (SUCCEED); } @@ -196,7 +196,7 @@ herr_t H5Dwrite(hatom_t oid, hatom_t did, VOIDP buf) uintn towrite; /* number of bytes to write out */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5Dset_info, H5D_init_interface, FAIL); + FUNC_ENTER(H5Dwrite, H5D_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -369,6 +369,7 @@ H5F_dest (hdf5_file_t *f) H5AC_dest (f); f->dir = H5MM_xfree (f->dir); f->filename = H5MM_xfree (f->filename); + f->root_sym = H5MM_xfree (f->root_sym); H5MM_xfree (f); } return NULL; @@ -8,7 +8,17 @@ * Jul 18 1997 * Robb Matzke <matzke@llnl.gov> * - * Purpose: + * Purpose: Symbol table functions. The functions that + * begin with `H5G_stab_' don't understand the + * directory hierarchy; they operate on a single + * symbol table at a time. + * + * The functions that begin with `H5G_node_' operate + * on the leaf nodes of a symbol table B-tree. They + * should be defined in the H5Gnode.c file. + * + * The remaining functions know about the directory + * hierarchy. * * Modifications: * @@ -37,10 +47,9 @@ /* Is the interface initialized? */ static intn interface_initialize_g = FALSE; - /*------------------------------------------------------------------------- - * Function: H5G_new + * Function: H5G_stab_new * * Purpose: Creates a new empty symbol table (object header, name heap, * and B-tree). The caller can specify an initial size for the @@ -54,7 +63,10 @@ static intn interface_initialize_g = FALSE; * item in the heap is the empty string, and must appear at * heap offset zero. * - * Return: Success: Address of new symbol table. + * Return: Success: Address of new symbol table header. If + * the caller supplies a symbol table entry + * SELF then it will be initialized to point to + * this symbol table. * * Failure: FAIL * @@ -67,13 +79,13 @@ static intn interface_initialize_g = FALSE; *------------------------------------------------------------------------- */ haddr_t -H5G_new (hdf5_file_t *f, size_t init) +H5G_stab_new (hdf5_file_t *f, H5G_entry_t *self, size_t init) { off_t name; /*offset of "" name */ haddr_t addr; /*object header address */ H5O_stab_t stab; /*symbol table message */ - FUNC_ENTER (H5G_new, NULL, FAIL); + FUNC_ENTER (H5G_stab_new, NULL, FAIL); /* * Check arguments. @@ -102,11 +114,18 @@ H5G_new (hdf5_file_t *f, size_t init) /* The B-tree is created on demand later */ stab.btree = 0; - /* Create symbol table object header */ - if ((addr = H5O_new (f, 0, 4+2*H5F_SIZEOF_OFFSET(f)))<0) { + /* Create symbol table object header with a single link */ + if ((addr = H5O_new (f, 1, 4+2*H5F_SIZEOF_OFFSET(f)))<0) { HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL); } - if (H5O_modify(f, addr, NULL, NULL, H5O_STAB, H5O_NEW_MESG, &stab)<0) { + if (self) { + self->name_off = 0; + self->header = addr; + self->type = H5G_NOTHING_CACHED; + } + + /* insert the symbol table message */ + if (H5O_modify(f, addr, self, NULL, H5O_STAB, H5O_NEW_MESG, &stab)<0) { HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL); } @@ -115,11 +134,11 @@ H5G_new (hdf5_file_t *f, size_t init) /*------------------------------------------------------------------------- - * Function: H5G_find + * Function: H5G_stab_find * - * Purpose: Finds a symbol named NAME in the symbol table whose address - * is ADDR and returns a copy of the symbol table entry through - * the ENTRY argument. + * Purpose: Finds a symbol named NAME in the symbol table whose + * description is stored in SELF in file F and returns a + * copy of the symbol table entry through the ENT argument. * * Return: Success: Address corresponding to the name. * @@ -134,21 +153,22 @@ H5G_new (hdf5_file_t *f, size_t init) *------------------------------------------------------------------------- */ haddr_t -H5G_find (hdf5_file_t *f, haddr_t addr, const char *name, H5G_entry_t *entry) +H5G_stab_find (hdf5_file_t *f, H5G_entry_t *self, const char *name, + H5G_entry_t *ent) { H5G_node_ud1_t udata; /*data to pass through B-tree */ H5O_stab_t stab; /*symbol table message */ - FUNC_ENTER (H5G_find, NULL, FAIL); + FUNC_ENTER (H5G_stab_find, NULL, FAIL); /* Check arguments */ assert (f); - assert (addr>=0); + assert (self && self->header>=0); assert (name && *name); - assert (entry); + assert (ent); /* set up the udata */ - if (NULL==H5O_read (f, addr, NULL, H5O_STAB, 0, &stab)) { + if (NULL==H5O_read (f, self->header, self, H5O_STAB, 0, &stab)) { HRETURN_ERROR (H5E_SYM, H5E_BADMESG, FAIL); } if (stab.btree<=0 || stab.heap<=0) { @@ -164,17 +184,17 @@ H5G_find (hdf5_file_t *f, haddr_t addr, const char *name, H5G_entry_t *entry) } /* return the result */ - if (entry) *entry = udata.entry; + if (ent) *ent = udata.entry; FUNC_LEAVE (udata.entry.header); } /*------------------------------------------------------------------------- - * Function: H5G_modify + * Function: H5G_stab_modify * * Purpose: Modifies the entry for an existing symbol. The name of the - * symbol is NAME in the symbol table whose address is ADDR in - * file F. ENTRY is the new symbol table entry to use for the + * symbol is NAME in the symbol table described by SELF in + * file F. ENT is the new symbol table entry to use for the * symbol. * * Return: Success: SUCCEED @@ -190,21 +210,22 @@ H5G_find (hdf5_file_t *f, haddr_t addr, const char *name, H5G_entry_t *entry) *------------------------------------------------------------------------- */ herr_t -H5G_modify (hdf5_file_t *f, haddr_t addr, const char *name, H5G_entry_t *entry) +H5G_stab_modify (hdf5_file_t *f, H5G_entry_t *self, const char *name, + H5G_entry_t *ent) { H5G_node_ud1_t udata; /*data to pass through B-tree */ H5O_stab_t stab; /*symbol table message */ - FUNC_ENTER (H5G_modify, NULL, FAIL); + FUNC_ENTER (H5G_stab_modify, NULL, FAIL); /* check arguments */ assert (f); - assert (addr>=0); + assert (self && self->header>=0); assert (name && *name); - assert (entry); + assert (ent); /* set up the udata */ - if (NULL==H5O_read (f, addr, NULL, H5O_STAB, 0, &stab)) { + if (NULL==H5O_read (f, self->header, self, H5O_STAB, 0, &stab)) { HRETURN_ERROR (H5E_SYM, H5E_BADMESG, FAIL); } if (stab.btree<=0 || stab.heap<=0) { @@ -213,7 +234,7 @@ H5G_modify (hdf5_file_t *f, haddr_t addr, const char *name, H5G_entry_t *entry) udata.operation = H5G_OPER_MODIFY; udata.name = name; udata.heap = stab.heap; - udata.entry = *entry; + udata.entry = *ent; /* search and modify the B-tree */ if (H5B_find (f, H5B_SNODE, stab.btree, &udata)<0) { @@ -225,11 +246,11 @@ H5G_modify (hdf5_file_t *f, haddr_t addr, const char *name, H5G_entry_t *entry) /*------------------------------------------------------------------------- - * Function: H5G_insert + * Function: H5G_stab_insert * - * Purpose: Insert a new symbol into the table whose address is ADDR in + * Purpose: Insert a new symbol into the table described by SELF in * file F. The name of the new symbol is NAME and its symbol - * table entry is ENTRY. + * table entry is ENT. * * Return: Success: SUCCEED * @@ -244,22 +265,23 @@ H5G_modify (hdf5_file_t *f, haddr_t addr, const char *name, H5G_entry_t *entry) *------------------------------------------------------------------------- */ herr_t -H5G_insert (hdf5_file_t *f, haddr_t addr, const char *name, H5G_entry_t *entry) +H5G_stab_insert (hdf5_file_t *f, H5G_entry_t *self, const char *name, + H5G_entry_t *ent) { H5O_stab_t stab; /*symbol table message */ H5G_node_ud1_t udata; /*data to pass through B-tree */ off_t offset; /*offset of name within heap */ - FUNC_ENTER (H5G_insert, NULL, FAIL); + FUNC_ENTER (H5G_stab_insert, NULL, FAIL); /* check arguments */ assert (f); - assert (addr>=0); + assert (self && self->header>=0); assert (name && *name); - assert (entry); + assert (ent); /* make sure we have a B-tree and a heap */ - if (NULL==H5O_read (f, addr, NULL, H5O_STAB, 0, &stab)) { + if (NULL==H5O_read (f, self->header, self, H5O_STAB, 0, &stab)) { HRETURN_ERROR (H5E_SYM, H5E_BADMESG, FAIL); } if (stab.btree<=0 || stab.heap<=0) { @@ -277,7 +299,7 @@ H5G_insert (hdf5_file_t *f, haddr_t addr, const char *name, H5G_entry_t *entry) HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL); } } - if (H5O_modify (f, addr, NULL, NULL, H5O_STAB, 0, &stab)<0) { + if (H5O_modify (f, self->header, self, NULL, H5O_STAB, 0, &stab)<0) { HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL); } } @@ -285,7 +307,7 @@ H5G_insert (hdf5_file_t *f, haddr_t addr, const char *name, H5G_entry_t *entry) /* initialize data to pass through B-tree */ udata.name = name; udata.heap = stab.heap; - udata.entry = *entry; + udata.entry = *ent; if (H5B_insert (f, H5B_SNODE, stab.btree, &udata)<0) { HRETURN_ERROR (H5E_SYM, H5E_CANTINSERT, FAIL); } @@ -295,7 +317,7 @@ H5G_insert (hdf5_file_t *f, haddr_t addr, const char *name, H5G_entry_t *entry) /*------------------------------------------------------------------------- - * Function: H5G_list + * Function: H5G_stab_list * * Purpose: Returns a list of all the symbols in a symbol table. * The caller allocates an array of pointers which this @@ -322,16 +344,21 @@ H5G_insert (hdf5_file_t *f, haddr_t addr, const char *name, H5G_entry_t *entry) *------------------------------------------------------------------------- */ intn -H5G_list (hdf5_file_t *f, haddr_t addr, int maxentries, - char *names[], H5G_entry_t entries[]) +H5G_stab_list (hdf5_file_t *f, H5G_entry_t *self, intn maxentries, + char *names[], H5G_entry_t entries[]) { H5G_node_list_t udata; H5O_stab_t stab; intn i; - FUNC_ENTER (H5G_list, NULL, FAIL); + FUNC_ENTER (H5G_stab_list, NULL, FAIL); + + /* check args */ + assert (f); + assert (self && self->header>=0); + assert (maxentries>=0); - if (NULL==H5O_read (f, addr, NULL, H5O_STAB, 0, &stab)) { + if (NULL==H5O_read (f, self->header, self, H5O_STAB, 0, &stab)) { HRETURN_ERROR (H5E_SYM, H5E_BADMESG, FAIL); } if (stab.btree<=0 || stab.heap<=0) HRETURN (0); /*empty directory*/ @@ -520,12 +547,16 @@ H5G_encode_vec (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent, intn n) * * Modifications: * + * Robb Matzke, 8 Aug 1997 + * Writes zeros for the bytes that aren't used so the file doesn't + * contain junk. + * *------------------------------------------------------------------------- */ herr_t H5G_encode (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent) { - uint8 *p_ret = *pp; + uint8 *p_ret = *pp + H5G_SIZEOF_ENTRY(f); FUNC_ENTER (H5G_encode, NULL, FAIL); @@ -562,7 +593,10 @@ H5G_encode (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent) abort(); } - *pp = p_ret + H5G_SIZEOF_ENTRY(f); + /* fill with zero */ + while (*pp<p_ret) *(*pp)++ = 0; + + *pp = p_ret; FUNC_LEAVE (SUCCEED); } diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 9e66188..11950f2 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -237,8 +237,6 @@ H5G_node_new (hdf5_file_t *f, void *_lt_key, void *_udata, void *_rt_key) * Check arguments. */ assert (f); - assert (lt_key); - assert (rt_key); sym = H5MM_xcalloc (1, sizeof(H5G_node_t)); size = H5G_node_size (f); @@ -320,9 +318,9 @@ H5G_node_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5G_node_t *sym) /* entries */ H5G_encode_vec (f, &p, sym->entry, sym->nsyms); - + memset (p, 0, size - (p-buf)); - status = H5F_block_write (f, addr, p-buf, buf); + status = H5F_block_write (f, addr, size, buf); buf = H5MM_xfree (buf); if (status<0) HRETURN_ERROR (H5E_SYM, H5E_WRITEERROR, FAIL); } @@ -855,12 +853,13 @@ H5G_node_list (hdf5_file_t *f, haddr_t addr, void *_udata) */ herr_t H5G_node_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, - intn fwidth) + intn fwidth, haddr_t heap) { int i, j; char buf[64]; H5G_node_t *sn = NULL; herr_t status; + const char *s; FUNC_ENTER (H5G_node_debug, NULL, FAIL); @@ -897,6 +896,11 @@ H5G_node_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, fwidth = MAX (0, fwidth-3); for (i=0; i<sn->nsyms; i++) { fprintf (stream, "%*sSymbol %d:\n", indent-3, "", i); + if (heap>0 && (s = H5H_peek (f, heap, sn->entry[i].name_off))) { + fprintf (stream, "%*s%-*s `%s'\n", indent, "", fwidth, + "Name:", + s); + } fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth, "Name offset into private heap:", (unsigned long)(sn->entry[i].name_off)); diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index fdfa10c..0e4057d 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -134,16 +134,16 @@ extern const H5B_class_t H5B_SNODE[1]; * Library prototypes... */ herr_t H5G_node_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, - intn fwidth); -haddr_t H5G_new (hdf5_file_t *f, size_t init); -haddr_t H5G_find (hdf5_file_t *f, haddr_t addr, const char *name, - H5G_entry_t *entry); -herr_t H5G_modify (hdf5_file_t *f, haddr_t addr, const char *name, - H5G_entry_t *entry); -herr_t H5G_insert (hdf5_file_t *f, haddr_t addr, const char *name, - H5G_entry_t *entry); -intn H5G_list (hdf5_file_t *f, haddr_t addr, int maxentries, - char *names[], H5G_entry_t entries[]); + intn fwidth, haddr_t heap); +haddr_t H5G_stab_new (hdf5_file_t *f, H5G_entry_t *self, size_t init); +haddr_t H5G_stab_find (hdf5_file_t *f, H5G_entry_t *self, const char *name, + H5G_entry_t *ent); +herr_t H5G_stab_modify (hdf5_file_t *f, H5G_entry_t *self, const char *name, + H5G_entry_t *ent); +herr_t H5G_stab_insert (hdf5_file_t *f, H5G_entry_t *self, const char *name, + H5G_entry_t *ent); +intn H5G_stab_list (hdf5_file_t *f, H5G_entry_t *self, intn maxentries, + char *names[], H5G_entry_t entries[]); herr_t H5G_decode (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent); herr_t H5G_decode_vec (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent, intn n); herr_t H5G_encode (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent); @@ -132,7 +132,7 @@ H5H_new (hdf5_file_t *f, H5H_type_t heap_type, size_t size_hint) heap->addr = addr + H5H_SIZEOF_HDR(f); heap->disk_alloc = size_hint; heap->mem_alloc = size_hint; - heap->chunk = H5MM_xmalloc (H5H_SIZEOF_HDR(f) + size_hint); + heap->chunk = H5MM_xcalloc (1, H5H_SIZEOF_HDR(f)+size_hint); /* free list */ if (size_hint) { @@ -179,7 +179,7 @@ H5H_load (hdf5_file_t *f, haddr_t addr, const void *udata) uint8 hdr[20], *p; H5H_t *heap=NULL; H5H_free_t *fl=NULL, *tail=NULL; - haddr_t free_block; + haddr_t free_block=H5H_FREE_NULL; FUNC_ENTER (H5H_load, NULL, NULL); @@ -211,7 +211,7 @@ H5H_load (hdf5_file_t *f, haddr_t addr, const void *udata) /* data */ H5F_decode_offset (f, p, heap->addr); - heap->chunk = H5MM_xmalloc (H5H_SIZEOF_HDR(f) + heap->mem_alloc); + heap->chunk = H5MM_xcalloc (1, H5H_SIZEOF_HDR(f) + heap->mem_alloc); if (heap->disk_alloc && H5F_block_read (f, heap->addr, heap->disk_alloc, heap->chunk + H5H_SIZEOF_HDR(f))<0) { @@ -517,12 +517,12 @@ H5H_remove_free (H5H_t *heap, H5H_free_t *fl) *------------------------------------------------------------------------- */ off_t -H5H_insert (hdf5_file_t *f, haddr_t addr, size_t size, const void *buf) +H5H_insert (hdf5_file_t *f, haddr_t addr, size_t buf_size, const void *buf) { H5H_t *heap=NULL; H5H_free_t *fl=NULL, *max_fl=NULL; off_t offset = -1; - size_t need_more; + size_t need, old_size, need_more; #ifndef NDEBUG static nmessages = 0; #endif @@ -533,9 +533,13 @@ H5H_insert (hdf5_file_t *f, haddr_t addr, size_t size, const void *buf) assert (f); if (H5H_GLOBAL==addr) addr = f->smallobj_off; assert (addr>0); - assert (size>0); + assert (buf_size>0); assert (buf); + /* allocate aligned file memory */ + need = buf_size; + H5H_ALIGN (need); + if (NULL==(heap=H5AC_find (f, H5AC_HEAP, addr, NULL))) { HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL); } @@ -546,12 +550,12 @@ H5H_insert (hdf5_file_t *f, haddr_t addr, size_t size, const void *buf) * leave zero or at least H5G_SIZEOF_FREE bytes left over. */ for (fl=heap->freelist; fl; fl=fl->next) { - if (fl->size>size && fl->size-size>=H5H_SIZEOF_FREE(f)) { + if (fl->size>need && fl->size-need>=H5H_SIZEOF_FREE(f)) { offset = fl->offset; - fl->offset += size; - fl->size -= size; + fl->offset += need; + fl->size -= need; break; - } else if (fl->size==size) { + } else if (fl->size==need) { offset = fl->offset; H5H_remove_free (heap, fl); break; @@ -570,15 +574,15 @@ H5H_insert (hdf5_file_t *f, haddr_t addr, size_t size, const void *buf) if (offset<0) { need_more = MAX (2*heap->mem_alloc, H5H_SIZEOF_FREE(f)); - need_more = MAX (need_more, size); + need_more = MAX (need_more, need); if (max_fl && max_fl->offset+max_fl->size==heap->mem_alloc) { /* * Increase the size of the maximum free block. */ offset = max_fl->offset; - max_fl->offset += size; - max_fl->size += need_more - size; + max_fl->offset += need; + max_fl->size += need_more - need; if (max_fl->size < H5H_SIZEOF_FREE(f)) { #ifndef NDEBUG @@ -600,18 +604,18 @@ H5H_insert (hdf5_file_t *f, haddr_t addr, size_t size, const void *buf) * take some space out of it right away. */ offset = heap->mem_alloc; - if (need_more-size >= H5H_SIZEOF_FREE(f)) { + if (need_more-need >= H5H_SIZEOF_FREE(f)) { fl = H5MM_xmalloc (sizeof(H5H_free_t)); - fl->offset = heap->mem_alloc + size; - fl->size = need_more - size; + fl->offset = heap->mem_alloc + need; + fl->size = need_more - need; fl->prev = NULL; fl->next = heap->freelist; if (heap->freelist) heap->freelist->prev = fl; heap->freelist = fl; #ifndef NDEBUG - } else if (need_more>size) { + } else if (need_more>need) { fprintf (stderr, "H5H_insert: lost %d bytes at line %d\n", - need_more-size, __LINE__); + need_more-need, __LINE__); if (0==nmessages++) { fprintf (stderr, "Messages from H5H_insert() will go away " "when assertions are turned off.\n"); @@ -629,15 +633,19 @@ H5H_insert (hdf5_file_t *f, haddr_t addr, size_t size, const void *buf) "when assertions are turned off.\n"); } #endif + old_size = heap->mem_alloc; heap->mem_alloc += need_more; heap->chunk = H5MM_xrealloc (heap->chunk, H5H_SIZEOF_HDR(f)+heap->mem_alloc); + + /* clear new section so junk doesn't appear in the file */ + memset (heap->chunk+H5H_SIZEOF_HDR(f)+old_size, 0, need_more); } /* * Copy the data into the heap */ - HDmemcpy (heap->chunk + H5H_SIZEOF_HDR(f) + offset, buf, size); + HDmemcpy (heap->chunk + H5H_SIZEOF_HDR(f) + offset, buf, buf_size); FUNC_LEAVE (offset); } @@ -796,7 +804,7 @@ H5H_remove (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size) * lost. */ if (size < H5H_SIZEOF_FREE(f)) { -#ifndef NDEUBG +#ifndef NDEBUG fprintf (stderr, "H5H_remove: lost %d bytes\n", size); if (0==nmessages++) { fprintf (stderr, "Messages from H5H_remove() will go away " diff --git a/src/H5Hprivate.h b/src/H5Hprivate.h index dc5318f..6a05049 100644 --- a/src/H5Hprivate.h +++ b/src/H5Hprivate.h @@ -22,6 +22,7 @@ #define H5H_MAGIC "HEAP" /*heap magic number */ #define H5H_SIZEOF_MAGIC 4 +#define H5H_ALIGN(X) ((X)=((X)+1) & ~0x01) typedef enum H5H_type_t { H5H_LOCAL =0, /*local symtab name heap */ diff --git a/src/H5Ocont.c b/src/H5Ocont.c index 068a768..7b184cb 100644 --- a/src/H5Ocont.c +++ b/src/H5Ocont.c @@ -23,6 +23,8 @@ #include "H5MMprivate.h" #include "H5Oprivate.h" +#define PABLO_MASK H5O_cont_mask + /* PRIVATE PROTOTYPES */ static void *H5O_cont_decode (hdf5_file_t *f, const uint8 *p); static herr_t H5O_cont_encode (hdf5_file_t *f, size_t size, uint8 *p, diff --git a/src/H5Onull.c b/src/H5Onull.c index 97e1ff7..965266d 100644 --- a/src/H5Onull.c +++ b/src/H5Onull.c @@ -18,6 +18,8 @@ #include "H5private.h" #include "H5Oprivate.h" +#define PABLO_MASK H5O_null_mask + /* This message derives from H5O */ const H5O_class_t H5O_NULL[1] = {{ H5O_NULL_ID, /*message id number */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index dfaa5b5..40d4a36 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -21,9 +21,9 @@ #include "H5Fprivate.h" #include "H5Gprivate.h" -#define H5O_MIN_SIZE 64 /*min obj header data size */ -#define H5O_NMESGS 64 /*initial number of messages */ -#define H5O_NCHUNKS 64 /*initial number of chunks */ +#define H5O_MIN_SIZE 16 /*min obj header data size */ +#define H5O_NMESGS 32 /*initial number of messages */ +#define H5O_NCHUNKS 8 /*initial number of chunks */ #define H5O_NEW_MESG (-1) /*new message */ #define H5O_NO_ADDR (-1) /*no disk address yet */ diff --git a/src/H5Ostab.c b/src/H5Ostab.c index ec6dd61..d2c1394 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -23,6 +23,8 @@ #include "H5MMprivate.h" #include "H5Oprivate.h" +#define PABLO_MASK H5O_stab_mask + /* PRIVATE PROTOTYPES */ static void *H5O_stab_decode (hdf5_file_t *f, const uint8 *p); static herr_t H5O_stab_encode (hdf5_file_t *f, size_t size, uint8 *p, @@ -200,20 +202,26 @@ H5O_stab_cache (H5G_entry_t *ent, const void *_mesg) assert (ent); assert (stab); - /* cache */ + /* + * We do this in two steps so Purify doesn't complain about + * uninitialized memory reads even though they don't bother + * anything. + */ if (H5G_CACHED_STAB != ent->type) { modified = TRUE; ent->type = H5G_CACHED_STAB; - } - - if (ent->cache.stab.btree != stab->btree) { - modified = TRUE; ent->cache.stab.btree = stab->btree; - } - - if (ent->cache.stab.heap != stab->heap) { - modified = TRUE; ent->cache.stab.heap = stab->heap; + } else { + if (ent->cache.stab.btree != stab->btree) { + modified = TRUE; + ent->cache.stab.btree = stab->btree; + } + + if (ent->cache.stab.heap != stab->heap) { + modified = TRUE; + ent->cache.stab.heap = stab->heap; + } } FUNC_LEAVE (modified); diff --git a/src/debug.c b/src/debug.c index d07b2cb..220b461 100644 --- a/src/debug.c +++ b/src/debug.c @@ -53,6 +53,7 @@ main (int argc, char *argv[]) uint8 sig[16]; intn i; herr_t status = SUCCEED; + haddr_t extra = 0; /* * Parse command arguments. @@ -61,6 +62,9 @@ main (int argc, char *argv[]) printf ("New address: %s\n", argv[2]); addr = strtol (argv[2], NULL, 0); } + if (argc>3) { + extra = strtol (argv[3], NULL, 0); + } /* * Open the file and get the file descriptor. @@ -99,7 +103,7 @@ main (int argc, char *argv[]) /* * Debug a symbol table node. */ - status = H5G_node_debug (f, addr, stdout, 0, VCOL); + status = H5G_node_debug (f, addr, stdout, 0, VCOL, extra); } else if (!memcmp (sig, H5B_MAGIC, H5B_SIZEOF_MAGIC)) { /* @@ -110,7 +114,7 @@ main (int argc, char *argv[]) H5B_subid_t subtype = sig[H5B_SIZEOF_MAGIC]; switch (subtype) { case H5B_SUBTYPE_SNODE: - status = H5G_node_debug (f, addr, stdout, 0, VCOL); + status = H5G_node_debug (f, addr, stdout, 0, VCOL, extra); break; default: @@ -33,6 +33,7 @@ #include "ProcIDs.h" #endif /* HAVE_PABLO */ + /* Determine the system and set up basic info. */ #include "hdf5plat.h" /* Platform/OS/CPU detection header file (should be first header included) */ diff --git a/src/hdf5pabl.h b/src/hdf5pabl.h index 008a265..6fa3922 100644 --- a/src/hdf5pabl.h +++ b/src/hdf5pabl.h @@ -20,7 +20,7 @@ #define HDF5PABL_H #ifdef HAVE_PABLO -#define PABLO_SAVE(func_id) int pablo_func_id = func_id +#define PABLO_SAVE(func_id) intn pablo_func_id = func_id #define PABLO_TRACE_ON(m, f) TRACE_ON(m,f) #define PABLO_TRACE_OFF(m, f) TRACE_OFF(m,f) #else /* no Pablo tracing enabled */ diff --git a/src/hdf5plat.h b/src/hdf5plat.h index 25d89cb..d73e7e6 100644 --- a/src/hdf5plat.h +++ b/src/hdf5plat.h @@ -332,6 +332,10 @@ typedef float float32; typedef double float64; typedef int intf; /* size of INTEGERs in Fortran compiler */ +#define HDF5_HAVE_NATIVE_INT64 +typedef __int64_t int64; +typedef __uint64_t uint64; + /* Fortran compatibility macros */ #define FNAME_POST_UNDERSCORE /* Fortran function names require trailing underscore */ #define _fcdtocp(desc) (desc) /* Macro to convert from Fortran character descriptor to C 'char *' */ |