From 4da7b1ee9b462925818cf704c89a72fef5f55e4d Mon Sep 17 00:00:00 2001
From: Quincey Koziol <koziol@hdfgroup.org>
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 <math.h>
 #include <time.h>
 #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<sizeof(double); j++) dp[j] = rand();
+	    for (j=0; j<sizeof(double); j++) dp[j] = HDrand();
 	    f = (float)d;
 	    some_dummy_func((float)f);
 	}
-	exit(0);
+	HDexit(0);
     }
     
-    while (pid!=waitpid(pid, &status, 0)) /*void*/;
+    while (pid!=waitpid(pid, &status, 0))
+        /*void*/;
     if (WIFEXITED(status) && 0==WEXITSTATUS(status)) {
-	puts("Floating-point overflow cases will be tested.");
+	HDputs("Floating-point overflow cases will be tested.");
 	skip_overflow_tests_g = FALSE;
     } else if (WIFSIGNALED(status) && SIGFPE==WTERMSIG(status)) {
-	puts("Floating-point overflow cases cannot be safely tested.");
+	HDputs("Floating-point overflow cases cannot be safely tested.");
 	skip_overflow_tests_g = TRUE;
 	/* delete the core dump file that SIGFPE may have created */
-	unlink("core");
+	HDunlink("core");
     }
 #else
-    puts("Cannot determine if floating-point overflows generate a SIGFPE;");
-    puts("assuming yes.");
-    puts("Overflow cases will not be tested.");
+    HDputs("Cannot determine if floating-point overflows generate a SIGFPE;");
+    HDputs("assuming yes.");
+    HDputs("Overflow cases will not be tested.");
     skip_overflow_tests_g = TRUE;
 #endif
 }
@@ -322,13 +324,13 @@ test_classes(void)
     if ((tcls=H5Tget_class(H5T_NATIVE_INT))<0) goto error;
     if (H5T_INTEGER!=tcls) {
 	H5_FAILED();
-        puts("    Invalid type class for H5T_NATIVE_INT");
+        HDputs("    Invalid type class for H5T_NATIVE_INT");
         goto error;
     }
     if ((tcls=H5Tget_class(H5T_NATIVE_DOUBLE))<0) goto error;
     if (H5T_FLOAT!=tcls) {
 	H5_FAILED();
-	puts("    Invalid type class for H5T_NATIVE_DOUBLE");
+	HDputs("    Invalid type class for H5T_NATIVE_DOUBLE");
         goto error;
     }
     PASSED();
@@ -372,7 +374,7 @@ test_copy(void)
     } H5E_END_TRY;
     if (status>=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<nelmts; i++) {
-	nchars = rand() % 8;
-	for (j=0; j<nchars; j++) {
-	    buf[i*8+j] = 'a' + rand()%26;
-	}
-	while (j<nchars) buf[i*8+j++] = '\0';
+	nchars = HDrand() % 8;
+	for (j=0; j<nchars; j++)
+	    buf[i*8+j] = 'a' + HDrand()%26;
+	while (j<nchars)
+            buf[i*8+j++] = '\0';
     }
 
     /* Do the conversions */
@@ -2270,15 +2272,17 @@ test_conv_str_2(void)
 	    sprintf(s, "Testing random string conversion speed");
 	}
 	printf("%-70s", s);
-	fflush(stdout);
-	if (H5Tconvert(c_type, f_type, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
-	if (H5Tconvert(f_type, c_type, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
+	HDfflush(stdout);
+	if (H5Tconvert(c_type, f_type, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0)
+            goto error;
+	if (H5Tconvert(f_type, c_type, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0)
+            goto error;
 	PASSED();
     }
     ret_value = 0;
 
  error:
-    if (buf) free(buf);
+    if (buf) HDfree(buf);
     reset_hdf5();
     return ret_value;
 }
@@ -2320,8 +2324,9 @@ test_conv_enum_1(void)
     }
 
     /* Initialize the buffer */
-    buf = malloc(nelmts*MAX(H5Tget_size(t1), H5Tget_size(t2)));
-    for (i=0; i<nelmts; i++) buf[i] = rand() % 26;
+    buf = HDmalloc(nelmts*MAX(H5Tget_size(t1), H5Tget_size(t2)));
+    for (i=0; i<nelmts; i++)
+        buf[i] = HDrand() % 26;
 
     /* Conversions */
     for (i=0; i<ntests; i++) {
@@ -2332,7 +2337,7 @@ test_conv_enum_1(void)
 	    sprintf(s, "Testing random enum conversion O(N)");
 	}
 	printf("%-70s", s);
-	fflush(stdout);
+	HDfflush(stdout);
 	if (H5Tconvert(t1, t2, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
 	PASSED();
     }
@@ -2345,7 +2350,7 @@ test_conv_enum_1(void)
 	    sprintf(s, "Testing random enum conversion O(N log N)");
 	}
 	printf("%-70s", s);
-	fflush(stdout);
+	HDfflush(stdout);
 	if (H5Tconvert(t2, t1, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
 	PASSED();
     }
@@ -2354,7 +2359,7 @@ test_conv_enum_1(void)
  error:
     H5Tclose(t1);
     H5Tclose(t2);
-    if (buf) free(buf);
+    if (buf) HDfree(buf);
     reset_hdf5();
     return ret_value;
 }
@@ -2885,7 +2890,7 @@ test_conv_int_1(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;
     }
 
@@ -2897,7 +2902,7 @@ test_conv_int_1(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
@@ -2912,7 +2917,7 @@ test_conv_int_1(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;
 
 	/*
@@ -2920,10 +2925,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 	 * will be used for the conversion while the `saved' buffer will be
 	 * sed for the comparison later.
 	 */
-	for (j=0; j<nelmts*src_size; j++) buf[j] = saved[j] = rand();
+	for (j=0; j<nelmts*src_size; j++)
+            buf[j] = saved[j] = HDrand();
 
 	/* Perform the conversion */
-	if (H5Tconvert(src, dst, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
+	if (H5Tconvert(src, dst, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0)
+            goto error;
 
 	/* Check the results from the library against hardware */
 	for (j=0; j<nelmts; j++) {
@@ -2931,48 +2938,43 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_char;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char), sizeof(char));
+		    HDmemcpy(aligned, saved+j*sizeof(char), sizeof(char));
 		    hw_char = (char)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char), sizeof(char));
+		    HDmemcpy(aligned, saved+j*sizeof(char), sizeof(char));
 		    hw_char = (char)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_char = (char)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		    hw_char = (char)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_char = (char)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_char = (char)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_char = (char)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		    hw_char = (char)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_char = (char)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
 		    hw_char = (char)(*((unsigned long_long*)aligned));
 		    break;
                 default:
@@ -2982,52 +2984,44 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_uchar;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(signed char));
+		    HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
 		    hw_uchar = (unsigned char)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(unsigned char));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
 		    hw_uchar = (unsigned char)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_uchar = (unsigned char)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		    hw_uchar = (unsigned char)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_uchar = (unsigned char)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_uchar = (unsigned char)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_uchar = (unsigned char)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		    hw_uchar = (unsigned char)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_uchar = (unsigned char)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
-		    hw_uchar = (unsigned char)(*((unsigned long_long*)
-						 aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
+		    hw_uchar = (unsigned char)(*((unsigned long_long*)aligned));
 		    break;
                 default:
 		    break;
@@ -3036,49 +3030,43 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_short;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char), sizeof(signed char));
+		    HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
 		    hw_short = (short)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(unsigned char));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
 		    hw_short = (short)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_short = (short)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		    hw_short = (short)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_short = (short)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_short = (short)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_short = (short)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		    hw_short = (short)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_short = (short)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
 		    hw_short = (short)(*((unsigned long_long*)aligned));
 		    break;
 
@@ -3089,51 +3077,44 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_ushort;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char), sizeof(signed char));
+		    HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
 		    hw_ushort = (unsigned short)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(unsigned char));
