summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-01-30 20:33:47 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-01-30 20:33:47 (GMT)
commita29f9e8451ffa391c8395db1142bd003f40f3aaa (patch)
treecbd191c05f7339d1fa502ed8efe880abd772fd1e /tools/lib
parent1531c49730e33e897cdfbdd0bf88267dd7f7c0f4 (diff)
downloadhdf5-a29f9e8451ffa391c8395db1142bd003f40f3aaa.zip
hdf5-a29f9e8451ffa391c8395db1142bd003f40f3aaa.tar.gz
hdf5-a29f9e8451ffa391c8395db1142bd003f40f3aaa.tar.bz2
Merge changes from develop to fix various issues
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff_array.c208
-rw-r--r--tools/lib/h5diff_attr.c1
-rw-r--r--tools/lib/h5tools.c4
-rw-r--r--tools/lib/h5tools_utils.h2
4 files changed, 74 insertions, 141 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 6cfe3d2..6667b01 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -243,7 +243,6 @@ typedef enum dtype_t {
} dtype_t;
#endif
-static hbool_t my_isnan(dtype_t type, void *val);
/*-------------------------------------------------------------------------
* XCAO, 11/10/2010
@@ -372,9 +371,7 @@ hsize_t diff_array(void *_mem1, void *_mem2, hsize_t nelmts, hsize_t hyper_start
} /* i */
close_member_types(&members);
} /* switch */
- H5TOOLS_DEBUG("diff_array finish:%d - errstat:%d", nfound, opts->err_stat);
-
- H5TOOLS_ENDDEBUG(": %d", nfound);
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
return nfound;
}
@@ -1759,8 +1756,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
- isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
+ isnan1 = HDisnan(temp1_float);
+ isnan2 = HDisnan(temp2_float);
}
/* both not NaN, do the comparison */
@@ -1794,8 +1791,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
- isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
+ isnan1 = HDisnan(temp1_float);
+ isnan2 = HDisnan(temp2_float);
}
/* both not NaN, do the comparison */
@@ -1840,8 +1837,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
- isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
+ isnan1 = HDisnan(temp1_float);
+ isnan2 = HDisnan(temp2_float);
}
/* both not NaN, do the comparison */
@@ -1917,8 +1914,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
}
/* both not NaN, do the comparison */
@@ -1952,8 +1949,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
}
/* both not NaN, do the comparison */
@@ -1997,8 +1994,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
}
/* both not NaN, do the comparison */
@@ -2078,8 +2075,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
}
/* both not NaN, do the comparison */
@@ -2113,8 +2110,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double);
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
}
/* both not NaN, do the comparison */
@@ -2158,8 +2155,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double);
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
}
/* both not NaN, do the comparison */
@@ -2215,9 +2212,7 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
done:
opts->err_stat = opts->err_stat | ret_value;
- H5TOOLS_DEBUG("diff_datum finish:%d - errstat:%d", nfound, opts->err_stat);
-
- H5TOOLS_ENDDEBUG("");
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
return nfound;
}
@@ -2633,8 +2628,8 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
- isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
+ isnan1 = HDisnan(temp1_float);
+ isnan2 = HDisnan(temp2_float);
}
/* both not NaN, do the comparison */
@@ -2678,8 +2673,8 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
- isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
+ isnan1 = HDisnan(temp1_float);
+ isnan2 = HDisnan(temp2_float);
}
/* both not NaN, do the comparison */
if ((!isnan1 && !isnan2)) {
@@ -2733,8 +2728,8 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
- isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
+ isnan1 = HDisnan(temp1_float);
+ isnan2 = HDisnan(temp2_float);
}
/* both not NaN, do the comparison */
@@ -2843,8 +2838,8 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
}
/* both not NaN, do the comparison */
@@ -2889,8 +2884,8 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
}
/* both not NaN, do the comparison */
if (!isnan1 && !isnan2) {
@@ -2945,8 +2940,8 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
}
/* both not NaN, do the comparison */
@@ -3062,8 +3057,8 @@ static hsize_t diff_ldouble(unsigned char *mem1,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
}
/* both not NaN, do the comparison */
@@ -3108,8 +3103,8 @@ static hsize_t diff_ldouble(unsigned char *mem1,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double);
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
}
/* both not NaN, do the comparison */
if (!isnan1 && !isnan2) {
@@ -3162,8 +3157,8 @@ static hsize_t diff_ldouble(unsigned char *mem1,
*-------------------------------------------------------------------------
*/
if (opts->do_nans) {
- isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double);
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
}
/* both not NaN, do the comparison */
@@ -4541,8 +4536,8 @@ static hbool_t equal_double(double value, double expected, diff_opt_t *opts) {
* detect NaNs
*-------------------------------------------------------------------------
*/
- hbool_t isnan1 = my_isnan(FLT_DOUBLE, &value);
- hbool_t isnan2 = my_isnan(FLT_DOUBLE, &expected);
+ hbool_t isnan1 = HDisnan(value);
+ hbool_t isnan2 = HDisnan(expected);
/*-------------------------------------------------------------------------
* we consider NaN == NaN to be true
@@ -4559,12 +4554,16 @@ static hbool_t equal_double(double value, double expected, diff_opt_t *opts) {
return FALSE;
}
- if (H5_DBL_ABS_EQUAL(value, expected))
- return TRUE;
-
- if (opts->use_system_epsilon)
- if (ABS((value-expected)) < DBL_EPSILON)
+ if (opts->use_system_epsilon) {
+ /* Check equality within some epsilon */
+ if (H5_DBL_ABS_EQUAL(value, expected))
+ return TRUE;
+ }
+ else {
+ /* Check bits */
+ if (!HDmemcmp(&value, &expected, sizeof(double)))
return TRUE;
+ }
return FALSE;
}
@@ -4585,8 +4584,8 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts)
* detect NaNs
*-------------------------------------------------------------------------
*/
- hbool_t isnan1 = my_isnan(FLT_LDOUBLE, &value);
- hbool_t isnan2 = my_isnan(FLT_LDOUBLE, &expected);
+ hbool_t isnan1 = HDisnan(value);
+ hbool_t isnan2 = HDisnan(expected);
/*-------------------------------------------------------------------------
* we consider NaN == NaN to be true
@@ -4603,12 +4602,16 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts)
return FALSE;
}
- if (H5_LDBL_ABS_EQUAL(value, expected))
- return TRUE;
-
- if (opts->use_system_epsilon)
- if (ABS((value-expected)) < DBL_EPSILON)
+ if (opts->use_system_epsilon) {
+ /* Check equality within some epsilon */
+ if (H5_LDBL_ABS_EQUAL(value, expected))
+ return TRUE;
+ }
+ else {
+ /* Check bits */
+ if (!HDmemcmp(&value, &expected, sizeof(long double)))
return TRUE;
+ }
return FALSE;
}
@@ -4627,8 +4630,8 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *opts) {
* detect NaNs
*-------------------------------------------------------------------------
*/
- hbool_t isnan1 = my_isnan(FLT_FLOAT, &value);
- hbool_t isnan2 = my_isnan(FLT_FLOAT, &expected);
+ hbool_t isnan1 = HDisnan(value);
+ hbool_t isnan2 = HDisnan(expected);
/*-------------------------------------------------------------------------
* we consider NaN == NaN to be true
@@ -4645,90 +4648,21 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *opts) {
return FALSE;
}
- if (H5_FLT_ABS_EQUAL(value, expected))
- return TRUE;
-
- if (opts->use_system_epsilon)
- if (ABS( (value-expected) ) < FLT_EPSILON)
+ if (opts->use_system_epsilon) {
+ /* Check equality within some epsilon */
+ if (H5_FLT_ABS_EQUAL(value, expected))
return TRUE;
-
- return FALSE;
-}
-
-/*-------------------------------------------------------------------------
- * Function: my_isnan
- *
- * Purpose: Determines whether VAL points to NaN.
- *
- * Return: TRUE or FALSE
- *-------------------------------------------------------------------------
- */
-static hbool_t my_isnan(dtype_t type, void *val) {
- hbool_t retval = FALSE;
- char s[256];
-
- if (FLT_FLOAT == type) {
- float x;
-
- HDmemcpy(&x, val, sizeof(float));
- retval = (x != x);
- }
- else if (FLT_DOUBLE == type) {
- double x;
-
- HDmemcpy(&x, val, sizeof(double));
- retval = (x != x);
- }
-#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0
- else if (FLT_LDOUBLE == type) {
- long double x;
-
- HDmemcpy(&x, val, sizeof(long double));
- retval = (x!=x);
}
-#endif
- else
- return FALSE;
-
- /*
- * Sometimes NaN==NaN (e.g., DEC Alpha) so we try to print it and see if
- * the result contains a NaN string.
- */
- if (!retval) {
- if (FLT_FLOAT == type) {
- float x;
-
- HDmemcpy(&x, val, sizeof(float));
- HDsnprintf(s, sizeof(s), "%g", (double) x);
- }
- else if (FLT_DOUBLE == type) {
- double x;
-
- HDmemcpy(&x, val, sizeof(double));
- HDsnprintf(s, sizeof(s), "%g", x);
- }
-#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0
- else if (FLT_LDOUBLE == type) {
- long double x;
-
- HDmemcpy(&x, val, sizeof(long double));
- HDsnprintf(s, sizeof(s), "%Lg", x);
- }
-#endif
- else
- return FALSE;
-
- if (HDstrstr(s, "NaN") ||
- HDstrstr(s, "NAN") ||
- HDstrstr(s, "nan") ||
- HDstrstr(s, "-1.#IND")) {
- retval = TRUE;
- }
+ else {
+ /* Check bits */
+ if (!HDmemcmp(&value, &expected, sizeof(float)))
+ return TRUE;
}
- return retval;
+ return FALSE;
}
+
/*-------------------------------------------------------------------------
*
* Local functions
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 087414d..5ad29fc 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -152,7 +152,6 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
unsigned i;
herr_t ret_value = SUCCEED;
-
H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
if(H5Oget_info3(loc1_id, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) {
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 47f6e3f..33f1e11 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -12,8 +12,8 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Purpose: A library for displaying the values of a dataset in a human
- * readable format.
+ * Purpose: A library for routines that are common
+ * amongst the various HDF5 tools.
*/
#include "h5tools.h"
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index 366800a..598930c 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -129,7 +129,7 @@ H5TOOLS_DLL void warn_msg(const char *fmt, ...);
H5TOOLS_DLL void help_ref_msg(FILE *output);
H5TOOLS_DLL void free_table(table_t *table);
#ifdef H5DUMP_DEBUG
-H5TOOLS_DLL void dump_tables(find_objs_t *info)
+H5TOOLS_DLL void dump_tables(find_objs_t *info);
#endif /* H5DUMP_DEBUG */
H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table);
H5TOOLS_DLL obj_t *search_obj(table_t *temp, const H5O_token_t *obj_token);