00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00002 * Copyright by The HDF Group. * 00003 * Copyright by the Board of Trustees of the University of Illinois. * 00004 * All rights reserved. * 00005 * * 00006 * This file is part of HDF5. The full HDF5 copyright notice, including * 00007 * terms governing use, modification, and redistribution, is contained in * 00008 * the files COPYING and Copyright.html. COPYING can be found at the root * 00009 * of the source code distribution tree; Copyright.html can be found at the * 00010 * root level of an installed copy of the electronic HDF5 document set and * 00011 * is linked from the top-level documents page. It can also be found at * 00012 * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 00013 * access to either file, you may request a copy from help@hdfgroup.org. * 00014 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00015 00016 /* 00017 * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> 00018 * Wednesday, July 9, 2003 00019 * 00020 * Purpose: This file contains declarations which are visible 00021 * only within the H5HG package. Source files outside the 00022 * H5HG package should include H5HGprivate.h instead. 00023 */ 00024 #ifndef H5HG_PACKAGE 00025 #error "Do not include this file outside the H5HG package!" 00026 #endif 00027 00028 #ifndef _H5HGpkg_H 00029 #define _H5HGpkg_H 00030 00031 /* Get package's private header */ 00032 #include "H5HGprivate.h" 00033 00034 /* Other private headers needed by this file */ 00035 #include "H5ACprivate.h" /* Metadata cache */ 00036 #include "H5FLprivate.h" /* Free lists */ 00037 00038 00039 /*****************************/ 00040 /* Package Private Variables */ 00041 /*****************************/ 00042 00043 /* The cache subclass */ 00044 H5_DLLVAR const H5AC_class_t H5AC_GHEAP[1]; 00045 00046 /* Declare extern the free list to manage the H5HG_t struct */ 00047 H5FL_EXTERN(H5HG_heap_t); 00048 00049 /* Declare extern the free list to manage sequences of H5HG_obj_t's */ 00050 H5FL_SEQ_EXTERN(H5HG_obj_t); 00051 00052 /* Declare extern the PQ free list to manage heap chunks */ 00053 H5FL_BLK_EXTERN(gheap_chunk); 00054 00055 00056 /**************************/ 00057 /* Package Private Macros */ 00058 /**************************/ 00059 00060 /* 00061 * Global heap collection version. 00062 */ 00063 #define H5HG_VERSION 1 00064 00065 /* 00066 * All global heap collections are at least this big. This allows us to read 00067 * most collections with a single read() since we don't have to read a few 00068 * bytes of header to figure out the size. If the heap is larger than this 00069 * then a second read gets the rest after we've decoded the header. 00070 */ 00071 #define H5HG_MINSIZE 4096 00072 00073 /* 00074 * Maximum length of the CWFS list, the list of remembered collections that 00075 * have free space. 00076 */ 00077 #define H5HG_NCWFS 16 00078 00079 /* 00080 * Pad all global heap messages to a multiple of eight bytes so we can load 00081 * the entire collection into memory and operate on it there. Eight should 00082 * be sufficient for machines that have alignment constraints because our 00083 * largest data type is eight bytes. 00084 */ 00085 #define H5HG_ALIGNMENT 8 00086 #define H5HG_ALIGN(X) (H5HG_ALIGNMENT*(((X)+H5HG_ALIGNMENT-1)/ \ 00087 H5HG_ALIGNMENT)) 00088 #define H5HG_ISALIGNED(X) ((X)==H5HG_ALIGN(X)) 00089 00090 /* 00091 * The size of the collection header, always a multiple of the alignment so 00092 * that the stuff that follows the header is aligned. 00093 */ 00094 #define H5HG_SIZEOF_HDR(f) \ 00095 H5HG_ALIGN(4 + /*magic number */ \ 00096 1 + /*version number */ \ 00097 3 + /*reserved */ \ 00098 H5F_SIZEOF_SIZE(f)) /*collection size */ 00099 00100 /* 00101 * The overhead associated with each object in the heap, always a multiple of 00102 * the alignment so that the stuff that follows the header is aligned. 00103 */ 00104 #define H5HG_SIZEOF_OBJHDR(f) \ 00105 H5HG_ALIGN(2 + /*object id number */ \ 00106 2 + /*reference count */ \ 00107 4 + /*reserved */ \ 00108 H5F_SIZEOF_SIZE(f)) /*object data size */ 00109 00110 /* 00111 * The initial guess for the number of messages in a collection. We assume 00112 * that all objects in that collection are zero length, giving the maximum 00113 * possible number of objects in the collection. The collection itself has 00114 * some overhead and each message has some overhead. The `+2' accounts for 00115 * rounding and for the free space object. 00116 */ 00117 #define H5HG_NOBJS(f,z) (int)((((z)-H5HG_SIZEOF_HDR(f))/ \ 00118 H5HG_SIZEOF_OBJHDR(f)+2)) 00119 00120 00121 /****************************/ 00122 /* Package Private Typedefs */ 00123 /****************************/ 00124 00125 typedef struct H5HG_obj_t { 00126 int nrefs; /*reference count */ 00127 size_t size; /*total size of object */ 00128 uint8_t *begin; /*ptr to object into heap->chunk*/ 00129 } H5HG_obj_t; 00130 00131 struct H5HG_heap_t { 00132 H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ 00133 /* first field in structure */ 00134 haddr_t addr; /*collection address */ 00135 size_t size; /*total size of collection */ 00136 uint8_t *chunk; /*the collection, incl. header */ 00137 size_t nalloc; /*numb object slots allocated */ 00138 size_t nused; /*number of slots used */ 00139 /* If this value is >65535 then all indices */ 00140 /* have been used at some time and the */ 00141 /* correct new index should be searched for */ 00142 H5HG_obj_t *obj; /*array of object descriptions */ 00143 }; 00144 00145 /******************************/ 00146 /* Package Private Prototypes */ 00147 /******************************/ 00148 H5_DLL herr_t H5HG_dest(H5F_t *f, H5HG_heap_t *heap); 00149 00150 #endif /* _H5HGpkg_H */ 00151