+		    HDmemcpy(aligned, saved+j*sizeof(char), sizeof(unsigned char));
 		    hw_ushort = (unsigned short)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_ushort = (unsigned short)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		    hw_ushort = (unsigned short)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_ushort = (unsigned short)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_ushort = (unsigned short)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_ushort = (unsigned short)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		    hw_ushort = (unsigned short)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_ushort = (unsigned short)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
-		    hw_ushort = (unsigned short)(*((unsigned long_long*)
-						   aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
+		    hw_ushort = (unsigned short)(*((unsigned long_long*)aligned));
 		    break;
                 default:
 		    break;
@@ -3142,49 +3123,43 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_int;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char), sizeof(signed char));
+		    HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
 		    hw_int = (int)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(unsigned char));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
 		    hw_int = (int)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_int = (int)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		    hw_int = (int)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_int = (int)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_int = (int)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_int = (int)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		    hw_int = (int)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_int = (int)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
 		    hw_int = (int)(*((unsigned long_long*)aligned));
 		    break;
                 default:
@@ -3194,50 +3169,43 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_uint;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(signed char));
+		    HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
 		    hw_uint = (unsigned int)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(unsigned char));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
 		    hw_uint = (unsigned int)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_uint = (unsigned int)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		    hw_uint = (unsigned int)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_uint = (unsigned int)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_uint = (unsigned int)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_uint = (unsigned int)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		    hw_uint = (unsigned int)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_uint = (unsigned int)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
 		    hw_uint = (unsigned int)(*((unsigned long_long*)aligned));
 		    break;
                 default:
@@ -3247,50 +3215,43 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_long;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(signed char));
+		    HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
 		    hw_long = (long int)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(unsigned char));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
 		    hw_long = (long int)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_long = (long int)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		    hw_long = (long int)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_long = (long int)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_long = (long int)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_long = (long int)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		    hw_long = (long int)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_long = (long int)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
 		    hw_long = (long int)(*((unsigned long_long*)aligned));
 		    break;
                 default:
@@ -3300,52 +3261,44 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_ulong;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(signed char));
+		    HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
 		    hw_ulong = (unsigned long)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(unsigned char));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
 		    hw_ulong = (unsigned long)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_ulong = (unsigned long)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		    hw_ulong = (unsigned long)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_ulong = (unsigned long)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_ulong = (unsigned long)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_ulong = (unsigned long)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		    hw_ulong = (unsigned long)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_ulong = (unsigned long)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
-		    hw_ulong = (unsigned long)(*((unsigned long_long*)
-						 aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
+		    hw_ulong = (unsigned long)(*((unsigned long_long*)aligned));
 		    break;
                 default:
 		    break;
@@ -3354,50 +3307,43 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_llong;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(signed char));
+		    HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
 		    hw_llong = (long_long)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(unsigned char));
+		    HDmemcpy(aligned, saved+j*sizeof(char), sizeof(unsigned char));
 		    hw_llong = (long_long)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_llong = (long_long)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		    hw_llong = (long_long)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_llong = (long_long)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_llong = (long_long)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_llong = (long_long)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		    hw_llong = (long_long)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_llong = (long_long)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
 		    hw_llong = (long_long)(*((unsigned long_long*)aligned));
 		    break;
                 default:
@@ -3407,56 +3353,44 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_ullong;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(signed char));
-		    hw_ullong = (unsigned long_long)(*((signed char*)
-						       aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
+		    hw_ullong = (unsigned long_long)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(unsigned char));
-		    hw_ullong = (unsigned long_long)(*((unsigned char*)
-						       aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
+		    hw_ullong = (unsigned long_long)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_ullong = (unsigned long_long)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
-		    hw_ullong = (unsigned long_long)(*((unsigned short*)
-						       aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
+		    hw_ullong = (unsigned long_long)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_ullong = (unsigned long_long)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_ullong = (unsigned long_long)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_ullong = (unsigned long_long)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
-		    hw_ullong = (unsigned long_long)(*((unsigned long*)
-						       aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
+		    hw_ullong = (unsigned long_long)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_ullong = (unsigned long_long)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
-		    hw_ullong = (unsigned long_long)(*((unsigned long_long*)
-						       aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
+		    hw_ullong = (unsigned long_long)(*((unsigned long_long*)aligned));
 		    break;
                 default:
 		    break;
@@ -3612,47 +3546,44 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 		   "");
 	    switch (src_type) {
 	    case INT_CHAR:
-		memcpy(aligned, saved+j*sizeof(char), sizeof(signed char));
+		HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
 		printf(" %29d\n", *((signed char*)aligned));
 		break;
 	    case INT_UCHAR:
-		memcpy(aligned, saved+j*sizeof(char), sizeof(unsigned char));
+		HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
 		printf(" %29u\n", *((unsigned char*)aligned));
 		break;
 	    case INT_SHORT:
-		memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		printf(" %29hd\n", *((short*)aligned));
 		break;
 	    case INT_USHORT:
-		memcpy(aligned, saved+j*sizeof(short),
-		       sizeof(unsigned short));
+		HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		printf(" %29hu\n", *((unsigned short*)aligned));
 		break;
 	    case INT_INT:
-		memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		printf(" %29d\n", *((int*)aligned));
 		break;
 	    case INT_UINT:
-		memcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
+		HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		printf(" %29u\n", *((unsigned*)aligned));
 		break;
 	    case INT_LONG:
-		memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		printf(" %29ld\n", *((long*)aligned));
 		break;
 	    case INT_ULONG:
-		memcpy(aligned, saved+j*sizeof(long), sizeof(unsigned long));
+		HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		printf(" %29lu\n", *((unsigned long*)aligned));
 		break;
 	    case INT_LLONG:
-		memcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
+		HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long_long*)aligned));
 		break;
 	    case INT_ULLONG:
-		memcpy(aligned, saved+j*sizeof(long_long),
-		       sizeof(unsigned long_long));
-		HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n",
-		       *((unsigned long_long*)aligned));
+		HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
+		HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)aligned));
 		break;
 	    default:
 		break;
@@ -3666,46 +3597,44 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 		   "");
 	    switch (dst_type) {
 	    case INT_CHAR:
-		memcpy(aligned, buf+j*sizeof(char), sizeof(signed char));
+		HDmemcpy(aligned, buf+j*sizeof(signed char), sizeof(signed char));
 		printf(" %29d\n", *((signed char*)aligned));
 		break;
 	    case INT_UCHAR:
-		memcpy(aligned, buf+j*sizeof(char), sizeof(unsigned char));
+		HDmemcpy(aligned, buf+j*sizeof(unsigned char), sizeof(unsigned char));
 		printf(" %29u\n", *((unsigned char*)aligned));
 		break;
 	    case INT_SHORT:
-		memcpy(aligned, buf+j*sizeof(short), sizeof(short));
+		HDmemcpy(aligned, buf+j*sizeof(short), sizeof(short));
 		printf(" %29d\n", *((short*)aligned));
 		break;
 	    case INT_USHORT:
-		memcpy(aligned, buf+j*sizeof(short), sizeof(unsigned short));
+		HDmemcpy(aligned, buf+j*sizeof(unsigned short), sizeof(unsigned short));
 		printf(" %29u\n", *((unsigned short*)aligned));
 		break;
 	    case INT_INT:
-		memcpy(aligned, buf+j*sizeof(int), sizeof(int));
+		HDmemcpy(aligned, buf+j*sizeof(int), sizeof(int));
 		printf(" %29d\n", *((int*)aligned));
 		break;
 	    case INT_UINT:
-		memcpy(aligned, buf+j*sizeof(unsigned), sizeof(unsigned));
+		HDmemcpy(aligned, buf+j*sizeof(unsigned), sizeof(unsigned));
 		printf(" %29u\n", *((unsigned*)aligned));
 		break;
 	    case INT_LONG:
-		memcpy(aligned, buf+j*sizeof(long), sizeof(long));
+		HDmemcpy(aligned, buf+j*sizeof(long), sizeof(long));
 		printf(" %29ld\n", *((long*)aligned));
 		break;
 	    case INT_ULONG:
-		memcpy(aligned, buf+j*sizeof(long), sizeof(unsigned long));
+		HDmemcpy(aligned, buf+j*sizeof(unsigned long), sizeof(unsigned long));
 		printf(" %29lu\n", *((unsigned long*)aligned));
 		break;
 	    case INT_LLONG:
-		memcpy(aligned, buf+j*sizeof(long_long), sizeof(long_long));
+		HDmemcpy(aligned, buf+j*sizeof(long_long), sizeof(long_long));
 		HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long_long*)aligned));
 		break;
 	    case INT_ULLONG:
