From 203a7329154d957480aa83f8508276197e4738f4 Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Thu, 2 Jul 1998 20:16:22 -0500 Subject: [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. --- MANIFEST | 3 +++ config/commence.in | 2 +- src/H5Tconv.c | 16 ++++++++++++++-- test/dtypes.c | 32 +++++++++++++++++++++++++++----- 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 #include #include +#include /*for FLT_MAX and FLT_MIN */ #include /*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 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 +#include #include #include #include @@ -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. -- cgit v0.12