summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-07-03 01:16:22 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-07-03 01:16:22 (GMT)
commit203a7329154d957480aa83f8508276197e4738f4 (patch)
treef752776b0a688b520d7b8b90ed296242b5aad019
parentb81abe336d5ab6498fc6e382822a9f85be1af8e9 (diff)
downloadhdf5-203a7329154d957480aa83f8508276197e4738f4.zip
hdf5-203a7329154d957480aa83f8508276197e4738f4.tar.gz
hdf5-203a7329154d957480aa83f8508276197e4738f4.tar.bz2
[svn-r446] Changes since 19980702
---------------------- ./MANIFEST Added new files from testpar directory. ./config/commence.in Removed -D_POSIX_SOURCE because hdf5 uses a couple of non-Posix things when certain debugging flags are switched on.
-rw-r--r--MANIFEST3
-rw-r--r--config/commence.in2
-rw-r--r--src/H5Tconv.c16
-rw-r--r--test/dtypes.c32
4 files changed, 45 insertions, 8 deletions
diff --git a/MANIFEST b/MANIFEST
index 1ad54e7..c71e31e 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -238,7 +238,10 @@
./testpar/Makefile.ascired
./testpar/Makefile.irix64
./testpar/README
+./testpar/t_dset.c
+./testpar/t_file.c
./testpar/testphdf5.c
+./testpar/testphdf5.h
./tgif/APIGrammar.obj
./tgif/FileGrammar.obj
./tgif/IOPipe.obj
diff --git a/config/commence.in b/config/commence.in
index 8b33182..72fb45c 100644
--- a/config/commence.in
+++ b/config/commence.in
@@ -12,7 +12,7 @@
# Programs
SHELL=/bin/sh
CC=@CC@
-CFLAGS=-D_POSIX_SOURCE @CFLAGS@
+CFLAGS=@CFLAGS@
CPPFLAGS=@CPPFLAGS@
LIBS=@LIBS@
AR=@AR@
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 930b330..800a9ea 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -13,6 +13,7 @@
#include <H5Eprivate.h>
#include <H5MMprivate.h>
#include <H5Tpkg.h>
+#include <float.h> /*for FLT_MAX and FLT_MIN */
#include <math.h> /*for ceil() */
/* Conversion data for H5T_conv_struct() */
@@ -1349,8 +1350,19 @@ H5T_conv_double_float (hid_t __unused__ src_id, hid_t __unused__ dst_id,
s = (double*)buf;
d = (float*)buf;
- for (elmtno=0; elmtno<nelmts; elmtno++) {
- *d++ = *s++;
+ /*
+ * We have to watch out because some machines generate a SIGFPE if
+ * the source has a larger magnitude than can be represented in the
+ * destination.
+ */
+ for (elmtno=0; elmtno<nelmts; elmtno++, d++, s++) {
+ if (*s > FLT_MAX) {
+ *d = FLT_MAX;
+ } else if (*s < -FLT_MAX) {
+ *d = -FLT_MAX;
+ } else {
+ *d = *s;
+ }
}
break;
diff --git a/test/dtypes.c b/test/dtypes.c
index 455fd3b..083e73f 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -8,6 +8,7 @@
* Purpose: Tests the data type interface (H5T)
*/
#include <assert.h>
+#include <float.h>
#include <hdf5.h>
#include <math.h>
#include <signal.h>
@@ -695,7 +696,7 @@ static int
test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
{
flt_t src_type, dst_type; /*data types */
- const size_t ntests=10; /*number of tests */
+ const size_t ntests=5; /*number of tests */
const size_t nelmts=200000; /*num values per test */
const size_t max_fails=8; /*max number of failures*/
size_t fails_all_tests=0; /*number of failures */
@@ -799,7 +800,14 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
}
} else if (FLT_DOUBLE==src_type) {
if (FLT_FLOAT==dst_type) {
- hw_f = ((double*)saved)[j];
+ /* Watch out for that FPE on overflow! */
+ if (((double*)saved)[j] > FLT_MAX) {
+ hw_f = FLT_MAX;
+ } else if (((double*)saved)[j] < -FLT_MAX) {
+ hw_f = -FLT_MAX;
+ } else {
+ hw_f = ((double*)saved)[j];
+ }
hw = (unsigned char*)&hw_f;
} else if (FLT_DOUBLE==dst_type) {
hw_d = ((double*)saved)[j];
@@ -810,10 +818,24 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
}
} else {
if (FLT_FLOAT==dst_type) {
- hw_f = ((long double*)saved)[j];
+ /* Watch out for that FPE on overflow! */
+ if (((long double*)saved)[j] > FLT_MAX) {
+ hw_f = FLT_MAX;
+ } else if (((long double*)saved)[j] < -FLT_MAX) {
+ hw_f = -FLT_MAX;
+ } else {
+ hw_f = ((long double*)saved)[j];
+ }
hw = (unsigned char*)&hw_f;
} else if (FLT_DOUBLE==dst_type) {
- hw_d = ((long double*)saved)[j];
+ /* Watch out for that FPE! */
+ if (((long double*)saved)[j] > DBL_MAX) {
+ hw_d = DBL_MAX;
+ } else if (((long double*)saved)[j] < -DBL_MAX) {
+ hw_d = -DBL_MAX;
+ } else {
+ hw_d = ((long double*)saved)[j];
+ }
hw = (unsigned char*)&hw_d;
} else {
hw_ld = ((long double*)saved)[j];
@@ -993,7 +1015,7 @@ main(void)
nerrors += test_named ()<0 ? 1 : 0;
nerrors += test_conv_int ()<0 ? 1 : 0;
-#ifndef LATER
+#ifdef LATER
/*
* NOT READY FOR TESTING YET BECAUSE SOME SYSTEMS GENERATE A SIGFPE WHEN
* AN OVERFLOW OCCURS CASTING A DOUBLE TO A FLOAT.