-		memcpy(aligned, buf+j*sizeof(long_long),
-		       sizeof(unsigned long_long));
-		HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n",
-		       *((unsigned long_long*)aligned));
+		HDmemcpy(aligned, buf+j*sizeof(long_long), sizeof(unsigned long_long));
+		HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)aligned));
 		break;
 	    default:
 		break;
@@ -3753,7 +3682,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
 	    }
 
 	    if (++fails_all_tests>=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<nelmts*src_size; j++) buf[j] = saved[j] = rand();
+	for (j=0; j<nelmts*src_size; j++)
+            buf[j] = saved[j] = HDrand();
 
 	/* Perform the conversion */
-	if (H5Tconvert(src, dst, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
+	if (H5Tconvert(src, dst, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0)
+            goto error;
 
 	/* Check the results from the library against hardware */
 	for (j=0; j<nelmts; j++) {
@@ -4074,48 +4005,43 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_float;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char), sizeof(char));
+		    HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(char));
 		    hw_float = (float)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char), sizeof(char));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
 		    hw_float = (float)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_float = (float)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		    hw_float = (float)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_float = (float)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_float = (float)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_float = (float)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		    hw_float = (float)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_float = (float)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
 		    hw_float = (float)(*((unsigned long_long*)aligned));
 		    break;
 		default:
@@ -4125,49 +4051,43 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_double;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char), sizeof(signed char));
+		    HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
 		    hw_double = (double)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(unsigned char));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
 		    hw_double = (double)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_double = (double)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		    hw_double = (double)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_double = (double)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_double = (double)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_double = (double)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		    hw_double = (double)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_double = (double)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
 		    hw_double = (double)(*((unsigned long_long*)aligned));
 		    break;
 		default:
@@ -4177,56 +4097,44 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_ldouble;
 		switch (src_type) {
 		case INT_CHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(signed char));
