summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2010-04-27 21:35:53 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2010-04-27 21:35:53 (GMT)
commit6c5e42a96720ccd4c7b517af8c00c658112dc7af (patch)
tree551e515bd01f54601d530b425d45d263b5f1acb8
parentdaddb56a02bb6503e57993631e70836a10b5d9f2 (diff)
downloadhdf5-6c5e42a96720ccd4c7b517af8c00c658112dc7af.zip
hdf5-6c5e42a96720ccd4c7b517af8c00c658112dc7af.tar.gz
hdf5-6c5e42a96720ccd4c7b517af8c00c658112dc7af.tar.bz2
[svn-r18648] In H5T_get_native_type of H5Tnative.c, I changed the way that the offset, alignment, and
size of nested compound type are calculated by using H5T_cmp_offset. The old way had a bug in it (see bug #1850). Tested on jam. I tested the same change for 1.8 on amani, linew, and jam.
-rwxr-xr-xconfigure5
-rw-r--r--configure.in3
-rw-r--r--src/H5Dchunk.c2
-rw-r--r--src/H5Tnative.c16
-rw-r--r--test/ntypes.c70
-rw-r--r--tools/h5ls/h5ls.c1
6 files changed, 65 insertions, 32 deletions
diff --git a/configure b/configure
index 74d48ad..233f15e 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Id: configure.in 18589 2010-04-18 13:59:45Z hdftest .
+# From configure.in Id: configure.in 18634 2010-04-27 18:25:31Z koziol .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.65 for HDF5 1.9.68.
#
@@ -27594,6 +27594,9 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
+ #include <stdlib.h>
+ #include <string.h>
+
int main(void)
{
/* General variables */
diff --git a/configure.in b/configure.in
index 21a1d4c..218dfcd 100644
--- a/configure.in
+++ b/configure.in
@@ -3405,6 +3405,9 @@ if test ${ac_cv_sizeof_long_double} = 0; then
else
AC_CACHE_VAL([hdf5_cv_ullong_to_ldouble_precision],
[AC_TRY_RUN([
+ #include <stdlib.h>
+ #include <string.h>
+
int main(void)
{
/* General variables */
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index aad39ee..2e0b096 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -4588,7 +4588,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5D_chunk_bh_size
+ * Function: H5D_chunk_bh_info
*
* Purpose: Retrieve the amount of index storage for chunked dataset
*
diff --git a/src/H5Tnative.c b/src/H5Tnative.c
index b22e3e5..ce2c141 100644
--- a/src/H5Tnative.c
+++ b/src/H5Tnative.c
@@ -148,6 +148,11 @@ done:
* Oct 3, 2002
*
* Modifications:
+ * Raymond Lu
+ * 27 April 2010
+ * I changed the way that the offset, alignment, and size of
+ * nested compound type are calculated by using H5T_cmp_offset.
+ * The old way had a bug in it (see bug #1850).
*
*-------------------------------------------------------------------------
*/
@@ -312,12 +317,11 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member to compound datatype")
}
- /* Update size, offset and compound alignment for parent. */
- if(offset)
- *offset = *comp_size;
- if(struct_align && *struct_align < children_st_align)
- *struct_align = children_st_align;
- *comp_size += children_size;
+ /* Update size, offset and compound alignment for parent in the case of
+ * nested compound type. */
+ if(H5T_cmp_offset(comp_size, offset, children_size, (size_t)1, children_st_align,
+ struct_align) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset")
/* Close member data type */
for(i=0; i<nmemb; i++) {
diff --git a/test/ntypes.c b/test/ntypes.c
index 781dfef..33a14d1 100644
--- a/test/ntypes.c
+++ b/test/ntypes.c
@@ -298,6 +298,7 @@ test_compound_dtype2(hid_t file)
typedef struct s2 {
short c2;
long l2;
+ long long ll2;
} s2;
typedef struct s1 {
char c;
@@ -329,7 +330,8 @@ test_compound_dtype2(hid_t file)
temp_point->i = n++;
temp_point->st.c2 = (short)(i + j);
temp_point->st.l2 = (i * 5 + j * 50) * n;
- temp_point->l = (unsigned long long)((i * 10 + j * 100) * n);
+ temp_point->st.ll2 = (i * 10 + j * 100) * n;
+ temp_point->l = (unsigned long long)((i * 100 + j * 1000) * n);
} /* end for */
} /* end for */
@@ -339,37 +341,40 @@ test_compound_dtype2(hid_t file)
if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR;
/* Create compound datatype for disk storage */
-#if H5_SIZEOF_LONG==4
- if((tid2=H5Tcreate(H5T_COMPOUND, 6)) < 0) TEST_ERROR;
- if((tid=H5Tcreate(H5T_COMPOUND, 19)) < 0) TEST_ERROR;
-#elif H5_SIZEOF_LONG==8
- if((tid2=H5Tcreate(H5T_COMPOUND, 10)) < 0) TEST_ERROR;
- if((tid=H5Tcreate(H5T_COMPOUND, 23)) < 0) TEST_ERROR;
-#else
-#error "Unknown 'long' size"
-#endif
+ if((tid2=H5Tcreate(H5T_COMPOUND, sizeof(s2))) < 0) TEST_ERROR;
+ if((tid=H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR;
/* Insert and pack members */
- if(H5Tinsert(tid2, "c2", 0, H5T_STD_I16BE) < 0) TEST_ERROR;
+ if(H5Tinsert(tid2, "c2", HOFFSET(s2, c2), H5T_STD_I16BE) < 0) TEST_ERROR;
#if H5_SIZEOF_LONG == 4
- if(H5Tinsert(tid2, "l2", 2, H5T_STD_I32LE) < 0) TEST_ERROR;
+ if(H5Tinsert(tid2, "l2", HOFFSET(s2, l2), H5T_STD_I32LE) < 0) TEST_ERROR;
#elif H5_SIZEOF_LONG == 8
- if(H5Tinsert(tid2, "l2", 2, H5T_STD_I64LE) < 0) TEST_ERROR;
+ if(H5Tinsert(tid2, "l2", HOFFSET(s2, l2), H5T_STD_I64LE) < 0) TEST_ERROR;
#else
#error "Unknown 'long' size"
#endif
+#if H5_SIZEOF_LONG_LONG == 4
+ if(H5Tinsert(tid2, "ll2", HOFFSET(s2, ll2), H5T_STD_I32BE) < 0) TEST_ERROR;
+#elif H5_SIZEOF_LONG_LONG == 8
+ if(H5Tinsert(tid2, "ll2", HOFFSET(s2, ll2), H5T_STD_I64BE) < 0) TEST_ERROR;
+#else
+#error "Unknown 'long long' size"
+#endif
- if(H5Tinsert(tid, "c", 0, H5T_STD_U8LE) < 0) TEST_ERROR;
- if(H5Tinsert(tid, "i", 1, H5T_STD_I32LE) < 0) TEST_ERROR;
- if(H5Tinsert(tid, "st", 5, tid2) < 0) TEST_ERROR;
-#if H5_SIZEOF_LONG == 4
- if(H5Tinsert(tid, "l", 11, H5T_STD_U64BE) < 0) TEST_ERROR;
-#elif H5_SIZEOF_LONG == 8
- if(H5Tinsert(tid, "l", 15, H5T_STD_U64BE) < 0) TEST_ERROR;
+ if(H5Tinsert(tid, "c", HOFFSET(s1, c), H5T_STD_U8LE) < 0) TEST_ERROR;
+ if(H5Tinsert(tid, "i", HOFFSET(s1, i), H5T_STD_I32LE) < 0) TEST_ERROR;
+ if(H5Tinsert(tid, "st", HOFFSET(s1, st), tid2) < 0) TEST_ERROR;
+#if H5_SIZEOF_LONG_LONG == 4
+ if(H5Tinsert(tid, "l", HOFFSET(s1, l), H5T_STD_U32BE) < 0) TEST_ERROR;
+#elif H5_SIZEOF_LONG_LONG == 8
+ if(H5Tinsert(tid, "l", HOFFSET(s1, l), H5T_STD_U64BE) < 0) TEST_ERROR;
#else
-#error "Unknown 'long' size"
+#error "Unknown 'long long' size"
#endif
+ /* Take away the paddings */
+ if(H5Tpack(tid) < 0) TEST_ERROR;
+
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_2, tid, space,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
@@ -382,6 +387,7 @@ test_compound_dtype2(hid_t file)
/* Insert members */
if(H5Tinsert(tid_m2, "c2", HOFFSET(s2, c2), H5T_NATIVE_SHORT) < 0) TEST_ERROR;
if(H5Tinsert(tid_m2, "l2", HOFFSET(s2, l2), H5T_NATIVE_LONG) < 0) TEST_ERROR;
+ if(H5Tinsert(tid_m2, "ll2", HOFFSET(s2, ll2), H5T_NATIVE_LLONG) < 0) TEST_ERROR;
if(H5Tinsert(tid_m, "c", HOFFSET(s1, c), H5T_NATIVE_UCHAR) < 0) TEST_ERROR;
if(H5Tinsert(tid_m, "i", HOFFSET(s1, i), H5T_NATIVE_INT) < 0) TEST_ERROR;
if(H5Tinsert(tid_m, "st", HOFFSET(s1, st), tid_m2) < 0) TEST_ERROR;
@@ -410,9 +416,9 @@ test_compound_dtype2(hid_t file)
/* check the char member */
if((mem_id = H5Tget_member_type(native_type, 0)) < 0)
TEST_ERROR;
- if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_UCHAR))
+ if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_SCHAR))
TEST_ERROR;
- if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_U8LE))
+ if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I8LE))
TEST_ERROR;
if(H5T_INTEGER != H5Tget_class(mem_id))
TEST_ERROR;
@@ -429,7 +435,7 @@ test_compound_dtype2(hid_t file)
TEST_ERROR;
H5Tclose(mem_id);
- /* check the long long member */
+ /* check the unsigned long long member */
if((mem_id = H5Tget_member_type(native_type, 3)) < 0)
TEST_ERROR;
if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_ULLONG))
@@ -469,6 +475,21 @@ test_compound_dtype2(hid_t file)
TEST_ERROR;
H5Tclose(mem_id);
+ if((mem_id = H5Tget_member_type(nest_mem_id, 2)) < 0)
+ TEST_ERROR;
+ if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LLONG))
+ TEST_ERROR;
+#if H5_SIZEOF_LONG_LONG==4
+ if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I32LE)) TEST_ERROR;
+#elif H5_SIZEOF_LONG_LONG==8
+ if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64LE)) TEST_ERROR;
+#else
+#error "Unknown 'long long' size"
+#endif
+ if(H5T_INTEGER!=H5Tget_class(mem_id))
+ TEST_ERROR;
+ H5Tclose(mem_id);
+
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
@@ -496,6 +517,7 @@ test_compound_dtype2(hid_t file)
temp_point->i != temp_check->i ||
temp_point->st.c2 != temp_check->st.c2 ||
temp_point->st.l2 != temp_check->st.l2 ||
+ temp_point->st.ll2 != temp_check->st.ll2 ||
temp_point->l != temp_check->l ) {
H5_FAILED();
printf(" Read different values than written.\n");
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index c6eee3f..ab3a110 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -2403,6 +2403,7 @@ main(int argc, const char *argv[])
break;
*oname = '\0';
} /* end while */
+
if(file < 0) {
fprintf(stderr, "%s: unable to open file\n", argv[argno-1]);
HDfree(fname);