summaryrefslogtreecommitdiffstats
path: root/src/H5VM.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5VM.c')
-rw-r--r--src/H5VM.c701
1 files changed, 329 insertions, 372 deletions
diff --git a/src/H5VM.c b/src/H5VM.c
index 7be8eab..a5461e8 100644
--- a/src/H5VM.c
+++ b/src/H5VM.c
@@ -16,37 +16,32 @@
* Friday, October 10, 1997
*/
-
#include "H5private.h"
#include "H5Eprivate.h"
-#include "H5MMprivate.h" /* Memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h"
#include "H5VMprivate.h"
/* Local typedefs */
typedef struct H5VM_memcpy_ud_t {
- unsigned char *dst; /* Pointer to destination buffer */
- const unsigned char *src; /* Pointer to source buffer */
+ unsigned char * dst; /* Pointer to destination buffer */
+ const unsigned char *src; /* Pointer to source buffer */
} H5VM_memcpy_ud_t;
/* Local macros */
#define H5VM_HYPER_NDIMS H5O_LAYOUT_NDIMS
/* Local prototypes */
-static void
-H5VM__stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
- const hsize_t *size, hsize_t *stride1);
-static void
-H5VM__stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
- const hsize_t *size, hsize_t *stride1, hsize_t *stride2);
+static void H5VM__stride_optimize1(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/,
+ const hsize_t *size, hsize_t *stride1);
+static void H5VM__stride_optimize2(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/,
+ const hsize_t *size, hsize_t *stride1, hsize_t *stride2);
#ifdef LATER
-static void
-H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size,
- unsigned dst_n, const hsize_t *dst_size, const ssize_t *dst_stride, void *_dst,
- unsigned src_n, const hsize_t *src_size, const ssize_t *src_stride, const void *_src);
+static void H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size, unsigned dst_n, const hsize_t *dst_size,
+ const ssize_t *dst_stride, void *_dst, unsigned src_n, const hsize_t *src_size,
+ const ssize_t *src_stride, const void *_src);
#endif /* LATER */
-
/*-------------------------------------------------------------------------
* Function: H5VM__stride_optimize1
*
@@ -66,8 +61,8 @@ H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size,
*-------------------------------------------------------------------------
*/
static void
-H5VM__stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
- const hsize_t *size, hsize_t *stride1)
+H5VM__stride_optimize1(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, const hsize_t *size,
+ hsize_t *stride1)
{
FUNC_ENTER_STATIC_NOERR
@@ -80,17 +75,15 @@ H5VM__stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
/*
* Combine adjacent memory accesses
*/
- while (*np && stride1[*np-1]>0 &&
- (hsize_t)(stride1[*np-1])==*elmt_size) {
- *elmt_size *= size[*np-1];
+ while (*np && stride1[*np - 1] > 0 && (hsize_t)(stride1[*np - 1]) == *elmt_size) {
+ *elmt_size *= size[*np - 1];
if (--*np)
- stride1[*np-1] += size[*np] * stride1[*np];
+ stride1[*np - 1] += size[*np] * stride1[*np];
}
FUNC_LEAVE_NOAPI_VOID
}
-
/*-------------------------------------------------------------------------
* Function: H5VM__stride_optimize2
*
@@ -110,8 +103,8 @@ H5VM__stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
*-------------------------------------------------------------------------
*/
static void
-H5VM__stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
- const hsize_t *size, hsize_t *stride1, hsize_t *stride2)
+H5VM__stride_optimize2(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, const hsize_t *size,
+ hsize_t *stride1, hsize_t *stride2)
{
FUNC_ENTER_STATIC_NOERR
@@ -120,92 +113,90 @@ H5VM__stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
* zero we still must make one reference.
*/
HDassert(1 == H5VM_vector_reduce_product(0, NULL));
- HDassert(*elmt_size>0);
+ HDassert(*elmt_size > 0);
/*
* Combine adjacent memory accesses
*/
/* Unroll loop for common cases */
- switch(*np) {
+ switch (*np) {
case 1: /* For 0-D datasets (dunno if this ever gets used...) */
- if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) {
+ if (stride1[0] == *elmt_size && stride2[0] == *elmt_size) {
*elmt_size *= size[0];
- --*np; /* *np decrements to a value of 0 now */
- } /* end if */
+ --*np; /* *np decrements to a value of 0 now */
+ } /* end if */
break;
case 2: /* For 1-D datasets */
- if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) {
+ if (stride1[1] == *elmt_size && stride2[1] == *elmt_size) {
*elmt_size *= size[1];
- --*np; /* *np decrements to a value of 1 now */
+ --*np; /* *np decrements to a value of 1 now */
stride1[0] += size[1] * stride1[1];
stride2[0] += size[1] * stride2[1];
- if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) {
+ if (stride1[0] == *elmt_size && stride2[0] == *elmt_size) {
*elmt_size *= size[0];
- --*np; /* *np decrements to a value of 0 now */
- } /* end if */
- } /* end if */
+ --*np; /* *np decrements to a value of 0 now */
+ } /* end if */
+ } /* end if */
break;
case 3: /* For 2-D datasets */
- if(stride1[2] == *elmt_size && stride2[2] == *elmt_size) {
+ if (stride1[2] == *elmt_size && stride2[2] == *elmt_size) {
*elmt_size *= size[2];
- --*np; /* *np decrements to a value of 2 now */
+ --*np; /* *np decrements to a value of 2 now */
stride1[1] += size[2] * stride1[2];
stride2[1] += size[2] * stride2[2];
- if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) {
+ if (stride1[1] == *elmt_size && stride2[1] == *elmt_size) {
*elmt_size *= size[1];
- --*np; /* *np decrements to a value of 1 now */
+ --*np; /* *np decrements to a value of 1 now */
stride1[0] += size[1] * stride1[1];
stride2[0] += size[1] * stride2[1];
- if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) {
+ if (stride1[0] == *elmt_size && stride2[0] == *elmt_size) {
*elmt_size *= size[0];
- --*np; /* *np decrements to a value of 0 now */
- } /* end if */
- } /* end if */
- } /* end if */
+ --*np; /* *np decrements to a value of 0 now */
+ } /* end if */
+ } /* end if */
+ } /* end if */
break;
case 4: /* For 3-D datasets */
- if(stride1[3] == *elmt_size && stride2[3] == *elmt_size) {
+ if (stride1[3] == *elmt_size && stride2[3] == *elmt_size) {
*elmt_size *= size[3];
- --*np; /* *np decrements to a value of 3 now */
+ --*np; /* *np decrements to a value of 3 now */
stride1[2] += size[3] * stride1[3];
stride2[2] += size[3] * stride2[3];
- if(stride1[2] == *elmt_size && stride2[2] == *elmt_size) {
+ if (stride1[2] == *elmt_size && stride2[2] == *elmt_size) {
*elmt_size *= size[2];
- --*np; /* *np decrements to a value of 2 now */
+ --*np; /* *np decrements to a value of 2 now */
stride1[1] += size[2] * stride1[2];
stride2[1] += size[2] * stride2[2];
- if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) {
+ if (stride1[1] == *elmt_size && stride2[1] == *elmt_size) {
*elmt_size *= size[1];
- --*np; /* *np decrements to a value of 1 now */
+ --*np; /* *np decrements to a value of 1 now */
stride1[0] += size[1] * stride1[1];
stride2[0] += size[1] * stride2[1];
- if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) {
+ if (stride1[0] == *elmt_size && stride2[0] == *elmt_size) {
*elmt_size *= size[0];
- --*np; /* *np decrements to a value of 0 now */
- } /* end if */
- } /* end if */
- } /* end if */
- } /* end if */
+ --*np; /* *np decrements to a value of 0 now */
+ } /* end if */
+ } /* end if */
+ } /* end if */
+ } /* end if */
break;
default:
- while (*np &&
- stride1[*np-1] == *elmt_size &&
- stride2[*np-1] == *elmt_size) {
- *elmt_size *= size[*np-1];
+ while (*np && stride1[*np - 1] == *elmt_size && stride2[*np - 1] == *elmt_size) {
+ *elmt_size *= size[*np - 1];
if (--*np) {
- stride1[*np-1] += size[*np] * stride1[*np];
- stride2[*np-1] += size[*np] * stride2[*np];
+ stride1[*np - 1] += size[*np] * stride1[*np];
+ stride2[*np - 1] += size[*np] * stride2[*np];
}
}
break;
@@ -214,7 +205,6 @@ H5VM__stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
FUNC_LEAVE_NOAPI_VOID
}
-
/*-------------------------------------------------------------------------
* Function: H5VM_hyper_stride
*
@@ -243,14 +233,13 @@ H5VM__stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
*-------------------------------------------------------------------------
*/
hsize_t
-H5VM_hyper_stride(unsigned n, const hsize_t *size,
- const hsize_t *total_size, const hsize_t *offset,
- hsize_t *stride/*out*/)
+H5VM_hyper_stride(unsigned n, const hsize_t *size, const hsize_t *total_size, const hsize_t *offset,
+ hsize_t *stride /*out*/)
{
- hsize_t skip; /*starting point byte offset */
- hsize_t acc; /*accumulator */
- int i; /*counter */
- hsize_t ret_value; /* Return value */
+ hsize_t skip; /*starting point byte offset */
+ hsize_t acc; /*accumulator */
+ int i; /*counter */
+ hsize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -260,42 +249,42 @@ H5VM_hyper_stride(unsigned n, const hsize_t *size,
HDassert(stride);
/* init */
- HDassert(n>0);
- stride[n-1] = 1;
- skip = offset ? offset[n-1] : 0;
+ HDassert(n > 0);
+ stride[n - 1] = 1;
+ skip = offset ? offset[n - 1] : 0;
- switch(n) {
+ switch (n) {
case 2: /* 1-D dataset */
- HDassert(total_size[1]>=size[1]);
- stride[0] = total_size[1]-size[1]; /*overflow checked*/
- acc = total_size[1];
+ HDassert(total_size[1] >= size[1]);
+ stride[0] = total_size[1] - size[1]; /*overflow checked*/
+ acc = total_size[1];
skip += acc * (offset ? offset[0] : 0);
break;
case 3: /* 2-D dataset */
- HDassert(total_size[2]>=size[2]);
- stride[1] = total_size[2]-size[2]; /*overflow checked*/
- acc = total_size[2];
+ HDassert(total_size[2] >= size[2]);
+ stride[1] = total_size[2] - size[2]; /*overflow checked*/
+ acc = total_size[2];
skip += acc * (offset ? (hsize_t)offset[1] : 0);
- HDassert(total_size[1]>=size[1]);
+ HDassert(total_size[1] >= size[1]);
stride[0] = acc * (total_size[1] - size[1]); /*overflow checked*/
acc *= total_size[1];
skip += acc * (offset ? (hsize_t)offset[0] : 0);
break;
case 4: /* 3-D dataset */
- HDassert(total_size[3]>=size[3]);
- stride[2] = total_size[3]-size[3]; /*overflow checked*/
- acc = total_size[3];
+ HDassert(total_size[3] >= size[3]);
+ stride[2] = total_size[3] - size[3]; /*overflow checked*/
+ acc = total_size[3];
skip += acc * (offset ? (hsize_t)offset[2] : 0);
- HDassert(total_size[2]>=size[2]);
+ HDassert(total_size[2] >= size[2]);
stride[1] = acc * (total_size[2] - size[2]); /*overflow checked*/
acc *= total_size[2];
skip += acc * (offset ? (hsize_t)offset[1] : 0);
- HDassert(total_size[1]>=size[1]);
+ HDassert(total_size[1] >= size[1]);
stride[0] = acc * (total_size[1] - size[1]); /*overflow checked*/
acc *= total_size[1];
skip += acc * (offset ? (hsize_t)offset[0] : 0);
@@ -303,22 +292,21 @@ H5VM_hyper_stride(unsigned n, const hsize_t *size,
default:
/* others */
- for (i=(int)(n-2), acc=1; i>=0; --i) {
- HDassert(total_size[i+1]>=size[i+1]);
- stride[i] = acc * (total_size[i+1] - size[i+1]); /*overflow checked*/
- acc *= total_size[i+1];
+ for (i = (int)(n - 2), acc = 1; i >= 0; --i) {
+ HDassert(total_size[i + 1] >= size[i + 1]);
+ stride[i] = acc * (total_size[i + 1] - size[i + 1]); /*overflow checked*/
+ acc *= total_size[i + 1];
skip += acc * (offset ? (hsize_t)offset[i] : 0);
}
break;
} /* end switch */
/* Set return value */
- ret_value=skip;
+ ret_value = skip;
FUNC_LEAVE_NOAPI(ret_value)
}
-
/*-------------------------------------------------------------------------
* Function: H5VM_hyper_eq
*
@@ -341,27 +329,27 @@ H5VM_hyper_stride(unsigned n, const hsize_t *size,
*-------------------------------------------------------------------------
*/
htri_t
-H5VM_hyper_eq(unsigned n,
- const hsize_t *offset1, const hsize_t *size1,
- const hsize_t *offset2, const hsize_t *size2)
+H5VM_hyper_eq(unsigned n, const hsize_t *offset1, const hsize_t *size1, const hsize_t *offset2,
+ const hsize_t *size2)
{
- hsize_t nelmts1 = 1, nelmts2 = 1;
- unsigned i;
- htri_t ret_value=TRUE; /* Return value */
+ hsize_t nelmts1 = 1, nelmts2 = 1;
+ unsigned i;
+ htri_t ret_value = TRUE; /* Return value */
/* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOERR
- if (n == 0) HGOTO_DONE(TRUE)
+ if (n == 0)
+ HGOTO_DONE(TRUE)
- for (i=0; i<n; i++) {
- if ((offset1 ? offset1[i] : 0) != (offset2 ? offset2[i] : 0))
- HGOTO_DONE(FALSE)
- if ((size1 ? size1[i] : 0) != (size2 ? size2[i] : 0))
- HGOTO_DONE(FALSE)
- if (0 == (nelmts1 *= (size1 ? size1[i] : 0)))
+ for (i = 0; i < n; i++) {
+ if ((offset1 ? offset1[i] : 0) != (offset2 ? offset2[i] : 0))
+ HGOTO_DONE(FALSE)
+ if ((size1 ? size1[i] : 0) != (size2 ? size2[i] : 0))
HGOTO_DONE(FALSE)
- if (0 == (nelmts2 *= (size2 ? size2[i] : 0)))
+ if (0 == (nelmts1 *= (size1 ? size1[i] : 0)))
+ HGOTO_DONE(FALSE)
+ if (0 == (nelmts2 *= (size2 ? size2[i] : 0)))
HGOTO_DONE(FALSE)
}
@@ -369,7 +357,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
}
-
/*-------------------------------------------------------------------------
* Function: H5VM_hyper_fill
*
@@ -390,18 +377,17 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VM_hyper_fill(unsigned n, const hsize_t *_size,
- const hsize_t *total_size, const hsize_t *offset, void *_dst,
- unsigned fill_value)
+H5VM_hyper_fill(unsigned n, const hsize_t *_size, const hsize_t *total_size, const hsize_t *offset,
+ void *_dst, unsigned fill_value)
{
- uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic */
- hsize_t size[H5VM_HYPER_NDIMS]; /*a modifiable copy of _size */
- hsize_t dst_stride[H5VM_HYPER_NDIMS]; /*destination stride info */
- hsize_t dst_start; /*byte offset to start of stride*/
- hsize_t elmt_size = 1; /*bytes per element */
- herr_t ret_value; /*function return status */
+ uint8_t *dst = (uint8_t *)_dst; /*cast for ptr arithmetic */
+ hsize_t size[H5VM_HYPER_NDIMS]; /*a modifiable copy of _size */
+ hsize_t dst_stride[H5VM_HYPER_NDIMS]; /*destination stride info */
+ hsize_t dst_start; /*byte offset to start of stride*/
+ hsize_t elmt_size = 1; /*bytes per element */
+ herr_t ret_value; /*function return status */
#ifndef NDEBUG
- unsigned u;
+ unsigned u;
#endif
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -426,13 +412,11 @@ H5VM_hyper_fill(unsigned n, const hsize_t *_size,
H5VM__stride_optimize1(&n, &elmt_size, size, dst_stride);
/* Copy */
- ret_value = H5VM_stride_fill(n, elmt_size, size, dst_stride, dst+dst_start,
- fill_value);
+ ret_value = H5VM_stride_fill(n, elmt_size, size, dst_stride, dst + dst_start, fill_value);
FUNC_LEAVE_NOAPI(ret_value)
}
-
/*-------------------------------------------------------------------------
* Function: H5VM_hyper_copy
*
@@ -465,24 +449,22 @@ H5VM_hyper_fill(unsigned n, const hsize_t *_size,
herr_t
H5VM_hyper_copy(unsigned n, const hsize_t *_size,
- /*destination*/
- const hsize_t *dst_size, const hsize_t *dst_offset,
- void *_dst,
+ /*destination*/
+ const hsize_t *dst_size, const hsize_t *dst_offset, void *_dst,
- /*source*/
- const hsize_t *src_size, const hsize_t *src_offset,
- const void *_src)
+ /*source*/
+ const hsize_t *src_size, const hsize_t *src_offset, const void *_src)
{
- const uint8_t *src = (const uint8_t*)_src; /*cast for ptr arithmtc */
- uint8_t *dst = (uint8_t*) _dst; /*cast for ptr arithmtc */
- hsize_t size[H5VM_HYPER_NDIMS]; /*a modifiable _size */
- hsize_t src_stride[H5VM_HYPER_NDIMS]; /*source stride info */
- hsize_t dst_stride[H5VM_HYPER_NDIMS]; /*dest stride info */
- hsize_t dst_start, src_start; /*offset to start at */
- hsize_t elmt_size = 1; /*element size in bytes */
- herr_t ret_value; /*return status */
+ const uint8_t *src = (const uint8_t *)_src; /*cast for ptr arithmtc */
+ uint8_t * dst = (uint8_t *)_dst; /*cast for ptr arithmtc */
+ hsize_t size[H5VM_HYPER_NDIMS]; /*a modifiable _size */
+ hsize_t src_stride[H5VM_HYPER_NDIMS]; /*source stride info */
+ hsize_t dst_stride[H5VM_HYPER_NDIMS]; /*dest stride info */
+ hsize_t dst_start, src_start; /*offset to start at */
+ hsize_t elmt_size = 1; /*element size in bytes */
+ herr_t ret_value; /*return status */
#ifndef NDEBUG
- unsigned u;
+ unsigned u;
#endif
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -509,45 +491,45 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size,
#ifdef NO_INLINED_CODE
dst_start = H5VM_hyper_stride(n, size, dst_size, dst_offset, dst_stride);
src_start = H5VM_hyper_stride(n, size, src_size, src_offset, src_stride);
-#else /* NO_INLINED_CODE */
+#else /* NO_INLINED_CODE */
/* in-line version of two calls to H5VM_hyper_stride() */
{
- hsize_t dst_acc; /*accumulator */
- hsize_t src_acc; /*accumulator */
- int ii; /*counter */
+ hsize_t dst_acc; /*accumulator */
+ hsize_t src_acc; /*accumulator */
+ int ii; /*counter */
/* init */
- HDassert(n>0);
- dst_stride[n-1] = 1;
- src_stride[n-1] = 1;
- dst_start = dst_offset ? dst_offset[n-1] : 0;
- src_start = src_offset ? src_offset[n-1] : 0;
+ HDassert(n > 0);
+ dst_stride[n - 1] = 1;
+ src_stride[n - 1] = 1;
+ dst_start = dst_offset ? dst_offset[n - 1] : 0;
+ src_start = src_offset ? src_offset[n - 1] : 0;
/* Unroll loop for common cases */
- switch(n) {
+ switch (n) {
case 2:
- HDassert(dst_size[1]>=size[1]);
- HDassert(src_size[1]>=size[1]);
+ HDassert(dst_size[1] >= size[1]);
+ HDassert(src_size[1] >= size[1]);
dst_stride[0] = dst_size[1] - size[1]; /*overflow checked*/
src_stride[0] = src_size[1] - size[1]; /*overflow checked*/
- dst_acc = dst_size[1];
- src_acc = src_size[1];
+ dst_acc = dst_size[1];
+ src_acc = src_size[1];
dst_start += dst_acc * (dst_offset ? dst_offset[0] : 0);
src_start += src_acc * (src_offset ? src_offset[0] : 0);
break;
case 3:
- HDassert(dst_size[2]>=size[2]);
- HDassert(src_size[2]>=size[2]);
+ HDassert(dst_size[2] >= size[2]);
+ HDassert(src_size[2] >= size[2]);
dst_stride[1] = dst_size[2] - size[2]; /*overflow checked*/
src_stride[1] = src_size[2] - size[2]; /*overflow checked*/
- dst_acc = dst_size[2];
- src_acc = src_size[2];
+ dst_acc = dst_size[2];
+ src_acc = src_size[2];
dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0);
src_start += src_acc * (src_offset ? src_offset[1] : 0);
- HDassert(dst_size[1]>=size[1]);
- HDassert(src_size[1]>=size[1]);
+ HDassert(dst_size[1] >= size[1]);
+ HDassert(src_size[1] >= size[1]);
dst_stride[0] = dst_acc * (dst_size[1] - size[1]); /*overflow checked*/
src_stride[0] = src_acc * (src_size[1] - size[1]); /*overflow checked*/
dst_acc *= dst_size[1];
@@ -557,17 +539,17 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size,
break;
case 4:
- HDassert(dst_size[3]>=size[3]);
- HDassert(src_size[3]>=size[3]);
+ HDassert(dst_size[3] >= size[3]);
+ HDassert(src_size[3] >= size[3]);
dst_stride[2] = dst_size[3] - size[3]; /*overflow checked*/
src_stride[2] = src_size[3] - size[3]; /*overflow checked*/
- dst_acc = dst_size[3];
- src_acc = src_size[3];
+ dst_acc = dst_size[3];
+ src_acc = src_size[3];
dst_start += dst_acc * (dst_offset ? dst_offset[2] : 0);
src_start += src_acc * (src_offset ? src_offset[2] : 0);
- HDassert(dst_size[2]>=size[2]);
- HDassert(src_size[2]>=size[2]);
+ HDassert(dst_size[2] >= size[2]);
+ HDassert(src_size[2] >= size[2]);
dst_stride[1] = dst_acc * (dst_size[2] - size[2]); /*overflow checked*/
src_stride[1] = src_acc * (src_size[2] - size[2]); /*overflow checked*/
dst_acc *= dst_size[2];
@@ -575,8 +557,8 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size,
dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0);
src_start += src_acc * (src_offset ? src_offset[1] : 0);
- HDassert(dst_size[1]>=size[1]);
- HDassert(src_size[1]>=size[1]);
+ HDassert(dst_size[1] >= size[1]);
+ HDassert(src_size[1] >= size[1]);
dst_stride[0] = dst_acc * (dst_size[1] - size[1]); /*overflow checked*/
src_stride[0] = src_acc * (src_size[1] - size[1]); /*overflow checked*/
dst_acc *= dst_size[1];
@@ -587,13 +569,13 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size,
default:
/* others */
- for (ii=(int)(n-2), dst_acc=1, src_acc=1; ii>=0; --ii) {
- HDassert(dst_size[ii+1]>=size[ii+1]);
- HDassert(src_size[ii+1]>=size[ii+1]);
- dst_stride[ii] = dst_acc * (dst_size[ii+1] - size[ii+1]); /*overflow checked*/
- src_stride[ii] = src_acc * (src_size[ii+1] - size[ii+1]); /*overflow checked*/
- dst_acc *= dst_size[ii+1];
- src_acc *= src_size[ii+1];
+ for (ii = (int)(n - 2), dst_acc = 1, src_acc = 1; ii >= 0; --ii) {
+ HDassert(dst_size[ii + 1] >= size[ii + 1]);
+ HDassert(src_size[ii + 1] >= size[ii + 1]);
+ dst_stride[ii] = dst_acc * (dst_size[ii + 1] - size[ii + 1]); /*overflow checked*/
+ src_stride[ii] = src_acc * (src_size[ii + 1] - size[ii + 1]); /*overflow checked*/
+ dst_acc *= dst_size[ii + 1];
+ src_acc *= src_size[ii + 1];
dst_start += dst_acc * (dst_offset ? dst_offset[ii] : 0);
src_start += src_acc * (src_offset ? src_offset[ii] : 0);
}
@@ -606,13 +588,12 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size,
H5VM__stride_optimize2(&n, &elmt_size, size, dst_stride, src_stride);
/* Perform the copy in terms of stride */
- ret_value = H5VM_stride_copy(n, elmt_size, size,
- dst_stride, dst+dst_start, src_stride, src+src_start);
+ ret_value =
+ H5VM_stride_copy(n, elmt_size, size, dst_stride, dst + dst_start, src_stride, src + src_start);
FUNC_LEAVE_NOAPI(ret_value)
}
-
/*-------------------------------------------------------------------------
* Function: H5VM_stride_fill
*
@@ -627,15 +608,15 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size,
*-------------------------------------------------------------------------
*/
herr_t
-H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size,
- const hsize_t *stride, void *_dst, unsigned fill_value)
+H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize_t *stride, void *_dst,
+ unsigned fill_value)
{
- uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic */
- hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */
- hsize_t nelmts; /*number of elements to fill */
- hsize_t i; /*counter */
- int j; /*counter */
- hbool_t carry; /*subtraction carray value */
+ uint8_t *dst = (uint8_t *)_dst; /*cast for ptr arithmetic */
+ hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */
+ hsize_t nelmts; /*number of elements to fill */
+ hsize_t i; /*counter */
+ int j; /*counter */
+ hbool_t carry; /*subtraction carray value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -643,13 +624,13 @@ H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size,
H5VM_vector_cpy(n, idx, size);
nelmts = H5VM_vector_reduce_product(n, size);
- for (i=0; i<nelmts; i++) {
+ for (i = 0; i < nelmts; i++) {
/* Copy an element */
- H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
+ H5_CHECK_OVERFLOW(elmt_size, hsize_t, size_t);
HDmemset(dst, (int)fill_value, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
/* Decrement indices and advance pointer */
- for (j=(int)(n-1), carry=TRUE; j>=0 && carry; --j) {
+ for (j = (int)(n - 1), carry = TRUE; j >= 0 && carry; --j) {
dst += stride[j];
if (--idx[j])
@@ -664,7 +645,6 @@ H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size,
FUNC_LEAVE_NOAPI(SUCCEED)
}
-
/*-------------------------------------------------------------------------
* Function: H5VM_stride_copy
*
@@ -685,33 +665,32 @@ H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size,
*-------------------------------------------------------------------------
*/
herr_t
-H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size,
- const hsize_t *dst_stride, void *_dst,
- const hsize_t *src_stride, const void *_src)
+H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize_t *dst_stride, void *_dst,
+ const hsize_t *src_stride, const void *_src)
{
- uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic*/
- const uint8_t *src = (const uint8_t*) _src; /*cast for ptr arithmetic*/
- hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */
- hsize_t nelmts; /*num elements to copy */
- hsize_t i; /*counter */
- int j; /*counters */
- hbool_t carry; /*carray for subtraction*/
+ uint8_t * dst = (uint8_t *)_dst; /*cast for ptr arithmetic*/
+ const uint8_t *src = (const uint8_t *)_src; /*cast for ptr arithmetic*/
+ hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */
+ hsize_t nelmts; /*num elements to copy */
+ hsize_t i; /*counter */
+ int j; /*counters */
+ hbool_t carry; /*carray for subtraction*/
FUNC_ENTER_NOAPI_NOINIT_NOERR
- HDassert(elmt_size<SIZET_MAX);
+ HDassert(elmt_size < SIZET_MAX);
if (n) {
H5VM_vector_cpy(n, idx, size);
nelmts = H5VM_vector_reduce_product(n, size);
- for (i=0; i<nelmts; i++) {
+ for (i = 0; i < nelmts; i++) {
/* Copy an element */
- H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
+ H5_CHECK_OVERFLOW(elmt_size, hsize_t, size_t);
H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
/* Decrement indices and advance pointers */
- for (j=(int)(n-1), carry=TRUE; j>=0 && carry; --j) {
+ for (j = (int)(n - 1), carry = TRUE; j >= 0 && carry; --j) {
src += src_stride[j];
dst += dst_stride[j];
@@ -723,15 +702,15 @@ H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size,
}
}
}
- } else {
- H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
- H5MM_memcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
+ }
+ else {
+ H5_CHECK_OVERFLOW(elmt_size, hsize_t, size_t);
+ H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
}
FUNC_LEAVE_NOAPI(SUCCEED)
}
-
/*-------------------------------------------------------------------------
* Function: H5VM_stride_copy_s
*
@@ -752,33 +731,32 @@ H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size,
*-------------------------------------------------------------------------
*/
herr_t
-H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size,
- const hssize_t *dst_stride, void *_dst,
- const hssize_t *src_stride, const void *_src)
+H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size, const hssize_t *dst_stride, void *_dst,
+ const hssize_t *src_stride, const void *_src)
{
- uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic*/
- const uint8_t *src = (const uint8_t*) _src; /*cast for ptr arithmetic*/
- hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */
- hsize_t nelmts; /*num elements to copy */
- hsize_t i; /*counter */
- int j; /*counters */
- hbool_t carry; /*carray for subtraction*/
+ uint8_t * dst = (uint8_t *)_dst; /*cast for ptr arithmetic*/
+ const uint8_t *src = (const uint8_t *)_src; /*cast for ptr arithmetic*/
+ hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */
+ hsize_t nelmts; /*num elements to copy */
+ hsize_t i; /*counter */
+ int j; /*counters */
+ hbool_t carry; /*carray for subtraction*/
FUNC_ENTER_NOAPI_NOINIT_NOERR
- HDassert(elmt_size<SIZET_MAX);
+ HDassert(elmt_size < SIZET_MAX);
if (n) {
H5VM_vector_cpy(n, idx, size);
nelmts = H5VM_vector_reduce_product(n, size);
- for (i=0; i<nelmts; i++) {
+ for (i = 0; i < nelmts; i++) {
/* Copy an element */
- H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
+ H5_CHECK_OVERFLOW(elmt_size, hsize_t, size_t);
H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
/* Decrement indices and advance pointers */
- for (j=(int)(n-1), carry=TRUE; j>=0 && carry; --j) {
+ for (j = (int)(n - 1), carry = TRUE; j >= 0 && carry; --j) {
src += src_stride[j];
dst += dst_stride[j];
@@ -790,16 +768,17 @@ H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size,
}
}
}
- } else {
- H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
- H5MM_memcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
+ }
+ else {
+ H5_CHECK_OVERFLOW(elmt_size, hsize_t, size_t);
+ H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
}
FUNC_LEAVE_NOAPI(SUCCEED)
}
#ifdef LATER
-
+
/*-------------------------------------------------------------------------
* Function: H5VM__stride_copy2
*
@@ -818,65 +797,60 @@ H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size,
static void
H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size,
- /* destination */
- unsigned dst_n, const hsize_t *dst_size,
- const hsize_t *dst_stride,
- void *_dst,
+ /* destination */
+ unsigned dst_n, const hsize_t *dst_size, const hsize_t *dst_stride, void *_dst,
- /* source */
- unsigned src_n, const hsize_t *src_size,
- const hsize_t *src_stride,
- const void *_src)
+ /* source */
+ unsigned src_n, const hsize_t *src_size, const hsize_t *src_stride, const void *_src)
{
- uint8_t *dst = (uint8_t *) _dst;
- const uint8_t *src = (const uint8_t *) _src;
- hsize_t dst_idx[H5VM_HYPER_NDIMS];
- hsize_t src_idx[H5VM_HYPER_NDIMS];
- hsize_t i; /* Local index variable */
- int j; /* Local index variable */
- hbool_t carry;
+ uint8_t * dst = (uint8_t *)_dst;
+ const uint8_t *src = (const uint8_t *)_src;
+ hsize_t dst_idx[H5VM_HYPER_NDIMS];
+ hsize_t src_idx[H5VM_HYPER_NDIMS];
+ hsize_t i; /* Local index variable */
+ int j; /* Local index variable */
+ hbool_t carry;
FUNC_ENTER_STATIC_NOERR
HDassert(elmt_size < SIZET_MAX);
- HDassert(dst_n>0);
- HDassert(src_n>0);
+ HDassert(dst_n > 0);
+ HDassert(src_n > 0);
H5VM_vector_cpy(dst_n, dst_idx, dst_size);
H5VM_vector_cpy(src_n, src_idx, src_size);
- for (i=0; i<nelmts; i++) {
+ for (i = 0; i < nelmts; i++) {
- /* Copy an element */
- H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
- H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
+ /* Copy an element */
+ H5_CHECK_OVERFLOW(elmt_size, hsize_t, size_t);
+ H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
- /* Decrement indices and advance pointers */
- for (j=(int)(dst_n-1), carry=TRUE; j>=0 && carry; --j) {
- dst += dst_stride[j];
- if (--dst_idx[j])
+ /* Decrement indices and advance pointers */
+ for (j = (int)(dst_n - 1), carry = TRUE; j >= 0 && carry; --j) {
+ dst += dst_stride[j];
+ if (--dst_idx[j])
carry = FALSE;
- else {
+ else {
HDassert(dst_size);
dst_idx[j] = dst_size[j];
} /* end else */
- }
- for (j=(int)(src_n-1), carry=TRUE; j>=0 && carry; --j) {
- src += src_stride[j];
- if (--src_idx[j])
+ }
+ for (j = (int)(src_n - 1), carry = TRUE; j >= 0 && carry; --j) {
+ src += src_stride[j];
+ if (--src_idx[j])
carry = FALSE;
- else {
+ else {
HDassert(src_size);
src_idx[j] = src_size[j];
} /* end else */
- }
+ }
}
FUNC_LEAVE_NOAPI_VOID
}
#endif /* LATER */
-
/*-------------------------------------------------------------------------
* Function: H5VM_array_fill
*
@@ -894,10 +868,10 @@ H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size,
herr_t
H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count)
{
- size_t copy_size; /* size of the buffer to copy */
- size_t copy_items; /* number of items currently copying*/
- size_t items_left; /* number of items left to copy */
- uint8_t *dst=(uint8_t*)_dst;/* alias for pointer arithmetic */
+ size_t copy_size; /* size of the buffer to copy */
+ size_t copy_items; /* number of items currently copying*/
+ size_t items_left; /* number of items left to copy */
+ uint8_t *dst = (uint8_t *)_dst; /* alias for pointer arithmetic */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -906,31 +880,29 @@ H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count)
HDassert(size < SIZET_MAX && size > 0);
HDassert(count < SIZET_MAX && count > 0);
- H5MM_memcpy(dst, src, size); /* copy first item */
+ H5MM_memcpy(dst, src, size); /* copy first item */
/* Initialize counters, etc. while compensating for first element copied */
- copy_size = size;
+ copy_size = size;
copy_items = 1;
items_left = count - 1;
dst += size;
/* copy until we've copied at least half of the items */
- while (items_left >= copy_items)
- {
- H5MM_memcpy(dst, _dst, copy_size); /* copy the current chunk */
- dst += copy_size; /* move the offset for the next chunk */
- items_left -= copy_items; /* decrement the number of items left */
-
- copy_size *= 2; /* increase the size of the chunk to copy */
- copy_items *= 2; /* increase the count of items we are copying */
- } /* end while */
- if (items_left > 0) /* if there are any items left to copy */
+ while (items_left >= copy_items) {
+ H5MM_memcpy(dst, _dst, copy_size); /* copy the current chunk */
+ dst += copy_size; /* move the offset for the next chunk */
+ items_left -= copy_items; /* decrement the number of items left */
+
+ copy_size *= 2; /* increase the size of the chunk to copy */
+ copy_items *= 2; /* increase the count of items we are copying */
+ } /* end while */
+ if (items_left > 0) /* if there are any items left to copy */
H5MM_memcpy(dst, _dst, items_left * size);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5VM_array_fill() */
+} /* H5VM_array_fill() */
-
/*-------------------------------------------------------------------------
* Function: H5VM_array_down
*
@@ -949,8 +921,8 @@ H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count)
herr_t
H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down)
{
- hsize_t acc; /*accumulator */
- int i; /*counter */
+ hsize_t acc; /*accumulator */
+ int i; /*counter */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -960,15 +932,14 @@ H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down)
/* Build the sizes of each dimension in the array */
/* (From fastest to slowest) */
- for(i=(int)(n-1),acc=1; i>=0; i--) {
- down[i]=acc;
+ for (i = (int)(n - 1), acc = 1; i >= 0; i--) {
+ down[i] = acc;
acc *= total_size[i];
} /* end for */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5VM_array_down() */
-
/*-------------------------------------------------------------------------
* Function: H5VM_array_offset_pre
*
@@ -990,8 +961,8 @@ H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down)
hsize_t
H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset)
{
- unsigned u; /* Local index variable */
- hsize_t ret_value; /* Return value */
+ unsigned u; /* Local index variable */
+ hsize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -1000,13 +971,12 @@ H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset)
HDassert(offset);
/* Compute offset in array */
- for(u = 0, ret_value = 0; u < n; u++)
+ for (u = 0, ret_value = 0; u < n; u++)
ret_value += acc[u] * offset[u];
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VM_array_offset_pre() */
-
/*-------------------------------------------------------------------------
* Function: H5VM_array_offset
*
@@ -1028,8 +998,8 @@ H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset)
hsize_t
H5VM_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset)
{
- hsize_t acc_arr[H5VM_HYPER_NDIMS]; /* Accumulated size of down dimensions */
- hsize_t ret_value; /* Return value */
+ hsize_t acc_arr[H5VM_HYPER_NDIMS]; /* Accumulated size of down dimensions */
+ hsize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI((HDabort(), 0)) /*lint !e527 Don't worry about unreachable statement */
@@ -1038,17 +1008,16 @@ H5VM_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset)
HDassert(offset);
/* Build the sizes of each dimension in the array */
- if(H5VM_array_down(n,total_size,acc_arr)<0)
+ if (H5VM_array_down(n, total_size, acc_arr) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, UFAIL, "can't compute down sizes")
/* Set return value */
- ret_value=H5VM_array_offset_pre(n,acc_arr,offset);
+ ret_value = H5VM_array_offset_pre(n, acc_arr, offset);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VM_array_offset() */
-
/*-------------------------------------------------------------------------
* Function: H5VM_array_calc_pre
*
@@ -1068,10 +1037,9 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down,
- hsize_t *coords)
+H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, hsize_t *coords)
{
- unsigned u; /* Local index variable */
+ unsigned u; /* Local index variable */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -1080,7 +1048,7 @@ H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down,
HDassert(coords);
/* Compute the coordinates from the offset */
- for(u = 0; u < n; u++) {
+ for (u = 0; u < n; u++) {
coords[u] = offset / down[u];
offset %= down[u];
} /* end for */
@@ -1088,7 +1056,6 @@ H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down,
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5VM_array_calc_pre() */
-
/*-------------------------------------------------------------------------
* Function: H5VM_array_calc
*
@@ -1110,8 +1077,8 @@ H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down,
herr_t
H5VM_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t *coords)
{
- hsize_t idx[H5VM_HYPER_NDIMS]; /* Size of each dimension in bytes */
- herr_t ret_value = SUCCEED; /* Return value */
+ hsize_t idx[H5VM_HYPER_NDIMS]; /* Size of each dimension in bytes */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1121,18 +1088,17 @@ H5VM_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t *
HDassert(coords);
/* Build the sizes of each dimension in the array */
- if(H5VM_array_down(n, total_size, idx) < 0)
+ if (H5VM_array_down(n, total_size, idx) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute down sizes")
/* Compute the coordinates from the offset */
- if(H5VM_array_calc_pre(offset, n, idx, coords) < 0)
+ if (H5VM_array_calc_pre(offset, n, idx, coords) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute coordinates")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VM_array_calc() */
-
/*-------------------------------------------------------------------------
* Function: H5VM_chunk_index
*
@@ -1174,11 +1140,10 @@ done:
*-------------------------------------------------------------------------
*/
hsize_t
-H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk,
- const hsize_t *down_nchunks)
+H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, const hsize_t *down_nchunks)
{
- hsize_t scaled_coord[H5VM_HYPER_NDIMS]; /* Scaled, coordinates, in terms of chunks */
- hsize_t chunk_idx; /* Chunk index computed */
+ hsize_t scaled_coord[H5VM_HYPER_NDIMS]; /* Scaled, coordinates, in terms of chunks */
+ hsize_t chunk_idx; /* Chunk index computed */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -1194,7 +1159,6 @@ H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk,
FUNC_LEAVE_NOAPI(chunk_idx)
} /* end H5VM_chunk_index() */
-
/*-------------------------------------------------------------------------
* Function: H5VM_chunk_scaled
*
@@ -1208,10 +1172,9 @@ H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk,
*-------------------------------------------------------------------------
*/
void
-H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk,
- hsize_t *scaled)
+H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, hsize_t *scaled)
{
- unsigned u; /* Local index variable */
+ unsigned u; /* Local index variable */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -1223,13 +1186,12 @@ H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk,
/* Compute the scaled coordinates for actual coordinates */
/* (Note that the 'scaled' array is an 'OUT' parameter) */
- for(u = 0; u < ndims; u++)
+ for (u = 0; u < ndims; u++)
scaled[u] = coord[u] / chunk[u];
FUNC_LEAVE_NOAPI_VOID
} /* end H5VM_chunk_scaled() */
-
/*-------------------------------------------------------------------------
* Function: H5VM_chunk_index_scaled
*
@@ -1275,10 +1237,10 @@ H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk,
*/
hsize_t
H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk,
- const hsize_t *down_nchunks, hsize_t *scaled)
+ const hsize_t *down_nchunks, hsize_t *scaled)
{
- hsize_t chunk_idx; /* Computed chunk index */
- unsigned u; /* Local index variable */
+ hsize_t chunk_idx; /* Computed chunk index */
+ unsigned u; /* Local index variable */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -1291,16 +1253,16 @@ H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *ch
/* Compute the scaled coordinates for actual coordinates */
/* (Note that the 'scaled' array is an 'OUT' parameter) */
- for(u = 0; u < ndims; u++)
+ for (u = 0; u < ndims; u++)
scaled[u] = coord[u] / chunk[u];
/* Compute the chunk index */
- chunk_idx = H5VM_array_offset_pre(ndims, down_nchunks, scaled); /*lint !e772 scaled_coord will always be initialized */
+ chunk_idx = H5VM_array_offset_pre(ndims, down_nchunks,
+ scaled); /*lint !e772 scaled_coord will always be initialized */
FUNC_LEAVE_NOAPI(chunk_idx)
} /* end H5VM_chunk_index_scaled() */
-
/*-------------------------------------------------------------------------
* Function: H5VM_opvv
*
@@ -1324,19 +1286,17 @@ H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *ch
*-------------------------------------------------------------------------
*/
ssize_t
-H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[],
- hsize_t dst_off_arr[],
- size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[],
- hsize_t src_off_arr[],
- H5VM_opvv_func_t op, void *op_data)
+H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize_t dst_off_arr[],
+ size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[],
+ H5VM_opvv_func_t op, void *op_data)
{
- hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */
- hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */
- size_t *dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */
- hsize_t tmp_dst_off, tmp_src_off; /* Temporary source and destination offset values */
- size_t tmp_dst_len, tmp_src_len; /* Temporary source and destination length values */
- size_t acc_len; /* Accumulated length of sequences */
- ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */
+ hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */
+ hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */
+ size_t * dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */
+ hsize_t tmp_dst_off, tmp_src_off; /* Temporary source and destination offset values */
+ size_t tmp_dst_len, tmp_src_len; /* Temporary source and destination length values */
+ size_t acc_len; /* Accumulated length of sequences */
+ ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */
FUNC_ENTER_NOAPI(FAIL)
@@ -1367,16 +1327,16 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[],
max_dst_off_ptr = dst_off_arr + dst_max_nseq;
max_src_off_ptr = src_off_arr + src_max_nseq;
-/* Work through the sequences */
-/* (Choose smallest sequence available initially) */
+ /* Work through the sequences */
+ /* (Choose smallest sequence available initially) */
/* Source sequence is less than destination sequence */
- if(tmp_src_len < tmp_dst_len) {
+ if (tmp_src_len < tmp_dst_len) {
src_smaller:
acc_len = 0;
do {
/* Make operator callback */
- if((*op)(tmp_dst_off, tmp_src_off, tmp_src_len, op_data) < 0)
+ if ((*op)(tmp_dst_off, tmp_src_off, tmp_src_len, op_data) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTOPERATE, FAIL, "can't perform operation")
/* Accumulate number of bytes copied */
@@ -1388,7 +1348,7 @@ src_smaller:
/* Advance source offset & check for being finished */
src_off_ptr++;
- if(src_off_ptr >= max_src_off_ptr) {
+ if (src_off_ptr >= max_src_off_ptr) {
/* Roll accumulated changes into appropriate counters */
*dst_off_ptr = tmp_dst_off;
*dst_len_ptr = tmp_dst_len;
@@ -1401,24 +1361,24 @@ src_smaller:
/* Update source information */
src_len_ptr++;
tmp_src_len = *src_len_ptr;
- } while(tmp_src_len < tmp_dst_len);
+ } while (tmp_src_len < tmp_dst_len);
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Transition to next state */
- if(tmp_dst_len < tmp_src_len)
+ if (tmp_dst_len < tmp_src_len)
goto dst_smaller;
else
goto equal;
} /* end if */
/* Destination sequence is less than source sequence */
- else if(tmp_dst_len < tmp_src_len) {
+ else if (tmp_dst_len < tmp_src_len) {
dst_smaller:
acc_len = 0;
do {
/* Make operator callback */
- if((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0)
+ if ((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTOPERATE, FAIL, "can't perform operation")
/* Accumulate number of bytes copied */
@@ -1430,7 +1390,7 @@ dst_smaller:
/* Advance destination offset & check for being finished */
dst_off_ptr++;
- if(dst_off_ptr >= max_dst_off_ptr) {
+ if (dst_off_ptr >= max_dst_off_ptr) {
/* Roll accumulated changes into appropriate counters */
*src_off_ptr = tmp_src_off;
*src_len_ptr = tmp_src_len;
@@ -1443,13 +1403,13 @@ dst_smaller:
/* Update destination information */
dst_len_ptr++;
tmp_dst_len = *dst_len_ptr;
- } while(tmp_dst_len < tmp_src_len);
+ } while (tmp_dst_len < tmp_src_len);
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Transition to next state */
- if(tmp_src_len < tmp_dst_len)
+ if (tmp_src_len < tmp_dst_len)
goto src_smaller;
else
goto equal;
@@ -1460,7 +1420,7 @@ equal:
acc_len = 0;
do {
/* Make operator callback */
- if((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0)
+ if ((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTOPERATE, FAIL, "can't perform operation")
/* Accumulate number of bytes copied */
@@ -1469,7 +1429,7 @@ equal:
/* Advance source & destination offset & check for being finished */
src_off_ptr++;
dst_off_ptr++;
- if(src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr)
+ if (src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr)
/* Done with sequences */
goto finished;
tmp_src_off = *src_off_ptr;
@@ -1482,13 +1442,13 @@ equal:
/* Update destination information */
dst_len_ptr++;
tmp_dst_len = *dst_len_ptr;
- } while(tmp_dst_len == tmp_src_len);
+ } while (tmp_dst_len == tmp_src_len);
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Transition to next state */
- if(tmp_dst_len < tmp_src_len)
+ if (tmp_dst_len < tmp_src_len)
goto dst_smaller;
else
goto src_smaller;
@@ -1506,7 +1466,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VM_opvv() */
-
/*-------------------------------------------------------------------------
* Function: H5VM_memcpyvv
*
@@ -1531,20 +1490,19 @@ done:
*-------------------------------------------------------------------------
*/
ssize_t
-H5VM_memcpyvv(void *_dst,
- size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize_t dst_off_arr[],
- const void *_src,
- size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[])
+H5VM_memcpyvv(void *_dst, size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[],
+ hsize_t dst_off_arr[], const void *_src, size_t src_max_nseq, size_t *src_curr_seq,
+ size_t src_len_arr[], hsize_t src_off_arr[])
{
- unsigned char *dst; /* Destination buffer pointer */
- const unsigned char *src; /* Source buffer pointer */
- hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */
- hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */
- size_t *dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */
- size_t tmp_dst_len; /* Temporary dest. length value */
- size_t tmp_src_len; /* Temporary source length value */
- size_t acc_len; /* Accumulated length of sequences */
- ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */
+ unsigned char * dst; /* Destination buffer pointer */
+ const unsigned char *src; /* Source buffer pointer */
+ hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */
+ hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */
+ size_t * dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */
+ size_t tmp_dst_len; /* Temporary dest. length value */
+ size_t tmp_src_len; /* Temporary source length value */
+ size_t acc_len; /* Accumulated length of sequences */
+ ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -1578,11 +1536,11 @@ H5VM_memcpyvv(void *_dst,
dst = (unsigned char *)_dst + *dst_off_ptr;
src = (const unsigned char *)_src + *src_off_ptr;
-/* Work through the sequences */
-/* (Choose smallest sequence available initially) */
+ /* Work through the sequences */
+ /* (Choose smallest sequence available initially) */
/* Source sequence is less than destination sequence */
- if(tmp_src_len < tmp_dst_len) {
+ if (tmp_src_len < tmp_dst_len) {
src_smaller:
acc_len = 0;
do {
@@ -1597,7 +1555,7 @@ src_smaller:
/* Advance source offset & check for being finished */
src_off_ptr++;
- if(src_off_ptr >= max_src_off_ptr) {
+ if (src_off_ptr >= max_src_off_ptr) {
/* Roll accumulated changes into appropriate counters */
*dst_off_ptr += acc_len;
*dst_len_ptr = tmp_dst_len;
@@ -1612,20 +1570,20 @@ src_smaller:
/* Update source information */
src_len_ptr++;
tmp_src_len = *src_len_ptr;
- src = (const unsigned char *)_src + *src_off_ptr;
- } while(tmp_src_len < tmp_dst_len);
+ src = (const unsigned char *)_src + *src_off_ptr;
+ } while (tmp_src_len < tmp_dst_len);
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Transition to next state */
- if(tmp_dst_len < tmp_src_len)
+ if (tmp_dst_len < tmp_src_len)
goto dst_smaller;
else
goto equal;
} /* end if */
/* Destination sequence is less than source sequence */
- else if(tmp_dst_len < tmp_src_len) {
+ else if (tmp_dst_len < tmp_src_len) {
dst_smaller:
acc_len = 0;
do {
@@ -1640,7 +1598,7 @@ dst_smaller:
/* Advance destination offset & check for being finished */
dst_off_ptr++;
- if(dst_off_ptr >= max_dst_off_ptr) {
+ if (dst_off_ptr >= max_dst_off_ptr) {
/* Roll accumulated changes into appropriate counters */
*src_off_ptr += acc_len;
*src_len_ptr = tmp_src_len;
@@ -1655,14 +1613,14 @@ dst_smaller:
/* Update destination information */
dst_len_ptr++;
tmp_dst_len = *dst_len_ptr;
- dst = (unsigned char *)_dst + *dst_off_ptr;
- } while(tmp_dst_len < tmp_src_len);
+ dst = (unsigned char *)_dst + *dst_off_ptr;
+ } while (tmp_dst_len < tmp_src_len);
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Transition to next state */
- if(tmp_src_len < tmp_dst_len)
+ if (tmp_src_len < tmp_dst_len)
goto src_smaller;
else
goto equal;
@@ -1681,26 +1639,26 @@ equal:
/* Advance source & destination offset & check for being finished */
src_off_ptr++;
dst_off_ptr++;
- if(src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr)
+ if (src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr)
/* Done with sequences */
goto finished;
/* Update source information */
src_len_ptr++;
tmp_src_len = *src_len_ptr;
- src = (const unsigned char *)_src + *src_off_ptr;
+ src = (const unsigned char *)_src + *src_off_ptr;
/* Update destination information */
dst_len_ptr++;
tmp_dst_len = *dst_len_ptr;
- dst = (unsigned char *)_dst + *dst_off_ptr;
- } while(tmp_dst_len == tmp_src_len);
+ dst = (unsigned char *)_dst + *dst_off_ptr;
+ } while (tmp_dst_len == tmp_src_len);
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Transition to next state */
- if(tmp_dst_len < tmp_src_len)
+ if (tmp_dst_len < tmp_src_len)
goto dst_smaller;
else
goto src_smaller;
@@ -1716,4 +1674,3 @@ finished:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VM_memcpyvv() */
-