-		    hw_ldouble = (long double)(*((signed char*)
-						       aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(signed char), sizeof(signed char));
+		    hw_ldouble = (long double)(*((signed char*)aligned));
 		    break;
 		case INT_UCHAR:
-		    memcpy(aligned, saved+j*sizeof(char),
-			   sizeof(unsigned char));
-		    hw_ldouble = (long double)(*((unsigned char*)
-						       aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned char), sizeof(unsigned char));
+		    hw_ldouble = (long double)(*((unsigned char*)aligned));
 		    break;
 		case INT_SHORT:
-		    memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		    HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		    hw_ldouble = (long double)(*((short*)aligned));
 		    break;
 		case INT_USHORT:
-		    memcpy(aligned, saved+j*sizeof(short),
-			   sizeof(unsigned short));
-		    hw_ldouble = (long double)(*((unsigned short*)
-						       aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
+		    hw_ldouble = (long double)(*((unsigned short*)aligned));
 		    break;
 		case INT_INT:
-		    memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		    HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		    hw_ldouble = (long double)(*((int*)aligned));
 		    break;
 		case INT_UINT:
-		    memcpy(aligned, saved+j*sizeof(unsigned),
-			   sizeof(unsigned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		    hw_ldouble = (long double)(*((unsigned*)aligned));
 		    break;
 		case INT_LONG:
-		    memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		    HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		    hw_ldouble = (long double)(*((long*)aligned));
 		    break;
 		case INT_ULONG:
-		    memcpy(aligned, saved+j*sizeof(long),
-			   sizeof(unsigned long));
-		    hw_ldouble = (long double)(*((unsigned long*)
-						       aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
+		    hw_ldouble = (long double)(*((unsigned long*)aligned));
 		    break;
 		case INT_LLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(long_long));
+		    HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		    hw_ldouble = (long double)(*((long_long*)aligned));
 		    break;
 		case INT_ULLONG:
-		    memcpy(aligned, saved+j*sizeof(long_long),
-			   sizeof(unsigned long_long));
-		    hw_ldouble = (long double)(*((unsigned long_long*)
-						       aligned));
+		    HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
+		    hw_ldouble = (long double)(*((unsigned long_long*)aligned));
 		    break;
 		default:
 		    break;
@@ -4235,16 +4143,15 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_char;
 		switch (src_type) {
 		case FLT_FLOAT:
-		    memcpy(aligned, saved+j*sizeof(float), sizeof(float));
+		    HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
 		    hw_char = (char)(*((float*)aligned));
 		    break;
 		case FLT_DOUBLE:
-		    memcpy(aligned, saved+j*sizeof(double), sizeof(double));
+		    HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
 		    hw_char = (char)(*((double*)aligned));
 		    break;
 		case FLT_LDOUBLE:
-		    memcpy(aligned, saved+j*sizeof(long double), 
-                            sizeof(long double));
+		    HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double));
 		    hw_char = (char)(*((long double*)aligned));
 		    break;
 		default:
@@ -4254,16 +4161,15 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_uchar;
 		switch (src_type) {
 		case FLT_FLOAT:
-		    memcpy(aligned, saved+j*sizeof(float), sizeof(float));
+		    HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
 		    hw_uchar = (unsigned char)(*((float*)aligned));
 		    break;
 		case FLT_DOUBLE:
-		    memcpy(aligned, saved+j*sizeof(double), sizeof(double));
+		    HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
 		    hw_uchar = (unsigned char)(*((double*)aligned));
 		    break;
 		case FLT_LDOUBLE:
-		    memcpy(aligned, saved+j*sizeof(long double), 
-                            sizeof(long double));
+		    HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double));
 		    hw_uchar = (unsigned char)(*((long double*)aligned));
 		    break;
 		default:
@@ -4273,16 +4179,15 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_short;
 		switch (src_type) {
 		case FLT_FLOAT:
-		    memcpy(aligned, saved+j*sizeof(float), sizeof(float));
+		    HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
 		    hw_short = (short)(*((float*)aligned));
 		    break;
 		case FLT_DOUBLE:
-		    memcpy(aligned, saved+j*sizeof(double), sizeof(double));
+		    HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
 		    hw_short = (short)(*((double*)aligned));
 		    break;
 		case FLT_LDOUBLE:
-		    memcpy(aligned, saved+j*sizeof(long double), 
-                            sizeof(long double));
+		    HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double));
 		    hw_short = (short)(*((long double*)aligned));
 		    break;
 		default:
@@ -4292,16 +4197,15 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_ushort;
 		switch (src_type) {
 		case FLT_FLOAT:
-		    memcpy(aligned, saved+j*sizeof(float), sizeof(float));
+		    HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
 		    hw_ushort = (unsigned short)(*((float*)aligned));
 		    break;
 		case FLT_DOUBLE:
-		    memcpy(aligned, saved+j*sizeof(double), sizeof(double));
+		    HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
 		    hw_ushort = (unsigned short)(*((double*)aligned));
 		    break;
 		case FLT_LDOUBLE:
-		    memcpy(aligned, saved+j*sizeof(long double), 
-                            sizeof(long double));
+		    HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double));
 		    hw_ushort = (unsigned short)(*((long double*)aligned));
 		    break;
 		default:
@@ -4311,16 +4215,15 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_int;
 		switch (src_type) {
 		case FLT_FLOAT:
-		    memcpy(aligned, saved+j*sizeof(float), sizeof(float));
+		    HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
 		    hw_int = (int)(*((float*)aligned));
 		    break;
 		case FLT_DOUBLE:
-		    memcpy(aligned, saved+j*sizeof(double), sizeof(double));
+		    HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
 		    hw_int = (int)(*((double*)aligned));
 		    break;
 		case FLT_LDOUBLE:
-		    memcpy(aligned, saved+j*sizeof(long double), 
-                            sizeof(long double));
+		    HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double));
 		    hw_int = (int)(*((long double*)aligned));
 		    break;
 		default:
@@ -4330,16 +4233,15 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_uint;
 		switch (src_type) {
 		case FLT_FLOAT:
-		    memcpy(aligned, saved+j*sizeof(float), sizeof(float));
+		    HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
 		    hw_uint = (unsigned int)(*((float*)aligned));
 		    break;
 		case FLT_DOUBLE:
-		    memcpy(aligned, saved+j*sizeof(double), sizeof(double));
+		    HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
 		    hw_uint = (unsigned int)(*((double*)aligned));
 		    break;
 		case FLT_LDOUBLE:
-		    memcpy(aligned, saved+j*sizeof(long double), 
-                            sizeof(long double));
+		    HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double));
 		    hw_uint = (unsigned int)(*((long double*)aligned));
 		    break;
 		default:
@@ -4349,16 +4251,15 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_long;
 		switch (src_type) {
 		case FLT_FLOAT:
-		    memcpy(aligned, saved+j*sizeof(float), sizeof(float));
+		    HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
 		    hw_long = (long)(*((float*)aligned));
 		    break;
 		case FLT_DOUBLE:
-		    memcpy(aligned, saved+j*sizeof(double), sizeof(double));
+		    HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
 		    hw_long = (long)(*((double*)aligned));
 		    break;
 		case FLT_LDOUBLE:
-		    memcpy(aligned, saved+j*sizeof(long double), 
-                            sizeof(long double));
+		    HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double));
 		    hw_long = (long)(*((long double*)aligned));
 		    break;
 		default:
@@ -4368,16 +4269,15 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_ulong;
 		switch (src_type) {
 		case FLT_FLOAT:
-		    memcpy(aligned, saved+j*sizeof(float), sizeof(float));
+		    HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
 		    hw_ulong = (unsigned long)(*((float*)aligned));
 		    break;
 		case FLT_DOUBLE:
-		    memcpy(aligned, saved+j*sizeof(double), sizeof(double));
+		    HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
 		    hw_ulong = (unsigned long)(*((double*)aligned));
 		    break;
 		case FLT_LDOUBLE:
-		    memcpy(aligned, saved+j*sizeof(long double), 
-                            sizeof(long double));
+		    HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double));
 		    hw_ulong = (unsigned long)(*((long double*)aligned));
 		    break;
 		default:
@@ -4387,15 +4287,15 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_llong;
 		switch (src_type) {
 		case FLT_FLOAT:
-		    memcpy(aligned, saved+j*sizeof(float), sizeof(float));
+		    HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
 		    hw_llong = (long_long)(*((float*)aligned));
 		    break;
 		case FLT_DOUBLE:
-		    memcpy(aligned, saved+j*sizeof(double), sizeof(double));
+		    HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
 		    hw_llong = (long_long)(*((double*)aligned));
 		    break;
 		case FLT_LDOUBLE:
-		    memcpy(aligned, saved+j*sizeof(long double), sizeof(double));
+		    HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(double));
 		    hw_llong = (long_long)(*((long double*)aligned));
 		    break;
 		default:
@@ -4405,15 +4305,15 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 		hw = (unsigned char*)&hw_ullong;
 		switch (src_type) {
 		case FLT_FLOAT:
-		    memcpy(aligned, saved+j*sizeof(float), sizeof(float));
+		    HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
 		    hw_ullong = (unsigned long_long)(*((float*)aligned));
 		    break;
 		case FLT_DOUBLE:
-		    memcpy(aligned, saved+j*sizeof(double), sizeof(double));
+		    HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
 		    hw_ullong = (unsigned long_long)(*((double*)aligned));
 		    break;
 		case FLT_LDOUBLE:
-		    memcpy(aligned, saved+j*sizeof(long double), sizeof(double));
+		    HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(double));
 		    hw_ullong = (unsigned long_long)(*((long double*)aligned));
 		    break;
 		default:
