summaryrefslogtreecommitdiffstats
path: root/config/cmake/ConversionTests.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2015-07-24 07:04:52 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2015-07-24 07:04:52 (GMT)
commitac5a796db2b3b35a74b69fc957fc020d42adf6ef (patch)
tree37fe5df1ad9deaac249894a3568909bc2b02d26d /config/cmake/ConversionTests.c
parent81d3377737c866deb77628b1b9e89e1fc675724a (diff)
downloadhdf5-ac5a796db2b3b35a74b69fc957fc020d42adf6ef.zip
hdf5-ac5a796db2b3b35a74b69fc957fc020d42adf6ef.tar.gz
hdf5-ac5a796db2b3b35a74b69fc957fc020d42adf6ef.tar.bz2
[svn-r27428] Bug fix: DAILYTEST-170
Description: XL compilers in ostrich (PowerPC64 linux) fail in test/dt_arith because of the removal of the LLONG_TO_LDOUBLE_CORRECT (removed in r26625) and LDOUBLE_TO_LLONG_ACCURATE (removed in r26623). Solution: Reverse revisions r26623: bring back LDOUBLE_TO_LLONG_ACCURATE configure macro r26625: bring back LLONG_TO_LDOUBLE_CORRECT configure macro r26627: bring back WANT_DATA_ACCURACY configure macro which is used together with the above two macros. This also brings back the enable-dconv-accuracy configure option. Tested: h5committested. Also tested in ostrich using the XL compilers.
Diffstat (limited to 'config/cmake/ConversionTests.c')
-rw-r--r--config/cmake/ConversionTests.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/config/cmake/ConversionTests.c b/config/cmake/ConversionTests.c
index cd2e8bb..d964bf8 100644
--- a/config/cmake/ConversionTests.c
+++ b/config/cmake/ConversionTests.c
@@ -116,6 +116,88 @@ done:
#endif
+#ifdef H5_LDOUBLE_TO_LLONG_ACCURATE_TEST
+int main(void)
+{
+ long double ld = 20041683600089727.779961L;
+ long long ll;
+ unsigned long long ull;
+ unsigned char s[16];
+ int ret = 0;
+
+ if(sizeof(long double) == 16) {
+ /*make sure the long double type is the same as the failing type
+ *which has 16 bytes in size and 11 bits of exponent. If it is,
+ *the bit sequence should be like below. It's not
+ *a decent way to check but this info isn't available. */
+ memcpy(s, &ld, 16);
+ if(s[0]==0x43 && s[1]==0x51 && s[2]==0xcc && s[3]==0xf3 &&
+ s[4]==0x85 && s[5]==0xeb && s[6]==0xc8 && s[7]==0xa0 &&
+ s[8]==0xbf && s[9]==0xcc && s[10]==0x2a && s[11]==0x3c) {
+
+ /*slightly adjust the bit sequence (s[8]=0xdf). The converted
+ *values will go wild on Mac OS 10.4 and IRIX64 6.5.*/
+ s[0]=0x43; s[1]=0x51; s[2]=0xcc; s[3]=0xf3;
+ s[4]=0x85; s[5]=0xeb; s[6]=0xc8; s[7]=0xa0;
+ s[8]=0xdf; s[9]=0xcc; s[10]=0x2a; s[11]=0x3c;
+ s[12]=0x3d; s[13]=0x85; s[14]=0x56; s[15]=0x20;
+
+ memcpy(&ld, s, 16);
+ ll = (long long)ld;
+ ull = (unsigned long long)ld;
+
+ if(ll != 20041683600089728 || ull != 20041683600089728)
+ ret = 1;
+ }
+ }
+done:
+ exit(ret);
+}
+#endif
+
+#ifdef H5_LLONG_TO_LDOUBLE_CORRECT_TEST
+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);
+}
+#endif
+
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS_TEST
#include <stdlib.h>