diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-18 22:02:19 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-18 22:02:19 (GMT) |
commit | a5984f59f71739531fb78c3933a726e73dd54328 (patch) | |
tree | 839fdd36b93e7976c97b9a351e3937266d1dd7b3 /src | |
parent | cf56cd041d119914d7a9bee79c22e59a8ce85059 (diff) | |
download | hdf5-a5984f59f71739531fb78c3933a726e73dd54328.zip hdf5-a5984f59f71739531fb78c3933a726e73dd54328.tar.gz hdf5-a5984f59f71739531fb78c3933a726e73dd54328.tar.bz2 |
[svn-r14212] Description:
Make H5Tarray_create() and H5Tget_array_dims() versioned, and drop the
"perm" parameter from the '2' versions.
Shift internal library usage to '2' versions.
Add simple regression tests for '1' versions.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'src')
-rw-r--r-- | src/H5T.c | 6 | ||||
-rw-r--r-- | src/H5Tarray.c | 121 | ||||
-rw-r--r-- | src/H5Tcommit.c | 2 | ||||
-rw-r--r-- | src/H5Tpublic.h | 11 | ||||
-rw-r--r-- | src/H5vers.txt | 2 | ||||
-rw-r--r-- | src/H5version.h | 30 |
6 files changed, 149 insertions, 23 deletions
@@ -3017,7 +3017,7 @@ H5T_create(H5T_class_t type, size_t size) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tvlen_create()"); case H5T_ARRAY: /* Array datatype */ - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tarray_create()"); + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tarray_create2()"); default: HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, NULL, "unknown data type class"); @@ -4712,7 +4712,7 @@ done: H5O_loc_t * H5T_oloc(H5T_t *dt) { - H5O_loc_t *ret_value; + H5O_loc_t *ret_value = NULL; FUNC_ENTER_NOAPI(H5T_oloc, NULL) @@ -4751,7 +4751,7 @@ done: H5G_name_t * H5T_nameof(H5T_t *dt) { - H5G_name_t *ret_value; + H5G_name_t *ret_value = NULL; FUNC_ENTER_NOAPI(H5T_nameof, NULL) diff --git a/src/H5Tarray.c b/src/H5Tarray.c index cef8f66..00f1177 100644 --- a/src/H5Tarray.c +++ b/src/H5Tarray.c @@ -53,7 +53,7 @@ H5T_init_array_interface(void) /*------------------------------------------------------------------------- - * Function: H5Tarray_create + * Function: H5Tarray_create2 * * Purpose: Create a new array data type based on the specified BASE_TYPE. * The type is an array with NDIMS dimensionality and the size of the @@ -67,21 +67,20 @@ H5T_init_array_interface(void) * Failure: Negative * * Programmer: Quincey Koziol - * Thursday, Oct 26, 2000 + * Thursday, Oct 17, 2007 * *------------------------------------------------------------------------- */ hid_t -H5Tarray_create(hid_t base_id, unsigned ndims, const hsize_t dim[/* ndims */], - const int UNUSED perm[/* ndims */]) +H5Tarray_create2(hid_t base_id, unsigned ndims, const hsize_t dim[/* ndims */]) { H5T_t *base; /* base data type */ H5T_t *dt; /* new array data type */ unsigned u; /* local index variable */ hid_t ret_value; /* return value */ - FUNC_ENTER_API(H5Tarray_create, FAIL) - H5TRACE4("i", "iIu*h*Is", base_id, ndims, dim, perm); + FUNC_ENTER_API(H5Tarray_create2, FAIL) + H5TRACE3("i", "iIu*h", base_id, ndims, dim); /* Check args */ if(ndims < 1 || ndims > H5S_MAX_RANK) @@ -93,8 +92,6 @@ H5Tarray_create(hid_t base_id, unsigned ndims, const hsize_t dim[/* ndims */], HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero-sized dimension specified") if(NULL == (base = H5I_object_verify(base_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") - if(perm) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimension permutations not supported") /* Create the actual array datatype */ if((dt = H5T_array_create(base, ndims, dim)) == NULL) @@ -106,7 +103,7 @@ H5Tarray_create(hid_t base_id, unsigned ndims, const hsize_t dim[/* ndims */], done: FUNC_LEAVE_API(ret_value) -} /* end H5Tarray_create */ +} /* end H5Tarray_create2() */ /*------------------------------------------------------------------------- @@ -234,7 +231,7 @@ H5T_get_array_ndims(const H5T_t *dt) /*------------------------------------------------------------------------- - * Function: H5Tget_array_dims + * Function: H5Tget_array_dims2 * * Purpose: Query the sizes of dimensions for an array datatype. * @@ -242,18 +239,18 @@ H5T_get_array_ndims(const H5T_t *dt) * Failure: Negative * * Programmer: Quincey Koziol - * Monday, November 6, 2000 + * Thursday, October 17, 2007 * *------------------------------------------------------------------------- */ int -H5Tget_array_dims(hid_t type_id, hsize_t dims[], int UNUSED perm[]) +H5Tget_array_dims2(hid_t type_id, hsize_t dims[]) { H5T_t *dt; /* pointer to array data type */ int ret_value; /* return value */ - FUNC_ENTER_API(H5Tget_array_dims, FAIL) - H5TRACE3("Is", "i*h*Is", type_id, dims, perm); + FUNC_ENTER_API(H5Tget_array_dims2, FAIL) + H5TRACE2("Is", "i*h", type_id, dims); /* Check args */ if(NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) @@ -266,7 +263,7 @@ H5Tget_array_dims(hid_t type_id, hsize_t dims[], int UNUSED perm[]) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get dimension sizes") done: FUNC_LEAVE_API(ret_value) -} /* end H5Tget_array_dims */ +} /* end H5Tget_array_dims2() */ /*------------------------------------------------------------------------- @@ -306,3 +303,97 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_array_dims */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/*------------------------------------------------------------------------- + * Function: H5Tarray_create1 + * + * Purpose: Create a new array data type based on the specified BASE_TYPE. + * The type is an array with NDIMS dimensionality and the size of the + * array is DIMS. The total member size should be relatively small. + * Array datatypes are currently limited to H5S_MAX_RANK number of + * dimensions and must have the number of dimensions set greater than + * 0. (i.e. 0 > ndims <= H5S_MAX_RANK) All dimensions sizes must be greater + * than 0 also. + * + * Return: Success: ID of new array data type + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, Oct 26, 2000 + * + *------------------------------------------------------------------------- + */ +hid_t +H5Tarray_create1(hid_t base_id, int ndims, const hsize_t dim[/* ndims */], + const int UNUSED perm[/* ndims */]) +{ + H5T_t *base; /* base data type */ + H5T_t *dt; /* new array data type */ + unsigned u; /* local index variable */ + hid_t ret_value; /* return value */ + + FUNC_ENTER_API(H5Tarray_create1, FAIL) + H5TRACE4("i", "iIs*h*Is", base_id, ndims, dim, perm); + + /* Check args */ + if(ndims < 1 || ndims > H5S_MAX_RANK) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimensionality") + if(!dim) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified") + for(u = 0; u < (unsigned)ndims; u++) + if(!(dim[u] > 0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero-sized dimension specified") + if(NULL == (base = H5I_object_verify(base_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") + + /* Create the actual array datatype */ + if((dt = H5T_array_create(base, (unsigned)ndims, dim)) == NULL) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create datatype") + + /* Atomize the type */ + if((ret_value = H5I_register(H5I_DATATYPE, dt)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Tarray_create1() */ + + +/*------------------------------------------------------------------------- + * Function: H5Tget_array_dims1 + * + * Purpose: Query the sizes of dimensions for an array datatype. + * + * Return: Success: Number of dimensions of the array type + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, November 6, 2000 + * + *------------------------------------------------------------------------- + */ +int +H5Tget_array_dims1(hid_t type_id, hsize_t dims[], int UNUSED perm[]) +{ + H5T_t *dt; /* pointer to array data type */ + int ret_value; /* return value */ + + FUNC_ENTER_API(H5Tget_array_dims1, FAIL) + H5TRACE3("Is", "i*h*Is", type_id, dims, perm); + + /* Check args */ + if(NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") + if(dt->shared->type != H5T_ARRAY) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype") + + /* Retrieve the sizes of the dimensions */ + if((ret_value = H5T_get_array_dims(dt, dims)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get dimension sizes") +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Tget_array_dims1() */ + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index dba5524..9739668 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -139,7 +139,7 @@ H5T_commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, { H5O_obj_create_t ocrt_info; /* Information for object creation */ H5T_obj_create_t tcrt_info; /* Information for named datatype creation */ - H5T_state_t old_state; /* The state of the datatype before H5T_commit. */ + H5T_state_t old_state = H5T_STATE_TRANSIENT; /* The state of the datatype before H5T_commit. */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_commit_named, FAIL) diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 97862b5..40a2a4d 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -528,11 +528,10 @@ H5_DLL herr_t H5Tenum_valueof(hid_t type, const char *name, H5_DLL hid_t H5Tvlen_create(hid_t base_id); /* Operations defined on array datatypes */ -H5_DLL hid_t H5Tarray_create(hid_t base_id, unsigned ndims, - const hsize_t dim[/* ndims */], - const int perm[/* ndims */]); +H5_DLL hid_t H5Tarray_create2(hid_t base_id, unsigned ndims, + const hsize_t dim[/* ndims */]); H5_DLL int H5Tget_array_ndims(hid_t type_id); -H5_DLL int H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[]); +H5_DLL int H5Tget_array_dims2(hid_t type_id, hsize_t dims[]); /* Operations defined on opaque datatypes */ H5_DLL herr_t H5Tset_tag(hid_t type, const char *tag); @@ -607,6 +606,10 @@ H5_DLL herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, /* Function prototypes */ H5_DLL herr_t H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id); H5_DLL hid_t H5Topen1(hid_t loc_id, const char *name); +H5_DLL hid_t H5Tarray_create1(hid_t base_id, int ndims, + const hsize_t dim[/* ndims */], + const int perm[/* ndims */]); +H5_DLL int H5Tget_array_dims1(hid_t type_id, hsize_t dims[], int perm[]); #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5vers.txt b/src/H5vers.txt index 4ef22d2..fb268c1 100644 --- a/src/H5vers.txt +++ b/src/H5vers.txt @@ -64,7 +64,9 @@ FUNCTION: H5Pget_filter_by_id; ; v16, v18 FUNCTION: H5Pinsert; ; v14, v18 FUNCTION: H5Pregister; ; v14, v18 FUNCTION: H5Rget_obj_type; ; v16, v18 +FUNCTION: H5Tarray_create; ; v14, v18 FUNCTION: H5Tcommit; ; v10, v18 +FUNCTION: H5Tget_array_dims; ; v14, v18 FUNCTION: H5Topen; ; v10, v18 # API typedefs diff --git a/src/H5version.h b/src/H5version.h index a9843bc..938279d 100644 --- a/src/H5version.h +++ b/src/H5version.h @@ -114,10 +114,18 @@ #define H5Rget_obj_type_vers 1 #endif /* !defined(H5Rget_obj_type_vers) */ +#if !defined(H5Tarray_create_vers) +#define H5Tarray_create_vers 1 +#endif /* !defined(H5Tarray_create_vers) */ + #if !defined(H5Tcommit_vers) #define H5Tcommit_vers 1 #endif /* !defined(H5Tcommit_vers) */ +#if !defined(H5Tget_array_dims_vers) +#define H5Tget_array_dims_vers 1 +#endif /* !defined(H5Tget_array_dims_vers) */ + #if !defined(H5Topen_vers) #define H5Topen_vers 1 #endif /* !defined(H5Topen_vers) */ @@ -358,6 +366,17 @@ #error "H5Rget_obj_type_vers set to invalid value" #endif /* H5Rget_obj_type_vers */ +#if !defined(H5Tarray_create_vers) || H5Tarray_create_vers == 2 +#ifndef H5Tarray_create_vers +#define H5Tarray_create_vers 2 +#endif /* H5Tarray_create_vers */ +#define H5Tarray_create H5Tarray_create2 +#elif H5Tarray_create_vers == 1 +#define H5Tarray_create H5Tarray_create1 +#else /* H5Tarray_create_vers */ +#error "H5Tarray_create_vers set to invalid value" +#endif /* H5Tarray_create_vers */ + #if !defined(H5Tcommit_vers) || H5Tcommit_vers == 2 #ifndef H5Tcommit_vers #define H5Tcommit_vers 2 @@ -369,6 +388,17 @@ #error "H5Tcommit_vers set to invalid value" #endif /* H5Tcommit_vers */ +#if !defined(H5Tget_array_dims_vers) || H5Tget_array_dims_vers == 2 +#ifndef H5Tget_array_dims_vers +#define H5Tget_array_dims_vers 2 +#endif /* H5Tget_array_dims_vers */ +#define H5Tget_array_dims H5Tget_array_dims2 +#elif H5Tget_array_dims_vers == 1 +#define H5Tget_array_dims H5Tget_array_dims1 +#else /* H5Tget_array_dims_vers */ +#error "H5Tget_array_dims_vers set to invalid value" +#endif /* H5Tget_array_dims_vers */ + #if !defined(H5Topen_vers) || H5Topen_vers == 2 #ifndef H5Topen_vers #define H5Topen_vers 2 |