diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2008-09-22 17:33:58 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2008-09-22 17:33:58 (GMT) |
commit | 926cfe52cc14c735e53709e8b8dc3bfc4d0f8dd8 (patch) | |
tree | ad06b825bd0d4dc30c88ab14dda1abe0c87f4ed5 /src | |
parent | 531822d443296bfe74a76aed6c121ec8421508a5 (diff) | |
download | hdf5-926cfe52cc14c735e53709e8b8dc3bfc4d0f8dd8.zip hdf5-926cfe52cc14c735e53709e8b8dc3bfc4d0f8dd8.tar.gz hdf5-926cfe52cc14c735e53709e8b8dc3bfc4d0f8dd8.tar.bz2 |
[svn-r15677] Description:
Bring r15676 back from trunk:
Centralize all macros for declaring "magic numbers"/signatures for
objects in the file into src/H5Fprivate.h, so it's easier to know what
values have already been defined, etc.
Tested on:
Mac OS X/32 10.5.5 (amazon)
Too minor to require h5committest
Diffstat (limited to 'src')
-rw-r--r-- | src/H5B.c | 2 | ||||
-rw-r--r-- | src/H5B2cache.c | 24 | ||||
-rw-r--r-- | src/H5B2pkg.h | 10 | ||||
-rw-r--r-- | src/H5Bcache.c | 4 | ||||
-rw-r--r-- | src/H5Bprivate.h | 3 | ||||
-rw-r--r-- | src/H5FScache.c | 16 | ||||
-rw-r--r-- | src/H5FSpkg.h | 15 | ||||
-rw-r--r-- | src/H5FSprivate.h | 4 | ||||
-rw-r--r-- | src/H5Fprivate.h | 46 | ||||
-rw-r--r-- | src/H5Gnode.c | 10 | ||||
-rw-r--r-- | src/H5Gprivate.h | 3 | ||||
-rw-r--r-- | src/H5HFcache.c | 24 | ||||
-rw-r--r-- | src/H5HFpkg.h | 12 | ||||
-rw-r--r-- | src/H5HG.c | 10 | ||||
-rw-r--r-- | src/H5HGprivate.h | 6 | ||||
-rw-r--r-- | src/H5HL.c | 8 | ||||
-rw-r--r-- | src/H5HLpkg.h | 2 | ||||
-rw-r--r-- | src/H5HLprivate.h | 3 | ||||
-rw-r--r-- | src/H5O.c | 2 | ||||
-rw-r--r-- | src/H5Oalloc.c | 4 | ||||
-rw-r--r-- | src/H5Ocache.c | 14 | ||||
-rw-r--r-- | src/H5Ocopy.c | 2 | ||||
-rw-r--r-- | src/H5Odbg.c | 2 | ||||
-rw-r--r-- | src/H5Opkg.h | 11 | ||||
-rw-r--r-- | src/H5SMcache.c | 16 | ||||
-rwxr-xr-x | src/H5SMpkg.h | 11 |
26 files changed, 129 insertions, 135 deletions
@@ -119,7 +119,7 @@ /* Local Macros */ /****************/ #define H5B_SIZEOF_HDR(F) \ - (H5B_SIZEOF_MAGIC + /*magic number */ \ + (H5_SIZEOF_MAGIC + /*magic number */ \ 4 + /*type, level, num entries */ \ 2*H5F_SIZEOF_ADDR(F)) /*left and right sibling addresses */ #define H5B_NKEY(b,shared,idx) ((b)->native+(shared)->nkey[(idx)]) diff --git a/src/H5B2cache.c b/src/H5B2cache.c index f6d95ce..1d34eb0 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -188,9 +188,9 @@ H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, vo p = hdr; /* Magic number */ - if(HDmemcmp(p, H5B2_HDR_MAGIC, (size_t)H5B2_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree header signature") - p += H5B2_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Version */ if(*p++ != H5B2_HDR_VERSION) @@ -307,8 +307,8 @@ H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B p = hdr; /* Magic number */ - HDmemcpy(p, H5B2_HDR_MAGIC, (size_t)H5B2_SIZEOF_MAGIC); - p += H5B2_SIZEOF_MAGIC; + HDmemcpy(p, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; /* Version # */ *p++ = H5B2_HDR_VERSION; @@ -522,9 +522,9 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda p = shared->page; /* Magic number */ - if(HDmemcmp(p, H5B2_INT_MAGIC, (size_t)H5B2_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree internal node signature") - p += H5B2_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Version */ if(*p++ != H5B2_INT_VERSION) @@ -641,8 +641,8 @@ H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr p = shared->page; /* Magic number */ - HDmemcpy(p, H5B2_INT_MAGIC, (size_t)H5B2_SIZEOF_MAGIC); - p += H5B2_SIZEOF_MAGIC; + HDmemcpy(p, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; /* Version # */ *p++ = H5B2_INT_VERSION; @@ -877,9 +877,9 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v p = shared->page; /* Magic number */ - if(HDmemcmp(p, H5B2_LEAF_MAGIC, (size_t)H5B2_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree leaf node signature") - p += H5B2_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Version */ if(*p++ != H5B2_LEAF_VERSION) @@ -977,8 +977,8 @@ H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5 p = shared->page; /* magic number */ - HDmemcpy(p, H5B2_LEAF_MAGIC, (size_t)H5B2_SIZEOF_MAGIC); - p += H5B2_SIZEOF_MAGIC; + HDmemcpy(p, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; /* version # */ *p++ = H5B2_LEAF_VERSION; diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 43fab1f..d05220b 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -40,14 +40,6 @@ /* Package Private Macros */ /**************************/ -/* Size of signature information (on disk) */ -#define H5B2_SIZEOF_MAGIC 4 - -/* B-tree signatures */ -#define H5B2_HDR_MAGIC "BTHD" /* Header */ -#define H5B2_INT_MAGIC "BTIN" /* Internal node */ -#define H5B2_LEAF_MAGIC "BTLF" /* Leaf node */ - /* Size of storage for number of records per node (on disk) */ #define H5B2_SIZEOF_RECORDS_PER_NODE 2 @@ -67,7 +59,7 @@ /* Format overhead for all v2 B-tree metadata in the file */ #define H5B2_METADATA_PREFIX_SIZE ( \ - H5B2_SIZEOF_MAGIC /* Signature */ \ + H5_SIZEOF_MAGIC /* Signature */ \ + 1 /* Version */ \ + 1 /* Tree type */ \ + H5B2_SIZEOF_CHKSUM /* Metadata checksum */ \ diff --git a/src/H5Bcache.c b/src/H5Bcache.c index e19efb4..d3b2a35 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -113,7 +113,7 @@ H5B_serialize(const H5F_t *f, const H5B_t *bt) p = shared->page; /* magic number */ - HDmemcpy(p, H5B_MAGIC, (size_t)H5B_SIZEOF_MAGIC); + HDmemcpy(p, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC); p += 4; /* node type and level */ @@ -202,7 +202,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) p = shared->page; /* magic number */ - if (HDmemcmp(p, H5B_MAGIC, (size_t)H5B_SIZEOF_MAGIC)) + if (HDmemcmp(p, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree signature") p += 4; diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index 18a2c71..dc8648e 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -51,8 +51,7 @@ #ifdef NDEBUG # undef H5B_DEBUG #endif -#define H5B_MAGIC "TREE" /*tree node magic number */ -#define H5B_SIZEOF_MAGIC 4 /*size of magic number */ + /****************************/ /* Library Private Typedefs */ diff --git a/src/H5FScache.c b/src/H5FScache.c index 0af87d9..edf045a 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -191,9 +191,9 @@ HDfprintf(stderr, "%s: Load free space header, addr = %a\n", FUNC, addr); p = hdr; /* Magic number */ - if(HDmemcmp(p, H5FS_HDR_MAGIC, (size_t)H5FS_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header signature") - p += H5FS_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Version */ if(*p++ != H5FS_HDR_VERSION) @@ -327,8 +327,8 @@ HDfprintf(stderr, "%s: Flushing free space header, addr = %a, destroy = %u\n", F p = hdr; /* Magic number */ - HDmemcpy(p, H5FS_HDR_MAGIC, (size_t)H5FS_SIZEOF_MAGIC); - p += H5FS_SIZEOF_MAGIC; + HDmemcpy(p, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; /* Version # */ *p++ = H5FS_HDR_VERSION; @@ -581,9 +581,9 @@ HDfprintf(stderr, "%s: fspace->sect_size = %Hu\n", FUNC, fspace->sect_size); p = buf; /* Magic number */ - if(HDmemcmp(p, H5FS_SINFO_MAGIC, (size_t)H5FS_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space sections signature") - p += H5FS_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Version */ if(*p++ != H5FS_SINFO_VERSION) @@ -890,8 +890,8 @@ HDfprintf(stderr, "%s: Flushing free space header, addr = %a, destroy = %u\n", F p = buf; /* Magic number */ - HDmemcpy(p, H5FS_SINFO_MAGIC, (size_t)H5FS_SIZEOF_MAGIC); - p += H5FS_SIZEOF_MAGIC; + HDmemcpy(p, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; /* Version # */ *p++ = H5FS_SINFO_VERSION; diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h index 9119902..9f3409f 100644 --- a/src/H5FSpkg.h +++ b/src/H5FSpkg.h @@ -42,19 +42,12 @@ /* Package Private Macros */ /**************************/ -/* Size of signature information (on disk) */ -#define H5FS_SIZEOF_MAGIC 4 - -/* Free space signatures */ -#define H5FS_HDR_MAGIC "FSHD" /* Header */ -#define H5FS_SINFO_MAGIC "FSSE" /* Serialized sections */ - /* Size of checksum information (on disk) */ #define H5FS_SIZEOF_CHKSUM 4 /* "Standard" size of prefix information for free space metadata */ #define H5FS_METADATA_PREFIX_SIZE ( \ - H5FS_SIZEOF_MAGIC /* Signature */ \ + H5_SIZEOF_MAGIC /* Signature */ \ + 1 /* Version */ \ + H5FS_SIZEOF_CHKSUM /* Metadata checksum */ \ ) @@ -208,12 +201,6 @@ H5_DLL H5FS_t *H5FS_new(size_t nclasses, const H5FS_section_class_t *classes[], /* Free space section routines */ H5_DLL H5FS_sinfo_t *H5FS_sinfo_new(H5F_t *f, H5FS_t *fspace); -/* Debugging routines for dumping file structures */ -H5_DLL herr_t H5FS_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, - FILE *stream, int indent, int fwidth); -H5_DLL herr_t H5FS_sects_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, - FILE *stream, int indent, int fwidth, haddr_t fs_addr, haddr_t client_addr); - /* Metadata cache callbacks */ H5_DLL herr_t H5FS_cache_hdr_dest(H5F_t *f, H5FS_t *hdr); H5_DLL herr_t H5FS_cache_sinfo_dest(H5F_t *f, H5FS_sinfo_t *sinfo); diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h index bf24b8a..ff8ecfd 100644 --- a/src/H5FSprivate.h +++ b/src/H5FSprivate.h @@ -175,6 +175,10 @@ H5_DLL herr_t H5FS_sect_change_class(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned new_class); /* Debugging routines for dumping file structures */ +H5_DLL herr_t H5FS_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, + FILE *stream, int indent, int fwidth); +H5_DLL herr_t H5FS_sects_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, + FILE *stream, int indent, int fwidth, haddr_t fs_addr, haddr_t client_addr); H5_DLL herr_t H5FS_sect_debug(const H5FS_t *fspace, const H5FS_section_info_t *sect, FILE *stream, int indent, int fwidth); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index f91ad82..b228b9d 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -408,6 +408,52 @@ typedef struct H5F_t H5F_t; must compensate. -QAK */ +/* Macros to define signatures of all objects in the file */ + +/* Size of signature information (on disk) */ +/* (all on-disk signatures should be this length) */ +#define H5_SIZEOF_MAGIC 4 + +/* v1 B-tree node signature */ +#define H5B_MAGIC "TREE" + +/* v2 B-tree signatures */ +#define H5B2_HDR_MAGIC "BTHD" /* Header */ +#define H5B2_INT_MAGIC "BTIN" /* Internal node */ +#define H5B2_LEAF_MAGIC "BTLF" /* Leaf node */ + +/* Extensible array signatures */ +#define H5EA_HDR_MAGIC "EAHD" /* Header */ +#define H5EA_IBLOCK_MAGIC "EAIB" /* Index block */ +#define H5EA_DBLOCK_MAGIC "EADB" /* Data block */ + +/* Free space signatures */ +#define H5FS_HDR_MAGIC "FSHD" /* Header */ +#define H5FS_SINFO_MAGIC "FSSE" /* Serialized sections */ + +/* Symbol table node signature */ +#define H5G_NODE_MAGIC "SNOD" + +/* Fractal heap signatures */ +#define H5HF_HDR_MAGIC "FRHP" /* Header */ +#define H5HF_IBLOCK_MAGIC "FHIB" /* Indirect block */ +#define H5HF_DBLOCK_MAGIC "FHDB" /* Direct block */ + +/* Global heap signature */ +#define H5HG_MAGIC "GCOL" + +/* Local heap signature */ +#define H5HL_MAGIC "HEAP" + +/* Object header signatures */ +#define H5O_HDR_MAGIC "OHDR" /* Header */ +#define H5O_CHK_MAGIC "OCHK" /* Continuation chunk */ + +/* Shared Message signatures */ +#define H5SM_TABLE_MAGIC "SMTB" /* Shared Message Table */ +#define H5SM_LIST_MAGIC "SMLI" /* Shared Message List */ + + /* Forward declarations for prototype arguments */ struct H5B_class_t; struct H5RC_t; diff --git a/src/H5Gnode.c b/src/H5Gnode.c index a3239c2..cefed5b 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -66,7 +66,7 @@ typedef struct H5G_node_t { /* Private macros */ #define H5G_NODE_VERS 1 /*symbol table node version number */ -#define H5G_NODE_SIZEOF_HDR(F) (H5G_NODE_SIZEOF_MAGIC + 4) +#define H5G_NODE_SIZEOF_HDR(F) (H5_SIZEOF_MAGIC + 4) /* Size of stack buffer for serialized nodes */ #define H5G_NODE_BUF_SIZE 512 @@ -380,9 +380,9 @@ H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_udata1 p = node; /* magic */ - if(HDmemcmp(p, H5G_NODE_MAGIC, (size_t)H5G_NODE_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "bad symbol table node signature") - p += 4; + p += H5_SIZEOF_MAGIC; /* version */ if(H5G_NODE_VERS != *p++) @@ -559,8 +559,8 @@ H5G_node_serialize(H5F_t *f, H5G_node_t *sym, size_t size, uint8_t *buf) p = buf; /* magic number */ - HDmemcpy(p, H5G_NODE_MAGIC, (size_t)H5G_NODE_SIZEOF_MAGIC); - p += 4; + HDmemcpy(p, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; /* version number */ *p++ = H5G_NODE_VERS; diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index ab6abc1..591be6b 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -43,9 +43,6 @@ # undef H5G_DEBUG #endif -#define H5G_NODE_MAGIC "SNOD" /*symbol table node magic number */ -#define H5G_NODE_SIZEOF_MAGIC 4 /*sizeof symbol node magic number */ - /* * The disk size for a symbol table entry... */ diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 0e31f9d..f057c7c 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -302,9 +302,9 @@ HDfprintf(stderr, "%s: Load heap header, addr = %a\n", FUNC, addr); p = buf; /* Magic number */ - if(HDmemcmp(p, H5HF_HDR_MAGIC, (size_t)H5HF_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "wrong fractal heap header signature") - p += H5HF_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Version */ if(*p++ != H5HF_HDR_VERSION) @@ -497,8 +497,8 @@ HDfprintf(stderr, "%s: Flushing heap header, addr = %a, destroy = %u\n", FUNC, a p = buf; /* Magic number */ - HDmemcpy(p, H5HF_HDR_MAGIC, (size_t)H5HF_SIZEOF_MAGIC); - p += H5HF_SIZEOF_MAGIC; + HDmemcpy(p, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; /* Version # */ *p++ = H5HF_HDR_VERSION; @@ -770,9 +770,9 @@ HDfprintf(stderr, "%s: Load indirect block, addr = %a\n", FUNC, addr); p = buf; /* Magic number */ - if(HDmemcmp(p, H5HF_IBLOCK_MAGIC, (size_t)H5HF_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "wrong fractal heap indirect block signature") - p += H5HF_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Version */ if(*p++ != H5HF_IBLOCK_VERSION) @@ -969,8 +969,8 @@ HDfprintf(stderr, "%s: hdr->man_dtable.cparam.width = %u\n", FUNC, hdr->man_dtab p = buf; /* Magic number */ - HDmemcpy(p, H5HF_IBLOCK_MAGIC, (size_t)H5HF_SIZEOF_MAGIC); - p += H5HF_SIZEOF_MAGIC; + HDmemcpy(p, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; /* Version # */ *p++ = H5HF_IBLOCK_VERSION; @@ -1315,9 +1315,9 @@ HDfprintf(stderr, "%s: nbytes = %Zu, read_size = %Zu, read_buf = %p\n", FUNC, nb p = dblock->blk; /* Magic number */ - if(HDmemcmp(p, H5HF_DBLOCK_MAGIC, (size_t)H5HF_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "wrong fractal heap direct block signature") - p += H5HF_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Version */ if(*p++ != H5HF_DBLOCK_VERSION) @@ -1421,8 +1421,8 @@ H5HF_cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, p = dblock->blk; /* Magic number */ - HDmemcpy(p, H5HF_DBLOCK_MAGIC, (size_t)H5HF_SIZEOF_MAGIC); - p += H5HF_SIZEOF_MAGIC; + HDmemcpy(p, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; /* Version # */ *p++ = H5HF_DBLOCK_VERSION; diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index fd332e5..71691c9 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -35,27 +35,19 @@ #include "H5ACprivate.h" /* Metadata cache */ #include "H5B2private.h" /* v2 B-trees */ #include "H5FLprivate.h" /* Free Lists */ -#include "H5FSprivate.h" /* File free space */ +#include "H5FSprivate.h" /* Free space manager */ #include "H5SLprivate.h" /* Skip lists */ /**************************/ /* Package Private Macros */ /**************************/ -/* Size of signature information (on disk) */ -#define H5HF_SIZEOF_MAGIC 4 - -/* Fractal heap signatures */ -#define H5HF_HDR_MAGIC "FRHP" /* Header */ -#define H5HF_IBLOCK_MAGIC "FHIB" /* Indirect block */ -#define H5HF_DBLOCK_MAGIC "FHDB" /* Direct block */ - /* Size of checksum information (on disk) */ #define H5HF_SIZEOF_CHKSUM 4 /* "Standard" size of prefix information for fractal heap metadata */ #define H5HF_METADATA_PREFIX_SIZE(c) ( \ - H5HF_SIZEOF_MAGIC /* Signature */ \ + H5_SIZEOF_MAGIC /* Signature */ \ + 1 /* Version */ \ + ((c) ? H5HF_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \ ) @@ -226,8 +226,8 @@ HDmemset(heap->chunk, 0, size); "memory allocation failed"); /* Initialize the header */ - HDmemcpy (heap->chunk, H5HG_MAGIC, (size_t)H5HG_SIZEOF_MAGIC); - p = heap->chunk + H5HG_SIZEOF_MAGIC; + HDmemcpy (heap->chunk, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p = heap->chunk + H5_SIZEOF_MAGIC; *p++ = H5HG_VERSION; *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ @@ -343,9 +343,9 @@ H5HG_load (H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, HGOTO_ERROR (H5E_HEAP, H5E_READERROR, NULL, "unable to read global heap collection"); /* Magic number */ - if(HDmemcmp(heap->chunk, H5HG_MAGIC, (size_t)H5HG_SIZEOF_MAGIC)) + if(HDmemcmp(heap->chunk, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "bad global heap collection signature"); - p = heap->chunk + H5HG_SIZEOF_MAGIC; + p = heap->chunk + H5_SIZEOF_MAGIC; /* Version */ if (H5HG_VERSION!=*p++) @@ -845,7 +845,7 @@ HDmemset(new_chunk + heap->size, 0, need); heap->size+=need; /* Encode the new size of the heap */ - p = new_chunk + H5HG_SIZEOF_MAGIC + 1 /* version */ + 3 /* reserved */; + p = new_chunk + H5_SIZEOF_MAGIC + 1 /* version */ + 3 /* reserved */; H5F_ENCODE_LENGTH (f, p, heap->size); /* Move the pointers to the existing objects to their new locations */ diff --git a/src/H5HGprivate.h b/src/H5HGprivate.h index 6e2c492..b6cdb4a 100644 --- a/src/H5HGprivate.h +++ b/src/H5HGprivate.h @@ -26,12 +26,6 @@ /* Private headers needed by this file. */ #include "H5Fprivate.h" /* File access */ -/* - * Each collection has a magic number for some redundancy. - */ -#define H5HG_MAGIC "GCOL" -#define H5HG_SIZEOF_MAGIC 4 - /* Information to locate object in global heap */ typedef struct H5HG_t { haddr_t addr; /*address of collection */ @@ -231,9 +231,9 @@ H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, p = hdr; /* Check magic number */ - if(HDmemcmp(hdr, H5HL_MAGIC, (size_t)H5HL_SIZEOF_MAGIC)) + if(HDmemcmp(hdr, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap signature") - p += H5HL_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Version */ if(H5HL_VERSION != *p++) @@ -488,8 +488,8 @@ H5HL_serialize(H5F_t *f, H5HL_t *heap, uint8_t *buf) /* serialize the header */ p = buf; fl = heap->freelist; - HDmemcpy(p, H5HL_MAGIC, (size_t)H5HL_SIZEOF_MAGIC); - p += H5HL_SIZEOF_MAGIC; + HDmemcpy(p, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; *p++ = H5HL_VERSION; *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h index fe6f107..48781e3 100644 --- a/src/H5HLpkg.h +++ b/src/H5HLpkg.h @@ -45,7 +45,7 @@ H5_DLLVAR const H5AC_class_t H5AC_LHEAP[1]; /**************************/ #define H5HL_SIZEOF_HDR(F) \ - H5HL_ALIGN(H5HL_SIZEOF_MAGIC + /*heap signature */ \ + H5HL_ALIGN(H5_SIZEOF_MAGIC + /*heap signature */ \ 4 + /*reserved */ \ H5F_SIZEOF_SIZE (F) + /*data size */ \ H5F_SIZEOF_SIZE (F) + /*free list head */ \ diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h index d8a4b49..2a3e2df 100644 --- a/src/H5HLprivate.h +++ b/src/H5HLprivate.h @@ -44,9 +44,6 @@ # undef H5HL_DEBUG #endif -#define H5HL_MAGIC "HEAP" /*heap magic number */ -#define H5HL_SIZEOF_MAGIC 4 - #define H5HL_ALIGN(X) (((X)+7)&(unsigned)(~0x07)) /*align on 8-byte boundary */ #define H5HL_SIZEOF_FREE(F) \ @@ -1163,7 +1163,7 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id, /* Put magic # for object header in first chunk */ if(oh->version > H5O_VERSION_1) - HDmemcpy(oh->chunk[0].image, H5O_HDR_MAGIC, (size_t)H5O_SIZEOF_MAGIC); + HDmemcpy(oh->chunk[0].image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); /* Create the message list */ oh->nmesgs = 1; diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 7abc11c..f9e06ad 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -837,8 +837,8 @@ H5O_alloc_new_chunk(H5F_t *f, * # at the beginning of the chunk image. */ if(oh->version > H5O_VERSION_1) { - HDmemcpy(p, H5O_CHK_MAGIC, (size_t)H5O_SIZEOF_MAGIC); - p += H5O_SIZEOF_MAGIC; + HDmemcpy(p, H5O_CHK_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; } /* end if */ /* diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 7d1f001..35b4e07 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -167,9 +167,9 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1, /* Check for magic number */ /* (indicates version 2 or later) */ - if(!HDmemcmp(p, H5O_HDR_MAGIC, (size_t)H5O_SIZEOF_MAGIC)) { + if(!HDmemcmp(p, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* Magic number */ - p += H5O_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Version */ oh->version = *p++; @@ -349,9 +349,9 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1, /* Check for magic # on chunks > 0 in later versions of the format */ if(chunkno > 0 && oh->version > H5O_VERSION_1) { /* Magic number */ - if(HDmemcmp(p, H5O_CHK_MAGIC, (size_t)H5O_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5O_CHK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "wrong object header chunk signature") - p += H5O_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; } /* end if */ /* Decode messages from this chunk */ @@ -682,8 +682,8 @@ H5O_assert(oh); uint64_t chunk0_size = oh->chunk[0].size - H5O_SIZEOF_HDR(oh); /* Size of chunk 0's data */ /* Verify magic number */ - HDassert(!HDmemcmp(p, H5O_HDR_MAGIC, H5O_SIZEOF_MAGIC)); - p += H5O_SIZEOF_MAGIC; + HDassert(!HDmemcmp(p, H5O_HDR_MAGIC, H5_SIZEOF_MAGIC)); + p += H5_SIZEOF_MAGIC; /* Version */ *p++ = oh->version; @@ -775,7 +775,7 @@ H5O_assert(oh); /* Sanity checks */ if(oh->version > H5O_VERSION_1) /* Make certain the magic # is present */ - HDassert(!HDmemcmp(oh->chunk[u].image, (u == 0 ? H5O_HDR_MAGIC : H5O_CHK_MAGIC), H5O_SIZEOF_MAGIC)); + HDassert(!HDmemcmp(oh->chunk[u].image, (u == 0 ? H5O_HDR_MAGIC : H5O_CHK_MAGIC), H5_SIZEOF_MAGIC)); else /* Gaps should never occur in version 1 of the format */ HDassert(oh->chunk[u].gap == 0); diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 7097b66..9a905d2 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -592,7 +592,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, * header. This will be written when the header is flushed to disk. */ if(oh_dst->version > H5O_VERSION_1) - HDmemcpy(current_pos, H5O_HDR_MAGIC, (size_t)H5O_SIZEOF_MAGIC); + HDmemcpy(current_pos, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); current_pos += H5O_SIZEOF_HDR(oh_dst) - H5O_SIZEOF_CHKSUM_OH(oh_dst); /* Loop through destination messages, updating their "raw" info */ diff --git a/src/H5Odbg.c b/src/H5Odbg.c index 279f328..7a49f75 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -127,7 +127,7 @@ H5O_assert(const H5O_t *oh) /* Version specific checks */ if(oh->version > H5O_VERSION_1) { /* Make certain that the magic number is correct for each chunk */ - HDassert(!HDmemcmp(oh->chunk[u].image, (u == 0 ? H5O_HDR_MAGIC : H5O_CHK_MAGIC), H5O_SIZEOF_MAGIC)); + HDassert(!HDmemcmp(oh->chunk[u].image, (u == 0 ? H5O_HDR_MAGIC : H5O_CHK_MAGIC), H5_SIZEOF_MAGIC)); /* Check for valid gap size */ HDassert(oh->chunk[u].gap < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); diff --git a/src/H5Opkg.h b/src/H5Opkg.h index c3737f5..a36ef6f 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -67,13 +67,6 @@ #define H5O_ALIGN_F(F, X) \ H5O_ALIGN_VERS((H5F_USE_LATEST_FORMAT(F) ? H5O_VERSION_LATEST : H5O_VERSION_1), X) -/* Size of signature information (on disk) */ -#define H5O_SIZEOF_MAGIC 4 - -/* Object header signatures */ -#define H5O_HDR_MAGIC "OHDR" /* Header */ -#define H5O_CHK_MAGIC "OCHK" /* Continuation chunk */ - /* Size of checksum (on disk) */ #define H5O_SIZEOF_CHKSUM 4 @@ -106,7 +99,7 @@ 4 + /*reference count */ \ 4) /*chunk data size */ \ : \ - (H5O_SIZEOF_MAGIC + /*magic number */ \ + (H5_SIZEOF_MAGIC + /*magic number */ \ 1 + /*version number */ \ 1 + /*flags */ \ (((O)->flags & H5O_HDR_STORE_TIMES) ? ( \ @@ -155,7 +148,7 @@ 0 + /*no magic # */ \ 0 /*no checksum */ \ : \ - H5O_SIZEOF_MAGIC + /*magic # */ \ + H5_SIZEOF_MAGIC + /*magic # */ \ H5O_SIZEOF_CHKSUM /*checksum */ \ ) #define H5O_SIZEOF_CHKHDR_OH(O) \ diff --git a/src/H5SMcache.c b/src/H5SMcache.c index e4af90e..021b43f 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -165,9 +165,9 @@ H5SM_table_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1 p = buf; /* Check magic number */ - if(HDmemcmp(p, H5SM_TABLE_MAGIC, (size_t)H5SM_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, NULL, "bad SOHM table signature") - p += H5SM_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Don't count the checksum in the table size yet, since it comes after * all of the index headers @@ -290,8 +290,8 @@ H5SM_table_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_ma p = buf; /* Encode magic number */ - HDmemcpy(p, H5SM_TABLE_MAGIC, (size_t)H5SM_SIZEOF_MAGIC); - p += H5SM_SIZEOF_MAGIC; + HDmemcpy(p, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; /* Encode each index header */ for(x = 0; x < table->num_indexes; ++x) { @@ -504,9 +504,9 @@ H5SM_list_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, p = buf; /* Check magic number */ - if(HDmemcmp(p, H5SM_LIST_MAGIC, (size_t)H5SM_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, NULL, "bad SOHM list signature") - p += H5SM_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Read messages into the list array */ for(x = 0; x < header->num_messages; x++) { @@ -598,8 +598,8 @@ H5SM_list_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_lis p = buf; /* Encode magic number */ - HDmemcpy(p, H5SM_LIST_MAGIC, (size_t)H5SM_SIZEOF_MAGIC); - p += H5SM_SIZEOF_MAGIC; + HDmemcpy(p, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC); + p += H5_SIZEOF_MAGIC; /* Write messages from the messages array to disk */ mesgs_written = 0; diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h index 8d987a9..dc69b2b 100755 --- a/src/H5SMpkg.h +++ b/src/H5SMpkg.h @@ -40,13 +40,6 @@ /* Package Macros */ /****************************/ -/* Size of signature information (on disk) */ -#define H5SM_SIZEOF_MAGIC 4 - -/* Shared Message signatures */ -#define H5SM_TABLE_MAGIC "SMTB" /* Shared Message Table */ -#define H5SM_LIST_MAGIC "SMLI" /* Shared Message List */ - /* Size of checksum information (on disk) */ #define H5SM_SIZEOF_CHECKSUM 4 @@ -69,7 +62,7 @@ ) #define H5SM_TABLE_SIZE(f) ( \ - H5SM_SIZEOF_MAGIC /* Signature */ \ + H5_SIZEOF_MAGIC /* Signature */ \ + H5SM_SIZEOF_CHECKSUM /* Checksum */ \ ) @@ -84,7 +77,7 @@ ) #define H5SM_LIST_SIZE(f, num_mesg) ( \ - H5SM_SIZEOF_MAGIC /* Signature */ \ + H5_SIZEOF_MAGIC /* Signature */ \ + (H5SM_SOHM_ENTRY_SIZE(f) * num_mesg) /* Message entries */ \ + H5SM_SIZEOF_CHECKSUM /* Checksum */ \ ) |