summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/H5AC.c4
-rw-r--r--src/H5B.c2
-rw-r--r--src/H5D.c19
-rw-r--r--src/H5F.c8
-rw-r--r--src/H5Ffamily.c10
-rw-r--r--src/H5Flow.c8
-rw-r--r--src/H5HG.c66
-rw-r--r--src/H5HGprivate.h23
-rw-r--r--src/H5HL.c44
-rw-r--r--src/H5HLprivate.h8
-rw-r--r--src/H5MF.c2
-rw-r--r--src/H5MFprivate.h8
-rw-r--r--src/H5O.c374
-rw-r--r--src/H5Ocont.c15
-rw-r--r--src/H5Odtype.c93
-rw-r--r--src/H5Oefl.c12
-rw-r--r--src/H5Olayout.c15
-rw-r--r--src/H5Oname.c34
-rw-r--r--src/H5Onull.c1
-rw-r--r--src/H5Oprivate.h45
-rw-r--r--src/H5Osdspace.c13
-rw-r--r--src/H5Oshared.c184
-rw-r--r--src/H5Ostab.c13
-rw-r--r--src/H5T.c562
-rw-r--r--src/H5Tconv.c6
-rw-r--r--src/H5Tpkg.h3
-rw-r--r--src/H5Tprivate.h2
-rw-r--r--src/H5Tpublic.h1
-rw-r--r--src/Makefile.in2
29 files changed, 1138 insertions, 439 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 23e86e4..9813af7 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -641,7 +641,7 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
#ifdef H5AC_DEBUG
static int ncalls = 0;
if (0 == ncalls++) {
- fprintf(stderr, "HDF5-DIAG: debugging cache (expensive)\n");
+ fprintf(stderr, "H5AC: debugging cache (expensive)\n");
}
#endif
@@ -838,7 +838,7 @@ H5AC_debug(H5F_t *f)
FUNC_ENTER(H5AC_debug, FAIL);
- fprintf(stderr, "HDF5-DIAG: cache diagnostics for %s\n", f->name);
+ fprintf(stderr, "H5AC: cache diagnostics for %s\n", f->name);
fprintf(stderr, " %18s %8s %8s %8s %8s+%-8s\n",
"", "Hits", "Misses", "MissRate", "Inits", "Flushes");
diff --git a/src/H5B.c b/src/H5B.c
index e061625..86e34ac 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -1640,7 +1640,7 @@ H5B_assert(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
FUNC_ENTER(H5B_assert, FAIL);
if (0 == ncalls++) {
- fprintf(stderr, "HDF5-DIAG: debugging B-trees (expensive)\n");
+ fprintf(stderr, "H5B: debugging B-trees (expensive)\n");
}
/* Initialize the queue */
bt = H5AC_find(f, H5AC_BT, addr, type, udata);
diff --git a/src/H5D.c b/src/H5D.c
index 8a527cd..8df99c0 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -820,7 +820,8 @@ H5D_create(H5G_t *loc, const char *name, const H5T_t *type, const H5S_t *space,
}
/* Update the type and space header messages */
- if (H5O_modify(&(new_dset->ent), H5O_DTYPE, 0, H5O_FLAG_CONSTANT,
+ if (H5O_modify(&(new_dset->ent), H5O_DTYPE, 0,
+ (H5O_FLAG_CONSTANT|H5O_FLAG_SHARED),
new_dset->type) < 0 ||
H5S_modify(&(new_dset->ent), new_dset->space) < 0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
@@ -1162,7 +1163,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
mem_space, buf/*out*/);
if (status>=0) goto succeed;
#ifdef H5D_DEBUG
- fprintf (stderr, "HDF5-DIAG: input pipe optimization failed "
+ fprintf (stderr, "H5D: input pipe optimization failed "
"(falling through)\n");
#endif
H5E_clear ();
@@ -1217,7 +1218,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
/* Strip mine diagnostics.... */
size_t buffer_size = smine_nelmts * MAX (src_type_size, dst_type_size);
if (smine_nelmts<nelmts) {
- fprintf (stderr, "HDF5-DIAG: strip mine");
+ fprintf (stderr, "H5D: strip mine");
if (smine_nelmts!=request_nelmts) {
fprintf (stderr, " got %lu of %lu",
(unsigned long)smine_nelmts,
@@ -1225,10 +1226,10 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
}
if (buffer_size!=target_size) {
fprintf (stderr, " (%1.1f%% of buffer)",
- 100.0*buffer_size/target_size);
+ 100.0*(double)buffer_size/(double)target_size);
}
fprintf (stderr, " %1.1f iterations\n",
- (double)nelmts/smine_nelmts);
+ (double)nelmts/(double)smine_nelmts);
}
}
#endif
@@ -1388,7 +1389,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
mem_space, buf);
if (status>=0) goto succeed;
#ifdef H5D_DEBUG
- fprintf (stderr, "HDF5-DIAG: output pipe optimization failed "
+ fprintf (stderr, "H5D: output pipe optimization failed "
"(falling through)\n");
#endif
H5E_clear ();
@@ -1443,7 +1444,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
/* Strip mine diagnostics.... */
size_t buffer_size = smine_nelmts * MAX (src_type_size, dst_type_size);
if (smine_nelmts<nelmts) {
- fprintf (stderr, "HDF5-DIAG: strip mine");
+ fprintf (stderr, "H5D: strip mine");
if (smine_nelmts!=request_nelmts) {
fprintf (stderr, " got %lu of %lu",
(unsigned long)smine_nelmts,
@@ -1451,10 +1452,10 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
}
if (buffer_size!=target_size) {
fprintf (stderr, " (%1.1f%% of buffer)",
- 100.0*buffer_size/target_size);
+ 100.0*(double)buffer_size/(double)target_size);
}
fprintf (stderr, " %1.1f iterations\n",
- (double)nelmts/smine_nelmts);
+ (double)nelmts/(double)smine_nelmts);
}
}
#endif
diff --git a/src/H5F.c b/src/H5F.c
index 4bec710..f29eec7 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -553,7 +553,7 @@ H5F_dest(H5F_t *f)
* following flags which are similar in nature to the Posix
* open(2) flags.
*
- * H5F_ACC_WRITE: Open with read/write access. If the file is
+ * H5F_ACC_RDWR: Open with read/write access. If the file is
* currently open for read-only access then it
* will be reopened. Absence of this flag
* implies read-only access.
@@ -968,7 +968,7 @@ H5F_open(const char *name, uintn flags,
* hdf5 data.
*/
#ifdef H5F_DEBUG
- fprintf(stderr, "HDF5-DIAG: resetting EOF from ");
+ fprintf(stderr, "H5F: resetting EOF from ");
H5F_addr_print(stderr, &addr1);
fprintf(stderr, " to ");
H5F_addr_print(stderr, &addr2);
@@ -1323,7 +1323,7 @@ H5F_close(H5F_t *f)
*/
if (f->nopen>0) {
#ifndef NDEBUG
- fprintf(stderr, "HDF5-DIAG: H5F_close: %u object header%s still "
+ fprintf(stderr, "H5F: H5F_close: %u object header%s still "
"open (file close will complete when %s closed)\n",
f->nopen,
1 == f->nopen ? " is" : "s are",
@@ -1333,7 +1333,7 @@ H5F_close(H5F_t *f)
HRETURN(SUCCEED);
} else if (f->close_pending) {
#ifndef NDEBUG
- fprintf(stderr, "HDF5-DIAG: H5F_close: operation completed\n");
+ fprintf(stderr, "H5F: H5F_close: operation completed\n");
#endif
}
diff --git a/src/H5Ffamily.c b/src/H5Ffamily.c
index b89b983..e9596b8 100644
--- a/src/H5Ffamily.c
+++ b/src/H5Ffamily.c
@@ -187,7 +187,7 @@ H5F_fam_open(const char *name, const H5F_access_t *access_parms,
if (size != mask) {
size++;
#ifdef H5F_DEBUG
- fprintf(stderr, "HDF5-DIAG: family member size was "
+ fprintf(stderr, "H5F: family member size was "
"rounded up to a power of 2");
#endif
}
@@ -199,16 +199,16 @@ H5F_fam_open(const char *name, const H5F_access_t *access_parms,
#ifdef H5F_DEBUG
if (nbits >= 30) {
- fprintf(stderr, "HDF5-DIAG: family members are %dGB\n",
+ fprintf(stderr, "H5F: family members are %dGB\n",
1 << (nbits-30));
} else if (nbits >= 20) {
- fprintf(stderr, "HDF5-DIAG: family members are %dMB\n",
+ fprintf(stderr, "H5F: family members are %dMB\n",
1 << (nbits-20));
} else if (nbits >= 10) {
- fprintf(stderr, "HDF5-DIAG: family members are %dkB\n",
+ fprintf(stderr, "H5F: family members are %dkB\n",
1 << (nbits-10));
} else {
- fprintf(stderr, "HDF5-DIAG: family members are %d bytes\n",
+ fprintf(stderr, "H5F: family members are %d bytes\n",
1 << nbits);
}
#endif
diff --git a/src/H5Flow.c b/src/H5Flow.c
index 125f8ed..545659a 100644
--- a/src/H5Flow.c
+++ b/src/H5Flow.c
@@ -283,7 +283,7 @@ H5F_low_write(H5F_low_t *lf, const H5F_access_t *access_parms,
tmp_addr = *addr;
H5F_addr_inc(&tmp_addr, size);
if (H5F_addr_gt(&tmp_addr, &(lf->eof))) {
- fprintf(stderr, "HDF5-DIAG: extending file w/o allocation\n");
+ fprintf(stderr, "H5F: extending file w/o allocation\n");
lf->eof = tmp_addr;
}
/* Write the data */
@@ -718,7 +718,7 @@ H5F_addr_encode(H5F_t *f, uint8 **pp, const haddr_t *addr)
*-------------------------------------------------------------------------
*/
void
-H5F_addr_decode(H5F_t *f, const uint8 **pp, haddr_t *addr /*out */ )
+H5F_addr_decode(H5F_t *f, const uint8 **pp, haddr_t *addr/*out*/)
{
int i;
haddr_t tmp;
@@ -763,9 +763,9 @@ H5F_addr_decode(H5F_t *f, const uint8 **pp, haddr_t *addr /*out */ )
*-------------------------------------------------------------------------
*/
void
-H5F_addr_print(FILE * stream, const haddr_t *addr)
+H5F_addr_print(FILE *stream, const haddr_t *addr)
{
- haddr_t tmp;
+ haddr_t tmp;
assert(stream);
assert(addr);
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");
+ }
}
}
diff --git a/src/H5HGprivate.h b/src/H5HGprivate.h
index aebb3f8..c6ec1cd 100644
--- a/src/H5HGprivate.h
+++ b/src/H5HGprivate.h
@@ -10,6 +10,8 @@
#include <H5HGpublic.h>
+#include <H5Fprivate.h>
+
/*
* Each collection has a magic number for some redundancy.
*/
@@ -59,14 +61,27 @@
* The initial guess for the number of messages in a collection. We assume
* that all objects in that collection are zero length, giving the maximum
* possible number of objects in the collection. The collection itself has
- * some overhead and each message has some overhead.
+ * some overhead and each message has some overhead. The `+2' accounts for
+ * rounding and for the free space object.
*/
#define H5HG_NOBJS(f,z) (int)((((z)-H5HG_SIZEOF_HDR(f))/ \
- H5HG_SIZEOF_OBJHDR(f)+1))
+ H5HG_SIZEOF_OBJHDR(f)+2))
+
+/*
+ * Makes a global heap object pointer undefined, or checks whether one is
+ * defined.
+ */
+#define H5HG_undef(HGP) ((HGP)->idx=0)
+#define H5HG_defined(HGP) ((HGP)->idx!=0)
+
+typedef struct H5HG_t {
+ haddr_t addr; /*address of collection */
+ intn idx; /*object ID within collection */
+} H5HG_t;
-typedef struct H5HG_t H5HG_t;
+typedef struct H5HG_heap_t H5HG_heap_t;
-herr_t H5HG_create (H5F_t *f, size_t size);
+H5HG_heap_t *H5HG_create (H5F_t *f, size_t size);
herr_t H5HG_insert (H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/);
void *H5HG_peek (H5F_t *f, H5HG_t *hobj);
void *H5HG_read (H5F_t *f, H5HG_t *hobj, void *object);
diff --git a/src/H5HL.c b/src/H5HL.c
index f6fa4f0..8c141a0 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -529,9 +529,6 @@ H5HL_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
size_t offset = 0;
size_t need_size, old_size, need_more;
hbool_t found;
-#ifndef NDEBUG
- static int nmessages = 0;
-#endif
FUNC_ENTER(H5HL_insert, (size_t)(-1));
@@ -601,14 +598,10 @@ H5HL_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
assert (max_fl->size==H5HL_ALIGN (max_fl->size));
if (max_fl->size < H5HL_SIZEOF_FREE(f)) {
-#ifndef NDEBUG
+#ifdef H5HL_DEBUG
if (max_fl->size) {
- fprintf(stderr, "H5HL_insert: lost %lu bytes at line %d\n",
- (unsigned long) (max_fl->size), __LINE__);
- if (0 == nmessages++) {
- fprintf(stderr, "Messages from H5HL_insert() will go "
- "away when assertions are turned off.\n");
- }
+ fprintf(stderr, "H5HL: lost %lu bytes at line %d\n",
+ (unsigned long)(max_fl->size), __LINE__);
}
#endif
max_fl = H5HL_remove_free(heap, max_fl);
@@ -629,26 +622,18 @@ H5HL_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
fl->next = heap->freelist;
if (heap->freelist) heap->freelist->prev = fl;
heap->freelist = fl;
-#ifndef NDEBUG
+#ifdef H5HL_DEBUG
} else if (need_more > need_size) {
fprintf(stderr, "H5HL_insert: lost %lu bytes at line %d\n",
- (unsigned long) (need_more - need_size), __LINE__);
- if (0 == nmessages++) {
- fprintf(stderr, "Messages from H5HL_insert() will go away "
- "when assertions are turned off.\n");
- }
+ (unsigned long)(need_more - need_size), __LINE__);
#endif
}
}
-#ifndef NDEBUG
- fprintf(stderr, "H5HL_insert: resize mem buf from %lu to %lu bytes\n",
- (unsigned long) (heap->mem_alloc),
- (unsigned long) (heap->mem_alloc + need_more));
- if (0 == nmessages++) {
- fprintf(stderr, "Messages from H5HL_insert() will go away "
- "when assertions are turned off.\n");
- }
+#ifdef H5HL_DEBUG
+ fprintf(stderr, "H5HL: resize mem buf from %lu to %lu bytes\n",
+ (unsigned long)(heap->mem_alloc),
+ (unsigned long)(heap->mem_alloc + need_more));
#endif
old_size = heap->mem_alloc;
heap->mem_alloc += need_more;
@@ -748,9 +733,6 @@ H5HL_remove(H5F_t *f, const haddr_t *addr, size_t offset, size_t size)
{
H5HL_t *heap = NULL;
H5HL_free_t *fl = heap->freelist, *fl2 = NULL;
-#ifndef NDEBUG
- static int nmessages = 0;
-#endif
FUNC_ENTER(H5HL_remove, FAIL);
@@ -817,12 +799,8 @@ H5HL_remove(H5F_t *f, const haddr_t *addr, size_t offset, size_t size)
* lost.
*/
if (size < H5HL_SIZEOF_FREE(f)) {
-#ifndef NDEBUG
- fprintf(stderr, "H5HL_remove: lost %lu bytes\n", (unsigned long) size);
- if (0 == nmessages++) {
- fprintf(stderr, "Messages from H5HL_remove() will go away "
- "when assertions are turned off.\n");
- }
+#ifdef H5HL_DEBUG
+ fprintf(stderr, "H5HL: lost %lu bytes\n", (unsigned long) size);
#endif
HRETURN(SUCCEED);
}
diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h
index 8ccc2ed..b1af51a 100644
--- a/src/H5HLprivate.h
+++ b/src/H5HLprivate.h
@@ -23,6 +23,14 @@
#include <H5private.h>
#include <H5Fprivate.h>
+/*
+ * Feature: Define H5HL_DEBUG on the compiler command line if you want to
+ * diagnostic messages from this layer.
+ */
+#ifdef NDEBUG
+# undef H5HL_DEBUG
+#endif
+
#define H5HL_MAGIC "HEAP" /*heap magic number */
#define H5HL_SIZEOF_MAGIC 4
diff --git a/src/H5MF.c b/src/H5MF.c
index 8985490..46d5bae 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -116,7 +116,7 @@ H5MF_free(H5F_t *f, const haddr_t *addr, size_t size)
HRETURN(SUCCEED);
assert(!H5F_addr_zerop(addr));
-#ifndef NDEBUG
+#ifdef H5MF_DEBUG
fprintf(stderr, "H5MF_free: lost %lu bytes of file storage\n",
(unsigned long) size);
#endif
diff --git a/src/H5MFprivate.h b/src/H5MFprivate.h
index 403da90..739966a 100644
--- a/src/H5MFprivate.h
+++ b/src/H5MFprivate.h
@@ -23,6 +23,14 @@
#include <H5private.h>
#include <H5Fprivate.h>
+/*
+ * Feature: Define H5MF_DEBUG on the compiler command line if you want to
+ * see diagnostics from this layer.
+ */
+#ifdef NDEBUG
+# undef H5MF_DEBUG
+#endif
+
#define H5MF_META 0 /*request storage for meta data */
#define H5MF_RAW 1 /*request storage for raw data */
diff --git a/src/H5O.c b/src/H5O.c
index bf60b09..87f29fc 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -107,6 +107,7 @@ H5O_init_interface(void)
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_create
@@ -281,6 +282,7 @@ H5O_close(H5G_entry_t *obj_ent)
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_load
@@ -317,7 +319,7 @@ 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? */
+ uint8 flags;
FUNC_ENTER(H5O_load, NULL);
@@ -392,14 +394,8 @@ H5O_load(H5F_t *f, const haddr_t *addr, const void *_udata1, void *_udata2)
UINT16DECODE(p, id);
UINT16DECODE(p, mesg_size);
assert (mesg_size==H5O_ALIGN (mesg_size));
- p += 4; /*reserved*/
-
- /*
- * 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;
+ flags = *p++;
+ p += 3; /*reserved*/
if (id >= NELMTS(message_type_g) || NULL == message_type_g[id]) {
HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL,
@@ -424,7 +420,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].flags = flags;
oh->mesg[mesgno].native = NULL;
oh->mesg[mesgno].raw = p;
oh->mesg[mesgno].raw_size = mesg_size;
@@ -439,7 +435,7 @@ H5O_load(H5F_t *f, const haddr_t *addr, const void *_udata1, void *_udata2)
curmesg++) {
if (H5O_CONT_ID == oh->mesg[curmesg].type->id) {
uint8 *p2 = oh->mesg[curmesg].raw;
- cont = (H5O_CONT->decode) (f, oh->mesg[curmesg].raw_size, p2);
+ cont = (H5O_CONT->decode) (f, p2, NULL);
oh->mesg[curmesg].native = cont;
chunk_addr = cont->addr;
chunk_size = cont->size;
@@ -464,6 +460,7 @@ H5O_load(H5F_t *f, const haddr_t *addr, const void *_udata1, void *_udata2)
}
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_flush
@@ -491,6 +488,7 @@ H5O_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
uint8 buf[16], *p;
intn i, id;
H5O_cont_t *cont = NULL;
+ herr_t (*encode)(H5F_t*, uint8*, const void*) = NULL;
FUNC_ENTER(H5O_flush, FAIL);
@@ -532,12 +530,10 @@ H5O_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
if (oh->mesg[i].dirty) {
p = oh->mesg[i].raw - H5O_SIZEOF_MSGHDR(f);
- /* 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);
- *p++ = 0; /*reserved*/
+ *p++ = oh->mesg[i].flags;
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
@@ -563,7 +559,11 @@ H5O_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
oh->chunk[cont->chunkno].addr = cont->addr;
}
- /* encode the message */
+ /*
+ * Encode the message. If the message is shared then we
+ * encode a Shared Object message instead of the object
+ * which is being shared.
+ */
assert(oh->mesg[i].raw >=
oh->chunk[oh->mesg[i].chunkno].image);
assert (oh->mesg[i].raw_size ==
@@ -571,9 +571,12 @@ H5O_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
assert(oh->mesg[i].raw + oh->mesg[i].raw_size <=
oh->chunk[oh->mesg[i].chunkno].image +
oh->chunk[oh->mesg[i].chunkno].size);
- if ((oh->mesg[i].type->encode) (f, oh->mesg[i].raw_size,
- oh->mesg[i].raw,
- oh->mesg[i].native) < 0) {
+ if (oh->mesg[i].flags & H5O_FLAG_SHARED) {
+ encode = H5O_SHARED->encode;
+ } else {
+ encode = oh->mesg[i].type->encode;
+ }
+ if ((encode)(f, oh->mesg[i].raw, oh->mesg[i].native)<0) {
HRETURN_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL,
"unable to encode object header message");
}
@@ -607,7 +610,11 @@ H5O_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
/* destroy messages */
for (i = 0; i < oh->nmesgs; i++) {
- H5O_reset(oh->mesg[i].type, oh->mesg[i].native);
+ if (oh->mesg[i].flags & H5O_FLAG_SHARED) {
+ H5O_reset (H5O_SHARED, oh->mesg[i].native);
+ } else {
+ H5O_reset(oh->mesg[i].type, oh->mesg[i].native);
+ }
oh->mesg[i].native = H5MM_xfree(oh->mesg[i].native);
}
oh->mesg = H5MM_xfree(oh->mesg);
@@ -617,6 +624,7 @@ H5O_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
}
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_reset
@@ -654,6 +662,7 @@ H5O_reset(const H5O_class_t *type, void *native)
}
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_link
@@ -676,8 +685,8 @@ H5O_reset(const H5O_class_t *type, void *native)
intn
H5O_link(H5G_entry_t *ent, intn adjust)
{
- H5O_t *oh = NULL;
- intn ret_value = FAIL;
+ H5O_t *oh = NULL;
+ intn ret_value = FAIL;
FUNC_ENTER(H5O_link, FAIL);
@@ -714,6 +723,7 @@ H5O_link(H5G_entry_t *ent, intn adjust)
}
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_read
@@ -739,11 +749,11 @@ H5O_link(H5G_entry_t *ent, intn adjust)
void *
H5O_read(H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg)
{
- H5O_t *oh = NULL;
- void *retval = NULL;
- intn idx;
- H5G_cache_t *cache = NULL;
- H5G_type_t cache_type;
+ H5O_t *oh = NULL;
+ void *ret_value = NULL;
+ intn idx;
+ H5G_cache_t *cache = NULL;
+ H5G_type_t cache_type;
FUNC_ENTER(H5O_read, NULL);
@@ -757,9 +767,9 @@ H5O_read(H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg)
/* can we get it from the symbol table entry? */
cache = H5G_ent_cache(ent, &cache_type);
if (H5O_fast_g[cache_type]) {
- retval = (H5O_fast_g[cache_type]) (cache, type, mesg);
- if (retval)
- HRETURN(retval);
+ ret_value = (H5O_fast_g[cache_type]) (cache, type, mesg);
+ if (ret_value)
+ HRETURN(ret_value);
H5E_clear(); /*don't care, try reading from header */
}
@@ -776,19 +786,54 @@ H5O_read(H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg)
HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
"unable to load object header");
}
- retval = (type->copy) (oh->mesg[idx].native, mesg);
+ if (oh->mesg[idx].flags & H5O_FLAG_SHARED) {
+ /*
+ * If the message is shared then then the native pointer points to an
+ * H5O_SHARED message. We use that information to look up the real
+ * message in the global heap.
+ */
+ H5O_shared_t *shared;
+ void *tmp_buf, *tmp_mesg;
+
+ shared = (H5O_shared_t *)(oh->mesg[idx].native);
+ if (NULL==(tmp_buf = H5HG_read (ent->file, shared, NULL))) {
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
+ "unable to read shared message from global heap");
+ }
+ tmp_mesg = (type->decode)(ent->file, tmp_buf, shared);
+ if (!tmp_mesg) {
+ H5MM_xfree (tmp_buf);
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
+ "unable to decode object header shared message");
+ }
+ if (mesg) {
+ HDmemcpy (mesg, tmp_mesg, type->native_size);
+ H5MM_xfree (tmp_mesg);
+ } else {
+ ret_value = tmp_mesg;
+ }
+ } else {
+ /*
+ * The message is not shared, but rather exists in the object
+ * header. The object header caches the native message (along with
+ * the raw message) so we must copy the native message before
+ * returning.
+ */
+ if (NULL==(ret_value = (type->copy) (oh->mesg[idx].native, mesg))) {
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL,
+ "unable to copy message to user space");
+ }
+ }
+
+ done:
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");
- }
- FUNC_LEAVE(retval);
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_find_in_ohdr
@@ -812,23 +857,24 @@ static intn
H5O_find_in_ohdr(H5F_t *f, const haddr_t *addr, const H5O_class_t **type_p,
intn sequence)
{
- H5O_t *oh = NULL;
- int i;
+ H5O_t *oh = NULL;
+ int i;
+ const H5O_class_t *type = NULL;
FUNC_ENTER(H5O_find_in_ohdr, FAIL);
- /* check args */
+ /* Check args */
assert(f);
assert(addr && H5F_addr_defined(addr));
assert(type_p);
- /* load the object header */
+ /* Load the object header */
if (NULL == (oh = H5AC_find(f, H5AC_OHDR, addr, NULL, NULL))) {
HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
"unable to load object header");
}
- /* scan through the messages looking for the right one */
+ /* Scan through the messages looking for the right one */
for (i = 0; i < oh->nmesgs; i++) {
if (*type_p && (*type_p)->id != oh->mesg[i].type->id) continue;
if (--sequence < 0) break;
@@ -838,24 +884,32 @@ H5O_find_in_ohdr(H5F_t *f, const haddr_t *addr, const H5O_class_t **type_p,
"unable to find object header message");
}
- /* decode the message if necessary */
+ /*
+ * Decode the message if necessary. If the message is shared then decode
+ * a shared message, ignoring the message type.
+ */
+ if (oh->mesg[i].flags & H5O_FLAG_SHARED) {
+ type = H5O_SHARED;
+ } else {
+ type = oh->mesg[i].type;
+ }
if (NULL == oh->mesg[i].native) {
- assert(oh->mesg[i].type->decode);
- assert (oh->mesg[i].raw_size==H5O_ALIGN (oh->mesg[i].raw_size));
- oh->mesg[i].native = (oh->mesg[i].type->decode) (f,
- oh->mesg[i].raw_size,
- oh->mesg[i].raw);
+ assert(type->decode);
+ oh->mesg[i].native = (type->decode) (f, oh->mesg[i].raw, NULL);
if (NULL == oh->mesg[i].native) {
HRETURN_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL,
"unable to decode message");
}
}
- /*return the message type */
+ /*
+ * Return the message type. If this is a shared message then return the
+ * pointed-to type.
+ */
*type_p = oh->mesg[i].type;
-
FUNC_LEAVE(i);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_modify
@@ -898,10 +952,11 @@ intn
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;
+ H5O_t *oh = NULL;
+ intn idx, sequence;
+ intn ret_value = FAIL;
+ size_t size = 0;
+ H5O_shared_t *sh_mesg = NULL;
FUNC_ENTER(H5O_modify, FAIL);
@@ -911,6 +966,7 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
assert(H5F_addr_defined(&(ent->header)));
assert(type);
assert(mesg);
+ assert (0==(flags & ~H5O_FLAG_BITS));
if (NULL == (oh = H5AC_protect(ent->file, H5AC_OHDR, &(ent->header),
NULL, NULL))) {
@@ -937,27 +993,59 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
}
if (overwrite < 0) {
/* Allocate space for the new message */
- size = (type->raw_size) (ent->file, mesg);
+ if (flags & H5O_FLAG_SHARED) {
+ if (NULL==type->share) {
+ HGOTO_ERROR (H5E_OHDR, H5E_UNSUPPORTED, FAIL,
+ "message class is not sharable");
+ }
+ sh_mesg = H5MM_xcalloc (1, sizeof *sh_mesg);
+ if ((type->share)(ent->file, mesg, sh_mesg/*out*/)<0) {
+ /*
+ * If the message isn't shared then turn of the shared bit
+ * and treat it as an unshared message.
+ */
+ H5E_clear ();
+ flags &= ~H5O_FLAG_SHARED;
+ } else {
+ if (H5HG_link (ent->file, sh_mesg, 1)<0) {
+ HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL,
+ "unable to adjust shared object link count");
+ }
+ size = (H5O_SHARED->raw_size)(ent->file, sh_mesg);
+ }
+ }
+ if (0==(flags & H5O_FLAG_SHARED)) {
+ size = (type->raw_size) (ent->file, mesg);
+ }
size = H5O_ALIGN(size);
idx = H5O_alloc(ent->file, oh, type, size);
if (idx < 0) {
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to allocate object header space for message");
+ "unable to allocate space for message");
}
sequence++;
-
- } else if (oh->mesg[idx].constant) {
+
+ } else if (oh->mesg[idx].flags & H5O_FLAG_CONSTANT) {
HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL,
"unable to modify constant message");
+ } else if (oh->mesg[idx].flags & H5O_FLAG_SHARED) {
+ HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL,
+ "unable to modify shared (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) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to copy message to object header");
+ if (flags & H5O_FLAG_SHARED) {
+ oh->mesg[idx].native = sh_mesg;
+ } else {
+ oh->mesg[idx].native = (type->copy) (mesg, oh->mesg[idx].native);
+ if (NULL == oh->mesg[idx].native) {
+ 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].flags = flags;
oh->mesg[idx].dirty = TRUE;
oh->dirty = TRUE;
ret_value = sequence;
@@ -967,8 +1055,10 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
HRETURN_ERROR(H5E_OHDR, H5E_PROTECT, FAIL,
"unable to release object header");
}
+
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_remove
@@ -1000,9 +1090,10 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
herr_t
H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
{
- H5O_t *oh = NULL;
- intn i, seq, nfailed = 0;
- herr_t ret_value = FAIL;
+ H5O_t *oh = NULL;
+ intn i, seq, nfailed = 0;
+ herr_t ret_value = FAIL;
+ H5O_shared_t *sh_mesg = NULL;
FUNC_ENTER(H5O_remove, FAIL);
@@ -1018,6 +1109,7 @@ H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
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) {
@@ -1025,11 +1117,27 @@ H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
* Keep track of how many times we failed trying to remove constant
* messages.
*/
- if (oh->mesg[i].constant) {
+ if (oh->mesg[i].flags & H5O_FLAG_CONSTANT) {
nfailed++;
continue;
}
+ if (oh->mesg[i].flags & H5O_FLAG_SHARED) {
+ if (NULL==oh->mesg[i].native) {
+ sh_mesg = (H5O_SHARED->decode)(ent->file, oh->mesg[i].raw,
+ NULL);
+ if (NULL==(oh->mesg[i].native = sh_mesg)) {
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTDECODE, FAIL,
+ "unable to decode shared message info");
+ }
+ }
+ if (H5HG_link (ent->file, sh_mesg, -1)<0) {
+ HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL,
+ "unable to decrement link count on shared "
+ "message");
+ }
+ }
+
/* change message type to nil and zero it */
oh->mesg[i].type = H5O_NULL;
HDmemset(oh->mesg[i].raw, 0, oh->mesg[i].raw_size);
@@ -1055,6 +1163,7 @@ H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
}
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_alloc_extend_chunk
@@ -1083,9 +1192,9 @@ H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
static intn
H5O_alloc_extend_chunk(H5O_t *oh, intn chunkno, size_t size)
{
- intn idx, i;
- size_t delta;
- uint8 *old_addr;
+ intn idx, i;
+ size_t delta;
+ uint8 *old_addr;
FUNC_ENTER(H5O_alloc_extend_chunk, FAIL);
@@ -1167,6 +1276,7 @@ H5O_alloc_extend_chunk(H5O_t *oh, intn chunkno, size_t size)
}
FUNC_LEAVE(idx);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_alloc_new_chunk
@@ -1339,6 +1449,7 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
FUNC_LEAVE(idx);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_alloc
@@ -1360,9 +1471,9 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
static intn
H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
{
- intn chunkno;
- intn idx;
- intn null_idx;
+ intn chunkno;
+ intn idx;
+ intn null_idx;
FUNC_ENTER(H5O_alloc, FAIL);
@@ -1441,6 +1552,60 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
oh->dirty = TRUE;
FUNC_LEAVE(idx);
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_share
+ *
+ * Purpose: Writes a message to the global heap.
+ *
+ * Return: Success: SUCCEED, and HOBJ describes the global heap
+ * object.
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, April 2, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_share (H5F_t *f, const H5O_class_t *type, const void *mesg,
+ H5HG_t *hobj/*out*/)
+{
+ size_t size;
+ void *buf = NULL;
+ herr_t ret_value = FAIL;
+
+ FUNC_ENTER (H5O_share, FAIL);
+
+ /* Check args */
+ assert (f);
+ assert (type);
+ assert (mesg);
+ assert (hobj);
+
+ /* Encode the message put it in the global heap */
+ if ((size = (type->raw_size)(f, mesg))>0) {
+ buf = H5MM_xmalloc (size);
+ if ((type->encode)(f, buf, mesg)<0) {
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTENCODE, FAIL,
+ "unable to encode message");
+ }
+ if (H5HG_insert (f, size, buf, hobj)<0) {
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
+ "unable to store message in global heap");
+ }
+ }
+ ret_value = SUCCEED;
+
+ done:
+ H5MM_xfree (buf);
+ FUNC_LEAVE (ret_value);
+}
+
/*-------------------------------------------------------------------------
* Function: H5O_debug
@@ -1463,12 +1628,14 @@ herr_t
H5O_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
intn fwidth)
{
- H5O_t *oh = NULL;
- intn i, chunkno;
- size_t mesg_total = 0, chunk_total = 0;
- int *sequence;
- haddr_t tmp_addr;
- herr_t ret_value = FAIL;
+ H5O_t *oh = NULL;
+ intn i, chunkno;
+ size_t mesg_total = 0, chunk_total = 0;
+ int *sequence;
+ haddr_t tmp_addr;
+ herr_t ret_value = FAIL;
+ void *(*decode)(H5F_t*, const uint8*, H5HG_t*);
+ herr_t (*debug)(H5F_t*, const void*, FILE*, intn, intn)=NULL;
FUNC_ENTER(H5O_debug, FAIL);
@@ -1540,6 +1707,7 @@ H5O_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
oh->mesg[i].type->id);
continue;
}
+
/* message name and size */
fprintf(stream, "%*s%-*s 0x%04x %s(%d)\n",
indent + 3, "", MAX(0, fwidth - 3),
@@ -1547,12 +1715,20 @@ H5O_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
(unsigned) (oh->mesg[i].type->id),
oh->mesg[i].type->name,
sequence[oh->mesg[i].type->id]++);
- 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),
+ "Shared message:",
+ (oh->mesg[i].flags & H5O_FLAG_SHARED) ? "Yes" : "No");
fprintf(stream, "%*s%-*s %s\n", indent + 3, "", MAX(0, fwidth - 3),
"Constant:",
- oh->mesg[i].constant ? "Yes" : "No");
+ (oh->mesg[i].flags & H5O_FLAG_CONSTANT) ? "Yes" : "No");
+ if (oh->mesg[i].flags & ~H5O_FLAG_BITS) {
+ fprintf (stream, "%*s%-*s 0x%02x\n", indent+3,"",MAX(0,fwidth-3),
+ "*** ADDITIONAL UNKNOWN FLAGS --->",
+ oh->mesg[i].flags & ~H5O_FLAG_BITS);
+ }
+ fprintf(stream, "%*s%-*s %lu bytes\n", indent+3, "", MAX(0,fwidth-3),
+ "Raw size in obj header:",
+ (unsigned long) (oh->mesg[i].raw_size));
fprintf(stream, "%*s%-*s %d\n", indent + 3, "", MAX(0, fwidth - 3),
"Chunk number:",
(int) (oh->mesg[i].chunkno));
@@ -1560,25 +1736,47 @@ H5O_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
if (chunkno < 0 || chunkno >= oh->nchunks) {
fprintf(stream, "*** BAD CHUNK NUMBER\n");
}
+
/* check the size */
if ((oh->mesg[i].raw + oh->mesg[i].raw_size >
oh->chunk[chunkno].image + oh->chunk[chunkno].size) ||
(oh->mesg[i].raw < oh->chunk[chunkno].image)) {
fprintf(stream, "*** BAD MESSAGE RAW ADDRESS\n");
}
+
/* decode the message */
if (NULL == oh->mesg[i].native && oh->mesg[i].type->decode) {
- oh->mesg[i].native = (oh->mesg[i].type->decode) (f,
- oh->mesg[i].raw_size,
- oh->mesg[i].raw);
+ if (oh->mesg[i].flags & H5O_FLAG_SHARED) {
+ decode = H5O_SHARED->decode;
+ debug = H5O_SHARED->debug;
+ } else {
+ decode = oh->mesg[i].type->decode;
+ debug = oh->mesg[i].type->debug;
+ }
+ oh->mesg[i].native = (decode)(f, oh->mesg[i].raw, NULL);
+ } else {
+ debug = NULL;
}
+
/* print the message */
- if (oh->mesg[i].type->debug) {
- (oh->mesg[i].type->debug)(f, oh->mesg[i].native, stream, indent+3,
- MAX(0, fwidth-3));
+ if (debug) {
+ (debug)(f, oh->mesg[i].native, stream, indent+3, MAX(0, fwidth-3));
} else {
fprintf(stream, "%*sNo info for this message.\n", indent + 3, "");
}
+
+ /* If the message is shared then also print the pointed-to message */
+ if (oh->mesg[i].flags & H5O_FLAG_SHARED) {
+ void *p = H5HG_read (f, oh->mesg[i].native, NULL);
+ void *mesg = (oh->mesg[i].type->decode)(f, p, oh->mesg[i].native);
+ if (oh->mesg[i].type->debug) {
+ (oh->mesg[i].type->debug)(f, mesg, stream, indent+3,
+ MAX (0, fwidth-3));
+ }
+ H5O_reset (oh->mesg[i].type, mesg);
+ H5MM_xfree (mesg);
+ H5MM_xfree (p);
+ }
}
sequence = H5MM_xfree(sequence);
diff --git a/src/H5Ocont.c b/src/H5Ocont.c
index b3226e2..5d59875 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -25,9 +25,8 @@
#define PABLO_MASK H5O_cont_mask
/* PRIVATE PROTOTYPES */
-static void *H5O_cont_decode(H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_cont_encode(H5F_t *f, size_t size, uint8 *p,
- const void *_mesg);
+static void *H5O_cont_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
+static herr_t H5O_cont_encode(H5F_t *f, uint8 *p, const void *_mesg);
static herr_t H5O_cont_debug(H5F_t *f, const void *_mesg, FILE * stream,
intn indent, intn fwidth);
@@ -41,6 +40,7 @@ const H5O_class_t H5O_CONT[1] = {{
NULL, /*no copy method */
NULL, /*no size method */
NULL, /*default reset method */
+ NULL, /*no share method */
H5O_cont_debug, /*debugging */
}};
@@ -65,8 +65,8 @@ static intn interface_initialize_g = FALSE;
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_cont_decode(H5F_t *f, size_t raw_size, const uint8 *p)
+static void *
+H5O_cont_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj)
{
H5O_cont_t *cont = NULL;
@@ -74,8 +74,8 @@ H5O_cont_decode(H5F_t *f, size_t raw_size, const uint8 *p)
/* check args */
assert(f);
- assert(raw_size == H5O_ALIGN (H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f)));
assert(p);
+ assert (!hobj || !H5HG_defined (hobj));
/* decode */
cont = H5MM_xcalloc(1, sizeof(H5O_cont_t));
@@ -103,7 +103,7 @@ H5O_cont_decode(H5F_t *f, size_t raw_size, const uint8 *p)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_cont_encode(H5F_t *f, size_t size, uint8 *p, const void *_mesg)
+H5O_cont_encode(H5F_t *f, uint8 *p, const void *_mesg)
{
const H5O_cont_t *cont = (const H5O_cont_t *) _mesg;
@@ -111,7 +111,6 @@ H5O_cont_encode(H5F_t *f, size_t size, uint8 *p, const void *_mesg)
/* check args */
assert(f);
- assert(size == H5O_ALIGN (H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f)));
assert(p);
assert(cont);
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index fe30d00..c3b46cd 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -28,29 +28,28 @@ static char RcsId[] = "@(#)$Revision$";
#define PABLO_MASK H5O_dtype_mask
/* PRIVATE PROTOTYPES */
-static herr_t H5O_dtype_encode(H5F_t *f, size_t raw_size, uint8 *p,
- const void *mesg);
-static void *H5O_dtype_decode(H5F_t *f, size_t raw_size, const uint8 *p);
-static void *H5O_dtype_copy(const void *_mesg, void *_dest);
-static size_t H5O_dtype_size(H5F_t *f, const void *_mesg);
-static herr_t H5O_dtype_reset(void *_mesg);
-static herr_t H5O_dtype_debug(H5F_t *f, const void *_mesg,
- FILE * stream, intn indent, intn fwidth);
+static herr_t H5O_dtype_encode (H5F_t *f, uint8 *p, const void *mesg);
+static void *H5O_dtype_decode (H5F_t *f, const uint8 *p, H5HG_t *hobj);
+static void *H5O_dtype_copy (const void *_mesg, void *_dest);
+static size_t H5O_dtype_size (H5F_t *f, const void *_mesg);
+static herr_t H5O_dtype_reset (void *_mesg);
+static herr_t H5O_dtype_debug (H5F_t *f, const void *_mesg,
+ FILE * stream, intn indent, intn fwidth);
+static herr_t H5O_dtype_share (H5F_t *f, const void *_mesg, H5HG_t *hobj);
/* This message derives from H5O */
-const H5O_class_t H5O_DTYPE[1] =
-{
- {
- H5O_DTYPE_ID, /* message id number */
- "data_type", /* message name for debugging */
- sizeof(H5T_t), /* native message size */
- H5O_dtype_decode, /* decode message */
- H5O_dtype_encode, /* encode message */
- H5O_dtype_copy, /* copy the native value */
- H5O_dtype_size, /* size of raw message */
- H5O_dtype_reset, /* reset method */
- H5O_dtype_debug, /* debug the message */
- }};
+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 */
+ H5O_dtype_decode, /* decode message */
+ H5O_dtype_encode, /* encode message */
+ H5O_dtype_copy, /* copy the native value */
+ H5O_dtype_size, /* size of raw message */
+ H5O_dtype_reset, /* reset method */
+ H5O_dtype_share, /* share method */
+ H5O_dtype_debug, /* debug the message */
+}};
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
@@ -436,8 +435,8 @@ H5O_dtype_encode_helper(uint8 **pp, const H5T_t *dt)
into a struct in memory native format. The struct is allocated within this
function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
-static void *
-H5O_dtype_decode(H5F_t *f, size_t raw_size, const uint8 *p)
+static void *
+H5O_dtype_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj)
{
H5T_t *dt = NULL;
@@ -445,7 +444,6 @@ H5O_dtype_decode(H5F_t *f, size_t raw_size, const uint8 *p)
/* check args */
assert(f);
- assert(raw_size > 0);
assert(p);
dt = H5MM_xcalloc(1, sizeof(H5T_t));
@@ -455,7 +453,10 @@ H5O_dtype_decode(H5F_t *f, size_t raw_size, const uint8 *p)
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL,
"can't decode type");
}
- assert(raw_size == H5O_ALIGN (H5O_dtype_size(f, (void *) dt)));
+ if (hobj) {
+ dt->sh_heap = *hobj;
+ dt->sh_file = f;
+ }
FUNC_LEAVE(dt);
}
@@ -478,7 +479,7 @@ H5O_dtype_decode(H5F_t *f, size_t raw_size, const uint8 *p)
message in the "raw" disk form.
--------------------------------------------------------------------------*/
static herr_t
-H5O_dtype_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
+H5O_dtype_encode(H5F_t *f, uint8 *p, const void *mesg)
{
const H5T_t *dt = (const H5T_t *) mesg;
@@ -486,7 +487,6 @@ H5O_dtype_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
/* check args */
assert(f);
- assert(raw_size == H5O_ALIGN (H5O_dtype_size(f, mesg)));
assert(p);
assert(dt);
@@ -625,6 +625,45 @@ H5O_dtype_reset(void *_mesg)
FUNC_LEAVE(SUCCEED);
}
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_dtype_share
+ *
+ * Purpose: Returns, through argument HOBJ, whether a data type is shared
+ * in the specified file.
+ *
+ * Return: Success: SUCCEED if the data type is shared in file F,
+ * and HOBJ is set to the global heap address.
+ *
+ * Failure: FAIL if the data type is not shared, or
+ * shared but not in file F. The value of HOBJ
+ * is undefined.
+ *
+ * Programmer: Robb Matzke
+ * Thursday, April 2, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_dtype_share (H5F_t *f, const void *_mesg, H5HG_t *hobj/*out*/)
+{
+ const H5T_t *dt = (const H5T_t *)_mesg;
+
+ FUNC_ENTER (H5O_dtype_share, FAIL);
+
+ if (!H5HG_defined (&(dt->sh_heap)) ||
+ NULL==dt->sh_file ||
+ dt->sh_file->shared != f->shared) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "data type is not shared");
+ }
+
+ *hobj = dt->sh_heap;
+ FUNC_LEAVE (SUCCEED);
+}
+
/*--------------------------------------------------------------------------
NAME
H5O_dtype_debug
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index b4bdf19..18dd40d 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -14,9 +14,8 @@
#define PABLO_MASK H5O_efl_mask
/* PRIVATE PROTOTYPES */
-static void *H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_efl_encode(H5F_t *f, size_t size, uint8 *p,
- const void *_mesg);
+static void *H5O_efl_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
+static herr_t H5O_efl_encode(H5F_t *f, uint8 *p, const void *_mesg);
static void *H5O_efl_copy(const void *_mesg, void *_dest);
static size_t H5O_efl_size(H5F_t *f, const void *_mesg);
static herr_t H5O_efl_reset(void *_mesg);
@@ -33,6 +32,7 @@ const H5O_class_t H5O_EFL[1] = {{
H5O_efl_copy, /*copy native value */
H5O_efl_size, /*size of message on disk */
H5O_efl_reset, /*reset method */
+ NULL, /*no share method */
H5O_efl_debug, /*debug the message */
}};
@@ -59,7 +59,7 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
static void *
-H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p)
+H5O_efl_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj)
{
H5O_efl_t *mesg = NULL;
int i;
@@ -70,6 +70,7 @@ H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p)
/* Check args */
assert(f);
assert(p);
+ assert (!hobj || !H5HG_defined (hobj));
/* Decode the header */
mesg = H5MM_xcalloc(1, sizeof(H5O_efl_t));
@@ -122,7 +123,7 @@ H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_efl_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
+H5O_efl_encode(H5F_t *f, uint8 *p, const void *_mesg)
{
const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
int i;
@@ -134,7 +135,6 @@ H5O_efl_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
/* check args */
assert(f);
assert(mesg);
- assert(raw_size == H5O_ALIGN (H5O_efl_size(f, _mesg)));
assert(p);
/* Encode header */
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 71fe092..7949136 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -14,9 +14,8 @@
#include <H5Oprivate.h>
/* PRIVATE PROTOTYPES */
-static void *H5O_layout_decode(H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_layout_encode(H5F_t *f, size_t size, uint8 *p,
- const void *_mesg);
+static void *H5O_layout_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
+static herr_t H5O_layout_encode(H5F_t *f, uint8 *p, const void *_mesg);
static void *H5O_layout_copy(const void *_mesg, void *_dest);
static size_t H5O_layout_size(H5F_t *f, const void *_mesg);
static herr_t H5O_layout_debug(H5F_t *f, const void *_mesg, FILE * stream,
@@ -32,6 +31,7 @@ const H5O_class_t H5O_LAYOUT[1] = {{
H5O_layout_copy, /*copy the native value */
H5O_layout_size, /*size of message on disk */
NULL, /*reset method */
+ NULL, /*no share method */
H5O_layout_debug, /*debug the message */
}};
@@ -58,8 +58,8 @@ static hbool_t interface_initialize_g = FALSE;
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_layout_decode(H5F_t *f, size_t raw_size, const uint8 *p)
+static void *
+H5O_layout_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj)
{
H5O_layout_t *mesg = NULL;
intn i;
@@ -69,12 +69,12 @@ H5O_layout_decode(H5F_t *f, size_t raw_size, const uint8 *p)
/* check args */
assert(f);
assert(p);
+ assert (!hobj || !H5HG_defined (hobj));
/* decode */
mesg = H5MM_xcalloc(1, sizeof(H5O_layout_t));
H5F_addr_decode(f, &p, &(mesg->addr));
mesg->ndims = *p++;
- assert(raw_size == H5O_ALIGN (H5O_layout_size(f, mesg)));
/* Layout class */
mesg->type = *p++;
@@ -108,7 +108,7 @@ H5O_layout_decode(H5F_t *f, size_t raw_size, const uint8 *p)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_layout_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
+H5O_layout_encode(H5F_t *f, uint8 *p, const void *_mesg)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
int i;
@@ -119,7 +119,6 @@ H5O_layout_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
assert(f);
assert(mesg);
assert(mesg->ndims > 0 && mesg->ndims <= H5O_LAYOUT_NDIMS);
- assert(raw_size == H5O_ALIGN (H5O_layout_size(f, _mesg)));
assert(p);
/* data or B-tree address */
diff --git a/src/H5Oname.c b/src/H5Oname.c
index b36c550..cd7e144 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -22,9 +22,8 @@
#define PABLO_MASK H5O_name_mask
/* PRIVATE PROTOTYPES */
-static void *H5O_name_decode(H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_name_encode(H5F_t *f, size_t raw_size, uint8 *p,
- const void *_mesg);
+static void *H5O_name_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
+static herr_t H5O_name_encode(H5F_t *f, uint8 *p, const void *_mesg);
static void *H5O_name_copy(const void *_mesg, void *_dest);
static size_t H5O_name_size(H5F_t *f, const void *_mesg);
static herr_t H5O_name_reset(void *_mesg);
@@ -41,6 +40,7 @@ const H5O_class_t H5O_NAME[1] = {{
H5O_name_copy, /*copy the native value */
H5O_name_size, /*raw message size */
H5O_name_reset, /*free internal memory */
+ NULL, /*no share method */
H5O_name_debug, /*debug the message */
}};
@@ -67,23 +67,22 @@ static hbool_t interface_initialize_g = FALSE;
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_name_decode(H5F_t *f, size_t raw_size, const uint8 *p)
+static void *
+H5O_name_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj)
{
H5O_name_t *mesg;
- char *s;
FUNC_ENTER(H5O_name_decode, NULL);
/* check args */
assert(f);
assert(p);
+ assert (!hobj || !H5HG_defined (hobj));
/* decode */
mesg = H5MM_xcalloc(1, sizeof(H5O_name_t));
- s = H5MM_xmalloc(raw_size);
- HDmemcpy(s, p, raw_size);
- mesg->s = s;
+ mesg->s = H5MM_xmalloc (strlen ((const char*)p)+1);
+ strcpy (mesg->s, (const char*)p);
FUNC_LEAVE(mesg);
}
@@ -106,10 +105,9 @@ H5O_name_decode(H5F_t *f, size_t raw_size, const uint8 *p)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_name_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
+H5O_name_encode(H5F_t *f, uint8 *p, const void *_mesg)
{
const H5O_name_t *mesg = (const H5O_name_t *) _mesg;
- size_t size;
FUNC_ENTER(H5O_name_encode, FAIL);
@@ -118,14 +116,8 @@ H5O_name_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
assert(p);
assert(mesg && mesg->s);
- /* message size */
- size = HDstrlen(mesg->s) + 1;
- assert(size <= raw_size);
-
/* encode */
- HDmemcpy(p, mesg->s, size);
- HDmemset(p + size, 0, raw_size - size);
-
+ strcpy ((char*)p, mesg->s);
FUNC_LEAVE(SUCCEED);
}
@@ -255,10 +247,10 @@ H5O_name_reset(void *_mesg)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_name_debug(H5F_t *f, const void *_mesg, FILE * stream,
- intn indent, intn fwidth)
+H5O_name_debug(H5F_t *f, const void *_mesg, FILE *stream, intn indent,
+ intn fwidth)
{
- const H5O_name_t *mesg = (const H5O_name_t *) _mesg;
+ const H5O_name_t *mesg = (const H5O_name_t *)_mesg;
FUNC_ENTER(H5O_name_debug, FAIL);
diff --git a/src/H5Onull.c b/src/H5Onull.c
index 57cec41..b2b9136 100644
--- a/src/H5Onull.c
+++ b/src/H5Onull.c
@@ -29,5 +29,6 @@ const H5O_class_t H5O_NULL[1] = {{
NULL, /*no copy method */
NULL, /*no size method */
NULL, /*no reset method */
+ NULL, /*no share method */
NULL, /*no debug method */
}};
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index b20e6ed..90317fc 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -19,10 +19,11 @@
#include <H5Opublic.h>
-/* Private headers neede by this file */
+/* Private headers needed by this file */
#include <H5private.h>
#include <H5Fprivate.h>
#include <H5Gprivate.h>
+#include <H5HGprivate.h>
#include <H5Tprivate.h>
#include <H5Sprivate.h>
@@ -40,9 +41,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
+/* Flags which are part of a message */
+#define H5O_FLAG_CONSTANT 0x01
+#define H5O_FLAG_SHARED 0x02
+#define H5O_FLAG_BITS 0x03
#define H5O_VERSION 1
/*
@@ -64,21 +66,22 @@
4) /*reserved */
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*/
- void *(*decode) (H5F_t *, size_t, const uint8 *);
- herr_t (*encode) (H5F_t *, size_t, uint8 *, const void *);
- void *(*copy) (const void *, void *); /*copy native value */
- size_t (*raw_size) (H5F_t *, const void *); /*sizeof raw val */
- herr_t (*reset) (void *); /*free nested data structures*/
- herr_t (*debug) (H5F_t *, const void *, FILE *, intn, intn);
+ intn id; /*message type ID on disk */
+ const char *name; /*for debugging */
+ size_t native_size; /*size of native message */
+ void *(*decode)(H5F_t*, const uint8*, H5HG_t*);
+ herr_t (*encode)(H5F_t*, uint8*, const void*);
+ void *(*copy)(const void*, void*); /*copy native value */
+ size_t (*raw_size)(H5F_t*, const void*);/*sizeof raw val */
+ herr_t (*reset)(void *); /*free nested data structs */
+ herr_t (*share)(H5F_t*, const void*, H5HG_t*);
+ herr_t (*debug)(H5F_t*, const void*, FILE*, intn, intn);
} 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? */
+ uint8 flags; /*message flags */
void *native; /*native format message */
uint8 *raw; /*ptr to raw data */
size_t raw_size; /*size with alignment */
@@ -169,10 +172,20 @@ typedef struct H5O_layout_t {
extern const H5O_class_t H5O_NAME[1];
typedef struct H5O_name_t {
- const char *s; /*ptr to malloc'd memory */
+ char *s; /*ptr to malloc'd memory */
} H5O_name_t;
/*
+ * Shared object message. This message ID never really appears in an object
+ * header. Instead, bit 2 of the `Flags' field will be set and the ID field
+ * will be the ID of the pointed-to message.
+ */
+#define H5O_SHARED_ID 0x000f
+extern const H5O_class_t H5O_SHARED[1];
+
+typedef H5HG_t H5O_shared_t;
+
+/*
* Object header continuation message.
*/
#define H5O_CONT_ID 0x0010
@@ -211,6 +224,8 @@ 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_share (H5F_t *f, const H5O_class_t *type, const void *mesg,
+ H5HG_t *hobj/*out*/);
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 9818130..21d8f3c 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -25,9 +25,8 @@ static char RcsId[] = "@(#)$Revision$";
#define PABLO_MASK H5O_sdspace_mask
/* PRIVATE PROTOTYPES */
-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_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
+static herr_t H5O_sdspace_encode(H5F_t *f, uint8 *p, const void *_mesg);
static void *H5O_sdspace_copy(const void *_mesg, void *_dest);
static size_t H5O_sdspace_size(H5F_t *f, const void *_mesg);
static herr_t H5O_sdspace_debug(H5F_t *f, const void *_mesg,
@@ -43,6 +42,7 @@ const H5O_class_t H5O_SDSPACE[1] = {{
H5O_sdspace_copy, /* copy the native value */
H5O_sdspace_size, /* size of symbol table entry */
NULL, /* default reset method */
+ NULL, /* no share method */
H5O_sdspace_debug, /* debug the message */
}};
@@ -69,7 +69,7 @@ static hbool_t interface_initialize_g = FALSE;
within this function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
static void *
-H5O_sdspace_decode(H5F_t *f, size_t raw_size, const uint8 *p)
+H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj)
{
H5S_simple_t *sdim = NULL;/* New simple dimensionality structure */
uintn u; /* local counting variable */
@@ -79,8 +79,8 @@ H5O_sdspace_decode(H5F_t *f, size_t raw_size, const uint8 *p)
/* check args */
assert(f);
- assert(raw_size >= 8); /* at least the rank and flags must be present */
assert(p);
+ assert (!hobj || !H5HG_defined (hobj));
/* decode */
if ((sdim = H5MM_xcalloc(1, sizeof(H5S_simple_t))) != NULL) {
@@ -131,7 +131,7 @@ H5O_sdspace_decode(H5F_t *f, size_t raw_size, const uint8 *p)
dimensionality message in the "raw" disk form.
--------------------------------------------------------------------------*/
static herr_t
-H5O_sdspace_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
+H5O_sdspace_encode(H5F_t *f, uint8 *p, const void *mesg)
{
const H5S_simple_t *sdim = (const H5S_simple_t *) mesg;
uintn u; /* Local counting variable */
@@ -141,7 +141,6 @@ H5O_sdspace_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
/* check args */
assert(f);
- assert(raw_size >= 8); /* at least the rank & flags must be present */
assert(p);
assert(sdim);
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
new file mode 100644
index 0000000..a62a562
--- /dev/null
+++ b/src/H5Oshared.c
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Wednesday, April 1, 1998
+ *
+ * Purpose: Functions that operate on a shared message. The shared
+ * message doesn't ever actually appear in the object header as
+ * a normal message. Instead, if a message is shared, the
+ * H5O_FLAG_SHARED bit is set and the message body is that
+ * defined here for H5O_SHARED. The message ID is the ID of the
+ * pointed-to message and the pointed-to message is stored in
+ * the global heap.
+ */
+#include <H5private.h>
+#include <H5Eprivate.h>
+#include <H5MMprivate.h>
+#include <H5Oprivate.h>
+
+static void *H5O_shared_decode (H5F_t*, const uint8*, H5HG_t *hobj);
+static herr_t H5O_shared_encode (H5F_t*, uint8*, const void*);
+static size_t H5O_shared_size (H5F_t*, const void*);
+static herr_t H5O_shared_debug (H5F_t*, const void*, FILE*, intn, intn);
+
+/* This message derives from H5O */
+const H5O_class_t H5O_SHARED[1] = {{
+ H5O_SHARED_ID, /*message id number */
+ "shared", /*message name for debugging */
+ sizeof(H5O_shared_t), /*native message size */
+ H5O_shared_decode, /*decode method */
+ H5O_shared_encode, /*encode method */
+ NULL, /*no copy method */
+ H5O_shared_size, /*size method */
+ NULL, /*no reset method */
+ NULL, /*no share method */
+ H5O_shared_debug, /*debug method */
+}};
+
+/* Interface initialization */
+#define PABLO_MASK H5O_shared_mask
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_shared_decode
+ *
+ * Purpose: Decodes a shared object message and returns it.
+ *
+ * Return: Success: Ptr to a new shared object message.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, April 2, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5O_shared_decode (H5F_t *f, const uint8 *buf, H5HG_t *hobj)
+{
+ H5O_shared_t *mesg;
+
+ FUNC_ENTER (H5O_shared_decode, NULL);
+
+ /* Check args */
+ assert (f);
+ assert (buf);
+ assert (!hobj || !H5HG_defined (hobj));
+
+ /* Decode */
+ mesg = H5MM_xcalloc (1, sizeof *mesg);
+ H5F_addr_decode (f, &buf, &(mesg->addr));
+ INT32DECODE (buf, mesg->idx);
+
+ FUNC_LEAVE (mesg);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_shared_encode
+ *
+ * Purpose: Encodes message _MESG into buffer BUF.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, April 2, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_shared_encode (H5F_t *f, uint8 *buf/*out*/, const void *_mesg)
+{
+ const H5O_shared_t *mesg = (const H5O_shared_t *)_mesg;
+
+ FUNC_ENTER (H5O_shared_encode, FAIL);
+
+ /* Check args */
+ assert (f);
+ assert (buf);
+ assert (mesg);
+
+ /* Encode */
+ H5F_addr_encode (f, &buf, &(mesg->addr));
+ INT32ENCODE (buf, mesg->idx);
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_shared_size
+ *
+ * Purpose: Returns the length of a shared object message.
+ *
+ * Return: Success: Length
+ *
+ * Failure: 0
+ *
+ * Programmer: Robb Matzke
+ * Thursday, April 2, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static size_t
+H5O_shared_size (H5F_t *f, const void *_mesg)
+{
+ FUNC_ENTER (H5O_shared_size, 0);
+ FUNC_LEAVE (H5F_SIZEOF_ADDR(f)+4);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_shared_debug
+ *
+ * Purpose: Prints debugging info for the message
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, April 2, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_shared_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent,
+ intn fwidth)
+{
+ const H5O_shared_t *mesg = (const H5O_shared_t *)_mesg;
+
+ FUNC_ENTER (H5O_shared_debug, FAIL);
+
+ /* Check args */
+ assert (f);
+ assert (mesg);
+ assert (stream);
+ assert (indent>=0);
+ assert (fwidth>=0);
+
+ fprintf (stream, "%*s%-*s ", indent, "", fwidth,
+ "Collection address:");
+ H5F_addr_print (stream, &(mesg->addr));
+ fprintf (stream, "\n");
+
+ fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Object ID within collection:",
+ mesg->idx);
+
+ FUNC_LEAVE (SUCCEED);
+}
diff --git a/src/H5Ostab.c b/src/H5Ostab.c
index 56d3955..a5b0dc7 100644
--- a/src/H5Ostab.c
+++ b/src/H5Ostab.c
@@ -23,9 +23,8 @@
#define PABLO_MASK H5O_stab_mask
/* PRIVATE PROTOTYPES */
-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_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
+static herr_t H5O_stab_encode(H5F_t *f, uint8 *p, const void *_mesg);
static void *H5O_stab_copy(const void *_mesg, void *_dest);
static size_t H5O_stab_size(H5F_t *f, const void *_mesg);
static herr_t H5O_stab_debug(H5F_t *f, const void *_mesg,
@@ -41,6 +40,7 @@ const H5O_class_t H5O_STAB[1] = {{
H5O_stab_copy, /*copy the native value */
H5O_stab_size, /*size of symbol table entry */
NULL, /*default reset method */
+ NULL, /*no share method */
H5O_stab_debug, /*debug the message */
}};
@@ -67,7 +67,7 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
static void *
-H5O_stab_decode(H5F_t *f, size_t raw_size, const uint8 *p)
+H5O_stab_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj)
{
H5O_stab_t *stab;
@@ -75,8 +75,8 @@ H5O_stab_decode(H5F_t *f, size_t raw_size, const uint8 *p)
/* check args */
assert(f);
- assert(raw_size == H5O_ALIGN (2 * H5F_SIZEOF_ADDR(f)));
assert(p);
+ assert (!hobj || !H5HG_defined (hobj));
/* decode */
stab = H5MM_xcalloc(1, sizeof(H5O_stab_t));
@@ -104,7 +104,7 @@ H5O_stab_decode(H5F_t *f, size_t raw_size, const uint8 *p)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_stab_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
+H5O_stab_encode(H5F_t *f, uint8 *p, const void *_mesg)
{
const H5O_stab_t *stab = (const H5O_stab_t *) _mesg;
@@ -112,7 +112,6 @@ H5O_stab_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
/* check args */
assert(f);
- assert(raw_size == H5O_ALIGN (2 * H5F_SIZEOF_ADDR(f)));
assert(p);
assert(stab);
diff --git a/src/H5T.c b/src/H5T.c
index fe23b04..be72fa6 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -1,16 +1,10 @@
/*
- *
-* NCSA HDF *
-* Software Development Group *
-* National Center for Supercomputing Applications *
-* University of Illinois at Urbana-Champaign *
-* 605 E. Springfield, Champaign IL 61820 *
-* *
-* For conditions of distribution and use, see the accompanying *
-* hdf/COPYING file. *
-* *
-****************************************************************************/
-
+ * Copyright (C) 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Tuesday, March 31, 1998
+ */
#ifdef RCSID
static char RcsId[] = "@(#)$Revision$";
#endif
@@ -19,7 +13,8 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5private.h> /*generic functions */
#include <H5Iprivate.h> /*ID functions */
-#include <H5Eprivate.h> /*error handling */
+#include <H5Eprivate.h> /*error handling */
+#include <H5HGprivate.h> /*global heap */
#include <H5MMprivate.h> /*memory management */
#include <H5Sprivate.h> /*data space */
#include <H5Tpkg.h> /*data-type functions */
@@ -29,47 +24,47 @@ static char RcsId[] = "@(#)$Revision$";
#define H5T_COMPND_INC 64 /*typical max numb of members per struct */
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = FALSE;
#define INTERFACE_INIT H5T_init_interface
-static void H5T_term_interface(void);
+static void H5T_term_interface(void);
/* Predefined types */
-hid_t H5T_NATIVE_CHAR_g = FAIL;
-hid_t H5T_NATIVE_UCHAR_g = FAIL;
-hid_t H5T_NATIVE_SHORT_g = FAIL;
-hid_t H5T_NATIVE_USHORT_g = FAIL;
-hid_t H5T_NATIVE_INT_g = FAIL;
-hid_t H5T_NATIVE_UINT_g = FAIL;
-hid_t H5T_NATIVE_LONG_g = FAIL;
-hid_t H5T_NATIVE_LLONG_g = FAIL;
-hid_t H5T_NATIVE_ULLONG_g = FAIL;
-hid_t H5T_NATIVE_HYPER_g = FAIL;
-hid_t H5T_NATIVE_UHYPER_g = FAIL;
-hid_t H5T_NATIVE_INT8_g = FAIL;
-hid_t H5T_NATIVE_UINT8_g = FAIL;
-hid_t H5T_NATIVE_INT16_g = FAIL;
-hid_t H5T_NATIVE_UINT16_g = FAIL;
-hid_t H5T_NATIVE_INT32_g = FAIL;
-hid_t H5T_NATIVE_UINT32_g = FAIL;
-hid_t H5T_NATIVE_INT64_g = FAIL;
-hid_t H5T_NATIVE_UINT64_g = FAIL;
-hid_t H5T_NATIVE_ULONG_g = FAIL;
-hid_t H5T_NATIVE_FLOAT_g = FAIL;
-hid_t H5T_NATIVE_DOUBLE_g = FAIL;
-hid_t H5T_NATIVE_TIME_g = FAIL;
-hid_t H5T_NATIVE_STRING_g = FAIL;
-hid_t H5T_NATIVE_BITFIELD_g = FAIL;
-hid_t H5T_NATIVE_OPAQUE_g = FAIL;
+hid_t H5T_NATIVE_CHAR_g = FAIL;
+hid_t H5T_NATIVE_UCHAR_g = FAIL;
+hid_t H5T_NATIVE_SHORT_g = FAIL;
+hid_t H5T_NATIVE_USHORT_g = FAIL;
+hid_t H5T_NATIVE_INT_g = FAIL;
+hid_t H5T_NATIVE_UINT_g = FAIL;
+hid_t H5T_NATIVE_LONG_g = FAIL;
+hid_t H5T_NATIVE_LLONG_g = FAIL;
+hid_t H5T_NATIVE_ULLONG_g = FAIL;
+hid_t H5T_NATIVE_HYPER_g = FAIL;
+hid_t H5T_NATIVE_UHYPER_g = FAIL;
+hid_t H5T_NATIVE_INT8_g = FAIL;
+hid_t H5T_NATIVE_UINT8_g = FAIL;
+hid_t H5T_NATIVE_INT16_g = FAIL;
+hid_t H5T_NATIVE_UINT16_g = FAIL;
+hid_t H5T_NATIVE_INT32_g = FAIL;
+hid_t H5T_NATIVE_UINT32_g = FAIL;
+hid_t H5T_NATIVE_INT64_g = FAIL;
+hid_t H5T_NATIVE_UINT64_g = FAIL;
+hid_t H5T_NATIVE_ULONG_g = FAIL;
+hid_t H5T_NATIVE_FLOAT_g = FAIL;
+hid_t H5T_NATIVE_DOUBLE_g = FAIL;
+hid_t H5T_NATIVE_TIME_g = FAIL;
+hid_t H5T_NATIVE_STRING_g = FAIL;
+hid_t H5T_NATIVE_BITFIELD_g = FAIL;
+hid_t H5T_NATIVE_OPAQUE_g = FAIL;
/* The path database */
-static intn H5T_npath_g = 0; /*num paths defined */
-static intn H5T_apath_g = 0; /*num slots allocated */
-static H5T_path_t *H5T_path_g = NULL; /*path array */
+static intn H5T_npath_g = 0; /*num paths defined */
+static intn H5T_apath_g = 0; /*num slots allocated */
+static H5T_path_t *H5T_path_g = NULL; /*path array */
/* The soft conversion function master list */
-static intn H5T_nsoft_g = 0; /*num soft funcs defined */
-static intn H5T_asoft_g = 0; /*num slots allocated */
-static H5T_soft_t *H5T_soft_g = NULL; /*master soft list */
+static intn H5T_nsoft_g = 0; /*num soft funcs defined */
+static intn H5T_asoft_g = 0; /*num slots allocated */
+static H5T_soft_t *H5T_soft_g = NULL; /*master soft list */
/*--------------------------------------------------------------------------
NAME
@@ -86,8 +81,8 @@ DESCRIPTION
herr_t
H5T_init_interface(void)
{
- H5T_t *dt = NULL;
- herr_t ret_value = SUCCEED;
+ H5T_t *dt = NULL;
+ herr_t ret_value = SUCCEED;
interface_initialize_g = TRUE;
FUNC_ENTER(H5T_init_interface, FAIL);
@@ -285,7 +280,7 @@ H5T_term_interface(void)
path->cdata.command = H5T_CONV_FREE;
if ((path->func)(FAIL, FAIL, &(path->cdata), 0, NULL, NULL)<0) {
#ifdef H5T_DEBUG
- fprintf (stderr, "HDF5-DIAG: conversion function failed "
+ fprintf (stderr, "H5T: conversion function failed "
"to free private data\n");
#endif
H5E_clear(); /*ignore the error*/
@@ -336,6 +331,7 @@ H5T_term_interface(void)
H5T_NATIVE_BITFIELD_g = FAIL;
H5T_NATIVE_OPAQUE_g = FAIL;
}
+
/*-------------------------------------------------------------------------
* Function: H5Tcreate
@@ -362,8 +358,8 @@ H5T_term_interface(void)
hid_t
H5Tcreate(H5T_class_t type, size_t size)
{
- H5T_t *dt = NULL;
- hid_t ret_value = FAIL;
+ H5T_t *dt = NULL;
+ hid_t ret_value = FAIL;
FUNC_ENTER(H5Tcreate, FAIL);
@@ -371,17 +367,21 @@ H5Tcreate(H5T_class_t type, size_t size)
if (size <= 0) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid size");
}
+
/* create the type */
if (NULL == (dt = H5T_create(type, size))) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't create type");
}
+
/* Make it an atom */
if ((ret_value = H5I_register(H5_DATATYPE, dt)) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
"can't register data type atom");
}
+
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tcopy
@@ -404,9 +404,9 @@ H5Tcreate(H5T_class_t type, size_t size)
hid_t
H5Tcopy(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_t *new_dt = NULL;
- hid_t ret_value = FAIL;
+ H5T_t *dt = NULL;
+ H5T_t *new_dt = NULL;
+ hid_t ret_value = FAIL;
FUNC_ENTER(H5Tcopy, FAIL);
@@ -420,14 +420,17 @@ H5Tcopy(hid_t type_id)
if (NULL == (new_dt = H5T_copy(dt))) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't copy");
}
- /* atomize result */
+
+ /* Atomize result */
if ((ret_value = H5I_register(H5_DATATYPE, new_dt)) < 0) {
H5T_close(new_dt);
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
"can't register data type atom");
}
+
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tclose
@@ -448,7 +451,7 @@ H5Tcopy(hid_t type_id)
herr_t
H5Tclose(hid_t type_id)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tclose, FAIL);
@@ -460,12 +463,15 @@ H5Tclose(hid_t type_id)
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "predefined data type");
}
+
/* When the reference count reaches zero the resources are freed */
if (H5I_dec_ref(type_id) < 0) {
HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
}
+
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tequal
@@ -488,9 +494,9 @@ H5Tclose(hid_t type_id)
hbool_t
H5Tequal(hid_t type1_id, hid_t type2_id)
{
- const H5T_t *dt1 = NULL;
- const H5T_t *dt2 = NULL;
- hbool_t ret_value = FAIL;
+ const H5T_t *dt1 = NULL;
+ const H5T_t *dt2 = NULL;
+ hbool_t ret_value = FAIL;
FUNC_ENTER(H5Tequal, FAIL);
@@ -505,6 +511,7 @@ H5Tequal(hid_t type1_id, hid_t type2_id)
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tlock
@@ -530,7 +537,7 @@ H5Tequal(hid_t type1_id, hid_t type2_id)
herr_t
H5Tlock(hid_t type_id)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tlock, FAIL);
@@ -540,8 +547,10 @@ H5Tlock(hid_t type_id)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
dt->locked = TRUE;
+
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_class
@@ -563,7 +572,7 @@ H5Tlock(hid_t type_id)
H5T_class_t
H5Tget_class(hid_t type_id)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tget_class, H5T_NO_CLASS);
@@ -572,8 +581,10 @@ H5Tget_class(hid_t type_id)
NULL == (dt = H5I_object(type_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type");
}
+
FUNC_LEAVE(dt->type);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_size
@@ -596,8 +607,8 @@ H5Tget_class(hid_t type_id)
size_t
H5Tget_size(hid_t type_id)
{
- H5T_t *dt = NULL;
- size_t size;
+ H5T_t *dt = NULL;
+ size_t size;
FUNC_ENTER(H5Tget_size, 0);
@@ -606,11 +617,13 @@ H5Tget_size(hid_t type_id)
NULL == (dt = H5I_object(type_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data type");
}
+
/* size */
size = H5T_get_size(dt);
FUNC_LEAVE(size);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tset_size
@@ -643,8 +656,8 @@ H5Tget_size(hid_t type_id)
herr_t
H5Tset_size(hid_t type_id, size_t size)
{
- H5T_t *dt = NULL;
- size_t prec, offset;
+ H5T_t *dt = NULL;
+ size_t prec, offset;
FUNC_ENTER(H5Tset_size, FAIL);
@@ -713,12 +726,14 @@ H5Tset_size(hid_t type_id, size_t size)
}
/* Commit */
+ H5T_unshare (dt);
dt->size = size;
dt->u.atomic.offset = offset;
dt->u.atomic.prec = prec;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_order
@@ -739,8 +754,8 @@ H5Tset_size(hid_t type_id, size_t size)
H5T_order_t
H5Tget_order(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_order_t order;
+ H5T_t *dt = NULL;
+ H5T_order_t order;
FUNC_ENTER(H5Tget_order, H5T_ORDER_ERROR);
@@ -751,11 +766,13 @@ H5Tget_order(hid_t type_id)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR,
"not an atomic data type");
}
- /* order */
+
+ /* Order */
order = dt->u.atomic.order;
FUNC_LEAVE(order);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tset_order
@@ -776,7 +793,7 @@ H5Tget_order(hid_t type_id)
herr_t
H5Tset_order(hid_t type_id, H5T_order_t order)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_order, FAIL);
@@ -792,10 +809,13 @@ H5Tset_order(hid_t type_id, H5T_order_t order)
if (order < 0 || order > H5T_ORDER_NONE) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal byte order");
}
- /* order */
+
+ /* Commit */
+ H5T_unshare (dt);
dt->u.atomic.order = order;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_precision
@@ -820,8 +840,8 @@ H5Tset_order(hid_t type_id, H5T_order_t order)
size_t
H5Tget_precision(hid_t type_id)
{
- H5T_t *dt = NULL;
- size_t prec;
+ H5T_t *dt = NULL;
+ size_t prec;
FUNC_ENTER(H5Tget_precision, 0);
@@ -831,11 +851,13 @@ H5Tget_precision(hid_t type_id)
!H5T_is_atomic(dt)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an atomic data type");
}
- /* precision */
+
+ /* Precision */
prec = dt->u.atomic.prec;
FUNC_LEAVE(prec);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tset_precision
@@ -870,8 +892,8 @@ H5Tget_precision(hid_t type_id)
herr_t
H5Tset_precision(hid_t type_id, size_t prec)
{
- H5T_t *dt = NULL;
- size_t offset, size;
+ H5T_t *dt = NULL;
+ size_t offset, size;
FUNC_ENTER(H5Tset_prec, FAIL);
@@ -888,6 +910,7 @@ H5Tset_precision(hid_t type_id, size_t prec)
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"precision must be positive");
}
+
/* Adjust the offset and size */
offset = dt->u.atomic.offset;
size = dt->size;
@@ -934,12 +957,14 @@ H5Tset_precision(hid_t type_id, size_t prec)
}
/* Commit */
+ H5T_unshare (dt);
dt->size = size;
dt->u.atomic.offset = offset;
dt->u.atomic.prec = prec;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_offset
@@ -976,8 +1001,8 @@ H5Tset_precision(hid_t type_id, size_t prec)
size_t
H5Tget_offset(hid_t type_id)
{
- H5T_t *dt = NULL;
- size_t offset;
+ H5T_t *dt = NULL;
+ size_t offset;
FUNC_ENTER(H5Tget_offset, 0);
@@ -987,11 +1012,13 @@ H5Tget_offset(hid_t type_id)
!H5T_is_atomic(dt)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an atomic data type");
}
- /* offset */
+
+ /* Offset */
offset = dt->u.atomic.offset;
FUNC_LEAVE(offset);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tset_offset
@@ -1035,7 +1062,7 @@ H5Tget_offset(hid_t type_id)
herr_t
H5Tset_offset(hid_t type_id, size_t offset)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_offset, FAIL);
@@ -1052,15 +1079,19 @@ H5Tset_offset(hid_t type_id, size_t offset)
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"offset must be zero for this type");
}
+
/* Adjust the size */
if (offset + dt->u.atomic.prec > 8 * dt->size) {
dt->size = (offset + dt->u.atomic.prec + 7) / 8;
}
+
/* Commit */
+ H5T_unshare (dt);
dt->u.atomic.offset = offset;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_pad
@@ -1081,9 +1112,9 @@ H5Tset_offset(hid_t type_id, size_t offset)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tget_pad(hid_t type_id, H5T_pad_t *lsb /*out */ , H5T_pad_t *msb /*out */ )
+H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tget_pad, FAIL);
@@ -1093,14 +1124,14 @@ H5Tget_pad(hid_t type_id, H5T_pad_t *lsb /*out */ , H5T_pad_t *msb /*out */ )
!H5T_is_atomic(dt)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
}
+
/* Get values */
- if (lsb)
- *lsb = dt->u.atomic.lsb_pad;
- if (msb)
- *msb = dt->u.atomic.msb_pad;
+ if (lsb) *lsb = dt->u.atomic.lsb_pad;
+ if (msb) *msb = dt->u.atomic.msb_pad;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tset_pad
@@ -1121,7 +1152,7 @@ H5Tget_pad(hid_t type_id, H5T_pad_t *lsb /*out */ , H5T_pad_t *msb /*out */ )
herr_t
H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_pad, FAIL);
@@ -1137,11 +1168,15 @@ H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb)
if (lsb < 0 || lsb >= H5T_NPAD || msb < 0 || msb >= H5T_NPAD) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pad type");
}
+
+ /* Commit */
+ H5T_unshare (dt);
dt->u.atomic.lsb_pad = lsb;
dt->u.atomic.msb_pad = msb;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_sign
@@ -1162,8 +1197,8 @@ H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb)
H5T_sign_t
H5Tget_sign(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_sign_t sign;
+ H5T_t *dt = NULL;
+ H5T_sign_t sign;
FUNC_ENTER(H5Tget_sign, H5T_SGN_ERROR);
@@ -1174,11 +1209,13 @@ H5Tget_sign(hid_t type_id)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_SGN_ERROR,
"not an integer data type");
}
- /* sign */
+
+ /* Sign */
sign = dt->u.atomic.u.i.sign;
FUNC_LEAVE(sign);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tset_sign
@@ -1199,7 +1236,7 @@ H5Tget_sign(hid_t type_id)
herr_t
H5Tset_sign(hid_t type_id, H5T_sign_t sign)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_sign, FAIL);
@@ -1215,10 +1252,13 @@ H5Tset_sign(hid_t type_id, H5T_sign_t sign)
if (sign < 0 || sign >= H5T_NSGN) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal sign type");
}
- /* sign */
+
+ /* Commit */
+ H5T_unshare (dt);
dt->u.atomic.u.i.sign = sign;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_fields
@@ -1243,11 +1283,11 @@ H5Tset_sign(hid_t type_id, H5T_sign_t sign)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tget_fields(hid_t type_id, size_t *spos /*out */ ,
- size_t *epos /*out */ , size_t *esize /*out */ ,
- size_t *mpos /*out */ , size_t *msize /*out */ )
+H5Tget_fields(hid_t type_id, size_t *spos/*out*/,
+ size_t *epos/*out*/, size_t *esize/*out*/,
+ size_t *mpos/*out*/, size_t *msize/*out*/)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tget_fields, FAIL);
@@ -1258,20 +1298,17 @@ H5Tget_fields(hid_t type_id, size_t *spos /*out */ ,
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a floating-point data type");
}
+
/* Get values */
- if (spos)
- *spos = dt->u.atomic.u.f.sign;
- if (epos)
- *epos = dt->u.atomic.u.f.epos;
- if (esize)
- *esize = dt->u.atomic.u.f.esize;
- if (mpos)
- *mpos = dt->u.atomic.u.f.mpos;
- if (msize)
- *msize = dt->u.atomic.u.f.msize;
+ if (spos) *spos = dt->u.atomic.u.f.sign;
+ if (epos) *epos = dt->u.atomic.u.f.epos;
+ if (esize) *esize = dt->u.atomic.u.f.esize;
+ if (mpos) *mpos = dt->u.atomic.u.f.mpos;
+ if (msize) *msize = dt->u.atomic.u.f.msize;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tset_fields
@@ -1299,7 +1336,7 @@ herr_t
H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize,
size_t mpos, size_t msize)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_fields, FAIL);
@@ -1325,6 +1362,7 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize,
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"sign location is not valid");
}
+
/* Check for overlap */
if (spos >= epos && spos < epos + esize) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
@@ -1339,7 +1377,9 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize,
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"exponent and mantissa fields overlap");
}
+
/* Commit */
+ H5T_unshare (dt);
dt->u.atomic.u.f.sign = spos;
dt->u.atomic.u.f.epos = epos;
dt->u.atomic.u.f.mpos = mpos;
@@ -1348,6 +1388,7 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize,
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_ebias
@@ -1368,8 +1409,8 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize,
size_t
H5Tget_ebias(hid_t type_id)
{
- H5T_t *dt = NULL;
- size_t ebias;
+ H5T_t *dt = NULL;
+ size_t ebias;
FUNC_ENTER(H5Tget_ebias, 0);
@@ -1380,11 +1421,13 @@ H5Tget_ebias(hid_t type_id)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0,
"not a floating-point data type");
}
+
/* bias */
ebias = dt->u.atomic.u.f.ebias;
FUNC_LEAVE(ebias);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tset_ebias
@@ -1405,7 +1448,7 @@ H5Tget_ebias(hid_t type_id)
herr_t
H5Tset_ebias(hid_t type_id, size_t ebias)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_ebias, FAIL);
@@ -1419,10 +1462,14 @@ H5Tset_ebias(hid_t type_id, size_t ebias)
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
+
+ /* Commit */
+ H5T_unshare (dt);
dt->u.atomic.u.f.ebias = ebias;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_norm
@@ -1444,8 +1491,8 @@ H5Tset_ebias(hid_t type_id, size_t ebias)
H5T_norm_t
H5Tget_norm(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_norm_t norm;
+ H5T_t *dt = NULL;
+ H5T_norm_t norm;
FUNC_ENTER(H5Tget_norm, H5T_NORM_ERROR);
@@ -1456,11 +1503,13 @@ H5Tget_norm(hid_t type_id)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR,
"not a floating-point data type");
}
+
/* norm */
norm = dt->u.atomic.u.f.norm;
FUNC_LEAVE(norm);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tset_norm
@@ -1482,7 +1531,7 @@ H5Tget_norm(hid_t type_id)
herr_t
H5Tset_norm(hid_t type_id, H5T_norm_t norm)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_norm, FAIL);
@@ -1499,10 +1548,13 @@ H5Tset_norm(hid_t type_id, H5T_norm_t norm)
if (norm < 0 || norm > H5T_NORM_NONE) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization");
}
- /* norm */
+
+ /* Commit */
+ H5T_unshare (dt);
dt->u.atomic.u.f.norm = norm;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_inpad
@@ -1526,8 +1578,8 @@ H5Tset_norm(hid_t type_id, H5T_norm_t norm)
H5T_pad_t
H5Tget_inpad(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_pad_t pad;
+ H5T_t *dt = NULL;
+ H5T_pad_t pad;
FUNC_ENTER(H5Tget_inpad, H5T_PAD_ERROR);
@@ -1538,11 +1590,13 @@ H5Tget_inpad(hid_t type_id)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR,
"not a floating-point data type");
}
+
/* pad */
pad = dt->u.atomic.u.f.pad;
FUNC_LEAVE(pad);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tset_inpad
@@ -1566,7 +1620,7 @@ H5Tget_inpad(hid_t type_id)
herr_t
H5Tset_inpad(hid_t type_id, H5T_pad_t pad)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_inpad, FAIL);
@@ -1584,10 +1638,13 @@ H5Tset_inpad(hid_t type_id, H5T_pad_t pad)
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"illegal internal pad type");
}
- /* pad */
+
+ /* Commit */
+ H5T_unshare (dt);
dt->u.atomic.u.f.pad = pad;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_cset
@@ -1610,8 +1667,8 @@ H5Tset_inpad(hid_t type_id, H5T_pad_t pad)
H5T_cset_t
H5Tget_cset(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_cset_t cset;
+ H5T_t *dt = NULL;
+ H5T_cset_t cset;
FUNC_ENTER(H5Tget_cset, H5T_CSET_ERROR);
@@ -1622,11 +1679,13 @@ H5Tget_cset(hid_t type_id)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR,
"not a string data type");
}
+
/* result */
cset = dt->u.atomic.u.s.cset;
FUNC_LEAVE(cset);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tset_cset
@@ -1649,7 +1708,7 @@ H5Tget_cset(hid_t type_id)
herr_t
H5Tset_cset(hid_t type_id, H5T_cset_t cset)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_cset, FAIL);
@@ -1666,10 +1725,13 @@ H5Tset_cset(hid_t type_id, H5T_cset_t cset)
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"illegal character set type");
}
- /* set */
+
+ /* Commit */
+ H5T_unshare (dt);
dt->u.atomic.u.s.cset = cset;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_strpad
@@ -1693,8 +1755,8 @@ H5Tset_cset(hid_t type_id, H5T_cset_t cset)
H5T_str_t
H5Tget_strpad(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_str_t strpad;
+ H5T_t *dt = NULL;
+ H5T_str_t strpad;
FUNC_ENTER(H5Tget_strpad, H5T_STR_ERROR);
@@ -1705,11 +1767,13 @@ H5Tget_strpad(hid_t type_id)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_STR_ERROR,
"not a string data type");
}
+
/* result */
strpad = dt->u.atomic.u.s.pad;
FUNC_LEAVE(strpad);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tset_strpad
@@ -1733,7 +1797,7 @@ H5Tget_strpad(hid_t type_id)
herr_t
H5Tset_strpad(hid_t type_id, H5T_str_t strpad)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_strpad, FAIL);
@@ -1749,10 +1813,13 @@ H5Tset_strpad(hid_t type_id, H5T_str_t strpad)
if (strpad < 0 || strpad >= H5T_NSTR) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal string pad type");
}
- /* set */
+
+ /* Commit */
+ H5T_unshare (dt);
dt->u.atomic.u.s.pad = strpad;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_nmembers
@@ -1777,7 +1844,7 @@ int
H5Tget_nmembers(hid_t type_id)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tget_num_members, FAIL);
@@ -1787,8 +1854,10 @@ H5Tget_nmembers(hid_t type_id)
H5T_COMPOUND != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
}
+
FUNC_LEAVE(dt->u.compnd.nmembs);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_member_name
@@ -1813,8 +1882,8 @@ H5Tget_nmembers(hid_t type_id)
char *
H5Tget_member_name(hid_t type_id, int membno)
{
- H5T_t *dt = NULL;
- char *s = NULL;
+ H5T_t *dt = NULL;
+ char *s = NULL;
FUNC_ENTER(H5Tget_member_name, NULL);
@@ -1827,9 +1896,12 @@ H5Tget_member_name(hid_t type_id, int membno)
if (membno < 0 || membno >= dt->u.compnd.nmembs) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number");
}
+
+ /* Value */
s = H5MM_xstrdup(dt->u.compnd.memb[membno].name);
FUNC_LEAVE(s);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_member_offset
@@ -1854,8 +1926,8 @@ H5Tget_member_name(hid_t type_id, int membno)
size_t
H5Tget_member_offset(hid_t type_id, int membno)
{
- H5T_t *dt = NULL;
- size_t offset = 0;
+ H5T_t *dt = NULL;
+ size_t offset = 0;
FUNC_ENTER(H5Tget_member_offset, 0);
@@ -1868,9 +1940,13 @@ H5Tget_member_offset(hid_t type_id, int membno)
if (membno < 0 || membno >= dt->u.compnd.nmembs) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number");
}
+
+ /* Value */
offset = dt->u.compnd.memb[membno].offset;
+
FUNC_LEAVE(offset);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_member_dims
@@ -1895,8 +1971,8 @@ int
H5Tget_member_dims(hid_t type_id, int membno,
size_t dims[]/*out*/, int perm[]/*out*/)
{
- H5T_t *dt = NULL;
- intn ndims, i;
+ H5T_t *dt = NULL;
+ intn ndims, i;
FUNC_ENTER(H5Tget_member_dims, FAIL);
@@ -1909,16 +1985,17 @@ H5Tget_member_dims(hid_t type_id, int membno,
if (membno < 0 || membno >= dt->u.compnd.nmembs) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number");
}
+
+ /* Value */
ndims = dt->u.compnd.memb[membno].ndims;
for (i = 0; i < ndims; i++) {
- if (dims[i])
- dims[i] = dt->u.compnd.memb[membno].dim[i];
- if (perm[i])
- perm[i] = dt->u.compnd.memb[membno].perm[i];
+ if (dims[i]) dims[i] = dt->u.compnd.memb[membno].dim[i];
+ if (perm[i]) perm[i] = dt->u.compnd.memb[membno].perm[i];
}
FUNC_LEAVE(ndims);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tget_member_type
@@ -1943,8 +2020,8 @@ H5Tget_member_dims(hid_t type_id, int membno,
hid_t
H5Tget_member_type(hid_t type_id, int membno)
{
- H5T_t *dt = NULL, *memb_dt = NULL;
- hid_t memb_type_id;
+ H5T_t *dt = NULL, *memb_dt = NULL;
+ hid_t memb_type_id;
FUNC_ENTER(H5Tget_member_type, FAIL);
@@ -1957,6 +2034,7 @@ H5Tget_member_type(hid_t type_id, int membno)
if (membno < 0 || membno >= dt->u.compnd.nmembs) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number");
}
+
/* Copy data type into an atom */
if (NULL == (memb_dt = H5T_copy(dt->u.compnd.memb[membno].type))) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
@@ -1967,8 +2045,10 @@ H5Tget_member_type(hid_t type_id, int membno)
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
"can't register data type atom");
}
+
FUNC_LEAVE(memb_type_id);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tinsert
@@ -2001,8 +2081,8 @@ H5Tget_member_type(hid_t type_id, int membno)
herr_t
H5Tinsert(hid_t parent_id, const char *name, off_t offset, hid_t member_id)
{
- H5T_t *parent = NULL; /*the compound parent data type */
- H5T_t *member = NULL; /*the atomic member type */
+ H5T_t *parent = NULL; /*the compound parent data type */
+ H5T_t *member = NULL; /*the atomic member type */
FUNC_ENTER(H5Tinsert, FAIL);
@@ -2022,12 +2102,16 @@ H5Tinsert(hid_t parent_id, const char *name, off_t offset, hid_t member_id)
NULL == (member = H5I_object(member_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
+
+ /* Insert */
if (H5T_insert(parent, name, offset, member) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
"can't insert member");
}
+
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tpack
@@ -2049,7 +2133,7 @@ H5Tinsert(hid_t parent_id, const char *name, off_t offset, hid_t member_id)
herr_t
H5Tpack(hid_t type_id)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5Tpack, FAIL);
@@ -2062,12 +2146,64 @@ H5Tpack(hid_t type_id)
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "data type is read-only");
}
+
+ /* Pack */
if (H5T_pack(dt) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to pack compound data type");
}
+
FUNC_LEAVE(SUCCEED);
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tshare
+ *
+ * Purpose: Marks a data type as sharable. Using the type during the
+ * creation of a dataset will cause the dataset object header to
+ * point to the type in the global heap instead of containing
+ * the type directly in its object header. Subsequent
+ * modifications to a shared type cause the type to become
+ * unshared.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, March 31, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Tshare (hid_t loc_id, hid_t type_id)
+{
+ H5G_t *loc = NULL;
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER (H5Tshare, FAIL);
+
+ /* Check arguments */
+ if (NULL==(loc=H5G_loc (loc_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ }
+ if (H5_DATATYPE!=H5I_group (type_id) ||
+ NULL==(dt=H5I_object (type_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+
+ /* Make it sharable */
+ if (H5T_share (H5G_fileof (loc), dt)<0) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to make data type sharable");
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
/*-------------------------------------------------------------------------
* Function: H5Tregister_hard
@@ -2217,7 +2353,7 @@ H5Tregister_soft(H5T_class_t src_cls, H5T_class_t dst_cls, H5T_conv_t func)
if ((path->func)(src_id, dst_id, &(path->cdata),
0, NULL, NULL)<0) {
#ifdef H5T_DEBUG
- fprintf (stderr, "HDF5-DIAG: conversion function failed "
+ fprintf (stderr, "H5T: conversion function failed "
"to free private data.\n");
#endif
H5E_clear();
@@ -2289,7 +2425,7 @@ H5Tunregister(H5T_conv_t func)
path->cdata.command = H5T_CONV_FREE;
if ((func)(FAIL, FAIL, &(path->cdata), 0, NULL, NULL)<0) {
#ifdef H5T_DEBUG
- fprintf (stderr, "HDF5-DIAG: conversion function failed to "
+ fprintf (stderr, "H5T: conversion function failed to "
"free private data.\n");
#endif
H5E_clear();
@@ -2364,8 +2500,8 @@ H5Tunregister(H5T_conv_t func)
H5T_conv_t
H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata)
{
- H5T_conv_t ret_value = NULL;
- H5T_t *src = NULL, *dst = NULL;
+ H5T_conv_t ret_value = NULL;
+ H5T_t *src = NULL, *dst = NULL;
FUNC_ENTER(H5Tfind, NULL);
@@ -2387,6 +2523,7 @@ H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata)
HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL,
"conversion function not found");
}
+
FUNC_LEAVE(ret_value);
}
@@ -2413,10 +2550,10 @@ H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata)
*
*-------------------------------------------------------------------------
*/
-H5T_t *
+H5T_t *
H5T_create(H5T_class_t type, size_t size)
{
- H5T_t *dt = NULL;
+ H5T_t *dt = NULL;
FUNC_ENTER(H5T_create, NULL);
@@ -2445,6 +2582,7 @@ H5T_create(H5T_class_t type, size_t size)
dt->size = size;
FUNC_LEAVE(dt);
}
+
/*-------------------------------------------------------------------------
* Function: H5T_copy
@@ -2466,9 +2604,9 @@ H5T_create(H5T_class_t type, size_t size)
H5T_t *
H5T_copy(const H5T_t *old_dt)
{
- H5T_t *new_dt=NULL, *tmp=NULL;
- intn i;
- char *s;
+ H5T_t *new_dt=NULL, *tmp=NULL;
+ intn i;
+ char *s;
FUNC_ENTER(H5T_copy, NULL);
@@ -2498,8 +2636,10 @@ H5T_copy(const H5T_t *old_dt)
new_dt->u.compnd.memb[i].type = tmp;
}
}
+
FUNC_LEAVE(new_dt);
}
+
/*-------------------------------------------------------------------------
* Function: H5T_close
@@ -2542,6 +2682,93 @@ H5T_close(H5T_t *dt)
FUNC_LEAVE(SUCCEED);
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_share
+ *
+ * Purpose: Causes a data type to be marked as sharable. If the data
+ * type isn't already marked sharable in the specified file then
+ * it is written to the global heap of that file and the heap
+ * location information is added to the sh_file and sh_heap
+ * fields of the data type.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, March 31, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5T_share (H5F_t *f, H5T_t *dt)
+{
+ FUNC_ENTER (H5T_share, FAIL);
+
+ /* Check args */
+ assert (f);
+ assert (dt);
+
+ /*
+ * If the type is sharable in some other file then unshare it first. A
+ * type can only be sharable in one file at a time.
+ */
+ if (H5HG_defined (&(dt->sh_heap)) && f->shared!=dt->sh_file->shared) {
+ H5T_unshare (dt);
+ H5E_clear (); /*don't really care if it fails*/
+ }
+
+ /*
+ * Write the message to the global heap if it isn't already shared in
+ * this file.
+ */
+ if (!H5HG_defined (&(dt->sh_heap))) {
+ if (H5O_share (f, H5O_DTYPE, dt, &(dt->sh_heap))<0) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to store data type message in global heap");
+ }
+ dt->sh_file = f;
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_unshare
+ *
+ * Purpose: If a data type is in the global heap then this function
+ * removes that information from the H5T_t struct.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, March 31, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5T_unshare (H5T_t *dt)
+{
+ FUNC_ENTER (H5T_unshare, FAIL);
+
+ /* Check args */
+ assert (dt);
+
+ H5HG_undef (&(dt->sh_heap));
+ dt->sh_file = NULL;
+
+ FUNC_LEAVE (SUCCEED);
+}
+
/*-------------------------------------------------------------------------
* Function: H5T_is_atomic
@@ -2568,6 +2795,7 @@ H5T_is_atomic(const H5T_t *dt)
FUNC_LEAVE(H5T_COMPOUND == dt->type ? FALSE : TRUE);
}
+
/*-------------------------------------------------------------------------
* Function: H5T_get_size
@@ -2597,6 +2825,7 @@ H5T_get_size(const H5T_t *dt)
FUNC_LEAVE(dt->size);
}
+
/*-------------------------------------------------------------------------
* Function: H5T_insert
@@ -2659,6 +2888,7 @@ H5T_insert(H5T_t *parent, const char *name, off_t offset, const H5T_t *member)
}
/* Add member to end of member array */
+ H5T_unshare (parent);
i = parent->u.compnd.nmembs;
parent->u.compnd.memb[i].name = H5MM_xstrdup(name);
parent->u.compnd.memb[i].offset = offset;
@@ -2668,6 +2898,7 @@ H5T_insert(H5T_t *parent, const char *name, off_t offset, const H5T_t *member)
parent->u.compnd.nmembs++;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5T_pack
@@ -2689,14 +2920,15 @@ H5T_insert(H5T_t *parent, const char *name, off_t offset, const H5T_t *member)
herr_t
H5T_pack(H5T_t *dt)
{
- int i;
- size_t offset;
+ int i;
+ size_t offset;
FUNC_ENTER(H5T_pack, FAIL);
assert(dt);
assert(!dt->locked);
+ H5T_unshare (dt);
if (H5T_COMPOUND == dt->type) {
/* Recursively pack the members */
for (i = 0; i < dt->u.compnd.nmembs; i++) {
@@ -2716,8 +2948,10 @@ H5T_pack(H5T_t *dt)
/* Change total size */
dt->size = MAX(1, offset);
}
+
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5T_sort_by_offset
@@ -2740,8 +2974,8 @@ H5T_pack(H5T_t *dt)
herr_t
H5T_sort_by_offset(H5T_t *dt)
{
- int i, j, nmembs;
- hbool_t swapped;
+ int i, j, nmembs;
+ hbool_t swapped;
FUNC_ENTER(H5T_sort_by_offset, FAIL);
@@ -2771,6 +3005,7 @@ H5T_sort_by_offset(H5T_t *dt)
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5T_cmp
@@ -2793,10 +3028,10 @@ H5T_sort_by_offset(H5T_t *dt)
intn
H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
{
- intn *idx1 = NULL, *idx2 = NULL;
- intn ret_value = 0;
- intn i, j, tmp;
- hbool_t swapped;
+ intn *idx1 = NULL, *idx2 = NULL;
+ intn ret_value = 0;
+ intn i, j, tmp;
+ hbool_t swapped;
FUNC_ENTER(H5T_equal, 0);
@@ -3016,6 +3251,7 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5T_find
*
@@ -3157,7 +3393,7 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, hbool_t create,
}
if ((func)(src_id, dst_id, &(path->cdata), 0, NULL, NULL)<0) {
#ifdef H5T_DEBUG
- fprintf (stderr, "HDF5-DIAG: conversion function init "
+ fprintf (stderr, "H5T: conversion function init "
"failed\n");
#endif
H5E_clear(); /*ignore the failure*/
@@ -3213,9 +3449,9 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, hbool_t create,
herr_t
H5T_debug(H5T_t *dt, FILE * stream)
{
- const char *s = "";
- int i, j;
- uint64 tmp;
+ const char *s = "";
+ int i, j;
+ uint64 tmp;
FUNC_ENTER(H5T_debug, FAIL);
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 02b7db3..0b4e86f 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -63,7 +63,7 @@ H5T_conv_noop(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
/* Nothing to free */
#ifdef H5T_DEBUG
if (cdata->ncalls>0) {
- fprintf (stderr, "HDF5-DIAG: H5T_conv_noop statistics...\n");
+ fprintf (stderr, "H5T: H5T_conv_noop statistics...\n");
fprintf (stderr, " Number of calls: %lu\n", cdata->ncalls);
fprintf (stderr, " Data points converted: %lu\n", cdata->nelmts);
}
@@ -174,7 +174,7 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
/* Free private data */
#ifdef H5T_DEBUG
if (cdata->ncalls>0) {
- fprintf (stderr, "HDF5-DIAG: H5T_conv_order statistics...\n");
+ fprintf (stderr, "H5T: H5T_conv_order statistics...\n");
fprintf (stderr, " Number of calls: %lu\n", cdata->ncalls);
fprintf (stderr, " Data points converted: %lu\n", cdata->nelmts);
}
@@ -396,7 +396,7 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
*/
#ifdef H5T_DEBUG
if (cdata->ncalls>0) {
- fprintf (stderr, "HDF5-DIAG: H5T_conv_struct statistics...\n");
+ fprintf (stderr, "H5T: H5T_conv_struct statistics...\n");
fprintf (stderr, " Number of calls: %lu\n", cdata->ncalls);
fprintf (stderr, " Data points converted: %lu\n", cdata->nelmts);
}
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
index be52256..84b1235 100644
--- a/src/H5Tpkg.h
+++ b/src/H5Tpkg.h
@@ -23,6 +23,7 @@
# undef H5T_DEBUG
#endif
+#include <H5HGprivate.h>
#include <H5Tprivate.h>
typedef struct H5T_atomic_t {
@@ -62,6 +63,8 @@ typedef struct H5T_compnd_t {
struct H5T_t {
hbool_t locked; /*if locked, then can't be modified */
+ H5HG_t sh_heap; /*if defined, type is in global heap */
+ H5F_t *sh_file; /*file pointer if this is a shared type */
H5T_class_t type; /*which class of type is this? */
size_t size; /*total size of an instance of this type */
union {
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index 7ff5d18..27d27f3 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -32,6 +32,8 @@ herr_t H5T_init_interface (void);
H5T_t *H5T_create (H5T_class_t type, size_t size);
H5T_t *H5T_copy (const H5T_t *old_dt);
herr_t H5T_close (H5T_t *dt);
+herr_t H5T_share (H5F_t *f, H5T_t *dt);
+herr_t H5T_unshare (H5T_t *dt);
size_t H5T_get_size (const H5T_t *dt);
intn H5T_cmp (const H5T_t *dt1, const H5T_t *dt2);
hbool_t H5T_is_atomic (const H5T_t *dt);
diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h
index f546200..f362cdf 100644
--- a/src/H5Tpublic.h
+++ b/src/H5Tpublic.h
@@ -184,6 +184,7 @@ hid_t H5Tcopy (hid_t type_id);
herr_t H5Tclose (hid_t type_id);
hbool_t H5Tequal (hid_t type1_id, hid_t type2_id);
herr_t H5Tlock (hid_t type_id);
+herr_t H5Tshare (hid_t location_id, hid_t type_id);
/* Operations defined on compound data types */
herr_t H5Tinsert (hid_t parent_id, const char *name, off_t offset,
diff --git a/src/Makefile.in b/src/Makefile.in
index 7c5a8a5..20b4ae3 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -20,7 +20,7 @@ LIB_SRC=H5.c H5AC.c H5B.c H5D.c H5E.c H5F.c H5Farray.c H5Fcore.c H5Ffamily.c \
H5Fistore.c H5Flow.c H5Fsec2.c H5Fsplit.c H5Fstdio.c H5G.c H5Gent.c \
H5Gnode.c H5Gstab.c H5HG.c H5HL.c H5I.c H5MF.c H5MM.c H5O.c H5Ocont.c \
H5Odtype.c H5Oefl.c H5Olayout.c H5Oname.c H5Onull.c H5Osdspace.c \
- H5Ostab.c H5P.c H5S.c H5Ssimp.c H5T.c H5Tconv.c H5Tinit.c \
+ H5Oshared.c H5Ostab.c H5P.c H5S.c H5Ssimp.c H5T.c H5Tconv.c H5Tinit.c \
H5V.c @PARALLEL_SRC@
LIB_OBJ=$(LIB_SRC:.c=.o)