diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2004-05-07 21:58:54 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2004-05-07 21:58:54 (GMT) |
commit | 4d0c0891c07c06b5a2243e935669d7abba1e55f8 (patch) | |
tree | 829620c51b25580dbb041be16671bbf543e631a4 | |
parent | e88f391fe1fa16695e8e6c495196202704d48f9a (diff) | |
download | hdf5-4d0c0891c07c06b5a2243e935669d7abba1e55f8.zip hdf5-4d0c0891c07c06b5a2243e935669d7abba1e55f8.tar.gz hdf5-4d0c0891c07c06b5a2243e935669d7abba1e55f8.tar.bz2 |
[svn-r8491] Purpose: Bug fix
Description: For certain compiler(PGI we know so far), during conversion
from float or double to unsigned long long, it does round-up when the
fraction part is greater than 0.5, which shouldn't happen.
Solution: check it during configuration and compensate this offset
during testing in dtypes.
Platforms tested: verbena and fuss. verbena is the only machine with
PGI compiler. Ran it on fuss to verify it with other compiler.
-rwxr-xr-x | configure | 70 | ||||
-rw-r--r-- | configure.in | 37 |
2 files changed, 107 insertions, 0 deletions
@@ -33384,6 +33384,76 @@ else echo "${ECHO_T}no" >&6 fi +echo "$as_me:$LINENO: checking if accurately converting floating-point to unsigned long long values works" >&5 +echo $ECHO_N "checking if accurately converting floating-point to unsigned long long values works... $ECHO_C" >&6 + +if test "${hdf5_cv_fp_to_ullong_bottom_bit_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) + { + float f = 111.60; + double d = 222.55; + unsigned long long l1 = (unsigned long long)f; + unsigned long long l2 = (unsigned long long)d; + int ret = 0; + + if(l1 == 112) + ret = 1; + if(l2 == 223) + 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_fp_to_ullong_bottom_bit_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_fp_to_ullong_bottom_bit_works=no +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi + + +if test ${hdf5_cv_fp_to_ullong_bottom_bit_works} = "yes"; then + +cat >>confdefs.h <<\_ACEOF +#define FP_TO_ULLONG_BOTTOM_BIT_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 if test "${hdf5_cv_ullong_to_fp_cast_works+set}" = set; then diff --git a/configure.in b/configure.in index 4f87cd4..e4b3e57 100644 --- a/configure.in +++ b/configure.in @@ -2465,6 +2465,43 @@ else fi dnl ---------------------------------------------------------------------- +dnl Set the flag to indicate that the machine can accurately convert +dnl 'float' or 'double' to 'unsigned (long) long' values. +dnl (This flag should be set for all machines, except for PGI compiler +dnl where round-up happens when the fraction of float-point value is greater +dnl than 0.5. +dnl +AC_MSG_CHECKING([if accurately converting floating-point to unsigned long long values works]) + +AC_CACHE_VAL([hdf5_cv_fp_to_ullong_bottom_bit_works], + [AC_TRY_RUN([ + int main(void) + { + float f = 111.60; + double d = 222.55; + unsigned long long l1 = (unsigned long long)f; + unsigned long long l2 = (unsigned long long)d; + int ret = 0; + + if(l1 == 112) + ret = 1; + if(l2 == 223) + ret = 1; + +done: + exit(ret); + } + ], [hdf5_cv_fp_to_ullong_bottom_bit_works=yes], [hdf5_cv_fp_to_ullong_bottom_bit_works=no],)]) + +if test ${hdf5_cv_fp_to_ullong_bottom_bit_works} = "yes"; then + AC_DEFINE([FP_TO_ULLONG_BOTTOM_BIT_WORKS], [1], + [Define if your system can accurately convert floating-point to unsigned long long values.]) + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + +dnl ---------------------------------------------------------------------- dnl Set the flag to indicate that the machine can _compile_ dnl 'unsigned long long' to 'float' and 'double' typecasts. dnl (This flag should be set for all machines, except for under Windows when |