mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-31 17:10:47 +08:00
[svn-r26623] Description:
Bring r26513 from autotools_rework branch to trunk: Remove the LDOUBLE_TO_LLONG_ACCURATE macro/define, it's working around bugs in older SGI, HP/UX, MacOSX and Windows .NET 2003 compilers. Tested on: Linux/32 2.6.18 (jam) w/serial & parallel (Daily tested on branch for 2+ days)
This commit is contained in:
parent
f7386e173c
commit
79f59eaf4d
@ -272,16 +272,6 @@ H5ConversionTests (H5_LDOUBLE_TO_LONG_SPECIAL "Checking IF your system converts
|
||||
H5ConversionTests (H5_LONG_TO_LDOUBLE_SPECIAL "Checking IF your system can convert (unsigned) long to long double values with special algorithm")
|
||||
# ----------------------------------------------------------------------
|
||||
# Set the flag to indicate that the machine can accurately convert
|
||||
# 'long double' to '(unsigned) long long' values. (This flag should be set for
|
||||
# all machines, except for Mac OS 10.4 and SGI IRIX64 6.5. When the bit sequence
|
||||
# of long double is 0x4351ccf385ebc8a0bfcc2a3c..., the values of (unsigned)long long
|
||||
# start to go wrong on these two machines. Adjusting it higher to
|
||||
# 0x4351ccf385ebc8a0dfcc... or 0x4351ccf385ebc8a0ffcc... will make the converted
|
||||
# values wildly wrong. This test detects this wrong behavior and disable the test.
|
||||
#
|
||||
H5ConversionTests (H5_LDOUBLE_TO_LLONG_ACCURATE "Checking IF correctly converting long double to (unsigned) long long values")
|
||||
# ----------------------------------------------------------------------
|
||||
# Set the flag to indicate that the machine can accurately convert
|
||||
# '(unsigned) long long' to 'long double' values. (This flag should be set for
|
||||
# all machines, except for Mac OS 10.4, when the bit sequences are 003fff...,
|
||||
# 007fff..., 00ffff..., 01ffff..., ..., 7fffff..., the converted values are twice
|
||||
|
@ -116,45 +116,6 @@ 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)
|
||||
{
|
||||
|
@ -429,10 +429,6 @@
|
||||
/* Define if HDF5's high-level library headers should be included in hdf5.h */
|
||||
#cmakedefine H5_INCLUDE_HL @H5_INCLUDE_HL@
|
||||
|
||||
/* Define if your system can convert long double to (unsigned) long long
|
||||
values correctly. */
|
||||
#cmakedefine H5_LDOUBLE_TO_LLONG_ACCURATE @H5_LDOUBLE_TO_LLONG_ACCURATE@
|
||||
|
||||
/* Define if your system converts long double to (unsigned) long values with
|
||||
special algorithm. */
|
||||
#cmakedefine H5_LDOUBLE_TO_LONG_SPECIAL @H5_LDOUBLE_TO_LONG_SPECIAL@
|
||||
|
90
configure
vendored
90
configure
vendored
@ -28338,96 +28338,6 @@ else
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
## ----------------------------------------------------------------------
|
||||
## Set the flag to indicate that the machine can accurately convert
|
||||
## 'long double' to '(unsigned) long long' values. (This flag should be set for
|
||||
## all machines, except for Mac OS 10.4 and SGI IRIX64 6.5. When the bit sequence
|
||||
## of long double is 0x4351ccf385ebc8a0bfcc2a3c..., the values of (unsigned)long long
|
||||
## start to go wrong on these two machines. Adjusting it higher to
|
||||
## 0x4351ccf385ebc8a0dfcc... or 0x4351ccf385ebc8a0ffcc... will make the converted
|
||||
## values wildly wrong. This test detects this wrong behavior and disable the test.
|
||||
##
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if correctly converting long double to (unsigned) long long values" >&5
|
||||
$as_echo_n "checking if correctly converting long double to (unsigned) long long values... " >&6; }
|
||||
|
||||
if test ${ac_cv_sizeof_long_double} = 0; then
|
||||
hdf5_cv_ldouble_to_llong_accurate=${hdf5_cv_ldouble_to_llong_accurate=no}
|
||||
else
|
||||
if ${hdf5_cv_ldouble_to_llong_accurate+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test "$cross_compiling" = yes; then :
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
||||
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
||||
as_fn_error $? "cannot run test program while cross compiling
|
||||
See \`config.log' for more details" "$LINENO" 5; }
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
_ACEOF
|
||||
if ac_fn_c_try_run "$LINENO"; then :
|
||||
hdf5_cv_ldouble_to_llong_accurate=yes
|
||||
else
|
||||
hdf5_cv_ldouble_to_llong_accurate=no
|
||||
fi
|
||||
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
||||
conftest.$ac_objext conftest.beam conftest.$ac_ext
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if test ${hdf5_cv_ldouble_to_llong_accurate} = "yes"; then
|
||||
|
||||
$as_echo "#define LDOUBLE_TO_LLONG_ACCURATE 1" >>confdefs.h
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
## ----------------------------------------------------------------------
|
||||
## Set the flag to indicate that the machine can accurately convert
|
||||
## '(unsigned) long long' to 'long double' values. (This flag should be set for
|
||||
|
64
configure.ac
64
configure.ac
@ -2700,70 +2700,6 @@ else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
## ----------------------------------------------------------------------
|
||||
## Set the flag to indicate that the machine can accurately convert
|
||||
## 'long double' to '(unsigned) long long' values. (This flag should be set for
|
||||
## all machines, except for Mac OS 10.4 and SGI IRIX64 6.5. When the bit sequence
|
||||
## of long double is 0x4351ccf385ebc8a0bfcc2a3c..., the values of (unsigned)long long
|
||||
## start to go wrong on these two machines. Adjusting it higher to
|
||||
## 0x4351ccf385ebc8a0dfcc... or 0x4351ccf385ebc8a0ffcc... will make the converted
|
||||
## values wildly wrong. This test detects this wrong behavior and disable the test.
|
||||
##
|
||||
AC_MSG_CHECKING([if correctly converting long double to (unsigned) long long values])
|
||||
|
||||
if test ${ac_cv_sizeof_long_double} = 0; then
|
||||
hdf5_cv_ldouble_to_llong_accurate=${hdf5_cv_ldouble_to_llong_accurate=no}
|
||||
else
|
||||
AC_CACHE_VAL([hdf5_cv_ldouble_to_llong_accurate],
|
||||
[AC_TRY_RUN([
|
||||
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);
|
||||
}
|
||||
], [hdf5_cv_ldouble_to_llong_accurate=yes], [hdf5_cv_ldouble_to_llong_accurate=no],)])
|
||||
fi
|
||||
|
||||
if test ${hdf5_cv_ldouble_to_llong_accurate} = "yes"; then
|
||||
AC_DEFINE([LDOUBLE_TO_LLONG_ACCURATE], [1],
|
||||
[Define if your system can convert long double to (unsigned) long long values correctly.])
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
|
||||
## ----------------------------------------------------------------------
|
||||
## Set the flag to indicate that the machine can accurately convert
|
||||
## '(unsigned) long long' to 'long double' values. (This flag should be set for
|
||||
|
@ -1278,16 +1278,12 @@ H5T_init_interface(void)
|
||||
/* From floats to long long */
|
||||
status |= H5T_register(H5T_PERS_HARD, "flt_llong", native_float, native_llong, H5T__conv_float_llong, H5AC_dxpl_id, FALSE);
|
||||
status |= H5T_register(H5T_PERS_HARD, "dbl_llong", native_double, native_llong, H5T__conv_double_llong, H5AC_dxpl_id, FALSE);
|
||||
#ifdef H5T_CONV_INTERNAL_LDOUBLE_LLONG
|
||||
status |= H5T_register(H5T_PERS_HARD, "ldbl_llong", native_ldouble, native_llong, H5T__conv_ldouble_llong, H5AC_dxpl_id, FALSE);
|
||||
#endif /* H5T_CONV_INTERNAL_LDOUBLE_LLONG */
|
||||
|
||||
/* From floats to unsigned long long */
|
||||
status |= H5T_register(H5T_PERS_HARD, "flt_ullong", native_float, native_ullong, H5T__conv_float_ullong, H5AC_dxpl_id, FALSE);
|
||||
status |= H5T_register(H5T_PERS_HARD, "dbl_ullong", native_double, native_ullong, H5T__conv_double_ullong, H5AC_dxpl_id, FALSE);
|
||||
#if H5T_CONV_INTERNAL_LDOUBLE_ULLONG
|
||||
status |= H5T_register(H5T_PERS_HARD, "ldbl_ullong", native_ldouble, native_ullong, H5T__conv_ldouble_ullong, H5AC_dxpl_id, FALSE);
|
||||
#endif /* H5T_CONV_INTERNAL_LDOUBLE_ULLONG */
|
||||
|
||||
/*
|
||||
* The special no-op conversion is the fastest, so we list it last. The
|
||||
|
@ -8757,7 +8757,6 @@ H5T__conv_double_ullong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#if H5T_CONV_INTERNAL_LDOUBLE_LLONG
|
||||
herr_t
|
||||
H5T__conv_ldouble_llong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
|
||||
size_t nelmts, size_t buf_stride,
|
||||
@ -8768,7 +8767,6 @@ H5_GCC_DIAG_OFF(float-equal)
|
||||
H5T_CONV_Fx(LDOUBLE, LLONG, long double, long long, LLONG_MIN, LLONG_MAX);
|
||||
H5_GCC_DIAG_ON(float-equal)
|
||||
}
|
||||
#endif /*H5T_CONV_INTERNAL_LDOUBLE_LLONG*/
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -8786,7 +8784,6 @@ H5_GCC_DIAG_ON(float-equal)
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#if H5T_CONV_INTERNAL_LDOUBLE_ULLONG
|
||||
herr_t
|
||||
H5T__conv_ldouble_ullong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
|
||||
size_t nelmts, size_t buf_stride,
|
||||
@ -8795,7 +8792,6 @@ H5T__conv_ldouble_ullong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
|
||||
{
|
||||
H5T_CONV_Fx(LDOUBLE, ULLONG, long double, unsigned long long, 0, ULLONG_MAX);
|
||||
}
|
||||
#endif /*H5T_CONV_INTERNAL_LDOUBLE_ULLONG*/
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
|
18
src/H5Tpkg.h
18
src/H5Tpkg.h
@ -126,24 +126,6 @@
|
||||
#define H5T_CONV_INTERNAL_ULLONG_LDOUBLE 1
|
||||
#endif
|
||||
|
||||
/* Define an internal macro for converting long double to long long. SGI compilers give some incorrect
|
||||
* conversions. Mac OS 10.4 gives incorrect conversions. HP-UX 11.00 compiler generates floating exception.
|
||||
* The hard conversion on Windows .NET 2003 has a bug and gives wrong exception value. */
|
||||
#if (H5_WANT_DATA_ACCURACY && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)) || \
|
||||
(!H5_WANT_DATA_ACCURACY)
|
||||
#define H5T_CONV_INTERNAL_LDOUBLE_LLONG 1
|
||||
#endif
|
||||
|
||||
/* Define an internal macro for converting long double to unsigned long long. SGI compilers give some
|
||||
* incorrect conversions. Mac OS 10.4 gives incorrect conversions. HP-UX 11.00 compiler generates
|
||||
* floating exception. */
|
||||
#if (H5_WANT_DATA_ACCURACY && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)) || \
|
||||
(!H5_WANT_DATA_ACCURACY)
|
||||
#define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 1
|
||||
#else
|
||||
#define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 0
|
||||
#endif
|
||||
|
||||
/* Statistics about a conversion function */
|
||||
struct H5T_stats_t {
|
||||
unsigned ncalls; /*num calls to conversion function */
|
||||
|
@ -362,10 +362,6 @@
|
||||
/* Define if HDF5's high-level library headers should be included in hdf5.h */
|
||||
#undef INCLUDE_HL
|
||||
|
||||
/* Define if your system can convert long double to (unsigned) long long
|
||||
values correctly. */
|
||||
#undef LDOUBLE_TO_LLONG_ACCURATE
|
||||
|
||||
/* Define if your system converts long double to (unsigned) long values with
|
||||
special algorithm. */
|
||||
#undef LDOUBLE_TO_LONG_SPECIAL
|
||||
|
@ -5158,40 +5158,8 @@ run_fp_int_conv(const char *name)
|
||||
#endif /*H5_SIZEOF_LONG!=H5_SIZEOF_INT && H5_SIZEOF_LONG_DOUBLE!=0 */
|
||||
|
||||
#if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG && H5_SIZEOF_LONG_DOUBLE!=0
|
||||
#ifdef H5_LDOUBLE_TO_LLONG_ACCURATE
|
||||
nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LLONG);
|
||||
#else /*H5_LDOUBLE_TO_LLONG_ACCURATE*/
|
||||
{
|
||||
char str[256]; /*string */
|
||||
|
||||
HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions",
|
||||
name, "long double", "long long");
|
||||
printf("%-70s", str);
|
||||
SKIPPED();
|
||||
#if H5_SIZEOF_LONG_DOUBLE!=0
|
||||
HDputs(" Test skipped due to hardware conversion error.");
|
||||
#else
|
||||
HDputs(" Test skipped due to disabled long double.");
|
||||
#endif
|
||||
}
|
||||
#endif /*H5_LDOUBLE_TO_LLONG_ACCURATE*/
|
||||
#if defined(H5_LDOUBLE_TO_LLONG_ACCURATE)
|
||||
nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULLONG);
|
||||
#else /*H5_LDOUBLE_TO_LLONG_ACCURATE*/
|
||||
{
|
||||
char str[256]; /*string */
|
||||
|
||||
HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions",
|
||||
name, "long double", "unsigned long long");
|
||||
printf("%-70s", str);
|
||||
SKIPPED();
|
||||
#if H5_SIZEOF_LONG_DOUBLE!=0
|
||||
HDputs(" Test skipped due to hardware conversion error.");
|
||||
#else
|
||||
HDputs(" Test skipped due to disabled long double.");
|
||||
#endif
|
||||
}
|
||||
#endif /*H5_LDOUBLE_TO_LLONG_ACCURATE*/
|
||||
#endif
|
||||
#endif
|
||||
#ifndef H5_VMS
|
||||
|
Loading…
x
Reference in New Issue
Block a user