summaryrefslogtreecommitdiffstats
path: root/configure.in
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2005-05-25 15:59:30 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2005-05-25 15:59:30 (GMT)
commitdb223e85b2ae5113c1579a7d0f437d0226a416f5 (patch)
tree6fd9b2f41c2f10471f0eb8fa13754af04b37aee2 /configure.in
parent8ed5f2349226a268d8cf84b640ecdff3e3eded2d (diff)
downloadhdf5-db223e85b2ae5113c1579a7d0f437d0226a416f5.zip
hdf5-db223e85b2ae5113c1579a7d0f437d0226a416f5.tar.gz
hdf5-db223e85b2ae5113c1579a7d0f437d0226a416f5.tar.bz2
[svn-r10797] Purpose: A feature
Description: Cygwin compiler doesn't do rounding correctly when converting "unsigned long long" to "long double". Solution: Added test case to variable detection of "hdf5_cv_ullong_to_ldouble_precision_works". Platforms tested: sleipnir, fuss, and shanti - mainly to test configuration, don't need to run h5committest.
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in52
1 files changed, 43 insertions, 9 deletions
diff --git a/configure.in b/configure.in
index 292e484..6bc90e9 100644
--- a/configure.in
+++ b/configure.in
@@ -2646,21 +2646,31 @@ 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 the conversion, and Cygwin where compiler doesn't do rounding correctly.)
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)
{
+ /* 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;
- int endian;
- int tst_value = 1;
- int ret = 0;
+ /* 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));
@@ -2668,7 +2678,8 @@ AC_CACHE_VAL([hdf5_cv_ullong_to_ldouble_precision_works],
endian = 0; /* little endian */
else
endian = 1; /* big endian */
-
+
+ /* For FreeBSD */
size = sizeof(long double);
memset(&ld, 0, size);
ld = (long double)l;
@@ -2679,12 +2690,35 @@ AC_CACHE_VAL([hdf5_cv_ullong_to_ldouble_precision_works],
/* 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*/
+ if(endian==0 && c2[0]==0) { /*little endian*/
ret = 1;
-
- free(c1);
- free(c2);
+ 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_works=yes], [hdf5_cv_ullong_to_ldouble_precision_works=no],)])