From 7d4bb6efd27d5ec2321cef54f3e17f4852f585ec Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 7 Jul 2003 11:33:13 -0500 Subject: [svn-r7174] Purpose: Bug fix Description: Fix "unaligned access" warning on IA64 (and alpha, probably) machines. Solution: Make certain that temporary destination buffer is aligned on correct boundary for type conversion. Platforms tested: IA64 Linux cluster (titan) too small for h5committest --- src/H5Tconv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 44dde72..ab4ef71 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -2126,7 +2126,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, size_t conv_buf_size=0; /*size of conversion buffer in bytes */ void *tmp_buf=NULL; /*temporary background buffer */ size_t tmp_buf_size=0; /*size of temporary bkg buffer */ - uint8_t dbuf[64],*dbuf_ptr=dbuf;/*temp destination buffer */ + uint8_t dbuf[64],*dbuf_ptr; /*temp destination buffer */ int direction; /*direction of traversal */ int nested=0; /*flag of nested VL case */ hsize_t elmtno; /*element number counter */ @@ -2205,6 +2205,12 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, dst_delta = direction * (buf_stride ? buf_stride : dst->size); bkg_delta = direction * (bkg_stride ? bkg_stride : dst->size); + /* Set the dbuf_ptr correctly, based on the alignment of the dbuf */ + /* (Have to use the maximum alignment of hvl_t and 'char *' types */ + /* since this routine is used for both variable-length sequences */ + /* and variable-length strings) */ + dbuf_ptr=dbuf+(((size_t)dbuf)%MAX(H5T_HVL_COMP_ALIGN_g,H5T_POINTER_COMP_ALIGN_g)); + /* * If the source and destination buffers overlap then use a * temporary buffer for the destination. @@ -2334,7 +2340,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, * then we should copy the value to the true destination * buffer. */ - if (d==dbuf) HDmemcpy (dp, d, dst->size); + if (d==dbuf_ptr) HDmemcpy (dp, d, dst->size); sp += src_delta; dp += dst_delta; if(bg_ptr!=NULL) -- cgit v0.12