diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-05-15 19:22:33 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-05-15 19:22:33 (GMT) |
commit | b496ac1482d97086112c890a0154ce9e1522a815 (patch) | |
tree | f3c3ae6ccff7a59bb73e8fe9433f656dfaea680c /src/H5HG.c | |
parent | f36a66b6fb7fb2eed7c8656972d6ce8ec9e75f8c (diff) | |
download | hdf5-b496ac1482d97086112c890a0154ce9e1522a815.zip hdf5-b496ac1482d97086112c890a0154ce9e1522a815.tar.gz hdf5-b496ac1482d97086112c890a0154ce9e1522a815.tar.bz2 |
[svn-r6878] Purpose:
Code cleanup
Description:
Limit the scope on more function prototypes/macros/typedefs.
Platforms tested:
FreeBSD 4.8 (sleipnir)
h5committest not necessary.
Diffstat (limited to 'src/H5HG.c')
-rw-r--r-- | src/H5HG.c | 105 |
1 files changed, 94 insertions, 11 deletions
@@ -35,20 +35,97 @@ * for a new object based on object size, amount of free space * in the collection, and temporal locality. */ + #define H5F_PACKAGE /*suppress error about including H5Fpkg */ -#include "H5private.h" /*library */ -#include "H5ACprivate.h" /*caching */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Fpkg.h" /*file access */ -#include "H5FLprivate.h" /*Free Lists */ -#include "H5HGprivate.h" /*global heaps */ -#include "H5MFprivate.h" /*file memory management */ -#include "H5MMprivate.h" /*core memory management */ -#include "H5Pprivate.h" /*property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5HGprivate.h" /* Global heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +/* Pablo information */ #define PABLO_MASK H5HG_mask +/* Private macros */ + +/* + * Global heap collection version. + */ +#define H5HG_VERSION 1 + +/* + * Pad all global heap messages to a multiple of eight bytes so we can load + * the entire collection into memory and operate on it there. Eight should + * be sufficient for machines that have alignment constraints because our + * largest data type is eight bytes. + */ +#define H5HG_ALIGNMENT 8 +#define H5HG_ALIGN(X) (H5HG_ALIGNMENT*(((X)+H5HG_ALIGNMENT-1)/ \ + H5HG_ALIGNMENT)) +#define H5HG_ISALIGNED(X) ((X)==H5HG_ALIGN(X)) + +/* + * All global heap collections are at least this big. This allows us to read + * most collections with a single read() since we don't have to read a few + * bytes of header to figure out the size. If the heap is larger than this + * then a second read gets the rest after we've decoded the header. + */ +#define H5HG_MINSIZE 4096 + +/* + * Maximum length of the CWFS list, the list of remembered collections that + * have free space. + */ +#define H5HG_NCWFS 16 + +/* + * The maximum number of links allowed to a global heap object. + */ +#define H5HG_MAXLINK 65535 + +/* + * The size of the collection header, always a multiple of the alignment so + * that the stuff that follows the header is aligned. + */ +#define H5HG_SIZEOF_HDR(f) \ + H5HG_ALIGN(4 + /*magic number */ \ + 1 + /*version number */ \ + 3 + /*reserved */ \ + H5F_SIZEOF_SIZE(f)) /*collection size */ + +/* + * The overhead associated with each object in the heap, always a multiple of + * the alignment so that the stuff that follows the header is aligned. + */ +#define H5HG_SIZEOF_OBJHDR(f) \ + H5HG_ALIGN(2 + /*object id number */ \ + 2 + /*reference count */ \ + 4 + /*reserved */ \ + H5F_SIZEOF_SIZE(f)) /*object data size */ + +/* + * The initial guess for the number of messages in a collection. We assume + * that all objects in that collection are zero length, giving the maximum + * possible number of objects in the collection. The collection itself has + * some overhead and each message has some overhead. The `+2' accounts for + * rounding and for the free space object. + */ +#define H5HG_NOBJS(f,z) (int)((((z)-H5HG_SIZEOF_HDR(f))/ \ + H5HG_SIZEOF_OBJHDR(f)+2)) + +/* + * Makes a global heap object pointer undefined, or checks whether one is + * defined. + */ +#define H5HG_undef(HGP) ((HGP)->idx=0) +#define H5HG_defined(HGP) ((HGP)->idx!=0) + +/* Private typedefs */ + typedef struct H5HG_obj_t { int nrefs; /*reference count */ size_t size; /*total size of object */ @@ -66,6 +143,10 @@ struct H5HG_heap_t { }; /* PRIVATE PROTOTYPES */ +static H5HG_heap_t *H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size); +#ifdef NOT_YET +static void *H5HG_peek(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj); +#endif /* NOT_YET */ /* Metadata cache callbacks */ static H5HG_heap_t *H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata1, @@ -121,7 +202,7 @@ H5FL_BLK_DEFINE_STATIC(heap_chunk); * *------------------------------------------------------------------------- */ -H5HG_heap_t * +static H5HG_heap_t * H5HG_create (H5F_t *f, hid_t dxpl_id, size_t size) { H5HG_heap_t *heap = NULL; @@ -675,6 +756,7 @@ done: FUNC_LEAVE_NOAPI(ret_value); } +#ifdef NOT_YET /*------------------------------------------------------------------------- * Function: H5HG_peek @@ -697,7 +779,7 @@ done: * *------------------------------------------------------------------------- */ -void * +static void * H5HG_peek (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj) { H5HG_heap_t *heap = NULL; @@ -736,6 +818,7 @@ H5HG_peek (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj) done: FUNC_LEAVE_NOAPI(ret_value); } +#endif /* NOT_YET */ /*------------------------------------------------------------------------- |