H5HLpkg.h

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 H5HL package. Source files outside the
00022  *              H5HL package should include H5HLprivate.h instead.
00023  */
00024 #ifndef H5HL_PACKAGE
00025 #error "Do not include this file outside the H5HL package!"
00026 #endif
00027 
00028 #ifndef _H5HLpkg_H
00029 #define _H5HLpkg_H
00030 
00031 /* Get package's private header */
00032 #include "H5HLprivate.h"
00033 
00034 /* Other private headers needed by this file */
00035 #include "H5FLprivate.h"        /* Free lists                           */
00036 
00037 
00038 /*****************************/
00039 /* Package Private Variables */
00040 /*****************************/
00041 
00042 /* The local heap prefix cache subclass */
00043 H5_DLLVAR const H5AC_class_t H5AC_LHEAP_PRFX[1];
00044 
00045 /* The local heap data block cache subclass */
00046 H5_DLLVAR const H5AC_class_t H5AC_LHEAP_DBLK[1];
00047 
00048 /* Declare extern the free list to manage the H5HL_free_t struct */
00049 H5FL_EXTERN(H5HL_free_t);
00050 
00051 /* Declare extern the PQ free list to manage the heap chunk information */
00052 H5FL_BLK_EXTERN(lheap_chunk);
00053 
00054 
00055 /**************************/
00056 /* Package Private Macros */
00057 /**************************/
00058 
00059 #define H5HL_SIZEOF_HDR(F)                                                    \
00060     H5HL_ALIGN(H5_SIZEOF_MAGIC +        /*heap signature                */    \
00061                1 +                      /*version                       */    \
00062                3 +                      /*reserved                      */    \
00063                H5F_SIZEOF_SIZE(F) +     /*data size                     */    \
00064                H5F_SIZEOF_SIZE(F) +     /*free list head                */    \
00065                H5F_SIZEOF_ADDR(F))      /*data address                  */
00066 
00067 /* Value indicating end of free list on disk */
00068 #define H5HL_FREE_NULL  1
00069 
00070 
00071 /****************************/
00072 /* Package Private Typedefs */
00073 /****************************/
00074 
00075 typedef struct H5HL_free_t {
00076     size_t              offset;         /*offset of free block          */
00077     size_t              size;           /*size of free block            */
00078     struct H5HL_free_t  *prev;          /*previous entry in free list   */
00079     struct H5HL_free_t  *next;          /*next entry in free list       */
00080 } H5HL_free_t;
00081 
00082 /* Forward declarations */
00083 typedef struct H5HL_dblk_t H5HL_dblk_t;
00084 typedef struct H5HL_prfx_t H5HL_prfx_t;
00085 
00086 struct H5HL_t {
00087     /* General heap-management fields */
00088     size_t                  rc;         /* Ref. count for prefix & data block using this struct */
00089     size_t                  prots;      /* # of times the heap has been protected */
00090     size_t                  sizeof_size; /* Size of file sizes */
00091     size_t                  sizeof_addr; /* Size of file addresses */
00092     hbool_t                 single_cache_obj;   /* Indicate if the heap is a single object in the cache */
00093 
00094     /* Prefix-specific fields */
00095     H5HL_prfx_t            *prfx;       /* The prefix object for the heap */
00096     haddr_t                 prfx_addr;  /* address of heap prefix */
00097     size_t                  prfx_size;  /* size of heap prefix */
00098 
00099     /* Data block-specific fields */
00100     H5HL_dblk_t            *dblk;       /* The data block object for the heap */
00101     haddr_t                 dblk_addr;  /* address of data block        */
00102     size_t                  dblk_size;  /* size of heap data block on disk and in mem */
00103     uint8_t                *dblk_image; /* The data block image */
00104     H5HL_free_t            *freelist;   /*the free list                 */
00105 };
00106 
00107 /* Struct for heap data block */
00108 struct H5HL_dblk_t {
00109     H5AC_info_t cache_info;    /* Information for H5AC cache functions, _must_ be */
00110                                 /* first field in structure */
00111     H5HL_t                 *heap;       /* Pointer to heap for data block */
00112 };
00113 
00114 /* Struct for heap prefix */
00115 struct H5HL_prfx_t {
00116     H5AC_info_t cache_info;    /* Information for H5AC cache functions, _must_ be */
00117                                 /* first field in structure */
00118     H5HL_t                 *heap;       /* Pointer to heap for prefix */
00119 };
00120 
00121 /* Callback information for loading local heap prefix from disk */
00122 typedef struct H5HL_cache_prfx_ud_t {
00123     /* Downwards */
00124     size_t sizeof_size;                 /* Size of file sizes */
00125     size_t sizeof_addr;                 /* Size of file addresses */
00126     size_t sizeof_prfx;                 /* Size of heap prefix */
00127 
00128     /* Upwards */
00129     hbool_t loaded;                     /* Whether prefix was loaded from file */
00130     hsize_t free_block;                 /* First free block in heap */
00131 } H5HL_cache_prfx_ud_t;
00132 
00133 /* Callback information for loading local heap data block from disk */
00134 typedef struct H5HL_cache_dblk_ud_t {
00135     /* Downwards */
00136     H5HL_t *heap;                       /* Local heap */
00137     hsize_t free_block;                 /* First free block in heap */
00138 
00139     /* Upwards */
00140     hbool_t loaded;                     /* Whether data block was loaded from file */
00141 } H5HL_cache_dblk_ud_t;
00142 
00143 
00144 /******************************/
00145 /* Package Private Prototypes */
00146 /******************************/
00147 
00148 /* Heap routines */
00149 H5_DLL H5HL_t *H5HL_new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size);
00150 H5_DLL herr_t H5HL_dest(H5HL_t *heap);
00151 
00152 /* Heap prefix routines */
00153 H5_DLL H5HL_prfx_t *H5HL_prfx_new(H5HL_t *heap);
00154 H5_DLL herr_t H5HL_prfx_dest(H5HL_prfx_t *prfx);
00155 
00156 /* Heap data block routines */
00157 H5_DLL H5HL_dblk_t *H5HL_dblk_new(H5HL_t *heap);
00158 H5_DLL herr_t H5HL_dblk_dest(H5HL_dblk_t *dblk);
00159 
00160 #endif /* _H5HLpkg_H */
00161