@@ -4425,10 +4325,11 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
             assert(dst_nbits%8==0);
 
             /* Are the two results the same */
-            for (k=(dst_size-(dst_nbits/8)); k<dst_size; k++) {
-                if (buf[j*dst_size+k]!=hw[k]) break;
-	    }
-	    if (k==dst_size) continue; /*no error*/
+            for (k=(dst_size-(dst_nbits/8)); k<dst_size; k++)
+                if (buf[j*dst_size+k]!=hw[k])
+                    break;
+	    if (k==dst_size)
+                continue; /*no error*/
            
 	    /*
 	     * Convert the source and destination values to little endian
@@ -4436,141 +4337,125 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 	     * certain things.  These routines have already been tested by
 	     * the `bittests' program.
 	     */
-	    for (k=0; k<src_size; k++) {
-		src_bits[src_size-(k+1)] = saved[j*src_size+
-						 ENDIAN(src_size, k)];
-	    }
+	    for (k=0; k<src_size; k++)
+		src_bits[src_size-(k+1)] = saved[j*src_size+ENDIAN(src_size, k)];
 	    
-	    for (k=0; k<dst_size; k++) {
-		dst_bits[dst_size-(k+1)] = buf[j*dst_size+
-					       ENDIAN(dst_size, k)];
-	    }
+	    for (k=0; k<dst_size; k++)
+		dst_bits[dst_size-(k+1)] = buf[j*dst_size+ENDIAN(dst_size, k)];
 
-#ifndef TMP
 	    /*
 	     * Hardware usually doesn't handle overflows too gracefully. The
 	     * hardware conversion result during overflows is usually garbage
 	     * so we must handle those cases differetly when checking results.
 	     */
             if ((FLT_FLOAT==src_type || FLT_DOUBLE==src_type || FLT_LDOUBLE==src_type)
-                && (INT_CHAR==dst_type || INT_SHORT==dst_type || INT_INT==dst_type 
-                || INT_LONG==dst_type || INT_LLONG==dst_type)) {
+                    && (INT_CHAR==dst_type || INT_SHORT==dst_type || INT_INT==dst_type 
+                    || INT_LONG==dst_type || INT_LLONG==dst_type)) {
                 if(0==H5T_bit_get_d(src_bits, src_nbits-1, 1) &&
-                    overflows(src_bits, src_type, src_size, dst_nbits-1)) {
+                        overflows(src_bits, src_type, src_size, dst_nbits-1)) {
                     /*
                      * Source is positive and the magnitude is too large for
                      * the destination.  The destination should be set to the
                      * maximum possible value: 0x7f...f
                      */
                     if (0==H5T_bit_get_d(dst_bits, dst_nbits-1, 1) &&
-                            H5T_bit_find(dst_bits, 0, dst_nbits-1,
-                                 H5T_BIT_LSB, 0)<0) {
+                            H5T_bit_find(dst_bits, 0, dst_nbits-1, H5T_BIT_LSB, 0)<0)
                         continue; /*no error*/
-                    }
                 } else if (1==H5T_bit_get_d(src_bits, src_nbits-1, 1) &&
-                    overflows(src_bits, src_type, src_size, dst_nbits-1)) {
+                        overflows(src_bits, src_type, src_size, dst_nbits-1)) {
                     /*
                      * Source is negative but the magnitude is too large for
                      * the destination. The destination should be set to the
                      * smallest possible value: 0x80...0
                      */
                     if (1==H5T_bit_get_d(dst_bits, dst_nbits-1, 1) &&
-                            H5T_bit_find(dst_bits, 0, dst_nbits-1,
-                                 H5T_BIT_LSB, 1)<0) {
+                            H5T_bit_find(dst_bits, 0, dst_nbits-1, H5T_BIT_LSB, 1)<0)
                         continue; /*no error*/
-                    }
                 }
             }
 
             if ((FLT_FLOAT==src_type || FLT_DOUBLE==src_type || FLT_LDOUBLE==src_type)
-                && (INT_UCHAR==dst_type || INT_USHORT==dst_type || INT_UINT==dst_type 
-                || INT_ULONG==dst_type || INT_ULLONG==dst_type)) {
+                    && (INT_UCHAR==dst_type || INT_USHORT==dst_type || INT_UINT==dst_type 
+                    || INT_ULONG==dst_type || INT_ULLONG==dst_type)) {
                 if (H5T_bit_get_d(src_bits, src_nbits-1, 1)) {
                     /*
                      * The source is negative so the result should be zero.
                      * The source is negative if the most significant bit is
                      * set.  The destination is zero if all bits are zero.
                      */
-                    if (H5T_bit_find(dst_bits, 0, dst_nbits, H5T_BIT_LSB, 1)<0) {
+                    if (H5T_bit_find(dst_bits, 0, dst_nbits, H5T_BIT_LSB, 1)<0)
                         continue; /*no error*/
-                    }
                 } else if (overflows(src_bits, src_type, src_size, dst_nbits)) {
                     /*
                      * The source is a value with a magnitude too large for
                      * the destination.  The destination should be the
                      * largest possible value: 0xff...f
                      */
-                    if (H5T_bit_find(dst_bits, 0, dst_nbits, H5T_BIT_LSB, 0)<0) {
+                    if (H5T_bit_find(dst_bits, 0, dst_nbits, H5T_BIT_LSB, 0)<0)
                         continue; /*no error*/
-                    }
                 }
             }
-#endif /*TMP*/
 
 	    /* Print errors */
-	    if (0==fails_this_test++) H5_FAILED();
+	    if (0==fails_this_test++)
+                H5_FAILED();
 	    printf("    test %u elmt %u: \n", (unsigned)i+1, (unsigned)j);
 
 	    printf("        src = ");
