mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-18 15:15:56 +08:00
[svn-r27130] Fix warnings in H5Tconv
Remove H5T_INIT_INTERFACE from H5Tconv Add macro in H5Tconv to check overflow when using H5T_CONV_uS
This commit is contained in:
parent
1ac9bcaaa6
commit
92e3188ff3
223
src/H5Tconv.c
223
src/H5Tconv.c
@ -23,10 +23,6 @@
|
||||
|
||||
#define H5T_PACKAGE /*suppress error about including H5Tpkg */
|
||||
|
||||
/* Interface initialization */
|
||||
#define H5_INTERFACE_INIT_FUNC H5T_init_conv_interface
|
||||
|
||||
|
||||
/***********/
|
||||
/* Headers */
|
||||
/***********/
|
||||
@ -174,10 +170,10 @@
|
||||
* destination.
|
||||
*
|
||||
*/
|
||||
#define H5T_CONV_xX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_xX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
#define H5T_CONV_xX_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_xX_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
|
||||
@ -188,7 +184,7 @@
|
||||
* equal. In this case, do not return exception but make sure the maximum is assigned
|
||||
* to the destination. SLU - 2005/06/29
|
||||
*/
|
||||
#define H5T_CONV_Xx_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_Xx_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if (*(S) > (ST)(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); \
|
||||
@ -210,7 +206,7 @@
|
||||
} else \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
#define H5T_CONV_Xx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_Xx_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if (*(S) > (ST)(D_MAX)) { \
|
||||
*(D) = (DT)(D_MAX); \
|
||||
} else if (*(S) < (ST)(D_MIN)) { \
|
||||
@ -219,7 +215,7 @@
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
|
||||
#define H5T_CONV_Ux_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_Ux_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if (*(S) > (ST)(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); \
|
||||
@ -232,7 +228,7 @@
|
||||
} else \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
#define H5T_CONV_Ux_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_Ux_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if (*(S) > (ST)(D_MAX)) { \
|
||||
*(D) = (DT)(D_MAX); \
|
||||
} else \
|
||||
@ -244,7 +240,7 @@
|
||||
H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \
|
||||
}
|
||||
|
||||
#define H5T_CONV_sU_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_sU_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if (*(S) < 0) { \
|
||||
H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \
|
||||
src_id, dst_id, S, D, cb_struct.user_data); \
|
||||
@ -257,7 +253,7 @@
|
||||
} else \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
#define H5T_CONV_sU_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_sU_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if(*(S) < 0) \
|
||||
*(D) = 0; \
|
||||
else \
|
||||
@ -269,28 +265,87 @@
|
||||
H5T_CONV(H5T_CONV_sU, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \
|
||||
}
|
||||
|
||||
#define H5T_CONV_uS_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if(sizeof(ST) == sizeof(DT) && *(S) > (DT)(D_MAX)) { \
|
||||
H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \
|
||||
/* Define to 1 if overflow is possible during conversion, 0 otherwise
|
||||
* Because destination is at least as wide as the source, this should only
|
||||
* occur between types of equal size */
|
||||
#define H5T_CONV_uS_UCHAR_SHORT 0
|
||||
#define H5T_CONV_uS_UCHAR_INT 0
|
||||
#define H5T_CONV_uS_UCHAR_LONG 0
|
||||
#define H5T_CONV_uS_UCHAR_LLONG 0
|
||||
#if H5_SIZEOF_SHORT == H5_SIZEOF_INT
|
||||
#define H5T_CONV_uS_USHORT_INT 1
|
||||
#else
|
||||
#define H5T_CONV_uS_USHORT_INT 0
|
||||
#endif
|
||||
#define H5T_CONV_uS_USHORT_LONG 0
|
||||
#define H5T_CONV_uS_USHORT_LLONG 0
|
||||
#if H5_SIZEOF_INT == H5_SIZEOF_LONG
|
||||
#define H5T_CONV_uS_UINT_LONG 1
|
||||
#else
|
||||
#define H5T_CONV_uS_UINT_LONG 0
|
||||
#endif
|
||||
#define H5T_CONV_uS_UINT_LLONG 0
|
||||
#if H5_SIZEOF_LONG == H5_SIZEOF_LONG_LONG
|
||||
#define H5T_CONV_uS_ULONG_LLONG 1
|
||||
#else
|
||||
#define H5T_CONV_uS_ULONG_LLONG 0
|
||||
#endif
|
||||
|
||||
/* Note. If an argument is stringified or concatenated, the prescan does not
|
||||
* occur. To expand the macro, then stringify or concatenate its expansion,
|
||||
* one macro must call another macro that does the stringification or
|
||||
* concatenation. */
|
||||
#define H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE) \
|
||||
H5_GLUE4(H5T_CONV_uS_, STYPE, _, DTYPE)
|
||||
|
||||
/* Called if overflow is possible */
|
||||
#define H5T_CONV_uS_CORE_1(S, D, ST, DT, D_MIN, D_MAX) \
|
||||
if (*(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*/ \
|
||||
*(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 */ \
|
||||
} else \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
#define H5T_CONV_uS_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if (sizeof(ST)==sizeof(DT) && *(S) > (DT)(D_MAX)) { \
|
||||
*(D) = (D_MAX); \
|
||||
} else \
|
||||
*(D) = (DT)(*(S)); \
|
||||
/* Let compiler convert if case is ignored by user handler */ \
|
||||
*(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 */\
|
||||
} else \
|
||||
*(D) = (DT)(*(S));
|
||||
|
||||
/* Called if no overflow is possible */
|
||||
#define H5T_CONV_uS_CORE_0(S, D, ST, DT, D_MIN, D_MAX) \
|
||||
*(D) = (DT)(*(S));
|
||||
|
||||
#define H5T_CONV_uS_CORE_I(over, S, D, ST, DT, D_MIN, D_MAX) \
|
||||
H5_GLUE(H5T_CONV_uS_CORE_, over)(S, D, ST, DT, D_MIN, D_MAX)
|
||||
|
||||
#define H5T_CONV_uS_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) { \
|
||||
H5T_CONV_uS_CORE_I(H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE), \
|
||||
S, D, ST, DT, D_MIN, D_MAX) \
|
||||
}
|
||||
|
||||
#define H5T_CONV_uS(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
|
||||
HDcompile_assert(sizeof(ST)<=sizeof(DT)); \
|
||||
/* Called if overflow is possible */
|
||||
#define H5T_CONV_uS_NOEX_CORE_1(S, D, ST, DT, D_MIN, D_MAX) \
|
||||
if (*(S) > (DT)(D_MAX)) \
|
||||
*(D) = (D_MAX); \
|
||||
else \
|
||||
*(D) = (DT)(*(S));
|
||||
|
||||
/* Called if no overflow is possible */
|
||||
#define H5T_CONV_uS_NOEX_CORE_0(S, D, ST, DT, D_MIN, D_MAX) \
|
||||
*(D) = (DT)(*(S));
|
||||
|
||||
#define H5T_CONV_uS_NOEX_CORE_I(over, S, D, ST, DT, D_MIN, D_MAX) \
|
||||
H5_GLUE(H5T_CONV_uS_NOEX_CORE_, over)(S, D, ST, DT, D_MIN, D_MAX)
|
||||
|
||||
#define H5T_CONV_uS_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) { \
|
||||
H5T_CONV_uS_NOEX_CORE_I(H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE), \
|
||||
S, D, ST, DT, D_MIN, D_MAX) \
|
||||
}
|
||||
|
||||
#define H5T_CONV_uS(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) { \
|
||||
HDcompile_assert(sizeof(ST) <= sizeof(DT)); \
|
||||
H5T_CONV(H5T_CONV_uS, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \
|
||||
}
|
||||
|
||||
@ -304,7 +359,7 @@
|
||||
H5T_CONV(H5T_CONV_Xx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \
|
||||
}
|
||||
|
||||
#define H5T_CONV_Su_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_Su_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if(*(S) < 0) { \
|
||||
H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \
|
||||
src_id, dst_id, S, D, cb_struct.user_data); \
|
||||
@ -326,7 +381,7 @@
|
||||
} else \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
#define H5T_CONV_Su_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_Su_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if(*(S) < 0) \
|
||||
*(D) = 0; \
|
||||
else if (sizeof(ST)>sizeof(DT) && *(S) > (ST)(D_MAX)) \
|
||||
@ -350,7 +405,7 @@
|
||||
H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \
|
||||
}
|
||||
|
||||
#define H5T_CONV_su_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_su_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
/* Assumes memory format of unsigned & signed integers is same */ \
|
||||
if(*(S) < 0) { \
|
||||
H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \
|
||||
@ -364,7 +419,7 @@
|
||||
} else \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
#define H5T_CONV_su_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_su_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
/* Assumes memory format of unsigned & signed integers is same */ \
|
||||
if(*(S) < 0) \
|
||||
*(D) = 0; \
|
||||
@ -377,7 +432,7 @@
|
||||
H5T_CONV(H5T_CONV_su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \
|
||||
}
|
||||
|
||||
#define H5T_CONV_us_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_us_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
/* Assumes memory format of unsigned & signed integers is same */ \
|
||||
if (*(S) > (ST)(D_MAX)) { \
|
||||
H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \
|
||||
@ -391,7 +446,7 @@
|
||||
} else \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
#define H5T_CONV_us_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_us_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
/* Assumes memory format of unsigned & signed integers is same */ \
|
||||
if(*(S) > (ST)(D_MAX)) \
|
||||
*(D) = (DT)(D_MAX); \
|
||||
@ -412,7 +467,7 @@
|
||||
/* Same as H5T_CONV_Xx_CORE, except that instead of using D_MAX and D_MIN
|
||||
* when an overflow occurs, use the 'float' infinity values.
|
||||
*/
|
||||
#define H5T_CONV_Ff_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_Ff_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if(*(S) > (ST)(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); \
|
||||
@ -434,7 +489,7 @@
|
||||
} else \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
#define H5T_CONV_Ff_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_Ff_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if(*(S) > (ST)(D_MAX)) \
|
||||
*(D) = (H5T_NATIVE_FLOAT_POS_INF_g); \
|
||||
else if (*(S) < (ST)(D_MIN)) \
|
||||
@ -507,7 +562,7 @@
|
||||
LO = count; \
|
||||
}
|
||||
|
||||
#define H5T_CONV_xF_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_xF_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if (sprec > dprec) { \
|
||||
unsigned low_bit_pos, high_bit_pos; \
|
||||
\
|
||||
@ -531,7 +586,7 @@
|
||||
else \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
#define H5T_CONV_xF_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_xF_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
|
||||
@ -547,7 +602,7 @@
|
||||
* (ST)(D_MAX))) is for some compilers like Sun, HP, IBM, and SGI where under
|
||||
* the same situation the "int" doesn't overflow. SLU - 2005/9/12
|
||||
*/
|
||||
#define H5T_CONV_Fx_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_Fx_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if(*(S) > (ST)(D_MAX) || (sprec < dprec && *(S) == (ST)(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); \
|
||||
@ -579,7 +634,7 @@
|
||||
else \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
#define H5T_CONV_Fx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_Fx_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
if(*(S) > (ST)(D_MAX)) \
|
||||
*(D) = (DT)(D_MAX); \
|
||||
else if(*(S) < (ST)(D_MIN)) \
|
||||
@ -597,7 +652,7 @@
|
||||
* to do them all.
|
||||
*/
|
||||
#ifndef H5_WANT_DCONV_EXCEPTION
|
||||
#define H5T_CONV_NO_EXCEPT_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
#define H5T_CONV_NO_EXCEPT_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \
|
||||
*(D) = (DT)(*(S)); \
|
||||
}
|
||||
#endif /* H5_WANT_DCONV_EXCEPTION */
|
||||
@ -718,17 +773,17 @@
|
||||
if (s_mv && d_mv) { \
|
||||
/* Alignment is required for both source and dest */ \
|
||||
s = &src_aligned; \
|
||||
H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DALIGN,POST_SALIGN,POST_DALIGN,GUTS,s,d,ST,DT,D_MIN,D_MAX) \
|
||||
H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DALIGN,POST_SALIGN,POST_DALIGN,GUTS,STYPE,DTYPE,s,d,ST,DT,D_MIN,D_MAX) \
|
||||
} else if(s_mv) { \
|
||||
/* Alignment is required only for source */ \
|
||||
s = &src_aligned; \
|
||||
H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DNOALIGN,POST_SALIGN,POST_DNOALIGN,GUTS,s,dst,ST,DT,D_MIN,D_MAX) \
|
||||
H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DNOALIGN,POST_SALIGN,POST_DNOALIGN,GUTS,STYPE,DTYPE,s,dst,ST,DT,D_MIN,D_MAX) \
|
||||
} else if(d_mv) { \
|
||||
/* Alignment is required only for destination */ \
|
||||
H5T_CONV_LOOP_OUTER(PRE_SNOALIGN,PRE_DALIGN,POST_SNOALIGN,POST_DALIGN,GUTS,src,d,ST,DT,D_MIN,D_MAX) \
|
||||
H5T_CONV_LOOP_OUTER(PRE_SNOALIGN,PRE_DALIGN,POST_SNOALIGN,POST_DALIGN,GUTS,STYPE,DTYPE,src,d,ST,DT,D_MIN,D_MAX) \
|
||||
} else { \
|
||||
/* Alignment is not required for both source and destination */ \
|
||||
H5T_CONV_LOOP_OUTER(PRE_SNOALIGN,PRE_DNOALIGN,POST_SNOALIGN,POST_DNOALIGN,GUTS,src,dst,ST,DT,D_MIN,D_MAX) \
|
||||
H5T_CONV_LOOP_OUTER(PRE_SNOALIGN,PRE_DNOALIGN,POST_SNOALIGN,POST_DNOALIGN,GUTS,STYPE,DTYPE,src,dst,ST,DT,D_MIN,D_MAX) \
|
||||
} \
|
||||
\
|
||||
/* Decrement number of elements left to convert */ \
|
||||
@ -812,16 +867,16 @@ done: \
|
||||
}
|
||||
|
||||
/* The outer wrapper for the type conversion loop, to check for an exception handling routine */
|
||||
#define H5T_CONV_LOOP_OUTER(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
#define H5T_CONV_LOOP_OUTER(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
if(cb_struct.func) { \
|
||||
H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
} \
|
||||
else { \
|
||||
H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,H5_GLUE(GUTS,_NOEX),S,D,ST,DT,D_MIN,D_MAX) \
|
||||
H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,H5_GLUE(GUTS,_NOEX),STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
}
|
||||
|
||||
/* The inner loop of the type conversion macro, actually converting the elements */
|
||||
#define H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
#define H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
for (elmtno=0; elmtno<safe; elmtno++) { \
|
||||
/* Handle source pre-alignment */ \
|
||||
H5_GLUE(H5T_CONV_LOOP_,PRE_SALIGN_GUTS)(ST) \
|
||||
@ -830,7 +885,7 @@ done: \
|
||||
H5_GLUE(H5T_CONV_LOOP_,PRE_DALIGN_GUTS)(DT) \
|
||||
\
|
||||
/* ... user-defined stuff here -- the conversion ... */ \
|
||||
H5T_CONV_LOOP_GUTS(GUTS,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
H5T_CONV_LOOP_GUTS(GUTS,STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
\
|
||||
/* Handle source post-alignment */ \
|
||||
H5_GLUE(H5T_CONV_LOOP_,POST_SALIGN_GUTS)(ST) \
|
||||
@ -847,12 +902,12 @@ done: \
|
||||
|
||||
/* Macro to call the actual "guts" of the type conversion, or call the "no exception" guts */
|
||||
#ifdef H5_WANT_DCONV_EXCEPTION
|
||||
#define H5T_CONV_LOOP_GUTS(GUTS,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
#define H5T_CONV_LOOP_GUTS(GUTS,STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
/* ... user-defined stuff here -- the conversion ... */ \
|
||||
H5_GLUE(GUTS,_CORE)(S,D,ST,DT,D_MIN,D_MAX)
|
||||
H5_GLUE(GUTS,_CORE)(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX)
|
||||
#else /* H5_WANT_DCONV_EXCEPTION */
|
||||
#define H5T_CONV_LOOP_GUTS(GUTS,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
H5_GLUE(H5T_CONV_NO_EXCEPT,_CORE)(S,D,ST,DT,D_MIN,D_MAX)
|
||||
#define H5T_CONV_LOOP_GUTS(GUTS,STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \
|
||||
H5_GLUE(H5T_CONV_NO_EXCEPT,_CORE)(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX)
|
||||
#endif /* H5_WANT_DCONV_EXCEPTION */
|
||||
|
||||
|
||||
@ -970,26 +1025,6 @@ H5FL_BLK_DEFINE_STATIC(vlen_seq);
|
||||
H5FL_BLK_DEFINE_STATIC(array_seq);
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
NAME
|
||||
H5T_init_conv_interface -- Initialize interface-specific information
|
||||
USAGE
|
||||
herr_t H5T_init_conv_interface()
|
||||
RETURNS
|
||||
Non-negative on success/Negative on failure
|
||||
DESCRIPTION
|
||||
Initializes any interface-specific data or routines. (Just calls
|
||||
H5T_init() currently).
|
||||
--------------------------------------------------------------------------*/
|
||||
static herr_t
|
||||
H5T_init_conv_interface(void)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOERR
|
||||
|
||||
FUNC_LEAVE_NOAPI(H5T_init())
|
||||
} /* H5T_init_conv_interface() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5T__conv_noop
|
||||
*
|
||||
@ -8682,7 +8717,9 @@ H5T__conv_float_ullong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
|
||||
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
|
||||
hid_t UNUSED dxpl_id)
|
||||
{
|
||||
H5_GCC_DIAG_OFF(float-equal)
|
||||
H5T_CONV_Fx(FLOAT, ULLONG, float, unsigned long long, 0, ULLONG_MAX);
|
||||
H5_GCC_DIAG_ON(float-equal)
|
||||
}
|
||||
|
||||
|
||||
@ -8734,7 +8771,9 @@ H5T__conv_double_ullong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
|
||||
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
|
||||
hid_t dxpl_id)
|
||||
{
|
||||
H5_GCC_DIAG_OFF(float-equal)
|
||||
H5T_CONV_Fx(DOUBLE, ULLONG, double, unsigned long long, 0, ULLONG_MAX);
|
||||
H5_GCC_DIAG_ON(float-equal)
|
||||
}
|
||||
|
||||
|
||||
@ -8786,7 +8825,9 @@ H5T__conv_ldouble_ullong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
|
||||
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
|
||||
hid_t dxpl_id)
|
||||
{
|
||||
H5_GCC_DIAG_OFF(float-equal)
|
||||
H5T_CONV_Fx(LDOUBLE, ULLONG, long double, unsigned long long, 0, ULLONG_MAX);
|
||||
H5_GCC_DIAG_ON(float-equal)
|
||||
}
|
||||
|
||||
|
||||
@ -8903,7 +8944,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
|
||||
/* Allocate enough space for the buffer holding temporary
|
||||
* converted value
|
||||
*/
|
||||
buf_size = (size_t)HDpow((double)2.0f, (double)src.u.f.esize) / 8 + 1;
|
||||
buf_size = (size_t) (HDpow((double)2.0f, (double)src.u.f.esize) / 8 + 1);
|
||||
int_buf = (uint8_t*)H5MM_calloc(buf_size);
|
||||
|
||||
/* Get the plist structure. Do I need to close it? */
|
||||
@ -8979,7 +9020,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
|
||||
/*
|
||||
* Find the sign bit value of the source.
|
||||
*/
|
||||
sign = H5T__bit_get_d(s, src.u.f.sign, (size_t)1);
|
||||
sign = (hssize_t) H5T__bit_get_d(s, src.u.f.sign, (size_t)1);
|
||||
|
||||
/*
|
||||
* Check for special cases: +0, -0, +Inf, -Inf, NaN
|
||||
@ -9106,16 +9147,16 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
|
||||
* the source bit field where it's located. Not expecting
|
||||
* exponent to be greater than the maximal value of hssize_t.
|
||||
*/
|
||||
expo = H5T__bit_get_d(s, src.u.f.epos, src.u.f.esize);
|
||||
expo = (hssize_t) H5T__bit_get_d(s, src.u.f.epos, src.u.f.esize);
|
||||
|
||||
/*
|
||||
* Calculate the true source exponent by adjusting according to
|
||||
* the source exponent bias.
|
||||
*/
|
||||
if (0==expo || H5T_NORM_NONE==src.u.f.norm) {
|
||||
expo -= (src.u.f.ebias-1);
|
||||
expo -= (hssize_t) (src.u.f.ebias-1);
|
||||
} else if (H5T_NORM_IMPLIED==src.u.f.norm) {
|
||||
expo -= src.u.f.ebias;
|
||||
expo -= (hssize_t) src.u.f.ebias;
|
||||
} else {
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet")
|
||||
}
|
||||
@ -9145,7 +9186,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
|
||||
* 10...010111, expo=20, expo-msize=-3. Right-shift the sequence, we get
|
||||
* 00010...10. The last three bits were dropped.
|
||||
*/
|
||||
H5T__bit_shift(int_buf, (ssize_t)(expo-src.u.f.msize), (size_t)0, buf_size * 8);
|
||||
H5T__bit_shift(int_buf, expo - (ssize_t)src.u.f.msize, (size_t)0, buf_size * 8);
|
||||
|
||||
/*
|
||||
* If expo is less than mantissa size, the frantional value is dropped off
|
||||
@ -9350,11 +9391,11 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
|
||||
if (d==dbuf)
|
||||
HDmemcpy (dp, d, dst_p->shared->size);
|
||||
if (buf_stride) {
|
||||
sp += direction * buf_stride;
|
||||
dp += direction * buf_stride;
|
||||
sp += direction * (ssize_t) buf_stride;
|
||||
dp += direction * (ssize_t) buf_stride;
|
||||
} else {
|
||||
sp += direction * src_p->shared->size;
|
||||
dp += direction * dst_p->shared->size;
|
||||
sp += direction * (ssize_t) src_p->shared->size;
|
||||
dp += direction * (ssize_t) dst_p->shared->size;
|
||||
}
|
||||
|
||||
HDmemset(int_buf, 0, buf_size);
|
||||
@ -9700,7 +9741,7 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
|
||||
|
||||
|
||||
/* Check if the exponent is too big */
|
||||
expo_max = (hsize_t)HDpow((double)2.0f, (double)dst.u.f.esize) - 1;
|
||||
expo_max = (hsize_t) (HDpow((double)2.0f, (double)dst.u.f.esize) - 1);
|
||||
|
||||
if(expo > expo_max) { /*overflows*/
|
||||
if(cb_struct.func) { /*user's exception handler. Reverse back source order*/
|
||||
@ -9779,11 +9820,11 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
|
||||
if (d==dbuf)
|
||||
HDmemcpy (dp, d, dst_p->shared->size);
|
||||
if (buf_stride) {
|
||||
sp += direction * buf_stride;
|
||||
dp += direction * buf_stride;
|
||||
sp += direction * (ssize_t) buf_stride;
|
||||
dp += direction * (ssize_t) buf_stride;
|
||||
} else {
|
||||
sp += direction * src_p->shared->size;
|
||||
dp += direction * dst_p->shared->size;
|
||||
sp += direction * (ssize_t) src_p->shared->size;
|
||||
dp += direction * (ssize_t) dst_p->shared->size;
|
||||
}
|
||||
|
||||
HDmemset(int_buf, 0, buf_size);
|
||||
|
Loading…
Reference in New Issue
Block a user