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@hdfgroup.org> 16 * Wednesday, July 9, 2003 17 * 18 * Purpose: This file contains declarations which are visible 19 * only within the H5HL package. Source files outside the 20 * H5HL package should include H5HLprivate.h instead. 21 */ 22 #if !(defined H5HL_FRIEND || defined H5HL_MODULE) 23 #error "Do not include this file outside the H5HL package!" 24 #endif 25 26 #ifndef _H5HLpkg_H 27 #define _H5HLpkg_H 28 29 /* Get package's private header */ 30 #include "H5HLprivate.h" 31 32 /* Other private headers needed by this file */ 33 #include "H5FLprivate.h" /* Free lists */ 34 35 36 /*****************************/ 37 /* Package Private Variables */ 38 /*****************************/ 39 40 /* Declare extern the free list to manage the H5HL_free_t struct */ 41 H5FL_EXTERN(H5HL_free_t); 42 43 /* Declare extern the PQ free list to manage the heap chunk information */ 44 H5FL_BLK_EXTERN(lheap_chunk); 45 46 47 /**************************/ 48 /* Package Private Macros */ 49 /**************************/ 50 51 /* If this package header is being included in one of the H5HL source files, 52 * define the proper control macros for the generic FUNC_ENTER/LEAVE and 53 * error reporting macros. 54 */ 55 #ifdef H5HL_PACKAGE 56 #define H5_MY_PKG H5HL 57 #define H5_MY_PKG_ERR H5E_HEAP 58 #define H5_MY_PKG_INIT NO 59 #endif /* H5HL_PACKAGE */ 60 61 #define H5HL_SIZEOF_HDR(F) \ 62 H5HL_ALIGN(H5_SIZEOF_MAGIC + /* heap signature */ \ 63 1 + /* version */ \ 64 3 + /* reserved */ \ 65 H5F_SIZEOF_SIZE(F) + /* data size */ \ 66 H5F_SIZEOF_SIZE(F) + /* free list head */ \ 67 H5F_SIZEOF_ADDR(F)) /* data address */ 68 69 /* Value indicating end of free list on disk */ 70 #define H5HL_FREE_NULL 1 71 72 73 /****************************/ 74 /* Package Private Typedefs */ 75 /****************************/ 76 77 typedef struct H5HL_free_t { 78 size_t offset; /* offset of free block */ 79 size_t size; /* size of free block */ 80 struct H5HL_free_t *prev; /* previous entry in free list */ 81 struct H5HL_free_t *next; /* next entry in free list */ 82 } H5HL_free_t; 83 84 /* Forward declarations */ 85 typedef struct H5HL_dblk_t H5HL_dblk_t; 86 typedef struct H5HL_prfx_t H5HL_prfx_t; 87 88 struct H5HL_t { 89 /* General heap-management fields */ 90 size_t rc; /* Ref. count for prefix & data block using this struct */ 91 size_t prots; /* # of times the heap has been protected */ 92 size_t sizeof_size; /* Size of file sizes */ 93 size_t sizeof_addr; /* Size of file addresses */ 94 hbool_t single_cache_obj; /* Indicate if the heap is a single object in the cache */ 95 H5HL_free_t *freelist; /* the free list */ 96 97 /* Prefix-specific fields */ 98 H5HL_prfx_t *prfx; /* The prefix object for the heap */ 99 haddr_t prfx_addr; /* address of heap prefix */ 100 size_t prfx_size; /* size of heap prefix */ 101 hsize_t free_block; /* Address of first free block */ 102 103 /* Data block-specific fields */ 104 H5HL_dblk_t *dblk; /* The data block object for the heap */ 105 haddr_t dblk_addr; /* address of data block */ 106 size_t dblk_size; /* size of heap data block on disk and in mem */ 107 uint8_t *dblk_image; /* The data block image */ 108 }; 109 110 /* Struct for heap data block */ 111 struct H5HL_dblk_t { 112 H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ 113 /* first field in structure */ 114 H5HL_t *heap; /* Pointer to heap for data block */ 115 }; 116 117 /* Struct for heap prefix */ 118 struct H5HL_prfx_t { 119 H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ 120 /* first field in structure */ 121 H5HL_t *heap; /* Pointer to heap for prefix */ 122 }; 123 124 /* Callback information for loading local heap prefix from disk */ 125 typedef struct H5HL_cache_prfx_ud_t { 126 size_t sizeof_size; /* Size of file sizes */ 127 size_t sizeof_addr; /* Size of file addresses */ 128 haddr_t prfx_addr; /* Address of prefix */ 129 size_t sizeof_prfx; /* Size of heap prefix */ 130 } H5HL_cache_prfx_ud_t; 131 132 133 /******************************/ 134 /* Package Private Prototypes */ 135 /******************************/ 136 137 /* Heap routines */ 138 H5_DLL H5HL_t *H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size); 139 H5_DLL herr_t H5HL__dest(H5HL_t *heap); 140 H5_DLL herr_t H5HL__inc_rc(H5HL_t *heap); 141 H5_DLL herr_t H5HL__dec_rc(H5HL_t *heap); 142 143 /* Heap prefix routines */ 144 H5_DLL H5HL_prfx_t *H5HL__prfx_new(H5HL_t *heap); 145 H5_DLL herr_t H5HL__prfx_dest(H5HL_prfx_t *prfx); 146 147 /* Heap data block routines */ 148 H5_DLL H5HL_dblk_t *H5HL__dblk_new(H5HL_t *heap); 149 H5_DLL herr_t H5HL__dblk_dest(H5HL_dblk_t *dblk); 150 H5_DLL herr_t H5HL__dblk_realloc(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t new_heap_size); 151 152 #endif /* _H5HLpkg_H */ 153