-	    for (k=0; k<src_size; k++) {
+	    for (k=0; k<src_size; k++)
 		printf(" %02x", saved[j*src_size+ENDIAN(src_size, k)]);
-	    }
-	    printf("%*s", (int)(3*MAX(0, (ssize_t)dst_size-(ssize_t)src_size)),
-		   "");
+	    printf("%*s", (int)(3*MAX(0, (ssize_t)dst_size-(ssize_t)src_size)), "");
 	    switch (src_type) {
 	    case INT_CHAR:
-		memcpy(aligned, saved+j*sizeof(char), sizeof(signed char));
+		HDmemcpy(aligned, saved+j*sizeof(char), sizeof(signed char));
 		printf(" %29d\n", *((signed char*)aligned));
 		break;
 	    case INT_UCHAR:
-		memcpy(aligned, saved+j*sizeof(char), sizeof(unsigned char));
+		HDmemcpy(aligned, saved+j*sizeof(char), sizeof(unsigned char));
 		printf(" %29u\n", *((unsigned char*)aligned));
 		break;
 	    case INT_SHORT:
-		memcpy(aligned, saved+j*sizeof(short), sizeof(short));
+		HDmemcpy(aligned, saved+j*sizeof(short), sizeof(short));
 		printf(" %29hd\n", *((short*)aligned));
 		break;
 	    case INT_USHORT:
-		memcpy(aligned, saved+j*sizeof(short),
-		       sizeof(unsigned short));
+		HDmemcpy(aligned, saved+j*sizeof(unsigned short), sizeof(unsigned short));
 		printf(" %29hu\n", *((unsigned short*)aligned));
 		break;
 	    case INT_INT:
-		memcpy(aligned, saved+j*sizeof(int), sizeof(int));
+		HDmemcpy(aligned, saved+j*sizeof(int), sizeof(int));
 		printf(" %29d\n", *((int*)aligned));
 		break;
 	    case INT_UINT:
-		memcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
+		HDmemcpy(aligned, saved+j*sizeof(unsigned), sizeof(unsigned));
 		printf(" %29u\n", *((unsigned*)aligned));
 		break;
 	    case INT_LONG:
-		memcpy(aligned, saved+j*sizeof(long), sizeof(long));
+		HDmemcpy(aligned, saved+j*sizeof(long), sizeof(long));
 		printf(" %29ld\n", *((long*)aligned));
 		break;
 	    case INT_ULONG:
-		memcpy(aligned, saved+j*sizeof(long), sizeof(unsigned long));
+		HDmemcpy(aligned, saved+j*sizeof(unsigned long), sizeof(unsigned long));
 		printf(" %29lu\n", *((unsigned long*)aligned));
 		break;
 	    case INT_LLONG:
-		memcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
+		HDmemcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long));
 		HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long_long*)aligned));
 		break;
 	    case INT_ULLONG:
-		memcpy(aligned, saved+j*sizeof(long_long),
-		       sizeof(unsigned long_long));
-		HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n",
-		       *((unsigned long_long*)aligned));
+		HDmemcpy(aligned, saved+j*sizeof(unsigned long_long), sizeof(unsigned long_long));
+		HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)aligned));
 		break;
 	    case FLT_FLOAT:
-		memcpy(aligned, saved+j*sizeof(float), sizeof(float));
+		HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
 		printf(" %29f\n", *((float*)aligned));
 		break;
 	    case FLT_DOUBLE:
-		memcpy(aligned, saved+j*sizeof(double), sizeof(double));
+		HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
 		printf(" %29f\n", *((double*)aligned));
 		break;
 	    case FLT_LDOUBLE:
-		memcpy(aligned, saved+j*sizeof(long double), sizeof(long double));
+		HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double));
 		printf(" %29Lf\n", *((long double*)aligned));
 		break;
 	    case OTHER:
@@ -4578,65 +4463,60 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 	    }
 	    
 	    printf("        dst = ");
-	    for (k=0; k<dst_size; k++) {
+	    for (k=0; k<dst_size; k++)
 		printf(" %02x", buf[j*dst_size+ENDIAN(dst_size, k)]);
-	    }
-	    printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)),
-		   "");
+	    printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)), "");
 	    switch (dst_type) {
 	    case INT_CHAR:
-		memcpy(aligned, buf+j*sizeof(char), sizeof(signed char));
+		HDmemcpy(aligned, buf+j*sizeof(char), sizeof(signed char));
 		printf(" %29d\n", *((signed char*)aligned));
 		break;
 	    case INT_UCHAR:
-		memcpy(aligned, buf+j*sizeof(char), sizeof(unsigned char));
+		HDmemcpy(aligned, buf+j*sizeof(char), sizeof(unsigned char));
 		printf(" %29u\n", *((unsigned char*)aligned));
 		break;
 	    case INT_SHORT:
-		memcpy(aligned, buf+j*sizeof(short), sizeof(short));
+		HDmemcpy(aligned, buf+j*sizeof(short), sizeof(short));
 		printf(" %29hd\n", *((short*)aligned));
 		break;
 	    case INT_USHORT:
-		memcpy(aligned, buf+j*sizeof(short),
-		       sizeof(unsigned short));
+		HDmemcpy(aligned, buf+j*sizeof(unsigned short), sizeof(unsigned short));
 		printf(" %29hu\n", *((unsigned short*)aligned));
 		break;
 	    case INT_INT:
-		memcpy(aligned, buf+j*sizeof(int), sizeof(int));
+		HDmemcpy(aligned, buf+j*sizeof(int), sizeof(int));
 		printf(" %29d\n", *((int*)aligned));
 		break;
 	    case INT_UINT:
-		memcpy(aligned, buf+j*sizeof(unsigned), sizeof(unsigned));
+		HDmemcpy(aligned, buf+j*sizeof(unsigned), sizeof(unsigned));
 		printf(" %29u\n", *((unsigned*)aligned));
 		break;
 	    case INT_LONG:
-		memcpy(aligned, buf+j*sizeof(long), sizeof(long));
+		HDmemcpy(aligned, buf+j*sizeof(long), sizeof(long));
 		printf(" %29ld\n", *((long*)aligned));
 		break;
 	    case INT_ULONG:
-		memcpy(aligned, buf+j*sizeof(long), sizeof(unsigned long));
+		HDmemcpy(aligned, buf+j*sizeof(unsigned long), sizeof(unsigned long));
 		printf(" %29lu\n", *((unsigned long*)aligned));
 		break;
 	    case INT_LLONG:
-		memcpy(aligned, buf+j*sizeof(long_long), sizeof(long_long));
+		HDmemcpy(aligned, buf+j*sizeof(long_long), sizeof(long_long));
 		HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"d\n", *((long_long*)aligned));
 		break;
 	    case INT_ULLONG:
-		memcpy(aligned, buf+j*sizeof(long_long),
-		       sizeof(unsigned long_long));
-		HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n",
-		       *((unsigned long_long*)aligned));
+		HDmemcpy(aligned, buf+j*sizeof(long_long), sizeof(unsigned long_long));
+		HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)aligned));
 		break;
 	    case FLT_FLOAT:
-		memcpy(aligned, buf+j*sizeof(float), sizeof(float));
+		HDmemcpy(aligned, buf+j*sizeof(float), sizeof(float));
 		printf(" %29f\n", *((float*)aligned));
 		break;
 	    case FLT_DOUBLE:
-		memcpy(aligned, buf+j*sizeof(double), sizeof(double));
+		HDmemcpy(aligned, buf+j*sizeof(double), sizeof(double));
 		printf(" %29f\n", *((double*)aligned));
 		break;
 	    case FLT_LDOUBLE:
-		memcpy(aligned, buf+j*sizeof(long double), sizeof(long double));
+		HDmemcpy(aligned, buf+j*sizeof(long double), sizeof(long double));
 		printf(" %29Lf\n", *((long double*)aligned));
 		break;
 	    case OTHER:
@@ -4644,11 +4524,9 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 	    }
 	    
 	    printf("        ans = ");
