MISR Toolkit  1.5.1
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 #ifndef H5HG_PACKAGE
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 /* The cache subclass */
42 H5_DLLVAR const H5AC_class_t H5AC_GHEAP[1];
43 
44 /* Declare extern the free list to manage the H5HG_t struct */
46 
47 /* Declare extern the free list to manage sequences of H5HG_obj_t's */
49 
50 /* Declare extern the PQ free list to manage heap chunks */
51 H5FL_BLK_EXTERN(gheap_chunk);
52 
53 
54 /**************************/
55 /* Package Private Macros */
56 /**************************/
57 
58 /*
59  * Global heap collection version.
60  */
61 #define H5HG_VERSION 1
62 
63 /*
64  * All global heap collections are at least this big. This allows us to read
65  * most collections with a single read() since we don't have to read a few
66  * bytes of header to figure out the size. If the heap is larger than this
67  * then a second read gets the rest after we've decoded the header.
68  */
69 #define H5HG_MINSIZE 4096
70 
71 /*
72  * Pad all global heap messages to a multiple of eight bytes so we can load
73  * the entire collection into memory and operate on it there. Eight should
74  * be sufficient for machines that have alignment constraints because our
75  * largest data type is eight bytes.
76  */
77 #define H5HG_ALIGNMENT 8
78 #define H5HG_ALIGN(X) (H5HG_ALIGNMENT*(((X)+H5HG_ALIGNMENT-1)/H5HG_ALIGNMENT))
79 #define H5HG_ISALIGNED(X) ((X)==H5HG_ALIGN(X))
80 
81 /*
82  * The size of the collection header, always a multiple of the alignment so
83  * that the stuff that follows the header is aligned.
84  */
85 #define H5HG_SIZEOF_HDR(f) \
86  (size_t)H5HG_ALIGN(4 + /*magic number */ \
87  1 + /*version number */ \
88  3 + /*reserved */ \
89  H5F_SIZEOF_SIZE(f)) /*collection size */
90 
91 /*
92  * The overhead associated with each object in the heap, always a multiple of
93  * the alignment so that the stuff that follows the header is aligned.
94  */
95 #define H5HG_SIZEOF_OBJHDR(f) \
96  (size_t)H5HG_ALIGN(2 + /*object id number */ \
97  2 + /*reference count */ \
98  4 + /*reserved */ \
99  H5F_SIZEOF_SIZE(f)) /*object data size */
100 
101 /*
102  * The initial guess for the number of messages in a collection. We assume
103  * that all objects in that collection are zero length, giving the maximum
104  * possible number of objects in the collection. The collection itself has
105  * some overhead and each message has some overhead. The `+2' accounts for
106  * rounding and for the free space object.
107  */
108 #define H5HG_NOBJS(f,z) ((((z)-H5HG_SIZEOF_HDR(f))/ \
109  H5HG_SIZEOF_OBJHDR(f)+2))
110 
111 
112 /****************************/
113 /* Package Private Typedefs */
114 /****************************/
115 
116 typedef struct H5HG_obj_t {
117  int nrefs; /*reference count */
118  size_t size; /*total size of object */
119  uint8_t *begin; /*ptr to object into heap->chunk*/
120 } H5HG_obj_t;
121 
122 /* Forward declarations for fields */
123 struct H5F_file_t;
124 
125 struct H5HG_heap_t {
126  H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
127  /* first field in structure */
128  haddr_t addr; /*collection address */
129  size_t size; /*total size of collection */
130  uint8_t *chunk; /*the collection, incl. header */
131  size_t nalloc; /*numb object slots allocated */
132  size_t nused; /*number of slots used */
133  /* If this value is >65535 then all indices */
134  /* have been used at some time and the */
135  /* correct new index should be searched for */
136  struct H5F_file_t *shared; /* shared file */
137  H5HG_obj_t *obj; /*array of object descriptions */
138 };
139 
140 /******************************/
141 /* Package Private Prototypes */
142 /******************************/
144 H5_DLL H5HG_heap_t *H5HG_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5AC_protect_t rw);
145 
146 #endif /* _H5HGpkg_H */
147 
H5_DLLVAR const H5AC_class_t H5AC_GHEAP[1]
Definition: H5HGpkg.h:42
size_t nalloc
Definition: H5HGpkg.h:131
size_t size
Definition: H5HGpkg.h:118
#define H5_DLL
Definition: H5api_adpt.h:256
H5_DLL H5HG_heap_t * H5HG_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5AC_protect_t rw)
int herr_t
Definition: H5public.h:124
size_t size
Definition: H5HGpkg.h:129
uint8_t * begin
Definition: H5HGpkg.h:119
uint8_t * chunk
Definition: H5HGpkg.h:130
haddr_t addr
Definition: H5HGpkg.h:128
H5AC_info_t cache_info
Definition: H5HGpkg.h:126
H5FL_SEQ_EXTERN(H5HG_obj_t)
H5FL_BLK_EXTERN(gheap_chunk)
uint64_t haddr_t
Definition: H5public.h:182
int hid_t
Definition: H5Ipublic.h:54
int nrefs
Definition: H5HGpkg.h:117
struct H5F_file_t * shared
Definition: H5HGpkg.h:136
size_t nused
Definition: H5HGpkg.h:132
#define H5_DLLVAR
Definition: H5api_adpt.h:257
H5_DLL herr_t H5HG_free(H5HG_heap_t *heap)
H5FL_EXTERN(H5HG_heap_t)
Definition: H5Fpkg.h:255
H5HG_obj_t * obj
Definition: H5HGpkg.h:137
struct H5HG_obj_t H5HG_obj_t

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:52