diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2005-01-11 18:17:01 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2005-01-11 18:17:01 (GMT) |
commit | a985c4c52596924c1cb5020ac514163c46e4ff79 (patch) | |
tree | f210749d5adec2791265434da4e3e765ebc877b1 /configure.in | |
parent | 76ba1a99d30f5808b08214ef07019672694b73da (diff) | |
download | hdf5-a985c4c52596924c1cb5020ac514163c46e4ff79.zip hdf5-a985c4c52596924c1cb5020ac514163c46e4ff79.tar.gz hdf5-a985c4c52596924c1cb5020ac514163c46e4ff79.tar.bz2 |
[svn-r9807] Purpose: bug fix
Description: For FreeBSD (sleipnir), when GNU compilers do conversion from
unsigned long long to long double, the last 2 bytes of mantissa are lost.
The impact of precision loss isn't significant.
Solution: Detect this case on FreeBSD in configure, ignore it in dtypes.c
test instead of return failure.
Platforms tested: sleipnir, fuss, modi4. These systems are mainly concerned.
Diffstat (limited to 'configure.in')
-rw-r--r-- | configure.in | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/configure.in b/configure.in index f668717..3dfacbc 100644 --- a/configure.in +++ b/configure.in @@ -2685,7 +2685,7 @@ AC_CACHE_VAL([hdf5_cv_fp_to_ullong_right_maximum], unsigned long long l2 = (unsigned long long)d1; unsigned long long l3 = (unsigned long long)d2; unsigned long long l4; - unsigned long long l5 = 0x7fffffffffffffffLLU; + unsigned long long l5 = 0x7fffffffffffffffULL; int ret = 0; if(l1 <= l5 || l2 <= l5 || l3 <= l5) @@ -2728,6 +2728,61 @@ else fi dnl ---------------------------------------------------------------------- +dnl Set the flag to indicate that the machine can convert from +dnl 'unsigned long long' to 'long double' without precision loss. +dnl (This flag should be set for all machines, except for FreeBSD(sleipnir) +dnl where the last 2 bytes of mantissa are lost when compiler tries to do +dnl the conversion.) +dnl +AC_MSG_CHECKING([if converting unsigned long long to long double with precision work]) +AC_CACHE_VAL([hdf5_cv_ullong_to_ldouble_precision_works], + [AC_TRY_RUN([ + int main(void) + { + unsigned long long l = 0xa601e80bda85fcefULL; + long double ld; + unsigned char *c1, *c2; + int endian, size; + int tst_value = 1; + int i; + int ret = 0; + + /* Determine this system's endianess */ + c1 = (unsigned char*)calloc(1, sizeof(int)); + memcpy(c1, &tst_value, sizeof(int)); + if(c1[0]==1) + endian = 0; /* little endian */ + else + endian = 1; /* big endian */ + + memset(&ld, 0, 12); + ld = (long double)l; + + size = sizeof(long double); + c2 = (unsigned char*)malloc(size); + memcpy(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*/ + ret = 1; + + free(c1); + free(c2); +done: + exit(ret); + } + ], [hdf5_cv_ullong_to_ldouble_precision_works=yes], [hdf5_cv_ullong_to_ldouble_precision_works=no],)]) + +if test ${hdf5_cv_ullong_to_ldouble_precision_works} = "yes"; then + AC_DEFINE([ULLONG_TO_LDOUBLE_PRECISION_WORKS], [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 + +dnl ---------------------------------------------------------------------- dnl Set some variables for general configuration information to be saved dnl and installed with the libraries. dnl |