diff options
Diffstat (limited to 'src/H5Snone.c')
-rw-r--r-- | src/H5Snone.c | 170 |
1 files changed, 66 insertions, 104 deletions
diff --git a/src/H5Snone.c b/src/H5Snone.c index 67c07d0..1909ff8 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -22,72 +22,65 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Selection callbacks */ -static herr_t H5S__none_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); -static herr_t H5S__none_release(H5S_t *space); -static htri_t H5S__none_is_valid(const H5S_t *space); +static herr_t H5S__none_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +static herr_t H5S__none_release(H5S_t *space); +static htri_t H5S__none_is_valid(const H5S_t *space); static hssize_t H5S__none_serial_size(const H5S_t *space); -static herr_t H5S__none_serialize(const H5S_t *space, uint8_t **p); -static herr_t H5S__none_deserialize(H5S_t **space, const uint8_t **p); -static herr_t H5S__none_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); -static herr_t H5S__none_offset(const H5S_t *space, hsize_t *off); -static int H5S__none_unlim_dim(const H5S_t *space); -static htri_t H5S__none_is_contiguous(const H5S_t *space); -static htri_t H5S__none_is_single(const H5S_t *space); -static htri_t H5S__none_is_regular(const H5S_t *space); -static htri_t H5S__none_shape_same(const H5S_t *space1, const H5S_t *space2); -static htri_t H5S__none_intersect_block(const H5S_t *space, const hsize_t *start, - const hsize_t *end); -static herr_t H5S__none_adjust_u(H5S_t *space, const hsize_t *offset); -static herr_t H5S__none_adjust_s(H5S_t *space, const hssize_t *offset); -static herr_t H5S__none_project_scalar(const H5S_t *space, hsize_t *offset); -static herr_t H5S__none_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); -static herr_t H5S__none_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); +static herr_t H5S__none_serialize(const H5S_t *space, uint8_t **p); +static herr_t H5S__none_deserialize(H5S_t **space, const uint8_t **p); +static herr_t H5S__none_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); +static herr_t H5S__none_offset(const H5S_t *space, hsize_t *off); +static int H5S__none_unlim_dim(const H5S_t *space); +static htri_t H5S__none_is_contiguous(const H5S_t *space); +static htri_t H5S__none_is_single(const H5S_t *space); +static htri_t H5S__none_is_regular(const H5S_t *space); +static htri_t H5S__none_shape_same(const H5S_t *space1, const H5S_t *space2); +static htri_t H5S__none_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); +static herr_t H5S__none_adjust_u(H5S_t *space, const hsize_t *offset); +static herr_t H5S__none_adjust_s(H5S_t *space, const hssize_t *offset); +static herr_t H5S__none_project_scalar(const H5S_t *space, hsize_t *offset); +static herr_t H5S__none_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); +static herr_t H5S__none_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); /* Selection iteration callbacks */ -static herr_t H5S__none_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); -static herr_t H5S__none_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); +static herr_t H5S__none_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); +static herr_t H5S__none_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S__none_iter_nelmts(const H5S_sel_iter_t *iter); -static htri_t H5S__none_iter_has_next_block(const H5S_sel_iter_t *iter); -static herr_t H5S__none_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); -static herr_t H5S__none_iter_next_block(H5S_sel_iter_t *sel_iter); -static herr_t H5S__none_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); -static herr_t H5S__none_iter_release(H5S_sel_iter_t *sel_iter); - +static htri_t H5S__none_iter_has_next_block(const H5S_sel_iter_t *iter); +static herr_t H5S__none_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); +static herr_t H5S__none_iter_next_block(H5S_sel_iter_t *sel_iter); +static herr_t H5S__none_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); +static herr_t H5S__none_iter_release(H5S_sel_iter_t *sel_iter); /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -119,7 +112,6 @@ const H5S_select_class_t H5S_sel_none[1] = {{ H5S__none_iter_init, }}; - /*******************/ /* Local Variables */ /*******************/ @@ -139,8 +131,6 @@ static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{ H5S__none_iter_release, }}; - - /*------------------------------------------------------------------------- * Function: H5S__none_iter_init * @@ -168,7 +158,6 @@ H5S__none_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_iter_init() */ - /*------------------------------------------------------------------------- * Function: H5S__none_iter_coords * @@ -194,7 +183,6 @@ H5S__none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_iter_coords() */ - /*------------------------------------------------------------------------- * Function: H5S__none_iter_block * @@ -209,7 +197,8 @@ H5S__none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR *------------------------------------------------------------------------- */ static herr_t -H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_UNUSED *start, hsize_t H5_ATTR_UNUSED *end) +H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_UNUSED *start, + hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -221,7 +210,6 @@ H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_ FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_iter_block() */ - /*------------------------------------------------------------------------- * Function: H5S__none_iter_nelmts * @@ -245,7 +233,6 @@ H5S__none_iter_nelmts(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(0) } /* end H5S__none_iter_nelmts() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_has_next_block @@ -274,7 +261,6 @@ H5S__none_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_iter_has_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_next @@ -305,7 +291,6 @@ H5S__none_iter_next(H5S_sel_iter_t H5_ATTR_UNUSED *iter, size_t H5_ATTR_UNUSED n FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_iter_next() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_next_block @@ -334,7 +319,6 @@ H5S__none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_iter_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_get_seq_list @@ -365,9 +349,9 @@ H5S__none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__none_iter_get_seq_list(H5S_sel_iter_t H5_ATTR_UNUSED *iter, - size_t H5_ATTR_UNUSED maxseq, size_t H5_ATTR_UNUSED maxelem, size_t *nseq, - size_t *nelem, hsize_t H5_ATTR_UNUSED *off, size_t H5_ATTR_UNUSED *len) +H5S__none_iter_get_seq_list(H5S_sel_iter_t H5_ATTR_UNUSED *iter, size_t H5_ATTR_UNUSED maxseq, + size_t H5_ATTR_UNUSED maxelem, size_t *nseq, size_t *nelem, + hsize_t H5_ATTR_UNUSED *off, size_t H5_ATTR_UNUSED *len) { FUNC_ENTER_STATIC_NOERR @@ -389,7 +373,6 @@ H5S__none_iter_get_seq_list(H5S_sel_iter_t H5_ATTR_UNUSED *iter, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_iter_get_seq_list() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_release @@ -418,7 +401,6 @@ H5S__none_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_iter_release() */ - /*-------------------------------------------------------------------------- NAME H5S__none_release @@ -447,7 +429,6 @@ H5S__none_release(H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_release() */ - /*-------------------------------------------------------------------------- NAME H5S__none_copy @@ -482,7 +463,6 @@ H5S__none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, hbool_t H5_ATTR_UNUS FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_copy() */ - /*-------------------------------------------------------------------------- NAME H5S__none_is_valid @@ -513,7 +493,6 @@ H5S__none_is_valid(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__none_is_valid() */ - /*-------------------------------------------------------------------------- NAME H5S__none_serial_size @@ -547,7 +526,6 @@ H5S__none_serial_size(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(16) } /* end H5S__none_serial_size() */ - /*-------------------------------------------------------------------------- NAME H5S__none_serialize @@ -572,7 +550,7 @@ H5S__none_serial_size(const H5S_t H5_ATTR_UNUSED *space) static herr_t H5S__none_serialize(const H5S_t *space, uint8_t **p) { - uint8_t *pp = (*p); /* Local pointer for decoding */ + uint8_t *pp = (*p); /* Local pointer for decoding */ FUNC_ENTER_STATIC_NOERR @@ -584,8 +562,8 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(pp, (uint32_t)H5S_NONE_VERSION_1); /* Store the version number */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ + UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ + UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ /* Update encoding pointer */ *p = pp; @@ -593,7 +571,6 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_serialize() */ - /*-------------------------------------------------------------------------- NAME H5S__none_deserialize @@ -619,10 +596,10 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) static herr_t H5S__none_deserialize(H5S_t **space, const uint8_t **p) { - H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, - either *space or a newly allocated one */ - uint32_t version; /* Version number */ - herr_t ret_value = SUCCEED; /* return value */ + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ + uint32_t version; /* Version number */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -634,8 +611,8 @@ H5S__none_deserialize(H5S_t **space, const uint8_t **p) is moved from H5S_select_deserialize() in H5Sselect.c to here. This is needed for decoding virtual layout in H5O__layout_decode() */ /* Allocate space if not provided */ - if(!*space) { - if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + if (!*space) { + if (NULL == (tmp_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") } /* end if */ else @@ -644,30 +621,29 @@ H5S__none_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(*p, version); - if(version < H5S_NONE_VERSION_1 || version > H5S_NONE_VERSION_LATEST) + if (version < H5S_NONE_VERSION_1 || version > H5S_NONE_VERSION_LATEST) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for none selection") /* Skip over the remainder of the header */ *p += 8; /* Change to "none" selection */ - if(H5S_select_none(tmp_space) < 0) + if (H5S_select_none(tmp_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Return space to the caller if allocated */ - if(!*space) + if (!*space) *space = tmp_space; done: /* Free temporary space if not passed to caller (only happens on error) */ - if(!*space && tmp_space) - if(H5S_close(tmp_space) < 0) + if (!*space && tmp_space) + if (H5S_close(tmp_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__none_deserialize() */ - /*-------------------------------------------------------------------------- NAME H5S__none_bounds @@ -694,7 +670,8 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *start, hsize_t H5_ATTR_UNUSED *end) +H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *start, + hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -705,7 +682,6 @@ H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *star FUNC_LEAVE_NOAPI(FAIL) } /* end H5S_none_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S__none_offset @@ -737,7 +713,6 @@ H5S__none_offset(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *offs FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_offset() */ - /*-------------------------------------------------------------------------- NAME H5S__none_unlim_dim @@ -765,7 +740,6 @@ H5S__none_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(-1) } /* end H5S__none_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S__none_is_contiguous @@ -794,7 +768,6 @@ H5S__none_is_contiguous(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(FALSE) } /* end H5S__none_is_contiguous() */ - /*-------------------------------------------------------------------------- NAME H5S__none_is_single @@ -823,7 +796,6 @@ H5S__none_is_single(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(FALSE) } /* end H5S__none_is_single() */ - /*-------------------------------------------------------------------------- NAME H5S__none_is_regular @@ -854,7 +826,6 @@ H5S__none_is_regular(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__none_is_regular() */ - /*-------------------------------------------------------------------------- NAME H5S__none_shape_same @@ -875,8 +846,7 @@ H5S__none_is_regular(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, - const H5S_t H5_ATTR_UNUSED *space2) +H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, const H5S_t H5_ATTR_UNUSED *space2) { FUNC_ENTER_STATIC_NOERR @@ -887,7 +857,6 @@ H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__none_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S__none_intersect_block @@ -908,8 +877,8 @@ H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, REVISION LOG --------------------------------------------------------------------------*/ htri_t -H5S__none_intersect_block(const H5S_t H5_ATTR_UNUSED *space, - const hsize_t H5_ATTR_UNUSED *start, const hsize_t H5_ATTR_UNUSED *end) +H5S__none_intersect_block(const H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *start, + const hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -922,7 +891,6 @@ H5S__none_intersect_block(const H5S_t H5_ATTR_UNUSED *space, FUNC_LEAVE_NOAPI(FALSE) } /* end H5S__none_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5S__none_adjust_u @@ -953,7 +921,6 @@ H5S__none_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *of FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_adjust_u() */ - /*-------------------------------------------------------------------------- NAME H5S__none_adjust_s @@ -984,7 +951,6 @@ H5S__none_adjust_s(H5S_t H5_ATTR_UNUSED *space, const hssize_t H5_ATTR_UNUSED *o FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_adjust_s() */ - /*------------------------------------------------------------------------- * Function: H5S__none_project_scalar * @@ -1009,7 +975,6 @@ H5S__none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUS FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_project_scalar() */ - /*------------------------------------------------------------------------- * Function: H5S__none_project_simple * @@ -1024,10 +989,10 @@ H5S__none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUS *------------------------------------------------------------------------- */ static herr_t -H5S__none_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, - H5S_t *new_space, hsize_t H5_ATTR_UNUSED *offset) +H5S__none_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, H5S_t *new_space, + hsize_t H5_ATTR_UNUSED *offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1037,14 +1002,13 @@ H5S__none_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, HDassert(offset); /* Select the entire new space */ - if(H5S_select_none(new_space) < 0) + if (H5S_select_none(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to set none selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__none_project_simple() */ - /*-------------------------------------------------------------------------- NAME H5S_select_none @@ -1065,7 +1029,7 @@ done: herr_t H5S_select_none(H5S_t *space) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1073,7 +1037,7 @@ H5S_select_none(H5S_t *space) HDassert(space); /* Remove current selection first */ - if(H5S_SELECT_RELEASE(space) < 0) + if (H5S_SELECT_RELEASE(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release hyperslab") /* Set number of elements in selection */ @@ -1086,7 +1050,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_none() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_none @@ -1107,21 +1070,20 @@ done: herr_t H5Sselect_none(hid_t spaceid) { - H5S_t *space; /* Dataspace to modify selection of */ - herr_t ret_value = SUCCEED; /* return value */ + H5S_t *space; /* Dataspace to modify selection of */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Change to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_none() */ - |