summaryrefslogtreecommitdiffstats
path: root/src/H5Spoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Spoint.c')
-rw-r--r--src/H5Spoint.c150
1 files changed, 68 insertions, 82 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index d56fe82..0626a42 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -25,29 +25,29 @@ static intn interface_initialize_g = 0;
static herr_t H5S_point_init (const struct H5O_layout_t *layout,
const H5S_t *space, H5S_sel_iter_t *iter, size_t *min_elem_out);
-static size_t H5S_point_favail (const H5S_t *space, const H5S_sel_iter_t *iter,
- size_t max);
-static size_t H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout,
+static hsize_t H5S_point_favail (const H5S_t *space, const H5S_sel_iter_t *iter,
+ hsize_t max);
+static hsize_t H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout,
const struct H5O_pline_t *pline,
const struct H5O_fill_t *fill,
const struct H5O_efl_t *efl, size_t elmt_size,
const H5S_t *file_space,
- H5S_sel_iter_t *file_iter, size_t nelmts,
+ H5S_sel_iter_t *file_iter, hsize_t nelmts,
hid_t dxpl_id, void *buf/*out*/);
static herr_t H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout,
const struct H5O_pline_t *pline,
const struct H5O_fill_t *fill,
const struct H5O_efl_t *efl, size_t elmt_size,
const H5S_t *file_space,
- H5S_sel_iter_t *file_iter, size_t nelmts,
+ H5S_sel_iter_t *file_iter, hsize_t nelmts,
hid_t dxpl_id, const void *buf);
-static size_t H5S_point_mgath (const void *_buf, size_t elmt_size,
+static hsize_t H5S_point_mgath (const void *_buf, size_t elmt_size,
const H5S_t *mem_space,
- H5S_sel_iter_t *mem_iter, size_t nelmts,
+ H5S_sel_iter_t *mem_iter, hsize_t nelmts,
void *_tconv_buf/*out*/);
static herr_t H5S_point_mscat (const void *_tconv_buf, size_t elmt_size,
const H5S_t *mem_space,
- H5S_sel_iter_t *mem_iter, size_t nelmts,
+ H5S_sel_iter_t *mem_iter, hsize_t nelmts,
void *_buf/*out*/);
static herr_t H5S_select_elements(H5S_t *space, H5S_seloper_t op,
size_t num_elem, const hssize_t **coord);
@@ -228,7 +228,7 @@ done:
*
* Purpose: Figure out the optimal number of elements to transfer to/from the file
*
- * Return: non-negative number of elements on success, negative on failure
+ * Return: non-negative number of elements on success, zero on failure
*
* Programmer: Quincey Koziol
* Tuesday, June 16, 1998
@@ -237,19 +237,18 @@ done:
*
*-------------------------------------------------------------------------
*/
-static size_t
+static hsize_t
H5S_point_favail (const H5S_t UNUSED *space,
- const H5S_sel_iter_t *sel_iter, size_t max)
+ const H5S_sel_iter_t *sel_iter, hsize_t max)
{
- FUNC_ENTER (H5S_point_favail, FAIL);
+ FUNC_ENTER (H5S_point_favail, 0);
/* Check args */
assert (space && H5S_SEL_POINTS==space->select.type);
assert (sel_iter);
#ifdef QAK
- printf("%s: check 1.0, ret=%d\n",
- FUNC,(int)MIN(sel_iter->pnt.elmt_left,max));
+ printf("%s: check 1.0, ret=%d\n", FUNC,(int)MIN(sel_iter->pnt.elmt_left,max));
#endif /* QAK */
FUNC_LEAVE (MIN(sel_iter->pnt.elmt_left,max));
} /* H5S_point_favail() */
@@ -284,12 +283,12 @@ H5S_point_favail (const H5S_t UNUSED *space,
* what the virtual file layer needs.
*-------------------------------------------------------------------------
*/
-static size_t
+static hsize_t
H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout,
const struct H5O_pline_t *pline,
const struct H5O_fill_t *fill, const struct H5O_efl_t *efl,
size_t elmt_size, const H5S_t *file_space,
- H5S_sel_iter_t *file_iter, size_t nelmts, hid_t dxpl_id,
+ H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id,
void *_buf/*out*/)
{
hssize_t file_offset[H5O_LAYOUT_NDIMS]; /*offset of slab in file*/
@@ -297,8 +296,8 @@ H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout,
hssize_t zero[H5O_LAYOUT_NDIMS]; /*zero */
uint8_t *buf=(uint8_t *)_buf; /* Alias for pointer arithmetic */
uintn ndims; /* Number of dimensions of dataset */
- intn i; /*counters */
- size_t num_read; /* number of elements read into buffer */
+ uintn u; /*counters */
+ hsize_t num_read; /* number of elements read into buffer */
FUNC_ENTER (H5S_point_fgath, 0);
@@ -316,9 +315,9 @@ H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout,
#endif /* QAK */
ndims=file_space->extent.u.simple.rank;
/* initialize hyperslab size and offset in memory buffer */
- for(i=0; i<(int)(ndims+1); i++) {
- hsize[i]=1; /* hyperslab size is 1, except for last element */
- zero[i]=0; /* memory offset is 0 */
+ for(u=0; u<ndims+1; u++) {
+ hsize[u]=1; /* hyperslab size is 1, except for last element */
+ zero[u]=0; /* memory offset is 0 */
} /* end for */
hsize[ndims] = elmt_size;
@@ -330,31 +329,25 @@ H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout,
while(num_read<nelmts) {
if(file_iter->pnt.elmt_left>0) {
/* Copy the location of the point to get */
- HDmemcpy(file_offset, file_iter->pnt.curr->pnt,
- ndims*sizeof(hssize_t));
+ HDmemcpy(file_offset, file_iter->pnt.curr->pnt, ndims*sizeof(hssize_t));
file_offset[ndims] = 0;
/* Add in the offset */
- for(i=0; i<file_space->extent.u.simple.rank; i++)
- file_offset[i] += file_space->select.offset[i];
+ for(u=0; u<file_space->extent.u.simple.rank; u++)
+ file_offset[u] += file_space->select.offset[u];
/* Go read the point */
- if (H5F_arr_read(f, dxpl_id, layout, pline, fill, efl, hsize,
- hsize, zero, file_offset, buf/*out*/)<0) {
+ if (H5F_arr_read(f, dxpl_id, layout, pline, fill, efl, hsize, hsize, zero, file_offset, buf/*out*/)<0) {
HRETURN_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error");
}
#ifdef QAK
printf("%s: check 3.0\n",FUNC);
- {
- for(i=0; i<ndims; i++) {
- printf("%s: %d - pnt=%d\n",
- FUNC, (int)i, (int)file_iter->pnt.curr->pnt[i]);
- printf("%s: %d - file_offset=%d\n",
- FUNC, (int)i, (int)file_offset[i]);
+ for(u=0; u<ndims; u++) {
+ printf("%s: %u - pnt=%d\n", FUNC, (unsigned)u, (int)file_iter->pnt.curr->pnt[u]);
+ printf("%s: %u - file_offset=%d\n", FUNC, (unsigned)u, (int)file_offset[u]);
}
printf("%s: *buf=%u\n",FUNC,(unsigned)*buf);
- }
#endif /* QAK */
/* Increment the offset of the buffer */
buf+=elmt_size;
@@ -398,7 +391,7 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout,
const struct H5O_pline_t *pline,
const struct H5O_fill_t *fill, const struct H5O_efl_t *efl,
size_t elmt_size, const H5S_t *file_space,
- H5S_sel_iter_t *file_iter, size_t nelmts, hid_t dxpl_id,
+ H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id,
const void *_buf)
{
hssize_t file_offset[H5O_LAYOUT_NDIMS]; /*offset of hyperslab */
@@ -406,8 +399,8 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout,
hssize_t zero[H5O_LAYOUT_NDIMS]; /*zero vector */
const uint8_t *buf=(const uint8_t *)_buf; /* Alias for pointer arithmetic */
uintn ndims; /* Number of dimensions of dataset */
- intn i; /*counters */
- size_t num_written; /* number of elements written from buffer */
+ uintn u; /*counters */
+ hsize_t num_written; /* number of elements written from buffer */
FUNC_ENTER (H5S_point_fscat, FAIL);
@@ -425,9 +418,9 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout,
#endif /* QAK */
ndims=file_space->extent.u.simple.rank;
/* initialize hyperslab size and offset in memory buffer */
- for(i=0; i<(int)(ndims+1); i++) {
- hsize[i]=1; /* hyperslab size is 1, except for last element */
- zero[i]=0; /* memory offset is 0 */
+ for(u=0; u<ndims+1; u++) {
+ hsize[u]=1; /* hyperslab size is 1, except for last element */
+ zero[u]=0; /* memory offset is 0 */
} /* end for */
hsize[ndims] = elmt_size;
@@ -440,9 +433,8 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout,
#ifdef QAK
printf("%s: check 2.0\n",FUNC);
{
- for(i=0; i<ndims; i++) {
- printf("%s: %d - pnt=%d\n",
- FUNC, (int)i, (int)file_iter->pnt.curr->pnt[i]);
+ for(u=0; u<ndims; u++) {
+ printf("%s: %u - pnt=%d\n", FUNC, (unsigned)u, (int)file_iter->pnt.curr->pnt[u]);
}
}
#endif /* QAK */
@@ -451,24 +443,19 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout,
file_offset[ndims] = 0;
/* Add in the offset, if there is one */
- for(i=0; i<file_space->extent.u.simple.rank; i++)
- file_offset[i] += file_space->select.offset[i];
+ for(u=0; u<file_space->extent.u.simple.rank; u++)
+ file_offset[u] += file_space->select.offset[u];
#ifdef QAK
printf("%s: check 3.0\n",FUNC);
- {
- for(i=0; i<ndims; i++) {
- printf("%s: %d - pnt=%d\n",
- FUNC,(int)i,(int)file_iter->pnt.curr->pnt[i]);
- printf("%s: %d - file_offset=%d\n",
- FUNC,(int)i,(int)file_offset[i]);
- }
- printf("%s: *buf=%u\n",FUNC,(unsigned)*buf);
- }
+ for(u=0; u<ndims; u++) {
+ printf("%s: %u - pnt=%d\n", FUNC,(unsigned)u,(int)file_iter->pnt.curr->pnt[u]);
+ printf("%s: %u - file_offset=%d\n", FUNC,(unsigned)u,(int)file_offset[u]);
+ }
+ printf("%s: *buf=%u\n",FUNC,(unsigned)*buf);
#endif /* QAK */
/* Go write the point */
- if (H5F_arr_write(f, dxpl_id, layout, pline, fill, efl, hsize,
- hsize, zero, file_offset, buf)<0) {
+ if (H5F_arr_write(f, dxpl_id, layout, pline, fill, efl, hsize, hsize, zero, file_offset, buf)<0) {
HRETURN_ERROR(H5E_DATASPACE, H5E_WRITEERROR, 0, "write error");
}
@@ -482,8 +469,7 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout,
file_iter->pnt.elmt_left--;
file_iter->pnt.curr=file_iter->pnt.curr->next;
#ifdef QAK
- printf("%s: check 5.0, file_iter->pnt.curr=%p\n",
- FUNC,file_iter->pnt.curr);
+ printf("%s: check 5.0, file_iter->pnt.curr=%p\n", FUNC,file_iter->pnt.curr);
#endif
} /* end while */
@@ -510,10 +496,10 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout,
*
*-------------------------------------------------------------------------
*/
-static size_t
+static hsize_t
H5S_point_mgath (const void *_buf, size_t elmt_size,
const H5S_t *mem_space, H5S_sel_iter_t *mem_iter,
- size_t nelmts, void *_tconv_buf/*out*/)
+ hsize_t nelmts, void *_tconv_buf/*out*/)
{
hsize_t mem_size[H5O_LAYOUT_NDIMS]; /*total size of app buf */
const uint8_t *buf=(const uint8_t *)_buf; /* Get local copies for address arithmetic */
@@ -522,7 +508,7 @@ H5S_point_mgath (const void *_buf, size_t elmt_size,
hsize_t off; /* coordinate offset */
intn space_ndims; /*dimensionality of space*/
intn i; /*counters */
- size_t num_gath; /* number of elements gathered */
+ hsize_t num_gath; /* number of elements gathered */
FUNC_ENTER (H5S_point_mgath, 0);
@@ -589,7 +575,7 @@ H5S_point_mgath (const void *_buf, size_t elmt_size,
static herr_t
H5S_point_mscat (const void *_tconv_buf, size_t elmt_size,
const H5S_t *mem_space, H5S_sel_iter_t *mem_iter,
- size_t nelmts, void *_buf/*out*/)
+ hsize_t nelmts, void *_buf/*out*/)
{
hsize_t mem_size[H5O_LAYOUT_NDIMS]; /*total size of app buf */
uint8_t *buf=(uint8_t *)_buf; /* Get local copies for address arithmetic */
@@ -598,7 +584,7 @@ H5S_point_mscat (const void *_tconv_buf, size_t elmt_size,
hsize_t off; /* coordinate offset */
intn space_ndims; /*dimensionality of space*/
intn i; /*counters */
- size_t num_scat; /* Number of elements scattered */
+ hsize_t num_scat; /* Number of elements scattered */
FUNC_ENTER (H5S_point_mscat, FAIL);
@@ -826,8 +812,8 @@ done:
htri_t
H5S_point_select_valid (const H5S_t *space)
{
- H5S_pnt_node_t *curr; /* Point information nodes */
- intn i; /* Counter */
+ H5S_pnt_node_t *curr; /* Point information nodes */
+ uintn u; /* Counter */
htri_t ret_value=TRUE; /* return value */
FUNC_ENTER (H5S_point_select_valid, FAIL);
@@ -841,17 +827,17 @@ printf("%s: check 1.0\n",FUNC);
curr=space->select.sel_info.pnt_lst->head;
while(curr!=NULL) {
/* Check each dimension */
- for(i=0; i<space->extent.u.simple.rank; i++) {
+ for(u=0; u<space->extent.u.simple.rank; u++) {
#ifdef QAK
printf("%s: check 2.0\n",FUNC);
-printf("%s: curr->pnt[%d]=%d\n",FUNC,(int)i,(int)curr->pnt[i]);
-printf("%s: space->select.offset[%d]=%d\n",FUNC,(int)i,(int)space->select.offset[i]);
-printf("%s: space->extent.u.simple.size[%d]=%d\n",FUNC,(int)i,(int)space->extent.u.simple.size[i]);
+printf("%s: curr->pnt[%u]=%d\n",FUNC,(unsigned)u,(int)curr->pnt[u]);
+printf("%s: space->select.offset[%u]=%d\n",FUNC,(unsigned)u,(int)space->select.offset[u]);
+printf("%s: space->extent.u.simple.size[%u]=%d\n",FUNC,(unsigned)u,(int)space->extent.u.simple.size[u]);
#endif /* QAK */
/* Check if an offset has been defined */
/* Bounds check the selected point + offset against the extent */
- if(((curr->pnt[i]+space->select.offset[i])>(hssize_t)space->extent.u.simple.size[i])
- || ((curr->pnt[i]+space->select.offset[i])<0)) {
+ if(((curr->pnt[u]+space->select.offset[u])>(hssize_t)space->extent.u.simple.size[u])
+ || ((curr->pnt[u]+space->select.offset[u])<0)) {
ret_value=FALSE;
break;
} /* end if */
@@ -934,10 +920,10 @@ H5S_point_select_serial_size (const H5S_t *space)
herr_t
H5S_point_select_serialize (const H5S_t *space, uint8_t *buf)
{
- H5S_pnt_node_t *curr; /* Point information nodes */
- uint8_t *lenp; /* pointer to length location for later storage */
- uint32_t len=0; /* number of bytes used */
- intn i; /* local counting variable */
+ H5S_pnt_node_t *curr; /* Point information nodes */
+ uint8_t *lenp; /* pointer to length location for later storage */
+ uint32_t len=0; /* number of bytes used */
+ uintn u; /* local counting variable */
herr_t ret_value=FAIL; /* return value */
FUNC_ENTER (H5S_point_select_serialize, FAIL);
@@ -952,7 +938,7 @@ H5S_point_select_serialize (const H5S_t *space, uint8_t *buf)
buf+=4; /* skip over space for length */
/* Encode number of dimensions */
- INT32ENCODE(buf, (uint32_t)space->extent.u.simple.rank);
+ UINT32ENCODE(buf, (uint32_t)space->extent.u.simple.rank);
len+=4;
/* Encode number of elements */
@@ -966,8 +952,8 @@ H5S_point_select_serialize (const H5S_t *space, uint8_t *buf)
len+=4*space->extent.u.simple.rank;
/* Encode each point */
- for(i=0; i<space->extent.u.simple.rank; i++)
- UINT32ENCODE(buf, (uint32_t)curr->pnt[i]);
+ for(u=0; u<space->extent.u.simple.rank; u++)
+ UINT32ENCODE(buf, (uint32_t)curr->pnt[u]);
curr=curr->next;
} /* end while */
@@ -1004,7 +990,7 @@ herr_t
H5S_point_select_deserialize (H5S_t *space, const uint8_t *buf)
{
H5S_seloper_t op=H5S_SELECT_SET; /* Selection operation */
- int32_t rank; /* Rank of points */
+ uint32_t rank; /* Rank of points */
size_t num_elem=0; /* Number of elements in selection */
hssize_t *coord=NULL, *tcoord; /* Pointer to array of elements */
uintn i,j; /* local counting variables */
@@ -1018,7 +1004,7 @@ H5S_point_select_deserialize (H5S_t *space, const uint8_t *buf)
/* Deserialize points to select */
buf+=16; /* Skip over selection header */
- INT32DECODE(buf,rank); /* decode the rank of the point selection */
+ UINT32DECODE(buf,rank); /* decode the rank of the point selection */
if(rank!=space->extent.u.simple.rank)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of pointer does not match dataspace");
UINT32DECODE(buf,num_elem); /* decode the number of points */
@@ -1330,7 +1316,7 @@ H5S_point_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t
hsize_t offset; /* offset of region in buffer */
void *tmp_buf; /* temporary location of the element in the buffer */
H5S_pnt_node_t *node; /* Point node */
- intn rank; /* Dataspace rank */
+ uintn rank; /* Dataspace rank */
herr_t ret_value=0; /* return value */
FUNC_ENTER (H5S_point_select_iterate, 0);
@@ -1358,7 +1344,7 @@ H5S_point_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t
offset=H5V_array_offset(rank+1,mem_size,(const hssize_t *)mem_offset);
tmp_buf=((char *)buf+offset);
- ret_value=(*op)(tmp_buf,type_id,rank,node->pnt,operator_data);
+ ret_value=(*op)(tmp_buf,type_id,(hsize_t)rank,node->pnt,operator_data);
node=node->next;
} /* end while */