diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2009-08-20 18:40:50 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2009-08-20 18:40:50 (GMT) |
commit | 0b3b4351e7841f00cdcda837fc2960a37a923d69 (patch) | |
tree | b2b34f09112d63444133446152742e321e895beb | |
parent | f8c63dd9dcb4459dd8d57a2b2543e2e99f6d4a35 (diff) | |
download | hdf5-0b3b4351e7841f00cdcda837fc2960a37a923d69.zip hdf5-0b3b4351e7841f00cdcda837fc2960a37a923d69.tar.gz hdf5-0b3b4351e7841f00cdcda837fc2960a37a923d69.tar.bz2 |
[svn-r17392] I added a detection for the correctness of converting from unsigned long to float in the
configure.in. The Pathscale compiler on Sandia's Linux machine misinterprets the values of
unsigned long as negative during the conversion to float, when the first bit of unsigned long
is on.
Tested on jam. Need to test it on Sandia's machine.
-rwxr-xr-x | configure | 68 | ||||
-rw-r--r-- | configure.in | 50 | ||||
-rw-r--r-- | src/H5T.c | 6 | ||||
-rw-r--r-- | src/H5Tconv.c | 8 | ||||
-rw-r--r-- | src/H5Tpkg.h | 12 | ||||
-rw-r--r-- | src/H5config.h.in | 4 |
6 files changed, 140 insertions, 8 deletions
@@ -27058,6 +27058,74 @@ else $as_echo "no" >&6; } fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if accurately converting unsigned long to float values" >&5 +$as_echo_n "checking if accurately converting unsigned long to float values... " >&6; } + +if test "${hdf5_ulong_to_float_accurate+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot run test program while cross compiling +See \`config.log' for more details." "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + int main(void) + { + int ret = 0; + unsigned long l1; + unsigned long l2; + unsigned long l3; + float f1; + float f2; + float f3; + + + if(sizeof(unsigned long)==8) { + l1 = 0xffffffffffffffffUL; + l2 = 0xffffffffffff0000UL; + l3 = 0xf000000000000000UL; + + f1 = (float)l1; + f2 = (float)l2; + f3 = (float)l3; + + if((f1 < 0) || (f2 < 0) || (f3 < 0)) + ret = 1; + } + +done: + exit(ret); + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + hdf5_ulong_to_float_accurate=yes +else + hdf5_ulong_to_float_accurate=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + + +if test ${hdf5_ulong_to_float_accurate} = "yes"; then + +$as_echo "#define ULONG_TO_FLOAT_ACCURATE 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if accurately converting unsigned long long to floating-point values" >&5 $as_echo_n "checking if accurately converting unsigned long long to floating-point values... " >&6; } diff --git a/configure.in b/configure.in index 881051b..2442794 100644 --- a/configure.in +++ b/configure.in @@ -3053,6 +3053,56 @@ fi dnl ---------------------------------------------------------------------- dnl Set the flag to indicate that the machine can accurately convert +dnl 'unsigned long' to 'float' values. +dnl (This flag should be set for all machines, except for Pathscale compiler +dnl on Sandia's Linux machine where the compiler interprets 'unsigned long' +dnl values as negative when the first bit of 'unsigned long' is on during +dnl the conversion to float.) +dnl +AC_MSG_CHECKING([if accurately converting unsigned long to float values]) + +AC_CACHE_VAL([hdf5_ulong_to_float_accurate], + [AC_TRY_RUN([ + int main(void) + { + int ret = 0; + unsigned long l1; + unsigned long l2; + unsigned long l3; + float f1; + float f2; + float f3; + + + if(sizeof(unsigned long)==8) { + l1 = 0xffffffffffffffffUL; + l2 = 0xffffffffffff0000UL; + l3 = 0xf000000000000000UL; + + f1 = (float)l1; + f2 = (float)l2; + f3 = (float)l3; + + if((f1 < 0) || (f2 < 0) || (f3 < 0)) + ret = 1; + } + +done: + exit(ret); + } + ], [hdf5_ulong_to_float_accurate=yes], [hdf5_ulong_to_float_accurate=no],)]) + +if test ${hdf5_ulong_to_float_accurate} = "yes"; then + AC_DEFINE([ULONG_TO_FLOAT_ACCURATE], [1], + [Define if your system accurately converting unsigned long to float values.]) + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + + +dnl ---------------------------------------------------------------------- +dnl Set the flag to indicate that the machine can accurately convert dnl 'unsigned (long) long' values to 'float' and 'double' values. dnl (This flag should be set for all machines, except for the SGIs, where dnl the cache value is set in the config/irix6.x config file) and Solaris @@ -1198,10 +1198,12 @@ H5T_init_interface(void) #endif /* H5T_CONV_INTERNAL_INTEGER_LDOUBLE */ /* From unsigned long to floats */ -#if H5T_CONV_INTERNAL_ULONG_FP +#if H5T_CONV_INTERNAL_ULONG_FLT status |= H5T_register(H5T_PERS_HARD, "ulong_flt", native_ulong, native_float, H5T_conv_ulong_float, H5AC_dxpl_id, FALSE); +#endif /* H5T_CONV_INTERNAL_ULONG_FLT */ +#if H5T_CONV_INTERNAL_ULONG_DBL status |= H5T_register(H5T_PERS_HARD, "ulong_dbl", native_ulong, native_double, H5T_conv_ulong_double, H5AC_dxpl_id, FALSE); -#endif /* H5T_CONV_INTERNAL_ULONG_FP */ +#endif /* H5T_CONV_INTERNAL_ULONG_DBL */ #if H5T_CONV_INTERNAL_ULONG_LDOUBLE status |= H5T_register(H5T_PERS_HARD, "ulong_ldbl", native_ulong, native_ldouble, H5T_conv_ulong_ldouble, H5AC_dxpl_id, FALSE); #endif /* H5T_CONV_INTERNAL_ULONG_LDOUBLE */ diff --git a/src/H5Tconv.c b/src/H5Tconv.c index c621bf4..08e7fa1 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -8417,7 +8417,7 @@ done: * *------------------------------------------------------------------------- */ -#if H5T_CONV_INTERNAL_ULONG_FP +#if H5T_CONV_INTERNAL_ULONG_FLT herr_t H5T_conv_ulong_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, @@ -8433,7 +8433,7 @@ H5T_conv_ulong_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, done: FUNC_LEAVE_NOAPI(ret_value) } -#endif /* H5T_CONV_INTERNAL_ULONG_FP */ +#endif /* H5T_CONV_INTERNAL_ULONG_FLT */ /*------------------------------------------------------------------------- @@ -8451,7 +8451,7 @@ done: * *------------------------------------------------------------------------- */ -#if H5T_CONV_INTERNAL_ULONG_FP +#if H5T_CONV_INTERNAL_ULONG_DBL herr_t H5T_conv_ulong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, @@ -8467,7 +8467,7 @@ H5T_conv_ulong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, done: FUNC_LEAVE_NOAPI(ret_value) } -#endif /* H5T_CONV_INTERNAL_ULONG_FP */ +#endif /* H5T_CONV_INTERNAL_ULONG_DBL */ /*------------------------------------------------------------------------- diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 7ef4b63..18bf7cf 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -133,10 +133,18 @@ #define H5T_CONV_INTERNAL_INTEGER_LDOUBLE 1 #endif -/* Define an internal macro for converting unsigned (long) long to floating numbers. +/* Define an internal macro for converting unsigned long to float. + * Pathscale compiler on Sandia's Linux machine has some problem. + * 64-bit Solaris does different rounding. */ +#if (H5_WANT_DATA_ACCURACY && H5_ULONG_TO_FLOAT_ACCURATE && H5_ULONG_TO_FP_BOTTOM_BIT_ACCURATE) || \ + (!H5_WANT_DATA_ACCURACY) +#define H5T_CONV_INTERNAL_ULONG_FLT 1 +#endif + +/* Define an internal macro for converting unsigned (long) long to double. * 64-bit Solaris does different rounding. */ #if (H5_WANT_DATA_ACCURACY && H5_ULONG_TO_FP_BOTTOM_BIT_ACCURATE) || (!H5_WANT_DATA_ACCURACY) -#define H5T_CONV_INTERNAL_ULONG_FP 1 +#define H5T_CONV_INTERNAL_ULONG_DBL 1 #endif /* Define an internal macro for converting unsigned long to long double. SGI compilers give some diff --git a/src/H5config.h.in b/src/H5config.h.in index 5877c6d..bb03fc7 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -620,6 +620,10 @@ correct precision. */ #undef ULLONG_TO_LDOUBLE_PRECISION +/* Define if your system accurately converting unsigned long to float values. + */ +#undef ULONG_TO_FLOAT_ACCURATE + /* Define if your system can accurately convert unsigned (long) long values to floating-point values. */ #undef ULONG_TO_FP_BOTTOM_BIT_ACCURATE |