diff options
author | David Young <dyoung@hdfgroup.org> | 2020-09-03 21:13:47 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2020-09-03 21:13:47 (GMT) |
commit | d85cd245d29d72990ded9fdf60a2b849a85b1912 (patch) | |
tree | 83aaf2f0b9acc06c1d69af4c843fa23927822efb /src/H5Ofsinfo.c | |
parent | 651facc1446c36e6d77cc328682dac397bae27e3 (diff) | |
parent | b3a89155b986bca9c436d4ff6c229a68ac23f1ef (diff) | |
download | hdf5-d85cd245d29d72990ded9fdf60a2b849a85b1912.zip hdf5-d85cd245d29d72990ded9fdf60a2b849a85b1912.tar.gz hdf5-d85cd245d29d72990ded9fdf60a2b849a85b1912.tar.bz2 |
Merge remote-tracking branch 'hdffv/develop' into rebased-fprintf-experiment
Diffstat (limited to 'src/H5Ofsinfo.c')
-rw-r--r-- | src/H5Ofsinfo.c | 249 |
1 files changed, 123 insertions, 126 deletions
diff --git a/src/H5Ofsinfo.c b/src/H5Ofsinfo.c index dcfb1fe..a6406d5 100644 --- a/src/H5Ofsinfo.c +++ b/src/H5Ofsinfo.c @@ -15,7 +15,7 @@ * * Created: H5Ofsinfo.c * Feb 2009 - * Vailin Choi + * Vailin Choi * * Purpose: File space info message. * @@ -25,44 +25,44 @@ #include "H5Omodule.h" /* This source code file is part of the H5O module */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Opkg.h" /* Object headers */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void *H5O_fsinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, +static void *H5O__fsinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); -static herr_t H5O_fsinfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void *H5O_fsinfo_copy(const void *_mesg, void *_dest); -static size_t H5O_fsinfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); +static herr_t H5O__fsinfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); +static void *H5O__fsinfo_copy(const void *_mesg, void *_dest); +static size_t H5O__fsinfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__fsinfo_free(void *mesg); static herr_t H5O__fsinfo_debug(H5F_t *f, const void *_mesg, FILE * stream, int indent, int fwidth); /* This message derives from H5O message class */ const H5O_msg_class_t H5O_MSG_FSINFO[1] = {{ - H5O_FSINFO_ID, /* message id number */ - "fsinfo", /* message name for debugging */ - sizeof(H5O_fsinfo_t), /* native message size */ - 0, /* messages are sharable? */ - H5O_fsinfo_decode, /* decode message */ - H5O_fsinfo_encode, /* encode message */ - H5O_fsinfo_copy, /* copy the native value */ - H5O_fsinfo_size, /* size of free-space manager info message */ - NULL, /* default reset method */ - H5O__fsinfo_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /* set share method */ - NULL, /* can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__fsinfo_debug /* debug the message */ + H5O_FSINFO_ID, /* message id number */ + "fsinfo", /* message name for debugging */ + sizeof(H5O_fsinfo_t), /* native message size */ + 0, /* messages are sharable? */ + H5O__fsinfo_decode, /* decode message */ + H5O__fsinfo_encode, /* encode message */ + H5O__fsinfo_copy, /* copy the native value */ + H5O__fsinfo_size, /* size of free-space manager info message */ + NULL, /* default reset method */ + H5O__fsinfo_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /* set share method */ + NULL, /* can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__fsinfo_debug /* debug the message */ }}; /* Format version bounds for fsinfo message */ @@ -81,7 +81,7 @@ H5FL_DEFINE_STATIC(H5O_fsinfo_t); /*------------------------------------------------------------------------- - * Function: H5O_fsinfo_decode + * Function: H5O__fsinfo_decode * * Purpose: Decode a message and return a pointer to a newly allocated one. * @@ -93,7 +93,7 @@ H5FL_DEFINE_STATIC(H5O_fsinfo_t); *------------------------------------------------------------------------- */ static void * -H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, +H5O__fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { @@ -102,7 +102,7 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned vers; /* message version */ void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(f); @@ -110,7 +110,7 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, /* Allocate space for message */ if(NULL == (fsinfo = H5FL_CALLOC(H5O_fsinfo_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) fsinfo->fs_addr[ptype - 1] = HADDR_UNDEF; @@ -134,7 +134,6 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, /* Map version 0 (deprecated) to version 1 message */ switch(strategy) { - case H5F_FILE_SPACE_ALL_PERSIST: fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; fsinfo->persist = TRUE; @@ -166,8 +165,8 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, fsinfo->version = H5O_FSINFO_VERSION_1; fsinfo->mapped = TRUE; - - } else { + } + else { HDassert(vers >= H5O_FSINFO_VERSION_1); fsinfo->version = vers; @@ -180,10 +179,9 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, H5F_addr_decode(f, &p, &(fsinfo->eoa_pre_fsm_fsalloc)); /* EOA before free-space header and section info */ /* Decode addresses of free space managers, if persisting */ - if(fsinfo->persist) { + if(fsinfo->persist) for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) H5F_addr_decode(f, &p, &(fsinfo->fs_addr[ptype - 1])); - } /* end if */ fsinfo->mapped = FALSE; } @@ -196,11 +194,11 @@ done: fsinfo = H5FL_FREE(H5O_fsinfo_t, fsinfo); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_fsinfo_decode() */ +} /* end H5O__fsinfo_decode() */ /*------------------------------------------------------------------------- - * Function: H5O_fsinfo_encode + * Function: H5O__fsinfo_encode * * Purpose: Encodes a message. * @@ -211,12 +209,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; H5F_mem_page_t ptype; /* Memory type for iteration */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -233,18 +231,17 @@ H5O_fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c H5F_addr_encode(f, &p, fsinfo->eoa_pre_fsm_fsalloc); /* EOA before free-space header and section info */ /* Store addresses of free-space managers, if persisting */ - if(fsinfo->persist) { + if(fsinfo->persist) /* Addresses of free-space managers */ for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) H5F_addr_encode(f, &p, fsinfo->fs_addr[ptype - 1]); - } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_fsinfo_encode() */ +} /* end H5O__fsinfo_encode() */ /*------------------------------------------------------------------------- - * Function: H5O_fsinfo_copy + * Function: H5O__fsinfo_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. @@ -257,13 +254,13 @@ H5O_fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c *------------------------------------------------------------------------- */ static void * -H5O_fsinfo_copy(const void *_mesg, void *_dest) +H5O__fsinfo_copy(const void *_mesg, void *_dest) { const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; H5O_fsinfo_t *dest = (H5O_fsinfo_t *) _dest; void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(fsinfo); @@ -278,11 +275,11 @@ H5O_fsinfo_copy(const void *_mesg, void *_dest) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_fsinfo_copy() */ +} /* end H5O__fsinfo_copy() */ /*------------------------------------------------------------------------- - * Function: H5O_fsinfo_size + * Function: H5O__fsinfo_size * * Purpose: Returns the size of the raw message in bytes not counting * the message type or size fields, but only the data fields. @@ -296,12 +293,12 @@ done: *------------------------------------------------------------------------- */ static size_t -H5O_fsinfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) +H5O__fsinfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR ret_value = 3 /* Version, strategy & persist */ + (size_t)H5F_SIZEOF_SIZE(f) /* Free-space section threshold */ @@ -314,7 +311,7 @@ H5O_fsinfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const voi ret_value += (H5F_MEM_PAGE_NTYPES - 1) * (size_t)H5F_SIZEOF_ADDR(f); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_fsinfo_size() */ +} /* end H5O__fsinfo_size() */ /*------------------------------------------------------------------------- @@ -342,79 +339,6 @@ H5O__fsinfo_free(void *mesg) /*------------------------------------------------------------------------- - * Function: H5O_fsinfo_set_version - * - * Purpose: Set the version to encode the fsinfo message with. - * - * Return: SUCCEED/FAIL - * - * Programmer: Vailin Choi; June 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_fsinfo_set_version(H5F_libver_t low, H5F_libver_t high, H5O_fsinfo_t *fsinfo) -{ - unsigned version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDcompile_assert(N_FSINFO_VERSION_BOUNDS == H5F_LIBVER_NBOUNDS); - HDassert(fsinfo); - - version = H5O_FSINFO_VERSION_1; - - /* Upgrade to the version indicated by the file's low bound if higher */ - if(H5O_fsinfo_ver_bounds[low] != H5O_INVALID_VERSION) - version = MAX(version, H5O_fsinfo_ver_bounds[low]); - - /* Version bounds check */ - if(H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || version > H5O_fsinfo_ver_bounds[high]) - HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds") - - /* Set the message version */ - fsinfo->version = version; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_fsinfo_set_version() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_fsinfo_check_version - * - * Purpose: Validate the fsinfo message version - * - * Return: SUCCEED/FAIL - * - * Programmer: Dana Robinson - * Summer 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_fsinfo_check_version(H5F_libver_t high, H5O_fsinfo_t *fsinfo) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDcompile_assert(N_FSINFO_VERSION_BOUNDS == H5F_LIBVER_NBOUNDS); - HDassert(fsinfo); - - /* Check the version */ - if(H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || fsinfo->version > H5O_fsinfo_ver_bounds[high]) - HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_fsinfo_check_version() */ - - -/*------------------------------------------------------------------------- * Function: H5O__fsinfo_debug * * Purpose: Prints debugging info for a message. @@ -488,3 +412,76 @@ H5O__fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__fsinfo_debug() */ +/*------------------------------------------------------------------------- + * Function: H5O_fsinfo_set_version + * + * Purpose: Set the version to encode the fsinfo message with. + * + * Return: SUCCEED/FAIL + * + * Programmer: Vailin Choi; June 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_fsinfo_set_version(H5F_libver_t low, H5F_libver_t high, H5O_fsinfo_t *fsinfo) +{ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDcompile_assert(N_FSINFO_VERSION_BOUNDS == H5F_LIBVER_NBOUNDS); + HDassert(fsinfo); + + version = H5O_FSINFO_VERSION_1; + + /* Upgrade to the version indicated by the file's low bound if higher */ + if(H5O_fsinfo_ver_bounds[low] != H5O_INVALID_VERSION) + version = MAX(version, H5O_fsinfo_ver_bounds[low]); + + /* Version bounds check */ + if(H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || version > H5O_fsinfo_ver_bounds[high]) + HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds") + + /* Set the message version */ + fsinfo->version = version; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_fsinfo_set_version() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_fsinfo_check_version + * + * Purpose: Validate the fsinfo message version + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Summer 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_fsinfo_check_version(H5F_libver_t high, H5O_fsinfo_t *fsinfo) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDcompile_assert(N_FSINFO_VERSION_BOUNDS == H5F_LIBVER_NBOUNDS); + HDassert(fsinfo); + + /* Check the version */ + if(H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || fsinfo->version > H5O_fsinfo_ver_bounds[high]) + HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_fsinfo_check_version() */ + + |