summaryrefslogtreecommitdiffstats
path: root/src/H5HG.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-04-03 03:29:38 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-04-03 03:29:38 (GMT)
commita780cdd178f849afbc8cbb24e416eef733cbc9f2 (patch)
treec9e0162ab42567a4872a5c37444be0e08d4c1914 /src/H5HG.c
parent2a77c19b2216f04a6f8c50995ca0bf09f69e63d0 (diff)
downloadhdf5-a780cdd178f849afbc8cbb24e416eef733cbc9f2.zip
hdf5-a780cdd178f849afbc8cbb24e416eef733cbc9f2.tar.gz
hdf5-a780cdd178f849afbc8cbb24e416eef733cbc9f2.tar.bz2
[svn-r335] Changes since 19980330
---------------------- ./MANIFEST ./src/Makefile.in ./test/Makefile.in Added new files. ./config/linux ./src/H5HL.c ./src/H5HLprivate.h ./src/H5MF.c ./src/H5MFprivate.h Added `-DH5HL_DEBUG -DH5MF_DEBUG' to the debug list. ./html/H5.format.html Updated shared object message information. ./src/H5D.c Datasets can now share data types. ./src/H5F.c Updated a comment that referred to H5ACC_WRITE. ./src/H5HG.c ./src/H5HGprivate.h Moved a few things around. Made debugging better so you can now give a collection address to ./src/debug and it shows some useful stuff. ./src/H5O.c ./src/H5Ocont.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Olayout.c ./src/H5Oname.c ./src/H5Onull.c ./src/H5Oprivate.h ./src/H5Osdspace.c ./src/H5Oshared.c [NEW] ./src/H5Ostab.c Supports shared messages. ./src/H5T.c ./src/H5Tpkg.h ./src/H5Tprivate.h ./src/H5Tpublic.h The H5Tshare() function allows the user to give the library hints about how a data type will be used. ./test/shtype.c Tests the H5Tshare() function. ./test/gheap.c Tests the global heap. ./configure.in ./config/BlankForm [NEW] ./config/alpha-dec ./config/freebsd2.2.1 ./config/hpux10.20 ./config/irix6.2 ./config/irix64 ./config/linux ./config/powerpc-ibm-aix4.2.1.0 ./config/rs6000-ibm-aix4.1.4.0 ./config/solaris2.5 Cleaned up lots of configuration stuff and made the site configuration files lots easier and more uniform. To make a new file grab the BlankForm and modify it. By default, debugging is turned on for most packages. Within a package one can use `#ifdef H5AC_DEBUG' to wrap debugging code. Other options are: --enable-debug --enable-debug=yes The default, most but not all packages. --disable-debug --enable-debug=no --enable-debug=none The symbol NDEBUG is defined and none of the package debug symbols. --enable-debug=all Debugging is turned on for all packages. This might produce lots of output. --enable-debug=g,d Debugging is turned on for H5G and H5D. A compile mode is also now supported --enable-production --enable-production=yes The library is compiled with optimizations turned on. The compiler flags are augmented by adding PROD_CFLAGS and PROD_CPPFLAGS which are defined in the site config file. --disable-production --enable-production=no The default. The library is compiled for development by including DEBUG_CFLAGS and DEBUG_CPPFLAGS defined in the site config file. This is usually just `-g'. --enable-production=profile --enable-production=pg Builds a library for profiling by including the flags from PROFILE_CFLAGS and PROFILE_CPPFLAGS defined in the site config file. This is usullay just `-pg' but it could include optimization flags as well depending on the type of profile one wants. In summary, configure by saying `./configure' and you'll get a development version of the library. Configure by saying `./configure --enable-production --disable-debug' and you'll get a production version with no debugging code.
Diffstat (limited to 'src/H5HG.c')
-rw-r--r--src/H5HG.c66
1 files changed, 44 insertions, 22 deletions
diff --git a/src/H5HG.c b/src/H5HG.c
index 63b41a3..9af1074 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -33,25 +33,20 @@
#define PABLO_MASK H5HG_mask
-struct H5HG_t {
- haddr_t addr; /*address of collection */
- intn idx; /*object ID within collection */
-};
-
typedef struct H5HG_obj_t {
intn nrefs; /*reference count */
size_t size; /*total size of object */
uint8 *begin; /*ptr to object into heap->chunk*/
} H5HG_obj_t;
-typedef struct H5HG_heap_t {
+struct H5HG_heap_t {
haddr_t addr; /*collection address */
hbool_t dirty; /*does heap need to be saved? */
size_t size; /*total size of collection */
uint8 *chunk; /*the collection, incl. header */
intn nalloc; /*numb object slots allocated */
H5HG_obj_t *obj; /*array of object descriptions */
-} H5HG_heap_t;
+};
/* PRIVATE PROTOTYPES */
static H5HG_heap_t *H5HG_load(H5F_t *f, const haddr_t *addr,
@@ -81,9 +76,11 @@ static intn interface_initialize_g = FALSE;
* new collection is allocated in the file and added to the
* beginning of the CWFS list.
*
- * Return: Success: SUCCEED
+ * Return: Success: Ptr to a cached heap. The pointer is valid
+ * only until some other hdf5 library function
+ * is called.
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Robb Matzke
* Friday, March 27, 1998
@@ -92,15 +89,15 @@ static intn interface_initialize_g = FALSE;
*
*-------------------------------------------------------------------------
*/
-herr_t
+H5HG_heap_t *
H5HG_create (H5F_t *f, size_t size)
{
H5HG_heap_t *heap = NULL;
- herr_t ret_value = FAIL;
+ H5HG_heap_t *ret_value = NULL;
uint8 *p = NULL;
haddr_t addr;
- FUNC_ENTER (H5HG_create, FAIL);
+ FUNC_ENTER (H5HG_create, NULL);
/* Check args */
assert (f);
@@ -108,7 +105,7 @@ H5HG_create (H5F_t *f, size_t size)
/* Create it */
if (H5MF_alloc (f, H5MF_META, size, &addr/*out*/)<0) {
- HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, FAIL,
+ HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, NULL,
"unable to allocate file space for global heap");
}
heap = H5MM_xcalloc (1, sizeof(H5HG_heap_t));
@@ -123,7 +120,9 @@ H5HG_create (H5F_t *f, size_t size)
HDmemcpy (heap->chunk, H5HG_MAGIC, H5HG_SIZEOF_MAGIC);
p = heap->chunk + H5HG_SIZEOF_MAGIC;
*p++ = H5HG_VERSION;
- p += 3; /*reserved*/
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
H5F_encode_length (f, p, size);
/* The freespace object */
@@ -136,7 +135,7 @@ H5HG_create (H5F_t *f, size_t size)
/* Add the heap to the cache */
if (H5AC_set (f, H5AC_GHEAP, &addr, heap)<0) {
- HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, FAIL,
+ HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, NULL,
"unable to cache global heap collection");
}
@@ -152,10 +151,10 @@ H5HG_create (H5F_t *f, size_t size)
f->shared->ncwfs = MIN (H5HG_NCWFS, f->shared->ncwfs+1);
}
- ret_value = SUCCEED;
+ ret_value = heap;
done:
- if (ret_value<0 && heap) {
+ if (!ret_value && heap) {
H5MM_xfree (heap->chunk);
H5MM_xfree (heap->obj);
H5MM_xfree (heap);
@@ -263,7 +262,7 @@ H5HG_load (H5F_t *f, const haddr_t *addr, const void *udata1, void *udata2)
UINT16DECODE (p, heap->obj[idx].nrefs);
H5F_decode_length (f, p, heap->obj[idx].size);
heap->obj[idx].begin = begin;
- p += heap->obj[idx].size;
+ p = begin + heap->obj[idx].size;
}
}
assert (p==heap->chunk+heap->size);
@@ -502,8 +501,8 @@ H5HG_insert (H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/)
f->shared->cwfs[cwfsno] = f->shared->cwfs[cwfsno-1];
f->shared->cwfs[cwfsno-1] = tmp;
--cwfsno;
- break;
}
+ break;
}
}
@@ -512,11 +511,12 @@ H5HG_insert (H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/)
* new collection large enough for the message plus the collection header.
*/
if (cwfsno>=f->shared->ncwfs) {
- if (H5HG_create (f, need+H5HG_SIZEOF_HDR (f))<0) {
+ if (NULL==(heap=H5HG_create (f, need+H5HG_SIZEOF_HDR (f)))) {
HRETURN_ERROR (H5E_HEAP, H5E_CANTINIT, FAIL,
"unable to allocate a global heap collection");
}
assert (f->shared->ncwfs>0);
+ assert (f->shared->cwfs[0]==heap);
assert (f->shared->cwfs[0]->obj[0].size >= need+H5HG_SIZEOF_HDR(f));
cwfsno = 0;
}
@@ -763,6 +763,8 @@ H5HG_remove (H5F_t *f, H5HG_t *hobj)
heap->obj[0].begin = heap->chunk + (heap->size-size);
heap->obj[0].size = size;
heap->obj[0].nrefs = 0;
+ } else {
+ heap->obj[0].size += size;
}
HDmemmove (obj_start, obj_start+size,
heap->size-((obj_start+size)-heap->chunk));
@@ -830,9 +832,11 @@ herr_t
H5HG_debug(H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
intn fwidth)
{
- int i, nused, maxobj;
+ int i, j, k, nused, maxobj;
H5HG_heap_t *h = NULL;
char buf[64];
+ size_t size;
+ uint8 *p = NULL;
FUNC_ENTER(H5HG_debug, FAIL);
@@ -873,13 +877,31 @@ H5HG_debug(H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
for (i=1; i<h->nalloc; i++) {
if (h->obj[i].begin) {
sprintf (buf, "Object %d", i);
- fprintf (stream, "%*s%-*s:\n", indent, "", fwidth, buf);
+ fprintf (stream, "%*s%s\n", indent, "", buf);
fprintf (stream, "%*s%-*s %d\n", indent+3, "", MIN(fwidth-3, 0),
"Reference count:",
h->obj[i].nrefs);
fprintf (stream, "%*s%-*s %lu\n", indent+3, "", MIN(fwidth-3, 0),
"Size of object body:",
(unsigned long)(h->obj[i].size));
+ size = h->obj[i].size - H5HG_SIZEOF_OBJHDR (f);
+ p = h->obj[i].begin + H5HG_SIZEOF_OBJHDR (f);
+ for (j=0; j<size; j+=16) {
+ fprintf (stream, "%*s%04d: ", indent+6, "", j);
+ for (k=0; k<16; k++) {
+ if (8==k) fprintf (stream, " ");
+ if (j+k<size) {
+ fprintf (stream, "%02x ", p[j+k]);
+ } else {
+ fputs (" ", stream);
+ }
+ }
+ for (k=0; k<16 && j+k<size; k++) {
+ if (8==k) fprintf (stream, " ");
+ fputc (p[j+k]>' ' && p[j+k]<='~' ? p[j+k] : '.', stream);
+ }
+ fprintf (stream, "\n");
+ }
}
}