summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2006-03-14 22:11:21 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2006-03-14 22:11:21 (GMT)
commita2a98a8135c3efee38b04b1d07e4602cdff1f1ef (patch)
tree926dbec855974eb9e4d799b33e55719e5db717be /src
parenta4c816eb75c20de14a5e557ffd76c33190152ce2 (diff)
downloadhdf5-a2a98a8135c3efee38b04b1d07e4602cdff1f1ef.zip
hdf5-a2a98a8135c3efee38b04b1d07e4602cdff1f1ef.tar.gz
hdf5-a2a98a8135c3efee38b04b1d07e4602cdff1f1ef.tar.bz2
[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.
Diffstat (limited to 'src')
-rw-r--r--src/H5Odtype.c55
-rw-r--r--src/H5T.c40
-rw-r--r--src/H5Tconv.c122
-rw-r--r--src/H5Tpublic.h8
-rw-r--r--src/H5detect.c60
5 files changed, 238 insertions, 47 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; 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");