mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[svn-r26501] Desscription:
Remove ULLONG_TO_LDOUBLE_PRECISION macro/define, as it's targeting bugs in the FreeBSD and Cygwin compilers. Tested on: MacOSX/64 10.10.2 (amazon) w/serial & parallel (h5committest not required on this branch)
This commit is contained in:
parent
b08160e38b
commit
3344302a1e
@ -258,14 +258,6 @@ ENDMACRO (H5MiscConversionTest)
|
||||
# Check various conversion capabilities
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# 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.
|
||||
|
@ -266,82 +266,3 @@ main ()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef H5_ULLONG_TO_LDOUBLE_PRECISION_TEST
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
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
|
||||
|
||||
|
@ -653,10 +653,6 @@
|
||||
/* Define to 1 if your <sys/time.h> 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@
|
||||
|
||||
|
98
configure.ac
98
configure.ac
@ -2442,104 +2442,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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
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.
|
||||
|
@ -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
|
||||
|
||||
|
@ -4489,24 +4489,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*/
|
||||
|
||||
/* Print errors */
|
||||
if (0==fails_this_test++) {
|
||||
if(run_test==TEST_NORMAL) {
|
||||
@ -5159,9 +5141,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 */
|
||||
|
||||
@ -5171,7 +5153,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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user