diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-06-13 19:09:35 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-06-13 19:09:35 (GMT) |
commit | 737f79b5da933853fde9a194d3fe5c4bd820261b (patch) | |
tree | 2d1924110a080401f2ee9cc583edfdba5e30e40e /src | |
parent | 6e2c92c082868c8cb7e612c91fd82371e91f2851 (diff) | |
download | hdf5-737f79b5da933853fde9a194d3fe5c4bd820261b.zip hdf5-737f79b5da933853fde9a194d3fe5c4bd820261b.tar.gz hdf5-737f79b5da933853fde9a194d3fe5c4bd820261b.tar.bz2 |
[svn-r8674] Purpose:
Code optimization
Description:
Revised dataspace selections to use a more "object oriented" mechanism
to set the function pointers for each selection and selection iterator. This
reduces the amount and number of times that dataspace selection info has to
be copied.
Additionally, change hyperslab selection information to be dynamically
allocated instead of an inline struct.
Platforms tested:
Solaris 2.7 (arabica)
FreeBSD 4.10 (sleipnir) w/parallel
Too minor to require h5committest
Diffstat (limited to 'src')
-rw-r--r-- | src/H5.c | 2 | ||||
-rw-r--r-- | src/H5A.c | 6 | ||||
-rw-r--r-- | src/H5D.c | 14 | ||||
-rw-r--r-- | src/H5Dcontig.c | 2 | ||||
-rw-r--r-- | src/H5Dio.c | 4 | ||||
-rw-r--r-- | src/H5Oattr.c | 2 | ||||
-rw-r--r-- | src/H5S.c | 53 | ||||
-rw-r--r-- | src/H5Sall.c | 87 | ||||
-rw-r--r-- | src/H5Shyper.c | 350 | ||||
-rw-r--r-- | src/H5Smpio.c | 12 | ||||
-rw-r--r-- | src/H5Snone.c | 81 | ||||
-rw-r--r-- | src/H5Spkg.h | 152 | ||||
-rw-r--r-- | src/H5Spoint.c | 91 | ||||
-rw-r--r-- | src/H5Sprivate.h | 83 | ||||
-rw-r--r-- | src/H5Sselect.c | 116 |
15 files changed, 565 insertions, 490 deletions
@@ -2142,7 +2142,7 @@ H5_trace (double *returning, const char *func, const char *type, ...) /* This may generate recursive call to the library... -QAK */ { H5S_t *space = H5I_object(obj); - if (H5S_SIMPLE==H5S_GET_SIMPLE_EXTENT_TYPE(space)) { + if (H5S_SIMPLE==H5S_GET_EXTENT_TYPE(space)) { asize[argno] = H5S_get_simple_extent_ndims(space); } } @@ -272,7 +272,7 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type, assert(attr->dt_size>0); attr->ds_size=H5O_raw_size(H5O_SDSPACE_ID,attr->ent.file,&(space->extent.u.simple)); assert(attr->ds_size>0); - H5_ASSIGN_OVERFLOW(attr->data_size,H5S_GET_SIMPLE_EXTENT_NPOINTS(attr->ds)*H5T_get_size(attr->dt),hssize_t,size_t); + H5_ASSIGN_OVERFLOW(attr->data_size,H5S_GET_EXTENT_NPOINTS(attr->ds)*H5T_get_size(attr->dt),hssize_t,size_t); /* Hold the symbol table entry (and file) open */ if (H5O_open(&(attr->ent)) < 0) @@ -630,7 +630,7 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) assert(buf); /* Create buffer for data to store on disk */ - if((snelmts=H5S_GET_SIMPLE_EXTENT_NPOINTS(attr->ds))<0) + if((snelmts=H5S_GET_EXTENT_NPOINTS(attr->ds))<0) HGOTO_ERROR (H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") nelmts=(hsize_t)snelmts; @@ -780,7 +780,7 @@ H5A_read(H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id) assert(buf); /* Create buffer for data to store on disk */ - if((snelmts=H5S_GET_SIMPLE_EXTENT_NPOINTS(attr->ds))<0) + if((snelmts=H5S_GET_EXTENT_NPOINTS(attr->ds))<0) HGOTO_ERROR (H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") nelmts=(hsize_t)snelmts; @@ -1337,7 +1337,7 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) assert(space); /* Get the total number of elements in dataset's dataspace */ - if((total_elem=H5S_GET_SIMPLE_EXTENT_NPOINTS(space))<0) + if((total_elem=H5S_GET_EXTENT_NPOINTS(space))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get # of dataspace elements") /* Get the size of the dataset's datatype */ @@ -2054,7 +2054,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space new_dset->alloc_time=H5D_ALLOC_TIME_EARLY; /* Set up layout information */ - new_dset->layout.unused.ndims = H5S_GET_SIMPLE_EXTENT_NDIMS(new_dset->space) + 1; + new_dset->layout.unused.ndims = H5S_GET_EXTENT_NDIMS(new_dset->space) + 1; assert((unsigned)(new_dset->layout.unused.ndims) <= NELMTS(new_dset->layout.unused.dim)); if (H5S_get_simple_extent_dims(new_dset->space, new_dset->layout.unused.dim, NULL)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize storage info") @@ -2095,7 +2095,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space } /* Compute the total size of a chunk */ - tmp_size = H5S_GET_SIMPLE_EXTENT_NPOINTS(new_dset->space) * + tmp_size = H5S_GET_EXTENT_NPOINTS(new_dset->space) * H5T_get_size(new_dset->type); H5_ASSIGN_OVERFLOW(new_dset->layout.u.contig.size,tmp_size,hssize_t,hsize_t); } /* end case */ @@ -2106,7 +2106,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space hsize_t max_dim[H5O_LAYOUT_NDIMS]; /* Maximum size of data in elements */ /* Set up layout information */ - if((ndims=H5S_GET_SIMPLE_EXTENT_NDIMS(new_dset->space))<0) + if((ndims=H5S_GET_EXTENT_NDIMS(new_dset->space))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get rank") new_dset->layout.u.chunk.ndims = (unsigned)ndims + 1; assert((unsigned)(new_dset->layout.u.chunk.ndims) <= NELMTS(new_dset->layout.u.chunk.dim)); @@ -2158,7 +2158,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space * Compact dataset is stored in dataset object header message of * layout. */ - tmp_size = H5S_GET_SIMPLE_EXTENT_NPOINTS(space) * + tmp_size = H5S_GET_EXTENT_NPOINTS(space) * H5T_get_size(new_dset->type); H5_ASSIGN_OVERFLOW(new_dset->layout.u.compact.size,tmp_size,hssize_t,size_t); @@ -2443,7 +2443,7 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) if(dataset->layout.version<3) { hssize_t tmp_size; /* Temporary holder for raw data size */ - tmp_size = H5S_GET_SIMPLE_EXTENT_NPOINTS(dataset->space) * + tmp_size = H5S_GET_EXTENT_NPOINTS(dataset->space) * H5T_get_size(dataset->type); H5_ASSIGN_OVERFLOW(dataset->layout.u.contig.size,tmp_size,hssize_t,hsize_t); } /* end if */ @@ -3036,7 +3036,7 @@ H5D_init_storage(H5D_t *dset, hbool_t full_overwrite, hid_t dxpl_id) size_t npoints; /* Number of points in space */ /* Get the number of elements in the dataset's dataspace */ - snpoints = H5S_GET_SIMPLE_EXTENT_NPOINTS(dset->space); + snpoints = H5S_GET_EXTENT_NPOINTS(dset->space); assert(snpoints>=0); H5_ASSIGN_OVERFLOW(npoints,snpoints,hssize_t,size_t); diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 47fdace..407873a 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -166,7 +166,7 @@ H5D_contig_fill(H5F_t *f, hid_t dxpl_id, H5D_t *dset) assert(elmt_size>0); /* Get the number of elements in the dataset's dataspace */ - snpoints = H5S_GET_SIMPLE_EXTENT_NPOINTS(dset->space); + snpoints = H5S_GET_EXTENT_NPOINTS(dset->space); assert(snpoints>=0); H5_ASSIGN_OVERFLOW(npoints,snpoints,hssize_t,size_t); diff --git a/src/H5Dio.c b/src/H5Dio.c index 47d6bdf..0190555 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -917,7 +917,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, hbool_t full_overwrite; /* Whether we are over-writing all the elements */ /* Get the number of elements in file dataset's dataspace */ - if((file_nelmts=H5S_GET_SIMPLE_EXTENT_NPOINTS(file_space))<0) + if((file_nelmts=H5S_GET_EXTENT_NPOINTS(file_space))<0) HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, FAIL, "can't retrieve number of elements in file dataset") /* Always allow fill values to be written if the dataset has a VL datatype */ @@ -2309,7 +2309,7 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp fm->layout = &(dataset->layout); /* Check if the memory space is scalar & make equivalent memory space */ - if((sm_ndims = H5S_GET_SIMPLE_EXTENT_NDIMS(mem_space))<0) + if((sm_ndims = H5S_GET_EXTENT_NDIMS(mem_space))<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimension number") if(sm_ndims==0) { hsize_t dims[H5O_LAYOUT_NDIMS]; /* Temporary dimension information */ diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 2ae0278..e1528ef 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -210,7 +210,7 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED * p += attr->ds_size; /* Compute the size of the data */ - H5_ASSIGN_OVERFLOW(attr->data_size,H5S_GET_SIMPLE_EXTENT_NPOINTS(attr->ds)*H5T_get_size(attr->dt),hsize_t,size_t); + H5_ASSIGN_OVERFLOW(attr->data_size,H5S_GET_EXTENT_NPOINTS(attr->ds)*H5T_get_size(attr->dt),hsize_t,size_t); /* Go get the data */ if (NULL==(attr->data = H5MM_malloc(attr->data_size))) @@ -534,6 +534,7 @@ H5S_release_simple(H5S_simple_t *simple) done: FUNC_LEAVE_NOAPI(ret_value); } + /*------------------------------------------------------------------------- * Function: H5Scopy @@ -808,7 +809,7 @@ H5Sget_simple_extent_npoints(hid_t space_id) if (NULL == (ds = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - ret_value = H5S_GET_SIMPLE_EXTENT_NPOINTS(ds); + ret_value = H5S_GET_EXTENT_NPOINTS(ds); done: FUNC_LEAVE_API(ret_value); @@ -847,7 +848,7 @@ H5S_get_npoints_max(const H5S_t *ds) /* check args */ assert(ds); - switch (ds->extent.type) { + switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_SCALAR: ret_value = 1; break; @@ -911,7 +912,7 @@ H5Sget_simple_extent_ndims(hid_t space_id) if (NULL == (ds = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - ret_value = H5S_GET_SIMPLE_EXTENT_NDIMS(ds); + ret_value = H5S_GET_EXTENT_NDIMS(ds); done: FUNC_LEAVE_API(ret_value); @@ -949,7 +950,7 @@ H5S_get_simple_extent_ndims(const H5S_t *ds) /* check args */ assert(ds); - switch (ds->extent.type) { + switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_SCALAR: case H5S_SIMPLE: ret_value = ds->extent.u.simple.rank; @@ -1039,7 +1040,7 @@ H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[]) /* check args */ assert(ds); - switch (ds->extent.type) { + switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_SCALAR: ret_value = 0; break; @@ -1096,7 +1097,7 @@ H5S_modify(H5G_entry_t *ent, const H5S_t *ds, hbool_t update_time, hid_t dxpl_id assert(ent); assert(ds); - switch (ds->extent.type) { + switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_SCALAR: case H5S_SIMPLE: if (H5O_modify(ent, H5O_SDSPACE_ID, 0, 0, update_time, &(ds->extent.u.simple), dxpl_id)<0) @@ -1142,7 +1143,7 @@ H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, const H5S_t *ds) assert(oh); assert(ds); - switch (ds->extent.type) { + switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_SCALAR: case H5S_SIMPLE: if (H5O_append(f, dxpl_id, oh, H5O_SDSPACE_ID, 0, &(ds->extent.u.simple))<0) @@ -1253,8 +1254,8 @@ H5S_is_simple(const H5S_t *sdim) /* Check args and all the boring stuff. */ assert(sdim); - ret_value = (sdim->extent.type == H5S_SIMPLE || - sdim->extent.type == H5S_SCALAR) ? TRUE : FALSE; + ret_value = (H5S_GET_EXTENT_TYPE(sdim) == H5S_SIMPLE || + H5S_GET_EXTENT_TYPE(sdim) == H5S_SCALAR) ? TRUE : FALSE; done: FUNC_LEAVE_NOAPI(ret_value); @@ -1390,7 +1391,7 @@ H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims, assert(0==rank || dims); /* shift out of the previous state to a "simple" dataspace */ - switch (space->extent.type) { + switch (H5S_GET_EXTENT_TYPE(space)) { case H5S_SCALAR: /* do nothing */ break; @@ -1504,18 +1505,18 @@ UNUSED FUNC_ENTER_NOAPI(H5S_find, NULL); /* Check args */ - assert (mem_space && (H5S_SIMPLE==mem_space->extent.type || - H5S_SCALAR==mem_space->extent.type)); - assert (file_space && (H5S_SIMPLE==file_space->extent.type || - H5S_SCALAR==file_space->extent.type)); + assert (mem_space && (H5S_SIMPLE==H5S_GET_EXTENT_TYPE(mem_space) || + H5S_SCALAR==H5S_GET_EXTENT_TYPE(mem_space))); + assert (file_space && (H5S_SIMPLE==H5S_GET_EXTENT_TYPE(file_space) || + H5S_SCALAR==H5S_GET_EXTENT_TYPE(file_space))); /* * Is this path already present in the data space conversion path table? * If so then return a pointer to that entry. */ for (i=0; i<H5S_nconv_g; i++) { - if (H5S_conv_g[i]->ftype==file_space->select.type && - H5S_conv_g[i]->mtype==mem_space->select.type) { + if (H5S_conv_g[i]->ftype==H5S_GET_SELECT_TYPE(file_space) && + H5S_conv_g[i]->mtype==H5S_GET_SELECT_TYPE(mem_space)) { #ifdef H5_HAVE_PARALLEL /* @@ -1556,8 +1557,8 @@ UNUSED HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for data space conversion path"); /* Initialize file & memory conversion functions */ - path->ftype = file_space->select.type; - path->mtype = mem_space->select.type; + path->ftype = H5S_GET_SELECT_TYPE(file_space); + path->mtype = H5S_GET_SELECT_TYPE(mem_space); #ifdef H5_HAVE_PARALLEL /* @@ -1639,7 +1640,7 @@ H5S_extend (H5S_t *space, const hsize_t *size) FUNC_ENTER_NOAPI(H5S_extend, FAIL); /* Check args */ - assert (space && H5S_SIMPLE==space->extent.type); + assert (space && H5S_SIMPLE==H5S_GET_EXTENT_TYPE(space)); assert (size); /* Check through all the dimensions to see if modifying the dataspace is allowed */ @@ -1824,7 +1825,7 @@ H5S_get_simple_extent_type(const H5S_t *space) assert(space); - ret_value=space->extent.type; + ret_value=H5S_GET_EXTENT_TYPE(space); done: FUNC_LEAVE_NOAPI(ret_value); @@ -1862,7 +1863,7 @@ H5Sget_simple_extent_type(hid_t sid) if (NULL == (space = H5I_object_verify(sid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5S_NO_CLASS, "not a dataspace"); - ret_value=H5S_GET_SIMPLE_EXTENT_TYPE(space); + ret_value=H5S_GET_EXTENT_TYPE(space); done: FUNC_LEAVE_API(ret_value); @@ -1935,7 +1936,7 @@ H5Soffset_simple(hid_t space_id, const hssize_t *offset) /* Check args */ if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); - if (space->extent.u.simple.rank==0 || space->extent.type==H5S_SCALAR) + if (space->extent.u.simple.rank==0 || H5S_GET_EXTENT_TYPE(space)==H5S_SCALAR) HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar dataspace"); if (offset == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified"); @@ -1973,7 +1974,7 @@ H5S_set_extent( H5S_t *space, const hsize_t *size ) FUNC_ENTER_NOAPI( H5S_set_extent, FAIL ); /* Check args */ - assert( space && H5S_SIMPLE==space->extent.type ); + assert( space && H5S_SIMPLE==H5S_GET_EXTENT_TYPE(space) ); assert( size); /* Verify that the dimensions being changed are allowed to change */ @@ -2019,7 +2020,7 @@ H5S_set_extent_real( H5S_t *space, const hsize_t *size ) FUNC_ENTER_NOAPI(H5S_set_extent_real, FAIL ); /* Check args */ - assert(space && H5S_SIMPLE==space->extent.type ); + assert(space && H5S_SIMPLE==H5S_GET_EXTENT_TYPE(space)); assert(size); /* Change the dataspace size & re-compute the number of elements in the extent */ @@ -2061,7 +2062,7 @@ H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, FUNC_ENTER_NOAPI(H5S_debug, FAIL); - switch (mesg->extent.type) { + switch (H5S_GET_EXTENT_TYPE(mesg)) { case H5S_SCALAR: fprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth, "Space class:"); @@ -2076,7 +2077,7 @@ H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, default: fprintf(stream, "%*s%-*s **UNKNOWN-%ld**\n", indent, "", fwidth, - "Space class:", (long)(mesg->extent.type)); + "Space class:", (long)(H5S_GET_EXTENT_TYPE(mesg))); break; } diff --git a/src/H5Sall.c b/src/H5Sall.c index fafbf09..1058e07 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -36,6 +36,24 @@ static int interface_initialize_g = 0; /* Static function prototypes */ + +/* Selection callbacks */ +static herr_t H5S_all_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +static herr_t H5S_all_get_seq_list(const H5S_t *space, unsigned flags, + 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_all_release(H5S_t *space); +static htri_t H5S_all_is_valid(const H5S_t *space); +static hssize_t H5S_all_serial_size(const H5S_t *space); +static herr_t H5S_all_serialize(const H5S_t *space, uint8_t *buf); +static herr_t H5S_all_deserialize(H5S_t *space, const uint8_t *buf); +static herr_t H5S_all_bounds(const H5S_t *space, hssize_t *start, hssize_t *end); +static htri_t H5S_all_is_contiguous(const H5S_t *space); +static htri_t H5S_all_is_single(const H5S_t *space); +static htri_t H5S_all_is_regular(const H5S_t *space); +static herr_t H5S_all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); + +/* Selection iteration callbacks */ static herr_t H5S_all_iter_coords(const H5S_sel_iter_t *iter, hssize_t *coords); static herr_t H5S_all_iter_block(const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *end); static hsize_t H5S_all_iter_nelmts(const H5S_sel_iter_t *iter); @@ -44,6 +62,39 @@ static herr_t H5S_all_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); static herr_t H5S_all_iter_next_block(H5S_sel_iter_t *sel_iter); static herr_t H5S_all_iter_release(H5S_sel_iter_t *sel_iter); +/* Selection properties for "all" selections */ +const H5S_select_class_t H5S_sel_all[1] = {{ + H5S_SEL_ALL, + + /* Methods on selection */ + H5S_all_copy, + H5S_all_get_seq_list, + H5S_all_release, + H5S_all_is_valid, + H5S_all_serial_size, + H5S_all_serialize, + H5S_all_deserialize, + H5S_all_bounds, + H5S_all_is_contiguous, + H5S_all_is_single, + H5S_all_is_regular, + H5S_all_iter_init, +}}; + +/* Iteration properties for "all" selections */ +static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{ + H5S_SEL_ALL, + + /* Methods on selection iterator */ + H5S_all_iter_coords, + H5S_all_iter_block, + H5S_all_iter_nelmts, + H5S_all_iter_has_next_block, + H5S_all_iter_next, + H5S_all_iter_next_block, + H5S_all_iter_release, +}}; + /*------------------------------------------------------------------------- * Function: H5S_all_iter_init @@ -67,7 +118,7 @@ H5S_all_iter_init (H5S_sel_iter_t *iter, const H5S_t *space) FUNC_ENTER_NOAPI(H5S_all_iter_init, FAIL); /* Check args */ - assert (space && H5S_SEL_ALL==space->select.type); + assert (space && H5S_SEL_ALL==H5S_GET_SELECT_TYPE(space)); assert (iter); /* Initialize the number of elements to iterate over */ @@ -77,14 +128,8 @@ H5S_all_iter_init (H5S_sel_iter_t *iter, const H5S_t *space) iter->u.all.elmt_offset=0; iter->u.all.byte_offset=0; - /* Initialize methods for selection iterator */ - iter->iter_coords=H5S_all_iter_coords; - iter->iter_block=H5S_all_iter_block; - iter->iter_nelmts=H5S_all_iter_nelmts; - iter->iter_has_next_block=H5S_all_iter_has_next_block; - iter->iter_next=H5S_all_iter_next; - iter->iter_next_block=H5S_all_iter_next_block; - iter->iter_release=H5S_all_iter_release; + /* Initialize type of selection iterator */ + iter->type=H5S_sel_iter_all; done: FUNC_LEAVE_NOAPI(ret_value); @@ -370,7 +415,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_all_copy (H5S_t *dst, const H5S_t *src) +H5S_all_copy(H5S_t *dst, const H5S_t *src, hbool_t UNUSED share_selection) { herr_t ret_value=SUCCEED; /* return value */ @@ -380,7 +425,7 @@ H5S_all_copy (H5S_t *dst, const H5S_t *src) assert(dst); /* Set number of elements in selection */ - dst->select.num_elem=(hsize_t)H5S_GET_SIMPLE_EXTENT_NPOINTS(dst); + dst->select.num_elem=(hsize_t)H5S_GET_EXTENT_NPOINTS(dst); done: FUNC_LEAVE_NOAPI(ret_value); @@ -489,7 +534,7 @@ H5S_all_serialize (const H5S_t *space, uint8_t *buf) assert(space); /* Store the preamble information */ - UINT32ENCODE(buf, (uint32_t)space->select.type); /* Store the type of selection */ + UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(buf, (uint32_t)1); /* Store the version number */ UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */ UINT32ENCODE(buf, (uint32_t)0); /* Store the additional information length */ @@ -524,7 +569,7 @@ done: herr_t H5S_all_deserialize (H5S_t *space, const uint8_t UNUSED *buf) { - herr_t ret_value=FAIL; /* return value */ + herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI(H5S_all_deserialize, FAIL); @@ -723,22 +768,10 @@ H5S_select_all (H5S_t *space, unsigned rel_prev) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection"); /* Set number of elements in selection */ - space->select.num_elem=(hsize_t)H5S_GET_SIMPLE_EXTENT_NPOINTS(space); + space->select.num_elem=(hsize_t)H5S_GET_EXTENT_NPOINTS(space); /* Set selection type */ - space->select.type=H5S_SEL_ALL; - - /* Set selection methods */ - space->select.get_seq_list=H5S_all_get_seq_list; - space->select.release=H5S_all_release; - space->select.is_valid=H5S_all_is_valid; - space->select.serial_size=H5S_all_serial_size; - space->select.serialize=H5S_all_serialize; - space->select.bounds=H5S_all_bounds; - space->select.is_contiguous=H5S_all_is_contiguous; - space->select.is_single=H5S_all_is_single; - space->select.is_regular=H5S_all_is_regular; - space->select.iter_init=H5S_all_iter_init; + space->select.type=H5S_sel_all; done: FUNC_LEAVE_NOAPI(ret_value); diff --git a/src/H5Shyper.c b/src/H5Shyper.c index cb7c5d7..91e55e6 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -47,6 +47,24 @@ static herr_t H5S_hyper_span_precompute (H5S_hyper_span_info_t *spans, size_t el static herr_t H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, const hssize_t start[], const hsize_t stride[], const hsize_t count[], const hsize_t block[]); static herr_t H5S_hyper_generate_spans(H5S_t *space); + +/* Selection callbacks */ +static herr_t H5S_hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +static herr_t H5S_hyper_get_seq_list(const H5S_t *space, unsigned flags, + 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_hyper_release(H5S_t *space); +static htri_t H5S_hyper_is_valid(const H5S_t *space); +static hssize_t H5S_hyper_serial_size(const H5S_t *space); +static herr_t H5S_hyper_serialize(const H5S_t *space, uint8_t *buf); +static herr_t H5S_hyper_deserialize(H5S_t *space, const uint8_t *buf); +static herr_t H5S_hyper_bounds(const H5S_t *space, hssize_t *start, hssize_t *end); +static htri_t H5S_hyper_is_contiguous(const H5S_t *space); +static htri_t H5S_hyper_is_single(const H5S_t *space); +static htri_t H5S_hyper_is_regular(const H5S_t *space); +static herr_t H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); + +/* Selection iteration callbacks */ static herr_t H5S_hyper_iter_coords(const H5S_sel_iter_t *iter, hssize_t *coords); static herr_t H5S_hyper_iter_block(const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *end); static hsize_t H5S_hyper_iter_nelmts(const H5S_sel_iter_t *iter); @@ -55,6 +73,39 @@ static herr_t H5S_hyper_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); static herr_t H5S_hyper_iter_next_block(H5S_sel_iter_t *sel_iter); static herr_t H5S_hyper_iter_release(H5S_sel_iter_t *sel_iter); +/* Selection properties for hyperslab selections */ +const H5S_select_class_t H5S_sel_hyper[1] = {{ + H5S_SEL_HYPERSLABS, + + /* Methods on selection */ + H5S_hyper_copy, + H5S_hyper_get_seq_list, + H5S_hyper_release, + H5S_hyper_is_valid, + H5S_hyper_serial_size, + H5S_hyper_serialize, + H5S_hyper_deserialize, + H5S_hyper_bounds, + H5S_hyper_is_contiguous, + H5S_hyper_is_single, + H5S_hyper_is_regular, + H5S_hyper_iter_init, +}}; + +/* Iteration properties for hyperslab selections */ +static const H5S_sel_iter_class_t H5S_sel_iter_hyper[1] = {{ + H5S_SEL_HYPERSLABS, + + /* Methods on selection iterator */ + H5S_hyper_iter_coords, + H5S_hyper_iter_block, + H5S_hyper_iter_nelmts, + H5S_hyper_iter_has_next_block, + H5S_hyper_iter_next, + H5S_hyper_iter_next_block, + H5S_hyper_iter_release, +}}; + /* Static variables */ static const hsize_t _stride[H5O_LAYOUT_NDIMS]={ /* Default stride array */ 1,1,1,1, 1,1,1,1, @@ -67,6 +118,9 @@ static const hsize_t _block[H5O_LAYOUT_NDIMS]={ /* Default block size ar 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,1}; +/* Declare a free list to manage the H5S_hyper_sel_t struct */ +H5FL_DEFINE_STATIC(H5S_hyper_sel_t); + /* Declare a free list to manage the H5S_hyper_span_t struct */ H5FL_DEFINE_STATIC(H5S_hyper_span_t); @@ -110,7 +164,7 @@ H5S_space_print_spans(FILE *f, const H5S_t *space) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_space_print_spans); - H5S_hyper_print_spans(f,space->select.sel_info.hslab.span_lst); + H5S_hyper_print_spans(f,space->select.sel_info.hslab->span_lst); FUNC_LEAVE_NOAPI(SUCCEED); } @@ -147,8 +201,8 @@ H5S_hyper_print_diminfo(FILE *f, const H5S_t *space) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_print_diminfo); - H5S_hyper_print_diminfo_helper(f,"opt_diminfo",space->extent.u.simple.rank,space->select.sel_info.hslab.opt_diminfo); - H5S_hyper_print_diminfo_helper(f,"app_diminfo",space->extent.u.simple.rank,space->select.sel_info.hslab.app_diminfo); + H5S_hyper_print_diminfo_helper(f,"opt_diminfo",space->extent.u.simple.rank,space->select.sel_info.hslab->opt_diminfo); + H5S_hyper_print_diminfo_helper(f,"app_diminfo",space->extent.u.simple.rank,space->select.sel_info.hslab->app_diminfo); FUNC_LEAVE_NOAPI(SUCCEED); } @@ -187,7 +241,7 @@ H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) FUNC_ENTER_NOAPI(H5S_hyper_iter_init, FAIL); /* Check args */ - assert(space && H5S_SEL_HYPERSLABS==space->select.type); + assert(space && H5S_SEL_HYPERSLABS==H5S_GET_SELECT_TYPE(space)); assert(iter); /* Initialize the number of points to iterate over */ @@ -198,10 +252,10 @@ H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) rank=space->extent.u.simple.rank; /* Set the temporary pointer to the dimension information */ - tdiminfo=space->select.sel_info.hslab.opt_diminfo; + tdiminfo=space->select.sel_info.hslab->opt_diminfo; /* Check for the special case of just one H5Sselect_hyperslab call made */ - if(space->select.sel_info.hslab.diminfo_valid) { + if(space->select.sel_info.hslab->diminfo_valid) { /* Initialize the information needed for regular hyperslab I/O */ const hsize_t *mem_size; /* Temporary pointer to dataspace extent's dimension sizes */ hsize_t acc; /* Accumulator for "flattened" dimension's sizes */ @@ -310,9 +364,9 @@ H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) } /* end if */ else { /* Initialize the information needed for non-regular hyperslab I/O */ - assert(space->select.sel_info.hslab.span_lst); + assert(space->select.sel_info.hslab->span_lst); /* Make a copy of the span tree to iterate over */ - iter->u.hyp.spans=H5S_hyper_copy_span(space->select.sel_info.hslab.span_lst); + iter->u.hyp.spans=H5S_hyper_copy_span(space->select.sel_info.hslab->span_lst); /* Set the nelem & pstride values according to the element size */ H5S_hyper_span_precompute(iter->u.hyp.spans,iter->elmt_size); @@ -339,14 +393,8 @@ H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) } /* end else */ - /* Initialize methods for selection iterator */ - iter->iter_coords=H5S_hyper_iter_coords; - iter->iter_block=H5S_hyper_iter_block; - iter->iter_nelmts=H5S_hyper_iter_nelmts; - iter->iter_has_next_block=H5S_hyper_iter_has_next_block; - iter->iter_next=H5S_hyper_iter_next; - iter->iter_next_block=H5S_hyper_iter_next_block; - iter->iter_release=H5S_hyper_iter_release; + /* Initialize type of selection iterator */ + iter->type=H5S_sel_iter_hyper; done: FUNC_LEAVE_NOAPI(ret_value); @@ -1541,17 +1589,23 @@ H5S_hyper_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) assert(src); assert(dst); + /* Allocate space for the hyperslab selection information */ + if((dst->select.sel_info.hslab=H5FL_MALLOC(H5S_hyper_sel_t))==NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab info"); + + /* Copy the hyperslab information */ + HDmemcpy(dst->select.sel_info.hslab,src->select.sel_info.hslab,sizeof(H5S_hyper_sel_t)); + /* Check if there is hyperslab span information to copy */ /* (Regular hyperslab information is copied with the selection structure) */ - if(src->select.sel_info.hslab.span_lst!=NULL) { + if(src->select.sel_info.hslab->span_lst!=NULL) { if(share_selection) { /* Share the source's span tree by incrementing the reference count on it */ - dst->select.sel_info.hslab.span_lst=src->select.sel_info.hslab.span_lst; - dst->select.sel_info.hslab.span_lst->count++; + dst->select.sel_info.hslab->span_lst->count++; } /* end if */ else /* Copy the hyperslab span information */ - dst->select.sel_info.hslab.span_lst=H5S_hyper_copy_span(src->select.sel_info.hslab.span_lst); + dst->select.sel_info.hslab->span_lst=H5S_hyper_copy_span(src->select.sel_info.hslab->span_lst); } /* end if */ done: @@ -1656,8 +1710,8 @@ H5S_hyper_is_valid (const H5S_t *space) assert(space); /* Check for a "regular" hyperslab selection */ - if(space->select.sel_info.hslab.diminfo_valid) { - const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab.opt_diminfo; /* local alias for diminfo */ + if(space->select.sel_info.hslab->diminfo_valid) { + const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */ hssize_t end; /* The high bound of a region in a dimension */ /* Check each dimension */ @@ -1681,7 +1735,7 @@ H5S_hyper_is_valid (const H5S_t *space) } /* end if */ else { /* Call the recursive routine to validate the span tree */ - ret_value=H5S_hyper_is_valid_helper(space->select.sel_info.hslab.span_lst,space->select.offset,space->extent.u.simple.size,(hsize_t)0); + ret_value=H5S_hyper_is_valid_helper(space->select.sel_info.hslab->span_lst,space->select.offset,space->extent.u.simple.size,(hsize_t)0); } /* end else */ done: @@ -1765,13 +1819,13 @@ H5S_get_select_hyper_nblocks(H5S_t *space) assert(space); /* Check for a "regular" hyperslab selection */ - if(space->select.sel_info.hslab.diminfo_valid) { + if(space->select.sel_info.hslab->diminfo_valid) { /* Check each dimension */ for(ret_value=1,u=0; u<space->extent.u.simple.rank; u++) - ret_value*=space->select.sel_info.hslab.app_diminfo[u].count; + ret_value*=space->select.sel_info.hslab->app_diminfo[u].count; } /* end if */ else - ret_value = H5S_hyper_span_nblocks(space->select.sel_info.hslab.span_lst); + ret_value = H5S_hyper_span_nblocks(space->select.sel_info.hslab->span_lst); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_get_select_hyper_nblocks() */ @@ -1806,7 +1860,7 @@ H5Sget_select_hyper_nblocks(hid_t spaceid) /* Check args */ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - if(space->select.type!=H5S_SEL_HYPERSLABS) + if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection"); ret_value = H5S_get_select_hyper_nblocks(space); @@ -1853,15 +1907,15 @@ H5S_hyper_serial_size (const H5S_t *space) ret_value=24; /* Check for a "regular" hyperslab selection */ - if(space->select.sel_info.hslab.diminfo_valid) { + if(space->select.sel_info.hslab->diminfo_valid) { /* Check each dimension */ for(block_count=1,u=0; u<space->extent.u.simple.rank; u++) - block_count*=space->select.sel_info.hslab.opt_diminfo[u].count; + block_count*=space->select.sel_info.hslab->opt_diminfo[u].count; ret_value+=8*block_count*space->extent.u.simple.rank; } /* end if */ else { /* Spin through hyperslab spans, adding 8 * rank bytes for each block */ - block_count=H5S_hyper_span_nblocks(space->select.sel_info.hslab.span_lst); + block_count=H5S_hyper_span_nblocks(space->select.sel_info.hslab->span_lst); ret_value+=8*space->extent.u.simple.rank*block_count; } /* end else */ @@ -1991,7 +2045,7 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) assert(space); /* Store the preamble information */ - UINT32ENCODE(buf, (uint32_t)space->select.type); /* Store the type of selection */ + UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(buf, (uint32_t)1); /* Store the version number */ UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */ lenp=buf; /* keep the pointer to the length location for later */ @@ -2002,11 +2056,11 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) len+=4; /* Check for a "regular" hyperslab selection */ - if(space->select.sel_info.hslab.diminfo_valid) { + if(space->select.sel_info.hslab->diminfo_valid) { /* Set some convienence values */ ndims=space->extent.u.simple.rank; fast_dim=ndims-1; - diminfo=space->select.sel_info.hslab.opt_diminfo; + diminfo=space->select.sel_info.hslab->opt_diminfo; /* Check each dimension */ for(block_count=1,i=0; i<ndims; i++) @@ -2088,7 +2142,7 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) } /* end if */ else { /* Encode number of hyperslabs */ - block_count=H5S_hyper_span_nblocks(space->select.sel_info.hslab.span_lst); + block_count=H5S_hyper_span_nblocks(space->select.sel_info.hslab->span_lst); UINT32ENCODE(buf, (uint32_t)block_count); len+=4; @@ -2098,7 +2152,7 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) len+=(size_t)(8*space->extent.u.simple.rank*block_count); /* Encode each hyperslab in selection */ - H5S_hyper_serialize_helper(space->select.sel_info.hslab.span_lst,start,end,(hsize_t)0,&buf); + H5S_hyper_serialize_helper(space->select.sel_info.hslab->span_lst,start,end,(hsize_t)0,&buf); } /* end else */ /* Encode length */ @@ -2345,7 +2399,7 @@ H5S_get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startbloc assert(buf); /* Check for a "regular" hyperslab selection */ - if(space->select.sel_info.hslab.diminfo_valid) { + if(space->select.sel_info.hslab->diminfo_valid) { /* Set some convienence values */ ndims=space->extent.u.simple.rank; fast_dim=ndims-1; @@ -2356,13 +2410,13 @@ H5S_get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startbloc * Use the "optimized dimension information" to pass back information * on the blocks set, not the "application information". */ - diminfo=space->select.sel_info.hslab.opt_diminfo; + diminfo=space->select.sel_info.hslab->opt_diminfo; else /* * Use the "application dimension information" to pass back to the user * the blocks they set, not the optimized, internal information. */ - diminfo=space->select.sel_info.hslab.app_diminfo; + diminfo=space->select.sel_info.hslab->app_diminfo; /* Build the tables of count sizes as well as the initial offset */ for(i=0; i<ndims; i++) { @@ -2438,7 +2492,7 @@ H5S_get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startbloc } /* end while */ } /* end if */ else - ret_value=H5S_hyper_span_blocklist(space->select.sel_info.hslab.span_lst,start,end,(hsize_t)0,&startblock,&numblocks,&buf); + ret_value=H5S_hyper_span_blocklist(space->select.sel_info.hslab->span_lst,start,end,(hsize_t)0,&startblock,&numblocks,&buf); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_get_select_hyper_blocklist() */ @@ -2488,7 +2542,7 @@ H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numbloc HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer"); if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - if(space->select.type!=H5S_SEL_HYPERSLABS) + if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection"); /* Go get the correct number of blocks */ @@ -2616,8 +2670,8 @@ H5S_hyper_bounds(const H5S_t *space, hssize_t *start, hssize_t *end) } /* end for */ /* Check for a "regular" hyperslab selection */ - if(space->select.sel_info.hslab.diminfo_valid) { - const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab.opt_diminfo; /* local alias for diminfo */ + if(space->select.sel_info.hslab->diminfo_valid) { + const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */ /* Check each dimension */ for(i=0; i<rank; i++) { @@ -2630,7 +2684,7 @@ H5S_hyper_bounds(const H5S_t *space, hssize_t *start, hssize_t *end) } /* end if */ else { /* Call the recursive routine to get the bounds for the span tree */ - ret_value=H5S_hyper_bounds_helper(space->select.sel_info.hslab.span_lst,space->select.offset,(hsize_t)0,start,end); + ret_value=H5S_hyper_bounds_helper(space->select.sel_info.hslab->span_lst,space->select.offset,(hsize_t)0,start,end); } /* end if */ done: @@ -2671,8 +2725,8 @@ H5S_hyper_is_contiguous(const H5S_t *space) assert(space); /* Check for a "regular" hyperslab selection */ - if(space->select.sel_info.hslab.diminfo_valid) { - const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab.opt_diminfo; /* local alias for diminfo */ + if(space->select.sel_info.hslab->diminfo_valid) { + const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */ /* * For a regular hyperslab to be contiguous, it must have only one @@ -2735,7 +2789,7 @@ H5S_hyper_is_contiguous(const H5S_t *space) small_contiguous=FALSE; /* assume false initially */ /* Get information for slowest changing information */ - spans=space->select.sel_info.hslab.span_lst; + spans=space->select.sel_info.hslab->span_lst; span=spans->head; /* If there are multiple spans in the slowest changing dimension, the selection isn't contiguous */ @@ -2781,7 +2835,7 @@ H5S_hyper_is_contiguous(const H5S_t *space) small_contiguous=TRUE; /* Get information for slowest changing information */ - spans=space->select.sel_info.hslab.span_lst; + spans=space->select.sel_info.hslab->span_lst; span=spans->head; /* Current dimension working on */ @@ -2854,7 +2908,7 @@ H5S_hyper_is_single(const H5S_t *space) assert(space); /* Check for a "single" hyperslab selection */ - if(space->select.sel_info.hslab.diminfo_valid) { + if(space->select.sel_info.hslab->diminfo_valid) { /* * For a regular hyperslab to be single, it must have only one * block (i.e. count==1 in all dimensions) @@ -2865,7 +2919,7 @@ H5S_hyper_is_single(const H5S_t *space) /* Check for a single block */ for(u=0; u<space->extent.u.simple.rank; u++) { - if(space->select.sel_info.hslab.opt_diminfo[u].count>1) { + if(space->select.sel_info.hslab->opt_diminfo[u].count>1) { ret_value=FALSE; break; } /* end if */ @@ -2879,7 +2933,7 @@ H5S_hyper_is_single(const H5S_t *space) ret_value=TRUE; /* assume true and reset if the dimensions don't match */ /* Get information for slowest changing information */ - spans=space->select.sel_info.hslab.span_lst; + spans=space->select.sel_info.hslab->span_lst; /* Cycle down the spans until we run out of down spans or find a non-contiguous span */ while(spans!=NULL) { @@ -2933,7 +2987,7 @@ H5S_hyper_is_regular(const H5S_t *space) assert(space); /* Only simple check for regular hyperslabs for now... */ - if(space->select.sel_info.hslab.diminfo_valid) + if(space->select.sel_info.hslab->diminfo_valid) ret_value=TRUE; else ret_value=FALSE; @@ -2973,21 +3027,21 @@ H5S_hyper_release (H5S_t *space) FUNC_ENTER_NOAPI(H5S_hyper_release, FAIL); /* Check args */ - assert (space && H5S_SEL_HYPERSLABS==space->select.type); + assert (space && H5S_SEL_HYPERSLABS==H5S_GET_SELECT_TYPE(space)); /* Reset the number of points selected */ space->select.num_elem=0; - /* Reset the regular selection info flag */ - space->select.sel_info.hslab.diminfo_valid=FALSE; - /* Release irregular hyperslab information */ - if(space->select.sel_info.hslab.span_lst!=NULL) { - if(H5S_hyper_free_span_info(space->select.sel_info.hslab.span_lst)<0) + if(space->select.sel_info.hslab->span_lst!=NULL) { + if(H5S_hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans"); - space->select.sel_info.hslab.span_lst=NULL; } /* end if */ + /* Release space for the hyperslab selection information */ + H5FL_FREE(H5S_hyper_sel_t,space->select.sel_info.hslab); + space->select.sel_info.hslab=NULL; + done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_hyper_release() */ @@ -3329,7 +3383,7 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, hssize_t *coords) assert(coords); /* Check if this is the first element in the selection */ - if(space->select.sel_info.hslab.span_lst==NULL) { + if(space->select.sel_info.hslab==NULL) { H5S_hyper_span_info_t *head; /* Pointer to new head of span tree */ /* Allocate a span info node */ @@ -3346,32 +3400,24 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, hssize_t *coords) if((head->head=H5S_hyper_coord_to_span(rank,coords))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); + /* Allocate selection info */ + if((space->select.sel_info.hslab=H5FL_MALLOC(H5S_hyper_sel_t))==NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info"); + /* Set the selection to the new span tree */ - space->select.sel_info.hslab.span_lst=head; + space->select.sel_info.hslab->span_lst=head; /* Set selection type */ - space->select.type=H5S_SEL_HYPERSLABS; + space->select.type=H5S_sel_hyper; /* Reset "regular" hyperslab flag */ - space->select.sel_info.hslab.diminfo_valid=FALSE; - - /* Set selection methods */ - space->select.get_seq_list=H5S_hyper_get_seq_list; - space->select.release=H5S_hyper_release; - space->select.is_valid=H5S_hyper_is_valid; - space->select.serial_size=H5S_hyper_serial_size; - space->select.serialize=H5S_hyper_serialize; - space->select.bounds=H5S_hyper_bounds; - space->select.is_contiguous=H5S_hyper_is_contiguous; - space->select.is_single=H5S_hyper_is_single; - space->select.is_regular=H5S_hyper_is_regular; - space->select.iter_init=H5S_hyper_iter_init; + space->select.sel_info.hslab->diminfo_valid=FALSE; /* Set # of elements in selection */ space->select.num_elem=1; } /* end if */ else { - if(H5S_hyper_add_span_element_helper(space->select.sel_info.hslab.span_lst,rank,coords)<0) + if(H5S_hyper_add_span_element_helper(space->select.sel_info.hslab->span_lst,rank,coords)<0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span"); /* Increment # of elements in selection */ @@ -3411,9 +3457,9 @@ H5S_hyper_reset_scratch(H5S_t *space) assert(space); /* Check if there are spans in the span tree */ - if(space->select.sel_info.hslab.span_lst!=NULL) + if(space->select.sel_info.hslab->span_lst!=NULL) /* Reset the scratch pointers for the next routine which needs them */ - if(H5S_hyper_span_scratch(space->select.sel_info.hslab.span_lst,NULL)==FAIL) + if(H5S_hyper_span_scratch(space->select.sel_info.hslab->span_lst,NULL)==FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "can't reset span tree scratch pointers"); done: @@ -3451,7 +3497,7 @@ H5S_hyper_convert(H5S_t *space) assert(space); /* Check the type of selection */ - switch(space->select.type) { + switch(H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_ALL: /* All elements selected in dataspace */ /* Convert current "all" selection to "real" hyperslab selection */ { @@ -3590,8 +3636,8 @@ H5S_hyper_intersect (H5S_t *space1, H5S_t *space2) assert(space2); /* Check that the space selections both have span trees */ - if(space1->select.sel_info.hslab.span_lst==NULL || - space2->select.sel_info.hslab.span_lst==NULL) + if(space1->select.sel_info.hslab->span_lst==NULL || + space2->select.sel_info.hslab->span_lst==NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree"); /* Check that the dataspaces are both the same rank */ @@ -3599,7 +3645,7 @@ H5S_hyper_intersect (H5S_t *space1, H5S_t *space2) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "dataspace ranks don't match"); /* Perform the span-by-span intersection check */ - if((ret_value=H5S_hyper_intersect_helper(space1->select.sel_info.hslab.span_lst,space2->select.sel_info.hslab.span_lst))<0) + if((ret_value=H5S_hyper_intersect_helper(space1->select.sel_info.hslab->span_lst,space2->select.sel_info.hslab->span_lst))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab intersection check"); done: @@ -3712,16 +3758,16 @@ H5S_hyper_intersect_block (H5S_t *space, hssize_t *start, hssize_t *end) /* Check for 'all' selection, instead of a hyperslab selection */ /* (Technically, this shouldn't be in the "hyperslab" routines...) */ - if(space->select.type==H5S_SEL_ALL) + if(H5S_GET_SELECT_TYPE(space)==H5S_SEL_ALL) HGOTO_DONE(TRUE); /* Check that the space selections both have span trees */ - if(space->select.sel_info.hslab.span_lst==NULL) + if(space->select.sel_info.hslab->span_lst==NULL) if(H5S_hyper_generate_spans(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree"); /* Perform the span-by-span intersection check */ - if((ret_value=H5S_hyper_intersect_block_helper(space->select.sel_info.hslab.span_lst,space->select.offset,start,end))<0) + if((ret_value=H5S_hyper_intersect_block_helper(space->select.sel_info.hslab->span_lst,space->select.offset,start,end))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab intersection check"); done: @@ -3821,20 +3867,20 @@ H5S_hyper_adjust(H5S_t *space, const hssize_t *offset) assert(offset); /* Subtract the offset from the "regular" coordinates, if they exist */ - if(space->select.sel_info.hslab.diminfo_valid) { + if(space->select.sel_info.hslab->diminfo_valid) { for(u=0; u<space->extent.u.simple.rank; u++) { - space->select.sel_info.hslab.opt_diminfo[u].start-=offset[u]; - assert(space->select.sel_info.hslab.opt_diminfo[u].start>=0); + space->select.sel_info.hslab->opt_diminfo[u].start-=offset[u]; + assert(space->select.sel_info.hslab->opt_diminfo[u].start>=0); } /* end for */ } /* end if */ /* Subtract the offset from the span tree coordinates, if they exist */ - if(space->select.sel_info.hslab.span_lst) { - if(H5S_hyper_adjust_helper(space->select.sel_info.hslab.span_lst,offset)<0) + if(space->select.sel_info.hslab->span_lst) { + if(H5S_hyper_adjust_helper(space->select.sel_info.hslab->span_lst,offset)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab offset adjustment"); /* Reset the scratch pointers for the next routine which needs them */ - if(H5S_hyper_span_scratch(space->select.sel_info.hslab.span_lst,NULL)==FAIL) + if(H5S_hyper_span_scratch(space->select.sel_info.hslab->span_lst,NULL)==FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "can't reset hyperslab scratch pointer"); } /* end if */ @@ -3936,20 +3982,20 @@ H5S_hyper_move(H5S_t *space, const hssize_t *offset) assert(offset); /* Move to the offset with the "regular" coordinates, if they exist */ - if(space->select.sel_info.hslab.diminfo_valid) { + if(space->select.sel_info.hslab->diminfo_valid) { for(u=0; u<space->extent.u.simple.rank; u++) { - space->select.sel_info.hslab.opt_diminfo[u].start=offset[u]; - assert(space->select.sel_info.hslab.opt_diminfo[u].start>=0); + space->select.sel_info.hslab->opt_diminfo[u].start=offset[u]; + assert(space->select.sel_info.hslab->opt_diminfo[u].start>=0); } /* end for */ } /* end if */ /* Subtract the offset from the span tree coordinates, if they exist */ - if(space->select.sel_info.hslab.span_lst) { - if(H5S_hyper_move_helper(space->select.sel_info.hslab.span_lst,offset)<0) + if(space->select.sel_info.hslab->span_lst) { + if(H5S_hyper_move_helper(space->select.sel_info.hslab->span_lst,offset)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab offset movement"); /* Reset the scratch pointers for the next routine which needs them */ - if(H5S_hyper_span_scratch(space->select.sel_info.hslab.span_lst,NULL)==FAIL) + if(H5S_hyper_span_scratch(space->select.sel_info.hslab->span_lst,NULL)==FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "can't reset hyperslab scratch pointer"); } /* end if */ @@ -3989,7 +4035,7 @@ H5S_hyper_normalize_offset(H5S_t *space) /* Check for 'all' selection, instead of a hyperslab selection */ /* (Technically, this check shouldn't be in the "hyperslab" routines...) */ - if(space->select.type!=H5S_SEL_ALL) { + if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_ALL) { /* Invert the selection offset */ for(u=0; u<space->extent.u.simple.rank; u++) space->select.offset[u] =- space->select.offset[u]; @@ -4957,26 +5003,26 @@ H5S_hyper_merge_spans (H5S_t *space, H5S_hyper_span_info_t *new_spans, hbool_t c assert (new_spans); /* If this is the first span tree in the hyperslab selection, just use it */ - if(space->select.sel_info.hslab.span_lst==NULL) { + if(space->select.sel_info.hslab->span_lst==NULL) { if(can_own) - space->select.sel_info.hslab.span_lst=new_spans; + space->select.sel_info.hslab->span_lst=new_spans; else - space->select.sel_info.hslab.span_lst=H5S_hyper_copy_span(new_spans); + space->select.sel_info.hslab->span_lst=H5S_hyper_copy_span(new_spans); } /* end if */ else { H5S_hyper_span_info_t *merged_spans; /* Get the merged spans */ - merged_spans=H5S_hyper_merge_spans_helper(space->select.sel_info.hslab.span_lst, new_spans); + merged_spans=H5S_hyper_merge_spans_helper(space->select.sel_info.hslab->span_lst, new_spans); /* Sanity checking since we started with some spans, we should still have some after the merge */ assert(merged_spans); /* Free the previous spans */ - H5S_hyper_free_span_info(space->select.sel_info.hslab.span_lst); + H5S_hyper_free_span_info(space->select.sel_info.hslab->span_lst); /* Point to the new merged spans */ - space->select.sel_info.hslab.span_lst=merged_spans; + space->select.sel_info.hslab->span_lst=merged_spans; } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED); @@ -5175,12 +5221,12 @@ H5S_hyper_can_rebuild (const H5S_t *space) /* Check args */ assert (space); - assert (space->select.sel_info.hslab.span_lst); + assert (space->select.sel_info.hslab->span_lst); /* For each level of the span tree check that there is only one span at * that level. */ - span=space->select.sel_info.hslab.span_lst->head; + span=space->select.sel_info.hslab->span_lst->head; while(span!=NULL) { if(span->next!=NULL) HGOTO_DONE(FALSE); @@ -5228,17 +5274,17 @@ H5S_hyper_rebuild (H5S_t *space) /* Check args */ assert (space); - assert (space->select.sel_info.hslab.span_lst); + assert (space->select.sel_info.hslab->span_lst); /* Get head of span list */ - span=space->select.sel_info.hslab.span_lst->head; + span=space->select.sel_info.hslab->span_lst->head; /* Protect against empty tree */ if(span!=NULL) { /* Iterate down the span tree */ curr_dim=0; - diminfo=space->select.sel_info.hslab.opt_diminfo; - app_diminfo=space->select.sel_info.hslab.app_diminfo; + diminfo=space->select.sel_info.hslab->opt_diminfo; + app_diminfo=space->select.sel_info.hslab->app_diminfo; while(span!=NULL) { /* Sanity check */ assert(curr_dim<space->extent.u.simple.rank); @@ -5260,7 +5306,7 @@ H5S_hyper_rebuild (H5S_t *space) } /* end while */ /* Indicate that the diminfo is valid */ - space->select.sel_info.hslab.diminfo_valid=TRUE; + space->select.sel_info.hslab->diminfo_valid=TRUE; } /* end if */ FUNC_LEAVE_NOAPI(ret_value); @@ -5298,14 +5344,14 @@ H5S_hyper_generate_spans(H5S_t *space) FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_generate_spans); assert(space); - assert(space->select.type==H5S_SEL_HYPERSLABS); + assert(H5S_GET_SELECT_TYPE(space)==H5S_SEL_HYPERSLABS); /* Get the diminfo */ for(u=0; u<space->extent.u.simple.rank; u++) { - tmp_start[u]=space->select.sel_info.hslab.opt_diminfo[u].start; - tmp_stride[u]=space->select.sel_info.hslab.opt_diminfo[u].stride; - tmp_count[u]=space->select.sel_info.hslab.opt_diminfo[u].count; - tmp_block[u]=space->select.sel_info.hslab.opt_diminfo[u].block; + tmp_start[u]=space->select.sel_info.hslab->opt_diminfo[u].start; + tmp_stride[u]=space->select.sel_info.hslab->opt_diminfo[u].stride; + tmp_count[u]=space->select.sel_info.hslab->opt_diminfo[u].count; + tmp_block[u]=space->select.sel_info.hslab->opt_diminfo[u].block; } /* end for */ /* Build the hyperslab information also */ @@ -5376,7 +5422,7 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, } /* end if */ else { /* Generate lists of spans which overlap and don't overlap */ - if(H5S_hyper_clip_spans(space->select.sel_info.hslab.span_lst,new_spans,&a_not_b,&a_and_b,&b_not_a)<0) + if(H5S_hyper_clip_spans(space->select.sel_info.hslab->span_lst,new_spans,&a_not_b,&a_and_b,&b_not_a)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information"); switch(op) { @@ -5395,9 +5441,9 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, case H5S_SELECT_AND: /* Free the current selection */ - if(H5S_hyper_free_span_info(space->select.sel_info.hslab.span_lst)<0) + if(H5S_hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans"); - space->select.sel_info.hslab.span_lst=NULL; + space->select.sel_info.hslab->span_lst=NULL; /* Reset the number of items in selection */ space->select.num_elem=0; @@ -5419,9 +5465,9 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, case H5S_SELECT_XOR: /* Free the current selection */ - if(H5S_hyper_free_span_info(space->select.sel_info.hslab.span_lst)<0) + if(H5S_hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans"); - space->select.sel_info.hslab.span_lst=NULL; + space->select.sel_info.hslab->span_lst=NULL; /* Reset the number of items in selection */ space->select.num_elem=0; @@ -5449,9 +5495,9 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, case H5S_SELECT_NOTB: /* Free the current selection */ - if(H5S_hyper_free_span_info(space->select.sel_info.hslab.span_lst)<0) + if(H5S_hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans"); - space->select.sel_info.hslab.span_lst=NULL; + space->select.sel_info.hslab->span_lst=NULL; /* Reset the number of items in selection */ space->select.num_elem=0; @@ -5473,9 +5519,9 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, case H5S_SELECT_NOTA: /* Free the current selection */ - if(H5S_hyper_free_span_info(space->select.sel_info.hslab.span_lst)<0) + if(H5S_hyper_free_span_info(space->select.sel_info.hslab->span_lst)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans"); - space->select.sel_info.hslab.span_lst=NULL; + space->select.sel_info.hslab->span_lst=NULL; /* Reset the number of items in selection */ space->select.num_elem=0; @@ -5508,7 +5554,7 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, H5S_hyper_free_span_info(b_not_a); /* Check if the resulting hyperslab span tree is empty */ - if(space->select.sel_info.hslab.span_lst==NULL) { + if(space->select.sel_info.hslab->span_lst==NULL) { H5S_hyper_span_info_t *spans; /* Empty hyperslab span tree */ /* Sanity check */ @@ -5528,7 +5574,7 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, spans->head=NULL; /* Set pointer to empty span tree */ - space->select.sel_info.hslab.span_lst=spans; + space->select.sel_info.hslab->span_lst=spans; } /* end if */ else { /* Check if the resulting hyperslab span tree can be used to re-build @@ -5628,7 +5674,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, } /* end for */ /* Fixup operation for non-hyperslab selections */ - switch(space->select.type) { + switch(H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_NONE: /* No elements selected in dataspace */ switch(op) { case H5S_SELECT_SET: /* Select "set" operation */ @@ -5716,38 +5762,42 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, if(H5S_SELECT_RELEASE(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release hyperslab"); + /* Allocate space for the hyperslab selection information */ + if((space->select.sel_info.hslab=H5FL_MALLOC(H5S_hyper_sel_t))==NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info"); + /* Save the diminfo */ space->select.num_elem=1; for(u=0; u<space->extent.u.simple.rank; u++) { - space->select.sel_info.hslab.app_diminfo[u].start = start[u]; - space->select.sel_info.hslab.app_diminfo[u].stride = stride[u]; - space->select.sel_info.hslab.app_diminfo[u].count = count[u]; - space->select.sel_info.hslab.app_diminfo[u].block = block[u]; - - space->select.sel_info.hslab.opt_diminfo[u].start = start[u]; - space->select.sel_info.hslab.opt_diminfo[u].stride = opt_stride[u]; - space->select.sel_info.hslab.opt_diminfo[u].count = opt_count[u]; - space->select.sel_info.hslab.opt_diminfo[u].block = opt_block[u]; + space->select.sel_info.hslab->app_diminfo[u].start = start[u]; + space->select.sel_info.hslab->app_diminfo[u].stride = stride[u]; + space->select.sel_info.hslab->app_diminfo[u].count = count[u]; + space->select.sel_info.hslab->app_diminfo[u].block = block[u]; + + space->select.sel_info.hslab->opt_diminfo[u].start = start[u]; + space->select.sel_info.hslab->opt_diminfo[u].stride = opt_stride[u]; + space->select.sel_info.hslab->opt_diminfo[u].count = opt_count[u]; + space->select.sel_info.hslab->opt_diminfo[u].block = opt_block[u]; space->select.num_elem*=(opt_count[u]*opt_block[u]); } /* end for */ /* Indicate that the dimension information is valid */ - space->select.sel_info.hslab.diminfo_valid=TRUE; + space->select.sel_info.hslab->diminfo_valid=TRUE; /* Indicate that there's no slab information */ - space->select.sel_info.hslab.span_lst=NULL; + space->select.sel_info.hslab->span_lst=NULL; } /* end if */ else if(op>=H5S_SELECT_OR && op<=H5S_SELECT_NOTA) { /* Sanity check */ - assert(space->select.type==H5S_SEL_HYPERSLABS); + assert(H5S_GET_SELECT_TYPE(space)==H5S_SEL_HYPERSLABS); /* Check if there's no hyperslab span information currently */ - if(space->select.sel_info.hslab.span_lst==NULL) + if(space->select.sel_info.hslab->span_lst==NULL) if(H5S_hyper_generate_spans(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree"); /* Indicate that the regular dimensions are no longer valid */ - space->select.sel_info.hslab.diminfo_valid=FALSE; + space->select.sel_info.hslab->diminfo_valid=FALSE; /* Add in the new hyperslab information */ if(H5S_generate_hyperslab (space, op, start, opt_stride, opt_count, opt_block)<0) @@ -5757,19 +5807,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); /* Set selection type */ - space->select.type=H5S_SEL_HYPERSLABS; - - /* Set selection methods */ - space->select.get_seq_list=H5S_hyper_get_seq_list; - space->select.release=H5S_hyper_release; - space->select.is_valid=H5S_hyper_is_valid; - space->select.serial_size=H5S_hyper_serial_size; - space->select.serialize=H5S_hyper_serialize; - space->select.bounds=H5S_hyper_bounds; - space->select.is_contiguous=H5S_hyper_is_contiguous; - space->select.is_single=H5S_hyper_is_single; - space->select.is_regular=H5S_hyper_is_regular; - space->select.iter_init=H5S_hyper_iter_init; + space->select.type=H5S_sel_hyper; done: FUNC_LEAVE_NOAPI(ret_value); @@ -5816,7 +5854,7 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[], /* Check args */ if (NULL == (space=H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - if (H5S_SCALAR==H5S_GET_SIMPLE_EXTENT_TYPE(space)) + if (H5S_SCALAR==H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_SCALAR space"); if(start==NULL || count==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified"); @@ -6799,7 +6837,7 @@ H5S_hyper_get_seq_list(const H5S_t *space, unsigned UNUSED flags, H5S_sel_iter_t assert(len); /* Check for the special case of just one H5Sselect_hyperslab call made */ - if(space->select.sel_info.hslab.diminfo_valid) + if(space->select.sel_info.hslab->diminfo_valid) /* Use optimized call to generate sequence list */ ret_value=H5S_hyper_get_seq_list_opt(space,iter,maxseq,maxelem,nseq,nelem,off,len); else diff --git a/src/H5Smpio.c b/src/H5Smpio.c index 6b8ce28..9f3d6ec 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -115,7 +115,7 @@ H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, assert (space); /* Just treat the entire extent as a block of bytes */ - if((snelmts = H5S_GET_SIMPLE_EXTENT_NPOINTS(space))<0) + if((snelmts = H5S_GET_EXTENT_NPOINTS(space))<0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,hsize_t); @@ -536,10 +536,10 @@ H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, assert (space); /* Creat MPI type based on the kind of selection */ - switch (space->extent.type) { + switch (H5S_GET_EXTENT_TYPE(space)) { case H5S_SCALAR: case H5S_SIMPLE: - switch(space->select.type) { + switch(H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_NONE: if ( H5S_mpio_none_type( space, elmt_size, /* out: */ new_type, count, extra_offset, is_derived_type ) <0) @@ -827,8 +827,8 @@ H5S_mpio_opt_possible( const H5S_t *mem_space, const H5S_t *file_space, const un assert(file_space); /* Check whether these are both simple or scalar dataspaces */ - if (!((H5S_SIMPLE==mem_space->extent.type || H5S_SCALAR==mem_space->extent.type) - && (H5S_SIMPLE==file_space->extent.type || H5S_SCALAR==file_space->extent.type))) + if (!((H5S_SIMPLE==H5S_GET_EXTENT_TYPE(mem_space) || H5S_SCALAR==H5S_GET_EXTENT_TYPE(mem_space)) + && (H5S_SIMPLE==H5S_GET_EXTENT_TYPE(file_space) || H5S_SCALAR==H5S_GET_EXTENT_TYPE(file_space)))) HGOTO_DONE(FALSE); /* Check whether both selections are "regular" */ @@ -840,7 +840,7 @@ H5S_mpio_opt_possible( const H5S_t *mem_space, const H5S_t *file_space, const un HGOTO_DONE(FALSE); /* Can't currently handle point selections */ - if (H5S_SEL_POINTS==mem_space->select.type || H5S_SEL_POINTS==file_space->select.type) + if (H5S_SEL_POINTS==H5S_GET_SELECT_TYPE(mem_space) || H5S_SEL_POINTS==H5S_GET_SELECT_TYPE(file_space)) HGOTO_DONE(FALSE); /* Dataset storage must be contiguous currently */ diff --git a/src/H5Snone.c b/src/H5Snone.c index 4409d2b..9e5e726 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -37,6 +37,24 @@ static int interface_initialize_g = 0; /* Static function 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_get_seq_list(const H5S_t *space, unsigned flags, + 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_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 *buf); +static herr_t H5S_none_deserialize(H5S_t *space, const uint8_t *buf); +static herr_t H5S_none_bounds(const H5S_t *space, hssize_t *start, hssize_t *end); +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 herr_t H5S_none_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); + +/* Selection iteration callbacks */ static herr_t H5S_none_iter_coords(const H5S_sel_iter_t *iter, hssize_t *coords); static herr_t H5S_none_iter_block(const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *end); static hsize_t H5S_none_iter_nelmts(const H5S_sel_iter_t *iter); @@ -45,6 +63,39 @@ 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_release(H5S_sel_iter_t *sel_iter); +/* Selection properties for "none" selections */ +const H5S_select_class_t H5S_sel_none[1] = {{ + H5S_SEL_NONE, + + /* Methods on selection */ + H5S_none_copy, + H5S_none_get_seq_list, + H5S_none_release, + H5S_none_is_valid, + H5S_none_serial_size, + H5S_none_serialize, + H5S_none_deserialize, + H5S_none_bounds, + H5S_none_is_contiguous, + H5S_none_is_single, + H5S_none_is_regular, + H5S_none_iter_init, +}}; + +/* Iteration properties for "none" selections */ +static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{ + H5S_SEL_NONE, + + /* Methods on selection iterator */ + H5S_none_iter_coords, + H5S_none_iter_block, + H5S_none_iter_nelmts, + H5S_none_iter_has_next_block, + H5S_none_iter_next, + H5S_none_iter_next_block, + H5S_none_iter_release, +}}; + /*------------------------------------------------------------------------- * Function: H5S_none_iter_init @@ -68,17 +119,11 @@ H5S_none_iter_init (H5S_sel_iter_t *iter, const H5S_t UNUSED *space) FUNC_ENTER_NOAPI(H5S_none_iter_init, FAIL); /* Check args */ - assert (space && H5S_SEL_NONE==space->select.type); + assert (space && H5S_SEL_NONE==H5S_GET_SELECT_TYPE(space)); assert (iter); - /* Initialize methods for selection iterator */ - iter->iter_coords=H5S_none_iter_coords; - iter->iter_block=H5S_none_iter_block; - iter->iter_nelmts=H5S_none_iter_nelmts; - iter->iter_has_next_block=H5S_none_iter_has_next_block; - iter->iter_next=H5S_none_iter_next; - iter->iter_next_block=H5S_none_iter_next_block; - iter->iter_release=H5S_none_iter_release; + /* Initialize type of selection iterator */ + iter->type=H5S_sel_iter_none; done: FUNC_LEAVE_NOAPI(ret_value); @@ -338,7 +383,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_none_copy (H5S_t *dst, const H5S_t *src) +H5S_none_copy(H5S_t *dst, const H5S_t *src, hbool_t UNUSED share_selection) { herr_t ret_value=SUCCEED; /* return value */ @@ -457,7 +502,7 @@ H5S_none_serialize (const H5S_t *space, uint8_t *buf) assert(space); /* Store the preamble information */ - UINT32ENCODE(buf, (uint32_t)space->select.type); /* Store the type of selection */ + UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(buf, (uint32_t)1); /* Store the version number */ UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */ UINT32ENCODE(buf, (uint32_t)0); /* Store the additional information length */ @@ -677,19 +722,7 @@ herr_t H5S_select_none (H5S_t *space) space->select.num_elem=0; /* Set selection type */ - space->select.type=H5S_SEL_NONE; - - /* Set selection methods */ - space->select.get_seq_list=H5S_none_get_seq_list; - space->select.release=H5S_none_release; - space->select.is_valid=H5S_none_is_valid; - space->select.serial_size=H5S_none_serial_size; - space->select.serialize=H5S_none_serialize; - space->select.bounds=H5S_none_bounds; - space->select.is_contiguous=H5S_none_is_contiguous; - space->select.is_single=H5S_none_is_single; - space->select.is_regular=H5S_none_is_regular; - space->select.iter_init=H5S_none_iter_init; + space->select.type=H5S_sel_none; done: FUNC_LEAVE_NOAPI(ret_value); diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 89243ff..2003b38 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -113,6 +113,8 @@ typedef struct { } H5S_hyper_sel_t; /* Selection information methods */ +/* Method to copy a selection */ +typedef herr_t (*H5S_sel_copy_func_t)(H5S_t *dst, const H5S_t *src, hbool_t share_selection); /* Method to retrieve a list of offset/length sequences for selection */ typedef herr_t (*H5S_sel_get_seq_list_func_t)(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, @@ -125,6 +127,8 @@ typedef htri_t (*H5S_sel_is_valid_func_t)(const H5S_t *space); typedef hssize_t (*H5S_sel_serial_size_func_t)(const H5S_t *space); /* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */ typedef herr_t (*H5S_sel_serialize_func_t)(const H5S_t *space, uint8_t *buf); +/* Method to store create selection from "serialized" form (a byte sequence suitable for storing on disk) */ +typedef herr_t (*H5S_sel_deserialize_func_t)(H5S_t *space, const uint8_t *buf); /* Method to determine to smallest n-D bounding box containing the current selection */ typedef herr_t (*H5S_sel_bounds_func_t)(const H5S_t *space, hssize_t *start, hssize_t *end); /* Method to determine if current selection is contiguous */ @@ -136,26 +140,34 @@ typedef htri_t (*H5S_sel_is_regular_func_t)(const H5S_t *space); /* 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); -/* Selection information object */ +/* Selection class information */ typedef struct { - H5S_sel_type type; /* Type of selection (list of points or hyperslabs) */ - hssize_t offset[H5S_MAX_RANK]; /* Offset within the extent */ - hsize_t *order; /* Selection order. (NULL means a specific ordering of points) */ - hsize_t num_elem; /* Number of elements in selection */ - union { - H5S_pnt_list_t *pnt_lst; /* List of selected points (order is important) */ - H5S_hyper_sel_t hslab; /* Info about new-style hyperslab selections */ - } sel_info; + H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ + + /* Methods */ + H5S_sel_copy_func_t copy; /* Method to make a copy of a selection */ H5S_sel_get_seq_list_func_t get_seq_list; /* Method to retrieve a list of offset/length sequences for selection */ H5S_sel_release_func_t release; /* Method to release current selection */ H5S_sel_is_valid_func_t is_valid; /* Method to determine if current selection is valid for dataspace */ H5S_sel_serial_size_func_t serial_size; /* Method to determine number of bytes required to store current selection */ H5S_sel_serialize_func_t serialize; /* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */ + H5S_sel_deserialize_func_t deserialize; /* Method to store create selection from "serialized" form (a byte sequence suitable for storing on disk) */ H5S_sel_bounds_func_t bounds; /* Method to determine to smallest n-D bounding box containing the current selection */ H5S_sel_is_contiguous_func_t is_contiguous; /* Method to determine if current selection is contiguous */ H5S_sel_is_single_func_t is_single; /* Method to determine if current selection is a single block */ H5S_sel_is_regular_func_t is_regular; /* Method to determine if current selection is "regular" */ H5S_sel_iter_init_func_t iter_init; /* Method to initialize iterator for current selection */ +} H5S_select_class_t; + +/* Selection information object */ +typedef struct { + const H5S_select_class_t *type; /* Pointer to selection's class info */ + hssize_t offset[H5S_MAX_RANK]; /* Offset within the extent */ + hsize_t num_elem; /* Number of elements in selection */ + union { + H5S_pnt_list_t *pnt_lst; /* List of selected points (order is important) */ + H5S_hyper_sel_t *hslab; /* Info about hyperslab selections */ + } sel_info; } H5S_select_t; /* Main dataspace structure (typedef'd in H5Sprivate.h) */ @@ -164,6 +176,56 @@ struct H5S_t { H5S_select_t select; /* Dataspace selection */ }; +/* Selection iteration methods */ +/* Method to retrieve the current coordinates of iterator for current selection */ +typedef herr_t (*H5S_sel_iter_coords_func_t)(const H5S_sel_iter_t *iter, hssize_t *coords); +/* Method to retrieve the current block of iterator for current selection */ +typedef herr_t (*H5S_sel_iter_block_func_t)(const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *end); +/* Method to determine number of elements left in iterator for current selection */ +typedef hsize_t (*H5S_sel_iter_nelmts_func_t)(const H5S_sel_iter_t *iter); +/* Method to determine if there are more blocks left in the current selection */ +typedef htri_t (*H5S_sel_iter_has_next_block_func_t)(const H5S_sel_iter_t *iter); +/* Method to move selection iterator to the next element in the selection */ +typedef herr_t (*H5S_sel_iter_next_func_t)(H5S_sel_iter_t *iter, size_t nelem); +/* Method to move selection iterator to the next block in the selection */ +typedef herr_t (*H5S_sel_iter_next_block_func_t)(H5S_sel_iter_t *iter); +/* Method to release iterator for current selection */ +typedef herr_t (*H5S_sel_iter_release_func_t)(H5S_sel_iter_t *iter); + +/* Selection iteration class */ +typedef struct H5S_sel_iter_class_t { + H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ + + /* Methods on selections */ + H5S_sel_iter_coords_func_t iter_coords; /* Method to retrieve the current coordinates of iterator for current selection */ + H5S_sel_iter_block_func_t iter_block; /* Method to retrieve the current block of iterator for current selection */ + H5S_sel_iter_nelmts_func_t iter_nelmts; /* Method to determine number of elements left in iterator for current selection */ + H5S_sel_iter_has_next_block_func_t iter_has_next_block; /* Method to query if there is another block left in the selection */ + H5S_sel_iter_next_func_t iter_next; /* Method to move selection iterator to the next element in the selection */ + H5S_sel_iter_next_block_func_t iter_next_block; /* Method to move selection iterator to the next block in the selection */ + H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */ +} H5S_sel_iter_class_t; + +/* + * All selection class methods. + */ +H5_DLLVAR const H5S_select_class_t H5S_sel_all[1]; + +/* + * Hyperslab selection class methods. + */ +H5_DLLVAR const H5S_select_class_t H5S_sel_hyper[1]; + +/* + * None selection class methods. + */ +H5_DLLVAR const H5S_select_class_t H5S_sel_none[1]; + +/* + * Pointer selection class methods. + */ +H5_DLLVAR const H5S_select_class_t H5S_sel_point[1]; + /* Extent functions */ H5_DLL herr_t H5S_close_simple(H5S_simple_t *simple); H5_DLL herr_t H5S_release_simple(H5S_simple_t *simple); @@ -171,78 +233,6 @@ H5_DLL herr_t H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src); /* Operations on selections */ -/* Point selection iterator functions */ -H5_DLL herr_t H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); - -/* Point selection functions */ -H5_DLL herr_t H5S_point_release(H5S_t *space); -H5_DLL herr_t H5S_point_copy(H5S_t *dst, const H5S_t *src); -H5_DLL htri_t H5S_point_is_valid(const H5S_t *space); -H5_DLL hssize_t H5S_point_serial_size(const H5S_t *space); -H5_DLL herr_t H5S_point_serialize(const H5S_t *space, uint8_t *buf); -H5_DLL herr_t H5S_point_deserialize(H5S_t *space, const uint8_t *buf); -H5_DLL herr_t H5S_point_bounds(const H5S_t *space, hssize_t *start, hssize_t *end); -H5_DLL htri_t H5S_point_is_contiguous(const H5S_t *space); -H5_DLL htri_t H5S_point_is_single(const H5S_t *space); -H5_DLL htri_t H5S_point_is_regular(const H5S_t *space); -H5_DLL herr_t H5S_point_get_seq_list(const H5S_t *space, unsigned flags, - H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, - size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); - -/* "All" selection iterator functions */ -H5_DLL herr_t H5S_all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); - -/* "All" selection functions */ -H5_DLL herr_t H5S_all_release(H5S_t *space); -H5_DLL herr_t H5S_all_copy(H5S_t *dst, const H5S_t *src); -H5_DLL htri_t H5S_all_is_valid(const H5S_t *space); -H5_DLL hssize_t H5S_all_serial_size(const H5S_t *space); -H5_DLL herr_t H5S_all_serialize(const H5S_t *space, uint8_t *buf); -H5_DLL herr_t H5S_all_deserialize(H5S_t *space, const uint8_t *buf); -H5_DLL herr_t H5S_all_bounds(const H5S_t *space, hssize_t *start, hssize_t *end); -H5_DLL htri_t H5S_all_is_contiguous(const H5S_t *space); -H5_DLL htri_t H5S_all_is_single(const H5S_t *space); -H5_DLL htri_t H5S_all_is_regular(const H5S_t *space); -H5_DLL herr_t H5S_all_get_seq_list(const H5S_t *space, unsigned flags, - H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, - size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); - -/* Hyperslab selection iterator functions */ -H5_DLL herr_t H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); - -/* Hyperslab selection functions */ -H5_DLL herr_t H5S_hyper_release(H5S_t *space); -H5_DLL herr_t H5S_hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); -H5_DLL htri_t H5S_hyper_is_valid(const H5S_t *space); -H5_DLL hssize_t H5S_hyper_serial_size(const H5S_t *space); -H5_DLL herr_t H5S_hyper_serialize(const H5S_t *space, uint8_t *buf); -H5_DLL herr_t H5S_hyper_deserialize(H5S_t *space, const uint8_t *buf); -H5_DLL herr_t H5S_hyper_bounds(const H5S_t *space, hssize_t *start, hssize_t *end); -H5_DLL htri_t H5S_hyper_is_contiguous(const H5S_t *space); -H5_DLL htri_t H5S_hyper_is_single(const H5S_t *space); -H5_DLL htri_t H5S_hyper_is_regular(const H5S_t *space); -H5_DLL herr_t H5S_hyper_get_seq_list(const H5S_t *space, unsigned flags, - H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, - size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); - -/* "None" selection iterator functions */ -H5_DLL herr_t H5S_none_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); - -/* "None" selection functions */ -H5_DLL herr_t H5S_none_release(H5S_t *space); -H5_DLL herr_t H5S_none_copy(H5S_t *dst, const H5S_t *src); -H5_DLL htri_t H5S_none_is_valid(const H5S_t *space); -H5_DLL hssize_t H5S_none_serial_size(const H5S_t *space); -H5_DLL herr_t H5S_none_serialize(const H5S_t *space, uint8_t *buf); -H5_DLL herr_t H5S_none_deserialize(H5S_t *space, const uint8_t *buf); -H5_DLL herr_t H5S_none_bounds(const H5S_t *space, hssize_t *start, hssize_t *end); -H5_DLL htri_t H5S_none_is_contiguous(const H5S_t *space); -H5_DLL htri_t H5S_none_is_single(const H5S_t *space); -H5_DLL htri_t H5S_none_is_regular(const H5S_t *space); -H5_DLL herr_t H5S_none_get_seq_list(const H5S_t *space, unsigned flags, - H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, - size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); - #ifdef H5_HAVE_PARALLEL /* MPI-IO function to read directly from app buffer to file rky980813 */ H5_DLL herr_t H5S_mpio_spaces_read(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, diff --git a/src/H5Spoint.c b/src/H5Spoint.c index d2b2562..9d0e0e2 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -38,6 +38,24 @@ static int interface_initialize_g = 0; /* Static function prototypes */ + +/* Selection callbacks */ +static herr_t H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +static herr_t H5S_point_get_seq_list(const H5S_t *space, unsigned flags, + 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_point_release(H5S_t *space); +static htri_t H5S_point_is_valid(const H5S_t *space); +static hssize_t H5S_point_serial_size(const H5S_t *space); +static herr_t H5S_point_serialize(const H5S_t *space, uint8_t *buf); +static herr_t H5S_point_deserialize(H5S_t *space, const uint8_t *buf); +static herr_t H5S_point_bounds(const H5S_t *space, hssize_t *start, hssize_t *end); +static htri_t H5S_point_is_contiguous(const H5S_t *space); +static htri_t H5S_point_is_single(const H5S_t *space); +static htri_t H5S_point_is_regular(const H5S_t *space); +static herr_t H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space); + +/* Selection iteration callbacks */ static herr_t H5S_point_iter_coords(const H5S_sel_iter_t *iter, hssize_t *coords); static herr_t H5S_point_iter_block(const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *end); static hsize_t H5S_point_iter_nelmts(const H5S_sel_iter_t *iter); @@ -46,6 +64,39 @@ static herr_t H5S_point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); static herr_t H5S_point_iter_next_block(H5S_sel_iter_t *sel_iter); static herr_t H5S_point_iter_release(H5S_sel_iter_t *sel_iter); +/* Selection properties for point selections */ +const H5S_select_class_t H5S_sel_point[1] = {{ + H5S_SEL_POINTS, + + /* Methods on selection */ + H5S_point_copy, + H5S_point_get_seq_list, + H5S_point_release, + H5S_point_is_valid, + H5S_point_serial_size, + H5S_point_serialize, + H5S_point_deserialize, + H5S_point_bounds, + H5S_point_is_contiguous, + H5S_point_is_single, + H5S_point_is_regular, + H5S_point_iter_init, +}}; + +/* Iteration properties for point selections */ +static const H5S_sel_iter_class_t H5S_sel_iter_point[1] = {{ + H5S_SEL_POINTS, + + /* Methods on selection iterator */ + H5S_point_iter_coords, + H5S_point_iter_block, + H5S_point_iter_nelmts, + H5S_point_iter_has_next_block, + H5S_point_iter_next, + H5S_point_iter_next_block, + H5S_point_iter_release, +}}; + /* Declare a free list to manage the H5S_pnt_node_t struct */ H5FL_DEFINE_STATIC(H5S_pnt_node_t); @@ -75,7 +126,7 @@ H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) FUNC_ENTER_NOAPI(H5S_point_iter_init, FAIL); /* Check args */ - assert (space && H5S_SEL_POINTS==space->select.type); + assert (space && H5S_SEL_POINTS==H5S_GET_SELECT_TYPE(space)); assert (iter); /* Initialize the number of points to iterate over */ @@ -84,14 +135,8 @@ H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) /* Start at the head of the list of points */ iter->u.pnt.curr=space->select.sel_info.pnt_lst->head; - /* Initialize methods for selection iterator */ - iter->iter_coords=H5S_point_iter_coords; - iter->iter_block=H5S_point_iter_block; - iter->iter_nelmts=H5S_point_iter_nelmts; - iter->iter_has_next_block=H5S_point_iter_has_next_block; - iter->iter_next=H5S_point_iter_next; - iter->iter_next_block=H5S_point_iter_next_block; - iter->iter_release=H5S_point_iter_release; + /* Initialize type of selection iterator */ + iter->type=H5S_sel_iter_point; done: FUNC_LEAVE_NOAPI(ret_value); @@ -504,13 +549,13 @@ H5S_select_elements (H5S_t *space, H5S_seloper_t op, size_t num_elem, assert(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND); /* If we are setting a new selection, remove current selection first */ - if(op==H5S_SELECT_SET || space->select.type!=H5S_SEL_POINTS) { + if(op==H5S_SELECT_SET || H5S_GET_SELECT_TYPE(space)!=H5S_SEL_POINTS) { if(H5S_SELECT_RELEASE(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release point selection"); } /* end if */ /* Allocate space for the point selection information if necessary */ - if(space->select.type!=H5S_SEL_POINTS || space->select.sel_info.pnt_lst==NULL) { + if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_POINTS || space->select.sel_info.pnt_lst==NULL) { if((space->select.sel_info.pnt_lst = H5FL_CALLOC(H5S_pnt_list_t))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate element information"); } /* end if */ @@ -520,19 +565,7 @@ H5S_select_elements (H5S_t *space, H5S_seloper_t op, size_t num_elem, HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert elements"); /* Set selection type */ - space->select.type=H5S_SEL_POINTS; - - /* Set selection methods */ - space->select.get_seq_list=H5S_point_get_seq_list; - space->select.release=H5S_point_release; - space->select.is_valid=H5S_point_is_valid; - space->select.serial_size=H5S_point_serial_size; - space->select.serialize=H5S_point_serialize; - space->select.bounds=H5S_point_bounds; - space->select.is_contiguous=H5S_point_is_contiguous; - space->select.is_single=H5S_point_is_single; - space->select.is_regular=H5S_point_is_regular; - space->select.iter_init=H5S_point_iter_init; + space->select.type=H5S_sel_point; done: FUNC_LEAVE_NOAPI(ret_value); @@ -559,7 +592,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_point_copy (H5S_t *dst, const H5S_t *src) +H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t UNUSED share_selection) { H5S_pnt_node_t *curr, *new_node, *new_head; /* Point information nodes */ herr_t ret_value=SUCCEED; /* return value */ @@ -682,7 +715,7 @@ H5Sget_select_elem_npoints(hid_t spaceid) /* Check args */ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - if(space->select.type!=H5S_SEL_POINTS) + if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_POINTS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an element selection"); ret_value = H5S_GET_SELECT_NPOINTS(space); @@ -773,7 +806,7 @@ H5S_point_serialize (const H5S_t *space, uint8_t *buf) assert(space); /* Store the preamble information */ - UINT32ENCODE(buf, (uint32_t)space->select.type); /* Store the type of selection */ + UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(buf, (uint32_t)1); /* Store the version number */ UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */ lenp=buf; /* keep the pointer to the length location for later */ @@ -979,7 +1012,7 @@ H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, hsize_t numpoint HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer"); if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - if(space->select.type!=H5S_SEL_POINTS) + if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_POINTS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a point selection"); ret_value = H5S_get_select_elem_pointlist(space,startpoint,numpoints,buf); @@ -1219,7 +1252,7 @@ H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem, /* Check args */ if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace"); - if (H5S_SCALAR==H5S_GET_SIMPLE_EXTENT_TYPE(space)) + if (H5S_SCALAR==H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "point doesn't support H5S_SCALAR space"); if(coord==NULL || num_elem==0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified"); diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 11fd2f6..9e6d4b4 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -84,25 +84,14 @@ typedef struct { hsize_t byte_offset; /* Next byte to output */ } H5S_all_iter_t; -typedef struct H5S_sel_iter_t H5S_sel_iter_t; - -/* Method to retrieve the current coordinates of iterator for current selection */ -typedef herr_t (*H5S_sel_iter_coords_func_t)(const H5S_sel_iter_t *iter, hssize_t *coords); -/* Method to retrieve the current block of iterator for current selection */ -typedef herr_t (*H5S_sel_iter_block_func_t)(const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *end); -/* Method to determine number of elements left in iterator for current selection */ -typedef hsize_t (*H5S_sel_iter_nelmts_func_t)(const H5S_sel_iter_t *iter); -/* Method to determine if there are more blocks left in the current selection */ -typedef htri_t (*H5S_sel_iter_has_next_block_func_t)(const H5S_sel_iter_t *iter); -/* Method to move selection iterator to the next element in the selection */ -typedef herr_t (*H5S_sel_iter_next_func_t)(H5S_sel_iter_t *iter, size_t nelem); -/* Method to move selection iterator to the next block in the selection */ -typedef herr_t (*H5S_sel_iter_next_block_func_t)(H5S_sel_iter_t *iter); -/* Method to release iterator for current selection */ -typedef herr_t (*H5S_sel_iter_release_func_t)(H5S_sel_iter_t *iter); +/* Forward declaration of selection iteration class */ +struct H5S_sel_iter_class_t; /* Selection iteration container */ -struct H5S_sel_iter_t { +typedef struct H5S_sel_iter_t { + /* Selection class */ + const struct H5S_sel_iter_class_t *type; /* Selection iteration class info */ + /* Information common to all iterators */ unsigned rank; /* Rank of dataspace the selection iterator is operating on */ hsize_t *dims; /* Dimensions of dataspace the selection is operating on */ @@ -115,16 +104,7 @@ struct H5S_sel_iter_t { H5S_hyper_iter_t hyp; /* New Hyperslab selection iteration information */ H5S_all_iter_t all; /* "All" selection iteration information */ } u; - - /* Methods on selections */ - H5S_sel_iter_coords_func_t iter_coords; /* Method to retrieve the current coordinates of iterator for current selection */ - H5S_sel_iter_block_func_t iter_block; /* Method to retrieve the current block of iterator for current selection */ - H5S_sel_iter_nelmts_func_t iter_nelmts; /* Method to determine number of elements left in iterator for current selection */ - H5S_sel_iter_has_next_block_func_t iter_has_next_block; /* Method to query if there is another block left in the selection */ - H5S_sel_iter_next_func_t iter_next; /* Method to move selection iterator to the next element in the selection */ - H5S_sel_iter_next_block_func_t iter_next_block; /* Method to move selection iterator to the next block in the selection */ - H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */ -}; +} H5S_sel_iter_t; typedef struct H5S_conv_t { H5S_sel_type ftype; @@ -174,31 +154,31 @@ typedef struct H5S_conv_t { /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5S_PACKAGE -#define H5S_GET_SIMPLE_EXTENT_TYPE(S) ((S)->extent.type) -#define H5S_GET_SIMPLE_EXTENT_NDIMS(S) ((S)->extent.u.simple.rank) -#define H5S_GET_SIMPLE_EXTENT_NPOINTS(S) ((S)->extent.nelem) +#define H5S_GET_EXTENT_TYPE(S) ((S)->extent.type) +#define H5S_GET_EXTENT_NDIMS(S) ((S)->extent.u.simple.rank) +#define H5S_GET_EXTENT_NPOINTS(S) ((S)->extent.nelem) #define H5S_GET_SELECT_NPOINTS(S) ((S)->select.num_elem) -#define H5S_GET_SELECT_TYPE(S) ((S)->select.type) -#define H5S_SELECT_GET_SEQ_LIST(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) ((*(S)->select.get_seq_list)(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN)) -#define H5S_SELECT_VALID(S) ((*(S)->select.is_valid)(S)) -#define H5S_SELECT_RELEASE(S) ((*(S)->select.release)(S)) -#define H5S_SELECT_SERIAL_SIZE(S) ((*(S)->select.serial_size)(S)) -#define H5S_SELECT_SERIALIZE(S,BUF) ((*(S)->select.serialize)(S,BUF)) -#define H5S_SELECT_BOUNDS(S,START,END) ((*(S)->select.bounds)(S,START,END)) -#define H5S_SELECT_IS_CONTIGUOUS(S) ((*(S)->select.is_contiguous)(S)) -#define H5S_SELECT_IS_SINGLE(S) ((*(S)->select.is_single)(S)) -#define H5S_SELECT_IS_REGULAR(S) ((*(S)->select.is_regular)(S)) -#define H5S_SELECT_ITER_COORDS(ITER,COORDS) ((*(ITER)->iter_coords)(ITER,COORDS)) -#define H5S_SELECT_ITER_BLOCK(ITER,START,END) ((*(ITER)->iter_block)(ITER,START,END)) -#define H5S_SELECT_ITER_NELMTS(ITER) ((*(ITER)->iter_nelmts)(ITER)) -#define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) ((*(ITER)->iter_has_next_block)(ITER)) -#define H5S_SELECT_ITER_NEXT(ITER,NELEM)((*(ITER)->iter_next)(ITER,NELEM)) -#define H5S_SELECT_ITER_NEXT_BLOCK(ITER) ((*(ITER)->iter_next_block)(ITER)) -#define H5S_SELECT_ITER_RELEASE(ITER) ((*(ITER)->iter_release)(ITER)) +#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)) +#define H5S_SELECT_IS_CONTIGUOUS(S) ((*(S)->select.type->is_contiguous)(S)) +#define H5S_SELECT_IS_SINGLE(S) ((*(S)->select.type->is_single)(S)) +#define H5S_SELECT_IS_REGULAR(S) ((*(S)->select.type->is_regular)(S)) +#define H5S_SELECT_ITER_COORDS(ITER,COORDS) ((*(ITER)->type->iter_coords)(ITER,COORDS)) +#define H5S_SELECT_ITER_BLOCK(ITER,START,END) ((*(ITER)->type->iter_block)(ITER,START,END)) +#define H5S_SELECT_ITER_NELMTS(ITER) ((*(ITER)->type->iter_nelmts)(ITER)) +#define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_has_next_block)(ITER)) +#define H5S_SELECT_ITER_NEXT(ITER,NELEM)((*(ITER)->type->iter_next)(ITER,NELEM)) +#define H5S_SELECT_ITER_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_next_block)(ITER)) +#define H5S_SELECT_ITER_RELEASE(ITER) ((*(ITER)->type->iter_release)(ITER)) #else /* H5S_PACKAGE */ -#define H5S_GET_SIMPLE_EXTENT_TYPE(S) (H5S_get_simple_extent_type(S)) -#define H5S_GET_SIMPLE_EXTENT_NDIMS(S) (H5S_get_simple_extent_ndims(S)) -#define H5S_GET_SIMPLE_EXTENT_NPOINTS(S) (H5S_get_simple_extent_npoints(S)) +#define H5S_GET_EXTENT_TYPE(S) (H5S_get_simple_extent_type(S)) +#define H5S_GET_EXTENT_NDIMS(S) (H5S_get_simple_extent_ndims(S)) +#define H5S_GET_EXTENT_NPOINTS(S) (H5S_get_simple_extent_npoints(S)) #define H5S_GET_SELECT_NPOINTS(S) (H5S_get_select_npoints(S)) #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)) @@ -218,6 +198,9 @@ typedef struct H5S_conv_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_PACKAGE */ +/* Handle these two 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_DESERIALIZE(S,BUF) (H5S_select_deserialize(S,BUF)) /* Operations on dataspaces */ diff --git a/src/H5Sselect.c b/src/H5Sselect.c index f2a4cb9..824d79a 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -120,7 +120,7 @@ done: herr_t H5S_select_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) { - herr_t ret_value=SUCCEED; /* return value */ + herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI(H5S_select_copy, FAIL); @@ -129,49 +129,11 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) assert(src); /* Copy regular fields */ - HDmemcpy(&dst->select,&src->select,sizeof(H5S_select_t)); - -/* Need to copy permutation order information still */ + dst->select=src->select; /* Perform correct type of copy based on the type of selection */ - switch (src->extent.type) { - case H5S_SCALAR: - /*nothing needed */ - break; - - case H5S_SIMPLE: - /* Deep copy extra stuff */ - switch(src->select.type) { - case H5S_SEL_NONE: - ret_value=H5S_none_copy(dst,src); - break; - - case H5S_SEL_ALL: - ret_value=H5S_all_copy(dst,src); - break; - - case H5S_SEL_POINTS: - ret_value=H5S_point_copy(dst,src); - break; - - case H5S_SEL_HYPERSLABS: - ret_value=H5S_hyper_copy(dst,src,share_selection); - break; - - default: - assert("unknown selection type" && 0); - break; - } /* end switch */ - break; - - case H5S_COMPLEX: - /*void */ - break; - - default: - assert("unknown dataspace type" && 0); - break; - } /* end switch */ + if((ret_value=(*src->select.type->copy)(dst,src,share_selection))<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy selection specific information"); done: FUNC_LEAVE_NOAPI(ret_value); @@ -199,14 +161,14 @@ done: herr_t H5S_select_release(H5S_t *ds) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5S_select_release, FAIL); assert(ds); /* Call the selection type's release function */ - (*ds->select.release)(ds); + ret_value=(*ds->select.type->release)(ds); done: FUNC_LEAVE_NOAPI(ret_value); @@ -237,14 +199,14 @@ H5S_select_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5S_select_get_seq_list, FAIL); assert(space); /* Call the selection type's get_seq_list function */ - (*space->select.get_seq_list)(space,flags,iter,maxseq,maxbytes,nseq,nbytes,off,len); + ret_value=(*space->select.type->get_seq_list)(space,flags,iter,maxseq,maxbytes,nseq,nbytes,off,len); done: FUNC_LEAVE_NOAPI(ret_value); @@ -280,7 +242,7 @@ H5S_select_serial_size(const H5S_t *space) assert(space); /* Call the selection type's serial_size function */ - ret_value=(*space->select.serial_size)(space); + ret_value=(*space->select.type->serial_size)(space); done: FUNC_LEAVE_NOAPI(ret_value); @@ -320,7 +282,7 @@ H5S_select_serialize(const H5S_t *space, uint8_t *buf) assert(buf); /* Call the selection type's serialize function */ - ret_value=(*space->select.serialize)(space,buf); + ret_value=(*space->select.type->serialize)(space,buf); done: FUNC_LEAVE_NOAPI(ret_value); @@ -474,7 +436,7 @@ H5S_select_valid(const H5S_t *space) assert(space); - ret_value = (*space->select.is_valid)(space); + ret_value = (*space->select.type->is_valid)(space); done: FUNC_LEAVE_NOAPI(ret_value); @@ -518,24 +480,26 @@ H5S_select_deserialize (H5S_t *space, const uint8_t *buf) UINT32DECODE(tbuf, sel_type); switch(sel_type) { case H5S_SEL_POINTS: /* Sequence of points selected */ - ret_value=H5S_point_deserialize(space,buf); + ret_value=(*H5S_sel_point->deserialize)(space,buf); break; case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ - ret_value=H5S_hyper_deserialize(space,buf); + ret_value=(*H5S_sel_hyper->deserialize)(space,buf); break; case H5S_SEL_ALL: /* Entire extent selected */ - ret_value=H5S_all_deserialize(space,buf); + ret_value=(*H5S_sel_all->deserialize)(space,buf); break; case H5S_SEL_NONE: /* Nothing selected */ - ret_value=H5S_none_deserialize(space,buf); + ret_value=(*H5S_sel_none->deserialize)(space,buf); break; default: break; } + if(ret_value<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "can't deserialize selection"); done: FUNC_LEAVE_NOAPI(ret_value); @@ -667,7 +631,7 @@ H5S_get_select_bounds(const H5S_t *space, hssize_t *start, hssize_t *end) assert(start); assert(end); - ret_value = (*space->select.bounds)(space,start,end); + ret_value = (*space->select.type->bounds)(space,start,end); done: FUNC_LEAVE_NOAPI(ret_value); @@ -705,7 +669,7 @@ H5S_select_is_contiguous(const H5S_t *space) /* Check args */ assert(space); - ret_value = (*space->select.is_contiguous)(space); + ret_value = (*space->select.type->is_contiguous)(space); done: FUNC_LEAVE_NOAPI(ret_value); @@ -743,7 +707,7 @@ H5S_select_is_single(const H5S_t *space) /* Check args */ assert(space); - ret_value = (*space->select.is_single)(space); + ret_value = (*space->select.type->is_single)(space); done: FUNC_LEAVE_NOAPI(ret_value); @@ -781,7 +745,7 @@ H5S_select_is_regular(const H5S_t *space) /* Check args */ assert(space); - ret_value = (*space->select.is_regular)(space); + ret_value = (*space->select.type->is_regular)(space); done: FUNC_LEAVE_NOAPI(ret_value); @@ -808,7 +772,7 @@ done: herr_t H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_size) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5S_select_iter_init, FAIL); @@ -832,7 +796,7 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_s sel_iter->elmt_size=elmt_size; /* Call initialization routine for selection type */ - ret_value= (*space->select.iter_init)(sel_iter, space); + ret_value= (*space->select.type->iter_init)(sel_iter, space); done: FUNC_LEAVE_NOAPI(ret_value); @@ -873,7 +837,7 @@ H5S_select_iter_coords (const H5S_sel_iter_t *sel_iter, hssize_t *coords) assert(coords); /* Call iter_coords routine for selection type */ - ret_value = (*sel_iter->iter_coords)(sel_iter,coords); + ret_value = (*sel_iter->type->iter_coords)(sel_iter,coords); done: FUNC_LEAVE_NOAPI(ret_value); @@ -916,7 +880,7 @@ H5S_select_iter_block (const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *en assert(end); /* Call iter_block routine for selection type */ - ret_value = (*iter->iter_block)(iter,start,end); + ret_value = (*iter->type->iter_block)(iter,start,end); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_iter_block() */ @@ -953,7 +917,7 @@ H5S_select_iter_nelmts (const H5S_sel_iter_t *sel_iter) assert(sel_iter); /* Call iter_nelmts routine for selection type */ - ret_value = (*sel_iter->iter_nelmts)(sel_iter); + ret_value = (*sel_iter->type->iter_nelmts)(sel_iter); done: FUNC_LEAVE_NOAPI(ret_value); @@ -992,7 +956,7 @@ H5S_select_iter_has_next_block (const H5S_sel_iter_t *iter) assert(iter); /* Call iter_has_next_block routine for selection type */ - ret_value = (*iter->iter_has_next_block)(iter); + ret_value = (*iter->type->iter_has_next_block)(iter); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_iter_has_next_block() */ @@ -1032,7 +996,7 @@ H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem) assert(nelem>0); /* Call iter_next routine for selection type */ - ret_value = (*iter->iter_next)(iter,nelem); + ret_value = (*iter->type->iter_next)(iter,nelem); /* Decrement the number of elements left in selection */ iter->elmt_left-=nelem; @@ -1076,7 +1040,7 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter) assert(iter); /* Call iter_next_block routine for selection type */ - ret_value = (*iter->iter_next_block)(iter); + ret_value = (*iter->type->iter_next_block)(iter); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_iter_next_block() */ @@ -1113,7 +1077,7 @@ H5S_select_iter_release(H5S_sel_iter_t *sel_iter) assert(sel_iter); /* Call selection type-specific release routine */ - ret_value = (*sel_iter->iter_release)(sel_iter); + ret_value = (*sel_iter->type->iter_release)(sel_iter); done: FUNC_LEAVE_NOAPI(ret_value); @@ -1330,7 +1294,7 @@ H5S_get_select_type(const H5S_t *space) assert(space); /* Set return value */ - ret_value=space->select.type; + ret_value=H5S_GET_SELECT_TYPE(space); done: FUNC_LEAVE_NOAPI(ret_value); @@ -1386,7 +1350,7 @@ HDfprintf(stderr,"%s: Entering\n",FUNC); HGOTO_DONE(FALSE); /* Check for "easy" cases before getting into generalized block iteration code */ - if(space1->select.type==H5S_SEL_ALL && space2->select.type==H5S_SEL_ALL) { + if(H5S_GET_SELECT_TYPE(space1)==H5S_SEL_ALL && H5S_GET_SELECT_TYPE(space2)==H5S_SEL_ALL) { hsize_t dims1[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #1 */ hsize_t dims2[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace #2 */ @@ -1400,19 +1364,19 @@ HDfprintf(stderr,"%s: Entering\n",FUNC); if(dims1[u]!=dims2[u]) HGOTO_DONE(FALSE); } /* end if */ - else if(space1->select.type==H5S_SEL_NONE || space2->select.type==H5S_SEL_NONE) { + else if(H5S_GET_SELECT_TYPE(space1)==H5S_SEL_NONE || H5S_GET_SELECT_TYPE(space2)==H5S_SEL_NONE) { HGOTO_DONE(TRUE); } /* end if */ - else if((space1->select.type==H5S_SEL_HYPERSLABS && space1->select.sel_info.hslab.diminfo_valid) - && (space2->select.type==H5S_SEL_HYPERSLABS && space2->select.sel_info.hslab.diminfo_valid)) { + else if((H5S_GET_SELECT_TYPE(space1)==H5S_SEL_HYPERSLABS && space1->select.sel_info.hslab->diminfo_valid) + && (H5S_GET_SELECT_TYPE(space2)==H5S_SEL_HYPERSLABS && space2->select.sel_info.hslab->diminfo_valid)) { /* Check that the shapes are the same */ for (u=0; u<space1->extent.u.simple.rank; u++) { - if(space1->select.sel_info.hslab.opt_diminfo[u].stride!=space2->select.sel_info.hslab.opt_diminfo[u].stride) + if(space1->select.sel_info.hslab->opt_diminfo[u].stride!=space2->select.sel_info.hslab->opt_diminfo[u].stride) HGOTO_DONE(FALSE); - if(space1->select.sel_info.hslab.opt_diminfo[u].count!=space2->select.sel_info.hslab.opt_diminfo[u].count) + if(space1->select.sel_info.hslab->opt_diminfo[u].count!=space2->select.sel_info.hslab->opt_diminfo[u].count) HGOTO_DONE(FALSE); - if(space1->select.sel_info.hslab.opt_diminfo[u].block!=space2->select.sel_info.hslab.opt_diminfo[u].block) + if(space1->select.sel_info.hslab->opt_diminfo[u].block!=space2->select.sel_info.hslab->opt_diminfo[u].block) HGOTO_DONE(FALSE); } /* end for */ } /* end if */ @@ -1428,7 +1392,7 @@ HDfprintf(stderr,"%s: Entering\n",FUNC); unsigned first_block=1; /* Flag to indicate the first block */ #ifdef QAK HDfprintf(stderr,"%s: Check 10.0\n",FUNC); -HDfprintf(stderr,"%s: space1 selection type=%d\n",FUNC,(int)space1->select.type); +HDfprintf(stderr,"%s: space1 selection type=%d\n",FUNC,(int)H5S_GET_SELECT_TYPE(space1)); if(space1->select.sel_info.hslab.span_lst) { HDfprintf(stderr,"%s: Dumping space1 span list\n",FUNC); H5S_hyper_print_spans(stderr,space1->select.sel_info.hslab.span_lst); @@ -1437,7 +1401,7 @@ else { HDfprintf(stderr,"%s: Dumping space1 diminfo\n",FUNC); H5S_hyper_print_diminfo(stderr,space1); } /* end else */ -HDfprintf(stderr,"%s: space2 selection type=%d\n",FUNC,(int)space2->select.type); +HDfprintf(stderr,"%s: space2 selection type=%d\n",FUNC,(int)H5S_GET_SELECT_TYPE(space2)); if(space2->select.sel_info.hslab.span_lst) { HDfprintf(stderr,"%s: Dumping space2 span list\n",FUNC); H5S_hyper_print_spans(stderr,space2->select.sel_info.hslab.span_lst); |