-	    for (k=0; k<dst_size; k++) {
+	    for (k=0; k<dst_size; k++)
 		printf(" %02x", hw[ENDIAN(dst_size, k)]);
-	    }
-	    printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)),
-		   "");
+	    printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)), "");
 	    switch (dst_type) {
 	    case INT_CHAR:
 		printf(" %29d\n", *((char*)hw));
@@ -4694,7 +4572,7 @@ test_conv_int_float(const char *name, hid_t src, hid_t dst)
 	    }
 
 	    if (++fails_all_tests>=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<ntests; i++) {
 
 	/*
@@ -5013,7 +4898,7 @@ test_conv_flt_1 (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;
 
 	/*
@@ -5022,7 +4907,8 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
 	 * used for the comparison later.
 	 */
 	if (!skip_overflow_tests_g) {
-	    for (j=0; j<nelmts*src_size; j++) buf[j] = saved[j] = rand();
+	    for (j=0; j<nelmts*src_size; j++)
+                buf[j] = saved[j] = HDrand();
 	} else {
 	    for (j=0; j<nelmts; j++) {
 		/* Do it this way for alignment reasons */
@@ -5032,30 +4918,30 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
 		double temp[1];
 #endif
 		if (src_size<=dst_size) {
-		    for (k=0; k<dst_size; k++) buf[j*src_size+k] = rand();
+		    for (k=0; k<dst_size; k++) buf[j*src_size+k] = HDrand();
 		} else {
-		    for (k=0; k<dst_size; k++) {
-			((unsigned char*)temp)[k] = rand();
-		    }
+		    for (k=0; k<dst_size; k++)
+			((unsigned char*)temp)[k] = HDrand();
 		    if (FLT_DOUBLE==src_type && FLT_FLOAT==dst_type) {
 			hw_d = *((float*)temp);
-			memcpy(buf+j*src_size, &hw_d, src_size);
+			HDmemcpy(buf+j*src_size, &hw_d, src_size);
 #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE
 		    } else if (FLT_LDOUBLE==src_type && FLT_FLOAT==dst_type) {
 			hw_ld = *((float*)temp);
-			memcpy(buf+j*src_size, &hw_ld, src_size);
+			HDmemcpy(buf+j*src_size, &hw_ld, src_size);
 		    } else if (FLT_LDOUBLE==src_type && FLT_DOUBLE==dst_type) {
 			hw_ld = *((double*)temp);
-			memcpy(buf+j*src_size, &hw_ld, src_size);
+			HDmemcpy(buf+j*src_size, &hw_ld, src_size);
 #endif
 		    }
 		}
-		memcpy(saved+j*src_size, buf+j*src_size, src_size);
+		HDmemcpy(saved+j*src_size, buf+j*src_size, src_size);
 	    }
 	}
 
 	/* Perform the conversion in software */
-	if (H5Tconvert(src, dst, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error;
+	if (H5Tconvert(src, dst, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0)
+            goto error;
 
 	/* Check the software results against the hardware */
 	for (j=0; j<nelmts; j++) {
@@ -5067,7 +4953,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
 
 	    /* The hardware conversion */
 	    if (FLT_FLOAT==src_type) {
-		memcpy(aligned, saved+j*sizeof(float), sizeof(float));
+		HDmemcpy(aligned, saved+j*sizeof(float), sizeof(float));
 		if (FLT_FLOAT==dst_type) {
 		    hw_f = *((float*)aligned);
 		    hw = (unsigned char*)&hw_f;
@@ -5081,7 +4967,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
 #endif
 		}
 	    } else if (FLT_DOUBLE==src_type) {
-		memcpy(aligned, saved+j*sizeof(double), sizeof(double));
+		HDmemcpy(aligned, saved+j*sizeof(double), sizeof(double));
 		if (FLT_FLOAT==dst_type) {
 		    hw_f = (float)(*((double*)aligned));
 		    hw = (unsigned char*)&hw_f;
@@ -5096,8 +4982,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
 		}
 #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE
 	    } else {
-		memcpy(aligned, saved+j*sizeof(long double),
-		       sizeof(long double)); 
+		HDmemcpy(aligned, saved+j*sizeof(long double), sizeof(long double)); 
 		if (FLT_FLOAT==dst_type) {
 		    hw_f = *((long double*)aligned); 
 		    hw = (unsigned char*)&hw_f;
@@ -5112,12 +4997,12 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
 	    }
 
 	    /* Are the two results the same? */
-	    for (k=0; k<dst_size; k++) {
-		if (buf[j*dst_size+k]!=hw[k]) break;
-	    }
-	    if (k==dst_size) continue; /*no error*/
+	    for (k=0; k<dst_size; k++)
+		if (buf[j*dst_size+k]!=hw[k])
+                    break;
+	    if (k==dst_size)
+                continue; /*no error*/
 
-#if 1
 	    /*
 	     * Assume same if both results are NaN.  There are many NaN bit
 	     * patterns and the software doesn't attemt to emulate the
@@ -5125,32 +5010,29 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
 	     * pattern for NaN by setting the significand to all ones.
 	     */
 	    if (FLT_FLOAT==dst_type &&
-		my_isnan(dst_type, (float*)buf+j) &&
-		my_isnan(dst_type, hw)) {
+                    my_isnan(dst_type, buf+j*sizeof(float)) &&
+                    my_isnan(dst_type, hw)) {
 		continue;
 	    } else if (FLT_DOUBLE==dst_type &&
-		       my_isnan(dst_type, (double*)buf+j) &&
-		       my_isnan(dst_type, hw)) {
+                    my_isnan(dst_type, buf+j*sizeof(double)) &&
+                    my_isnan(dst_type, hw)) {
 		continue;
 #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE
 	    } else if (FLT_LDOUBLE==dst_type &&
-		       my_isnan(dst_type, (long double*)buf+j) &&
-		       my_isnan(dst_type, hw)) {
+                    my_isnan(dst_type, buf+j*sizeof(long double)) &&
+                    my_isnan(dst_type, hw)) {
 		continue;
 #endif
 	    }
-#endif
 
-#if 1
 	    /*
 	     * Assume same if hardware result is NaN.  This is because the
 	     * hardware conversions on some machines return NaN instead of
 	     * overflowing to +Inf or -Inf or underflowing to +0 or -0.
 	     */
-	    if (my_isnan(dst_type, hw)) continue;
-#endif
+	    if (my_isnan(dst_type, hw))
+                continue;
 
-#if 1
 	    /*
 	     * Instead of matching down to the bit, just make sure the
 	     * exponents are the same and the mantissa is the same to a
@@ -5163,22 +5045,23 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
 		
 		if (FLT_FLOAT==dst_type) {
 		    float x;
-		    memcpy(&x, (float*)buf+j, sizeof(float));
-		    check_mant[0] = frexp(x, check_expo+0);
-		    check_mant[1] = frexp(((float*)hw)[0], check_expo+1);
+		    HDmemcpy(&x, &buf[j*dst_size], sizeof(float));
+		    check_mant[0] = HDfrexpf(x, check_expo+0);
+		    check_mant[1] = HDfrexpf(hw_f, check_expo+1);
 		} else if (FLT_DOUBLE==dst_type) {
 		    double x;
-		    memcpy(&x, (double*)buf+j, sizeof(double));
-		    check_mant[0] = frexp(x, check_expo+0);
-		    check_mant[1] = frexp(((double*)hw)[0], check_expo+1);
+		    HDmemcpy(&x, &buf[j*dst_size], sizeof(double));
+		    check_mant[0] = HDfrexp(x, check_expo+0);
+		    check_mant[1] = HDfrexp(hw_d, check_expo+1);
 #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE
 		} else {
 		    long double x;
-		    memcpy(&x, (long double*)buf+j, sizeof(long double));
-		    check_mant[0] = frexp(x, check_expo+0);
-		    check_mant[1] = frexp(((long double*)hw)[0], check_expo+1);
+		    HDmemcpy(&x, &buf[j*dst_size], sizeof(long double));
+		    check_mant[0] = HDfrexpl(x, check_expo+0);
+		    check_mant[1] = HDfrexpl(hw_ld, check_expo+1);
 #endif
 		}
+#ifdef H5_CONVERT_DENORMAL_FLOAT
 		/* Special check for denormalized values */
 		if(check_expo[0]<(-(int)dst_ebias) || check_expo[1]<(-(int)dst_ebias)) {
 		    int expo_diff=check_expo[0]-check_expo[1];
@@ -5187,107 +5070,131 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
 
 		    /* Re-scale the mantissas based on any exponent difference */
 		    if(expo_diff!=0)
-		        check_mant[0] = ldexp(check_mant[0],expo_diff);
+		        check_mant[0] = HDldexp(check_mant[0],expo_diff);
 
 		    /* Compute the proper epsilon */
-		    epsilon=ldexp(epsilon,-valid_bits);
+		    epsilon=HDldexp(epsilon,-valid_bits);
 
 		    /* Check for "close enough" fit with scaled epsilon value */
-		    if (fabs(check_mant[0]-check_mant[1])<=epsilon)
+		    if (HDfabs(check_mant[0]-check_mant[1])<=epsilon)
 		        continue;
 		} /* end if */
 		else {
 		    if (check_expo[0]==check_expo[1] &&
-                            fabs(check_mant[0]-check_mant[1])<FP_EPSILON)
+                            HDfabs(check_mant[0]-check_mant[1])<FP_EPSILON)
 		        continue;
 		} /* end else */
+#else /* H5_CONVERT_DENORMAL_FLOAT */
+                {
+                hssize_t	expo;			/*exponent			*/
+                uint8_t tmp[32];
+
+                assert(src_size<=sizeof(tmp));
+                if(endian==H5T_ORDER_LE)
+                    HDmemcpy(tmp,&saved[j*src_size],src_size);
+                else
+                    for (k=0; k<src_size; k++)
+                        tmp[k]=saved[j*src_size+(src_size-(k+1))];
+                expo = H5T_bit_get_d(tmp, src_epos, src_esize);
+                if(expo==0)
+                    continue;   /* Denormalized floating-point value detected */
+                else {
+                    assert(dst_size<=sizeof(tmp));
+                    if(endian==H5T_ORDER_LE)
+                        HDmemcpy(tmp,&buf[j*dst_size],dst_size);
+                    else
+                        for (k=0; k<dst_size; k++)
+                            tmp[k]=buf[j*dst_size+(dst_size-(k+1))];
+                    expo = H5T_bit_get_d(tmp, dst_epos, dst_esize);
+                    if(expo==0)
+                        continue;   /* Denormalized floating-point value detected */
+                    else {
+                        if (check_expo[0]==check_expo[1] &&
+                                HDfabs(check_mant[0]-check_mant[1])<FP_EPSILON)
+                            continue;
+                    } /* end else */
+                } /* end else */
+                }
+#endif /* H5_CONVERT_DENORMAL_FLOAT */
 	    }
-#endif
 
-	    if (0==fails_this_test++) H5_FAILED();
+	    if (0==fails_this_test++)
+                H5_FAILED();
 	    printf("    test %u, elmt %u\n", (unsigned)i+1, (unsigned)j);
 	    
 	    printf("        src =");
-	    for (k=0; k<src_size; k++) {
+	    for (k=0; k<src_size; k++)
 		printf(" %02x", saved[j*src_size+ENDIAN(src_size,k)]);
-	    }
-	    printf("%*s", (int)(3*MAX(0, (ssize_t)dst_size-(ssize_t)src_size)),
-		   "");
+	    printf("%*s", (int)(3*MAX(0, (ssize_t)dst_size-(ssize_t)src_size)), "");
 	    if (FLT_FLOAT==src_type) {
 		float x;
-		memcpy(&x, (float*)saved+j, sizeof(float));
+		HDmemcpy(&x, &saved[j*dst_size], sizeof(float));
 		printf(" %29.20e\n", x);
 	    } else if (FLT_DOUBLE==src_type) {
 		double x;
-		memcpy(&x, (double*)saved+j, sizeof(double));
+		HDmemcpy(&x, &saved[j*dst_size], sizeof(double));
 		printf(" %29.20e\n", x);
 #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE
 	    } else {
 		long double x;
-		memcpy(&x, (long double*)saved+j, sizeof(long double));
+		HDmemcpy(&x, &saved[j*src_size], sizeof(long double));
 		HDfprintf(stdout," %29.20Le\n", x);
 #endif
 	    }
 
 	    printf("        dst =");
-	    for (k=0; k<dst_size; k++) {
+	    for (k=0; k<dst_size; k++)
 		printf(" %02x", buf[j*dst_size+ENDIAN(dst_size,k)]);
-	    }
-	    printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)),
-		   "");
+	    printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)), "");
 	    if (FLT_FLOAT==dst_type) {
 		float x;
-		memcpy(&x, (float*)buf+j, sizeof(float));
+		HDmemcpy(&x, &buf[j*dst_size], sizeof(float));
 		printf(" %29.20e\n", x);
 	    } else if (FLT_DOUBLE==dst_type) {
 		double x;
-		memcpy(&x, (double*)buf+j, sizeof(double));
+		HDmemcpy(&x, &buf[j*dst_size], sizeof(double));
 		printf(" %29.20e\n", x);
 #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE
 	    } else {
 		long double x;
-		memcpy(&x, (long double*)buf+j, sizeof(long double));
+		HDmemcpy(&x, &buf[j*dst_size], sizeof(long double));
 		HDfprintf(stdout," %29.20Le\n", x);
 #endif
 	    }
 
 	    printf("        ans =");
-	    for (k=0; k<dst_size; k++) {
+	    for (k=0; k<dst_size; k++)
 		printf(" %02x", hw[ENDIAN(dst_size,k)]);
-	    }
-	    printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)),
-		   "");
-	    if (FLT_FLOAT==dst_type) {
+	    printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)), "");
+	    if (FLT_FLOAT==dst_type)
 		printf(" %29.20e\n", hw_f);
-	    } else if (FLT_DOUBLE==dst_type) {
+	    else if (FLT_DOUBLE==dst_type)
 		printf(" %29.20e\n", hw_d);
 #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE
-	    } else {
+	    else
 		HDfprintf(stdout," %29.20Le\n", hw_ld);
 #endif
-	    }
 
 	    if (++fails_all_tests>=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