summaryrefslogtreecommitdiffstats
path: root/configure.in
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2006-06-23 22:11:12 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2006-06-23 22:11:12 (GMT)
commit4dfad81062f0b195ee9fd10f0b4e5ba2f6056aeb (patch)
treedd1beab639cb485e8c4b785112f00081c4d7d321 /configure.in
parent842895a79950c2d43958831991a97802bcd58431 (diff)
downloadhdf5-4dfad81062f0b195ee9fd10f0b4e5ba2f6056aeb.zip
hdf5-4dfad81062f0b195ee9fd10f0b4e5ba2f6056aeb.tar.gz
hdf5-4dfad81062f0b195ee9fd10f0b4e5ba2f6056aeb.tar.bz2
[svn-r12435] Purpose: Bug fix
Description: Mac OS 10.4 on PowerPC chip has some errors to convert (unsigned) long long to long double. When the bit sequences are 0x003ff..., 0x007fff..., 0x00ffff..., 0x01ffff..., 0x7fffff..., the converted values are twice as big as they should be. Solution: Detect the error in configure and disable the compiler conversion and test case. Platforms tested: h5committest, Mac OS 10.4, and fuss.
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in65
1 files changed, 65 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 358b5ce..e70346d 100644
--- a/configure.in
+++ b/configure.in
@@ -3157,6 +3157,71 @@ else
fi
dnl ----------------------------------------------------------------------
+dnl Set the flag to indicate that the machine can accurately convert
+dnl '(unsigned) long long' to 'long double' values. (This flag should be set for
+dnl all machines, except for Mac OS 10.4, when the bit sequences are 003fff...,
+dnl 007fff..., 00ffff..., 01ffff..., ..., 7fffff..., the converted values are twice
+dnl as big as they should be.
+dnl
+AC_MSG_CHECKING([if correctly converting (unsigned) long long to long double values])
+
+if test ${ac_cv_sizeof_long_double} = 0; then
+ hdf5_llong_to_ldouble_correct=${hdf5_llong_to_ldouble_correct=no}
+else
+ AC_CACHE_VAL([hdf5_llong_to_ldouble_correct],
+ [AC_TRY_RUN([
+ int main(void)
+ {
+ long double ld;
+ long long ll;
+ unsigned long long ull;
+ unsigned char s[16];
+ int flag=0, ret=0;
+
+ /*Determine if long double has 16 byte in size, 11 bit exponent, and
+ *the bias is 0x3ff */
+ if(sizeof(long double) == 16) {
+ ld = 1.0L;
+ memcpy(s, &ld, 16);
+ if(s[0]==0x3f && s[1]==0xf0 && s[2]==0x00 && s[3]==0x00 &&
+ s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00)
+ flag = 1;
+ }
+
+ if(flag==1 && sizeof(long long)==8) {
+ ll = 0x01ffffffffffffffLL;
+ ld = (long double)ll;
+ memcpy(s, &ld, 16);
+ /*Check if the bit sequence is as supposed to be*/
+ if(s[0]!=0x43 || s[1]!=0x7f || s[2]!=0xff || s[3]!=0xff ||
+ s[4]!=0xff || s[5]!=0xff || s[6]!=0xff || s[7]!=0xff ||
+ s[8]!=0xf0 || s[9]!=0x00 || s[10]!=0x00 || s[11]!=0x00)
+ ret = 1;
+ }
+ if(flag==1 && sizeof(unsigned long long)==8) {
+ ull = 0x01ffffffffffffffULL;
+ ld = (long double)ull;
+ memcpy(s, &ld, 16);
+ if(s[0]!=0x43 || s[1]!=0x7f || s[2]!=0xff || s[3]!=0xff ||
+ s[4]!=0xff || s[5]!=0xff || s[6]!=0xff || s[7]!=0xff ||
+ s[8]!=0xf0 || s[9]!=0x00 || s[10]!=0x00 || s[11]!=0x00)
+ ret = 1;
+ }
+ done:
+ exit(ret);
+ }
+ ], [hdf5_llong_to_ldouble_correct=yes], [hdf5_llong_to_ldouble_correct=no],)])
+fi
+
+if test ${hdf5_llong_to_ldouble_correct} = "yes"; then
+ AC_DEFINE([LLONG_TO_LDOUBLE_CORRECT], [1],
+ [Define if your system can convert (unsigned) long long to long double values correctly.])
+ 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