diff options
-rw-r--r-- | release_docs/RELEASE.txt | 2 | ||||
-rw-r--r-- | src/H5Dscatgath.c | 11 | ||||
-rw-r--r-- | src/H5Tconv.c | 54 | ||||
-rw-r--r-- | test/dtransform.c | 59 |
4 files changed, 70 insertions, 56 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 33fed05..1802d27 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -162,6 +162,8 @@ Bug Fixes since HDF5-1.8.0 release Library ------- + - Fixed a problem with using data transforms with non-native types in the + file. (NAF - 2009/04/20 - 1548) - Added direct.h include file to windows section of H5private.h to fix _getcwd() warning. (ADB - 2009/04/14 - 1536) - Fixed a bug that prevented external links from working after calling diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index bb9f46b..ed73f3c 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -662,6 +662,12 @@ H5D_scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") } /* end if */ + /* Do the data transform before the type conversion (since + * transforms must be done in the memory type). */ + if(!type_info->is_xform_noop) + if(H5Z_xform_eval(dxpl_cache->data_xform_prop, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Error performing data transform") + /* * Perform datatype conversion. */ @@ -669,11 +675,6 @@ H5D_scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf smine_nelmts, (size_t)0, (size_t)0, type_info->tconv_buf, type_info->bkg_buf, io_info->dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") - - /* Do the data transform after the type conversion (since we're using dataset->shared->type). */ - if(!type_info->is_xform_noop) - if(H5Z_xform_eval(dxpl_cache->data_xform_prop, type_info->tconv_buf, smine_nelmts, type_info->dset_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Error performing data transform") } /* end else */ /* diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 90b7a21..c621bf4 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -194,7 +194,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -203,7 +203,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MIN); \ + *((DT*)D) = (DT)(D_MIN); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -212,9 +212,9 @@ } #define H5T_CONV_Xx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ } else if (*((ST*)S) < (DT)(D_MIN)) { \ - *((DT*)D) = (D_MIN); \ + *((DT*)D) = (DT)(D_MIN); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } @@ -225,7 +225,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -234,7 +234,7 @@ } #define H5T_CONV_Ux_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } @@ -270,12 +270,12 @@ } #define H5T_CONV_uS_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (sizeof(ST)==sizeof(DT) && *((ST*)S) > (D_MAX)) { \ + if (sizeof(ST)==sizeof(DT) && *((ST*)S) > (DT)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -319,7 +319,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -330,7 +330,7 @@ if (*((ST*)S) < 0) { \ *((DT*)D) = 0; \ } else if (sizeof(ST)>sizeof(DT) && *((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } @@ -384,7 +384,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -394,7 +394,7 @@ #define H5T_CONV_us_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ /* Assumes memory format of unsigned & signed integers is same */ \ if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } @@ -553,7 +553,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -562,7 +562,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MIN); \ + *((DT*)D) = (DT)(D_MIN); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -581,9 +581,9 @@ } #define H5T_CONV_Fx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ } else if (*((ST*)S) < (DT)(D_MIN)) { \ - *((DT*)D) = (D_MIN); \ + *((DT*)D) = (DT)(D_MIN); \ } \ else \ *((DT*)D) = (DT)(*((ST*)S)); \ @@ -621,7 +621,7 @@ case H5T_CONV_INIT: \ /* Sanity check and initialize statistics */ \ cdata->need_bkg = H5T_BKG_NO; \ - if (NULL==(st=H5I_object(src_id)) || NULL==(dt=H5I_object(dst_id))) \ + if (NULL==(st=(H5T_t*)H5I_object(src_id)) || NULL==(dt=(H5T_t*)H5I_object(dst_id))) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ "unable to dereference datatype object ID") \ if (st->shared->size!=sizeof(ST) || dt->shared->size!=sizeof(DT)) \ @@ -669,7 +669,7 @@ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); \ \ /* Get source and destination datatypes */ \ - if (NULL==(st=H5I_object(src_id)) || NULL==(dt=H5I_object(dst_id))) \ + if (NULL==(st=(H5T_t*)H5I_object(src_id)) || NULL==(dt=(H5T_t*)H5I_object(dst_id))) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ "unable to dereference datatype object ID") \ \ @@ -714,7 +714,7 @@ } /* end if */ \ else { \ /* Single forward pass over all data */ \ - src = dst = buf; \ + src = dst = (uint8_t*)buf; \ safe=nelmts; \ } /* end else */ \ \ @@ -9755,8 +9755,8 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch (cdata->command) { case H5T_CONV_INIT: - if (NULL==(src_p=H5I_object(src_id)) || - NULL==(dst_p=H5I_object(dst_id))) + if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) || + NULL==(dst_p=(H5T_t*)H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -9774,8 +9774,8 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if (NULL==(src_p=H5I_object(src_id)) || - NULL==(dst_p=H5I_object(dst_id))) + if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) || + NULL==(dst_p=(H5T_t*)H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -10345,8 +10345,8 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch (cdata->command) { case H5T_CONV_INIT: - if (NULL==(src_p=H5I_object(src_id)) || - NULL==(dst_p=H5I_object(dst_id))) + if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) || + NULL==(dst_p=(H5T_t*)H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -10364,8 +10364,8 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if (NULL==(src_p=H5I_object(src_id)) || - NULL==(dst_p=H5I_object(dst_id))) + if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) || + NULL==(dst_p=(H5T_t*)H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; diff --git a/test/dtransform.c b/test/dtransform.c index 8b5dce0..cb58a6c 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -50,17 +50,17 @@ const float windchillFfloat[ROWS][COLS] = const int transformData[ROWS][COLS] = { {36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, 28, 34, 40, 46, 52, 57, 63 }, - {34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 72 } , - {32, 25, 19, 13, 6, 0, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 77 }, - {30, 24, 17, 11, 4, 2, 9, 15, 22, 29, 35, 42, 48, 55, 61, 68, 74, 81 }, - {29, 23, 16, 9, 3, 4, 11, 17, 24, 31, 37, 44, 51, 58, 64, 71, 78, 84 }, - {28, 22, 15, 8, 1, 5, 12, 19, 26, 33, 39, 46, 53, 60, 67, 73, 80, 87 }, - {28, 21, 14, 7, 0, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 76, 82, 89 }, - {27, 20, 13, 6, 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 84, 91 }, - {26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 72, 79, 86, 93 }, - {26, 19, 12, 4, 3, 10, 17, 24, 31, 38, 45, 52, 60, 67, 74, 81, 88, 95}, - {25, 18, 11, 4, 3, 11, 18, 25, 32, 39, 46, 54, 61, 68, 75, 82, 89, 97}, - {25, 17, 10, 3, 4, 11, 19, 26, 33, 40, 48, 55, 62, 69, 76, 84, 91, 98} + {34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 0 } , + {32, 25, 19, 13, 6, 0, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 5 }, + {30, 24, 17, 11, 4, 2, 9, 15, 22, 29, 35, 42, 48, 55, 61, 68, 2, 9 }, + {29, 23, 16, 9, 3, 4, 11, 17, 24, 31, 37, 44, 51, 58, 64, 71, 6, 12 }, + {28, 22, 15, 8, 1, 5, 12, 19, 26, 33, 39, 46, 53, 60, 67, 1, 8, 15 }, + {28, 21, 14, 7, 0, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 4, 10, 17 }, + {27, 20, 13, 6, 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 6, 12, 19 }, + {26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 0, 7, 14, 21 }, + {26, 19, 12, 4, 3, 10, 17, 24, 31, 38, 45, 52, 60, 67, 2, 9, 16, 23}, + {25, 18, 11, 4, 3, 11, 18, 25, 32, 39, 46, 54, 61, 68, 3, 10, 17, 25}, + {25, 17, 10, 3, 4, 11, 19, 26, 33, 40, 48, 55, 62, 69, 4, 12, 19, 26} }; #define UCOMPARE(TYPE,VAR1,VAR2,TOL) \ @@ -104,17 +104,25 @@ const int transformData[ROWS][COLS] = /* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit into uchar */ \ const char* utrans = "((x+100)/4)*3"; \ \ - hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, dset; \ + hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, dset, dset_nn, dt_nn; \ + H5T_order_t order; \ hsize_t dim[2] = {ROWS, COLS}; \ \ if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR; \ - if((dset = H5Dcreate2(file_id, "/transformtest_"TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; \ + if((dset = H5Dcreate2(file_id, "/transformtest_"TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; \ + \ + if((dt_nn = H5Tcopy(HDF_TYPE)) < 0) TEST_ERROR \ + if((order = H5Tget_order(dt_nn)) == H5T_ORDER_ERROR) TEST_ERROR \ + if(H5Tset_order(dt_nn, order == H5T_ORDER_LE ? H5T_ORDER_BE : H5T_ORDER_LE) < 0) TEST_ERROR \ + if((dset_nn = H5Dcreate2(file_id, "/nonnative_transformtest_"TEST_STR, dt_nn, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR \ + if(H5Tclose(dt_nn) < 0) TEST_ERROR \ \ if(SIGNED) \ { \ if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \ if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) TEST_ERROR; \ if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR; \ + if(H5Dwrite(dset_nn, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR; \ if(H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR; \ } \ else \ @@ -122,6 +130,7 @@ const int transformData[ROWS][COLS] = if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \ if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) TEST_ERROR; \ if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData) < 0) TEST_ERROR; \ + if(H5Dwrite(dset_nn, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData) < 0) TEST_ERROR; \ if(H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR; \ } \ \ @@ -133,16 +142,21 @@ const int transformData[ROWS][COLS] = COMPARE(TYPE, array, COMPARE_DATA, 2) \ else \ UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ + \ + TESTING("contiguous, byte order conversion ("TEST_STR"->"TEST_STR")") \ + \ + if(H5Dread(dset_nn, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) TEST_ERROR; \ + if(SIGNED) \ + COMPARE(TYPE, array, COMPARE_DATA, 2) \ + else \ + UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ \ if(SIGNED) \ { \ TESTING("contiguous, with type conversion (float->"TEST_STR")") \ \ if(H5Dread(dset_id_float, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) TEST_ERROR; \ - if(SIGNED) \ - COMPARE(TYPE, array, COMPARE_DATA, 2) \ - else \ - UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ + COMPARE(TYPE, array, COMPARE_DATA, 2) \ } \ \ if(H5Dclose(dset) < 0) TEST_ERROR; \ @@ -200,10 +214,7 @@ const int transformData[ROWS][COLS] = TESTING("chunked, with type conversion (float->"TEST_STR")") \ \ if(H5Dread(dset_id_float_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) TEST_ERROR; \ - if(SIGNED) \ - COMPARE(TYPE, array, COMPARE_DATA, 2) \ - else \ - UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ + COMPARE(TYPE, array, COMPARE_DATA, 2) \ } \ \ \ @@ -516,7 +527,7 @@ test_getset(const hid_t dxpl_id_c_to_f) float windchillFfloatread[ROWS][COLS]; const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ const char* c_to_f = "(9/5.0)*x + 32"; - char* ptrgetTest = HDmalloc(HDstrlen(simple)+1); + char* ptrgetTest = (char *) HDmalloc(HDstrlen(simple)+1); TESTING("H5Pget_data_transform") H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(c_to_f)+1); @@ -549,7 +560,7 @@ test_getset(const hid_t dxpl_id_c_to_f) PASSED(); - ptrgetTest = malloc(strlen(simple)+1); + ptrgetTest = (char *) malloc(strlen(simple)+1); HDmemset(ptrgetTest, 0, strlen(simple)+1); TESTING("H5Pget_data_transform, after resetting transform property") @@ -577,7 +588,7 @@ test_set(void) hid_t dxpl_id; H5E_auto2_t func; const char* str = "(9/5.0)*x + 32"; - char* ptrgetTest = malloc(strlen(str)+1); + char* ptrgetTest = (char *) malloc(strlen(str)+1); if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; |