summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5.c53
-rw-r--r--src/H5Odtype.c12
-rw-r--r--src/H5S.c3
-rw-r--r--src/H5Sselect.c2
-rw-r--r--src/H5T.c116
-rw-r--r--src/H5Tconv.c98
-rw-r--r--src/H5Tpkg.h1
-rw-r--r--src/H5Tprivate.h3
-rw-r--r--src/H5Tpublic.h3
9 files changed, 233 insertions, 58 deletions
diff --git a/src/H5.c b/src/H5.c
index dd185b1..c521ea0 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -53,6 +53,7 @@ FILE *fdopen(int fd, const char *mode);
#include <H5Iprivate.h> /*atoms */
#include <H5MMprivate.h> /*memory management */
#include <H5Pprivate.h> /*property lists */
+#include <H5Sprivate.h> /*data spaces */
#include <H5Tprivate.h> /*data types */
#include <H5Zprivate.h> /*compression */
@@ -1518,6 +1519,58 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...)
}
break;
+ case 'S':
+ switch (type[1]) {
+ case 'c':
+ if (ptr) {
+ fprintf(out, "0x%lx", (unsigned long)vp);
+ } else {
+ H5S_class_t cls = va_arg(ap, H5S_class_t);
+ switch (cls) {
+ case H5S_NO_CLASS:
+ fprintf(out, "H5S_NO_CLASS");
+ break;
+ case H5S_SCALAR:
+ fprintf(out, "H5S_SCALAR");
+ break;
+ case H5S_SIMPLE:
+ fprintf(out, "H5S_SIMPLE");
+ break;
+ case H5S_COMPLEX:
+ fprintf(out, "H5S_COMPLEX");
+ break;
+ default:
+ fprintf(out, "%ld", (long)cls);
+ break;
+ }
+ }
+ break;
+
+ case 's':
+ if (ptr) {
+ fprintf(out, "0x%lx", (unsigned long)vp);
+ } else {
+ H5S_seloper_t so = va_arg(ap, H5S_seloper_t);
+ switch (so) {
+ case H5S_NOOP:
+ fprintf(out, "H5S_NOOP");
+ break;
+ case H5S_SELECT_SET:
+ fprintf(out, "H5S_SELECT_SET");
+ break;
+ default:
+ fprintf(out, "%ld", (long)so);
+ break;
+ }
+ }
+ break;
+
+ default:
+ fprintf(out, "BADTYPE(F%c)", type[1]);
+ goto error;
+ }
+ break;
+
case 't':
if (ptr) {
fprintf (out, "0x%lx", (unsigned long)vp);
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 6ff75d9..aefa335 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -160,14 +160,16 @@ H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt)
dt->u.compnd.nmembs = flags & 0xffff;
assert(dt->u.compnd.nmembs > 0);
dt->u.compnd.nalloc = dt->u.compnd.nmembs;
- dt->u.compnd.memb = H5MM_calloc(dt->u.compnd.nalloc*sizeof(H5T_member_t));
+ dt->u.compnd.memb = H5MM_calloc(dt->u.compnd.nalloc*
+ sizeof(H5T_member_t));
if (NULL==dt->u.compnd.memb) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
for (i = 0; i < dt->u.compnd.nmembs; i++) {
dt->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp);
- *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8; /*multiple of 8 w/ null terminator */
+ /*multiple of 8 w/ null terminator */
+ *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8;
UINT32DECODE(*pp, dt->u.compnd.memb[i].offset);
dt->u.compnd.memb[i].ndims = *(*pp)++;
assert(dt->u.compnd.memb[i].ndims <= 4);
@@ -194,6 +196,12 @@ H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt)
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL,
"can't decode member type");
}
+
+ /* Total member size */
+ dt->u.compnd.memb[i].size = dt->u.compnd.memb[i].type->size;
+ for (j=0; j<dt->u.compnd.memb[i].ndims; j++) {
+ dt->u.compnd.memb[i].size *= dt->u.compnd.memb[i].dim[j];
+ }
}
break;
diff --git a/src/H5S.c b/src/H5S.c
index 89d4c92..27ac7d9 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -138,12 +138,13 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
hid_t
-H5Screate(H5S_class_t type)
+H5Screate (H5S_class_t type)
{
H5S_t *new_ds=NULL;
hid_t ret_value = FAIL;
FUNC_ENTER(H5Screate, FAIL);
+ H5TRACE1("i","Sc",type);
/* Check args */
if(type<=H5S_NO_CLASS || type> H5S_SIMPLE) /* don't allow complex dataspace yet */
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 4763149..8c45deb 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -192,6 +192,7 @@ H5Sselect_hyperslab (hid_t spaceid, H5S_seloper_t op,
herr_t ret_value=FAIL; /* return value */
FUNC_ENTER (H5Sselect_hyperslab, FAIL);
+ H5TRACE6("e","iSs*Hs*h*h*h",spaceid,op,start,_stride,count,_block);
/* Check args */
if (H5_DATASPACE != H5I_group(spaceid) ||
@@ -332,6 +333,7 @@ H5Sselect_npoints (hid_t spaceid)
hsize_t ret_value=0; /* return value */
FUNC_ENTER (H5Sselect_npoints, 0);
+ H5TRACE1("h","i",spaceid);
/* Check args */
if (H5_DATASPACE != H5I_group(spaceid) ||
diff --git a/src/H5T.c b/src/H5T.c
index d9280eb..07bc062 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -2761,7 +2761,79 @@ H5Tinsert (hid_t parent_id, const char *name, size_t offset, hid_t member_id)
}
/* Insert */
- if (H5T_insert(parent, name, offset, member) < 0) {
+ if (H5T_insert(parent, name, offset, 0, NULL, NULL, member) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
+ "can't insert member");
+ }
+
+ FUNC_LEAVE(SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tinsert_array
+ *
+ * Purpose: Adds another member to the compound data type PARENT_ID. The
+ * new member has a NAME which must be unique within the
+ * compound data type. The OFFSET argument defines the start of
+ * the member in an instance of the compound data type and
+ * MEMBER_ID is the type of the new member. The member is an
+ * array with NDIMS dimensionality and the size of the array is
+ * DIMS. The total member size should be relatively small.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, July 7, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Tinsert_array (hid_t parent_id, const char *name, size_t offset,
+ int ndims, const size_t *dim, const int *perm,
+ hid_t member_id)
+{
+ H5T_t *parent = NULL; /*the compound parent data type */
+ H5T_t *member = NULL; /*the atomic member type */
+ intn i;
+
+ FUNC_ENTER(H5Tinsert_array, FAIL);
+ H5TRACE7("e","iszIs*z*Isi",parent_id,name,offset,ndims,dim,perm,member_id);
+
+ /* Check args */
+ if (H5_DATATYPE != H5I_group(parent_id) ||
+ NULL == (parent = H5I_object(parent_id)) ||
+ H5T_COMPOUND != parent->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
+ }
+ if (H5T_STATE_TRANSIENT!=parent->state) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only");
+ }
+ if (!name || !*name) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name");
+ }
+ if (ndims<1 || ndims>4) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimensionality");
+ }
+ if (!dim) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified");
+ }
+ for (i=0; i<ndims; i++) {
+ if (dim[i]<1) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimension");
+ }
+ }
+ if (H5_DATATYPE != H5I_group(member_id) ||
+ NULL == (member = H5I_object(member_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+
+ /* Insert */
+ if (H5T_insert(parent, name, offset, ndims, dim, perm, member) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
"can't insert member");
}
@@ -3781,9 +3853,12 @@ H5T_get_size(const H5T_t *dt)
*-------------------------------------------------------------------------
*/
herr_t
-H5T_insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
+H5T_insert(H5T_t *parent, const char *name, size_t offset, intn ndims,
+ const size_t *dim, const intn *perm, const H5T_t *member)
{
- intn i;
+ intn idx, i;
+ size_t total_size;
+
FUNC_ENTER(H5T_insert, FAIL);
@@ -3794,7 +3869,7 @@ H5T_insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
assert(name && *name);
/* Does NAME already exist in PARENT? */
- for (i = 0; i < parent->u.compnd.nmembs; i++) {
+ for (i=0; i<parent->u.compnd.nmembs; i++) {
if (!HDstrcmp(parent->u.compnd.memb[i].name, name)) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
"member name is not unique");
@@ -3802,12 +3877,13 @@ H5T_insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
}
/* Does the new member overlap any existing member ? */
- for (i = 0; i < parent->u.compnd.nmembs; i++) {
+ for (total_size=member->size, i=0; i<ndims; i++) total_size *= dim[i];
+ for (i=0; i<parent->u.compnd.nmembs; i++) {
if ((offset <= parent->u.compnd.memb[i].offset &&
- offset + member->size > parent->u.compnd.memb[i].offset) ||
+ offset + total_size > parent->u.compnd.memb[i].offset) ||
(parent->u.compnd.memb[i].offset <= offset &&
parent->u.compnd.memb[i].offset +
- parent->u.compnd.memb[i].type->size > offset)) {
+ parent->u.compnd.memb[i].size > offset)) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
"member overlaps with another member");
}
@@ -3827,11 +3903,16 @@ H5T_insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
}
/* Add member to end of member array */
- i = parent->u.compnd.nmembs;
- parent->u.compnd.memb[i].name = H5MM_xstrdup(name);
- parent->u.compnd.memb[i].offset = offset;
- parent->u.compnd.memb[i].ndims = 0; /*defaults to scalar */
- parent->u.compnd.memb[i].type = H5T_copy (member, H5T_COPY_ALL);
+ idx = parent->u.compnd.nmembs;
+ parent->u.compnd.memb[idx].name = H5MM_xstrdup(name);
+ parent->u.compnd.memb[idx].offset = offset;
+ parent->u.compnd.memb[idx].size = total_size;
+ parent->u.compnd.memb[idx].ndims = ndims;
+ parent->u.compnd.memb[idx].type = H5T_copy (member, H5T_COPY_ALL);
+ for (i=0; i<ndims; i++) {
+ parent->u.compnd.memb[idx].dim[i] = dim[i];
+ parent->u.compnd.memb[idx].perm[i] = perm?perm[i]:i;
+ }
parent->u.compnd.nmembs++;
FUNC_LEAVE(SUCCEED);
@@ -3868,7 +3949,7 @@ H5T_pack(H5T_t *dt)
if (H5T_COMPOUND == dt->type) {
/* Recursively pack the members */
- for (i = 0; i < dt->u.compnd.nmembs; i++) {
+ for (i=0; i<dt->u.compnd.nmembs; i++) {
if (H5T_pack(dt->u.compnd.memb[i].type) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to pack part of a compound data type");
@@ -3877,9 +3958,9 @@ H5T_pack(H5T_t *dt)
/* Remove padding between members */
H5T_sort_by_offset(dt);
- for (i = 0, offset = 0; i < dt->u.compnd.nmembs; i++) {
+ for (i=0, offset=0; i<dt->u.compnd.nmembs; i++) {
dt->u.compnd.memb[i].offset = offset;
- offset += H5T_get_size (dt->u.compnd.memb[i].type);
+ offset += dt->u.compnd.memb[i].size;
}
/* Change total size */
@@ -4043,6 +4124,11 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
if (dt1->u.compnd.memb[idx1[i]].offset >
dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(1);
+ if (dt1->u.compnd.memb[idx1[i]].size <
+ dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[i]].size >
+ dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(1);
+
if (dt1->u.compnd.memb[idx1[i]].ndims <
dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE(-1);
if (dt1->u.compnd.memb[idx1[i]].ndims >
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 211caf7..966e910 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -23,6 +23,7 @@ typedef struct H5T_conv_struct_t {
hid_t *dst_memb_id; /*destination member type ID's */
H5T_conv_t *memb_conv; /*array of membr conversion functions*/
H5T_cdata_t **memb_cdata; /*array of member cdata pointers */
+ size_t *memb_nelmts; /*member element count */
} H5T_conv_struct_t;
/* Interface initialization */
@@ -268,6 +269,45 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
priv->dst_memb_id[priv->src2dst[i]] = tid;
}
}
+
+ /*
+ * Those members which are in both the source and destination must be
+ * the same size and shape arrays.
+ */
+ for (i=0; i<src->u.compnd.nmembs; i++) {
+ if (priv->src2dst[i]>=0) {
+ H5T_member_t *src_memb = src->u.compnd.memb + i;
+ H5T_member_t *dst_memb = dst->u.compnd.memb + priv->src2dst[i];
+ if (src_memb->ndims != dst_memb->ndims) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "source and dest members have incompatible "
+ "size or shape");
+ }
+ for (j=0; j<src_memb->ndims; j++) {
+ if (src_memb->dim[j] != dst_memb->dim[j]) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "source and dest members have "
+ "incompatible size or shape");
+ }
+#ifndef LATER
+ /* Their permutation vectors must be equal */
+ if (src_memb->perm[j]!=dst_memb->perm[j]) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "member permutations must be equal");
+ }
+#endif
+ }
+ }
+ }
+
+ /* Calculate number of elements of each member */
+ priv->memb_nelmts = H5MM_malloc(src->u.compnd.nmembs*sizeof(size_t));
+ for (i=0; i<src->u.compnd.nmembs; i++) {
+ priv->memb_nelmts[i] = 1;
+ for (j=0; j<src->u.compnd.memb[i].ndims; j++) {
+ priv->memb_nelmts[i] *= src->u.compnd.memb[i].dim[j];
+ }
+ }
}
/*
@@ -374,24 +414,6 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
assert (H5T_COMPOUND==src->type);
assert (H5T_COMPOUND==dst->type);
-#ifndef LATER
- /*
- * Struct members must be scalar for now.
- */
- for (i=0; i<src->u.compnd.nmembs; i++) {
- if (src->u.compnd.memb[i].ndims>0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "array members are not supported yet");
- }
- }
- for (i=0; i<dst->u.compnd.nmembs; i++) {
- if (dst->u.compnd.memb[i].ndims>0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "array members are not supported yet");
- }
- }
-#endif
-
if (H5T_conv_struct_init (src, dst, cdata)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize conversion data");
@@ -402,11 +424,12 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
/*
* Free the private conversion data.
*/
- H5MM_xfree (priv->src2dst);
- H5MM_xfree (priv->src_memb_id);
- H5MM_xfree (priv->dst_memb_id);
- H5MM_xfree (priv->memb_conv);
- H5MM_xfree (priv->memb_cdata);
+ H5MM_xfree(priv->src2dst);
+ H5MM_xfree(priv->src_memb_id);
+ H5MM_xfree(priv->dst_memb_id);
+ H5MM_xfree(priv->memb_conv);
+ H5MM_xfree(priv->memb_cdata);
+ H5MM_xfree(priv->memb_nelmts);
cdata->priv = priv = H5MM_xfree (priv);
break;
@@ -463,25 +486,23 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
- if (H5T_get_size (dst_memb->type) <=
- H5T_get_size (src_memb->type)) {
+ if (dst_memb->size <= src_memb->size) {
H5T_conv_t tconv_func = priv->memb_conv[src2dst[i]];
H5T_cdata_t *memb_cdata = priv->memb_cdata[src2dst[i]];
memb_cdata->command = H5T_CONV_CONV;
(tconv_func)(priv->src_memb_id[src2dst[i]],
priv->dst_memb_id[src2dst[i]],
- memb_cdata,
- 1,
+ memb_cdata, priv->memb_nelmts[i],
buf + src_memb->offset,
bkg + dst_memb->offset);
HDmemmove (buf + offset, buf + src_memb->offset,
- H5T_get_size (dst_memb->type));
- offset += H5T_get_size (dst_memb->type);
+ dst_memb->size);
+ offset += dst_memb->size;
} else {
HDmemmove (buf + offset, buf + src_memb->offset,
- H5T_get_size (src_memb->type));
- offset += H5T_get_size (src_memb->type);
+ src_memb->size);
+ offset += src_memb->size;
}
}
@@ -496,19 +517,18 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
if (src2dst[i]<0) continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
- offset -= H5T_get_size (dst_memb->type);
+ offset -= dst_memb->size;
- if (H5T_get_size (dst_memb->type) >
- H5T_get_size (src_memb->type)) {
+ if (dst_memb->size > src_memb->size) {
H5T_conv_t tconv_func = priv->memb_conv[src2dst[i]];
H5T_cdata_t *memb_cdata = priv->memb_cdata[src2dst[i]];
memb_cdata->command = H5T_CONV_CONV;
(tconv_func)(priv->src_memb_id[src2dst[i]],
- priv->dst_memb_id[src2dst[i]], memb_cdata, 1,
- buf + offset, bkg + dst_memb->offset);
+ priv->dst_memb_id[src2dst[i]],
+ memb_cdata, priv->memb_nelmts[i],
+ buf+offset, bkg+dst_memb->offset);
}
- HDmemmove (bkg+dst_memb->offset, buf+offset,
- H5T_get_size (dst_memb->type));
+ HDmemmove (bkg+dst_memb->offset, buf+offset, dst_memb->size);
}
assert (0==offset);
@@ -935,7 +955,7 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
/* Conversion-related variables */
hssize_t expo; /*exponent */
hssize_t expo_max; /*maximum possible dst exponent */
- size_t msize; /*useful size of mantissa in src*/
+ size_t msize=0; /*useful size of mantissa in src*/
size_t mpos; /*offset to useful mant is src */
size_t mrsh; /*amount to right shift mantissa*/
hbool_t carry; /*carry after rounding mantissa */
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
index e53a5e0..05c36a4 100644
--- a/src/H5Tpkg.h
+++ b/src/H5Tpkg.h
@@ -86,6 +86,7 @@ struct H5T_t {
typedef struct H5T_member_t {
char *name; /*name of this member */
size_t offset; /*offset from beginning of struct */
+ size_t size; /*total size: dims * type_size */
intn ndims; /*member dimensionality */
size_t dim[4]; /*size in each dimension */
intn perm[4]; /*index permutation */
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index af3e2a3..a686b59 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -54,7 +54,8 @@ size_t H5T_get_size (const H5T_t *dt);
intn H5T_cmp (const H5T_t *dt1, const H5T_t *dt2);
hbool_t H5T_is_atomic (const H5T_t *dt);
herr_t H5T_insert (H5T_t *parent, const char *name, size_t offset,
- const H5T_t *member);
+ intn ndims, const size_t *dim, const intn *perm,
+ const H5T_t *member);
herr_t H5T_sort_by_offset (H5T_t *dt);
herr_t H5T_pack (H5T_t *dt);
herr_t H5T_debug (H5T_t *dt, FILE * stream);
diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h
index 89491fc..822e053 100644
--- a/src/H5Tpublic.h
+++ b/src/H5Tpublic.h
@@ -342,6 +342,9 @@ hbool_t H5Tcommitted (hid_t type_id);
/* Operations defined on compound data types */
herr_t H5Tinsert (hid_t parent_id, const char *name, size_t offset,
hid_t member_id);
+herr_t H5Tinsert_array (hid_t parent_id, const char *name, size_t offset,
+ int ndims, const size_t *dim, const int *perm,
+ hid_t member_id);
herr_t H5Tpack (hid_t type_id);
/* Querying property values */