[svn-r1836] Mainly fixed a bug in VL datatype comparisons which was causing non-equal

VL types to compare as equal.  Added some asserts to make certain nothing
slips through again.  Also cleaned up a few warnings from the SGI compiler.
This commit is contained in:
Quincey Koziol 1999-11-17 16:59:53 -05:00
parent cd313a1645
commit 9e014467b6
10 changed files with 1211 additions and 1134 deletions

View File

@ -182,7 +182,7 @@ H5FDregister(const H5FD_class_t *cls)
HRETURN_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL,
"`read' and/or `write' method is not defined");
}
for (type=0; type<H5FD_MEM_NTYPES; type++) {
for (type=H5FD_MEM_DEFAULT; type<H5FD_MEM_NTYPES; type++) {
if (cls->fl_map[type]<H5FD_MEM_NOLIST ||
cls->fl_map[type]>=H5FD_MEM_NTYPES) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
@ -856,7 +856,7 @@ H5FD_close(H5FD_t *file)
assert(file && file->cls);
/* Free all free-lists, leaking any memory thus described */
for (i=0; i<H5FD_MEM_NTYPES; i++) {
for (i=H5FD_MEM_DEFAULT; i<H5FD_MEM_NTYPES; i++) {
for (cur=file->fl[i]; cur; cur=next) {
#ifdef H5F_DEBUG
nblocks++;

View File

@ -40,7 +40,7 @@
hbool_t _seen[H5FD_MEM_NTYPES]; \
\
memset(_seen, 0, sizeof _seen); \
for (_unmapped=1; _unmapped<H5FD_MEM_NTYPES; _unmapped++) { \
for (_unmapped=H5FD_MEM_SUPER; _unmapped<H5FD_MEM_NTYPES; _unmapped++) { \
LOOPVAR = MAP[_unmapped]; \
if (H5FD_MEM_DEFAULT==LOOPVAR) LOOPVAR=_unmapped; \
assert(LOOPVAR>0 && LOOPVAR<H5FD_MEM_NTYPES); \
@ -49,14 +49,14 @@
#define MAPPED_MEMBERS(MAP,LOOPVAR) { \
H5FD_mem_t _unmapped, LOOPVAR; \
\
for (_unmapped=1; _unmapped<H5FD_MEM_NTYPES; _unmapped++) { \
for (_unmapped=H5FD_MEM_SUPER; _unmapped<H5FD_MEM_NTYPES; _unmapped++) { \
LOOPVAR = MAP[_unmapped]; \
if (H5FD_MEM_DEFAULT==LOOPVAR) LOOPVAR=_unmapped; \
assert(LOOPVAR>0 && LOOPVAR<H5FD_MEM_NTYPES);
#define ALL_MEMBERS(LOOPVAR) { \
H5FD_mem_t LOOPVAR; \
for (LOOPVAR=0; LOOPVAR<H5FD_MEM_NTYPES; LOOPVAR++) {
for (LOOPVAR=H5FD_MEM_DEFAULT; LOOPVAR<H5FD_MEM_NTYPES; LOOPVAR++) {
#define END_MEMBERS }}
@ -247,7 +247,7 @@ H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id,
H5Eclear();
/* Initialize */
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
memb_map[mt] = (H5FD_MEM_DRAW==mt?mt:H5FD_MEM_SUPER);
memb_fapl[mt] = -1;
memb_name[mt] = NULL;
@ -375,33 +375,33 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map,
if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "not a file access property list", -1);
if (!memb_map) {
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
_memb_map[mt] = H5FD_MEM_DEFAULT;
}
memb_map = _memb_map;
}
if (!memb_fapl) {
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
_memb_fapl[mt] = H5P_DEFAULT;
}
memb_fapl = _memb_fapl;
}
if (!memb_name) {
assert(strlen(letters)==H5FD_MEM_NTYPES);
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
sprintf(_memb_name[mt], "%%s-%c.h5", letters[mt]);
_memb_name_ptrs[mt] = _memb_name[mt];
}
memb_name = _memb_name_ptrs;
}
if (!memb_addr) {
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
_memb_addr[mt] = (mt?mt-1:0) * HADDR_MAX/H5FD_MEM_NTYPES;
}
memb_addr = _memb_addr;
}
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
/* Map usage type */
mmt = memb_map[mt];
if (mmt<0 || mmt>=H5FD_MEM_NTYPES)
@ -476,7 +476,7 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/,
memcpy(memb_map, fa->memb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t));
}
if (memb_fapl) {
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (fa->memb_fapl[mt]>=0) {
memb_fapl[mt] = H5Pcopy(fa->memb_fapl[mt]);
} else {
@ -485,7 +485,7 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/,
}
}
if (memb_name) {
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (fa->memb_name[mt]) {
memb_name[mt] = malloc(strlen(fa->memb_name[mt])+1);
strcpy(memb_name[mt], fa->memb_name[mt]);
@ -541,7 +541,7 @@ H5Pset_dxpl_multi(hid_t dxpl_id, const hid_t *memb_dxpl)
H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a data transfer property list", -1);
if (!memb_dxpl)
H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid pointer", -1);
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (H5P_DEFAULT!=memb_dxpl[mt] &&
H5P_DATA_XFER!=H5Pget_class(memb_dxpl[mt]))
H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a data transfer property list", -1);
@ -590,7 +590,7 @@ H5Pget_dxpl_multi(hid_t dxpl_id, hid_t *memb_dxpl/*out*/)
H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "bad VFL driver info", -1);
if (memb_dxpl) {
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (dx->memb_dxpl[mt]>=0) {
memb_dxpl[mt] = H5Pcopy(dx->memb_dxpl[mt]);
} else {
@ -692,7 +692,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/,
strcpy(name, "NCSAmulti");
assert(7==H5FD_MEM_NTYPES);
for (m=1; m<H5FD_MEM_NTYPES; m++) {
for (m=H5FD_MEM_SUPER; m<H5FD_MEM_NTYPES; m++) {
buf[m-1] = file->fa.memb_map[m];
}
buf[7] = 0;
@ -789,8 +789,8 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf)
*/
memset(map, 0, sizeof map);
for (i=0; i<6; i++) {
map[i+1] = buf[i];
if (file->fa.memb_map[i+1]!=map[i+1]) map_changed=TRUE;
map[i+1] = (H5FD_mem_t)buf[i];
if (file->fa.memb_map[i+1]!=map[i+1]) map_changed=TRUE;
}
UNIQUE_MEMBERS(map, mt) {
nseen++;
@ -950,7 +950,7 @@ H5FD_multi_fapl_copy(const void *_old_fa)
H5Eclear();
memcpy(new_fa, old_fa, sizeof(H5FD_multi_fapl_t));
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (old_fa->memb_fapl[mt]>=0) {
new_fa->memb_fapl[mt] = H5Pcopy(old_fa->memb_fapl[mt]);
if (new_fa->memb_fapl[mt]<0) nerrors++;
@ -963,7 +963,7 @@ H5FD_multi_fapl_copy(const void *_old_fa)
}
if (nerrors) {
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (new_fa->memb_fapl[mt]>=0) H5Pclose(new_fa->memb_fapl[mt]);
if (new_fa->memb_name[mt]) free(new_fa->memb_name[mt]);
}
@ -999,7 +999,7 @@ H5FD_multi_fapl_free(void *_fa)
/* Clear the error stack */
H5Eclear();
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (fa->memb_fapl[mt]>=0) H5Pclose(fa->memb_fapl[mt]);
if (fa->memb_name[mt]) free(fa->memb_name[mt]);
}
@ -1039,7 +1039,7 @@ H5FD_multi_dxpl_copy(const void *_old_dx)
H5Eclear();
memcpy(new_dx, old_dx, sizeof(H5FD_multi_dxpl_t));
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (old_dx->memb_dxpl[mt]>=0) {
new_dx->memb_dxpl[mt] = H5Pcopy(old_dx->memb_dxpl[mt]);
if (new_dx->memb_dxpl[mt]<0) nerrors++;
@ -1047,7 +1047,7 @@ H5FD_multi_dxpl_copy(const void *_old_dx)
}
if (nerrors) {
for (mt=0; mt<H5FD_MEM_NTYPES; mt++)
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++)
H5Pclose(new_dx->memb_dxpl[mt]);
free(new_dx);
H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid freespace objects", NULL);
@ -1081,7 +1081,7 @@ H5FD_multi_dxpl_free(void *_dx)
/* Clear the error stack */
H5Eclear();
for (mt=0; mt<H5FD_MEM_NTYPES; mt++)
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++)
if (dx->memb_dxpl[mt]>=0)
H5Pclose(dx->memb_dxpl[mt]);
free(dx);
@ -1284,7 +1284,7 @@ H5FD_multi_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
/* Clear the error stack */
H5Eclear();
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (f1->memb[mt] && f2->memb[mt]) break;
if (!cmp) {
if (f1->memb[mt]) cmp = -1;
@ -1359,7 +1359,7 @@ H5FD_multi_set_eoa(H5FD_t *_file, haddr_t eoa)
H5Eclear();
/* Find the subfile in which the new EOA value falls */
for (mt=1; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt++) {
mmt = file->fa.memb_map[mt];
if (H5FD_MEM_DEFAULT==mmt) mmt = mt;
assert(mmt>0 && mmt<H5FD_MEM_NTYPES);
@ -1549,7 +1549,7 @@ H5FD_multi_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
}
/* Find the file to which this address belongs */
for (mt=1; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt++) {
mmt = file->fa.memb_map[mt];
if (H5FD_MEM_DEFAULT==mmt) mmt = mt;
assert(mmt>0 && mmt<H5FD_MEM_NTYPES);
@ -1604,7 +1604,7 @@ H5FD_multi_write(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
}
/* Find the file to which this address belongs */
for (mt=1; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt++) {
mmt = file->fa.memb_map[mt];
if (H5FD_MEM_DEFAULT==mmt) mmt = mt;
assert(mmt>0 && mmt<H5FD_MEM_NTYPES);
@ -1683,7 +1683,7 @@ H5FD_multi_flush(H5FD_t *_file)
H5Eclear();
/* Flush each file */
for (mt=1; mt<H5FD_MEM_NTYPES; mt++) {
for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt++) {
if (file->memb[mt]) {
H5E_BEGIN_TRY {
if (H5FDflush(file->memb[mt])<0) nerrors++;

View File

@ -657,7 +657,7 @@ H5FD_sec2_flush(H5FD_t *_file)
FUNC_ENTER(H5FD_sec2_seek, FAIL);
if (file->eoa>file->eof) {
if (-1==file_seek(file->fd, file->eoa-1, SEEK_SET))
if (-1==file_seek(file->fd, (file_offset_t)(file->eoa-1), SEEK_SET))
HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL,
"unable to seek to proper position");
if (write(file->fd, "", 1)!=1)

View File

@ -564,7 +564,7 @@ H5FD_stdio_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
*/
if (!(file->op == H5FD_STDIO_OP_READ || file->op==H5FD_STDIO_OP_SEEK) ||
file->pos != addr) {
if (fseek(file->fp, addr, SEEK_SET) < 0) {
if (fseek(file->fp, (long)addr, SEEK_SET) < 0) {
file->op = H5FD_STDIO_OP_UNKNOWN;
file->pos = HADDR_UNDEF;
H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fseek failed", -1);
@ -653,7 +653,7 @@ H5FD_stdio_write(H5FD_t *_file, hid_t dxpl_id, haddr_t addr,
*/
if (!(file->op == H5FD_STDIO_OP_WRITE || file->op==H5FD_STDIO_OP_SEEK) ||
file->pos != addr) {
if (fseek(file->fp, addr, SEEK_SET) < 0) {
if (fseek(file->fp, (long)addr, SEEK_SET) < 0) {
file->op = H5FD_STDIO_OP_UNKNOWN;
file->pos = HADDR_UNDEF;
H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fseek failed", -1);
@ -718,7 +718,7 @@ H5FD_stdio_flush(H5FD_t *_file)
if(file->write_access) {
/* Makes sure that the true file size is the same (or larger) than the end-of-address. */
if (file->eoa>file->eof) {
if (fseek(file->fp, file->eoa-1, SEEK_SET)<0)
if (fseek(file->fp, (long)(file->eoa-1), SEEK_SET)<0)
H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fseek failed", -1);
if (fwrite("", 1, 1, file->fp)!=1)
H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "EOF fwrite failed", -1);

View File

@ -486,7 +486,7 @@ H5S_hyper_block_cache (H5S_hyper_node_t *node,
} /* end else */
/* Set up parameters for accessing block (starting the read and write information at the same point) */
node->cinfo.wleft=node->cinfo.rleft=node->cinfo.size;
node->cinfo.wleft=node->cinfo.rleft=(uintn)node->cinfo.size;
node->cinfo.wpos=node->cinfo.rpos=node->cinfo.block;
/* Set cached flag */
@ -3002,7 +3002,7 @@ H5S_hyper_select_contiguous(const H5S_t *space)
*
*-------------------------------------------------------------------------
*/
static size_t
static herr_t
H5S_hyper_select_iterate_mem (intn dim, H5S_hyper_iter_info_t *iter_info)
{
hsize_t offset; /* offset of region in buffer */

View File

@ -1161,7 +1161,7 @@ H5S_get_select_hyper_nblocks(H5S_t *space)
assert(space);
ret_value = space->select.sel_info.hslab.hyper_lst->count;
ret_value = (hssize_t)space->select.sel_info.hslab.hyper_lst->count;
FUNC_LEAVE (ret_value);
} /* H5Sget_select_hyper_nblocks() */

1180
src/H5T.c

File diff suppressed because it is too large Load Diff

View File

@ -788,96 +788,96 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
FUNC_ENTER (H5T_conv_struct_init, FAIL);
if (!priv) {
/*
* Allocate private data structure and arrays.
*/
if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(H5T_conv_struct_t))) ||
NULL==(priv->src2dst=H5MM_malloc(src->u.compnd.nmembs *
sizeof(intn))) ||
NULL==(priv->src_memb_id=H5MM_malloc(src->u.compnd.nmembs *
sizeof(hid_t))) ||
NULL==(priv->dst_memb_id=H5MM_malloc(dst->u.compnd.nmembs *
sizeof(hid_t))) ||
NULL==(priv->memb_nelmts=H5MM_malloc(src->u.compnd.nmembs *
sizeof(size_t)))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
src2dst = priv->src2dst;
/*
* Allocate private data structure and arrays.
*/
if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(H5T_conv_struct_t))) ||
NULL==(priv->src2dst=H5MM_malloc(src->u.compnd.nmembs *
sizeof(intn))) ||
NULL==(priv->src_memb_id=H5MM_malloc(src->u.compnd.nmembs *
sizeof(hid_t))) ||
NULL==(priv->dst_memb_id=H5MM_malloc(dst->u.compnd.nmembs *
sizeof(hid_t))) ||
NULL==(priv->memb_nelmts=H5MM_malloc(src->u.compnd.nmembs *
sizeof(size_t)))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
src2dst = priv->src2dst;
/*
* Insure that members are sorted.
*/
H5T_sort_value(src, NULL);
H5T_sort_value(dst, NULL);
/*
* Insure that members are sorted.
*/
H5T_sort_value(src, NULL);
H5T_sort_value(dst, NULL);
/*
* Build a mapping from source member number to destination member
* number. If some source member is not a destination member then that
* mapping element will be negative. Also create atoms for each
* source and destination member data type so we can look up the
* member data type conversion functions later.
*/
for (i=0; i<src->u.compnd.nmembs; i++) {
src2dst[i] = -1;
for (j=0; j<dst->u.compnd.nmembs; j++) {
if (!HDstrcmp (src->u.compnd.memb[i].name,
dst->u.compnd.memb[j].name)) {
src2dst[i] = j;
break;
}
}
if (src2dst[i]>=0) {
type = H5T_copy (src->u.compnd.memb[i].type, H5T_COPY_ALL);
tid = H5I_register (H5I_DATATYPE, type);
assert (tid>=0);
priv->src_memb_id[i] = tid;
/*
* Build a mapping from source member number to destination member
* number. If some source member is not a destination member then that
* mapping element will be negative. Also create atoms for each
* source and destination member data type so we can look up the
* member data type conversion functions later.
*/
for (i=0; i<src->u.compnd.nmembs; i++) {
src2dst[i] = -1;
for (j=0; j<dst->u.compnd.nmembs; j++) {
if (!HDstrcmp (src->u.compnd.memb[i].name,
dst->u.compnd.memb[j].name)) {
src2dst[i] = j;
break;
}
}
if (src2dst[i]>=0) {
type = H5T_copy (src->u.compnd.memb[i].type, H5T_COPY_ALL);
tid = H5I_register (H5I_DATATYPE, type);
assert (tid>=0);
priv->src_memb_id[i] = tid;
type = H5T_copy (dst->u.compnd.memb[src2dst[i]].type,
H5T_COPY_ALL);
tid = H5I_register (H5I_DATATYPE, type);
assert (tid>=0);
priv->dst_memb_id[src2dst[i]] = tid;
}
}
type = H5T_copy (dst->u.compnd.memb[src2dst[i]].type,
H5T_COPY_ALL);
tid = H5I_register (H5I_DATATYPE, type);
assert (tid>=0);
priv->dst_memb_id[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 (src2dst[i]>=0) {
H5T_cmemb_t *src_memb = src->u.compnd.memb + i;
H5T_cmemb_t *dst_memb = dst->u.compnd.memb + 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");
}
/*
* 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 (src2dst[i]>=0) {
H5T_cmemb_t *src_memb = src->u.compnd.memb + i;
H5T_cmemb_t *dst_memb = dst->u.compnd.memb + 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");
}
/* 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 */
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];
}
}
/* Calculate number of elements of each member */
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];
}
}
}
/*
@ -888,27 +888,26 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
H5MM_xfree(priv->memb_path);
if (NULL==(priv->memb_path=H5MM_malloc(src->u.compnd.nmembs *
sizeof(H5T_path_t*)))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
for (i=0; i<src->u.compnd.nmembs; i++) {
if (src2dst[i]>=0) {
H5T_path_t *tpath;
tpath = H5T_path_find(src->u.compnd.memb[i].type,
dst->u.compnd.memb[src2dst[i]].type,
NULL, NULL);
if (NULL==(priv->memb_path[i] = tpath)) {
H5MM_xfree(priv->src2dst);
H5MM_xfree(priv->src_memb_id);
H5MM_xfree(priv->dst_memb_id);
H5MM_xfree(priv->memb_path);
H5MM_xfree(priv->memb_nelmts);
cdata->priv = priv = H5MM_xfree (priv);
HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
"unable to convert member data type");
}
}
if (src2dst[i]>=0) {
H5T_path_t *tpath = H5T_path_find(src->u.compnd.memb[i].type,
dst->u.compnd.memb[src2dst[i]].type, NULL, NULL);
if (NULL==(priv->memb_path[i] = tpath)) {
H5MM_xfree(priv->src2dst);
H5MM_xfree(priv->src_memb_id);
H5MM_xfree(priv->dst_memb_id);
H5MM_xfree(priv->memb_path);
H5MM_xfree(priv->memb_nelmts);
cdata->priv = priv = H5MM_xfree (priv);
HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
"unable to convert member data type");
}
}
}
cdata->need_bkg = H5T_BKG_TEMP;
@ -968,166 +967,165 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
FUNC_ENTER (H5T_conv_struct, FAIL);
switch (cdata->command) {
case H5T_CONV_INIT:
/*
* First, determine if this conversion function applies to the
* conversion path SRC_ID-->DST_ID. If not, return failure;
* otherwise initialize the `priv' field of `cdata' with information
* that remains (almost) constant for this conversion path.
*/
if (H5I_DATATYPE != H5I_get_type(src_id) ||
NULL == (src = H5I_object(src_id)) ||
H5I_DATATYPE != H5I_get_type(dst_id) ||
NULL == (dst = H5I_object(dst_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
assert (H5T_COMPOUND==src->type);
assert (H5T_COMPOUND==dst->type);
case H5T_CONV_INIT:
/*
* First, determine if this conversion function applies to the
* conversion path SRC_ID-->DST_ID. If not, return failure;
* otherwise initialize the `priv' field of `cdata' with information
* that remains (almost) constant for this conversion path.
*/
if (H5I_DATATYPE != H5I_get_type(src_id) ||
NULL == (src = H5I_object(src_id)) ||
H5I_DATATYPE != H5I_get_type(dst_id) ||
NULL == (dst = H5I_object(dst_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
assert (H5T_COMPOUND==src->type);
assert (H5T_COMPOUND==dst->type);
if (H5T_conv_struct_init (src, dst, cdata)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize conversion data");
}
break;
if (H5T_conv_struct_init (src, dst, cdata)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize conversion data");
}
break;
case H5T_CONV_FREE:
/*
* 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_path);
H5MM_xfree(priv->memb_nelmts);
cdata->priv = priv = H5MM_xfree (priv);
break;
case H5T_CONV_FREE:
/*
* 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_path);
H5MM_xfree(priv->memb_nelmts);
cdata->priv = priv = H5MM_xfree (priv);
break;
case H5T_CONV_CONV:
/*
* Conversion.
*/
if (H5I_DATATYPE != H5I_get_type(src_id) ||
NULL == (src = H5I_object(src_id)) ||
H5I_DATATYPE != H5I_get_type(dst_id) ||
NULL == (dst = H5I_object(dst_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
assert (priv);
assert (bkg && cdata->need_bkg>=H5T_BKG_TEMP);
case H5T_CONV_CONV:
/*
* Conversion.
*/
if (H5I_DATATYPE != H5I_get_type(src_id) ||
NULL == (src = H5I_object(src_id)) ||
H5I_DATATYPE != H5I_get_type(dst_id) ||
NULL == (dst = H5I_object(dst_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
assert (priv);
assert (bkg && cdata->need_bkg>=H5T_BKG_TEMP);
if (cdata->recalc &&
H5T_conv_struct_init (src, dst, cdata)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize conversion data");
}
if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize conversion data");
}
/*
* Insure that members are sorted.
*/
H5T_sort_value(src, NULL);
H5T_sort_value(dst, NULL);
src2dst = priv->src2dst;
/*
* Insure that members are sorted.
*/
H5T_sort_value(src, NULL);
H5T_sort_value(dst, NULL);
src2dst = priv->src2dst;
/*
* Direction of conversion.
*/
if (stride) {
src_delta = dst_delta = stride;
} else if (dst->size <= src->size) {
src_delta = src->size;
dst_delta = dst->size;
} else {
src_delta = -(src->size);
dst_delta = -(dst->size);
buf += (nelmts-1) * src->size;
bkg += (nelmts-1) * dst->size;
}
/*
* Direction of conversion.
*/
if (stride) {
src_delta = dst_delta = stride;
} else if (dst->size <= src->size) {
src_delta = src->size;
dst_delta = dst->size;
} else {
src_delta = -(src->size);
dst_delta = -(dst->size);
buf += (nelmts-1) * src->size;
bkg += (nelmts-1) * dst->size;
}
for (elmtno=0; elmtno<nelmts; elmtno++) {
/*
* For each source member which will be present in the
* destination, convert the member to the destination type unless
* it is larger than the source type. Then move the member to the
* left-most unoccupied position in the buffer. This makes the
* data point as small as possible with all the free space on the
* right side.
*/
for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
if (src2dst[i]<0) continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
for (elmtno=0; elmtno<nelmts; elmtno++) {
/*
* For each source member which will be present in the
* destination, convert the member to the destination type unless
* it is larger than the source type. Then move the member to the
* left-most unoccupied position in the buffer. This makes the
* data point as small as possible with all the free space on the
* right side.
*/
for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
if (src2dst[i]<0)
continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
if (dst_memb->size <= src_memb->size) {
if (H5T_convert(priv->memb_path[i],
priv->src_memb_id[i],
priv->dst_memb_id[src2dst[i]],
priv->memb_nelmts[i],
0, /*no striding*/
buf + src_memb->offset,
bkg + dst_memb->offset,dset_xfer_plist)<0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to convert compound data type "
"member");
}
HDmemmove (buf+offset, buf+src_memb->offset,
dst_memb->size);
offset += dst_memb->size;
} else {
HDmemmove (buf+offset, buf+src_memb->offset,
src_memb->size);
offset += src_memb->size;
}
}
if (dst_memb->size <= src_memb->size) {
if (H5T_convert(priv->memb_path[i],
priv->src_memb_id[i],
priv->dst_memb_id[src2dst[i]],
priv->memb_nelmts[i],
0, /*no striding*/
buf + src_memb->offset,
bkg + dst_memb->offset,dset_xfer_plist)<0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to convert compound data type member");
}
HDmemmove (buf+offset, buf+src_memb->offset,
dst_memb->size);
offset += dst_memb->size;
} else {
HDmemmove (buf+offset, buf+src_memb->offset,
src_memb->size);
offset += src_memb->size;
}
}
/*
* For each source member which will be present in the
* destination, convert the member to the destination type if it
* is larger than the source type (that is, has not been converted
* yet). Then copy the member to the destination offset in the
* background buffer.
*/
for (i=src->u.compnd.nmembs-1; i>=0; --i) {
if (src2dst[i]<0) continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
/*
* For each source member which will be present in the
* destination, convert the member to the destination type if it
* is larger than the source type (that is, has not been converted
* yet). Then copy the member to the destination offset in the
* background buffer.
*/
for (i=src->u.compnd.nmembs-1; i>=0; --i) {
if (src2dst[i]<0)
continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
if (dst_memb->size > src_memb->size) {
offset -= src_memb->size;
if (H5T_convert(priv->memb_path[i],
priv->src_memb_id[i],
priv->dst_memb_id[src2dst[i]],
priv->memb_nelmts[i],
0, /*no striding*/
buf+offset, bkg+dst_memb->offset,dset_xfer_plist)<0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to convert compound data type "
"member");
}
} else {
offset -= dst_memb->size;
}
HDmemmove (bkg+dst_memb->offset, buf+offset, dst_memb->size);
}
assert (0==offset);
if (dst_memb->size > src_memb->size) {
offset -= src_memb->size;
if (H5T_convert(priv->memb_path[i],
priv->src_memb_id[i],
priv->dst_memb_id[src2dst[i]],
priv->memb_nelmts[i],
0, /*no striding*/
buf+offset, bkg+dst_memb->offset,dset_xfer_plist)<0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to convert compound data type member");
}
} else {
offset -= dst_memb->size;
}
HDmemmove (bkg+dst_memb->offset, buf+offset, dst_memb->size);
}
assert (0==offset);
/*
* Update buf and background.
*/
buf += src_delta;
bkg += dst_delta;
}
/*
* Update buf and background.
*/
buf += src_delta;
bkg += dst_delta;
}
/*
* Copy the background buffer back into the in-place conversion
* buffer.
*/
HDmemcpy (_buf, _bkg, nelmts*dst->size);
break;
/*
* Copy the background buffer back into the in-place conversion
* buffer.
*/
HDmemcpy (_buf, _bkg, nelmts*dst->size);
break;
default:
/* Some other command we don't know about yet.*/
HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
"unknown conversion command");
default:
/* Some other command we don't know about yet.*/
HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
"unknown conversion command");
}
FUNC_LEAVE (SUCCEED);
@ -1202,214 +1200,214 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
FUNC_ENTER (H5T_conv_struct_opt, FAIL);
switch (cdata->command) {
case H5T_CONV_INIT:
/*
* First, determine if this conversion function applies to the
* conversion path SRC_ID-->DST_ID. If not, return failure;
* otherwise initialize the `priv' field of `cdata' with information
* that remains (almost) constant for this conversion path.
*/
if (H5I_DATATYPE != H5I_get_type(src_id) ||
NULL == (src = H5I_object(src_id)) ||
H5I_DATATYPE != H5I_get_type(dst_id) ||
NULL == (dst = H5I_object(dst_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
assert (H5T_COMPOUND==src->type);
assert (H5T_COMPOUND==dst->type);
case H5T_CONV_INIT:
/*
* First, determine if this conversion function applies to the
* conversion path SRC_ID-->DST_ID. If not, return failure;
* otherwise initialize the `priv' field of `cdata' with information
* that remains (almost) constant for this conversion path.
*/
if (H5I_DATATYPE != H5I_get_type(src_id) ||
NULL == (src = H5I_object(src_id)) ||
H5I_DATATYPE != H5I_get_type(dst_id) ||
NULL == (dst = H5I_object(dst_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
assert (H5T_COMPOUND==src->type);
assert (H5T_COMPOUND==dst->type);
/* Initialize data which is relatively constant */
if (H5T_conv_struct_init (src, dst, cdata)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize conversion data");
}
priv = (H5T_conv_struct_t *)(cdata->priv);
src2dst = priv->src2dst;
/*
* If the destination type is not larger than the source type then
* this conversion function is guaranteed to work (provided all
* members can be converted also). Otherwise the determination is
* quite a bit more complicated. Essentially we have to make sure
* that there is always room in the source buffer to do the
* conversion of a member in place. This is basically the same pair
* of loops as in the actual conversion except it checks that there
* is room for each conversion instead of actually doing anything.
*/
if (dst->size > src->size) {
for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
if (src2dst[i]<0) continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
src_memb_size = src_memb->size / priv->memb_nelmts[i];
dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
for (j=0; j<(intn)(priv->memb_nelmts[i]); j++) {
if (dst_memb_size > src_memb_size) {
offset += src_memb_size;
}
}
}
for (i=src->u.compnd.nmembs-1; i>=0; --i) {
if (src2dst[i]<0) continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
src_memb_size = src_memb->size / priv->memb_nelmts[i];
dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
/* Initialize data which is relatively constant */
if (H5T_conv_struct_init (src, dst, cdata)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize conversion data");
}
priv = (H5T_conv_struct_t *)(cdata->priv);
src2dst = priv->src2dst;
/*
* If the destination type is not larger than the source type then
* this conversion function is guaranteed to work (provided all
* members can be converted also). Otherwise the determination is
* quite a bit more complicated. Essentially we have to make sure
* that there is always room in the source buffer to do the
* conversion of a member in place. This is basically the same pair
* of loops as in the actual conversion except it checks that there
* is room for each conversion instead of actually doing anything.
*/
if (dst->size > src->size) {
for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
if (src2dst[i]<0)
continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
src_memb_size = src_memb->size / priv->memb_nelmts[i];
dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
for (j=0; j<(intn)(priv->memb_nelmts[i]); j++) {
if (dst_memb_size > src_memb_size)
offset += src_memb_size;
}
}
for (i=src->u.compnd.nmembs-1; i>=0; --i) {
if (src2dst[i]<0)
continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
src_memb_size = src_memb->size / priv->memb_nelmts[i];
dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
for (j=priv->memb_nelmts[i]-1; j>=0; --j) {
if (dst_memb_size > src_memb_size) {
offset -= src_memb_size;
if (dst_memb_size > src->size-offset) {
H5MM_xfree(priv->src2dst);
H5MM_xfree(priv->src_memb_id);
H5MM_xfree(priv->dst_memb_id);
H5MM_xfree(priv->memb_path);
H5MM_xfree(priv->memb_nelmts);
cdata->priv = priv = H5MM_xfree (priv);
HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
"convertion is unsupported by this "
"function");
}
}
}
}
}
break;
for (j=(intn)(priv->memb_nelmts[i]-1); j>=0; --j) {
if (dst_memb_size > src_memb_size) {
offset -= src_memb_size;
if (dst_memb_size > src->size-offset) {
H5MM_xfree(priv->src2dst);
H5MM_xfree(priv->src_memb_id);
H5MM_xfree(priv->dst_memb_id);
H5MM_xfree(priv->memb_path);
H5MM_xfree(priv->memb_nelmts);
cdata->priv = priv = H5MM_xfree (priv);
HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
"convertion is unsupported by this "
"function");
}
}
}
}
}
break;
case H5T_CONV_FREE:
/*
* Free the private conversion data.
*/
priv = (H5T_conv_struct_t *)(cdata->priv);
H5MM_xfree(priv->src2dst);
H5MM_xfree(priv->src_memb_id);
H5MM_xfree(priv->dst_memb_id);
H5MM_xfree(priv->memb_path);
H5MM_xfree(priv->memb_nelmts);
cdata->priv = priv = H5MM_xfree (priv);
break;
case H5T_CONV_FREE:
/*
* Free the private conversion data.
*/
priv = (H5T_conv_struct_t *)(cdata->priv);
H5MM_xfree(priv->src2dst);
H5MM_xfree(priv->src_memb_id);
H5MM_xfree(priv->dst_memb_id);
H5MM_xfree(priv->memb_path);
H5MM_xfree(priv->memb_nelmts);
cdata->priv = priv = H5MM_xfree (priv);
break;
case H5T_CONV_CONV:
/*
* Conversion.
*/
if (H5I_DATATYPE != H5I_get_type(src_id) ||
NULL == (src = H5I_object(src_id)) ||
H5I_DATATYPE != H5I_get_type(dst_id) ||
NULL == (dst = H5I_object(dst_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
case H5T_CONV_CONV:
/*
* Conversion.
*/
if (H5I_DATATYPE != H5I_get_type(src_id) ||
NULL == (src = H5I_object(src_id)) ||
H5I_DATATYPE != H5I_get_type(dst_id) ||
NULL == (dst = H5I_object(dst_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
/* Update cached data if necessary */
if (cdata->recalc &&
H5T_conv_struct_init (src, dst, cdata)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize conversion data");
}
priv = (H5T_conv_struct_t *)(cdata->priv);
src2dst = priv->src2dst;
assert(priv);
assert(bkg && cdata->need_bkg>=H5T_BKG_TEMP);
/* Update cached data if necessary */
if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize conversion data");
}
priv = (H5T_conv_struct_t *)(cdata->priv);
src2dst = priv->src2dst;
assert(priv);
assert(bkg && cdata->need_bkg>=H5T_BKG_TEMP);
/*
* Insure that members are sorted.
*/
H5T_sort_value(src, NULL);
H5T_sort_value(dst, NULL);
/*
* Insure that members are sorted.
*/
H5T_sort_value(src, NULL);
H5T_sort_value(dst, NULL);
/*
* For each member where the destination is not larger than the
* source, stride through all the elements converting only that member
* in each element and then copying the element to its final
* destination in the bkg buffer. Otherwise move the element as far
* left as possible in the buffer.
*/
for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
if (src2dst[i]<0) continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
src_memb_size = src_memb->size / priv->memb_nelmts[i];
dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
/*
* For each member where the destination is not larger than the
* source, stride through all the elements converting only that member
* in each element and then copying the element to its final
* destination in the bkg buffer. Otherwise move the element as far
* left as possible in the buffer.
*/
for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
if (src2dst[i]<0)
continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
src_memb_size = src_memb->size / priv->memb_nelmts[i];
dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
for (j=0; j<(intn)(priv->memb_nelmts[i]); j++) {
if (dst_memb_size <= src_memb_size) {
xbuf = buf + src_memb->offset + j*src_memb_size;
xbkg = bkg + dst_memb->offset + j*dst_memb_size;
if (H5T_convert(priv->memb_path[i],
priv->src_memb_id[i],
priv->dst_memb_id[src2dst[i]],
nelmts,
stride?stride:src->size,
xbuf, xbkg,dset_xfer_plist)<0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to convert compound data "
"type member");
}
for (elmtno=0; elmtno<nelmts; elmtno++) {
HDmemmove(xbkg, xbuf, dst_memb_size);
xbuf += stride ? stride : src->size;
xbkg += stride ? stride : dst->size;
}
} else {
for (xbuf=buf, elmtno=0; elmtno<nelmts; elmtno++) {
HDmemmove(xbuf+offset,
xbuf+src_memb->offset+j*src_memb_size,
src_memb_size);
xbuf += stride ? stride : src->size;
}
offset += src_memb_size;
}
}
}
for (j=0; j<(intn)(priv->memb_nelmts[i]); j++) {
if (dst_memb_size <= src_memb_size) {
xbuf = buf + src_memb->offset + j*src_memb_size;
xbkg = bkg + dst_memb->offset + j*dst_memb_size;
if (H5T_convert(priv->memb_path[i],
priv->src_memb_id[i],
priv->dst_memb_id[src2dst[i]],
nelmts,
stride?stride:src->size,
xbuf, xbkg,dset_xfer_plist)<0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to convert compound data "
"type member");
}
for (elmtno=0; elmtno<nelmts; elmtno++) {
HDmemmove(xbkg, xbuf, dst_memb_size);
xbuf += stride ? stride : src->size;
xbkg += stride ? stride : dst->size;
}
} else {
for (xbuf=buf, elmtno=0; elmtno<nelmts; elmtno++) {
HDmemmove(xbuf+offset,
xbuf+src_memb->offset+j*src_memb_size, src_memb_size);
xbuf += stride ? stride : src->size;
}
offset += src_memb_size;
}
}
}
/*
* Work from right to left, converting those members that weren't
* converted in the previous loop (those members where the destination
* is larger than the source) and them to their final position in the
* bkg buffer.
*/
for (i=src->u.compnd.nmembs-1; i>=0; --i) {
if (src2dst[i]<0) continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
src_memb_size = src_memb->size / priv->memb_nelmts[i];
dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
/*
* Work from right to left, converting those members that weren't
* converted in the previous loop (those members where the destination
* is larger than the source) and them to their final position in the
* bkg buffer.
*/
for (i=src->u.compnd.nmembs-1; i>=0; --i) {
if (src2dst[i]<0)
continue;
src_memb = src->u.compnd.memb + i;
dst_memb = dst->u.compnd.memb + src2dst[i];
src_memb_size = src_memb->size / priv->memb_nelmts[i];
dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
for (j=priv->memb_nelmts[i]-1; j>=0; --j) {
if (dst_memb_size > src_memb_size) {
offset -= src_memb_size;
xbuf = buf + offset;
xbkg = bkg + dst_memb->offset + j*dst_memb_size;
if (H5T_convert(priv->memb_path[i],
priv->src_memb_id[i],
priv->dst_memb_id[src2dst[i]],
nelmts, stride?stride:src->size,
xbuf, xbkg, dset_xfer_plist)<0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to convert compound data "
"type member");
}
for (elmtno=0; elmtno<nelmts; elmtno++) {
HDmemmove(xbkg, xbuf, dst_memb_size);
xbuf += stride ? stride : src->size;
xbkg += stride ? stride : dst->size;
}
}
}
}
for (j=(intn)(priv->memb_nelmts[i]-1); j>=0; --j) {
if (dst_memb_size > src_memb_size) {
offset -= src_memb_size;
xbuf = buf + offset;
xbkg = bkg + dst_memb->offset + j*dst_memb_size;
if (H5T_convert(priv->memb_path[i],
priv->src_memb_id[i],
priv->dst_memb_id[src2dst[i]],
nelmts, stride?stride:src->size,
xbuf, xbkg, dset_xfer_plist)<0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to convert compound data type member");
}
for (elmtno=0; elmtno<nelmts; elmtno++) {
HDmemmove(xbkg, xbuf, dst_memb_size);
xbuf += stride ? stride : src->size;
xbkg += stride ? stride : dst->size;
}
}
}
}
/* Move background into buffer */
for (xbuf=buf, xbkg=bkg, elmtno=0; elmtno<nelmts; elmtno++) {
HDmemmove(xbuf, xbkg, dst->size);
xbuf += stride ? stride : dst->size;
xbkg += stride ? stride : dst->size;
}
break;
/* Move background into buffer */
for (xbuf=buf, xbkg=bkg, elmtno=0; elmtno<nelmts; elmtno++) {
HDmemmove(xbuf, xbkg, dst->size);
xbuf += stride ? stride : dst->size;
xbkg += stride ? stride : dst->size;
}
break;
default:
/* Some other command we don't know about yet.*/
HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
"unknown conversion command");
default:
/* Some other command we don't know about yet.*/
HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
"unknown conversion command");
}
FUNC_LEAVE (SUCCEED);
@ -1654,7 +1652,7 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
* Direction of conversion.
*/
if (stride) {
src_delta = dst_delta = stride;
src_delta = dst_delta = (intn)stride;
s = d = buf;
} else if (dst->size <= src->size) {
src_delta = (int)src->size; /*overflow shouldn't be possible*/

View File

@ -102,6 +102,9 @@ __DLL__ H5T_t *H5T_copy(const H5T_t *old_dt, H5T_copy_t method);
__DLL__ herr_t H5T_commit(H5G_entry_t *loc, const char *name, H5T_t *type);
__DLL__ herr_t H5T_lock(H5T_t *dt, hbool_t immutable);
__DLL__ herr_t H5T_close(H5T_t *dt);
__DLL__ herr_t H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src,
H5T_t *dst, H5T_conv_t func);
__DLL__ herr_t H5T_path_force_reinit(H5T_t *dt);
__DLL__ H5T_class_t H5T_get_class(const H5T_t *dt);
__DLL__ size_t H5T_get_size(const H5T_t *dt);
__DLL__ intn H5T_cmp(const H5T_t *dt1, const H5T_t *dt2);
@ -128,7 +131,7 @@ __DLL__ char *H5T_enum_nameof(H5T_t *dt, void *value, char *name/*out*/,
__DLL__ herr_t H5T_enum_valueof(H5T_t *dt, const char *name,
void *value/*out*/);
__DLL__ herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, hsize_t UNUSED ndim, hssize_t UNUSED *point, void UNUSED *_op_data);
__DLL__ herr_t H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc);
__DLL__ htri_t H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc);
__DLL__ H5R_type_t H5T_get_ref_type(const H5T_t *dt);
#endif

View File

@ -36,11 +36,15 @@ static herr_t H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_f
/*-------------------------------------------------------------------------
* Function: H5T_vlen_set_loc
* Function: H5T_vlen_set_loc
*
* Purpose: Sets the location of a VL datatype to be either on disk or in memory
*
* Return: Non-negative on success/Negative on failure
* Return:
* One of two values on success:
* TRUE - If the location of any vlen types changed
* FALSE - If the location of any vlen types is the same
* <0 is returned on failure
*
* Programmer: Quincey Koziol
* Friday, June 4, 1999
@ -49,74 +53,82 @@ static herr_t H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_f
*
*-------------------------------------------------------------------------
*/
static herr_t
static htri_t
H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc)
{
htri_t ret_value = 0; /* Indicate that success, but no location change */
FUNC_ENTER (H5T_vlen_set_loc, FAIL);
/* check parameters */
assert(dt);
assert(loc>H5T_VLEN_BADLOC && loc<H5T_VLEN_MAXLOC);
switch(loc) {
case H5T_VLEN_MEMORY: /* Memory based VL datatype */
assert(f==NULL);
/* Only change the location if it's different */
if(loc!=dt->u.vlen.loc) {
/* Indicate that the location changed */
ret_value=TRUE;
/* Mark this type as being stored in memory */
dt->u.vlen.loc=H5T_VLEN_MEMORY;
switch(loc) {
case H5T_VLEN_MEMORY: /* Memory based VL datatype */
assert(f==NULL);
if(dt->u.vlen.type==H5T_VLEN_SEQUENCE) {
/* size in memory, disk size is different */
dt->size = sizeof(hvl_t);
/* Mark this type as being stored in memory */
dt->u.vlen.loc=H5T_VLEN_MEMORY;
/* Set up the function pointers to access the VL sequence in memory */
dt->u.vlen.getlen=H5T_vlen_seq_mem_getlen;
dt->u.vlen.read=H5T_vlen_seq_mem_read;
dt->u.vlen.write=H5T_vlen_seq_mem_write;
} else if(dt->u.vlen.type==H5T_VLEN_STRING) {
/* size in memory, disk size is different */
dt->size = sizeof(char *);
if(dt->u.vlen.type==H5T_VLEN_SEQUENCE) {
/* size in memory, disk size is different */
dt->size = sizeof(hvl_t);
/* Set up the function pointers to access the VL string in memory */
dt->u.vlen.getlen=H5T_vlen_str_mem_getlen;
dt->u.vlen.read=H5T_vlen_str_mem_read;
dt->u.vlen.write=H5T_vlen_str_mem_write;
} else {
assert(0 && "Invalid VL type");
}
/* Set up the function pointers to access the VL sequence in memory */
dt->u.vlen.getlen=H5T_vlen_seq_mem_getlen;
dt->u.vlen.read=H5T_vlen_seq_mem_read;
dt->u.vlen.write=H5T_vlen_seq_mem_write;
} else if(dt->u.vlen.type==H5T_VLEN_STRING) {
/* size in memory, disk size is different */
dt->size = sizeof(char *);
/* Reset file ID (since this VL is in memory) */
dt->u.vlen.f=NULL;
break;
/* Set up the function pointers to access the VL string in memory */
dt->u.vlen.getlen=H5T_vlen_str_mem_getlen;
dt->u.vlen.read=H5T_vlen_str_mem_read;
dt->u.vlen.write=H5T_vlen_str_mem_write;
} else {
assert(0 && "Invalid VL type");
}
case H5T_VLEN_DISK: /* Disk based VL datatype */
assert(f);
/* Reset file ID (since this VL is in memory) */
dt->u.vlen.f=NULL;
break;
/* Mark this type as being stored on disk */
dt->u.vlen.loc=H5T_VLEN_DISK;
case H5T_VLEN_DISK: /* Disk based VL datatype */
assert(f);
/*
* Size of element on disk is 4 bytes for the length, plus the size
* of an address in this file, plus 4 bytes for the size of a heap
* ID. Memory size is different
*/
dt->size = 4 + H5F_SIZEOF_ADDR(f) + 4;
/* Mark this type as being stored on disk */
dt->u.vlen.loc=H5T_VLEN_DISK;
/* Set up the function pointers to access the VL information on disk */
/* VL sequences and VL strings are stored identically on disk, so use the same functions */
dt->u.vlen.getlen=H5T_vlen_disk_getlen;
dt->u.vlen.read=H5T_vlen_disk_read;
dt->u.vlen.write=H5T_vlen_disk_write;
/*
* Size of element on disk is 4 bytes for the length, plus the size
* of an address in this file, plus 4 bytes for the size of a heap
* ID. Memory size is different
*/
dt->size = 4 + H5F_SIZEOF_ADDR(f) + 4;
/* Set file ID (since this VL is on disk) */
dt->u.vlen.f=f;
break;
/* Set up the function pointers to access the VL information on disk */
/* VL sequences and VL strings are stored identically on disk, so use the same functions */
dt->u.vlen.getlen=H5T_vlen_disk_getlen;
dt->u.vlen.read=H5T_vlen_disk_read;
dt->u.vlen.write=H5T_vlen_disk_write;
default:
HRETURN_ERROR (H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid VL datatype location");
} /* end switch */
/* Set file ID (since this VL is on disk) */
dt->u.vlen.f=f;
break;
FUNC_LEAVE (SUCCEED);
default:
HRETURN_ERROR (H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid VL datatype location");
} /* end switch */
} /* end if */
FUNC_LEAVE (ret_value);
} /* end H5T_vlen_set_loc() */
@ -144,7 +156,7 @@ hssize_t H5T_vlen_seq_mem_getlen(H5F_t UNUSED *f, void *vl_addr)
/* check parameters */
assert(vl);
ret_value=vl->len;
ret_value=(hssize_t)vl->len;
FUNC_LEAVE (ret_value);
} /* end H5T_vlen_seq_mem_getlen() */
@ -246,7 +258,7 @@ hssize_t H5T_vlen_str_mem_getlen(H5F_t UNUSED *f, void *vl_addr)
/* check parameters */
assert(s);
ret_value=HDstrlen(s);
ret_value=(hssize_t)HDstrlen(s);
FUNC_LEAVE (ret_value);
} /* end H5T_vlen_str_mem_getlen() */
@ -593,13 +605,16 @@ done:
PURPOSE
Recursively mark any VL datatypes as on disk/in memory
USAGE
herr_t H5T_vlen_mark(dt,f,loc)
htri_t H5T_vlen_mark(dt,f,loc)
H5T_t *dt; IN/OUT: Pointer to the datatype to mark
H5F_t *dt; IN: Pointer to the file the datatype is in
H5T_vlen_type_t loc IN: location of VL type
RETURNS
SUCCEED/FAIL
One of two values on success:
TRUE - If the location of any vlen types changed
FALSE - If the location of any vlen types is the same
<0 is returned on failure
DESCRIPTION
Recursively descends any VL or compound datatypes to mark all VL datatypes
as either on disk or in memory.
@ -608,11 +623,11 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
htri_t
H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc)
{
intn i; /* local counting variable */
herr_t ret_value = SUCCEED;
htri_t vlen_changed; /* Whether H5T_vlen_mark changed the type (even if the size didn't change) */
htri_t ret_value = 0; /* Indicate that success, but no location change */
FUNC_ENTER(H5T_vlen_mark, FAIL);
@ -623,54 +638,63 @@ H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc)
switch(dt->type) {
/* Check each field and recurse on VL and compound ones */
case H5T_COMPOUND:
{
intn accum_change=0; /* Amount of change in the offset of the fields */
size_t old_size; /* Preview size of a field */
/* Compound datatypes can't change in size if the force_conv flag is not set */
if(dt->force_conv) {
intn i; /* local counting variable */
intn accum_change=0; /* Amount of change in the offset of the fields */
size_t old_size; /* Preview size of a field */
/* Sort the fields based on offsets */
H5T_sort_value(dt,NULL);
for (i=0; i<dt->u.compnd.nmembs; i++) {
/* Apply the accumulated size change to the offset of the field */
dt->u.compnd.memb[i].offset += accum_change;
/* Sort the fields based on offsets */
H5T_sort_value(dt,NULL);
for (i=0; i<dt->u.compnd.nmembs; i++) {
/* Apply the accumulated size change to the offset of the field */
dt->u.compnd.memb[i].offset += accum_change;
/* Recurse if it's VL or compound */
if(dt->u.compnd.memb[i].type->type==H5T_COMPOUND || dt->u.compnd.memb[i].type->type==H5T_VLEN) {
/* Keep the old field size for later */
old_size=dt->u.compnd.memb[i].type->size;
/* Recurse if it's VL or compound */
/* (If the type is compound and the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */
if((dt->u.compnd.memb[i].type->type==H5T_COMPOUND && dt->u.compnd.memb[i].type->force_conv) || dt->u.compnd.memb[i].type->type==H5T_VLEN) {
/* Keep the old field size for later */
old_size=dt->u.compnd.memb[i].type->size;
/* Mark the VL or compound type */
if(H5T_vlen_mark(dt->u.compnd.memb[i].type,f,loc)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
/* Check if the field changed size */
if(old_size != dt->u.compnd.memb[i].type->size) {
/* Adjust the size of the member */
dt->u.compnd.memb[i].size = (dt->u.compnd.memb[i].size*dt->u.compnd.memb[i].type->size)/old_size;
/* Mark the VL or compound type */
if((vlen_changed=H5T_vlen_mark(dt->u.compnd.memb[i].type,f,loc))<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
if(vlen_changed>0)
ret_value=vlen_changed;
/* Check if the field changed size */
if(old_size != dt->u.compnd.memb[i].type->size) {
/* Adjust the size of the member */
dt->u.compnd.memb[i].size = (dt->u.compnd.memb[i].size*dt->u.compnd.memb[i].type->size)/old_size;
/* Add that change to the accumulated size change */
accum_change += (dt->u.compnd.memb[i].type->size - (int)old_size);
/* Add that change to the accumulated size change */
accum_change += (dt->u.compnd.memb[i].type->size - (int)old_size);
} /* end if */
} /* end if */
} /* end if */
} /* end for */
} /* end for */
/* Apply the accumulated size change to the datatype */
dt->size += accum_change;
} /* end case */
/* Apply the accumulated size change to the datatype */
dt->size += accum_change;
} /* end if */
break;
/* Recurse on the VL information if it's VL or compound, then free VL sequence */
case H5T_VLEN:
/* Recurse if it's VL or compound */
if(dt->parent->type==H5T_COMPOUND || dt->parent->type==H5T_VLEN) {
if(H5T_vlen_mark(dt->parent,f,loc)<0)
/* (If the type is compound and the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */
if((dt->parent->type==H5T_COMPOUND && dt->parent->force_conv) || dt->parent->type==H5T_VLEN) {
if((vlen_changed=H5T_vlen_mark(dt->parent,f,loc))<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
if(vlen_changed>0)
ret_value=vlen_changed;
} /* end if */
/* Mark this VL sequence */
if(H5T_vlen_set_loc(dt,f,loc)<0)
if((vlen_changed=H5T_vlen_set_loc(dt,f,loc))<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
if(vlen_changed>0)
ret_value=vlen_changed;
break;
default: