HDF5  1.12.0
H5HGpkg.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group. *
3  * Copyright by the Board of Trustees of the University of Illinois. *
4  * All rights reserved. *
5  * *
6  * This file is part of HDF5. The full HDF5 copyright notice, including *
7  * terms governing use, modification, and redistribution, is contained in *
8  * the COPYING file, which can be found at the root of the source code *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10  * If you do not have access to either file, you may request a copy from *
11  * help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*
15  * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
16  * Wednesday, July 9, 2003
17  *
18  * Purpose: This file contains declarations which are visible
19  * only within the H5HG package. Source files outside the
20  * H5HG package should include H5HGprivate.h instead.
21  */
22 #if !(defined H5HG_FRIEND || defined H5HG_MODULE)
23 #error "Do not include this file outside the H5HG package!"
24 #endif
25 
26 #ifndef _H5HGpkg_H
27 #define _H5HGpkg_H
28 
29 /* Get package's private header */
30 #include "H5HGprivate.h"
31 
32 /* Other private headers needed by this file */
33 #include "H5ACprivate.h" /* Metadata cache */
34 #include "H5FLprivate.h" /* Free lists */
35 
36 
37 /*****************************/
38 /* Package Private Variables */
39 /*****************************/
40 
41 /* Declare extern the free list to manage the H5HG_t struct */
43 
44 /* Declare extern the free list to manage sequences of H5HG_obj_t's */
46 
47 /* Declare extern the PQ free list to manage heap chunks */
48 H5FL_BLK_EXTERN(gheap_chunk);
49 
50 
51 /**************************/
52 /* Package Private Macros */
53 /**************************/
54 
55 /*
56  * Global heap collection version.
57  */
58 #define H5HG_VERSION 1
59 
60 /*
61  * All global heap collections are at least this big. This allows us to read
62  * most collections with a single read() since we don't have to read a few
63  * bytes of header to figure out the size. If the heap is larger than this
64  * then a second read gets the rest after we've decoded the header.
65  */
66 #define H5HG_MINSIZE 4096
67 
68 /*
69  * Pad all global heap messages to a multiple of eight bytes so we can load
70  * the entire collection into memory and operate on it there. Eight should
71  * be sufficient for machines that have alignment constraints because our
72  * largest data type is eight bytes.
73  */
74 #define H5HG_ALIGNMENT 8
75 #define H5HG_ALIGN(X) (H5HG_ALIGNMENT*(((X)+H5HG_ALIGNMENT-1)/H5HG_ALIGNMENT))
76 #define H5HG_ISALIGNED(X) ((X)==H5HG_ALIGN(X))
77 
78 /*
79  * The size of the collection header, always a multiple of the alignment so
80  * that the stuff that follows the header is aligned.
81  */
82 #define H5HG_SIZEOF_HDR(f) \
83  (size_t)H5HG_ALIGN(4 + /*magic number */ \
84  1 + /*version number */ \
85  3 + /*reserved */ \
86  H5F_SIZEOF_SIZE(f)) /*collection size */
87 
88 /*
89  * The overhead associated with each object in the heap, always a multiple of
90  * the alignment so that the stuff that follows the header is aligned.
91  */
92 #define H5HG_SIZEOF_OBJHDR(f) \
93  (size_t)H5HG_ALIGN(2 + /*object id number */ \
94  2 + /*reference count */ \
95  4 + /*reserved */ \
96  H5F_SIZEOF_SIZE(f)) /*object data size */
97 
98 /*
99  * The initial guess for the number of messages in a collection. We assume
100  * that all objects in that collection are zero length, giving the maximum
101  * possible number of objects in the collection. The collection itself has
102  * some overhead and each message has some overhead. The `+2' accounts for
103  * rounding and for the free space object.
104  */
105 #define H5HG_NOBJS(f,z) ((((z)-H5HG_SIZEOF_HDR(f))/ \
106  H5HG_SIZEOF_OBJHDR(f)+2))
107 
108 
109 /****************************/
110 /* Package Private Typedefs */
111 /****************************/
112 
113 typedef struct H5HG_obj_t {
114  int nrefs; /* reference count */
115  size_t size; /* total size of object */
116  uint8_t *begin; /* ptr to object into heap->chunk */
118 
119 /* Forward declarations for fields */
120 struct H5F_shared_t;
121 
122 struct H5HG_heap_t {
123  H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
124  /* first field in structure */
125  haddr_t addr; /*collection address */
126  size_t size; /*total size of collection */
127  uint8_t *chunk; /*the collection, incl. header */
128  size_t nalloc; /*numb object slots allocated */
129  size_t nused; /*number of slots used */
130  /* If this value is >65535 then all indices */
131  /* have been used at some time and the */
132  /* correct new index should be searched for */
133  struct H5F_shared_t *shared; /* shared file */
134  H5HG_obj_t *obj; /*array of object descriptions */
135 };
136 
137 /******************************/
138 /* Package Private Prototypes */
139 /******************************/
141 H5_DLL H5HG_heap_t *H5HG__protect(H5F_t *f, haddr_t addr, unsigned flags);
142 
143 #endif /* _H5HGpkg_H */
144 
H5HG_heap_t::nused
size_t nused
Definition: H5HGpkg.h:129
f
hdr f
Definition: H5EA.c:755
H5FL_EXTERN
H5FL_EXTERN(H5HG_heap_t)
H5HG_heap_t::obj
H5HG_obj_t * obj
Definition: H5HGpkg.h:134
haddr_t
CATCH haddr_t
Definition: H5EAdblock.c:162
H5HG_heap_t::addr
haddr_t addr
Definition: H5HGpkg.h:125
uint8_t
unsigned char uint8_t
Definition: H5private.h:429
H5FL_BLK_EXTERN
H5FL_BLK_EXTERN(gheap_chunk)
H5HG_heap_t::shared
struct H5F_shared_t * shared
Definition: H5HGpkg.h:133
H5HGprivate.h
H5HG_heap_t::cache_info
H5AC_info_t cache_info
Definition: H5HGpkg.h:123
H5HG__free
H5_DLL herr_t H5HG__free(H5HG_heap_t *heap)
Definition: H5HG.c:861
H5F_shared_t
Definition: H5Fpkg.h:242
H5HG_obj_t::size
size_t size
Definition: H5HGpkg.h:115
H5HG_heap_t
Definition: H5HGpkg.h:122
H5ACprivate.h
H5HG_obj_t
struct H5HG_obj_t H5HG_obj_t
H5HG__protect
H5_DLL H5HG_heap_t * H5HG__protect(H5F_t *f, haddr_t addr, unsigned flags)
Definition: H5HG.c:248
H5HG_heap_t::chunk
uint8_t * chunk
Definition: H5HGpkg.h:127
H5_DLL
#define H5_DLL
Definition: H5api_adpt.h:234
heap
CATCH unable to release unprotect heap
Definition: H5HLdbg.c:119
H5HG_heap_t::nalloc
size_t nalloc
Definition: H5HGpkg.h:128
H5HG_obj_t::begin
uint8_t * begin
Definition: H5HGpkg.h:116
H5HG_obj_t::nrefs
int nrefs
Definition: H5HGpkg.h:114
H5F_t
Definition: H5Fpkg.h:374
H5FLprivate.h
herr_t
int herr_t
Definition: H5public.h:128
H5HG_obj_t
Definition: H5HGpkg.h:113
H5C_cache_entry_t
Definition: H5Cprivate.h:1597
H5F_shared_t::flags
unsigned flags
Definition: H5Fpkg.h:261
H5FL_SEQ_EXTERN
H5FL_SEQ_EXTERN(H5HG_obj_t)
H5HG_heap_t::size
size_t size
Definition: H5HGpkg.h:126