mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-21 01:04:10 +08:00
Replaced my_isnan with C99 isnan in h5diff.
This commit is contained in:
parent
3e22f567c4
commit
8b4d774eb9
@ -1010,6 +1010,9 @@ typedef off_t h5_stat_size_t;
|
|||||||
#ifndef HDislower
|
#ifndef HDislower
|
||||||
#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/
|
#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/
|
||||||
#endif /* HDislower */
|
#endif /* HDislower */
|
||||||
|
#ifndef HDisnan
|
||||||
|
#define HDisnan(X) isnan(X)
|
||||||
|
#endif /* HDisnan */
|
||||||
#ifndef HDisprint
|
#ifndef HDisprint
|
||||||
#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/
|
#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/
|
||||||
#endif /* HDisprint */
|
#endif /* HDisprint */
|
||||||
|
@ -243,7 +243,6 @@ typedef enum dtype_t {
|
|||||||
} dtype_t;
|
} dtype_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static hbool_t my_isnan(dtype_t type, void *val);
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
* XCAO, 11/10/2010
|
* XCAO, 11/10/2010
|
||||||
@ -1759,8 +1758,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
|
isnan1 = HDisnan(temp1_float);
|
||||||
isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
|
isnan2 = HDisnan(temp2_float);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -1794,8 +1793,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
|
isnan1 = HDisnan(temp1_float);
|
||||||
isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
|
isnan2 = HDisnan(temp2_float);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -1840,8 +1839,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
|
isnan1 = HDisnan(temp1_float);
|
||||||
isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
|
isnan2 = HDisnan(temp2_float);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -1917,8 +1916,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
|
isnan1 = HDisnan(temp1_double);
|
||||||
isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
|
isnan2 = HDisnan(temp2_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -1952,8 +1951,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
|
isnan1 = HDisnan(temp1_double);
|
||||||
isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
|
isnan2 = HDisnan(temp2_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -1997,8 +1996,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
|
isnan1 = HDisnan(temp1_double);
|
||||||
isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
|
isnan2 = HDisnan(temp2_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -2078,8 +2077,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
|
isnan1 = HDisnan(temp1_double);
|
||||||
isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
|
isnan2 = HDisnan(temp2_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -2113,8 +2112,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double);
|
isnan1 = HDisnan(temp1_double);
|
||||||
isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double);
|
isnan2 = HDisnan(temp2_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -2158,8 +2157,8 @@ static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double);
|
isnan1 = HDisnan(temp1_double);
|
||||||
isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double);
|
isnan2 = HDisnan(temp2_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -2633,8 +2632,8 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
|
isnan1 = HDisnan(temp1_float);
|
||||||
isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
|
isnan2 = HDisnan(temp2_float);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -2678,8 +2677,8 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
|
isnan1 = HDisnan(temp1_float);
|
||||||
isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
|
isnan2 = HDisnan(temp2_float);
|
||||||
}
|
}
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
if ((!isnan1 && !isnan2)) {
|
if ((!isnan1 && !isnan2)) {
|
||||||
@ -2733,8 +2732,8 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_FLOAT, &temp1_float);
|
isnan1 = HDisnan(temp1_float);
|
||||||
isnan2 = my_isnan(FLT_FLOAT, &temp2_float);
|
isnan2 = HDisnan(temp2_float);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -2843,8 +2842,8 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
|
isnan1 = HDisnan(temp1_double);
|
||||||
isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
|
isnan2 = HDisnan(temp2_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -2889,8 +2888,8 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
|
isnan1 = HDisnan(temp1_double);
|
||||||
isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
|
isnan2 = HDisnan(temp2_double);
|
||||||
}
|
}
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
if (!isnan1 && !isnan2) {
|
if (!isnan1 && !isnan2) {
|
||||||
@ -2945,8 +2944,8 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_DOUBLE, &temp1_double);
|
isnan1 = HDisnan(temp1_double);
|
||||||
isnan2 = my_isnan(FLT_DOUBLE, &temp2_double);
|
isnan2 = HDisnan(temp2_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -3062,8 +3061,8 @@ static hsize_t diff_ldouble(unsigned char *mem1,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
|
isnan1 = HDisnan(temp1_double);
|
||||||
isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
|
isnan2 = HDisnan(temp2_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -3108,8 +3107,8 @@ static hsize_t diff_ldouble(unsigned char *mem1,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double);
|
isnan1 = HDisnan(temp1_double);
|
||||||
isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double);
|
isnan2 = HDisnan(temp2_double);
|
||||||
}
|
}
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
if (!isnan1 && !isnan2) {
|
if (!isnan1 && !isnan2) {
|
||||||
@ -3162,8 +3161,8 @@ static hsize_t diff_ldouble(unsigned char *mem1,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (opts->do_nans) {
|
if (opts->do_nans) {
|
||||||
isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double);
|
isnan1 = HDisnan(temp1_double);
|
||||||
isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double);
|
isnan2 = HDisnan(temp2_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* both not NaN, do the comparison */
|
/* both not NaN, do the comparison */
|
||||||
@ -4541,8 +4540,8 @@ static hbool_t equal_double(double value, double expected, diff_opt_t *opts) {
|
|||||||
* detect NaNs
|
* detect NaNs
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
hbool_t isnan1 = my_isnan(FLT_DOUBLE, &value);
|
hbool_t isnan1 = HDisnan(value);
|
||||||
hbool_t isnan2 = my_isnan(FLT_DOUBLE, &expected);
|
hbool_t isnan2 = HDisnan(expected);
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
* we consider NaN == NaN to be true
|
* we consider NaN == NaN to be true
|
||||||
@ -4585,8 +4584,8 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts)
|
|||||||
* detect NaNs
|
* detect NaNs
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
hbool_t isnan1 = my_isnan(FLT_LDOUBLE, &value);
|
hbool_t isnan1 = HDisnan(value);
|
||||||
hbool_t isnan2 = my_isnan(FLT_LDOUBLE, &expected);
|
hbool_t isnan2 = HDisnan(expected);
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
* we consider NaN == NaN to be true
|
* we consider NaN == NaN to be true
|
||||||
@ -4627,8 +4626,8 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *opts) {
|
|||||||
* detect NaNs
|
* detect NaNs
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
hbool_t isnan1 = my_isnan(FLT_FLOAT, &value);
|
hbool_t isnan1 = HDisnan(value);
|
||||||
hbool_t isnan2 = my_isnan(FLT_FLOAT, &expected);
|
hbool_t isnan2 = HDisnan(expected);
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
* we consider NaN == NaN to be true
|
* we consider NaN == NaN to be true
|
||||||
@ -4655,79 +4654,6 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *opts) {
|
|||||||
return FALSE;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user