From cacc8fa4c6bd301339ce78e8ab41a31ab8bdf654 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Thu, 21 Oct 2004 11:04:08 -0500 Subject: [svn-r9445] Purpose: Bug fix Description: "char" was considered as always "signed char" in data type conversion. However, ISO C leaves the definition of "char" to individual implementation. i.e. for IBM AIX C compiler, it's treated as "unsigned char". Solution: Changed all "char" to "signed char". Don't even do "char" anymore because its definition is up to each vendor. Platforms tested: h5committest --- src/H5T.c | 8 ++--- src/H5Tconv.c | 40 +++++++++++------------ src/H5Tpkg.h | 8 ++--- test/dtypes.c | 100 +++++++++++++++++++++++++++++----------------------------- 4 files changed, 78 insertions(+), 78 deletions(-) diff --git a/src/H5T.c b/src/H5T.c index 602da96..0c85c3f 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -1098,8 +1098,8 @@ H5T_init_interface(void) status |= H5T_register(H5T_PERS_HARD, "uchar_schar", native_uchar, native_schar, H5T_conv_uchar_schar, H5AC_dxpl_id); /* From char to floats */ - status |= H5T_register(H5T_PERS_HARD, "char_flt", native_schar, native_float, H5T_conv_char_float, H5AC_dxpl_id); - status |= H5T_register(H5T_PERS_HARD, "char_dbl", native_schar, native_double, H5T_conv_char_double, H5AC_dxpl_id); + status |= H5T_register(H5T_PERS_HARD, "schar_flt", native_schar, native_float, H5T_conv_schar_float, H5AC_dxpl_id); + status |= H5T_register(H5T_PERS_HARD, "schar_dbl", native_schar, native_double, H5T_conv_schar_double, H5AC_dxpl_id); /* From unsigned char to floats */ status |= H5T_register(H5T_PERS_HARD, "uchar_flt", native_uchar, native_float, H5T_conv_uchar_float, H5AC_dxpl_id); @@ -1140,8 +1140,8 @@ H5T_init_interface(void) #endif /* H5_ULLONG_TO_FP_CAST_WORKS */ /* From floats to char */ - status |= H5T_register(H5T_PERS_HARD, "flt_char", native_float, native_schar, H5T_conv_float_char, H5AC_dxpl_id); - status |= H5T_register(H5T_PERS_HARD, "dbl_char", native_double, native_schar, H5T_conv_double_char, H5AC_dxpl_id); + status |= H5T_register(H5T_PERS_HARD, "flt_schar", native_float, native_schar, H5T_conv_float_schar, H5AC_dxpl_id); + status |= H5T_register(H5T_PERS_HARD, "dbl_schar", native_double, native_schar, H5T_conv_double_schar, H5AC_dxpl_id); /* From floats to unsigned char */ status |= H5T_register(H5T_PERS_HARD, "flt_uchar", native_float, native_uchar, H5T_conv_float_uchar, H5AC_dxpl_id); diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 30f41fe..871e8e1 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -6976,9 +6976,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5T_conv_char_float + * Function: H5T_conv_schar_float * - * Purpose: Convert native char to native float using hardware. + * Purpose: Convert native signed char to native float using hardware. * This is a fast special case. * * Return: Non-negative on success/Negative on failure @@ -6991,16 +6991,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T_conv_char_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, +H5T_conv_schar_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5T_conv_char_float, FAIL); + FUNC_ENTER_NOAPI(H5T_conv_schar_float, FAIL); - H5T_CONV_xF(SCHAR, FLOAT, char, float, -, -); + H5T_CONV_xF(SCHAR, FLOAT, signed char, float, -, -); done: FUNC_LEAVE_NOAPI(ret_value); @@ -7008,9 +7008,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5T_conv_char_double + * Function: H5T_conv_schar_double * - * Purpose: Convert native char to native double using hardware. + * Purpose: Convert native signed char to native double using hardware. * This is a fast special case. * * Return: Non-negative on success/Negative on failure @@ -7023,16 +7023,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T_conv_char_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, +H5T_conv_schar_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5T_conv_char_double, FAIL); + FUNC_ENTER_NOAPI(H5T_conv_schar_double, FAIL); - H5T_CONV_xF(SCHAR, DOUBLE, char, double, -, -); + H5T_CONV_xF(SCHAR, DOUBLE, signed char, double, -, -); done: FUNC_LEAVE_NOAPI(ret_value); @@ -7619,9 +7619,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5T_conv_float_char + * Function: H5T_conv_float_schar * - * Purpose: Convert native float to native char using + * Purpose: Convert native float to native signed char using * hardware. This is a fast special case. * * Return: Non-negative on success/Negative on failure @@ -7634,16 +7634,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T_conv_float_char (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, +H5T_conv_float_schar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5T_conv_float_char, FAIL); + FUNC_ENTER_NOAPI(H5T_conv_float_schar, FAIL); - H5T_CONV_Fx(FLOAT, SCHAR, float, char, CHAR_MIN, CHAR_MAX); + H5T_CONV_Fx(FLOAT, SCHAR, float, signed char, SCHAR_MIN, SCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); @@ -7683,9 +7683,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5T_conv_double_char + * Function: H5T_conv_double_schar * - * Purpose: Convert native float to native char using + * Purpose: Convert native float to native signed char using * hardware. This is a fast special case. * * Return: Non-negative on success/Negative on failure @@ -7698,16 +7698,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T_conv_double_char (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, +H5T_conv_double_schar (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5T_conv_double_char, FAIL); + FUNC_ENTER_NOAPI(H5T_conv_double_schar, FAIL); - H5T_CONV_Fx(DOUBLE, SCHAR, double, char, CHAR_MIN, CHAR_MAX); + H5T_CONV_Fx(DOUBLE, SCHAR, double, signed char, SCHAR_MIN, SCHAR_MAX); done: FUNC_LEAVE_NOAPI(ret_value); diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 2993f2f..f1c71c9 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -857,12 +857,12 @@ H5_DLL herr_t H5T_conv_double_float(hid_t src_id, hid_t dst_id, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); -H5_DLL herr_t H5T_conv_char_float(hid_t src_id, hid_t dst_id, +H5_DLL herr_t H5T_conv_schar_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); -H5_DLL herr_t H5T_conv_char_double(hid_t src_id, hid_t dst_id, +H5_DLL herr_t H5T_conv_schar_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, @@ -959,7 +959,7 @@ H5_DLL herr_t H5T_conv_ullong_double(hid_t src_id, hid_t dst_id, void *buf, void *bkg, hid_t dset_xfer_plist); #endif /* H5_ULLONG_TO_FP_CAST_WORKS */ -H5_DLL herr_t H5T_conv_float_char(hid_t src_id, hid_t dst_id, +H5_DLL herr_t H5T_conv_float_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, @@ -1009,7 +1009,7 @@ H5_DLL herr_t H5T_conv_float_ullong(hid_t src_id, hid_t dst_id, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); -H5_DLL herr_t H5T_conv_double_char(hid_t src_id, hid_t dst_id, +H5_DLL herr_t H5T_conv_double_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, diff --git a/test/dtypes.c b/test/dtypes.c index 3dfb53b..b27de1d 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -82,7 +82,7 @@ typedef struct complex_t { #define ENDIAN(Z,I) (H5T_ORDER_BE==endian?(I):(Z)-((I)+1)) typedef enum dtype_t { - INT_CHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, + INT_SCHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, OTHER } dtype_t; @@ -3784,7 +3784,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) /* What are the names of the source and destination types */ if (H5Tequal(src, H5T_NATIVE_SCHAR)) { src_type_name = "signed char"; - src_type = INT_CHAR; + src_type = INT_SCHAR; } else if (H5Tequal(src, H5T_NATIVE_UCHAR)) { src_type_name = "unsigned char"; src_type = INT_UCHAR; @@ -3819,7 +3819,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) if (H5Tequal(dst, H5T_NATIVE_SCHAR)) { dst_type_name = "signed char"; - dst_type = INT_CHAR; + dst_type = INT_SCHAR; } else if (H5Tequal(dst, H5T_NATIVE_UCHAR)) { dst_type_name = "unsigned char"; dst_type = INT_UCHAR; @@ -3904,10 +3904,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) /* Check the results from the library against hardware */ for (j=0; j