From 34595bac3b5f0b2dad3050907c07e023a6972097 Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Mon, 20 Jul 1998 12:58:37 -0500 Subject: [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. --- doc/html/H5.format.html | 90 +++++++++++++++++++++++++++++++++---------------- src/H5Oattr.c | 27 +++++++++++++-- src/H5Odtype.c | 13 +++++-- src/H5Oefl.c | 56 +++++++++++++++++++++--------- src/H5Olayout.c | 33 ++++++++++++++---- src/H5Osdspace.c | 36 ++++++++++++++++---- src/H5Oshared.c | 24 ++++++++++--- test/testhdf5.c | 4 +-- 8 files changed, 213 insertions(+), 70 deletions(-) diff --git a/doc/html/H5.format.html b/doc/html/H5.format.html index ce7e112..3dd2bc5 100644 --- a/doc/html/H5.format.html +++ b/doc/html/H5.format.html @@ -1502,11 +1502,19 @@ byte byte byte + - Dimensionality + Version + Dimensionality + Flags + Reserved + + - Dimension Flags + Reserved + + Dimension Size #1 (<size> bytes) @@ -1543,12 +1551,12 @@ - Dimension Flags + Flags 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. + 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. @@ -1935,7 +1943,7 @@ - Type Class + Type Class and Version Class Bit Field @@ -1950,11 +1958,13 @@

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.

@@ -2269,7 +2279,8 @@ -
Heap Address

+ Version + Reserved @@ -2278,7 +2289,7 @@ - Reserved +
Heap Address

@@ -2451,17 +2462,18 @@ -
Address

+ Version + Dimensionality + Layout Class + Reserved - Dimensionality - Layout Class - Reserved + Reserved - Reserved (4-bytes) +
Address

@@ -2487,11 +2499,9 @@ - Address - 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. + Version + A version number for the layout message. This + documentation describes version one. @@ -2511,6 +2521,14 @@ + Address + 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. + + + Dimensions For contiguous storage the dimensions define the entire size of the array while for chunked storage they define @@ -2715,13 +2733,14 @@ + Version + Reserved Name Size - Type Size + Type Size Space Size - Reserved @@ -2751,6 +2770,12 @@ + Version + Version number for the message. This document describes + version 1 of attribute messages. + + + Name Size The length of the attribute name in bytes including the null terminator. Note that the Name field below may @@ -2881,8 +2906,9 @@ + Version Flags - Reserved + Reserved @@ -2904,6 +2930,12 @@ + Version + The version number for the message. This document + describes version one of shared messages. + + + Flags The Shared Message message points to a message which is shared among multiple object headers. The Flags field @@ -3108,7 +3140,7 @@ data-type.
Quincey Koziol
Robb Matzke
-Last modified: Mon Jul 20 10:17:03 EDT 1998 +Last modified: Mon Jul 20 13:49:08 EDT 1998 diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 6021802..99551ee 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -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 diff --git a/src/H5Odtype.c b/src/H5Odtype.c index c890a03..8e44223 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -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; diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 94e2650..442b7b4 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -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; inused; i++) { diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 3c534fa..f6ca222 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -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++) { diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 117dcf3..d7727ef 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -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; diff --git a/src/H5Oshared.c b/src/H5Oshared.c index f485143..198466b 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -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)); diff --git a/test/testhdf5.c b/test/testhdf5.c index bf63046..c25bcf4 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -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", -- cgit v0.12