summaryrefslogtreecommitdiffstats
path: root/src/H5Shyper.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2015-09-27 01:39:06 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2015-09-27 01:39:06 (GMT)
commit6f1dda474c22ee95b7cc132e703cd6a2ac596704 (patch)
tree84af5241f80a9c0a1e321a80508dc14a2b6ee711 /src/H5Shyper.c
parent574ff3980afe62f83660cb2c617154e85ab128fd (diff)
parent8186a5cee10c41e97ba24b6fe1de9f6ce0c3902d (diff)
downloadhdf5-6f1dda474c22ee95b7cc132e703cd6a2ac596704.zip
hdf5-6f1dda474c22ee95b7cc132e703cd6a2ac596704.tar.gz
hdf5-6f1dda474c22ee95b7cc132e703cd6a2ac596704.tar.bz2
[svn-r27887] Description:
Merge changes from trunk to the branch. Tested on: MacOSX/64 10.10.5 (amazon) w/serial & parallel (h5committest not required on this branch)
Diffstat (limited to 'src/H5Shyper.c')
-rw-r--r--src/H5Shyper.c94
1 files changed, 54 insertions, 40 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 1a4e4f5..11e5369 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -2014,14 +2014,14 @@ H5S_hyper_serial_size(const H5S_t *space)
PURPOSE
Serialize the current selection into a user-provided buffer.
USAGE
- herr_t H5S_hyper_serialize_helper(spans, start, end, rank, buf)
+ void H5S_hyper_serialize_helper(spans, start, end, rank, buf)
H5S_hyper_span_info_t *spans; IN: Hyperslab span tree to serialize
hssize_t start[]; IN/OUT: Accumulated start points
hssize_t end[]; IN/OUT: Accumulated end points
hsize_t rank; IN: Current rank looking at
uint8 *buf; OUT: Buffer to put serialized selection into
RETURNS
- Non-negative on success/Negative on failure
+ <none>
DESCRIPTION
Serializes the current element selection into a buffer. (Primarily for
storing on disk).
@@ -2030,13 +2030,13 @@ H5S_hyper_serial_size(const H5S_t *space)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static herr_t
-H5S_hyper_serialize_helper (const H5S_hyper_span_info_t *spans,
+static void
+H5S_hyper_serialize_helper(const H5S_hyper_span_info_t *spans,
hsize_t *start, hsize_t *end, hsize_t rank, uint8_t **p)
{
H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */
+ uint8_t *pp = (*p); /* Local pointer for decoding */
hsize_t u; /* Index variable */
- herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -2045,7 +2045,7 @@ H5S_hyper_serialize_helper (const H5S_hyper_span_info_t *spans,
HDassert(start);
HDassert(end);
HDassert(rank < H5O_LAYOUT_NDIMS);
- HDassert(p && *p);
+ HDassert(p && pp);
/* Walk through the list of spans, recursing or outputing them */
curr=spans->head;
@@ -2057,33 +2057,35 @@ H5S_hyper_serialize_helper (const H5S_hyper_span_info_t *spans,
end[rank]=curr->high;
/* Recurse down to the next dimension */
- if(H5S_hyper_serialize_helper(curr->down,start,end,rank+1,p)<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans")
+ *p = pp;
+ H5S_hyper_serialize_helper(curr->down, start, end, rank = 1, p);
} /* end if */
else {
/* Encode all the previous dimensions starting & ending points */
/* Encode previous starting points */
for(u=0; u<rank; u++)
- UINT32ENCODE(*p, (uint32_t)start[u]);
+ UINT32ENCODE(pp, (uint32_t)start[u]);
/* Encode starting point for this span */
- UINT32ENCODE(*p, (uint32_t)curr->low);
+ UINT32ENCODE(pp, (uint32_t)curr->low);
/* Encode previous ending points */
for(u=0; u<rank; u++)
- UINT32ENCODE(*p, (uint32_t)end[u]);
+ UINT32ENCODE(pp, (uint32_t)end[u]);
/* Encode starting point for this span */
- UINT32ENCODE(*p, (uint32_t)curr->high);
+ UINT32ENCODE(pp, (uint32_t)curr->high);
} /* end else */
/* Advance to next node */
curr=curr->next;
} /* end while */
-done:
- FUNC_LEAVE_NOAPI(ret_value)
+ /* Update encoding pointer */
+ *p = pp;
+
+ FUNC_LEAVE_NOAPI_VOID
} /* H5S_hyper_serialize_helper() */
@@ -2109,14 +2111,15 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_hyper_serialize (const H5S_t *space, uint8_t **p)
+H5S_hyper_serialize(const H5S_t *space, uint8_t **p)
{
const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */
+ uint8_t *pp = (*p); /* Local pointer for decoding */
hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary hyperslab counts */
- hsize_t offset[H5O_LAYOUT_NDIMS]; /* Offset of element in dataspace */
+ hsize_t offset[H5O_LAYOUT_NDIMS]; /* Offset of element in dataspace */
hsize_t start[H5O_LAYOUT_NDIMS]; /* Location of start of hyperslab */
hsize_t end[H5O_LAYOUT_NDIMS]; /* Location of end of hyperslab */
- hsize_t temp_off; /* Offset in a given dimension */
+ hsize_t temp_off; /* Offset in a given dimension */
uint8_t *lenp; /* pointer to length location for later storage */
uint32_t len = 0; /* number of bytes used */
uint32_t version; /* Version number */
@@ -2128,7 +2131,10 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t **p)
FUNC_ENTER_NOAPI_NOINIT_NOERR
+ /* Check args */
HDassert(space);
+ HDassert(p);
+ HDassert(pp);
/* Calculate version */
if(space->select.sel_info.hslab->unlim_dim >= 0) {
@@ -2139,17 +2145,17 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t **p)
version = 1;
/* Store the preamble information */
- UINT32ENCODE(*p, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */
- UINT32ENCODE(*p, version); /* Store the version number */
+ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */
+ UINT32ENCODE(pp, version); /* Store the version number */
if(version >= 2)
- *(*p)++ = flags; /* Store the flags */
+ *pp++ = flags; /* Store the flags */
else
- UINT32ENCODE(*p, (uint32_t)0); /* Store the un-used padding */
- lenp = *p; /* keep the pointer to the length location for later */
- *p += 4; /* skip over space for length */
+ UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */
+ lenp = pp; /* Keep the pointer to the length location for later */
+ pp += 4; /* Skip over space for length */
/* Encode number of dimensions */
- UINT32ENCODE(*p, (uint32_t)space->extent.rank);
+ UINT32ENCODE(pp, (uint32_t)space->extent.rank);
len += 4;
/* If there is an unlimited dimension, only encode opt_unlim_diminfo */
@@ -2161,10 +2167,10 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t **p)
/* Iterate over dimensions */
for(i = 0; i < space->extent.rank; i++) {
/* Encode start/stride/block/count */
- UINT64ENCODE(*p, space->select.sel_info.hslab->opt_diminfo[i].start);
- UINT64ENCODE(*p, space->select.sel_info.hslab->opt_diminfo[i].stride);
- UINT64ENCODE(*p, space->select.sel_info.hslab->opt_diminfo[i].count);
- UINT64ENCODE(*p, space->select.sel_info.hslab->opt_diminfo[i].block);
+ UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].start);
+ UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].stride);
+ UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].count);
+ UINT64ENCODE(pp, space->select.sel_info.hslab->opt_diminfo[i].block);
} /* end for */
} /* end if */
/* Check for a "regular" hyperslab selection */
@@ -2182,7 +2188,7 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t **p)
/* Encode number of hyperslabs */
H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t);
- UINT32ENCODE(*p, (uint32_t)block_count);
+ UINT32ENCODE(pp, (uint32_t)block_count);
len+=4;
/* Now serialize the information for the regular hyperslab */
@@ -2205,11 +2211,11 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t **p)
/* Encode hyperslab starting location */
for(u = 0; u < ndims; u++)
- UINT32ENCODE(*p, (uint32_t)offset[u]);
+ UINT32ENCODE(pp, (uint32_t)offset[u]);
/* Encode hyperslab ending location */
for(u = 0; u < ndims; u++)
- UINT32ENCODE(*p, (uint32_t)(offset[u] + (diminfo[u].block - 1)));
+ UINT32ENCODE(pp, (uint32_t)(offset[u] + (diminfo[u].block - 1)));
/* Move the offset to the next sequence to start */
offset[fast_dim]+=diminfo[fast_dim].stride;
@@ -2260,7 +2266,7 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t **p)
/* Encode number of hyperslabs */
block_count = H5S_hyper_span_nblocks(space->select.sel_info.hslab->span_lst);
H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t);
- UINT32ENCODE(*p, (uint32_t)block_count);
+ UINT32ENCODE(pp, (uint32_t)block_count);
len+=4;
/* Add 8 bytes times the rank for each hyperslab selected */
@@ -2268,12 +2274,16 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t **p)
len += (uint32_t)(8 * space->extent.rank * block_count);
/* Encode each hyperslab in selection */
+ *p = pp;
H5S_hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, p);
} /* end else */
/* Encode length */
UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */
+ /* Update encoding pointer */
+ *p = pp;
+
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5S_hyper_serialize() */
@@ -2306,6 +2316,7 @@ static herr_t
H5S_hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t flags,
const uint8_t **p)
{
+ const uint8_t *pp = (*p); /* Local pointer for decoding */
unsigned rank; /* rank of points */
size_t num_elem=0; /* number of elements in selection */
hsize_t start[H5O_LAYOUT_NDIMS]; /* hyperslab start information */
@@ -2326,7 +2337,7 @@ H5S_hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fla
/* Check args */
HDassert(space);
HDassert(p);
- HDassert(*p);
+ HDassert(pp);
/* Deserialize slabs to select */
/* (The header and rank have already beed decoded) */
@@ -2340,10 +2351,10 @@ H5S_hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fla
/* Iterate over dimensions */
for(i = 0; i < space->extent.rank; i++) {
/* Decode start/stride/block/count */
- UINT64DECODE(*p, start[i]);
- UINT64DECODE(*p, stride[i]);
- UINT64DECODE(*p, count[i]);
- UINT64DECODE(*p, block[i]);
+ UINT64DECODE(pp, start[i]);
+ UINT64DECODE(pp, stride[i]);
+ UINT64DECODE(pp, count[i]);
+ UINT64DECODE(pp, block[i]);
} /* end for */
/* Select the hyperslab to the current selection */
@@ -2352,7 +2363,7 @@ H5S_hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fla
} /* end if */
else {
/* decode the number of points */
- UINT32DECODE(*p,num_elem);
+ UINT32DECODE(pp,num_elem);
/* Set the count & stride for all blocks */
for(tcount=count,tstride=stride,j=0; j<rank; j++,tstride++,tcount++) {
@@ -2364,11 +2375,11 @@ H5S_hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fla
for(i=0; i<num_elem; i++) {
/* Decode the starting points */
for(tstart=start,j=0; j<rank; j++,tstart++)
- UINT32DECODE(*p, *tstart);
+ UINT32DECODE(pp, *tstart);
/* Decode the ending points */
for(tend=end,j=0; j<rank; j++,tend++)
- UINT32DECODE(*p, *tend);
+ UINT32DECODE(pp, *tend);
/* Change the ending points into blocks */
for(tblock=block,tstart=start,tend=end,j=0; j<rank; j++,tstart++,tend++,tblock++)
@@ -2380,6 +2391,9 @@ H5S_hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fla
} /* end for */
} /* end else */
+ /* Update decoding pointer */
+ *p = pp;
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5S_hyper_deserialize() */