From 4da7b1ee9b462925818cf704c89a72fef5f55e4d Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 31 Dec 2003 15:36:37 -0500 Subject: [svn-r8009] Purpose: Bug fix Description: Add special-case handling to floating-point conversion tests to avoid problems with denormalized values on Cray T3E & T90 platforms. (Still not working on Cray SV1, but at least it's closer). Solution: Detect denormalized values and don't try to operate on them on the Crays. Platforms tested: FreeBSD 4.9 (sleipnir) Cray T3E (hubble.cray.com) Cray T90 (gypsy.cray.com) --- config/sv1-cray | 4 + config/unicos10.0.X | 4 + config/unicosmk2.0.6.X | 4 + configure | 26 +- configure.in | 19 +- src/H5config.h.in | 10 + src/H5private.h | 11 + test/dtypes.c | 1169 ++++++++++++++++++++++-------------------------- 8 files changed, 613 insertions(+), 634 deletions(-) diff --git a/config/sv1-cray b/config/sv1-cray index a60a2be..4c943b9 100644 --- a/config/sv1-cray +++ b/config/sv1-cray @@ -136,6 +136,10 @@ esac # `ll' or if the format would be `%qd' set it to `q'. #hdf5_cv_printf_ll=${hdf5_cv_printf_ll='ll'} +# Hard set the flag to indicate that converting denormalized floating-point +# values doesn't work. +hdf5_cv_convert_denormal_float=${hdf5_cv_convert_denormal_float='no'} + # The default Fortran 90 compiler # diff --git a/config/unicos10.0.X b/config/unicos10.0.X index c014f00..1598fe8 100644 --- a/config/unicos10.0.X +++ b/config/unicos10.0.X @@ -137,6 +137,10 @@ ac_cv_c_bigendian=${ac_cv_c_bigendian='yes'} # `ll' or if the format would be `%qd' set it to `q'. #hdf5_cv_printf_ll=${hdf5_cv_printf_ll='ll'} +# Hard set the flag to indicate that converting denormalized floating-point +# values doesn't work. +hdf5_cv_convert_denormal_float=${hdf5_cv_convert_denormal_float='no'} + # The default Fortran 90 compiler # diff --git a/config/unicosmk2.0.6.X b/config/unicosmk2.0.6.X index e83e7ba..8f5c76d 100644 --- a/config/unicosmk2.0.6.X +++ b/config/unicosmk2.0.6.X @@ -137,6 +137,10 @@ esac # `ll' or if the format would be `%qd' set it to `q'. #hdf5_cv_printf_ll=${hdf5_cv_printf_ll='ll'} +# Hard set the flag to indicate that converting denormalized floating-point +# values doesn't work. +hdf5_cv_convert_denormal_float=${hdf5_cv_convert_denormal_float='no'} + # The default Fortran 90 compiler # diff --git a/configure b/configure index 50cbb5a..4f95040 100755 --- a/configure +++ b/configure @@ -30548,7 +30548,9 @@ rm -f conftest.$ac_objext conftest.$ac_ext -for ac_func in fork gethostname getpwuid getrusage + + +for ac_func in fork frexpf frexpl gethostname getpwuid getrusage do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -33239,6 +33241,28 @@ _ACEOF fi +echo "$as_me:$LINENO: checking if converting denormalized floating-point values is possible" >&5 +echo $ECHO_N "checking if converting denormalized floating-point values is possible... $ECHO_C" >&6 +if test "${hdf5_cv_convert_denormal_float+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + hdf5_cv_convert_denormal_float=yes +fi + + +if test ${hdf5_cv_convert_denormal_float} = "yes"; then + +cat >>confdefs.h <<\_ACEOF +#define CONVERT_DENORMAL_FLOAT 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 c2e9ef8..df912a1 100644 --- a/configure.in +++ b/configure.in @@ -1647,7 +1647,7 @@ AC_MSG_RESULT([no])) dnl ---------------------------------------------------------------------- dnl Check for functions. dnl -AC_CHECK_FUNCS(fork gethostname getpwuid getrusage) +AC_CHECK_FUNCS(fork frexpf frexpl gethostname getpwuid getrusage) AC_CHECK_FUNCS(BSDgettimeofday longjmp setsysinfo sigaction) AC_CHECK_FUNCS(signal snprintf vsnprintf strdup system waitpid) @@ -2364,6 +2364,23 @@ if test 1 = 2; then fi dnl ---------------------------------------------------------------------- +dnl Set the flag to indicate that the machine can handle converting +dnl denormalized floating-point values. +dnl (This flag should be set for all machines, except for the Crays, where +dnl the cache value is set in it's config file) +dnl +AC_MSG_CHECKING([if converting denormalized floating-point values is possible]) +AC_CACHE_VAL([hdf5_cv_convert_denormal_float], [hdf5_cv_convert_denormal_float=yes]) + +if test ${hdf5_cv_convert_denormal_float} = "yes"; then + AC_DEFINE([CONVERT_DENORMAL_FLOAT], [1], + [Define if your system can handle converting denormalized floating-point values.]) + 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/H5config.h.in b/src/H5config.h.in index f2348c4..3a2924c 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -1,5 +1,9 @@ /* src/H5config.h.in. Generated from configure.in by autoheader. */ +/* Define if your system can handle converting denormalized floating-point + values. */ +#undef CONVERT_DENORMAL_FLOAT + /* Define if `dev_t' is a scalar */ #undef DEV_T_IS_SCALAR @@ -39,6 +43,12 @@ /* Define if we want flexible parallel HDF5 support */ #undef HAVE_FPHDF5 +/* Define to 1 if you have the `frexpf' function. */ +#undef HAVE_FREXPF + +/* Define to 1 if you have the `frexpl' function. */ +#undef HAVE_FREXPL + /* Define to 1 if you have the `fseek64' function. */ #undef HAVE_FSEEK64 diff --git a/src/H5private.h b/src/H5private.h index 863973e..9f22433 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -605,6 +605,17 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDfree(M) free(M) #define HDfreopen(S,M,F) freopen(S,M,F) #define HDfrexp(X,N) frexp(X,N) +/* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */ +#ifdef H5_HAVE_FREXPF +#define HDfrexpf(X,N) frexpf(X,N) +#else /* H5_HAVE_FREXPF */ +#define HDfrexpf(X,N) frexp(X,N) +#endif /* H5_HAVE_FREXPF */ +#ifdef H5_HAVE_FREXPL +#define HDfrexpl(X,N) frexpl(X,N) +#else /* H5_HAVE_FREXPL */ +#define HDfrexpl(X,N) frexp(X,N) +#endif /* H5_HAVE_FREXPL */ /* fscanf() variable arguments */ #define HDfseek(F,O,W) fseek(F,O,W) #define HDfsetpos(F,P) fsetpos(F,P) diff --git a/test/dtypes.c b/test/dtypes.c index 9577455..c306e83 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -19,6 +19,7 @@ * Purpose: Tests the data type interface (H5T) */ +#include #include #include "h5test.h" @@ -106,8 +107,8 @@ static int num_opaque_conversions_g = 0; #endif /* Allocates memory aligned on a certain boundary. */ -#define aligned_malloc(Z) ((void*)((char*)malloc(ALIGNMENT+Z)+ALIGNMENT)) -#define aligned_free(M) free((char*)(M)-ALIGNMENT) +#define aligned_malloc(Z) ((void*)((char*)HDmalloc(ALIGNMENT+Z)+ALIGNMENT)) +#define aligned_free(M) HDfree((char*)(M)-ALIGNMENT) void some_dummy_func(float x); static hbool_t overflows(unsigned char *origin_bits, dtype_t src_dtype, @@ -133,12 +134,12 @@ static void fpe_handler(int UNUSED signo) { SKIPPED(); - puts(" Test skipped due to SIGFPE."); + HDputs(" Test skipped due to SIGFPE."); #ifndef HANDLE_SIGFPE - puts(" Remaining tests could not be run."); - puts(" Please turn off SIGFPE on overflows and try again."); + HDputs(" Remaining tests could not be run."); + HDputs(" Please turn off SIGFPE on overflows and try again."); #endif - exit(255); + HDexit(255); } @@ -221,34 +222,35 @@ generates_sigfpe(void) unsigned char *dp = (unsigned char*)&d; float f; - fflush(stdout); - fflush(stderr); + HDfflush(stdout); + HDfflush(stderr); if ((pid=fork())<0) { - perror("fork"); - exit(1); + HDperror("fork"); + HDexit(1); } else if (0==pid) { for (i=0; i<2000; i++) { - for (j=0; j=0) { H5_FAILED(); - puts (" Should not be able to close a predefined type!"); + HDputs (" Should not be able to close a predefined type!"); goto error; } @@ -620,7 +622,7 @@ test_compound_2(void) s_ptr->d = i*8+6; s_ptr->e = i*8+7; } - memcpy(buf, orig, nelmts*sizeof(struct st)); + HDmemcpy(buf, orig, nelmts*sizeof(struct st)); /* Build hdf5 datatypes */ array_dt=H5Tarray_create(H5T_NATIVE_INT,1, &four, NULL); @@ -737,7 +739,7 @@ test_compound_3(void) s_ptr->d = i*8+6; s_ptr->e = i*8+7; } - memcpy(buf, orig, nelmts*sizeof(struct st)); + HDmemcpy(buf, orig, nelmts*sizeof(struct st)); /* Build hdf5 datatypes */ array_dt=H5Tarray_create(H5T_NATIVE_INT, 1, &four, NULL); @@ -855,7 +857,7 @@ test_compound_4(void) s_ptr->d = (i*8+6) & 0x7fff; s_ptr->e = i*8+7; } - memcpy(buf, orig, nelmts*sizeof(struct st)); + HDmemcpy(buf, orig, nelmts*sizeof(struct st)); /* Build hdf5 datatypes */ array_dt=H5Tarray_create(H5T_NATIVE_INT, 1, &four, NULL); @@ -999,7 +1001,7 @@ test_compound_5(void) H5Tinsert(dst_type, "coll_ids", HOFFSET(dst_type_t, coll_ids), int_array ); /* Convert data */ - memcpy(buf, src, sizeof(src)); + HDmemcpy(buf, src, sizeof(src)); H5Tconvert(src_type, dst_type, (hsize_t)2, buf, bkg, H5P_DEFAULT); dst = (dst_type_t*)buf; @@ -1013,7 +1015,7 @@ test_compound_5(void) /* Check results */ - if (memcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || + if (HDmemcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || src[1].tdim!=dst[1].tdim || src[1].coll_ids[0]!=dst[1].coll_ids[0] || src[1].coll_ids[1]!=dst[1].coll_ids[1] || @@ -1078,7 +1080,7 @@ test_compound_6(void) s_ptr->b = (i*8+1) & 0x7fff; s_ptr->d = (i*8+6) & 0x7fff; } - memcpy(buf, orig, nelmts*sizeof(struct st)); + HDmemcpy(buf, orig, nelmts*sizeof(struct st)); /* Build hdf5 datatypes */ if ((st=H5Tcreate(H5T_COMPOUND, sizeof(struct st)))<0 || @@ -1669,7 +1671,7 @@ test_transient (hid_t fapl) } H5E_END_TRY; if (status>=0) { H5_FAILED(); - puts (" Predefined types should not be modifiable!"); + HDputs (" Predefined types should not be modifiable!"); goto error; } H5E_BEGIN_TRY { @@ -1677,7 +1679,7 @@ test_transient (hid_t fapl) } H5E_END_TRY; if (status>=0) { H5_FAILED(); - puts (" Predefined types should not be closable!"); + HDputs (" Predefined types should not be closable!"); goto error; } @@ -1691,7 +1693,7 @@ test_transient (hid_t fapl) } H5E_END_TRY; if (status>=0) { H5_FAILED(); - puts (" Attributes should not be allowed for transient types!"); + HDputs (" Attributes should not be allowed for transient types!"); goto error; } @@ -1708,7 +1710,7 @@ test_transient (hid_t fapl) } H5E_END_TRY; if (status>=0) { H5_FAILED(); - puts (" Dataset data types should not be modifiable!"); + HDputs (" Dataset data types should not be modifiable!"); goto error; } if (H5Tclose (t2)<0) goto error; @@ -1725,7 +1727,7 @@ test_transient (hid_t fapl) } H5E_END_TRY; if (status>=0) { H5_FAILED(); - puts (" Dataset data types should not be modifiable!"); + HDputs (" Dataset data types should not be modifiable!"); goto error; } if (H5Tclose (t2)<0) goto error; @@ -1799,7 +1801,7 @@ test_named (hid_t fapl) } H5E_END_TRY; if (status>=0) { H5_FAILED(); - puts (" Predefined types should not be committable!"); + HDputs (" Predefined types should not be committable!"); goto error; } @@ -1809,7 +1811,7 @@ test_named (hid_t fapl) if ((status=H5Tcommitted (type))<0) goto error; if (0==status) { H5_FAILED(); - puts (" H5Tcommitted() returned false!"); + HDputs (" H5Tcommitted() returned false!"); goto error; } @@ -1819,7 +1821,7 @@ test_named (hid_t fapl) } H5E_END_TRY; if (status>=0) { H5_FAILED(); - puts (" Committed type is not constant!"); + HDputs (" Committed type is not constant!"); goto error; } @@ -1829,7 +1831,7 @@ test_named (hid_t fapl) } H5E_END_TRY; if (status>=0) { H5_FAILED(); - puts (" Committed types should not be recommitted!"); + HDputs (" Committed types should not be recommitted!"); goto error; } @@ -1848,7 +1850,7 @@ test_named (hid_t fapl) if ((status=H5Tcommitted (t2))<0) goto error; if (status) { H5_FAILED(); - puts (" Copying a named type should result in a transient type!"); + HDputs (" Copying a named type should result in a transient type!"); goto error; } if (H5Tset_precision (t2, 256)<0) goto error; @@ -1862,7 +1864,7 @@ test_named (hid_t fapl) if ((status=H5Tcommitted (type))<0) goto error; if (!status) { H5_FAILED(); - puts (" Opened named types should be named types!"); + HDputs (" Opened named types should be named types!"); goto error; } @@ -1876,7 +1878,7 @@ test_named (hid_t fapl) if ((status=H5Tcommitted (t2))<0) goto error; if (!status) { H5_FAILED(); - puts (" Dataset type should be a named type!"); + HDputs (" Dataset type should be a named type!"); goto error; } @@ -1890,7 +1892,7 @@ test_named (hid_t fapl) if ((status=H5Tcommitted (t2))<0) goto error; if (!status) { H5_FAILED(); - puts (" Dataset type should be a named type!"); + HDputs (" Dataset type should be a named type!"); goto error; } @@ -1911,7 +1913,7 @@ test_named (hid_t fapl) if ((status=H5Tcommitted (t2))<0) goto error; if (!status) { H5_FAILED(); - puts (" Dataset type should be a named type!"); + HDputs (" Dataset type should be a named type!"); goto error; } if (H5Tclose (t2)<0) goto error; @@ -2002,21 +2004,21 @@ test_conv_str_1(void) */ src_type = mkstr(10, H5T_STR_NULLTERM); dst_type = mkstr(5, H5T_STR_NULLTERM); - buf = calloc(2, 10); - memcpy(buf, "abcdefghi\0abcdefghi\0", 20); + buf = HDcalloc(2, 10); + HDmemcpy(buf, "abcdefghi\0abcdefghi\0", 20); if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcd\0abcd\0abcdefghi\0", 20)) { + if (HDmemcmp(buf, "abcd\0abcd\0abcdefghi\0", 20)) { H5_FAILED(); - puts(" Truncated C-string test failed"); + HDputs(" Truncated C-string test failed"); goto error; } if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcd\0\0\0\0\0\0abcd\0\0\0\0\0\0", 20)) { + if (HDmemcmp(buf, "abcd\0\0\0\0\0\0abcd\0\0\0\0\0\0", 20)) { H5_FAILED(); - puts(" Extended C-string test failed"); + HDputs(" Extended C-string test failed"); goto error; } - free(buf); + HDfree(buf); if (H5Tclose(src_type)<0) goto error; if (H5Tclose(dst_type)<0) goto error; @@ -2025,21 +2027,21 @@ test_conv_str_1(void) */ src_type = mkstr(10, H5T_STR_NULLPAD); dst_type = mkstr(5, H5T_STR_NULLPAD); - buf = calloc(2, 10); - memcpy(buf, "abcdefghijabcdefghij", 20); + buf = HDcalloc(2, 10); + HDmemcpy(buf, "abcdefghijabcdefghij", 20); if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcdeabcdeabcdefghij", 20)) { + if (HDmemcmp(buf, "abcdeabcdeabcdefghij", 20)) { H5_FAILED(); - puts(" Truncated C buffer test failed"); + HDputs(" Truncated C buffer test failed"); goto error; } if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) { + if (HDmemcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) { H5_FAILED(); - puts(" Extended C buffer test failed"); + HDputs(" Extended C buffer test failed"); goto error; } - free(buf); + HDfree(buf); if (H5Tclose(src_type)<0) goto error; if (H5Tclose(dst_type)<0) goto error; @@ -2048,21 +2050,21 @@ test_conv_str_1(void) */ src_type = mkstr(10, H5T_STR_SPACEPAD); dst_type = mkstr(5, H5T_STR_SPACEPAD); - buf = calloc(2, 10); - memcpy(buf, "abcdefghijabcdefghij", 20); + buf = HDcalloc(2, 10); + HDmemcpy(buf, "abcdefghijabcdefghij", 20); if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcdeabcdeabcdefghij", 20)) { + if (HDmemcmp(buf, "abcdeabcdeabcdefghij", 20)) { H5_FAILED(); - puts(" Truncated Fortran-string test failed"); + HDputs(" Truncated Fortran-string test failed"); goto error; } if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcde abcde ", 20)) { + if (HDmemcmp(buf, "abcde abcde ", 20)) { H5_FAILED(); - puts(" Extended Fortran-string test failed"); + HDputs(" Extended Fortran-string test failed"); goto error; } - free(buf); + HDfree(buf); if (H5Tclose(src_type)<0) goto error; if (H5Tclose(dst_type)<0) goto error; @@ -2074,31 +2076,31 @@ test_conv_str_1(void) */ src_type = mkstr(10, H5T_STR_NULLTERM); dst_type = mkstr(10, H5T_STR_NULLTERM); - buf = calloc(2, 10); - memcpy(buf, "abcdefghijabcdefghij", 20); + buf = HDcalloc(2, 10); + HDmemcpy(buf, "abcdefghijabcdefghij", 20); if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcdefghijabcdefghij", 20)) { + if (HDmemcmp(buf, "abcdefghijabcdefghij", 20)) { H5_FAILED(); - puts(" Non-terminated string test 1"); + HDputs(" Non-terminated string test 1"); goto error; } H5Tclose(dst_type); dst_type = mkstr(5, H5T_STR_NULLTERM); - memcpy(buf, "abcdefghijabcdefghij", 20); + HDmemcpy(buf, "abcdefghijabcdefghij", 20); if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcd\0abcd\0abcdefghij", 20)) { + if (HDmemcmp(buf, "abcd\0abcd\0abcdefghij", 20)) { H5_FAILED(); - puts(" Non-terminated string test 2"); + HDputs(" Non-terminated string test 2"); goto error; } - memcpy(buf, "abcdeabcdexxxxxxxxxx", 20); + HDmemcpy(buf, "abcdeabcdexxxxxxxxxx", 20); if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) { + if (HDmemcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) { H5_FAILED(); - puts(" Non-terminated string test 2"); + HDputs(" Non-terminated string test 2"); goto error; } - free(buf); + HDfree(buf); if (H5Tclose(src_type)<0) goto error; if (H5Tclose(dst_type)<0) goto error; @@ -2107,53 +2109,53 @@ test_conv_str_1(void) */ src_type = mkstr(10, H5T_STR_NULLTERM); dst_type = mkstr(10, H5T_STR_SPACEPAD); - buf = calloc(2, 10); - memcpy(buf, "abcdefghi\0abcdefghi\0", 20); + buf = HDcalloc(2, 10); + HDmemcpy(buf, "abcdefghi\0abcdefghi\0", 20); if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcdefghi abcdefghi ", 20)) { + if (HDmemcmp(buf, "abcdefghi abcdefghi ", 20)) { H5_FAILED(); - puts(" C string to Fortran test 1"); + HDputs(" C string to Fortran test 1"); goto error; } if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcdefghi\0abcdefghi\0", 20)) { + if (HDmemcmp(buf, "abcdefghi\0abcdefghi\0", 20)) { H5_FAILED(); - puts(" Fortran to C string test 1"); + HDputs(" Fortran to C string test 1"); goto error; } if (H5Tclose(dst_type)<0) goto error; dst_type = mkstr(5, H5T_STR_SPACEPAD); - memcpy(buf, "abcdefgh\0\0abcdefgh\0\0", 20); + HDmemcpy(buf, "abcdefgh\0\0abcdefgh\0\0", 20); if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcdeabcdeabcdefgh\0\0", 20)) { + if (HDmemcmp(buf, "abcdeabcdeabcdefgh\0\0", 20)) { H5_FAILED(); - puts(" C string to Fortran test 2"); + HDputs(" C string to Fortran test 2"); goto error; } if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) { + if (HDmemcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) { H5_FAILED(); - puts(" Fortran to C string test 2"); + HDputs(" Fortran to C string test 2"); goto error; } if (H5Tclose(src_type)<0) goto error; if (H5Tclose(dst_type)<0) goto error; src_type = mkstr(5, H5T_STR_NULLTERM); dst_type = mkstr(10, H5T_STR_SPACEPAD); - memcpy(buf, "abcd\0abcd\0xxxxxxxxxx", 20); + HDmemcpy(buf, "abcd\0abcd\0xxxxxxxxxx", 20); if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcd abcd ", 20)) { + if (HDmemcmp(buf, "abcd abcd ", 20)) { H5_FAILED(); - puts(" C string to Fortran test 3"); + HDputs(" C string to Fortran test 3"); goto error; } if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcd\0abcd\0abcd ", 20)) { + if (HDmemcmp(buf, "abcd\0abcd\0abcd ", 20)) { H5_FAILED(); - puts(" Fortran to C string test 3"); + HDputs(" Fortran to C string test 3"); goto error; } - free(buf); + HDfree(buf); if (H5Tclose(src_type)<0) goto error; if (H5Tclose(dst_type)<0) goto error; @@ -2162,53 +2164,53 @@ test_conv_str_1(void) */ src_type = mkstr(10, H5T_STR_NULLPAD); dst_type = mkstr(10, H5T_STR_SPACEPAD); - buf = calloc(2, 10); - memcpy(buf, "abcdefghijabcdefghij", 20); + buf = HDcalloc(2, 10); + HDmemcpy(buf, "abcdefghijabcdefghij", 20); if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcdefghijabcdefghij", 20)) { + if (HDmemcmp(buf, "abcdefghijabcdefghij", 20)) { H5_FAILED(); - puts(" C buffer to Fortran test 1"); + HDputs(" C buffer to Fortran test 1"); goto error; } if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcdefghijabcdefghij", 20)) { + if (HDmemcmp(buf, "abcdefghijabcdefghij", 20)) { H5_FAILED(); - puts(" Fortran to C buffer test 1"); + HDputs(" Fortran to C buffer test 1"); goto error; } if (H5Tclose(dst_type)<0) goto error; dst_type = mkstr(5, H5T_STR_SPACEPAD); - memcpy(buf, "abcdefgh\0\0abcdefgh\0\0", 20); + HDmemcpy(buf, "abcdefgh\0\0abcdefgh\0\0", 20); if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcdeabcdeabcdefgh\0\0", 20)) { + if (HDmemcmp(buf, "abcdeabcdeabcdefgh\0\0", 20)) { H5_FAILED(); - puts(" C buffer to Fortran test 2"); + HDputs(" C buffer to Fortran test 2"); goto error; } if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) { + if (HDmemcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) { H5_FAILED(); - puts(" Fortran to C buffer test 2"); + HDputs(" Fortran to C buffer test 2"); goto error; } if (H5Tclose(src_type)<0) goto error; if (H5Tclose(dst_type)<0) goto error; src_type = mkstr(5, H5T_STR_NULLPAD); dst_type = mkstr(10, H5T_STR_SPACEPAD); - memcpy(buf, "abcd\0abcd\0xxxxxxxxxx", 20); + HDmemcpy(buf, "abcd\0abcd\0xxxxxxxxxx", 20); if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcd abcd ", 20)) { + if (HDmemcmp(buf, "abcd abcd ", 20)) { H5_FAILED(); - puts(" C buffer to Fortran test 3"); + HDputs(" C buffer to Fortran test 3"); goto error; } if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; - if (memcmp(buf, "abcd\0abcd\0abcd ", 20)) { + if (HDmemcmp(buf, "abcd\0abcd\0abcd ", 20)) { H5_FAILED(); - puts(" Fortran to C buffer test 3"); + HDputs(" Fortran to C buffer test 3"); goto error; } - free(buf); + HDfree(buf); if (H5Tclose(src_type)<0) goto error; if (H5Tclose(dst_type)<0) goto error; @@ -2252,13 +2254,13 @@ test_conv_str_2(void) */ c_type = mkstr(8, H5T_STR_NULLPAD); f_type = mkstr(8, H5T_STR_SPACEPAD); - buf = calloc(nelmts, 8); + buf = HDcalloc(nelmts, 8); for (i=0; i=max_fails) { - puts(" maximum failures reached, aborting test..."); + HDputs(" maximum failures reached, aborting test..."); goto done; } } @@ -3769,16 +3698,16 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) done: if (buf) aligned_free(buf); if (saved) aligned_free(saved); - if (aligned) free(aligned); - fflush(stdout); + if (aligned) HDfree(aligned); + HDfflush(stdout); reset_hdf5(); /*print statistics*/ return (int)fails_all_tests; error: if (buf) aligned_free(buf); if (saved) aligned_free(saved); - if (aligned) free(aligned); - fflush(stdout); + if (aligned) HDfree(aligned); + HDfflush(stdout); reset_hdf5(); /*print statistics*/ return MAX((int)fails_all_tests, 1); } @@ -3809,9 +3738,9 @@ test_conv_int_2(void) char buf[32*100]; printf("%-70s", "Testing overlap calculations"); - fflush(stdout); + HDfflush(stdout); - memset(buf, 0, sizeof buf); + HDmemset(buf, 0, sizeof buf); for (i=1; i<=32; i++) { for (j=1; j<=32; j++) { @@ -3998,7 +3927,7 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst) name, src_type_name, dst_type_name); printf("%-70s", str); H5_FAILED(); - puts(" Unknown data type."); + HDputs(" Unknown data type."); goto error; } @@ -4011,7 +3940,7 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst) name, src_type_name, dst_type_name); printf("%-70s", str); H5_FAILED(); - puts(" 1. Not an integer-float conversion."); + HDputs(" 1. Not an integer-float conversion."); goto error; } @@ -4024,7 +3953,7 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst) name, src_type_name, dst_type_name); printf("%-70s", str); H5_FAILED(); - puts(" 2. Not a float-integer conversion."); + HDputs(" 2. Not a float-integer conversion."); goto error; } @@ -4036,7 +3965,7 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst) dst_nbits = H5Tget_precision(dst); /* not 8*dst_size, esp on J90 - QAK */ buf = aligned_malloc(nelmts*MAX(src_size, dst_size)); saved = aligned_malloc(nelmts*MAX(src_size, dst_size)); - aligned = malloc(sizeof(long_long)); + aligned = HDmalloc(sizeof(long_long)); #ifdef SHOW_OVERFLOWS noverflows_g = 0; #endif @@ -4051,7 +3980,7 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst) name, src_type_name, dst_type_name); } printf("%-70s", str); - fflush(stdout); + HDfflush(stdout); fails_this_test=0; /* @@ -4059,10 +3988,12 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst) * will be used for the conversion while the `saved' buffer will be * used for the comparison later. */ - for (j=0; j=max_fails) { - puts(" maximum failures reached, aborting test..."); + HDputs(" maximum failures reached, aborting test..."); goto done; } } @@ -4710,16 +4588,16 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst) done: if (buf) aligned_free(buf); if (saved) aligned_free(saved); - if (aligned) free(aligned); - fflush(stdout); + if (aligned) HDfree(aligned); + HDfflush(stdout); reset_hdf5(); /*print statistics*/ return (int)fails_all_tests; error: if (buf) aligned_free(buf); if (saved) aligned_free(saved); - if (aligned) free(aligned); - fflush(stdout); + if (aligned) HDfree(aligned); + HDfflush(stdout); reset_hdf5(); /*print statistics*/ return MAX((int)fails_all_tests, 1); } @@ -4749,7 +4627,7 @@ overflows(unsigned char *origin_bits, dtype_t src_dtype, size_t src_size_bytes, ssize_t indx; unsigned char bits[32]; - memcpy(bits, origin_bits, src_size_bytes); + HDmemcpy(bits, origin_bits, src_size_bytes); if(src_dtype==FLT_FLOAT) { frct_digits = (FLT_MANT_DIG-1); @@ -4812,16 +4690,16 @@ my_isnan(dtype_t type, void *val) if (FLT_FLOAT==type) { float x; - memcpy(&x, val, sizeof(float)); + HDmemcpy(&x, val, sizeof(float)); retval = (x!=x); } else if (FLT_DOUBLE==type) { double x; - memcpy(&x, val, sizeof(double)); + HDmemcpy(&x, val, sizeof(double)); retval = (x!=x); #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE } else if (FLT_LDOUBLE==type) { long double x; - memcpy(&x, val, sizeof(long double)); + HDmemcpy(&x, val, sizeof(long double)); retval = (x!=x); #endif } else { @@ -4835,22 +4713,22 @@ my_isnan(dtype_t type, void *val) if (!retval) { if (FLT_FLOAT==type) { float x; - memcpy(&x, val, sizeof(float)); + HDmemcpy(&x, val, sizeof(float)); sprintf(s, "%g", x); } else if (FLT_DOUBLE==type) { double x; - memcpy(&x, val, sizeof(double)); + HDmemcpy(&x, val, sizeof(double)); sprintf(s, "%g", x); #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE } else if (FLT_LDOUBLE==type) { long double x; - memcpy(&x, val, sizeof(long double)); + HDmemcpy(&x, val, sizeof(long double)); sprintf(s, "%Lg", x); #endif } else { return 0; } - if (strstr(s, "NaN") || strstr(s, "NAN") || strstr(s, "nan")) + if (HDstrstr(s, "NaN") || HDstrstr(s, "NAN") || HDstrstr(s, "nan")) retval = 1; } @@ -4900,7 +4778,12 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) unsigned char *hw=NULL; /*ptr to hardware-conv'd*/ size_t i, j, k; /*counters */ int endian; /*machine endianess */ + size_t src_ebias; /* Source type's exponent bias */ size_t dst_ebias; /* Destination type's exponent bias */ + size_t src_epos; /* Source type's exponent position */ + size_t src_esize; /* Source type's exponent size */ + size_t dst_epos; /* Destination type's exponent position */ + size_t dst_esize; /* Destination type's exponent size */ size_t dst_msize; /* Destination type's mantissa size */ #ifdef HANDLE_SIGFPE @@ -4913,10 +4796,10 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) * fork here and let the child run the test and return the number of * failures with the exit status. */ - fflush(stdout); - fflush(stderr); + HDfflush(stdout); + HDfflush(stderr); if ((child_pid=fork())<0) { - perror("fork"); + HDperror("fork"); return 1; } else if (child_pid>0) { while (child_pid!=waitpid(child_pid, &status, 0)) /*void*/; @@ -4925,7 +4808,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) } else if (WIFEXITED(status)) { return WEXITSTATUS(status); } else { - puts(" Child didn't exit normally."); + HDputs(" Child didn't exit normally."); return 1; } } @@ -4974,31 +4857,33 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) /* Sanity checks */ if(sizeof(float)==sizeof(double)) - puts("Sizeof(float)==sizeof(double) - some tests may not be sensible."); + HDputs("Sizeof(float)==sizeof(double) - some tests may not be sensible."); if (OTHER==src_type || OTHER==dst_type) { sprintf(str, "Testing random %s %s -> %s conversions", name, src_type_name, dst_type_name); printf("%-70s", str); H5_FAILED(); - puts(" Unknown data type."); + HDputs(" Unknown data type."); goto error; } - /* Allocate buffers */ - endian = H5Tget_order(H5T_NATIVE_FLOAT); + /* Get "interesting" values */ src_size = H5Tget_size(src); dst_size = H5Tget_size(dst); + src_ebias=H5Tget_ebias(src); + dst_ebias=H5Tget_ebias(dst); + H5Tget_fields(src,NULL,&src_epos,&src_esize,NULL,NULL); + H5Tget_fields(dst,NULL,&dst_epos,&dst_esize,NULL,&dst_msize); + + /* Allocate buffers */ + endian = H5Tget_order(H5T_NATIVE_FLOAT); buf = aligned_malloc(nelmts*MAX(src_size, dst_size)); saved = aligned_malloc(nelmts*MAX(src_size, dst_size)); - aligned = malloc(16); /*should be big enough for any type*/ + aligned = HDmalloc(32); /*should be big enough for any type*/ #ifdef SHOW_OVERFLOWS noverflows_g = 0; #endif - /* Get "interesting" values */ - dst_ebias=H5Tget_ebias(dst); - H5Tget_fields(dst,NULL,NULL,NULL,NULL,&dst_msize); - for (i=0; i=max_fails) { - puts(" maximum failures reached, aborting test..."); + HDputs(" maximum failures reached, aborting test..."); goto done; } } PASSED(); } #ifdef SHOW_OVERFLOWS - if (noverflows_g>0) { + if (noverflows_g>0) printf(" %d overflow%s in previous test\n", noverflows_g, 1==noverflows_g?"":"s"); - } #endif done: if (buf) aligned_free(buf); if (saved) aligned_free(saved); - if (aligned) free(aligned); - fflush(stdout); + if (aligned) HDfree(aligned); + HDfflush(stdout); #ifdef HANDLE_SIGFPE - exit(MIN((int)fails_all_tests, 254)); + HDexit(MIN((int)fails_all_tests, 254)); #else reset_hdf5(); return (int)fails_all_tests; @@ -5296,10 +5203,10 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) error: if (buf) aligned_free(buf); if (saved) aligned_free(saved); - if (aligned) free(aligned); - fflush(stdout); + if (aligned) HDfree(aligned); + HDfflush(stdout); #ifdef HANDLE_SIGFPE - exit(MIN(MAX((int)fails_all_tests, 1), 254)); + HDexit(MIN(MAX((int)fails_all_tests, 1), 254)); #else reset_hdf5(); return MAX((int)fails_all_tests, 1); @@ -5607,15 +5514,13 @@ main(void) hid_t fapl=-1; /* Set the random # seed */ - HDsrandom((unsigned long)time(NULL)); + HDsrandom((unsigned long)HDtime(NULL)); reset_hdf5(); fapl = h5_fileaccess(); - if (ALIGNMENT) { - printf("Testing non-aligned conversions (ALIGNMENT=%d)....\n", - ALIGNMENT); - } + if (ALIGNMENT) + printf("Testing non-aligned conversions (ALIGNMENT=%d)....\n", ALIGNMENT); /* Do the tests */ nerrors += test_classes(); @@ -5689,7 +5594,7 @@ main(void) if (nerrors) { printf("***** %lu FAILURE%s! *****\n", nerrors, 1==nerrors?"":"S"); - exit(1); + HDexit(1); } printf("All data type tests passed.\n"); return 0; -- cgit v0.12