summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure66
-rw-r--r--configure.in31
-rw-r--r--src/H5config.h.in4
-rw-r--r--test/dtypes.c16
4 files changed, 114 insertions, 3 deletions
diff --git a/configure b/configure
index e8434da..4c9ed5f 100755
--- a/configure
+++ b/configure
@@ -33914,6 +33914,72 @@ else
echo "${ECHO_T}no" >&6
fi
+echo "$as_me:$LINENO: checking if converting long double to unsigned int values works" >&5
+echo $ECHO_N "checking if converting long double to unsigned int values works... $ECHO_C" >&6
+
+if test "${hdf5_cv_ldouble_to_uint_works+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling" >&5
+echo "$as_me: error: cannot run test program while cross compiling" >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+ int main(void)
+ {
+ long double ld = 2733248032.9183987530L;
+ unsigned int i;
+ int ret = 0;
+
+ i = (unsigned int)ld;
+ if(i!=2733248032 && i!=2733248031 && i!=2733248033)
+ ret = 1;
+
+done:
+ exit(ret);
+ }
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ hdf5_cv_ldouble_to_uint_works=yes
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+( exit $ac_status )
+hdf5_cv_ldouble_to_uint_works=no
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+
+
+if test ${hdf5_cv_ldouble_to_uint_works} = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define CV_LDOUBLE_TO_UINT_WORKS 1
+_ACEOF
+
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
echo "$as_me:$LINENO: checking if compiling unsigned long long to floating-point typecasts work" >&5
echo $ECHO_N "checking if compiling unsigned long long to floating-point typecasts work... $ECHO_C" >&6
diff --git a/configure.in b/configure.in
index b9c3846..7790aab 100644
--- a/configure.in
+++ b/configure.in
@@ -2734,6 +2734,37 @@ else
AC_MSG_RESULT([no])
fi
+dnl ----------------------------------------------------------------------
+dnl Set the flag to indicate that the machine can accurately convert
+dnl 'long double' to 'unsigned int' values. (This flag should be set for
+dnl all machines, except for some Intel compilers on some Linux.)
+dnl
+AC_MSG_CHECKING([if converting long double to unsigned int values works])
+
+AC_CACHE_VAL([hdf5_cv_ldouble_to_uint_works],
+ [AC_TRY_RUN([
+ int main(void)
+ {
+ long double ld = 2733248032.9183987530L;
+ unsigned int i;
+ int ret = 0;
+
+ i = (unsigned int)ld;
+ if(i!=2733248032 && i!=2733248031 && i!=2733248033)
+ ret = 1;
+
+done:
+ exit(ret);
+ }
+ ], [hdf5_cv_ldouble_to_uint_works=yes], [hdf5_cv_ldouble_to_uint_works=no],)])
+
+if test ${hdf5_cv_ldouble_to_uint_works} = "yes"; then
+ AC_DEFINE([CV_LDOUBLE_TO_UINT_WORKS], [1],
+ [Define if your system can convert long double to unsigned int values correctly.])
+ AC_MSG_RESULT([yes])
+else
+ AC_MSG_RESULT([no])
+fi
dnl ----------------------------------------------------------------------
dnl Set the flag to indicate that the machine can _compile_
diff --git a/src/H5config.h.in b/src/H5config.h.in
index aa30b7b..6edc4fd 100644
--- a/src/H5config.h.in
+++ b/src/H5config.h.in
@@ -4,6 +4,10 @@
values. */
#undef CONVERT_DENORMAL_FLOAT
+/* Define if your system can convert long double to unsigned int values
+ correctly. */
+#undef CV_LDOUBLE_TO_UINT_WORKS
+
/* Define if `dev_t' is a scalar */
#undef DEV_T_IS_SCALAR
diff --git a/test/dtypes.c b/test/dtypes.c
index a60d968..4c46001 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -6396,10 +6396,8 @@ run_int_float_conv(const char *name)
#endif
#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG
nerrors += test_conv_int_float(name, H5T_NATIVE_LLONG, H5T_NATIVE_LDOUBLE);
-#ifdef H5_ULLONG_TO_FP_CAST_WORKS
-#ifdef H5_ULLONG_TO_LDOUBLE_PRECISION_WORKS
+#ifdef H5_ULLONG_TO_FP_CAST_WORKS && H5_ULLONG_TO_LDOUBLE_PRECISION_WORKS
nerrors += test_conv_int_float(name, H5T_NATIVE_ULLONG, H5T_NATIVE_LDOUBLE);
-#endif /*H5_ULLONG_TO_LDOUBLE_PRECISION_WORKS*/
#else /* H5_ULLONG_TO_FP_CAST_WORKS */
{
char str[256]; /*hello string */
@@ -6517,7 +6515,19 @@ run_float_int_conv(const char *name)
nerrors += test_conv_int_float(name, H5T_NATIVE_LDOUBLE, H5T_NATIVE_SHORT);
nerrors += test_conv_int_float(name, H5T_NATIVE_LDOUBLE, H5T_NATIVE_USHORT);
nerrors += test_conv_int_float(name, H5T_NATIVE_LDOUBLE, H5T_NATIVE_INT);
+#if H5_CV_LDOUBLE_TO_UINT_WORKS
nerrors += test_conv_int_float(name, H5T_NATIVE_LDOUBLE, H5T_NATIVE_UINT);
+#else /*H5_CV_LDOUBLE_TO_UINT_WORKS*/
+ {
+ char str[256]; /*string */
+
+ sprintf(str, "Testing random %s %s -> %s conversions",
+ name, "long double", "unsigned int");
+ printf("%-70s", str);
+ SKIPPED();
+ HDputs(" Test skipped due to hardware conversion error.");
+ }
+#endif /*H5_CV_LDOUBLE_TO_UINT_WORKS*/
#if H5_SIZEOF_LONG!=H5_SIZEOF_INT
nerrors += test_conv_int_float(name, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LONG);
nerrors += test_conv_int_float(name, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULONG);