mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-18 15:15:56 +08:00
[svn-r9826] Purpose: Bug fix
Description: Intel compiler on Linux has some problem to convert long double to unsigned int correctly. Solution: Detect the problem in configure and define a macro to skip this test if it happens. Platforms tested: eirene and fuss. Simple change.
This commit is contained in:
parent
23130b569c
commit
105bee4ead
66
configure
vendored
66
configure
vendored
@ -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
|
||||
|
31
configure.in
31
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_
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user