[svn-r518] Changes since 19980720

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

./doc/html/H5.format.html
./src/H5Oattr.c
./src/H5Odtype.c
./src/H5Oefl.c
./src/H5Olayout.c
./src/H5Osdspace.c
./src/H5Oshared.c
	Added version numbers to some object header messages so we can
	update them easier in the future.  The library currently just
	gives up if the version numbers don't match, but in the future
	the library could handle multiple versions of a message.

./test/testhdf5.c
	Removed an argument from the H5version() call that I missed
	last time.
This commit is contained in:
Robb Matzke 1998-07-20 12:58:37 -05:00
parent 1dbacc8377
commit 34595bac3b
8 changed files with 214 additions and 71 deletions

View File

@ -1502,11 +1502,19 @@
<th width="25%">byte</th>
<th width="25%">byte</th>
<th width="25%">byte</th>
</tr>
<tr align=center>
<td colspan=4>Dimensionality</td>
<td>Version</td>
<td>Dimensionality</td>
<td>Flags</td>
<td>Reserved</td>
</tr>
<tr align=center>
<td colspan=4>Dimension Flags</td>
<td colspan=4>Reserved</td>
</tr>
<tr align=center>
<td colspan=4>Dimension Size #1 (&lt;size&gt; bytes)</td>
<tr align=center>
@ -1543,12 +1551,12 @@
</tr>
<tr valign=top>
<td>Dimension Flags</td>
<td>Flags</td>
<td>This field is used to store flags to indicate the
presence of parts of this message. Bit 0 (counting from
the right) is used to indicate that maximum dimensions are
present. Bit 1 is used to indicate that permutation
indices are present for each dimension.</td>
presence of parts of this message. Bit 0 (the least
significant bit) is used to indicate that maximum
dimensions are present. Bit 1 is used to indicate that
permutation indices are present for each dimension.</td>
</tr>
<tr valign=top>
@ -1935,7 +1943,7 @@
</tr>
<tr align=center>
<td>Type Class</td>
<td>Type Class and Version</td>
<td colspan=3>Class Bit Field</td>
</tr>
@ -1950,11 +1958,13 @@
</center>
<p>The Class Bit Field and Properties fields vary depending
on the Type Class. The type class is one of: 0 (fixed-point
number), 1 (floating-point number), 2 (date and time), 3 (text
string), 4 (bit field), 5 (opaque), 6 (compound). The Class Bit
Field is zero and the size of the Properties field is zero
except for the cases noted here.
on the Type Class, which is the low-order four bits of the Type
Class and Version field (the high-order four byte are the
version which should be set to the value one). The type class
is one of: 0 (fixed-point number), 1 (floating-point number), 2
(date and time), 3 (text string), 4 (bit field), 5 (opaque), 6
(compound). The Class Bit Field is zero and the size of the
Properties field is zero except for the cases noted here.
<p>
<center>
@ -2269,7 +2279,8 @@
</tr>
<tr align=center>
<td colspan=4><br>Heap Address<br><br></td>
<td>Version</td>
<td colspan=3>Reserved</td>
</tr>
<tr align=center>
@ -2278,7 +2289,7 @@
</tr>
<tr align=center>
<td colspan=4>Reserved</td>
<td colspan=4><br>Heap Address<br><br></td>
</tr>
<tr align=center>
@ -2451,17 +2462,18 @@
</tr>
<tr align=center>
<td colspan=4><br>Address<br><br></td>
</tr>
<tr align=center>
<td>Version</td>
<td>Dimensionality</td>
<td>Layout Class</td>
<td colspan=2>Reserved</td>
<td>Reserved</td>
</tr>
<tr align=center>
<td colspan=4>Reserved (4-bytes)</td>
<td colspan=4>Reserved</td>
</tr>
<tr align=center>
<td colspan=4><br>Address<br><br></td>
</tr>
<tr align=center>
@ -2487,11 +2499,9 @@
</tr>
<tr valign=top>
<td>Address</td>
<td>For contiguous storage, this is the address of the first
byte of storage. For chunked storage this is the address
of the B-tree that is used to look up the addresses of the
chunks.</td>
<td>Version</td>
<td>A version number for the layout message. This
documentation describes version one.</td>
</tr>
<tr valign=top>
@ -2510,6 +2520,14 @@
in the future.</td>
</tr>
<tr valign=top>
<td>Address</td>
<td>For contiguous storage, this is the address of the first
byte of storage. For chunked storage this is the address
of the B-tree that is used to look up the addresses of the
chunks.</td>
</tr>
<tr valign=top>
<td>Dimensions</td>
<td>For contiguous storage the dimensions define the entire
@ -2715,13 +2733,14 @@
</tr>
<tr align=center>
<td>Version</td>
<td>Reserved</td>
<td colspan=2>Name Size</td>
<td colspan=2>Type Size</td>
</tr>
<tr align=center>
<td colspan=2>Type Size</td>
<td colspan=2>Space Size</td>
<td colspan=2>Reserved</td>
</tr>
<tr align=center>
@ -2750,6 +2769,12 @@
<th width="70%">Description</th>
</tr>
<tr valign=top>
<td>Version</td>
<td>Version number for the message. This document describes
version 1 of attribute messages.</td>
</tr>
<tr valign=top>
<td>Name Size</td>
<td>The length of the attribute name in bytes including the
@ -2881,8 +2906,9 @@
</tr>
<tr align=center>
<td>Version</td>
<td>Flags</td>
<td colspan=3>Reserved</td>
<td colspan=2>Reserved</td>
</tr>
<tr align=center>
@ -2903,6 +2929,12 @@
<th width="70%">Description</th>
</tr>
<tr valign=top>
<td>Version</td>
<td>The version number for the message. This document
describes version one of shared messages.</td>
</tr>
<tr valign=top>
<td>Flags</td>
<td>The Shared Message message points to a message which is
@ -3108,7 +3140,7 @@ data-type.
<address><a href="mailto:koziol@ncsa.uiuc.edu">Quincey Koziol</a></address>
<address><a href="mailto:matzke@llnl.gov">Robb Matzke</a></address>
<!-- hhmts start -->
Last modified: Mon Jul 20 10:17:03 EDT 1998
Last modified: Mon Jul 20 13:49:08 EDT 1998
<!-- hhmts end -->
</body>
</html>

