diff options
-rw-r--r-- | src/H5Odtype.c | 55 | ||||
-rw-r--r-- | src/H5T.c | 40 | ||||
-rw-r--r-- | src/H5Tconv.c | 122 | ||||
-rw-r--r-- | src/H5Tpublic.h | 8 | ||||
-rw-r--r-- | src/H5detect.c | 60 | ||||
-rw-r--r-- | test/dt_arith.c | 267 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 6 | ||||
-rw-r--r-- | 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; @@ -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; i<half_size; i++) { - uint8_t tmp = s[src_p->shared->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; i<half_size; i++) { - uint8_t tmp = s[src_p->shared->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; i<half_size; i++) { - uint8_t tmp = d[dst_p->shared->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; i<half_size; i++) { - uint8_t tmp = s[src_p->shared->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<size; i++) rev[size-(i+1)] = s[i]; - else + } else { for (i=0; i<size; i++) rev[i] = s[i]; - + } + FUNC_LEAVE_NOAPI(SUCCEED); } diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index d8ce90d..7e9ccdf 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -235,6 +235,14 @@ H5_DLLVAR hid_t H5T_IEEE_F64BE_g; H5_DLLVAR hid_t H5T_IEEE_F64LE_g; /* + * The VAX floating point types + */ +#define H5T_VAX_F32 (H5OPEN H5T_VAX_F32_g) +#define H5T_VAX_F64 (H5OPEN H5T_VAX_F64_g) +H5_DLLVAR hid_t H5T_VAX_F32_g; +H5_DLLVAR hid_t H5T_VAX_F64_g; + +/* * These are "standard" types. For instance, signed (2's complement) and * unsigned integers of various sizes and byte orders. */ diff --git a/src/H5detect.c b/src/H5detect.c index 4b15c36..ba1bd16 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -66,7 +66,8 @@ typedef struct detected_t { int size; /*total byte size */ int precision; /*meaningful bits */ int offset; /*bit offset to meaningful bits */ - int perm[32]; /*byte order */ + int perm[32]; /*for detection of byte order */ + int is_vax; /*for vax (float & double) only */ int sign; /*location of sign bit */ int mpos, msize, imp;/*information about mantissa */ int epos, esize; /*information about exponent */ @@ -283,6 +284,9 @@ precision (detected_t *d) } \ } \ fix_order (sizeof(TYPE), _first, _last, INFO.perm, (const char**)&_mesg); \ + \ + if(!strcmp(_mesg, "VAX")) \ + INFO.is_vax = TRUE; \ \ /* Implicit mantissa bit */ \ _v1 = 0.5; \ @@ -370,13 +374,14 @@ precision (detected_t *d) /* locations with pointers that are supposed to be */ \ /* word aligned. -QAK */ \ memset(_buf, 0xff, sizeof(TYPE)+align_g[NELMTS(align_g)-1]); \ + /*How to handle VAX types?*/ \ if(INFO.perm[0]) /* Big-Endian */ \ memcpy(_buf+align_g[_ano]+(INFO.size-((INFO.offset+INFO.precision)/8)),((char *)&_val)+(INFO.size-((INFO.offset+INFO.precision)/8)),(size_t)(INFO.precision/8)); \ else /* Little-Endian */ \ memcpy(_buf+align_g[_ano]+(INFO.offset/8),((char *)&_val)+(INFO.offset/8),(size_t)(INFO.precision/8)); \ _val2 = *((TYPE*)(_buf+align_g[_ano])); \ if(_val!=_val2) \ - longjmp(jbuf_g, 1); \ + longjmp(jbuf_g, 1); \ /* End Cray Check */ \ (INFO.align)=align_g[_ano]; \ } else { \ @@ -486,6 +491,7 @@ sigbus_handler(int UNUSED signo) { signal(SIGBUS, sigbus_handler); longjmp(jbuf_g, 1); + siglongjmp(jbuf_g, 1); } @@ -507,7 +513,7 @@ sigbus_handler(int UNUSED signo) static void print_results(int nd, detected_t *d, int na, malign_t *misc_align) { - int byte_order=0; + int byte_order=0; /*byte order of data types*/ int i, j; /* Include files */ @@ -538,11 +544,15 @@ H5TN_init_interface(void)\n\ * are always zero. This happens on the Cray for `short' where * sizeof(short) is 8, but only the low-order 4 bytes are ever used. */ - 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; + 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<half_size; m++) { \ @@ -170,6 +175,18 @@ static int without_hardware_g = 0; EBUF[ESIZE-(m+1)] = EBUF[m]; \ EBUF[m] = mediator; \ } \ + } else if (H5T_ORDER_VAX==EORDER) { \ + unsigned char mediator1, mediator2; \ + for (m = 0; m < ESIZE; m += 4) { \ + mediator1 = EBUF[m]; \ + mediator2 = EBUF[m+1]; \ + \ + EBUF[m] = EBUF[(ESIZE-2)-m]; \ + EBUF[m+1] = EBUF[(ESIZE-1)-m]; \ + \ + EBUF[(ESIZE-2)-m] = mediator1; \ + EBUF[(ESIZE-1)-m] = mediator2; \ + } \ } \ } @@ -372,7 +389,7 @@ static int without_hardware_g = 0; void some_dummy_func(float x); static hbool_t overflows(unsigned char *origin_bits, hid_t src_id, size_t dst_num_bits); static int my_isnan(dtype_t type, void *val); -static int my_isinf(int endian, unsigned char *val, size_t size, +static int my_isinf(dtype_t type, int endian, unsigned char *val, size_t size, size_t mpos, size_t msize, size_t epos, size_t esize); /*------------------------------------------------------------------------- @@ -763,14 +780,14 @@ static int test_particular_fp_integer(void) printf(" test double to signed char:\n"); printf(" src = "); for (j=0; j<src_size1; j++) - printf(" %02x", saved_buf1[ENDIAN(src_size1, j)]); + printf(" %02x", saved_buf1[ENDIAN(src_size1, j, endian)]); HDmemcpy(&x, saved_buf1, src_size1); printf(" %29.20e\n", x); printf(" dst = "); for (j=0; j<dst_size1; j++) - printf(" %02x", buf1[ENDIAN(dst_size1, j)]); + printf(" %02x", buf1[ENDIAN(dst_size1, j, endian)]); HDmemcpy(&y, buf1, dst_size1); printf(" %29d\n", y); @@ -807,14 +824,14 @@ static int test_particular_fp_integer(void) printf(" test float to int:\n"); printf(" src = "); for (j=0; j<src_size2; j++) - printf(" %02x", saved_buf2[ENDIAN(src_size2, j)]); + printf(" %02x", saved_buf2[ENDIAN(src_size2, j, endian)]); HDmemcpy(&x, saved_buf2, src_size2); printf(" %29.20e\n", x); printf(" dst = "); for (j=0; j<dst_size2; j++) - printf(" %02x", buf2[ENDIAN(dst_size2, j)]); + printf(" %02x", buf2[ENDIAN(dst_size2, j, endian)]); HDmemcpy(&y, buf2, dst_size2); printf(" %29d\n", y); @@ -1067,14 +1084,14 @@ test_derived_flt(void) printf(" src = "); for (j=0; j<src_size; j++) - printf(" %02x", saved_buf[i*src_size+ENDIAN(src_size, j)]); + printf(" %02x", saved_buf[i*src_size+ENDIAN(src_size, j, endian)]); HDmemcpy(aligned, saved_buf+i*sizeof(int), sizeof(int)); printf(" %29d\n", *aligned); printf(" dst = "); for (j=0; j<src_size; j++) - printf(" %02x", buf[i*src_size+ENDIAN(src_size, j)]); + printf(" %02x", buf[i*src_size+ENDIAN(src_size, j, endian)]); HDmemcpy(aligned, buf+i*sizeof(int), sizeof(int)); printf(" %29d\n", *aligned); @@ -1238,12 +1255,12 @@ test_derived_flt(void) printf(" src = "); for (j=0; j<src_size; j++) - printf(" %02x", saved_buf[i*src_size+ENDIAN(src_size, j)]); + printf(" %02x", saved_buf[i*src_size+ENDIAN(src_size, j, endian)]); printf("\n"); printf(" dst = "); for (j=0; j<src_size; j++) - printf(" %02x", buf[i*src_size+ENDIAN(src_size, j)]); + printf(" %02x", buf[i*src_size+ENDIAN(src_size, j, endian)]); printf("\n"); if (fails_this_test>=max_fails) { @@ -1549,12 +1566,12 @@ test_derived_integer(void) printf(" src = "); for (j=0; j<src_size; j++) - printf(" %02x", saved_buf[i*src_size+ENDIAN(src_size, j)]); + printf(" %02x", saved_buf[i*src_size+ENDIAN(src_size, j, endian)]); printf("\n"); printf(" dst = "); for (j=0; j<src_size; j++) - printf(" %02x", buf[i*src_size+ENDIAN(src_size, j)]); + printf(" %02x", buf[i*src_size+ENDIAN(src_size, j, endian)]); printf("\n"); if (fails_this_test>=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<src_size; k++) - src_bits[src_size-(k+1)] = saved[j*src_size+ENDIAN(src_size, k)]; + src_bits[src_size-(k+1)] = saved[j*src_size+ENDIAN(src_size, k, endian)]; for (k=0; k<dst_size; k++) - dst_bits[dst_size-(k+1)] = buf[j*dst_size+ENDIAN(dst_size, k)]; + dst_bits[dst_size-(k+1)] = buf[j*dst_size+ENDIAN(dst_size, k, endian)]; /* * Hardware usually doesn't handle overflows too gracefully. The @@ -2385,7 +2402,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) printf(" src = "); for (k=0; k<src_size; k++) - printf(" %02x", saved[j*src_size+ENDIAN(src_size, k)]); + printf(" %02x", saved[j*src_size+ENDIAN(src_size, k, endian)]); printf("%*s", (int)(3*MAX(0, (ssize_t)dst_size-(ssize_t)src_size)), ""); switch (src_type) { case INT_SCHAR: @@ -2434,7 +2451,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) printf(" dst = "); for (k=0; k<dst_size; k++) - printf(" %02x", buf[j*dst_size+ENDIAN(dst_size, k)]); + printf(" %02x", buf[j*dst_size+ENDIAN(dst_size, k, endian)]); printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)), ""); switch (dst_type) { case INT_SCHAR: @@ -2483,7 +2500,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) printf(" ans = "); for (k=0; k<dst_size; k++) - printf(" %02x", hw[ENDIAN(dst_size, k)]); + printf(" %02x", hw[ENDIAN(dst_size, k, endian)]); printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)), ""); switch (dst_type) { case INT_SCHAR: @@ -2615,7 +2632,7 @@ test_conv_int_2(void) static int my_isnan(dtype_t type, void *val) { - int retval; + int retval = 0; char s[256]; if (FLT_FLOAT==type) { @@ -2662,6 +2679,24 @@ my_isnan(dtype_t type, void *val) retval = 1; } +#ifdef VMS + /* For "float" and "double" on OpenVMS/Alpha, NaN is + * actually a valid value of maximal value.*/ + if(!retval) { + if (FLT_FLOAT==type) { + float x; + HDmemcpy(&x, val, sizeof(float)); + retval = (x==FLT_MAX || x==-FLT_MAX); + } else if (FLT_DOUBLE==type) { + double x; + HDmemcpy(&x, val, sizeof(double)); + retval = (x==DBL_MAX || x==-DBL_MAX); + } else { + return 0; + } + } +#endif /*VMS*/ + return retval; } @@ -2681,7 +2716,7 @@ my_isnan(dtype_t type, void *val) *------------------------------------------------------------------------- */ static int -my_isinf(int endian, unsigned char *val, size_t size, +my_isinf(dtype_t type, int endian, unsigned char *val, size_t size, size_t mpos, size_t msize, size_t epos, size_t esize) { unsigned char *bits; @@ -2690,8 +2725,24 @@ my_isinf(int endian, unsigned char *val, size_t size, ssize_t ret1=0, ret2=0; bits = (unsigned char*)calloc(1, size); + +#ifdef VMS + if(H5T_ORDER_VAX==endian) { + for (i = 0; i < size; i += 4) { + bits[i] = val[(size-2)-i]; + bits[i+1] = val[(size-1)-i]; + + bits[(size-2)-i] = val[i]; + bits[(size-1)-i] = val[i+1]; + } + } else { + for (i=0; i<size; i++) + bits[size-(i+1)] = *(val + ENDIAN(size,i,endian)); + } +#else /*VMS*/ for (i=0; i<size; i++) - bits[size-(i+1)] = *(val + ENDIAN(size, i)); + bits[size-(i+1)] = *(val + ENDIAN(size, i, endian)); +#endif /*VMS*/ if((ret1=H5T_bit_find(bits, mpos, msize, H5T_BIT_LSB, 1))<0 && (ret2=H5T_bit_find(bits, epos, esize, H5T_BIT_LSB, 0))<0) @@ -2749,9 +2800,11 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) unsigned char *hw=NULL; /*ptr to hardware-conv'd*/ int underflow; /*underflow occurred */ int overflow; /*overflow occurred */ + int maximal; /*maximal value occurred, for VMS only. */ int uflow=0; /*underflow debug counters*/ size_t j, k; /*counters */ - int endian; /*machine endianess */ + int sendian; /* source type endianess */ + int dendian; /* Destination type endianess */ 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 */ @@ -2794,7 +2847,9 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) * The remainder of this function is executed only by the child if * HANDLE_SIGFPE is defined. */ +#ifndef VMS HDsignal(SIGFPE,fpe_handler); +#endif /* What are the names of the source and destination types */ if (H5Tequal(src, H5T_NATIVE_FLOAT)) { @@ -2877,7 +2932,8 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) dst_ebias=H5Tget_ebias(dst); H5Tget_fields(src,NULL,&src_epos,&src_esize,NULL,NULL); H5Tget_fields(dst,NULL,&dst_epos,&dst_esize,&dst_mpos,&dst_msize); - endian = H5Tget_order(H5T_NATIVE_FLOAT); + sendian = H5Tget_order(src); + dendian = H5Tget_order(dst); /* Allocate buffers */ aligned = HDcalloc(1, MAX(sizeof(long double), sizeof(double))); @@ -2891,32 +2947,59 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) switch (run_test) { case TEST_NOOP: case TEST_NORMAL: +#ifdef VMS if(src_type == FLT_FLOAT) { INIT_FP_NORM(float, FLT_MAX, FLT_MIN, FLT_MAX_10_EXP, FLT_MIN_10_EXP, src_size, dst_size, buf, saved, nelmts); - + } else if(src_type == FLT_DOUBLE && dst_type == FLT_FLOAT) { + /*Temporary solution for VMS. Cap double values between maximal and minimal + *destination values because VMS return exception when overflows or underflows. + *Same below.*/ + INIT_FP_NORM(double, FLT_MAX, FLT_MIN, FLT_MAX_10_EXP, FLT_MIN_10_EXP, + src_size, dst_size, buf, saved, nelmts); } else if(src_type == FLT_DOUBLE) { INIT_FP_NORM(double, DBL_MAX, DBL_MIN, DBL_MAX_10_EXP, DBL_MIN_10_EXP, src_size, dst_size, buf, saved, nelmts); #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 + } else if(src_type == FLT_LDOUBLE && dst_type == FLT_FLOAT) { + INIT_FP_NORM(long double, FLT_MAX, FLT_MIN, FLT_MAX_10_EXP, FLT_MIN_10_EXP, + src_size, dst_size, buf, saved, nelmts); + } else if(src_type == FLT_LDOUBLE && dst_type == FLT_DOUBLE) { + INIT_FP_NORM(long double, DBL_MAX, DBL_MIN, DBL_MAX_10_EXP, DBL_MIN_10_EXP, + src_size, dst_size, buf, saved, nelmts); } else if(src_type == FLT_LDOUBLE) { INIT_FP_NORM(long double, LDBL_MAX, LDBL_MIN, LDBL_MAX_10_EXP, LDBL_MIN_10_EXP, src_size, dst_size, buf, saved, nelmts); #endif } else goto error; - +#else /*VMS*/ + if(src_type == FLT_FLOAT) { + INIT_FP_NORM(float, FLT_MAX, FLT_MIN, FLT_MAX_10_EXP, FLT_MIN_10_EXP, + src_size, dst_size, buf, saved, nelmts); + } else if(src_type == FLT_DOUBLE) { + INIT_FP_NORM(double, DBL_MAX, DBL_MIN, DBL_MAX_10_EXP, DBL_MIN_10_EXP, + src_size, dst_size, buf, saved, nelmts); +#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 + } else if(src_type == FLT_LDOUBLE) { + INIT_FP_NORM(long double, LDBL_MAX, LDBL_MIN, LDBL_MAX_10_EXP, LDBL_MIN_10_EXP, + src_size, dst_size, buf, saved, nelmts); +#endif + } else + goto error; +#endif /*VMS*/ + break; case TEST_DENORM: if(src_type == FLT_FLOAT) { - INIT_FP_DENORM(float, FLT_MANT_DIG, src_size, src_nbits, endian, dst_size, + INIT_FP_DENORM(float, FLT_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, nelmts); } else if(src_type == FLT_DOUBLE) { - INIT_FP_DENORM(double, DBL_MANT_DIG, src_size, src_nbits, endian, dst_size, + INIT_FP_DENORM(double, DBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, nelmts); #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 } else if(src_type == FLT_LDOUBLE) { - INIT_FP_DENORM(long double, LDBL_MANT_DIG, src_size, src_nbits, endian, dst_size, + INIT_FP_DENORM(long double, LDBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, nelmts); #endif } else @@ -2926,14 +3009,14 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) case TEST_SPECIAL: if(src_type == FLT_FLOAT) { - INIT_FP_SPECIAL(src_size, src_nbits, endian, FLT_MANT_DIG, dst_size, + INIT_FP_SPECIAL(src_size, src_nbits, sendian, FLT_MANT_DIG, dst_size, buf, saved, nelmts); } else if(src_type == FLT_DOUBLE) { - INIT_FP_SPECIAL(src_size, src_nbits, endian, DBL_MANT_DIG, dst_size, + INIT_FP_SPECIAL(src_size, src_nbits, sendian, DBL_MANT_DIG, dst_size, buf, saved, nelmts); #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 } else if(src_type == FLT_LDOUBLE) { - INIT_FP_SPECIAL(src_size, src_nbits, endian, LDBL_MANT_DIG, dst_size, + INIT_FP_SPECIAL(src_size, src_nbits, sendian, LDBL_MANT_DIG, dst_size, buf, saved, nelmts); #endif } else @@ -2980,6 +3063,9 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) hw = (unsigned char*)&hw_f; underflow = HDfabs(*((double*)aligned)) < FLT_MIN; overflow = HDfabs(*((double*)aligned)) > 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<dst_size; q++) { buf[j*dst_size+q] = 0x00; @@ -3035,6 +3127,18 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) if (k==dst_size) continue; /*no error*/ +#ifdef VMS + /* For "float" and "double" on OpenVMS/Alpha, NaN is + * a valid value of maximal value.*/ + if (FLT_FLOAT==src_type && + my_isnan(src_type, saved+j*sizeof(float))) { + continue; + } else if (FLT_DOUBLE==src_type && + my_isnan(src_type, saved+j*sizeof(double))) { + continue; + } +#endif /*VMS*/ + /* * Assume same if both results are NaN. There are many NaN bit * patterns and the software doesn't attemt to emulate the @@ -3088,9 +3192,14 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) if (underflow && HDfabsf(x) <= FLT_MIN && HDfabsf(hw_f) <= FLT_MIN) continue; /* all underflowed, no error */ - if (overflow && my_isinf(endian, buf+j*sizeof(float), + if (overflow && my_isinf(dst_type, dendian, buf+j*sizeof(float), dst_size, dst_mpos, dst_msize, dst_epos, dst_esize)) continue; /* all overflowed, no error */ +#ifdef VMS + if (maximal && my_isinf(dst_type, dendian, buf+j*sizeof(float), + dst_size, dst_mpos, dst_msize, dst_epos, dst_esize)) + continue; /* maximal value, no error */ +#endif /*VMS*/ check_mant[0] = HDfrexpf(x, check_expo+0); check_mant[1] = HDfrexpf(hw_f, check_expo+1); } else if (FLT_DOUBLE==dst_type) { @@ -3099,9 +3208,14 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) if (underflow && HDfabs(x) <= DBL_MIN && HDfabs(hw_d) <= DBL_MIN) continue; /* all underflowed, no error */ - if (overflow && my_isinf(endian, buf+j*sizeof(double), + if (overflow && my_isinf(dst_type, dendian, buf+j*sizeof(double), dst_size, dst_mpos, dst_msize, dst_epos, dst_esize)) continue; /* all overflowed, no error */ +#ifdef VMS + if (maximal && my_isinf(dst_type, dendian, buf+j*sizeof(double), + dst_size, dst_mpos, dst_msize, dst_epos, dst_esize)) + continue; /* maximal value, no error */ +#endif /*VMS*/ check_mant[0] = HDfrexp(x, check_expo+0); check_mant[1] = HDfrexp(hw_d, check_expo+1); #if H5_SIZEOF_LONG_DOUBLE !=0 && (H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE) @@ -3142,21 +3256,41 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) uint8_t tmp[32]; assert(src_size<=sizeof(tmp)); - if(endian==H5T_ORDER_LE) + if(sendian==H5T_ORDER_LE) HDmemcpy(tmp,&saved[j*src_size],src_size); - else + else if(sendian==H5T_ORDER_BE) for (k=0; k<src_size; k++) tmp[k]=saved[j*src_size+(src_size-(k+1))]; + else { + for (k = 0; k < src_size; k += 4) { + tmp[k] = saved[j*src_size+(src_size-2)-k]; + tmp[k+1] = saved[j*src_size+(src_size-1)-k]; + + tmp[(src_size-2)-k] = saved[j*src_size+k] + tmp[(src_size-1)-k] = saved[j*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) + if(sendian==H5T_ORDER_LE) HDmemcpy(tmp,&buf[j*dst_size],dst_size); - else + else if(sendian==H5T_ORDER_BE) for (k=0; k<dst_size; k++) tmp[k]=buf[j*dst_size+(dst_size-(k+1))]; + else { + for (k = 0; k < src_size; k += 4) { + tmp[k] = buf[j*dst_size+(dst_size-2)-k]; + tmp[k+1] = buf[j*dst_size+(dst_size-1)-k]; + + tmp[(dst_size-2)-k] = buf[j*dst_size+k] + tmp[(dst_size-1)-k] = buf[j*dst_size+k+1]; + } + } + expo = H5T_bit_get_d(tmp, dst_epos, dst_esize); if(expo==0) continue; /* Denormalized floating-point value detected */ @@ -3181,7 +3315,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) printf(" src ="); for (k=0; k<src_size; k++) - printf(" %02x", saved[j*src_size+ENDIAN(src_size,k)]); + printf(" %02x", saved[j*src_size+ENDIAN(src_size,k,sendian)]); printf("%*s", (int)(3*MAX(0, (ssize_t)dst_size-(ssize_t)src_size)), ""); if (FLT_FLOAT==src_type) { float x; @@ -3201,7 +3335,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) printf(" dst ="); for (k=0; k<dst_size; k++) - printf(" %02x", buf[j*dst_size+ENDIAN(dst_size,k)]); + printf(" %02x", buf[j*dst_size+ENDIAN(dst_size,k,dendian)]); printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)), ""); if (FLT_FLOAT==dst_type) { float x; @@ -3221,7 +3355,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) printf(" ans ="); for (k=0; k<dst_size; k++) - printf(" %02x", hw[ENDIAN(dst_size,k)]); + printf(" %02x", hw[ENDIAN(dst_size,k,dendian)]); 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); @@ -3331,7 +3465,8 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) dtype_t dst_type; /*data types */ const char *src_type_name=NULL; /*source type name */ const char *dst_type_name=NULL; /*destination type name */ - int endian; /*machine endianess */ + int sendian; /*source endianess */ + int dendian; /*destination endianess */ size_t src_size, dst_size; /*type sizes */ unsigned char *buf=NULL; /*buffer for conversion */ unsigned char *saved=NULL; /*original values */ @@ -3519,7 +3654,8 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) } /* Some information about datatypes */ - endian = H5Tget_order(H5T_NATIVE_INT); + sendian = H5Tget_order(src); + dendian = H5Tget_order(dst); src_size = H5Tget_size(src); dst_size = H5Tget_size(dst); src_nbits = H5Tget_precision(src); /* not 8*src_size, esp on J90 - QAK */ @@ -3589,20 +3725,20 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) INIT_FP_NORM(float, FLT_MAX, FLT_MIN, FLT_MAX_10_EXP, FLT_MIN_10_EXP, src_size, dst_size, buf, saved, nelmts); } else if(run_test==TEST_DENORM) { - INIT_FP_DENORM(float, FLT_MANT_DIG, src_size, src_nbits, endian, dst_size, + INIT_FP_DENORM(float, FLT_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, nelmts); } else { - INIT_FP_SPECIAL(src_size, src_nbits, endian, FLT_MANT_DIG, dst_size, buf, saved, nelmts); + INIT_FP_SPECIAL(src_size, src_nbits, sendian, FLT_MANT_DIG, dst_size, buf, saved, nelmts); } } else if(src_type == FLT_DOUBLE) { if(run_test==TEST_NORMAL) { INIT_FP_NORM(double, DBL_MAX, DBL_MIN, DBL_MAX_10_EXP, DBL_MIN_10_EXP, src_size, dst_size, buf, saved, nelmts); } else if(run_test==TEST_DENORM) { - INIT_FP_DENORM(double, DBL_MANT_DIG, src_size, src_nbits, endian, dst_size, + INIT_FP_DENORM(double, DBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, nelmts); } else { - INIT_FP_SPECIAL(src_size, src_nbits, endian, DBL_MANT_DIG, dst_size, buf, saved, nelmts); + INIT_FP_SPECIAL(src_size, src_nbits, sendian, DBL_MANT_DIG, dst_size, buf, saved, nelmts); } #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 } else if(src_type == FLT_LDOUBLE) { @@ -3610,10 +3746,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) INIT_FP_NORM(long double, LDBL_MAX, LDBL_MIN, LDBL_MAX_10_EXP, LDBL_MIN_10_EXP, src_size, dst_size, buf, saved, nelmts); } else if(run_test==TEST_DENORM) { - INIT_FP_DENORM(long double, LDBL_MANT_DIG, src_size, src_nbits, endian, dst_size, + INIT_FP_DENORM(long double, LDBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, nelmts); } else { - INIT_FP_SPECIAL(src_size, src_nbits, endian, LDBL_MANT_DIG, dst_size, buf, saved, nelmts); + INIT_FP_SPECIAL(src_size, src_nbits, sendian, LDBL_MANT_DIG, dst_size, buf, saved, nelmts); } #endif } else @@ -3991,7 +4127,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * the values. */ #if H5_SIZEOF_LONG_DOUBLE !=0 - if(endian==H5T_ORDER_LE && dst_type==FLT_LDOUBLE) { + if(dendian==H5T_ORDER_LE && dst_type==FLT_LDOUBLE) { unsigned int q; for(q=dst_nbits/8; q<dst_size; q++) { buf[j*dst_size+q] = 0x00; @@ -4012,11 +4148,19 @@ test_conv_int_fp(const char *name, int run_test, 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)]; + + if ((FLT_FLOAT==src_type || FLT_DOUBLE==src_type) && sendian==H5T_ORDER_VAX) { + for (k = 0; k < src_size; k += 2) { + src_bits[k] = saved[j*src_size + (src_size - 2) - k]; + src_bits[k + 1] = saved[j*src_size + (src_size - 1) - k]; + } + } else { + for (k=0; k<src_size; k++) + src_bits[src_size-(k+1)] = saved[j*src_size+ENDIAN(src_size, k, sendian)]; + } for (k=0; k<dst_size; k++) - dst_bits[dst_size-(k+1)] = buf[j*dst_size+ENDIAN(dst_size, k)]; + dst_bits[dst_size-(k+1)] = buf[j*dst_size+ENDIAN(dst_size, k, dendian)]; /* Test library's default overflow handling: * Hardware usually doesn't handle overflows too gracefully. The @@ -4177,7 +4321,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) printf(" src = "); for (k=0; k<src_size; k++) - printf(" %02x", saved[j*src_size+ENDIAN(src_size, k)]); + printf(" %02x", saved[j*src_size+ENDIAN(src_size, k, sendian)]); printf("%*s", (int)(3*MAX(0, (ssize_t)dst_size-(ssize_t)src_size)), ""); switch (src_type) { case INT_SCHAR: @@ -4240,7 +4384,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) printf(" dst = "); for (k=0; k<dst_size; k++) - printf(" %02x", buf[j*dst_size+ENDIAN(dst_size, k)]); + printf(" %02x", buf[j*dst_size+ENDIAN(dst_size, k, dendian)]); printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)), ""); switch (dst_type) { case INT_SCHAR: @@ -4303,7 +4447,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) printf(" ans = "); for (k=0; k<dst_size; k++) - printf(" %02x", hw[ENDIAN(dst_size, k)]); + printf(" %02x", hw[ENDIAN(dst_size, k, dendian)]); printf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)), ""); switch (dst_type) { case INT_SCHAR: @@ -4865,7 +5009,15 @@ run_fp_int_conv(const char *name) run_test = FALSE; #endif +#ifdef VMS + run_test = TRUE; +#endif + if(run_test) { +#ifdef VMS + test_values = TEST_NORMAL; + { +#else for(i=0; i<3; i++) { if(i==0) test_values = TEST_NORMAL; @@ -4873,6 +5025,7 @@ run_fp_int_conv(const char *name) test_values = TEST_DENORM; else test_values = TEST_SPECIAL; +#endif /*VMS*/ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_SCHAR); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_SCHAR); @@ -5064,8 +5217,10 @@ main(void) * for user-defined integer types */ nerrors += test_derived_integer(); +#ifndef VMS /* Does floating point overflow generate a SIGFPE? */ generates_sigfpe(); +#endif /* Test degenerate cases */ nerrors += run_fp_tests("noop"); diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 8a5e192..65c2a80 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -763,6 +763,10 @@ print_datatype(hid_t type,unsigned in_group) printf("H5T_IEEE_F64BE"); } else if (H5Tequal(type, H5T_IEEE_F64LE)) { printf("H5T_IEEE_F64LE"); + } else if (H5Tequal(type, H5T_VAX_F32)) { + printf("H5T_VAX_F32"); + } else if (H5Tequal(type, H5T_VAX_F64)) { + printf("H5T_VAX_F64"); } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) { printf("H5T_NATIVE_FLOAT"); } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { @@ -4042,6 +4046,8 @@ xml_print_datatype(hid_t type, unsigned in_group) printf("BE"); break; case H5T_ORDER_VAX: + printf("VAX"); + break; default: printf("ERROR_UNKNOWN"); } diff --git a/vms/src/h5pubconf.h b/vms/src/h5pubconf.h index 0c5fa28..c80f460 100644 --- a/vms/src/h5pubconf.h +++ b/vms/src/h5pubconf.h @@ -32,7 +32,7 @@ /* Define if your system has right maximum convert floating-point to unsigned long long values. */ -/* #undef H5_FP_TO_ULLONG_RIGHT_MAXIMUM */ +#define H5_FP_TO_ULLONG_RIGHT_MAXIMUM 1 /* Define if gettimeofday() populates the tz pointer passed in */ #define H5_GETTIMEOFDAY_GIVES_TZ 1 |