From d992a4a387d543332c8fcc7e3cdebef5bcc47e7d Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 28 Apr 2004 13:42:25 -0500 Subject: [svn-r8427] Purpose: Bug fix (sorta) Description: Add hack to allow the MS Visual Studio 6 compiler to build the library. It cannot cast unsigned long long values to float or double values. So, add another configuration macro to disable this conversion in the library. Just the "hardware" conversion is disabled, so the library will still correctly convert unsigned long long to float and double values, it will just happen more slowly with the "software" conversion routine. Platforms tested: FreeBSD 4.9 (sleipnir) with "Windows" setting faked inappropriate for h5committest --- configure | 22 ++++++++++++++++++++++ configure.in | 18 ++++++++++++++++++ src/H5T.c | 2 ++ src/H5Tconv.c | 2 ++ src/H5Tpkg.h | 2 ++ src/H5config.h.in | 4 ++++ test/dtypes.c | 24 ++++++++++++++++++++++++ 7 files changed, 74 insertions(+) diff --git a/configure b/configure index b2efb89..b0d937a 100755 --- a/configure +++ b/configure @@ -33285,6 +33285,28 @@ else echo "${ECHO_T}no" >&6 fi +echo "$as_me:$LINENO: checking if compiling unsigned long long to floating-point typecasts work" >&5 +echo $ECHO_N "checking if compiling unsigned long long to floating-point typecasts work... $ECHO_C" >&6 +if test "${hdf5_cv_ullong_to_fp_cast_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + hdf5_cv_ullong_to_fp_cast_works=yes +fi + + +if test ${hdf5_cv_ullong_to_fp_cast_works} = "yes"; then + +cat >>confdefs.h <<\_ACEOF +#define ULLONG_TO_FP_CAST_WORKS 1 +_ACEOF + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + H5_VERSION="`cut -d' ' -f3 $srcdir/README.txt | head -1`" diff --git a/configure.in b/configure.in index dee22c2..61bf9d7 100644 --- a/configure.in +++ b/configure.in @@ -2398,6 +2398,24 @@ else fi dnl ---------------------------------------------------------------------- +dnl Set the flag to indicate that the machine can _compile_ +dnl 'unsigned long long' to 'float' and 'double' typecasts. +dnl (This flag should be set for all machines, except for under Windows when +dnl compiled with Visual Studio 6, where the macro value is set in the +dnl src/H5pubconf.h file) +dnl +AC_MSG_CHECKING([if compiling unsigned long long to floating-point typecasts work]) +AC_CACHE_VAL([hdf5_cv_ullong_to_fp_cast_works], [hdf5_cv_ullong_to_fp_cast_works=yes]) + +if test ${hdf5_cv_ullong_to_fp_cast_works} = "yes"; then + AC_DEFINE([ULLONG_TO_FP_CAST_WORKS], [1], + [Define if your system can compile unsigned long long to floating-point casts.]) + 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 diff --git a/src/H5T.c b/src/H5T.c index 174d1c1..6f602c8 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -1119,9 +1119,11 @@ H5T_init_interface(void) status |= H5T_register(H5T_PERS_HARD, "llong_flt", native_llong, native_float, H5T_conv_llong_float, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "llong_dbl", native_llong, native_double, H5T_conv_llong_double, H5AC_dxpl_id); +#ifdef H5_ULLONG_TO_FP_CAST_WORKS /* From unsigned long long to floats */ status |= H5T_register(H5T_PERS_HARD, "ullong_flt", native_ullong, native_float, H5T_conv_ullong_float, H5AC_dxpl_id); status |= H5T_register(H5T_PERS_HARD, "ullong_dbl", native_ullong, native_double, H5T_conv_ullong_double, H5AC_dxpl_id); +#endif /* H5_ULLONG_TO_FP_CAST_WORKS */ /* From floats to char */ status |= H5T_register(H5T_PERS_HARD, "flt_char", native_float, native_schar, H5T_conv_float_char, H5AC_dxpl_id); diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 156e359..d0d54df 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -7532,6 +7532,7 @@ done: FUNC_LEAVE_NOAPI(ret_value); } +#ifdef H5_ULLONG_TO_FP_CAST_WORKS /*------------------------------------------------------------------------- * Function: H5T_conv_ullong_float @@ -7595,6 +7596,7 @@ H5T_conv_ullong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, done: FUNC_LEAVE_NOAPI(ret_value); } +#endif /* H5_ULLONG_TO_FP_CAST_WORKS */ /*------------------------------------------------------------------------- diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index d22c733..5828ac9 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -947,6 +947,7 @@ H5_DLL herr_t H5T_conv_llong_double(hid_t src_id, hid_t dst_id, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); +#ifdef H5_ULLONG_TO_FP_CAST_WORKS H5_DLL herr_t H5T_conv_ullong_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, @@ -957,6 +958,7 @@ H5_DLL herr_t H5T_conv_ullong_double(hid_t src_id, hid_t dst_id, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); +#endif /* H5_ULLONG_TO_FP_CAST_WORKS */ H5_DLL herr_t H5T_conv_float_char(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, diff --git a/src/H5config.h.in b/src/H5config.h.in index dffdb8a..bcb1cab 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -515,6 +515,10 @@ /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME +/* Define if your system can compile unsigned long long to floating-point + casts. */ +#undef ULLONG_TO_FP_CAST_WORKS + /* Define if the HDF5 v1.6 compatibility functions are to be compiled in */ #undef WANT_H5_V1_6_COMPAT diff --git a/test/dtypes.c b/test/dtypes.c index 7e0b71b..96a3893 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -4114,10 +4114,12 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long)); hw_float = (float)(*((long_long*)aligned)); break; +#ifdef H5_ULLONG_TO_FP_CAST_WORKS case INT_ULLONG: HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long)); hw_float = (float)(*((unsigned long_long*)aligned)); break; +#endif /* H5_ULLONG_TO_FP_CAST_WORKS */ default: break; } @@ -4160,10 +4162,12 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long)); hw_double = (double)(*((long_long*)aligned)); break; +#ifdef H5_ULLONG_TO_FP_CAST_WORKS case INT_ULLONG: HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long)); hw_double = (double)(*((unsigned long_long*)aligned)); break; +#endif /* H5_ULLONG_TO_FP_CAST_WORKS */ default: break; } @@ -4206,10 +4210,12 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long)); hw_ldouble = (long double)(*((long_long*)aligned)); break; +#ifdef H5_ULLONG_TO_FP_CAST_WORKS case INT_ULLONG: HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long)); hw_ldouble = (long double)(*((unsigned long_long*)aligned)); break; +#endif /* H5_ULLONG_TO_FP_CAST_WORKS */ default: break; } @@ -5583,8 +5589,26 @@ run_int_float_conv(const char *name) nerrors += test_conv_int_float(name, H5T_NATIVE_LLONG, H5T_NATIVE_FLOAT); nerrors += test_conv_int_float(name, H5T_NATIVE_LLONG, H5T_NATIVE_DOUBLE); +#ifdef H5_ULLONG_TO_FP_CAST_WORKS nerrors += test_conv_int_float(name, H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT); nerrors += test_conv_int_float(name, H5T_NATIVE_ULLONG, H5T_NATIVE_DOUBLE); +#else /* H5_ULLONG_TO_FP_CAST_WORKS */ + { + char str[256]; /*hello string */ + + sprintf(str, "Testing random %s %s -> %s conversions", + name, "unsigned long long", "float"); + printf("%-70s", str); + SKIPPED(); + HDputs(" Test skipped due to compiler not handling conversion."); + + sprintf(str, "Testing random %s %s -> %s conversions", + name, "unsigned long long", "double"); + printf("%-70s", str); + SKIPPED(); + HDputs(" Test skipped due to compiler not handling conversion."); + } +#endif /* H5_ULLONG_TO_FP_CAST_WORKS */ #endif return nerrors; -- cgit v0.12