View File

@ -51,6 +51,8 @@ const H5O_class_t H5O_ATTR[1] = {{
H5O_attr_debug, /* debug the message */
}};
#define H5O_ATTR_VERSION 1
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
@ -76,6 +78,9 @@ static hbool_t interface_initialize_g = FALSE;
* Modifications:
* Robb Matzke, 17 Jul 1998
* Added padding for alignment.
*
* Robb Matzke, 20 Jul 1998
* Added a version number at the beginning.
--------------------------------------------------------------------------*/
static void *
H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
@ -83,6 +88,7 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
H5A_t *attr = NULL;
H5S_simple_t *simple; /*simple dimensionality information */
size_t name_len; /*attribute name length */
intn version; /*message version number*/
FUNC_ENTER(H5O_attr_decode, NULL);
@ -95,6 +101,16 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
"memory allocation failed");
}
/* Version number */
version = *p++;
if (version!=H5O_ATTR_VERSION) {
HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
"bad version number for attribute message");
}
/* Reserved */
p++;
/*
* Decode the sizes of the parts of the attribute. The sizes stored in
* the file are exact but the parts are aligned on 8-byte boundaries.
@ -102,7 +118,6 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
UINT16DECODE(p, name_len); /*including null*/
UINT16DECODE(p, attr->dt_size);
UINT16DECODE(p, attr->ds_size);
p += 2; /*reserved*/
/* Decode and store the name */
if (NULL==(attr->name=H5MM_malloc(name_len))) {
@ -175,6 +190,9 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
* Modifications:
* Robb Matzke, 17 Jul 1998
* Added padding for alignment.
*
* Robb Matzke, 20 Jul 1998
* Added a version number at the beginning.
--------------------------------------------------------------------------*/
static herr_t
H5O_attr_encode(H5F_t *f, uint8 *p, const void *mesg)
@ -189,6 +207,12 @@ H5O_attr_encode(H5F_t *f, uint8 *p, const void *mesg)
assert(p);
assert(attr);
/* Version */
*p++ = H5O_ATTR_VERSION;
/* Reserved */
*p++ = 0;
/*
* Encode the lengths of the various parts of the attribute message. The
* encoded lengths are exact but we pad each part except the data to be a
@ -198,7 +222,6 @@ H5O_attr_encode(H5F_t *f, uint8 *p, const void *mesg)
UINT16ENCODE(p, name_len);
UINT16ENCODE(p, attr->dt_size);
UINT16ENCODE(p, attr->ds_size);
UINT16ENCODE(p, 0); /*reserved*/
/*
* Write the name including null terminator padded to the correct number

View File

@ -55,6 +55,8 @@ const H5O_class_t H5O_DTYPE[1] = {{
H5O_dtype_debug, /* debug the message */
}};
#define H5O_DTYPE_VERSION 1
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
@ -78,7 +80,7 @@ static hbool_t interface_initialize_g = FALSE;
static herr_t
H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt)
{
uintn flags, perm_word;
uintn flags, perm_word, version;
intn i, j;
FUNC_ENTER(H5O_dtype_decode_helper, FAIL);
@ -89,7 +91,12 @@ H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt)
/* decode */
UINT32DECODE(*pp, flags);
dt->type = (H5T_class_t)(flags & 0xff);
version = (flags>>4) & 0x0f;
if (version!=H5O_DTYPE_VERSION) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL,
"bad version number for data type message");
}
dt->type = (H5T_class_t)(flags & 0x0f);
flags >>= 8;
UINT32DECODE(*pp, dt->size);
@ -455,7 +462,7 @@ H5O_dtype_encode_helper(uint8 **pp, const H5T_t *dt)
break;
}
*hdr++ = dt->type;
*hdr++ = ((uintn)(dt->type) & 0x0f) | (H5O_DTYPE_VERSION<<4);
*hdr++ = (flags >> 0) & 0xff;
*hdr++ = (flags >> 8) & 0xff;
*hdr++ = (flags >> 16) & 0xff;

