summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-07-08 22:33:22 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-07-09 00:41:47 (GMT)
commitd36ff651aff0f4e31b84eafc0fb526f33817735b (patch)
tree3be97925839f3495a4621582500e5a470ecd2701 /src
parent185ec14f360efb80eb4638cc3745834a141280e1 (diff)
downloadhdf5-d36ff651aff0f4e31b84eafc0fb526f33817735b.zip
hdf5-d36ff651aff0f4e31b84eafc0fb526f33817735b.tar.gz
hdf5-d36ff651aff0f4e31b84eafc0fb526f33817735b.tar.bz2
Continued normalization of H5S with develop.
Diffstat (limited to 'src')
-rw-r--r--src/H5Dchunk.c52
-rw-r--r--src/H5Dio.c14
-rw-r--r--src/H5Pdcpl.c4
-rw-r--r--src/H5S.c43
-rw-r--r--src/H5Sall.c4
-rw-r--r--src/H5Shyper.c39
-rw-r--r--src/H5Snone.c4
-rw-r--r--src/H5Spkg.h24
-rw-r--r--src/H5Spoint.c4
-rw-r--r--src/H5Sprivate.h17
-rw-r--r--src/H5Sselect.c75
11 files changed, 136 insertions, 144 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 511803e..a8f22cc 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -1272,7 +1272,7 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
} /* end else */
/* Build the memory selection for each chunk */
- if(sel_hyper_flag && H5S_select_shape_same(file_space, mem_space) == TRUE) {
+ if(sel_hyper_flag && H5S_SELECT_SHAPE_SAME(file_space, mem_space) == TRUE) {
/* Reset chunk template information */
fm->mchunk_tmpl = NULL;
@@ -1404,7 +1404,7 @@ H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline)
/*-------------------------------------------------------------------------
* Function: H5D__chunk_mem_xfree
*
- * Purpose: Free space for a chunk in memory. This routine allocates
+ * Purpose: Free space for a chunk in memory. This routine releases
* memory space for non-filtered chunks from a block free list
* and uses malloc()/free() for filtered chunks.
*
@@ -1565,7 +1565,8 @@ H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy file selection")
/* Move selection back to have correct offset in chunk */
- H5S_SELECT_ADJUST_U(fm->single_space, coords);
+ if(H5S_SELECT_ADJUST_U(fm->single_space, coords) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection")
#ifdef H5_HAVE_PARALLEL
/* store chunk selection information */
@@ -1626,7 +1627,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
FUNC_ENTER_STATIC
/* Sanity check */
- HDassert(fm->f_ndims>0);
+ HDassert(fm->f_ndims > 0);
/* Get number of elements selected in file */
sel_points = fm->nelmts;
@@ -1652,7 +1653,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
while(sel_points) {
/* Check for intersection of temporary chunk and file selection */
/* (Casting away const OK - QAK) */
- if(TRUE == H5S_hyper_intersect_block((H5S_t *)fm->file_space, coords, end)) {
+ if(TRUE == H5S_hyper_intersect_block(fm->file_space, coords, end)) {
H5S_t *tmp_fchunk; /* Temporary file dataspace */
H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */
hsize_t chunk_points; /* Number of elements in chunk selection */
@@ -1680,12 +1681,13 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
} /* end if */
/* Move selection back to have correct offset in chunk */
- H5S_SELECT_ADJUST_U(tmp_fchunk, coords);
+ if(H5S_SELECT_ADJUST_U(tmp_fchunk, coords) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't adjust chunk selection")
/* Add temporary chunk to the list of chunks */
/* Allocate the file & memory chunk information */
- if (NULL==(new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) {
+ if(NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) {
(void)H5S_close(tmp_fchunk);
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info")
} /* end if */
@@ -1693,7 +1695,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
/* Initialize the chunk information */
/* Set the chunk index */
- new_chunk_info->index=chunk_index;
+ new_chunk_info->index = chunk_index;
#ifdef H5_HAVE_PARALLEL
/* Store chunk selection information, for multi-chunk I/O */
@@ -1706,16 +1708,13 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
new_chunk_info->fspace_shared = FALSE;
/* Set the memory chunk dataspace */
- new_chunk_info->mspace=NULL;
+ new_chunk_info->mspace = NULL;
new_chunk_info->mspace_shared = FALSE;
/* Copy the chunk's scaled coordinates */
- H5MM_memcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims);
+ H5MM_memcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims);
new_chunk_info->scaled[fm->f_ndims] = 0;
- /* Copy the chunk's scaled coordinates */
- H5MM_memcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims);
-
/* Insert the new chunk into the skip list */
if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) {
H5D__free_chunk_info(new_chunk_info, NULL, NULL);
@@ -1723,8 +1722,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
} /* end if */
/* Get number of elements selected in chunk */
- if((chunk_points = H5S_GET_SELECT_NPOINTS(tmp_fchunk)) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements")
+ chunk_points = H5S_GET_SELECT_NPOINTS(tmp_fchunk);
H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, chunk_points, hsize_t);
/* Decrement # of points left in file selection */
@@ -1739,12 +1737,12 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
chunk_index++;
/* Set current increment dimension */
- curr_dim=(int)fm->f_ndims-1;
+ curr_dim = (int)fm->f_ndims - 1;
/* Increment chunk location in fastest changing dimension */
H5_CHECK_OVERFLOW(fm->chunk_dim[curr_dim],hsize_t,hssize_t);
- coords[curr_dim]+=fm->chunk_dim[curr_dim];
- end[curr_dim]+=fm->chunk_dim[curr_dim];
+ coords[curr_dim] += fm->chunk_dim[curr_dim];
+ end[curr_dim] += fm->chunk_dim[curr_dim];
scaled[curr_dim]++;
/* Bring chunk location back into bounds, if necessary */
@@ -1813,7 +1811,7 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm)
H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */
/* Get the node */
- curr_node=H5SL_first(fm->sel_chunks);
+ curr_node = H5SL_first(fm->sel_chunks);
/* Get pointer to chunk's information */
chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node);
@@ -1836,15 +1834,15 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info")
/* Calculate the adjustment for memory selection from file selection */
- HDassert(fm->m_ndims==fm->f_ndims);
- for(u=0; u<fm->f_ndims; u++) {
- H5_CHECK_OVERFLOW(file_sel_start[u],hsize_t,hssize_t);
- H5_CHECK_OVERFLOW(mem_sel_start[u],hsize_t,hssize_t);
- adjust[u]=(hssize_t)file_sel_start[u]-(hssize_t)mem_sel_start[u];
+ HDassert(fm->m_ndims == fm->f_ndims);
+ for(u = 0; u < fm->f_ndims; u++) {
+ H5_CHECK_OVERFLOW(file_sel_start[u], hsize_t, hssize_t);
+ H5_CHECK_OVERFLOW(mem_sel_start[u], hsize_t, hssize_t);
+ adjust[u] = (hssize_t)file_sel_start[u] - (hssize_t)mem_sel_start[u];
} /* end for */
/* Iterate over each chunk in the chunk list */
- curr_node=H5SL_first(fm->sel_chunks);
+ curr_node = H5SL_first(fm->sel_chunks);
while(curr_node) {
H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */
@@ -1879,11 +1877,11 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm)
} /* end for */
/* Adjust the selection */
- if(H5S_hyper_adjust_s(chunk_info->mspace, chunk_adjust) < 0) /*lint !e772 The chunk_adjust array will always be initialized */
+ if(H5S_hyper_adjust_s(chunk_info->mspace, chunk_adjust) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to adjust selection")
/* Get the next chunk node in the skip list */
- curr_node=H5SL_next(curr_node);
+ curr_node = H5SL_next(curr_node);
} /* end while */
} /* end else */
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 895f0bb..39112c7 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -102,7 +102,6 @@ H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_c
HDassert(offset);
HDassert(offset_copy);
-
/* The library's chunking code requires the offset to terminate with a zero.
* So transfer the offset array to an internal offset array that we
* can properly terminate (handled via the calloc call).
@@ -127,14 +126,13 @@ done:
} /* end H5D__get_offset_copy() */
-
/*-------------------------------------------------------------------------
- * Function: H5Dread
+ * Function: H5Dread
*
* Purpose: Reads (part of) a DSET from the file into application
* memory BUF. The part of the dataset to read is defined with
- * MEM_SPACE_ID and FILE_SPACE_ID. The data points are
+ * MEM_SPACE_ID and FILE_SPACE_ID. The data points are
* converted from their file type to the MEM_TYPE_ID specified.
* Additional miscellaneous data transfer properties can be
* passed to this function with the PLIST_ID argument.
@@ -194,8 +192,8 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
/* Set DXPL for operation */
H5CX_set_dxpl(dxpl_id);
- /* Read raw data */
- if (H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0)
+ /* Read the data */
+ if (H5D__read(dset, mem_type_id, mem_space, file_space, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data")
done:
@@ -518,7 +516,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
* Note that in general, this requires us to touch up the memory buffer as
* well.
*/
- if(TRUE == H5S_select_shape_same(mem_space, file_space) &&
+ if(TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) &&
H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) {
void *adj_buf = NULL; /* Pointer to the location in buf corresponding */
/* to the beginning of the projected mem space. */
@@ -753,7 +751,7 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
* Note that in general, this requires us to touch up the memory buffer
* as well.
*/
- if(TRUE == H5S_select_shape_same(mem_space, file_space) &&
+ if(TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) &&
H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) {
void *adj_buf = NULL; /* Pointer to the location in buf corresponding */
/* to the beginning of the projected mem space. */
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index d72a704..448d512 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -827,7 +827,7 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2,
if((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_dset.virtual_select, layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) HGOTO_DONE(-1)
if(!equal)
HGOTO_DONE(1)
- if((equal = H5S_select_shape_same(layout1->storage.u.virt.list[u].source_dset.virtual_select, layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) HGOTO_DONE(-1)
+ if((equal = H5S_SELECT_SHAPE_SAME(layout1->storage.u.virt.list[u].source_dset.virtual_select, layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) HGOTO_DONE(-1)
if(!equal)
HGOTO_DONE(1)
@@ -847,7 +847,7 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2,
if((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_select, layout2->storage.u.virt.list[u].source_select)) < 0) HGOTO_DONE(-1)
if(!equal)
HGOTO_DONE(1)
- if((equal = H5S_select_shape_same(layout1->storage.u.virt.list[u].source_select, layout2->storage.u.virt.list[u].source_select)) < 0) HGOTO_DONE(-1)
+ if((equal = H5S_SELECT_SHAPE_SAME(layout1->storage.u.virt.list[u].source_select, layout2->storage.u.virt.list[u].source_select)) < 0) HGOTO_DONE(-1)
if(!equal)
HGOTO_DONE(1)
} /* end for */
diff --git a/src/H5S.c b/src/H5S.c
index c6f81f8..c42c952 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -1836,49 +1836,6 @@ done:
} /* end H5Sset_extent_none() */
-/*--------------------------------------------------------------------------
- NAME
- H5Soffset_simple
- PURPOSE
- Changes the offset of a selection within a simple dataspace extent
- USAGE
- herr_t H5Soffset_simple(space_id, offset)
- hid_t space_id; IN: Dataspace object to reset
- const hssize_t *offset; IN: Offset to position the selection at
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- This function creates an offset for the selection within an extent, allowing
- the same shaped selection to be moved to different locations within a
- dataspace without requiring it to be re-defined.
---------------------------------------------------------------------------*/
-herr_t
-H5Soffset_simple(hid_t space_id, const hssize_t *offset)
-{
- H5S_t *space; /* dataspace to modify */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_API(FAIL)
- H5TRACE2("e", "i*Hs", space_id, offset);
-
- /* Check args */
- if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace")
- if (space->extent.rank==0 || (H5S_GET_EXTENT_TYPE(space)==H5S_SCALAR
- || H5S_GET_EXTENT_TYPE(space)==H5S_NULL))
- HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace")
- if (offset == NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified")
-
- /* Set the selection offset */
- if(H5S_select_offset(space,offset)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set offset")
-
-done:
- FUNC_LEAVE_API(ret_value)
-} /* end H5Soffset_simple() */
-
-
/*-------------------------------------------------------------------------
* Function: H5S_set_extent
*
diff --git a/src/H5Sall.c b/src/H5Sall.c
index 199213f..08fbb5c 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -68,7 +68,7 @@ static htri_t H5S__all_is_regular(const H5S_t *space);
static herr_t H5S__all_adjust_u(H5S_t *space, const hsize_t *offset);
static herr_t H5S__all_project_scalar(const H5S_t *space, hsize_t *offset);
static herr_t H5S__all_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
-static herr_t H5S__all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space);
+static herr_t H5S__all_iter_init(const H5S_t *space, H5S_sel_iter_t *iter);
/* Selection iteration callbacks */
static herr_t H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
@@ -148,7 +148,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{
*-------------------------------------------------------------------------
*/
static herr_t
-H5S__all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
+H5S__all_iter_init(const H5S_t *space, H5S_sel_iter_t *iter)
{
FUNC_ENTER_STATIC_NOERR
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 771b750..c93f631 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -117,7 +117,7 @@ static htri_t H5S__hyper_is_regular(const H5S_t *space);
static herr_t H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset);
static herr_t H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset);
static herr_t H5S__hyper_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
-static herr_t H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space);
+static herr_t H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter);
/* Selection iteration callbacks */
static herr_t H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
@@ -181,8 +181,6 @@ static const H5S_sel_iter_class_t H5S_sel_iter_hyper[1] = {{
H5S__hyper_iter_release,
}};
-/* Static variables */
-
/* Arrays for default stride, block, etc. */
static const hsize_t H5S_hyper_zeros_g[H5O_LAYOUT_NDIMS] = {
0,0,0,0, 0,0,0,0,
@@ -207,6 +205,7 @@ H5FL_DEFINE_STATIC(H5S_hyper_span_info_t);
/* Declare extern free list to manage the H5S_sel_iter_t struct */
H5FL_EXTERN(H5S_sel_iter_t);
+/* Uncomment this to provide the debugging routines for printing selection info */
/* #define H5S_HYPER_DEBUG */
#ifdef H5S_HYPER_DEBUG
static herr_t
@@ -290,13 +289,13 @@ H5S__hyper_print_diminfo(FILE *f, const H5S_t *space)
/*-------------------------------------------------------------------------
- * Function: H5S__hyper_iter_init
+ * Function: H5S__hyper_iter_init
*
- * Purpose: Initializes iteration information for hyperslab span tree selection.
+ * Purpose: Initializes iteration information for hyperslab span tree selection.
*
- * Return: non-negative on success, negative on failure.
+ * Return: Non-negative on success, negative on failure.
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Saturday, February 24, 2001
*
* Notes: If the 'elmt_size' parameter is set to zero, the regular
@@ -307,13 +306,13 @@ H5S__hyper_print_diminfo(FILE *f, const H5S_t *space)
*-------------------------------------------------------------------------
*/
static herr_t
-H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
+H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter)
{
const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */
H5S_hyper_span_info_t *spans; /* Pointer to hyperslab span info node */
- unsigned rank; /* Dataspace's dimension rank */
- unsigned u; /* Index variable */
- int i; /* Index variable */
+ unsigned rank; /* Dataspace's dimension rank */
+ unsigned u; /* Index variable */
+ int i; /* Index variable */
FUNC_ENTER_STATIC_NOERR
@@ -484,14 +483,14 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
/*-------------------------------------------------------------------------
- * Function: H5S__hyper_iter_coords
+ * Function: H5S__hyper_iter_coords
*
- * Purpose: Retrieve the current coordinates of iterator for current
+ * Purpose: Retrieve the current coordinates of iterator for current
* selection
*
- * Return: non-negative on success, negative on failure
+ * Return: Non-negative on success, negative on failure
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Tuesday, April 22, 2003
*
*-------------------------------------------------------------------------
@@ -604,16 +603,14 @@ H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
for(u = 0; u < iter->rank; u++) {
start[u] = iter->u.hyp.off[u];
end[u] = (start[u] + iter->u.hyp.diminfo[u].block) - 1;
- } /* end for */
+ }
} /* end if */
else {
- /* Copy the start of the block */
- for(u = 0; u < iter->rank; u++)
+ /* Copy the start & end of the block */
+ for(u = 0; u < iter->rank; u++) {
start[u] = iter->u.hyp.span[u]->low;
-
- /* Copy the end of the block */
- for(u = 0; u < iter->rank; u++)
end[u] = iter->u.hyp.span[u]->high;
+ }
} /* end else */
FUNC_LEAVE_NOAPI(SUCCEED)
diff --git a/src/H5Snone.c b/src/H5Snone.c
index b9a02a5..1546d0b 100644
--- a/src/H5Snone.c
+++ b/src/H5Snone.c
@@ -69,7 +69,7 @@ static htri_t H5S__none_is_regular(const H5S_t *space);
static herr_t H5S__none_adjust_u(H5S_t *space, const hsize_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(H5S_sel_iter_t *iter, const H5S_t *space);
+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);
@@ -149,7 +149,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{
*-------------------------------------------------------------------------
*/
static herr_t
-H5S__none_iter_init(H5S_sel_iter_t *iter, const H5S_t H5_ATTR_UNUSED *space)
+H5S__none_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter)
{
FUNC_ENTER_STATIC_NOERR
diff --git a/src/H5Spkg.h b/src/H5Spkg.h
index 52e683d..d95c4ff 100644
--- a/src/H5Spkg.h
+++ b/src/H5Spkg.h
@@ -109,29 +109,29 @@ struct H5S_extent_t {
/* Node in point selection list (typedef'd in H5Sprivate.h) */
struct H5S_pnt_node_t {
+ struct H5S_pnt_node_t *next; /* Pointer to next point in list */
hsize_t *pnt; /* Pointer to a selected point */
- struct H5S_pnt_node_t *next; /* pointer to next point in list */
};
-/* Information about point selection list */
-typedef struct {
+/* Information about point selection list (typedef'd in H5Sprivate.h) */
+struct H5S_pnt_list_t {
H5S_pnt_node_t *head; /* Pointer to head of point list */
-} H5S_pnt_list_t;
+};
/* Information about hyperslab spans */
-/* Information a particular hyperslab span */
+/* Information a particular hyperslab span (typedef'd in H5Sprivate.h) */
struct H5S_hyper_span_t {
- hsize_t low, high; /* Low & high bounds of span */
+ hsize_t low, high; /* Low & high bounds of elements selected for span, inclusive */
hsize_t nelem; /* Number of elements in span (only needed during I/O) */
hsize_t pstride; /* Pseudo-stride from start of previous span (only used during I/O) */
- struct H5S_hyper_span_info_t *down; /* Pointer to list of spans in next dimension down */
- struct H5S_hyper_span_t *next; /* Pointer to next span in list */
+ struct H5S_hyper_span_info_t *down; /* Pointer to list of spans in next dimension down */
+ struct H5S_hyper_span_t *next; /* Pointer to next span in list */
};
-/* Information about a list of hyperslab spans in one dimension */
+/* Information about a list of hyperslab spans in one dimension (typedef'd in H5Sprivate.h) */
struct H5S_hyper_span_info_t {
- unsigned count; /* Ref. count of number of spans which share this span */
+ unsigned count; /* Ref. count of number of spans which share this span */
struct H5S_hyper_span_info_t *scratch; /* Scratch pointer
* (used during copies, as mark
* during precomputes for I/O &
@@ -143,7 +143,7 @@ struct H5S_hyper_span_info_t {
/* Information about hyperslab selection */
typedef struct {
- hbool_t diminfo_valid; /* Whether the dataset has valid diminfo */
+ hbool_t diminfo_valid; /* Whether the dataset has valid diminfo */
H5S_hyper_dim_t opt_diminfo[H5S_MAX_RANK]; /* per-dim selection info */
H5S_hyper_dim_t app_diminfo[H5S_MAX_RANK]; /* per-dim selection info */
/* 'opt_diminfo' points to a [potentially] optimized version of the user's
@@ -196,7 +196,7 @@ typedef herr_t (*H5S_sel_project_scalar)(const H5S_t *space, hsize_t *offset);
/* Method to construct selection projection onto/into simple dataspace */
typedef herr_t (*H5S_sel_project_simple)(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
/* Method to initialize iterator for current selection */
-typedef herr_t (*H5S_sel_iter_init_func_t)(H5S_sel_iter_t *sel_iter, const H5S_t *space);
+typedef herr_t (*H5S_sel_iter_init_func_t)(const H5S_t *space, H5S_sel_iter_t *sel_iter);
/* Selection class information */
typedef struct {
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index 079840e..c23c6f3 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -68,7 +68,7 @@ static htri_t H5S__point_is_regular(const H5S_t *space);
static herr_t H5S__point_adjust_u(H5S_t *space, const hsize_t *offset);
static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset);
static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
-static herr_t H5S__point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space);
+static herr_t H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter);
static herr_t H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size);
/* Selection iteration callbacks */
@@ -139,7 +139,7 @@ H5FL_DEFINE_STATIC(H5S_pnt_list_t);
*-------------------------------------------------------------------------
*/
static herr_t
-H5S__point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
+H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter)
{
FUNC_ENTER_STATIC_NOERR
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index d4f6847..c361612 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -30,21 +30,13 @@
#include "H5Pprivate.h" /* Property lists */
#include "H5Tprivate.h" /* Datatypes */
-/* Flags for H5S_find */
-#define H5S_CONV_PAR_IO_POSSIBLE 0x0001
-/* The storage options are mutually exclusive */
-/* (2-bits reserved for storage type currently) */
-#define H5S_CONV_STORAGE_COMPACT 0x0000 /* i.e. '0' */
-#define H5S_CONV_STORAGE_CONTIGUOUS 0x0002 /* i.e. '1' */
-#define H5S_CONV_STORAGE_CHUNKED 0x0004 /* i.e. '2' */
-#define H5S_CONV_STORAGE_MASK 0x0006
-
/* Flags for "get_seq_list" methods */
#define H5S_GET_SEQ_LIST_SORTED 0x0001
/* Forward references of package typedefs */
typedef struct H5S_extent_t H5S_extent_t;
typedef struct H5S_pnt_node_t H5S_pnt_node_t;
+typedef struct H5S_pnt_list_t H5S_pnt_list_t;
typedef struct H5S_hyper_span_t H5S_hyper_span_t;
typedef struct H5S_hyper_span_info_t H5S_hyper_span_info_t;
@@ -144,7 +136,6 @@ typedef struct H5S_sel_iter_op_t {
#define H5S_GET_SELECT_TYPE(S) ((S)->select.type->type)
#define H5S_SELECT_GET_SEQ_LIST(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) ((*(S)->select.type->get_seq_list)(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN))
#define H5S_SELECT_VALID(S) ((*(S)->select.type->is_valid)(S))
-#define H5S_SELECT_RELEASE(S) ((*(S)->select.type->release)(S))
#define H5S_SELECT_SERIAL_SIZE(S) ((*(S)->select.type->serial_size)(S))
#define H5S_SELECT_SERIALIZE(S,BUF) ((*(S)->select.type->serialize)(S,BUF))
#define H5S_SELECT_BOUNDS(S,START,END) ((*(S)->select.type->bounds)(S,START,END))
@@ -170,7 +161,6 @@ typedef struct H5S_sel_iter_op_t {
#define H5S_GET_SELECT_TYPE(S) (H5S_get_select_type(S))
#define H5S_SELECT_GET_SEQ_LIST(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) (H5S_select_get_seq_list(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN))
#define H5S_SELECT_VALID(S) (H5S_select_valid(S))
-#define H5S_SELECT_RELEASE(S) (H5S_select_release(S))
#define H5S_SELECT_SERIAL_SIZE(S) (H5S_select_serial_size(S))
#define H5S_SELECT_SERIALIZE(S,BUF) (H5S_select_serialize(S,BUF))
#define H5S_SELECT_BOUNDS(S,START,END) (H5S_get_select_bounds(S,START,END))
@@ -189,8 +179,11 @@ typedef struct H5S_sel_iter_op_t {
#define H5S_SELECT_ITER_NEXT_BLOCK(ITER) (H5S_select_iter_next_block(ITER))
#define H5S_SELECT_ITER_RELEASE(ITER) (H5S_select_iter_release(ITER))
#endif /* H5S_MODULE */
+
/* Handle these callbacks in a special way, since they have prologs that need to be executed */
#define H5S_SELECT_COPY(DST,SRC,SHARE) (H5S_select_copy(DST,SRC,SHARE))
+#define H5S_SELECT_SHAPE_SAME(S1,S2) (H5S_select_shape_same(S1,S2))
+#define H5S_SELECT_RELEASE(S) (H5S_select_release(S))
#define H5S_SELECT_DESERIALIZE(S,BUF) (H5S_select_deserialize(S,BUF))
@@ -259,7 +252,7 @@ H5_DLL herr_t H5S_select_serialize(const H5S_t *space, uint8_t **p);
H5_DLL htri_t H5S_select_is_contiguous(const H5S_t *space);
H5_DLL htri_t H5S_select_is_single(const H5S_t *space);
H5_DLL htri_t H5S_select_is_regular(const H5S_t *space);
-H5_DLL void H5S_select_adjust_u(H5S_t *space, const hsize_t *offset);
+H5_DLL herr_t H5S_select_adjust_u(H5S_t *space, const hsize_t *offset);
H5_DLL herr_t H5S_select_project_scalar(const H5S_t *space, hsize_t *offset);
H5_DLL herr_t H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
H5_DLL herr_t H5S_select_project_intersection(const H5S_t *src_space,
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 8657008..dbb867e 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -124,6 +124,49 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset)
/*--------------------------------------------------------------------------
NAME
+ H5Soffset_simple
+ PURPOSE
+ Changes the offset of a selection within a simple dataspace extent
+ USAGE
+ herr_t H5Soffset_simple(space_id, offset)
+ hid_t space_id; IN: Dataspace object to reset
+ const hssize_t *offset; IN: Offset to position the selection at
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ This function creates an offset for the selection within an extent, allowing
+ the same shaped selection to be moved to different locations within a
+ dataspace without requiring it to be re-defined.
+--------------------------------------------------------------------------*/
+herr_t
+H5Soffset_simple(hid_t space_id, const hssize_t *offset)
+{
+ H5S_t *space; /* Dataspace to modify */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "i*Hs", space_id, offset);
+
+ /* Check args */
+ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace")
+ if(space->extent.rank == 0 || (H5S_GET_EXTENT_TYPE(space) == H5S_SCALAR
+ || H5S_GET_EXTENT_TYPE(space) == H5S_NULL))
+ HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace")
+ if(offset == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified")
+
+ /* Set the selection offset */
+ if(H5S_select_offset(space, offset) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set offset")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Soffset_simple() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5S_select_copy
PURPOSE
Copy a selection from one dataspace to another
@@ -189,7 +232,7 @@ done:
herr_t
H5S_select_release(H5S_t *ds)
{
- herr_t ret_value = FAIL; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -870,11 +913,11 @@ H5S_select_is_regular(const H5S_t *space)
PURPOSE
Adjust a selection by subtracting an offset
USAGE
- void H5S_select_adjust_u(space, offset)
+ herr_t H5S_select_adjust_u(space, offset)
H5S_t *space; IN/OUT: Pointer to dataspace to adjust
const hsize_t *offset; IN: Offset to subtract
RETURNS
- None
+ Non-negative on success, negative on failure
DESCRIPTION
Moves a selection by subtracting an offset from it.
GLOBAL VARIABLES
@@ -885,18 +928,21 @@ H5S_select_is_regular(const H5S_t *space)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-void
+herr_t
H5S_select_adjust_u(H5S_t *space, const hsize_t *offset)
{
+ herr_t ret_value = SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Check args */
HDassert(space);
HDassert(offset);
- (*space->select.type->adjust_u)(space, offset);
+ /* Perform operation */
+ ret_value = (*space->select.type->adjust_u)(space, offset);
- FUNC_LEAVE_NOAPI_VOID
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_select_adjust_u() */
@@ -1024,7 +1070,7 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space,
sel_iter->elmt_size = elmt_size;
/* Call initialization routine for selection type */
- ret_value = (*space->select.type->iter_init)(sel_iter, space);
+ ret_value = (*space->select.type->iter_init)(space, sel_iter);
HDassert(sel_iter->type);
FUNC_LEAVE_NOAPI(ret_value)
@@ -2277,7 +2323,7 @@ herr_t
H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
const H5S_t *src_intersect_space, H5S_t **new_space_ptr)
{
- H5S_t *new_space = NULL; /* New dataspace constructed */
+ H5S_t *new_space = NULL; /* New dataspace constructed */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -2287,6 +2333,8 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
HDassert(dst_space);
HDassert(src_intersect_space);
HDassert(new_space_ptr);
+ HDassert(H5S_GET_SELECT_NPOINTS(src_space) == H5S_GET_SELECT_NPOINTS(dst_space));
+ HDassert(H5S_GET_EXTENT_NDIMS(src_space) == H5S_GET_EXTENT_NDIMS(src_intersect_space));
/* Create new space, using dst extent. Start with "all" selection. */
if(NULL == (new_space = H5S_create(H5S_SIMPLE)))
@@ -2296,15 +2344,16 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
/* If the intersecting space is "all", the intersection must be equal to the
* source space and the projection must be equal to the destination space */
- if(src_intersect_space->select.type->type == H5S_SEL_ALL) {
+ if(H5S_GET_SELECT_TYPE(src_intersect_space) == H5S_SEL_ALL) {
/* Copy the destination selection. */
if(H5S_select_copy(new_space, dst_space, FALSE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination space selection")
} /* end if */
- /* If any of the spaces are "none", the projection must also be "none" */
- else if((src_intersect_space->select.type->type == H5S_SEL_NONE)
- || (src_space->select.type->type == H5S_SEL_NONE)
- || (dst_space->select.type->type == H5S_SEL_NONE)) {
+ /* If any of the selections contain no elements, the projection must be
+ * "none" */
+ else if((H5S_GET_SELECT_NPOINTS(src_intersect_space) == 0)
+ || (H5S_GET_SELECT_NPOINTS(src_space) == 0)
+ || (H5S_GET_SELECT_NPOINTS(dst_space) == 0)) {
/* Change to "none" selection */
if(H5S_select_none(new_space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")