From a2a98a8135c3efee38b04b1d07e4602cdff1f1ef Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Tue, 14 Mar 2006 17:11:21 -0500 Subject: [svn-r12091] Purpose: Support for VAX floating-point types. Solution: Support VAX float and double types with new byte order. There're some details not yet included, 1. the alignment detection for VAX order in H5detect.c. 2. support for special values in library conversion functions. 3. the infinity for VAX in H5T_init_inf. 4. support for VAX types in printing hexadecimal format. Platforms tested: h5committest and fuss. --- src/H5Odtype.c | 55 ++++++++--- src/H5T.c | 40 ++++++++ src/H5Tconv.c | 122 +++++++++++++++++++---- src/H5Tpublic.h | 8 ++ src/H5detect.c | 60 ++++++++---- test/dt_arith.c | 267 +++++++++++++++++++++++++++++++++++++++----------- tools/h5dump/h5dump.c | 6 ++ vms/src/h5pubconf.h | 2 +- 8 files changed, 456 insertions(+), 104 deletions(-) diff --git a/src/H5Odtype.c b/src/H5Odtype.c index fc3f641..9aa2e85 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -61,15 +61,19 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{ H5O_dtype_debug /* debug the message */ }}; -/* This is the correct version to create all datatypes which don't contain +/* This is the version bit to create all datatypes which don't contain * array datatypes (atomic types, compound datatypes without array fields, - * vlen sequences of objects which aren't arrays, etc.) */ + * vlen sequences of objects which aren't arrays, etc. 0x01) */ #define H5O_DTYPE_VERSION_COMPAT 1 -/* This is the correct version to create all datatypes which contain H5T_ARRAY - * class objects (array definitely, potentially compound & vlen sequences also) */ +/* This is the version bit to create all datatypes which contain H5T_ARRAY + * class objects (array definitely, potentially compound & vlen sequences also. + * 0x02) */ #define H5O_DTYPE_VERSION_UPDATED 2 +/* This version bit represents H5T_ORDER_VAX (0x04) */ +#define H5O_DTYPE_VERSION_VAX 4 + /*------------------------------------------------------------------------- * Function: H5O_dtype_decode_helper @@ -84,12 +88,16 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{ * Modifications: * Robb Matzke, Thursday, May 20, 1999 * Added support for bitfields and opaque datatypes. + * + * Raymond Lu. Monday, Mar 13, 2006 + * Added support for VAX floating-point types. *------------------------------------------------------------------------- */ static herr_t H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) { - unsigned flags, version; + unsigned flags; + unsigned version = 0; unsigned i, j; size_t z; herr_t ret_value=SUCCEED; /* Return value */ @@ -103,7 +111,8 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) /* decode */ UINT32DECODE(*pp, flags); version = (flags>>4) & 0x0f; - if (version!=H5O_DTYPE_VERSION_COMPAT && version!=H5O_DTYPE_VERSION_UPDATED) + if (!(version & H5O_DTYPE_VERSION_COMPAT) && !(version & H5O_DTYPE_VERSION_UPDATED) && + !(version & H5O_DTYPE_VERSION_VAX)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "bad version number for datatype message"); dt->shared->type = (H5T_class_t)(flags & 0x0f); flags >>= 8; @@ -151,6 +160,15 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) * Floating-point types... */ dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + if(version & H5O_DTYPE_VERSION_VAX) { + /*Unsupported byte order*/ + if((flags & 0x40) && !(flags & 0x1)) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bad byte order for datatype message"); + + /*VAX order if both 1st and 6th bits are turned on*/ + if(flags & 0x40) + dt->shared->u.atomic.order = H5T_ORDER_VAX; + } dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO; @@ -210,7 +228,7 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) /* Older versions of the library allowed a field to have * intrinsic 'arrayness'. Newer versions of the library * use the separate array datatypes. */ - if(version==H5O_DTYPE_VERSION_COMPAT) { + if(version & H5O_DTYPE_VERSION_COMPAT) { /* Decode the number of dimensions */ ndims = *(*pp)++; assert(ndims <= 4); @@ -240,7 +258,7 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) } /* Go create the array datatype now, for older versions of the datatype message */ - if(version==H5O_DTYPE_VERSION_COMPAT) { + if(version & H5O_DTYPE_VERSION_COMPAT) { /* Check if this member is an array field */ if(ndims>0) { /* Set up the permutation vector for the array create */ @@ -450,16 +468,21 @@ done: * Modifications: * Robb Matzke, Thursday, May 20, 1999 * Added support for bitfields and opaque types. + * + * Raymond Lu. Monday, Mar 13, 2006 + * Added support for VAX floating-point types. *------------------------------------------------------------------------- */ static herr_t H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) { - htri_t has_array=FALSE; /* Whether a compound datatype has an array inside it */ + htri_t has_array=FALSE; /* Whether a compound datatype has an array inside it */ + htri_t has_vax=FALSE; /* Whether VAX floating number exists */ unsigned flags = 0; char *hdr = (char *)*pp; unsigned i, j; size_t n, z, aligned; + uint8_t version; /* version number */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_encode_helper); @@ -579,10 +602,14 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) */ switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: - break; /*nothing */ + break; /*nothing*/ case H5T_ORDER_BE: flags |= 0x01; break; + case H5T_ORDER_VAX: /*turn on 1st and 6th (reserved before adding VAX) bits*/ + flags |= 0x41; + has_vax = TRUE; + break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet"); } @@ -793,7 +820,13 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) } /* Encode the type's class, version and bit field */ - *hdr++ = ((unsigned)(dt->shared->type) & 0x0f) | (((dt->shared->type==H5T_COMPOUND && has_array) ? H5O_DTYPE_VERSION_UPDATED : H5O_DTYPE_VERSION_COMPAT )<<4); + version &= 0x00; + /* Four combination exist for version number, compact, compact+vax, updated, and updated+vax. */ + version = (dt->shared->type==H5T_COMPOUND && has_array) ? H5O_DTYPE_VERSION_UPDATED : H5O_DTYPE_VERSION_COMPAT; + if(has_vax) + version |= H5O_DTYPE_VERSION_VAX; + + *hdr++ = ((unsigned)(dt->shared->type) & 0x0f) | (version<<4); *hdr++ = (flags >> 0) & 0xff; *hdr++ = (flags >> 8) & 0xff; *hdr++ = (flags >> 16) & 0xff; diff --git a/src/H5T.c b/src/H5T.c index a939d69..d3c745a 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -55,6 +55,9 @@ hid_t H5T_IEEE_F32LE_g = FAIL; hid_t H5T_IEEE_F64BE_g = FAIL; hid_t H5T_IEEE_F64LE_g = FAIL; +hid_t H5T_VAX_F32_g = FAIL; +hid_t H5T_VAX_F64_g = FAIL; + hid_t H5T_STD_I8BE_g = FAIL; hid_t H5T_STD_I8LE_g = FAIL; hid_t H5T_STD_I16BE_g = FAIL; @@ -347,6 +350,32 @@ static H5T_t *H5T_decode(const unsigned char *buf); H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_BE) \ } +/* Define the code templates for VAX float for the "GUTS" in the H5T_INIT_TYPE macro */ +#define H5T_INIT_TYPE_FLOATVAX_CORE { \ + H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_VAX) \ + dt->shared->u.atomic.u.f.sign = 31; \ + dt->shared->u.atomic.u.f.epos = 23; \ + dt->shared->u.atomic.u.f.esize = 8; \ + dt->shared->u.atomic.u.f.ebias = 0x81; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 23; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ +} + +/* Define the code templates for VAX double for the "GUTS" in the H5T_INIT_TYPE macro */ +#define H5T_INIT_TYPE_DOUBLEVAX_CORE { \ + H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_VAX) \ + dt->shared->u.atomic.u.f.sign = 63; \ + dt->shared->u.atomic.u.f.epos = 52; \ + dt->shared->u.atomic.u.f.esize = 11; \ + dt->shared->u.atomic.u.f.ebias = 0x0401; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 52; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ +} + /* Define the code templates for standard signed integers for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_SINT_COMMON(ENDIANNESS) { \ H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ @@ -808,6 +837,17 @@ H5T_init_interface(void) H5T_INIT_TYPE(DOUBLEBE,H5T_IEEE_F64BE_g,COPY,native_double,SET,8) /*------------------------------------------------------------ + * VAX Types + *------------------------------------------------------------ + */ + + /* VAX 4-byte float */ + H5T_INIT_TYPE(FLOATVAX,H5T_VAX_F32_g,COPY,native_double,SET,4) + + /* VAX 8-byte double */ + H5T_INIT_TYPE(DOUBLEVAX,H5T_VAX_F64_g,COPY,native_double,SET,8) + + /*------------------------------------------------------------ * Other "standard" types *------------------------------------------------------------ */ diff --git a/src/H5Tconv.c b/src/H5Tconv.c index be72c81..436a8e7 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -3540,6 +3540,9 @@ done: * Oops, forgot to increment the exponent when rounding the * significand resulted in a carry. Thanks to Guillaume Colin * de Verdiere for finding this one! + * + * Raymond Lu, 2006-03-13 + * Added support for VAX floating-point types. *------------------------------------------------------------------------- */ herr_t @@ -3555,11 +3558,13 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, int direction; /*forward or backward traversal */ size_t elmtno; /*element number */ size_t half_size; /*half the type size */ + size_t tsize; /*type size for swapping bytes */ size_t olap; /*num overlapping elements */ ssize_t bitno = 0; /*bit number */ uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ uint8_t *src_rev=NULL; /*order-reversed source buffer */ uint8_t dbuf[64]; /*temp destination buffer */ + uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ /* Conversion-related variables */ hssize_t expo; /*exponent */ @@ -3587,9 +3592,9 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; - if (H5T_ORDER_LE!=src.order && H5T_ORDER_BE!=src.order) + if (H5T_ORDER_LE!=src.order && H5T_ORDER_BE!=src.order && H5T_ORDER_VAX!=src.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (H5T_ORDER_LE!=dst.order && H5T_ORDER_BE!=dst.order) + if (H5T_ORDER_LE!=dst.order && H5T_ORDER_BE!=dst.order && H5T_ORDER_VAX!=dst.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); if (dst_p->shared->size>sizeof(dbuf)) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); @@ -3681,9 +3686,23 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (H5T_ORDER_BE==src.order) { half_size = src_p->shared->size/2; for (i=0; ishared->size-(i+1)]; + tmp1 = s[src_p->shared->size-(i+1)]; s[src_p->shared->size-(i+1)] = s[i]; - s[i] = tmp; + s[i] = tmp1; + } + } else if (H5T_ORDER_VAX==src.order) { + tsize = src_p->shared->size; + assert(0 == tsize % 2); + + for (i = 0; i < tsize; i += 4) { + tmp1 = s[i]; + tmp2 = s[i+1]; + + s[i] = s[(tsize-2)-i]; + s[i+1] = s[(tsize-1)-i]; + + s[(tsize-2)-i] = tmp1; + s[(tsize-1)-i] = tmp2; } } @@ -3771,6 +3790,9 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") goto padding; +#ifdef VMS + } /*Temporary solution to handle VAX special values*/ +#else /*VMS*/ } else if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE)<0) { /* NaN */ @@ -3796,6 +3818,7 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, goto padding; } +#endif /*VMS*/ /* * Get the exponent as an unsigned quantity from the section of @@ -4024,6 +4047,20 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, d[dst_p->shared->size-(i+1)] = d[i]; d[i] = tmp; } + } else if (H5T_ORDER_VAX==dst.order && reverse) { + tsize = dst_p->shared->size; + assert(0 == tsize % 2); + + for (i = 0; i < tsize; i += 4) { + tmp1 = d[i]; + tmp2 = d[i+1]; + + d[i] = d[(tsize-2)-i]; + d[i+1] = d[(tsize-1)-i]; + + d[(tsize-2)-i] = tmp1; + d[(tsize-1)-i] = tmp2; + } } /* @@ -9434,6 +9471,9 @@ done: * There is a new design for exception handling like overflow, * which is passed in as a transfer property. * + * Raymond Lu + * Monday, March 13, 2006 + * Added support for VAX floating-point types. *------------------------------------------------------------------------- */ herr_t @@ -9449,10 +9489,12 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, int direction; /*forward or backward traversal */ size_t elmtno; /*element number */ size_t half_size; /*half the type size */ + size_t tsize; /*type size for swapping bytes */ size_t olap; /*num overlapping elements */ uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ uint8_t *src_rev=NULL; /*order-reversed source buffer */ uint8_t dbuf[64]; /*temp destination buffer */ + uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ /* Conversion-related variables */ hssize_t expo; /*source exponent */ @@ -9478,7 +9520,7 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; - if (H5T_ORDER_LE!=src.order && H5T_ORDER_BE!=src.order) + if (H5T_ORDER_LE!=src.order && H5T_ORDER_BE!=src.order && H5T_ORDER_VAX!=src.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); if (dst_p->shared->size>sizeof(dbuf)) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); @@ -9575,9 +9617,23 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (H5T_ORDER_BE==src.order) { half_size = src_p->shared->size/2; for (i=0; ishared->size-(i+1)]; + tmp1 = s[src_p->shared->size-(i+1)]; s[src_p->shared->size-(i+1)] = s[i]; - s[i] = tmp; + s[i] = tmp1; + } + } else if (H5T_ORDER_VAX==src.order) { + tsize = src_p->shared->size; + assert(0 == tsize % 2); + + for (i = 0; i < tsize; i += 4) { + tmp1 = s[i]; + tmp2 = s[i+1]; + + s[i] = s[(tsize-2)-i]; + s[i+1] = s[(tsize-1)-i]; + + s[(tsize-2)-i] = tmp1; + s[(tsize-1)-i] = tmp2; } } @@ -9945,9 +10001,9 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (H5T_ORDER_BE==dst.order && reverse) { half_size = dst_p->shared->size/2; for (i=0; ishared->size-(i+1)]; + tmp1 = d[dst_p->shared->size-(i+1)]; d[dst_p->shared->size-(i+1)] = d[i]; - d[i] = tmp; + d[i] = tmp1; } } @@ -10002,7 +10058,10 @@ done: * Wednesday, April 21, 2004 * There is a new design for exception handling like overflow, * which is passed in as a transfer property. - * + * + * Raymond Lu + * Monday, March 13, 2006 + * Added support for VAX floating-point types. *------------------------------------------------------------------------- */ herr_t @@ -10018,11 +10077,13 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, int direction; /*forward or backward traversal */ size_t elmtno; /*element number */ size_t half_size; /*half the type size */ + size_t tsize; /*type size for swapping bytes */ size_t olap; /*num overlapping elements */ uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ uint8_t *src_rev=NULL; /*order-reversed source buffer */ uint8_t dbuf[64]; /*temp destination buffer */ - + uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ + /* Conversion-related variables */ hsize_t expo; /*destination exponent */ hsize_t expo_max; /*maximal possible exponent value */ @@ -10049,7 +10110,7 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; - if (H5T_ORDER_LE!=dst.order && H5T_ORDER_BE!=dst.order) + if (H5T_ORDER_LE!=dst.order && H5T_ORDER_BE!=dst.order && H5T_ORDER_VAX!=dst.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); if (dst_p->shared->size>sizeof(dbuf)) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); @@ -10152,9 +10213,9 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (H5T_ORDER_BE==src.order) { half_size = src_p->shared->size/2; for (i=0; ishared->size-(i+1)]; + tmp1 = s[src_p->shared->size-(i+1)]; s[src_p->shared->size-(i+1)] = s[i]; - s[i] = tmp; + s[i] = tmp1; } } @@ -10360,6 +10421,20 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, d[dst_p->shared->size-(i+1)] = d[i]; d[i] = tmp; } + } else if (H5T_ORDER_VAX==dst.order && reverse) { + tsize = dst_p->shared->size; + assert(0 == tsize % 2); + + for (i = 0; i < tsize; i += 4) { + tmp1 = d[i]; + tmp2 = d[i+1]; + + d[i] = d[(tsize-2)-i]; + d[i+1] = d[(tsize-1)-i]; + + d[(tsize-2)-i] = tmp1; + d[(tsize-1)-i] = tmp2; + } } /* @@ -10398,8 +10473,8 @@ done: * Function: H5T_reverse_order * * Purpose: Internal assisting function to reverse the order of - * a sequence of byte when it's big endian. The byte sequence - * simulates the endian order. + * a sequence of byte when it's big endian or VAX order. + * The byte sequence simulates the endian order. * * Return: Success: A pointer to the reversed byte sequence * @@ -10410,6 +10485,9 @@ done: * * Modifications: * + * Raymond Lu + * March 13, 2006 + * Add support for VAX floating-point types. *------------------------------------------------------------------------- */ static herr_t @@ -10422,12 +10500,18 @@ H5T_reverse_order(uint8_t *rev, uint8_t *s, size_t size, H5T_order_t order) assert(s); assert(size); - if (H5T_ORDER_BE == order) + if (H5T_ORDER_VAX == order) { + for (i = 0; i < size; i += 2) { + rev[i] = s[(size - 2) - i]; + rev[i + 1] = s[(size - 1) - i]; + } + } else if (H5T_ORDER_BE == order) { for (i=0; i-1) { - byte_order=d[i].perm[j]; - break; + if(d[i].is_vax) /* the type is a VAX floating number */ + byte_order=-1; + else { + for(j=0; j<32; j++) { + /*Find the 1st containing valid data*/ + if(d[i].perm[j]>-1) { + byte_order=d[i].perm[j]; + break; + } } } @@ -557,18 +567,28 @@ H5TN_init_interface(void)\n\ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,\"memory allocation failed\")\n\ dt->shared->state = H5T_STATE_IMMUTABLE;\n\ dt->shared->type = H5T_%s;\n\ - dt->shared->size = %d;\n\ - dt->shared->u.atomic.order = H5T_ORDER_%s;\n\ + dt->shared->size = %d;\n", + d[i].msize ? "FLOAT" : "INTEGER",/*class */ + d[i].size); /*size */ + + if(byte_order==-1) + printf("\ + dt->shared->u.atomic.order = H5T_ORDER_VAX;\n"); + else if(byte_order==0) + printf("\ + dt->shared->u.atomic.order = H5T_ORDER_LE;\n"); + else + printf("\ + dt->shared->u.atomic.order = H5T_ORDER_BE;\n"); + + printf("\ dt->shared->u.atomic.offset = %d;\n\ dt->shared->u.atomic.prec = %d;\n\ dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\ dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;\n", - d[i].msize ? "FLOAT" : "INTEGER",/*class */ - d[i].size, /*size */ - byte_order ? "BE" : "LE", /*byte order */ d[i].offset, /*offset */ d[i].precision); /*precision */ - assert((d[i].perm[0]>0)==(byte_order>0)); /* Double-check that byte-order doesn't change */ + /*assert((d[i].perm[0]>0)==(byte_order>0));*/ /* Double-check that byte-order doesn't change */ if (0 == d[i].msize) { /* The part unique to fixed point types */ @@ -613,10 +633,16 @@ H5TN_init_interface(void)\n\ } } - printf("\n\ + /* Consider VAX a little-endian machine */ + if(byte_order==0 || byte_order==-1) { + printf("\n\ /* Set the native order for this machine */\n\ - H5T_native_order_g = H5T_ORDER_%s;\n", - byte_order ? "BE" : "LE"); /*byte order */ + H5T_native_order_g = H5T_ORDER_%s;\n", "LE"); + } else { + printf("\n\ + /* Set the native order for this machine */\n\ + H5T_native_order_g = H5T_ORDER_%s;\n", "BE"); + } /* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */ printf("\n /* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */\n"); diff --git a/test/dt_arith.c b/test/dt_arith.c index 86aca82..9583b47 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -61,7 +61,7 @@ const char *FILENAME[] = { * endian. If local variable `endian' is H5T_ORDER_BE then the result will * be I, otherwise the result will be Z-(I+1). */ -#define ENDIAN(Z,I) (H5T_ORDER_BE==endian?(I):(Z)-((I)+1)) +#define ENDIAN(Z,I,E) (H5T_ORDER_BE==E?(I):(Z)-((I)+1)) typedef enum dtype_t { INT_SCHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, @@ -86,6 +86,11 @@ static int skip_overflow_tests_g = 0; #define HANDLE_SIGFPE #endif +/* OpenVMS doesn't have this feature. Make sure to disable it*/ +#ifdef VMS +#undef HANDLE_SIGFPE +#endif + /* * Decide what values of floating-point number we want to test. They are * 1 - normalized; 2 - denormalized; 3 - special. @@ -161,8 +166,8 @@ static int without_hardware_g = 0; */ #define CHANGE_ORDER(EBUF, EORDER, ESIZE) \ { \ + unsigned int m; \ if (H5T_ORDER_BE==EORDER) { \ - unsigned int m; \ unsigned char mediator; \ size_t half_size = ESIZE/2; \ for (m=0; m=max_fails) { @@ -1549,12 +1566,12 @@ test_derived_integer(void) printf(" src = "); for (j=0; j=max_fails) { @@ -2276,10 +2293,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) * the `bittests' program. */ for (k=0; k FLT_MAX; +#ifdef VMS + maximal = HDfabs(*((double*)aligned)) == FLT_MAX; +#endif } else if (FLT_DOUBLE==dst_type) { hw_d = *((double*)aligned); hw = (unsigned char*)&hw_d; @@ -2997,11 +3083,17 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) hw = (unsigned char*)&hw_f; underflow = HDfabsl(*((long double*)aligned)) < FLT_MIN; overflow = HDfabsl(*((long double*)aligned)) > FLT_MAX; +#ifdef VMS + maximal = HDfabs(*((long double*)aligned)) == FLT_MAX; +#endif } else if (FLT_DOUBLE==dst_type) { hw_d = *((long double*)aligned); hw = (unsigned char*)&hw_d; underflow = HDfabsl(*((long double*)aligned)) < DBL_MIN; overflow = HDfabsl(*((long double*)aligned)) > DBL_MAX; +#ifdef VMS + maximal = HDfabs(*((long double*)aligned)) == DBL_MAX; +#endif } else { hw_ld = *((long double*)aligned); hw = (unsigned char*)&hw_ld; @@ -3019,7 +3111,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) * 0s before compare the values. */ #if H5_SIZEOF_LONG_DOUBLE !=0 - if(endian==H5T_ORDER_LE && dst_type==FLT_LDOUBLE) { + if(sendian==H5T_ORDER_LE && dst_type==FLT_LDOUBLE) { unsigned int q; for(q=dst_nbits/8; q