From c183d0d6f32504fc4829c57e9b9ef0d66a3923cd Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 27 Mar 2015 21:19:21 -0500 Subject: [svn-r26638] Description: Bring r26598 from trunk to 1.8 branch: Bring r26501 from the autotools_rework branch to the trunk: Remove ULLONG_TO_LDOUBLE_PRECISION macro/define, as it's targeting bugs in the FreeBSD and Cygwin compilers. Tested on: Linux/32 2.6.18 (jam) w/serial & parallel (Daily tested on trunk for 2+ days) --- config/cmake/ConfigureChecks.cmake | 8 --- config/cmake/ConversionTests.c | 79 ----------------------- config/cmake/H5pubconf.h.in | 4 -- configure | 126 +------------------------------------ configure.ac | 98 ----------------------------- src/H5Tpkg.h | 3 +- src/H5config.h.in | 4 -- test/dt_arith.c | 24 +------ 8 files changed, 5 insertions(+), 341 deletions(-) diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index e8951c6..2b4c4a3 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -259,14 +259,6 @@ ENDMACRO (H5MiscConversionTest) #----------------------------------------------------------------------------- # ---------------------------------------------------------------------- -# Set the flag to indicate that the machine can convert from -# 'unsigned long long' to 'long double' without precision loss. -# (This flag should be set for all machines, except for FreeBSD(sleipnir) -# where the last 2 bytes of mantissa are lost when compiler tries to do -# the conversion, and Cygwin where compiler doesn't do rounding correctly.) -# -H5ConversionTests (H5_ULLONG_TO_LDOUBLE_PRECISION "Checking IF converting unsigned long long to long double with precision") -# ---------------------------------------------------------------------- # Set the flag to indicate that the machine can handle overflow converting # all floating-point to all integer types. # (This flag should be set for all machines, except for Cray X1 where diff --git a/config/cmake/ConversionTests.c b/config/cmake/ConversionTests.c index 3003ef2..9a81a20 100644 --- a/config/cmake/ConversionTests.c +++ b/config/cmake/ConversionTests.c @@ -266,82 +266,3 @@ main () #endif -#ifdef H5_ULLONG_TO_LDOUBLE_PRECISION_TEST - -#include -#include -#include - -int main(void) -{ - /* General variables */ - int endian; - int tst_value = 1; - int ret = 0; - - /* For FreeBSD */ - unsigned long long l = 0xa601e80bda85fcefULL; - long double ld; - unsigned char *c1, *c2; - size_t size; - - /* For Cygwin */ - unsigned long long l_cyg = 0xfffffffffffffff0ULL; - long double ld_cyg; - unsigned char *c2_cyg; - size_t size_cyg; - - - /* Determine this system's endianess */ - c1 = (unsigned char*)calloc(1, sizeof(int)); - memcpy((void*)c1, &tst_value, sizeof(int)); - if(c1[0]==1) - endian = 0; /* little endian */ - else - endian = 1; /* big endian */ - - /* For FreeBSD */ - size = sizeof(long double); - memset(&ld, 0, size); - ld = (long double)l; - - c2 = (unsigned char*)calloc(1, size); - memcpy((void*)c2, &ld, size); - - /* Test if the last 2 bytes of mantissa are lost. Mainly for FreeBSD on Intel - * architecture(sleipnir) where it happens. */ - /*if(endian==0 && c2[0]==0 && c2[1]==0)*/ /*little endian*/ - if(endian==0 && c2[0]==0) { /*little endian*/ - ret = 1; - goto done; - } - - /* For Cygwin */ - size_cyg = sizeof(long double); - memset(&ld_cyg, 0, size); - ld_cyg = (long double)l_cyg; - - c2_cyg = (unsigned char*)calloc(1, size_cyg); - memcpy((void*)c2_cyg, &ld_cyg, size_cyg); - - /* Test if the last 4 bytes(roughly) of mantissa are rounded up. Mainly for Cygwin - * where the values like 0xffffffffffffffff, 0xfffffffffffffffe, ..., - * 0xfffffffffffff000 ... are rounded up as 0x0000403f8000000000000000 - * instead of 0x0000403effffffffffffffff, 0x0000403efffffffffffffffe, ..., - * 0x0000403efffffffffffff000 ... - */ - if(endian==0 && c2_cyg[0]==0 && c2_cyg[1]==0 && c2_cyg[2]==0 && c2_cyg[3]==0) - ret = 1; - -done: - if(c1) - free(c1); - if(c2) - free(c2); - if(c2_cyg) - free(c2_cyg); - exit(ret); -} - -#endif - diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index aa96d1c..3b46d62 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -646,10 +646,6 @@ /* Define to 1 if your declares `struct tm'. */ #cmakedefine H5_TM_IN_SYS_TIME @H5_TM_IN_SYS_TIME@ -/* Define if your system can convert unsigned long long to long double with - correct precision. */ -#cmakedefine H5_ULLONG_TO_LDOUBLE_PRECISION @H5_ULLONG_TO_LDOUBLE_PRECISION@ - /* Define using v1.6 public API symbols by default */ #cmakedefine H5_USE_16_API_DEFAULT @H5_USE_16_API_DEFAULT@ diff --git a/configure b/configure index e463958..1511239 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac Id: configure.ac 26636 2015-03-28 00:42:13Z koziol . +# From configure.ac Id: configure.ac 26637 2015-03-28 01:14:40Z koziol . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for HDF5 1.8.15-snap13. # @@ -28124,130 +28124,6 @@ $as_echo "no" >&6; } esac ## ---------------------------------------------------------------------- -## Set the flag to indicate that the machine can convert from -## 'unsigned long long' to 'long double' without precision loss. -## (This flag should be set for all machines, except for FreeBSD(sleipnir) -## where the last 2 bytes of mantissa are lost when compiler tries to do -## the conversion, and Cygwin where compiler doesn't do rounding correctly.) -## -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if converting unsigned long long to long double with precision" >&5 -$as_echo_n "checking if converting unsigned long long to long double with precision... " >&6; } - -if test ${ac_cv_sizeof_long_double} = 0; then - hdf5_cv_ullong_to_ldouble_precision=${hdf5_cv_ullong_to_ldouble_precision=no} -else - if ${hdf5_cv_ullong_to_ldouble_precision+:} false; 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. */ - - #include - #include - - int main(void) - { - /* General variables */ - int endian; - int tst_value = 1; - int ret = 0; - - /* For FreeBSD */ - unsigned long long l = 0xa601e80bda85fcefULL; - long double ld; - unsigned char *c1, *c2; - size_t size; - - /* For Cygwin */ - unsigned long long l_cyg = 0xfffffffffffffff0ULL; - long double ld_cyg; - unsigned char *c2_cyg; - size_t size_cyg; - - - /* Determine this system's endianess */ - c1 = (unsigned char*)calloc(1, sizeof(int)); - memcpy((void*)c1, &tst_value, sizeof(int)); - if(c1[0]==1) - endian = 0; /* little endian */ - else - endian = 1; /* big endian */ - - /* For FreeBSD */ - size = sizeof(long double); - memset(&ld, 0, size); - ld = (long double)l; - - c2 = (unsigned char*)calloc(1, size); - memcpy((void*)c2, &ld, size); - - /* Test if the last 2 bytes of mantissa are lost. Mainly for FreeBSD on Intel - * architecture(sleipnir) where it happens. */ - /*if(endian==0 && c2[0]==0 && c2[1]==0)*/ /*little endian*/ - if(endian==0 && c2[0]==0) { /*little endian*/ - ret = 1; - goto done; - } - - /* For Cygwin */ - size_cyg = sizeof(long double); - memset(&ld_cyg, 0, size); - ld_cyg = (long double)l_cyg; - - c2_cyg = (unsigned char*)calloc(1, size_cyg); - memcpy((void*)c2_cyg, &ld_cyg, size_cyg); - - /* Test if the last 4 bytes(roughly) of mantissa are rounded up. Mainly for Cygwin - * where the values like 0xffffffffffffffff, 0xfffffffffffffffe, ..., - * 0xfffffffffffff000 ... are rounded up as 0x0000403f8000000000000000 - * instead of 0x0000403effffffffffffffff, 0x0000403efffffffffffffffe, ..., - * 0x0000403efffffffffffff000 ... - */ - if(endian==0 && c2_cyg[0]==0 && c2_cyg[1]==0 && c2_cyg[2]==0 && c2_cyg[3]==0) - ret = 1; - - done: - if(c1) - free(c1); - if(c2) - free(c2); - if(c2_cyg) - free(c2_cyg); - exit(ret); - } - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - hdf5_cv_ullong_to_ldouble_precision=yes -else - hdf5_cv_ullong_to_ldouble_precision=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 - -fi - -if test ${hdf5_cv_ullong_to_ldouble_precision} = "yes"; then - -$as_echo "#define ULLONG_TO_LDOUBLE_PRECISION 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 - -## ---------------------------------------------------------------------- ## Set the flag to indicate that the machine can handle overflow converting ## all floating-point to all integer types. ## (This flag should be set for all machines, except for Cray X1 where diff --git a/configure.ac b/configure.ac index 5222427..dc8ba32 100644 --- a/configure.ac +++ b/configure.ac @@ -2558,104 +2558,6 @@ case "`uname`" in esac ## ---------------------------------------------------------------------- -## Set the flag to indicate that the machine can convert from -## 'unsigned long long' to 'long double' without precision loss. -## (This flag should be set for all machines, except for FreeBSD(sleipnir) -## where the last 2 bytes of mantissa are lost when compiler tries to do -## the conversion, and Cygwin where compiler doesn't do rounding correctly.) -## -AC_MSG_CHECKING([if converting unsigned long long to long double with precision]) - -if test ${ac_cv_sizeof_long_double} = 0; then - hdf5_cv_ullong_to_ldouble_precision=${hdf5_cv_ullong_to_ldouble_precision=no} -else - AC_CACHE_VAL([hdf5_cv_ullong_to_ldouble_precision], - [AC_TRY_RUN([ - #include - #include - - int main(void) - { - /* General variables */ - int endian; - int tst_value = 1; - int ret = 0; - - /* For FreeBSD */ - unsigned long long l = 0xa601e80bda85fcefULL; - long double ld; - unsigned char *c1, *c2; - size_t size; - - /* For Cygwin */ - unsigned long long l_cyg = 0xfffffffffffffff0ULL; - long double ld_cyg; - unsigned char *c2_cyg; - size_t size_cyg; - - - /* Determine this system's endianess */ - c1 = (unsigned char*)calloc(1, sizeof(int)); - memcpy((void*)c1, &tst_value, sizeof(int)); - if(c1[0]==1) - endian = 0; /* little endian */ - else - endian = 1; /* big endian */ - - /* For FreeBSD */ - size = sizeof(long double); - memset(&ld, 0, size); - ld = (long double)l; - - c2 = (unsigned char*)calloc(1, size); - memcpy((void*)c2, &ld, size); - - /* Test if the last 2 bytes of mantissa are lost. Mainly for FreeBSD on Intel - * architecture(sleipnir) where it happens. */ - /*if(endian==0 && c2[0]==0 && c2[1]==0)*/ /*little endian*/ - if(endian==0 && c2[0]==0) { /*little endian*/ - ret = 1; - goto done; - } - - /* For Cygwin */ - size_cyg = sizeof(long double); - memset(&ld_cyg, 0, size); - ld_cyg = (long double)l_cyg; - - c2_cyg = (unsigned char*)calloc(1, size_cyg); - memcpy((void*)c2_cyg, &ld_cyg, size_cyg); - - /* Test if the last 4 bytes(roughly) of mantissa are rounded up. Mainly for Cygwin - * where the values like 0xffffffffffffffff, 0xfffffffffffffffe, ..., - * 0xfffffffffffff000 ... are rounded up as 0x0000403f8000000000000000 - * instead of 0x0000403effffffffffffffff, 0x0000403efffffffffffffffe, ..., - * 0x0000403efffffffffffff000 ... - */ - if(endian==0 && c2_cyg[0]==0 && c2_cyg[1]==0 && c2_cyg[2]==0 && c2_cyg[3]==0) - ret = 1; - - done: - if(c1) - free(c1); - if(c2) - free(c2); - if(c2_cyg) - free(c2_cyg); - exit(ret); - } - ], [hdf5_cv_ullong_to_ldouble_precision=yes], [hdf5_cv_ullong_to_ldouble_precision=no],)]) -fi - -if test ${hdf5_cv_ullong_to_ldouble_precision} = "yes"; then - AC_DEFINE([ULLONG_TO_LDOUBLE_PRECISION], [1], - [Define if your system can convert unsigned long long to long double with correct precision.]) - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi - -## ---------------------------------------------------------------------- ## Set the flag to indicate that the machine can handle overflow converting ## all floating-point to all integer types. ## (This flag should be set for all machines, except for Cray X1 where diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index ffcfe0a..ab64fdc 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -135,8 +135,7 @@ * not support unsigned long long. For FreeBSD(sleipnir), the last 2 bytes of mantissa are lost when * compiler tries to do the conversion. For Cygwin, compiler doesn't do rounding correctly. * Mac OS 10.4 gives some incorrect result. */ -#if (H5_WANT_DATA_ACCURACY && \ - defined(H5_ULLONG_TO_LDOUBLE_PRECISION) && defined(H5_LLONG_TO_LDOUBLE_CORRECT)) || (!H5_WANT_DATA_ACCURACY) +#if (H5_WANT_DATA_ACCURACY && defined(H5_LLONG_TO_LDOUBLE_CORRECT)) || (!H5_WANT_DATA_ACCURACY) #define H5T_CONV_INTERNAL_ULLONG_LDOUBLE 1 #endif diff --git a/src/H5config.h.in b/src/H5config.h.in index 4baab7e..5299d44 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -557,10 +557,6 @@ /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME -/* Define if your system can convert unsigned long long to long double with - correct precision. */ -#undef ULLONG_TO_LDOUBLE_PRECISION - /* Define using v1.6 public API symbols by default */ #undef USE_16_API_DEFAULT diff --git a/test/dt_arith.c b/test/dt_arith.c index 00d03d3..8823e24 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -4495,24 +4495,6 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) } #endif /*end H5_FP_TO_ULLONG_BOTTOM_BIT_WORKS*/ -/* For GNU compilers on FreeBSD(sleipnir), during conversion from 'unsigned long long' -* to 'long double', the last 2 bytes of mantissa are lost. But this loss seems -* acceptable. We allow it to go through instead of fail it. Sometimes, there's roundup -* to the 3rd last byte of mantissa. So we only try to compare all but the last 3 bytes. -*/ -#ifndef H5_ULLONG_TO_LDOUBLE_PRECISION -#if H5_SIZEOF_LONG_DOUBLE !=0 - if(src_type==INT_ULLONG && dst_type==FLT_LDOUBLE) { - long double tmp_s, tmp_h; - HDmemcpy(&tmp_s,&buf[j*dst_size],sizeof(long double)); - HDmemcpy(&tmp_h,&hw[0],sizeof(long double)); - /*Don't compare the last 3 bytes of mantissa*/ - if(!HDmemcmp(&tmp_s+4, &tmp_h+4, sizeof(long double)-4)) - continue; /*no error*/ - } -#endif -#endif /*end H5_ULLONG_TO_LDOUBLE_PRECISION*/ - #ifdef H5_VMS /* OpenVMS converts the value of zero in char or short to negative zero in @@ -5188,9 +5170,9 @@ run_int_fp_conv(const char *name) HDputs(" Test skipped due to compiler error in handling conversion."); } #endif /* H5_LLONG_TO_LDOUBLE_CORRECT */ -#if H5_ULLONG_TO_LDOUBLE_PRECISION && H5_LLONG_TO_LDOUBLE_CORRECT +#if H5_LLONG_TO_LDOUBLE_CORRECT nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULLONG, H5T_NATIVE_LDOUBLE); -#else /* H5_ULLONG_TO_LDOUBLE_PRECISION && H5_LLONG_TO_LDOUBLE_CORRECT */ +#else /* H5_LLONG_TO_LDOUBLE_CORRECT */ { char str[256]; /*hello string */ @@ -5200,7 +5182,7 @@ run_int_fp_conv(const char *name) SKIPPED(); HDputs(" Test skipped due to compiler not handling conversion."); } -#endif /* H5_ULLONG_TO_LDOUBLE_PRECISION && H5_LLONG_TO_LDOUBLE_CORRECT */ +#endif /* H5_LLONG_TO_LDOUBLE_CORRECT */ #endif #endif -- cgit v0.12