From 04b7826ed1b59bc7337ba96f99cc8b56d70a945d Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Tue, 15 Mar 2005 11:31:48 -0500 Subject: [svn-r10218] Purpose: Bug fix Description: This commit is actually revision 1.155, which is the 3rd step of changing conversion test. It's for conversion from floating-point to integer. In this step, the source buffer is filled in with normalized and denormalized floating-point values. For the normalized values, it starts from FLT(DBL, or LDBL)_MIN, multiplied by 10(10000 for double, 100000000 for long double) for the next value, until reaches to FLT_MAX. For denormalized values, the exponent part is always 0. Mantissa part starts with 000...001, 000...011, 000...111, until reaches to 111...111. The same is with negative values. There're also fixes in config/hpux11.00 for kelgia where default macro table size wasn't big enough to handle the big macro in dtypes.c. Platforms tested: h5committest and kelgia. --- config/hpux10.20 | 2 +- config/hpux11.00 | 2 +- config/hpux9.03 | 2 +- test/dtypes.c | 191 +++++++++++++++++++++++++++++++++++++++++-------------- 4 files changed, 146 insertions(+), 51 deletions(-) diff --git a/config/hpux10.20 b/config/hpux10.20 index fdd4dd1..cdd9b47 100644 --- a/config/hpux10.20 +++ b/config/hpux10.20 @@ -25,7 +25,7 @@ case "X-$CC" in ;; *) - CFLAGS="$CFLAGS -Ae" + CFLAGS="$CFLAGS -Ae -Wp,-H65536" #increase the size of macro definition table. For test/dtypes.c DEBUG_CFLAGS=-g DEBUG_CPPFLAGS="-Ae" PROD_CFLAGS=-O diff --git a/config/hpux11.00 b/config/hpux11.00 index 7cb01d4..30f0d52 100644 --- a/config/hpux11.00 +++ b/config/hpux11.00 @@ -25,7 +25,7 @@ case "X-$CC" in ;; *) - CFLAGS="$CFLAGS -Ae" + CFLAGS="$CFLAGS -Ae -Wp,-H65536" #increase the size of macro definition table. For test/dtypes.c DEBUG_CFLAGS=-g DEBUG_CPPFLAGS="-Ae" PROD_CFLAGS=-O diff --git a/config/hpux9.03 b/config/hpux9.03 index 6603aab..c3da65f 100644 --- a/config/hpux9.03 +++ b/config/hpux9.03 @@ -25,7 +25,7 @@ case "X-$CC" in ;; *) - CFLAGS="$CFLAGS -Ae" + CFLAGS="$CFLAGS -Ae -Wp,-H65536" #increase the size of macro definition table. For test/dtypes.c DEBUG_CFLAGS=-g DEBUG_CPPFLAGS= PROD_CFLAGS= diff --git a/test/dtypes.c b/test/dtypes.c index 77a0446..170daf5 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -118,7 +118,7 @@ static int num_opaque_conversions_g = 0; #define aligned_malloc(Z) ((void*)((char*)HDmalloc(ALIGNMENT+Z)+ALIGNMENT)) #define aligned_free(M) HDfree((char*)(M)-ALIGNMENT) -/* Initialize source buffer of integer for integer->integer conversion test. +/* Initialize source buffer of integer for integer->integer and integer->floating-point conversion test. * This algorithm is mainly to avoid any casting and comparison between source and destination types * for compiler, because we're testing conversions. */ #define INIT_INTEGER(TYPE, SRC_MAX, SRC_MIN, SRC_SIZE, DST_SIZE, SRC_PREC, BUF, SAVED, NELMTS) \ @@ -169,6 +169,129 @@ static int num_opaque_conversions_g = 0; } \ } +/* Change a buffer's byte order from big endian to little endian. It's mainly for library's + * bit operations which handle only little endian order. + */ +#define CHANGE_ORDER(EBUF, EORDER, ESIZE) \ +{ \ + if (H5T_ORDER_BE==EORDER) { \ + int m; \ + unsigned char mediator; \ + size_t half_size = ESIZE/2; \ + for (m=0; m=100 && SRC_MAX_10_EXP<400) { /*for double*/ \ + factor = 2; \ + multiply = 10000; \ + } else { /*for long double*/ \ + factor = 3; \ + multiply = 100000000; \ + } \ + \ + /*The number of values if multiplied by 10 for each step.*/ \ + num_norm = (SRC_MAX_10_EXP - SRC_MIN_10_EXP); \ + /*Reduce the number of values by 2^factor. MULTIPLY=10^(2^factor). Using this algorithm \ + *instead of arithmatic operation to avoid any conversion*/ \ + num_norm >>= factor; \ + \ + /*Total number of values*/ \ + NELMTS = 2 * /*both positive and negative*/ \ + (num_norm + /*number of normalized values*/ \ + 1 + /*maximal normalized value*/ \ + SRC_MANT_DIG - 1); /*number of denormalized values*/ \ + \ + /* Allocate buffers */ \ + BUF = (unsigned char*)aligned_malloc(NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ + SAVED = (unsigned char*)aligned_malloc(NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ + tmp1 = (unsigned char*)malloc(SRC_SIZE); \ + tmp2 = (unsigned char*)malloc(SRC_SIZE); \ + \ + buf_p = BUF; \ + saved_p = SAVED; \ + \ + /*Normalized values*/ \ + value1 = SRC_MIN; \ + value2 = -SRC_MIN; \ + for(n=0; n-SRC_MAX) { /*negative*/ \ + memcpy(buf_p, &value2, SRC_SIZE); \ + memcpy(saved_p, &value2, SRC_SIZE); \ + value2 *= multiply; \ + buf_p += SRC_SIZE; \ + saved_p += SRC_SIZE; \ + } \ + } \ + \ + value1 = SRC_MAX; /*maximal value*/ \ + memcpy(buf_p, &value1, SRC_SIZE); \ + memcpy(saved_p, &value1, SRC_SIZE); \ + buf_p += SRC_SIZE; \ + saved_p += SRC_SIZE; \ + \ + value2 = -SRC_MAX; /*negative value*/ \ + memcpy(buf_p, &value2, SRC_SIZE); \ + memcpy(saved_p, &value2, SRC_SIZE); \ + buf_p += SRC_SIZE; \ + saved_p += SRC_SIZE; \ + \ + /*Denormalized values. Exponent is 0. Let mantissa starts from 00000001, 00000011, \ + *00000111,..., until 11111111.*/ \ + memset(tmp1, 0, SRC_SIZE); \ + memset(tmp2, 0, SRC_SIZE); \ + H5T_bit_set (tmp2, SRC_PREC-1, 1, TRUE); /*the negative value*/ \ + for(n=0; n