View File

@ -37,6 +37,8 @@ const H5O_class_t H5O_EFL[1] = {{
H5O_efl_debug, /*debug the message */
}};
#define H5O_EFL_VERSION 1
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
@ -56,14 +58,16 @@ static hbool_t interface_initialize_g = FALSE;
* Tuesday, November 25, 1997
*
* Modifications:
*
* Robb Matzke, 1998-07-20
* Rearranged the message to add a version number near the beginning.
*
*-------------------------------------------------------------------------
*/
static void *
H5O_efl_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
{
H5O_efl_t *mesg = NULL;
int i;
intn i, version;
const char *s = NULL;
FUNC_ENTER(H5O_efl_decode, NULL);
@ -73,22 +77,34 @@ H5O_efl_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
assert(p);
assert (!sh);
/* Decode the header */
if (NULL==(mesg = H5MM_calloc(sizeof(H5O_efl_t)))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
/* Version */
version = *p++;
if (version!=H5O_EFL_VERSION) {
HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
"bad version number for external file list message");
}
/* Reserved */
p += 3;
/* Number of slots */
UINT16DECODE(p, mesg->nalloc);
assert(mesg->nalloc>0);
UINT16DECODE(p, mesg->nused);
assert(mesg->nused <= mesg->nalloc);
/* Heap address */
H5F_addr_decode(f, &p, &(mesg->heap_addr));
#ifndef NDEBUG
assert (H5F_addr_defined (&(mesg->heap_addr)));
s = H5HL_peek (f, &(mesg->heap_addr), 0);
assert (s && !*s);
#endif
UINT16DECODE(p, mesg->nalloc);
assert(mesg->nalloc>0);
UINT16DECODE(p, mesg->nused);
assert(mesg->nused <= mesg->nalloc);
p += 4; /*reserved*/
/* Decode the file list */
mesg->slot = H5MM_calloc(mesg->nalloc*sizeof(H5O_efl_entry_t));
@ -128,7 +144,9 @@ H5O_efl_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
* Tuesday, November 25, 1997
*
* Modifications:
*
* Robb Matzke, 1998-07-20
* Rearranged the message to add a version number near the beginning.
*
*-------------------------------------------------------------------------
*/
static herr_t
@ -146,17 +164,23 @@ H5O_efl_encode(H5F_t *f, uint8 *p, const void *_mesg)
assert(mesg);
assert(p);
/* Encode header */
assert (H5F_addr_defined (&(mesg->heap_addr)));
H5F_addr_encode(f, &p, &(mesg->heap_addr));
/* Version */
*p++ = H5O_EFL_VERSION;
/* Reserved */
*p++ = 0;
*p++ = 0;
*p++ = 0;
/* Number of slots */
assert (mesg->nalloc>0);
UINT16ENCODE(p, mesg->nused); /*yes, twice*/
assert (mesg->nused>0 && mesg->nused<=mesg->nalloc);
UINT16ENCODE(p, mesg->nused);
*p++ = 0;
*p++ = 0;
*p++ = 0;
*p++ = 0;
/* Heap address */
assert (H5F_addr_defined (&(mesg->heap_addr)));
H5F_addr_encode(f, &p, &(mesg->heap_addr));
/* Encode file list */
for (i=0; i<mesg->nused; i++) {

View File

@ -36,6 +36,8 @@ const H5O_class_t H5O_LAYOUT[1] = {{
H5O_layout_debug, /*debug the message */
}};
#define H5O_LAYOUT_VERSION 1
/* Interface initialization */
#define PABLO_MASK H5O_layout_mask
static hbool_t interface_initialize_g = FALSE;
@ -56,6 +58,8 @@ static hbool_t interface_initialize_g = FALSE;
* Wednesday, October 8, 1997
*
* Modifications:
* Robb Matzke, 1998-07-20
* Rearranged the message to add a version number at the beginning.
*
*-------------------------------------------------------------------------
*/
@ -63,7 +67,7 @@ static void *
H5O_layout_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
{
H5O_layout_t *mesg = NULL;
intn i;
intn i, version;
FUNC_ENTER(H5O_layout_decode, NULL);
@ -77,7 +81,15 @@ H5O_layout_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
H5F_addr_decode(f, &p, &(mesg->addr));
/* Version */
version = *p++;
if (version!=H5O_LAYOUT_VERSION) {
HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
"bad version number for layout message");
}
/* Dimensionality */
mesg->ndims = *p++;
/* Layout class */
@ -85,7 +97,10 @@ H5O_layout_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
assert(H5D_CONTIGUOUS == mesg->type || H5D_CHUNKED == mesg->type);
/* Reserved bytes */
p += 6;
p += 5;
/* Address */
H5F_addr_decode(f, &p, &(mesg->addr));
/* Read the size */
for (i = 0; i < mesg->ndims; i++) {
@ -108,6 +123,8 @@ H5O_layout_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
* Wednesday, October 8, 1997
*
* Modifications:
* Robb Matzke, 1998-07-20
* Rearranged the message to add a version number at the beginning.
*
*-------------------------------------------------------------------------
*/
@ -125,8 +142,8 @@ H5O_layout_encode(H5F_t *f, uint8 *p, const void *_mesg)
assert(mesg->ndims > 0 && mesg->ndims <= H5O_LAYOUT_NDIMS);
assert(p);
/* data or B-tree address */
H5F_addr_encode(f, &p, &(mesg->addr));
/* Version */
*p++ = H5O_LAYOUT_VERSION;
/* number of dimensions */
*p++ = mesg->ndims;
@ -135,8 +152,10 @@ H5O_layout_encode(H5F_t *f, uint8 *p, const void *_mesg)
*p++ = mesg->type;
/* reserved bytes should be zero */
for (i = 0; i < 6; i++)
*p++ = 0;
for (i=0; i<5; i++) *p++ = 0;
/* data or B-tree address */
H5F_addr_encode(f, &p, &(mesg->addr));
/* dimension size */
for (i = 0; i < mesg->ndims; i++) {

View File

@ -48,6 +48,8 @@ const H5O_class_t H5O_SDSPACE[1] = {{
H5O_sdspace_debug, /* debug the message */
}};
#define H5O_SDSPACE_VERSION 1
/* Is the interface initialized? */
static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
@ -74,13 +76,16 @@ static hbool_t interface_initialize_g = FALSE;
Robb Matzke, 1998-04-09
The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes
instead of just four bytes.
Robb Matzke, 1998-07-20
Added a version number and reformatted the message for aligment.
--------------------------------------------------------------------------*/
static void *
H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
{
H5S_simple_t *sdim = NULL;/* New simple dimensionality structure */
intn u; /* local counting variable */
uintn flags;
uintn flags, version;
FUNC_ENTER(H5O_sdspace_decode, NULL);
@ -91,8 +96,15 @@ H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
/* decode */
if ((sdim = H5MM_calloc(sizeof(H5S_simple_t))) != NULL) {
UINT32DECODE(p, sdim->rank);
UINT32DECODE(p, flags);
version = *p++;
if (version!=H5O_SDSPACE_VERSION) {
HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
"wrong version number in data space message");
}
sdim->rank = *p++;
flags = *p++;
p += 5; /*reserved*/
if (sdim->rank > 0) {
if (NULL==(sdim->size=H5MM_malloc(sizeof(sdim->size[0])*
sdim->rank))) {
@ -157,6 +169,9 @@ H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
Robb Matzke, 1998-04-09
The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes
instead of just four bytes.
Robb Matzke, 1998-07-20
Added a version number and reformatted the message for aligment.
--------------------------------------------------------------------------*/
static herr_t
H5O_sdspace_encode(H5F_t *f, uint8 *p, const void *mesg)
@ -179,8 +194,15 @@ H5O_sdspace_encode(H5F_t *f, uint8 *p, const void *mesg)
#endif
/* encode */
UINT32ENCODE(p, sdim->rank);
UINT32ENCODE(p, flags);
*p++ = H5O_SDSPACE_VERSION;
*p++ = sdim->rank;
*p++ = flags;
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
if (sdim->rank > 0) {
for (u = 0; u < sdim->rank; u++) {
H5F_encode_length (f, p, sdim->size[u]);
@ -317,9 +339,9 @@ static size_t
H5O_sdspace_size(H5F_t *f, const void *mesg)
{
const H5S_simple_t *sdim = (const H5S_simple_t *) mesg;
/*
* all dimensionality messages are at least 8 bytes long (four bytes for
* rank and four bytes for flags)
* All dimensionality messages are at least 8 bytes long.
*/
size_t ret_value = 8;

View File

@ -38,6 +38,8 @@ const H5O_class_t H5O_SHARED[1] = {{
H5O_shared_debug, /*debug method */
}};
#define H5O_SHARED_VERSION 1
/* Interface initialization */
#define PABLO_MASK H5O_shared_mask
static hbool_t interface_initialize_g = FALSE;
@ -57,14 +59,15 @@ static hbool_t interface_initialize_g = FALSE;
* Thursday, April 2, 1998
*
* Modifications:
*
* Robb Matzke, 1998-07-20
* Added a version number to the beginning of the message.
*-------------------------------------------------------------------------
*/
static void *
H5O_shared_decode (H5F_t *f, const uint8 *buf, H5O_shared_t __unused__ *sh)
{
H5O_shared_t *mesg;
uintn flags;
uintn flags, version;
FUNC_ENTER (H5O_shared_decode, NULL);
@ -79,10 +82,21 @@ H5O_shared_decode (H5F_t *f, const uint8 *buf, H5O_shared_t __unused__ *sh)
"memory allocation failed");
}
/* Version */
version = *buf++;
if (version!=H5O_SHARED_VERSION) {
HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
"bad version number for shared object message");
}
/* Flags */
flags = *buf++;
mesg->in_gh = (flags & 0x01);
buf += 7; /*reserved*/
/* Reserved */
buf += 6;
/* Body */
if (mesg->in_gh) {
H5F_addr_decode (f, &buf, &(mesg->u.gh.addr));
INT32DECODE (buf, mesg->u.gh.idx);
@ -107,6 +121,8 @@ H5O_shared_decode (H5F_t *f, const uint8 *buf, H5O_shared_t __unused__ *sh)
* Thursday, April 2, 1998
*
* Modifications:
* Robb Matzke, 1998-07-20
* Added a version number to the beginning of the message.
*
*-------------------------------------------------------------------------
*/
@ -124,6 +140,7 @@ H5O_shared_encode (H5F_t *f, uint8 *buf/*out*/, const void *_mesg)
assert (mesg);
/* Encode */
*buf++ = H5O_SHARED_VERSION;
flags = mesg->in_gh ? 0x01 : 0x00;
*buf++ = flags;
*buf++ = 0; /*reserved 1*/
@ -132,7 +149,6 @@ H5O_shared_encode (H5F_t *f, uint8 *buf/*out*/, const void *_mesg)
*buf++ = 0; /*reserved 4*/
*buf++ = 0; /*reserved 5*/
*buf++ = 0; /*reserved 6*/
*buf++ = 0; /*reserved 7*/
if (mesg->in_gh) {
H5F_addr_encode (f, &buf, &(mesg->u.gh.addr));

View File

@ -142,7 +142,7 @@ main(int argc, char *argv[])
int Summary = 0;
int CleanUp = 1;
int Cache = 1;
uintn major, minor, release, patch;
uintn major, minor, release;
#if defined __MWERKS__
argc = ccommand(&argv);
@ -172,7 +172,7 @@ main(int argc, char *argv[])
InitTest("select", test_select, cleanup_select, "Selections");
Verbosity = 4; /* Default Verbosity is Low */
H5version(&major, &minor, &release, &patch);
H5version(&major, &minor, &release);
print_func("\nFor help use: testhdf5 -help\n");
print_func("Linked with hdf5 version %u.%u release %u\n",