diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5.c | 4 | ||||
-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 | 7 | ||||
-rw-r--r-- | src/H5Oattr.c | 2 | ||||
-rw-r--r-- | src/H5S.c | 58 | ||||
-rw-r--r-- | src/H5Sall.c | 87 | ||||
-rw-r--r-- | src/H5Shyper.c | 449 | ||||
-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 | 93 | ||||
-rw-r--r-- | src/H5Sprivate.h | 83 | ||||
-rw-r--r-- | src/H5Spublic.h | 1 | ||||
-rw-r--r-- | src/H5Sselect.c | 121 |
16 files changed, 626 insertions, 546 deletions
@@ -2197,8 +2197,8 @@ H5_trace (const 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)) { - asize[argno] = H5S_GET_SIMPLE_EXTENT_NDIMS(space); + if (H5S_SIMPLE==H5S_GET_EXTENT_TYPE(space)) { + asize[argno] = H5S_GET_EXTENT_NDIMS(space); } } break; @@ -269,7 +269,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)); 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) @@ -629,7 +629,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; @@ -778,7 +778,7 @@ H5A_read(const 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; @@ -1442,7 +1442,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 */ @@ -2194,7 +2194,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 */ @@ -2205,7 +2205,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)); @@ -2257,7 +2257,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); @@ -2542,7 +2542,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 */ @@ -2986,7 +2986,7 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo * We assume that external storage is already * allocated by the caller, or at least will be before I/O is performed. */ - if(!(H5S_NULL == H5S_GET_SIMPLE_EXTENT_TYPE(dset->space) || dset->efl.nused>0)) { + if(!(H5S_NULL == H5S_GET_EXTENT_TYPE(dset->space) || dset->efl.nused>0)) { /* Get a pointer to the dataset's layout information */ layout=&(dset->layout); @@ -3135,7 +3135,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 3e0c163..ac93b26 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -161,7 +161,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 0ab50c2..a7686ed 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -920,7 +920,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 */ @@ -1085,7 +1085,7 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, assert(((dataset->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->layout.u.contig.addr)) || (dataset->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->layout.u.chunk.addr))) || dataset->efl.nused>0 || - H5S_NULL == H5S_GET_SIMPLE_EXTENT_TYPE(file_space) || + H5S_NULL == H5S_GET_EXTENT_TYPE(file_space) || dataset->layout.type==H5D_COMPACT); H5_CHECK_OVERFLOW(nelmts,hsize_t,size_t); status = (sconv->read)(dataset->ent.file, dxpl_cache, dxpl_id, @@ -2341,7 +2341,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 */ @@ -3213,4 +3213,3 @@ H5D_chunk_mem_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize_ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_mem_cb() */ - diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 4cd3a62..f454b74 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -200,7 +200,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(attr->data_size) { @@ -809,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); @@ -848,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_NULL: ret_value = 0; break; @@ -856,7 +856,7 @@ H5S_get_npoints_max(const H5S_t *ds) case H5S_SCALAR: ret_value = 1; break; - + case H5S_SIMPLE: if (ds->extent.u.simple.max) { for (ret_value=1, u=0; u<ds->extent.u.simple.rank; u++) { @@ -916,7 +916,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); @@ -954,7 +954,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_NULL: case H5S_SCALAR: case H5S_SIMPLE: @@ -1045,7 +1045,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_NULL: case H5S_SCALAR: ret_value = 0; @@ -1103,7 +1103,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_NULL: case H5S_SCALAR: case H5S_SIMPLE: @@ -1150,7 +1150,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_NULL: case H5S_SCALAR: case H5S_SIMPLE: @@ -1247,8 +1247,8 @@ H5S_is_simple(const H5S_t *sdim) /* Check args and all the boring stuff. */ assert(sdim); /* H5S_NULL shouldn't be simple dataspace */ - 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); @@ -1485,20 +1485,20 @@ UNUSED FUNC_ENTER_NOAPI(H5S_find, NULL); /* Check args */ - assert (mem_space && (H5S_SIMPLE==mem_space->extent.type || - H5S_NULL==mem_space->extent.type || - H5S_SCALAR==mem_space->extent.type)); - assert (file_space && (H5S_SIMPLE==file_space->extent.type || - H5S_NULL==file_space->extent.type || - H5S_SCALAR==file_space->extent.type)); + assert (mem_space && (H5S_SIMPLE==H5S_GET_EXTENT_TYPE(mem_space) || + H5S_NULL==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_NULL==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 /* @@ -1539,8 +1539,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 /* @@ -1622,7 +1622,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 */ @@ -1807,7 +1807,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); @@ -1845,7 +1845,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); @@ -1918,8 +1918,8 @@ 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 - || space->extent.type==H5S_NULL)) + if (space->extent.u.simple.rank==0 || (H5S_GET_EXTENT_TYPE(space)==H5S_SCALAR + || H5S_GET_EXTENT_TYPE(space)==H5S_NULL)) HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace"); if (offset == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified"); @@ -1957,7 +1957,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 */ @@ -2003,7 +2003,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 */ @@ -2045,7 +2045,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_NULL: fprintf(stream, "%*s%-*s H5S_NULL\n", indent, "", fwidth, "Space class:"); @@ -2065,7 +2065,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 c259316..a3e6f35 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -51,6 +51,24 @@ static herr_t H5S_hyper_generate_spans(H5S_t *space); #ifdef NEW_HYPERSLAB_API static herr_t H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2); #endif /*NEW_HYPERSLAB_API*/ + +/* 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); @@ -59,6 +77,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, @@ -71,6 +122,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); @@ -114,7 +168,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); } @@ -151,8 +205,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); } @@ -191,7 +245,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 */ @@ -202,10 +256,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 */ @@ -314,9 +368,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); @@ -343,14 +397,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); @@ -1545,17 +1593,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: @@ -1660,8 +1714,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 */ @@ -1685,7 +1739,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: @@ -1769,13 +1823,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() */ @@ -1810,7 +1864,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); @@ -1857,15 +1911,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 */ @@ -1995,7 +2049,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 */ @@ -2006,11 +2060,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++) @@ -2092,7 +2146,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; @@ -2102,7 +2156,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 */ @@ -2349,7 +2403,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; @@ -2360,13 +2414,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++) { @@ -2442,7 +2496,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() */ @@ -2492,7 +2546,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 */ @@ -2620,8 +2674,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++) { @@ -2634,7 +2688,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: @@ -2675,8 +2729,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 @@ -2739,7 +2793,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 */ @@ -2785,7 +2839,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 */ @@ -2858,7 +2912,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) @@ -2869,7 +2923,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 */ @@ -2883,7 +2937,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) { @@ -2937,7 +2991,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; @@ -2977,21 +3031,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() */ @@ -3333,7 +3387,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 */ @@ -3350,32 +3404,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 */ @@ -3415,9 +3461,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: @@ -3455,7 +3501,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 */ { @@ -3594,8 +3640,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 */ @@ -3603,7 +3649,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: @@ -3716,16 +3762,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: @@ -3825,20 +3871,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 */ @@ -3940,20 +3986,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 */ @@ -3993,7 +4039,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]; @@ -4961,26 +5007,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); @@ -5179,12 +5225,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); @@ -5232,17 +5278,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); @@ -5264,7 +5310,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); @@ -5302,14 +5348,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 */ @@ -5381,7 +5427,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) { @@ -5400,9 +5446,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; @@ -5424,9 +5470,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; @@ -5454,9 +5500,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; @@ -5478,9 +5524,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; @@ -5513,7 +5559,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 */ @@ -5533,7 +5579,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 @@ -5633,7 +5679,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 */ @@ -5721,38 +5767,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) @@ -5762,19 +5812,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); @@ -5821,9 +5859,9 @@ 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 (H5S_NULL==H5S_GET_SIMPLE_EXTENT_TYPE(space)) + if (H5S_NULL==H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_NULL space"); if(start==NULL || count==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified"); @@ -6009,7 +6047,7 @@ H5S_operate_hyperslab (H5S_t *result, H5S_hyper_span_info_t *spans1, H5S_seloper H5S_hyper_free_span_info(b_not_a); /* Check if the resulting hyperslab span tree is empty */ - if(result->select.sel_info.hslab.span_lst==NULL) { + if(result->select.sel_info.hslab->span_lst==NULL) { H5S_hyper_span_info_t *spans; /* Empty hyperslab span tree */ /* Sanity check */ @@ -6029,7 +6067,7 @@ H5S_operate_hyperslab (H5S_t *result, H5S_hyper_span_info_t *spans1, H5S_seloper spans->head=NULL; /* Set pointer to empty span tree */ - result->select.sel_info.hslab.span_lst=spans; + result->select.sel_info.hslab->span_lst=spans; } /* end if */ else { /* Check if the resulting hyperslab span tree can be used to re-build @@ -6090,15 +6128,19 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't create hyperslab information"); /* Copy the original dataspace */ - if(space->select.sel_info.hslab.span_lst!=NULL) { + if(space->select.sel_info.hslab->span_lst!=NULL) { /* Take ownership of the dataspace's hyperslab spans */ /* (These are freed later) */ - tmp_spans=space->select.sel_info.hslab.span_lst; - space->select.sel_info.hslab.span_lst=NULL; + tmp_spans=space->select.sel_info.hslab->span_lst; + space->select.sel_info.hslab->span_lst=NULL; /* Reset the other dataspace selection information */ if(H5S_SELECT_RELEASE(space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection"); + + /* 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"); } /* end if */ /* Combine tmp_space (really space) & new_space, with the result in space */ @@ -6193,7 +6235,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 */ @@ -6282,31 +6324,38 @@ 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, NULL, "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->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->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; } /* 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"); @@ -6315,25 +6364,13 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs"); /* 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; } /* end if */ else 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); @@ -6379,9 +6416,9 @@ 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 (H5S_NULL==H5S_GET_SIMPLE_EXTENT_TYPE(space)) + if (H5S_NULL==H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_NULL space"); if(start==NULL || count==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified"); @@ -6503,12 +6540,12 @@ H5S_combine_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2) assert(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID); /* Check that the space selections both have span trees */ - if(space1->select.sel_info.hslab.span_lst==NULL) + if(space1->select.sel_info.hslab->span_lst==NULL) if(H5S_hyper_generate_spans(space1)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree"); - if(space2->select.sel_info.hslab.span_lst==NULL) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, NULL, "dataspace does not have span tree"); + if(space2->select.sel_info.hslab->span_lst==NULL) if(H5S_hyper_generate_spans(space2)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree"); + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, NULL, "dataspace does not have span tree"); /* Copy the first dataspace */ if (NULL==(new_space=H5S_copy (space1, TRUE))) @@ -6518,8 +6555,12 @@ H5S_combine_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2) if(H5S_SELECT_RELEASE(new_space)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, NULL, "can't release selection"); + /* Allocate space for the hyperslab selection information */ + if((new_space->select.sel_info.hslab=H5FL_CALLOC(H5S_hyper_sel_t))==NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab info"); + /* Combine space1 & space2, with the result in new_space */ - if(H5S_operate_hyperslab(new_space,space1->select.sel_info.hslab.span_lst,op,space2->select.sel_info.hslab.span_lst,FALSE,&span2_owned)<0) + if(H5S_operate_hyperslab(new_space,space1->select.sel_info.hslab->span_lst,op,space2->select.sel_info.hslab->span_lst,FALSE,&span2_owned)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, NULL, "can't clip hyperslab information"); /* Set return value */ @@ -6579,7 +6620,7 @@ H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces not same rank"); /* Check that both dataspaces have hyperslab selections */ - if(space1->select.type!=H5S_SEL_HYPERSLABS || space2->select.type!=H5S_SEL_HYPERSLABS) + if(H5S_GET_SELECT_TYPE(space1)!=H5S_SEL_HYPERSLABS || H5S_GET_SELECT_TYPE(space2)!=H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces don't have hyperslab selections"); /* Go combine the dataspaces */ @@ -6627,24 +6668,28 @@ H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2) assert(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID); /* Check that the space selections both have span trees */ - if(space1->select.sel_info.hslab.span_lst==NULL) + if(space1->select.sel_info.hslab->span_lst==NULL) if(H5S_hyper_generate_spans(space1)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree"); - if(space2->select.sel_info.hslab.span_lst==NULL) + if(space2->select.sel_info.hslab->span_lst==NULL) if(H5S_hyper_generate_spans(space2)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree"); /* Take ownership of the dataspace's hyperslab spans */ /* (These are freed later) */ - tmp_spans=space1->select.sel_info.hslab.span_lst; - space1->select.sel_info.hslab.span_lst=NULL; + tmp_spans=space1->select.sel_info.hslab->span_lst; + space1->select.sel_info.hslab->span_lst=NULL; /* Reset the other dataspace selection information */ if(H5S_SELECT_RELEASE(space1)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection"); + /* Allocate space for the hyperslab selection information */ + if((space1->select.sel_info.hslab=H5FL_CALLOC(H5S_hyper_sel_t))==NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info"); + /* Combine tmp_spans (from space1) & spans from space2, with the result in space1 */ - if(H5S_operate_hyperslab(space1,tmp_spans,op,space2->select.sel_info.hslab.span_lst,FALSE,&span2_owned)<0) + if(H5S_operate_hyperslab(space1,tmp_spans,op,space2->select.sel_info.hslab->span_lst,FALSE,&span2_owned)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information"); done: @@ -6700,7 +6745,7 @@ H5Sselect_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces not same rank"); /* Check that both dataspaces have hyperslab selections */ - if(space1->select.type!=H5S_SEL_HYPERSLABS || space2->select.type!=H5S_SEL_HYPERSLABS) + if(H5S_GET_SELECT_TYPE(space1)!=H5S_SEL_HYPERSLABS || H5S_GET_SELECT_TYPE(space2)!=H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces don't have hyperslab selections"); /* Go refine the first selection */ @@ -7674,7 +7719,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 f32cf7a..a58103d 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -114,7 +114,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); @@ -535,11 +535,11 @@ 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_NULL: 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 24fc8f3..72f9fd6 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_extent_release(H5S_extent_t *extent); @@ -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 9becfb9..87dd0e2 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,9 +1252,9 @@ 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 (H5S_NULL==H5S_GET_SIMPLE_EXTENT_TYPE(space)) + if (H5S_NULL==H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "point doesn't support H5S_NULL 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/H5Spublic.h b/src/H5Spublic.h index 1121c02..70958c9 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -112,6 +112,7 @@ H5_DLL herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t _stride[], const hsize_t count[], const hsize_t _block[]); +/* #define NEW_HYPERSLAB_API */ #ifdef NEW_HYPERSLAB_API H5_DLL hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[], diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 8fb73cc..4d7091a 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,50 +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_NULL: - 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); @@ -200,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); @@ -238,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); @@ -281,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); @@ -321,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); @@ -475,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); @@ -519,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); @@ -634,7 +597,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); @@ -672,7 +635,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); @@ -710,7 +673,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); @@ -748,7 +711,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); @@ -775,7 +738,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); @@ -799,7 +762,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); @@ -840,7 +803,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); @@ -883,7 +846,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() */ @@ -920,7 +883,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); @@ -959,7 +922,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() */ @@ -999,7 +962,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; @@ -1043,7 +1006,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() */ @@ -1080,7 +1043,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); @@ -1297,7 +1260,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); @@ -1350,9 +1313,9 @@ HDfprintf(stderr,"%s: Entering\n",FUNC); #ifdef QAK HDfprintf(stderr,"%s: Check 0.5\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)); HDfprintf(stderr,"%s: space1->select.num_elem=%Hd\n",FUNC,space1->select.num_elem); -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)); HDfprintf(stderr,"%s: space2->select.num_elem=%Hd\n",FUNC,space2->select.num_elem); #endif /* QAK */ /* Check for different number of elements selected */ @@ -1363,7 +1326,7 @@ HDfprintf(stderr,"%s: space2->select.num_elem=%Hd\n",FUNC,space2->select.num_ele HDfprintf(stderr,"%s: Check 1.0\n",FUNC); #endif /* QAK */ /* 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 */ @@ -1380,25 +1343,25 @@ HDfprintf(stderr,"%s: Check 2.0\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) { #ifdef QAK HDfprintf(stderr,"%s: Check 3.0\n",FUNC); #endif /* QAK */ 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)) { #ifdef QAK HDfprintf(stderr,"%s: Check 4.0\n",FUNC); #endif /* QAK */ /* 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 */ @@ -1414,7 +1377,7 @@ HDfprintf(stderr,"%s: Check 4.0\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); @@ -1423,7 +1386,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); |