summaryrefslogtreecommitdiffstats
path: root/src/H5Tnative.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-12-29 14:32:06 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-12-29 14:32:06 (GMT)
commit37232bd4f0f8199f956c823cdff72ece2ca9aa16 (patch)
tree38e37f7208355500b7f223e90bf014424c63300b /src/H5Tnative.c
parent20146575aaeead9e05af73977dee863de63bf50f (diff)
downloadhdf5-37232bd4f0f8199f956c823cdff72ece2ca9aa16.zip
hdf5-37232bd4f0f8199f956c823cdff72ece2ca9aa16.tar.gz
hdf5-37232bd4f0f8199f956c823cdff72ece2ca9aa16.tar.bz2
[svn-r9729] Purpose:
Bug Fix/Code Cleanup/Doc Cleanup/Optimization/Branch Sync :-) Description: Generally speaking, this is the "signed->unsigned" change to selections. However, in the process of merging code back, things got stickier and stickier until I ended up doing a big "sync the two branches up" operation. So... I brought back all the "infrastructure" fixes from the development branch to the release branch (which I think were actually making some improvement in performance) as well as fixed several bugs which had been fixed in one branch, but not the other. I've also tagged the repository before making this checkin with the label "before_signed_unsigned_changes". Platforms tested: FreeBSD 4.10 (sleipnir) w/parallel & fphdf5 FreeBSD 4.10 (sleipnir) w/threadsafe FreeBSD 4.10 (sleipnir) w/backward compatibility Solaris 2.7 (arabica) w/"purify options" Solaris 2.8 (sol) w/FORTRAN & C++ AIX 5.x (copper) w/parallel & FORTRAN IRIX64 6.5 (modi4) w/FORTRAN Linux 2.4 (heping) w/FORTRAN & C++ Misc. update:
Diffstat (limited to 'src/H5Tnative.c')
-rw-r--r--src/H5Tnative.c382
1 files changed, 194 insertions, 188 deletions
diff --git a/src/H5Tnative.c b/src/H5Tnative.c
index 992a2ab..291c41b 100644
--- a/src/H5Tnative.c
+++ b/src/H5Tnative.c
@@ -17,23 +17,21 @@
* a "native" datatype for the H5T interface.
*/
-#define H5T_PACKAGE /*suppress error about including H5Tpkg */
+#define H5T_PACKAGE /*suppress error about including H5Tpkg */
+
+/* Interface initialization */
+#define H5_INTERFACE_INIT_FUNC H5T_init_native_interface
/* Pablo information */
/* (Put before include files to avoid problems with inline functions) */
-#define PABLO_MASK H5Tnative_mask
-
-#include "H5private.h" /*generic functions */
-#include "H5Eprivate.h" /*error handling */
-#include "H5Iprivate.h" /*ID functions */
-#include "H5Pprivate.h" /*property list */
-#include "H5MMprivate.h" /*memory management */
-#include "H5Tpkg.h" /*data-type functions */
+#define PABLO_MASK H5T_native_mask
-/* Interface initialization */
-static int interface_initialize_g = 0;
-#define INTERFACE_INIT H5T_init_native_interface
-static herr_t H5T_init_native_interface(void);
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Pprivate.h" /* Property lists */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Tpkg.h" /* Datatypes */
/* Static local functions */
static H5T_t *H5T_get_native_type(H5T_t *dt, H5T_direction_t direction,
@@ -62,9 +60,9 @@ DESCRIPTION
static herr_t
H5T_init_native_interface(void)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_native_interface);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_native_interface)
- FUNC_LEAVE_NOAPI(H5T_init());
+ FUNC_LEAVE_NOAPI(H5T_init())
} /* H5T_init_native_interface() */
@@ -108,31 +106,32 @@ H5Tget_native_type(hid_t type_id, H5T_direction_t direction)
size_t comp_size=0; /* Compound datatype's size */
hid_t ret_value; /* Return value */
- FUNC_ENTER_API(H5Tget_native_type, FAIL);
+ FUNC_ENTER_API(H5Tget_native_type, FAIL)
H5TRACE2("i","iTd",type_id,direction);
/* check argument */
if(NULL==(dt=H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
if(direction!=H5T_DIR_DEFAULT && direction!=H5T_DIR_ASCEND
&& direction!=H5T_DIR_DESCEND)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not valid direction value");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not valid direction value")
if((new_dt = H5T_get_native_type(dt, direction, NULL, NULL, &comp_size))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot retrieve native type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot retrieve native type")
if((ret_value=H5I_register(H5I_DATATYPE, new_dt)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type")
done:
/* Error cleanup */
if(ret_value<0) {
if(new_dt)
- H5T_close(new_dt);
+ if(H5T_close(new_dt)<0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release datatype")
} /* end if */
- FUNC_LEAVE_API(ret_value);
+ FUNC_LEAVE_API(ret_value)
}
@@ -148,7 +147,7 @@ done:
* Programmer: Raymond Lu
* Oct 3, 2002
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -159,22 +158,23 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
H5T_class_t h5_class; /* Class of datatype to make native */
size_t size; /* Size of datatype to make native */
size_t prec; /* Precision of datatype to make native */
- int nmemb; /* Number of members in compound & enum types */
+ int snmemb; /* Number of members in compound & enum types */
+ unsigned nmemb; /* Number of members in compound & enum types */
H5T_t *super_type; /* Super type of VL, array and enum datatypes */
H5T_t *nat_super_type; /* Native form of VL, array & enum super datatype */
H5T_t *new_type=NULL; /* New native datatype */
- int i; /* Local index variable */
+ unsigned i; /* Local index variable */
H5T_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5T_get_native_type, NULL);
+ FUNC_ENTER_NOAPI(H5T_get_native_type, NULL)
assert(dtype);
- if((h5_class = H5T_get_class(dtype))<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid class");
+ if((h5_class = H5T_get_class(dtype))==H5T_NO_CLASS)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid class")
if((size = H5T_get_size(dtype))==0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid size");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid size")
switch(h5_class) {
case H5T_INTEGER:
@@ -182,33 +182,33 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
H5T_sign_t sign; /* Signedness of integer type */
if((sign = H5T_get_sign(dtype))==H5T_SGN_ERROR)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid signess");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid signess")
prec = dtype->shared->u.atomic.prec;
-
+
if((ret_value = H5T_get_native_integer(prec, sign, direction, struct_align, offset, comp_size))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer type")
}
break;
case H5T_FLOAT:
if((ret_value = H5T_get_native_float(size, direction, struct_align, offset, comp_size))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type")
break;
case H5T_STRING:
if((ret_value=H5T_copy(dtype, H5T_COPY_TRANSIENT))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type")
if(H5T_IS_VL_STRING(dtype->shared)) {
/* Update size, offset and compound alignment for parent. */
if(H5T_cmp_offset(comp_size, offset, sizeof(char *), 1, H5T_POINTER_COMP_ALIGN_g, struct_align)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset")
} else {
/* Update size, offset and compound alignment for parent. */
if(H5T_cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, struct_align)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset")
}
break;
@@ -236,11 +236,11 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
int not_equal;
if((ret_value=H5T_copy(dtype, H5T_COPY_TRANSIENT))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type")
/* Decide if the data type is object or dataset region reference. */
if(NULL==(dt=H5I_object(H5T_STD_REF_OBJ_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type")
not_equal = H5T_cmp(ret_value, dt);
/* Update size, offset and compound alignment for parent. */
@@ -253,7 +253,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
}
if(H5T_cmp_offset(comp_size, offset, ref_size, 1, align, struct_align)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset")
}
break;
@@ -266,29 +266,30 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
size_t children_st_align=0; /* The max alignment among compound members. This'll be the compound alignment */
char **comp_mname; /* List of member names in compound type */
- if((nmemb = H5T_get_nmembers(dtype))<=0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "compound data type doesn't have any member");
+ if((snmemb = H5T_get_nmembers(dtype))<=0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "compound data type doesn't have any member")
+ H5_ASSIGN_OVERFLOW(nmemb,snmemb,int,unsigned);
if((memb_list = (H5T_t**)H5MM_malloc(nmemb*sizeof(H5T_t*)))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory")
if((memb_offset = (size_t*)H5MM_calloc(nmemb*sizeof(size_t)))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory")
if((comp_mname = (char**)H5MM_malloc(nmemb*sizeof(char*)))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory")
/* Construct child compound type and retrieve a list of their IDs, offsets, total size, and alignment for compound type. */
for(i=0; i<nmemb; i++) {
if((memb_type = H5T_get_member_type(dtype, i))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member type retrieval failed");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member type retrieval failed")
if((comp_mname[i] = H5T_get_member_name(dtype, i))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member type retrieval failed");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member type retrieval failed")
if((memb_list[i] = H5T_get_native_type(memb_type, direction, &children_st_align, &(memb_offset[i]), &children_size))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member identifier retrieval failed");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member identifier retrieval failed")
if(H5T_close(memb_type)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype")
}
/* The alignment for whole compound type */
@@ -297,12 +298,12 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
/* Construct new compound type based on native type */
if((new_type=H5T_create(H5T_COMPOUND, children_size))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot create a compound type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot create a compound type")
/* Insert members for the new compound type */
for(i=0; i<nmemb; i++) {
if(H5T_insert(new_type, comp_mname[i], memb_offset[i], memb_list[i])<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member to compound datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member to compound datatype")
}
/* Update size, offset and compound alignment for parent. */
@@ -315,7 +316,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
/* Close member data type */
for(i=0; i<nmemb; i++) {
if(H5T_close(memb_list[i])<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype")
/* Free member names in list */
H5MM_xfree(comp_mname[i]);
@@ -340,40 +341,41 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
/* Retrieve base type for enumarate type */
if((super_type=H5T_get_super(dtype))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get base type for enumarate type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get base type for enumarate type")
if((nat_super_type = H5T_get_native_type(super_type, direction, struct_align, offset, comp_size))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "base native type retrieval failed");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "base native type retrieval failed")
if((super_type_id=H5I_register(H5I_DATATYPE, super_type))<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot register datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot register datatype")
if((nat_super_type_id=H5I_register(H5I_DATATYPE, nat_super_type))<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot register datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot register datatype")
/* Allocate room for the enum values */
if((tmp_memb_value = H5MM_calloc(H5T_get_size(super_type)))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory")
if((memb_value = H5MM_calloc(H5T_get_size(nat_super_type)))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory")
/* Construct new enum type based on native type */
if((new_type=H5T_enum_create(nat_super_type))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create enum type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create enum type")
/* Retrieve member info and insert members into new enum type */
- if((nmemb = H5T_get_nmembers(dtype))<=0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "enumarate data type doesn't have any member");
+ if((snmemb = H5T_get_nmembers(dtype))<=0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "enumarate data type doesn't have any member")
+ H5_ASSIGN_OVERFLOW(nmemb,snmemb,int,unsigned);
for(i=0; i<nmemb; i++) {
if((memb_name=H5T_get_member_name(dtype, i))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member name");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member name")
if(H5T_get_member_value(dtype, i, tmp_memb_value)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value")
HDmemcpy(memb_value, tmp_memb_value, H5T_get_size(super_type));
if(H5Tconvert(super_type_id, nat_super_type_id, 1, memb_value, NULL, H5P_DEFAULT)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value")
if(H5T_enum_insert(new_type, memb_name, memb_value)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member")
H5MM_xfree(memb_name);
}
H5MM_xfree(memb_value);
@@ -381,10 +383,10 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
/* Close base type */
if(H5Tclose(nat_super_type_id)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype")
/* Close super type */
if(H5Tclose(super_type_id)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype")
ret_value = new_type;
}
@@ -392,7 +394,8 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
case H5T_ARRAY:
{
- int array_rank; /* Array's rank */
+ int sarray_rank; /* Array's rank */
+ unsigned array_rank; /* Array's rank */
hsize_t *dims = NULL; /* Dimension sizes for array */
hsize_t nelems = 1;
size_t super_offset=0;
@@ -400,37 +403,38 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
size_t super_align=0;
/* Retrieve dimension information for array data type */
- if((array_rank=H5T_get_array_ndims(dtype))<=0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension rank");
+ if((sarray_rank=H5T_get_array_ndims(dtype))<=0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension rank")
+ H5_ASSIGN_OVERFLOW(array_rank,sarray_rank,int,unsigned);
if((dims = (hsize_t*)H5MM_malloc(array_rank*sizeof(hsize_t)))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory")
if(H5T_get_array_dims(dtype, dims, NULL)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension size");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension size")
/* Retrieve base type for array type */
if((super_type=H5T_get_super(dtype))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for enumarate type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for enumarate type")
if((nat_super_type = H5T_get_native_type(super_type, direction, &super_align,
&super_offset, &super_size))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed")
/* Close super type */
if(H5T_close(super_type)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype")
/* Create a new array type based on native type */
- if((new_type=H5T_array_create(nat_super_type, array_rank, dims, NULL))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create array type");
+ if((new_type=H5T_array_create(nat_super_type, sarray_rank, dims, NULL))==NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create array type")
/* Close base type */
if(H5T_close(nat_super_type)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype")
for(i=0; i<array_rank; i++)
nelems *= dims[i];
H5_CHECK_OVERFLOW(nelems,hsize_t,size_t);
if(H5T_cmp_offset(comp_size, offset, super_size, (size_t)nelems, super_align, struct_align)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset")
H5MM_xfree(dims);
ret_value = new_type;
@@ -445,47 +449,50 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
/* Retrieve base type for array type */
if((super_type=H5T_get_super(dtype))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for enumarate type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for enumarate type")
/* Don't need alignment, offset information if this VL isn't a field of compound type. If it
* is, go to a few steps below to compute the information directly. */
if((nat_super_type = H5T_get_native_type(super_type, direction, NULL, NULL, &super_size))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed")
/* Close super type */
if(H5T_close(super_type)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype")
/* Create a new array type based on native type */
if((new_type=H5T_vlen_create(nat_super_type))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create VL type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create VL type")
/* Close base type */
if(H5T_close(nat_super_type)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype")
/* Update size, offset and compound alignment for parent compound type directly. */
vl_align = H5T_HVL_COMP_ALIGN_g;
vl_size = sizeof(hvl_t);
if(H5T_cmp_offset(comp_size, offset, vl_size, 1, vl_align, struct_align)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset")
ret_value = new_type;
}
break;
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
default:
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "data type doesn't match any native type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "data type doesn't match any native type")
}
done:
/* Error cleanup */
if(ret_value==NULL) {
if(new_type)
- H5T_close(new_type);
+ if(H5T_close(new_type)<0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, NULL, "unable to release datatype")
} /* end if */
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -530,71 +537,70 @@ H5T_get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction,
FUNC_ENTER_NOAPI(H5T_get_native_integer, NULL);
- if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND)
- {
- if(prec<=H5Tget_precision(H5T_NATIVE_SCHAR)) {
- match=H5T_NATIVE_INT_MATCH_CHAR;
- native_size = sizeof(char);
- } else if(prec<=H5Tget_precision(H5T_NATIVE_SHORT)) {
- match=H5T_NATIVE_INT_MATCH_SHORT;
- native_size = sizeof(short);
- } else if(prec<=H5Tget_precision(H5T_NATIVE_INT)) {
- match=H5T_NATIVE_INT_MATCH_INT;
- native_size = sizeof(int);
- } else if(prec<=H5Tget_precision(H5T_NATIVE_LONG)) {
- match=H5T_NATIVE_INT_MATCH_LONG;
- native_size = sizeof(long);
- } else if(prec<=H5Tget_precision(H5T_NATIVE_LLONG)) {
- match=H5T_NATIVE_INT_MATCH_LLONG;
- native_size = sizeof(long_long);
- } else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */
- match=H5T_NATIVE_INT_MATCH_LLONG;
- native_size = sizeof(long_long);
- }
- } else if(direction == H5T_DIR_DESCEND) {
- if(prec>=H5Tget_precision(H5T_NATIVE_LLONG)) {
- match=H5T_NATIVE_INT_MATCH_LLONG;
- native_size = sizeof(long_long);
- } else if(prec>=H5Tget_precision(H5T_NATIVE_LONG)) {
- if(prec==H5Tget_precision(H5T_NATIVE_LONG)) {
- match=H5T_NATIVE_INT_MATCH_LONG;
- native_size = sizeof(long);
- } else {
- match=H5T_NATIVE_INT_MATCH_LLONG;
- native_size = sizeof(long_long);
- }
- }
- else if(prec>=H5Tget_precision(H5T_NATIVE_INT)) {
- if(prec==H5Tget_precision(H5T_NATIVE_INT)) {
- match=H5T_NATIVE_INT_MATCH_INT;
- native_size = sizeof(int);
- } else {
- match=H5T_NATIVE_INT_MATCH_LONG;
- native_size = sizeof(long);
- }
- }
- else if(prec>=H5Tget_precision(H5T_NATIVE_SHORT)) {
- if(prec==H5Tget_precision(H5T_NATIVE_SHORT)) {
- match=H5T_NATIVE_INT_MATCH_SHORT;
- native_size = sizeof(short);
- } else {
- match=H5T_NATIVE_INT_MATCH_INT;
- native_size = sizeof(int);
- }
- }
- else if(prec>=H5Tget_precision(H5T_NATIVE_SCHAR)) {
- if(prec==H5Tget_precision(H5T_NATIVE_SCHAR)) {
- match=H5T_NATIVE_INT_MATCH_CHAR;
- native_size = sizeof(char);
- } else {
- match=H5T_NATIVE_INT_MATCH_SHORT;
- native_size = sizeof(short);
- }
- }
- else { /* If no native type matches the querried datatype, simple choose the type of smallest size. */
- match=H5T_NATIVE_INT_MATCH_CHAR;
- native_size = sizeof(char);
- }
+ if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) {
+ if(prec<=H5Tget_precision(H5T_NATIVE_SCHAR)) {
+ match=H5T_NATIVE_INT_MATCH_CHAR;
+ native_size = sizeof(char);
+ } else if(prec<=H5Tget_precision(H5T_NATIVE_SHORT)) {
+ match=H5T_NATIVE_INT_MATCH_SHORT;
+ native_size = sizeof(short);
+ } else if(prec<=H5Tget_precision(H5T_NATIVE_INT)) {
+ match=H5T_NATIVE_INT_MATCH_INT;
+ native_size = sizeof(int);
+ } else if(prec<=H5Tget_precision(H5T_NATIVE_LONG)) {
+ match=H5T_NATIVE_INT_MATCH_LONG;
+ native_size = sizeof(long);
+ } else if(prec<=H5Tget_precision(H5T_NATIVE_LLONG)) {
+ match=H5T_NATIVE_INT_MATCH_LLONG;
+ native_size = sizeof(long_long);
+ } else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */
+ match=H5T_NATIVE_INT_MATCH_LLONG;
+ native_size = sizeof(long_long);
+ }
+ } else if(direction == H5T_DIR_DESCEND) {
+ if(prec>=H5Tget_precision(H5T_NATIVE_LLONG)) {
+ match=H5T_NATIVE_INT_MATCH_LLONG;
+ native_size = sizeof(long_long);
+ } else if(prec>=H5Tget_precision(H5T_NATIVE_LONG)) {
+ if(prec==H5Tget_precision(H5T_NATIVE_LONG)) {
+ match=H5T_NATIVE_INT_MATCH_LONG;
+ native_size = sizeof(long);
+ } else {
+ match=H5T_NATIVE_INT_MATCH_LLONG;
+ native_size = sizeof(long_long);
+ }
+ }
+ else if(prec>=H5Tget_precision(H5T_NATIVE_INT)) {
+ if(prec==H5Tget_precision(H5T_NATIVE_INT)) {
+ match=H5T_NATIVE_INT_MATCH_INT;
+ native_size = sizeof(int);
+ } else {
+ match=H5T_NATIVE_INT_MATCH_LONG;
+ native_size = sizeof(long);
+ }
+ }
+ else if(prec>=H5Tget_precision(H5T_NATIVE_SHORT)) {
+ if(prec==H5Tget_precision(H5T_NATIVE_SHORT)) {
+ match=H5T_NATIVE_INT_MATCH_SHORT;
+ native_size = sizeof(short);
+ } else {
+ match=H5T_NATIVE_INT_MATCH_INT;
+ native_size = sizeof(int);
+ }
+ }
+ else if(prec>=H5Tget_precision(H5T_NATIVE_SCHAR)) {
+ if(prec==H5Tget_precision(H5T_NATIVE_SCHAR)) {
+ match=H5T_NATIVE_INT_MATCH_CHAR;
+ native_size = sizeof(char);
+ } else {
+ match=H5T_NATIVE_INT_MATCH_SHORT;
+ native_size = sizeof(short);
+ }
+ }
+ else { /* If no native type matches the queried datatype, simply choose the type of smallest size. */
+ match=H5T_NATIVE_INT_MATCH_CHAR;
+ native_size = sizeof(char);
+ }
}
/* Set the appropriate native datatype information */
@@ -643,25 +649,25 @@ H5T_get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction,
align = H5T_NATIVE_LLONG_COMP_ALIGN_g;
break;
+ case H5T_NATIVE_INT_MATCH_UNKNOWN:
default:
- assert(0 && "Unknown native integer match!");
- break;
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "Unknown native integer match")
} /* end switch */
/* Create new native type */
assert(tid>=0);
if(NULL==(dt=H5I_object(tid)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type")
if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type")
/* compute size and offset of compound type member. */
if(H5T_cmp_offset(comp_size, offset, native_size, 1, align, struct_align)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -688,7 +694,7 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig
H5T_t *dt=NULL; /* Appropriate native datatype to copy */
hid_t tid=(-1); /* Datatype ID of appropriate native datatype */
size_t align=0; /* Alignment necessary for native datatype */
- size_t native_size=0; /* Datatype size of the native type */
+ size_t native_size=0; /* Datatype size of the native type */
enum match_type { /* The different kinds of floating point types we can match */
H5T_NATIVE_FLOAT_MATCH_FLOAT,
H5T_NATIVE_FLOAT_MATCH_DOUBLE,
@@ -697,50 +703,50 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig
} match=H5T_NATIVE_FLOAT_MATCH_UNKNOWN;
H5T_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5T_get_native_float, NULL);
+ FUNC_ENTER_NOAPI(H5T_get_native_float, NULL)
assert(size>0);
if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) {
if(size<=sizeof(float)) {
match=H5T_NATIVE_FLOAT_MATCH_FLOAT;
- native_size = sizeof(float);
+ native_size = sizeof(float);
} else if(size<=sizeof(double)) {
match=H5T_NATIVE_FLOAT_MATCH_DOUBLE;
- native_size = sizeof(double);
+ native_size = sizeof(double);
} else if(size<=sizeof(long double)) {
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
- native_size = sizeof(long double);
+ native_size = sizeof(long double);
} else { /* If not match, return the biggest datatype */
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
- native_size = sizeof(long double);
- }
+ native_size = sizeof(long double);
+ }
} else {
if(size>=sizeof(long double)) {
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
- native_size = sizeof(long double);
+ native_size = sizeof(long double);
} else if(size>=sizeof(double)) {
if(size==sizeof(double)) {
match=H5T_NATIVE_FLOAT_MATCH_DOUBLE;
- native_size = sizeof(double);
+ native_size = sizeof(double);
} else {
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
- native_size = sizeof(long double);
- }
+ native_size = sizeof(long double);
+ }
}
else if(size>=sizeof(float)) {
if(size==sizeof(float)) {
match=H5T_NATIVE_FLOAT_MATCH_FLOAT;
- native_size = sizeof(float);
+ native_size = sizeof(float);
} else {
match=H5T_NATIVE_FLOAT_MATCH_DOUBLE;
- native_size = sizeof(double);
- }
+ native_size = sizeof(double);
+ }
}
else {
match=H5T_NATIVE_FLOAT_MATCH_FLOAT;
- native_size = sizeof(float);
- }
+ native_size = sizeof(float);
+ }
}
/* Set the appropriate native floating point information */
@@ -760,40 +766,40 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig
align = H5T_NATIVE_LDOUBLE_COMP_ALIGN_g;
break;
+ case H5T_NATIVE_FLOAT_MATCH_UNKNOWN:
default:
- assert(0 && "Unknown native floating-point match!");
- break;
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "Unknown native floating-point match")
} /* end switch */
/* Create new native type */
assert(tid>=0);
if(NULL==(dt=H5I_object(tid)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type")
if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type")
/* compute offset of compound type member. */
if(H5T_cmp_offset(comp_size, offset, native_size, 1, align, struct_align)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
/*-------------------------------------------------------------------------
- * Function: H5T_cmp_offset
+ * Function: H5T_cmp_offset
*
- * Purpose: This function is only for convenience. It computes the
+ * Purpose: This function is only for convenience. It computes the
* compound type size, offset of the member being considered
* and the alignment for the whole compound type.
*
- * Return: Success: Non-negative value.
+ * Return: Success: Non-negative value.
*
- * Failure: Negative value.
+ * Failure: Negative value.
*
- * Programmer: Raymond Lu
- * December 10, 2002
+ * Programmer: Raymond Lu
+ * December 10, 2002
*
* Modifications:
*
@@ -805,7 +811,7 @@ H5T_cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size,
{
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI(H5T_cmp_offset, FAIL);
+ FUNC_ENTER_NOAPI(H5T_cmp_offset, FAIL)
if(offset && comp_size) {
if(align>1 && *comp_size%align) {
@@ -823,6 +829,6 @@ H5T_cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size,
*struct_align = align;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}