diff options
Diffstat (limited to 'src/H5private.h')
-rw-r--r-- | src/H5private.h | 114 |
1 files changed, 84 insertions, 30 deletions
diff --git a/src/H5private.h b/src/H5private.h index 27a8f65..998b7c3 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -436,35 +436,6 @@ #endif /* - * A macro for detecting over/under-flow when casting between types - */ -#ifndef NDEBUG -#define H5_CHECK_OVERFLOW(var, vartype, casttype) \ -{ \ - casttype _tmp_overflow = (casttype)(var); \ - assert((var) == (vartype)_tmp_overflow); \ -} -#else /* NDEBUG */ -#define H5_CHECK_OVERFLOW(var, vartype, casttype) -#endif /* NDEBUG */ - -/* - * A macro for detecting over/under-flow when assigning between types - */ -#ifndef NDEBUG -#define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \ -{ \ - srctype _tmp_overflow = (srctype)(src); \ - dsttype _tmp_overflow2 = (dsttype)(_tmp_overflow); \ - assert((dsttype)_tmp_overflow == _tmp_overflow2); \ - (dst) = _tmp_overflow2; \ -} -#else /* NDEBUG */ -#define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \ - (dst) = (dsttype)(src); -#endif /* NDEBUG */ - -/* * Data types and functions for timing certain parts of the library. */ typedef struct { @@ -758,6 +729,7 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #endif /* HDstat */ typedef struct stat64 h5_stat_t; typedef off64_t h5_stat_size_t; + #define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF64_T #else /* H5_SIZEOF_OFF_T!=8 && ... */ #ifndef HDfstat #define HDfstat(F,B) fstat(F,B) @@ -767,6 +739,7 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #endif /* HDstat */ typedef struct stat h5_stat_t; typedef off_t h5_stat_size_t; + #define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF_T #endif /* H5_SIZEOF_OFF_T!=8 && ... */ #endif /* !defined(HDfstat) || !defined(HDstat) */ @@ -1231,6 +1204,9 @@ H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); #ifndef HDstrtoul #define HDstrtoul(S,R,N) strtoul(S,R,N) #endif /* HDstrtoul */ +#ifndef HDstrtoull + #define HDstrtoull(S,R,N) strtoull(S,R,N) +#endif /* HDstrtoul */ #ifndef HDstrxfrm #define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) #endif /* HDstrxfrm */ @@ -1370,6 +1346,78 @@ extern char *strdup(const char *s); #define HDpthread_self_ulong() ((unsigned long)pthread_self()) #endif /* HDpthread_self_ulong */ +/* + * A macro for detecting over/under-flow when casting between types + */ +#ifndef NDEBUG +#define H5_CHECK_OVERFLOW(var, vartype, casttype) \ +{ \ + casttype _tmp_overflow = (casttype)(var); \ + assert((var) == (vartype)_tmp_overflow); \ +} +#else /* NDEBUG */ +#define H5_CHECK_OVERFLOW(var, vartype, casttype) +#endif /* NDEBUG */ + +/* + * A macro for detecting over/under-flow when assigning between types + */ +#ifndef NDEBUG +#define ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) \ +{ \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + assert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ +} + +#define ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) \ + (dst) = (dsttype)(src); + +#define ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \ +{ \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + assert(_tmp_src >= 0); \ + assert(_tmp_src == _tmp_dst); \ + (dst) = _tmp_dst; \ +} + +#define ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \ + (dst) = (dsttype)(src); + +#define ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \ +{ \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + assert(_tmp_dst >= 0); \ + assert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ +} + +#define ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \ +{ \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + assert(_tmp_src >= 0); \ + assert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ +} + +#define ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) \ + (dst) = (dsttype)(src); + +/* Include the generated overflow header file */ +#include "H5overflow.h" + +#define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \ + H5_GLUE4(ASSIGN_,srctype,_TO_,dsttype)(dst,dsttype,src,srctype)\ + +#else /* NDEBUG */ +#define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \ + (dst) = (dsttype)(src); +#endif /* NDEBUG */ + #if defined(H5_HAVE_WINDOW_PATH) /* directory delimiter for Windows: slash and backslash are acceptable on Windows */ @@ -1687,6 +1735,7 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); #define FUNC_ENTER_COMMON(func_name,asrt) \ static const char FUNC[]=#func_name; \ + hbool_t err_occurred = FALSE; \ FUNC_ENTER_COMMON_NOFUNC(func_name,asrt); /* Threadsafety initialization code for API routines */ @@ -1856,7 +1905,9 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); #define FUNC_LEAVE_API(ret_value) \ FINISH_MPE_LOG; \ H5TRACE_RETURN(ret_value); \ - H5_POP_FUNC; \ + H5_POP_FUNC \ + if(err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ FUNC_LEAVE_API_THREADSAFE \ return (ret_value); \ } /*end scope from end of FUNC_ENTER*/ \ @@ -1865,6 +1916,8 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); #define FUNC_LEAVE_API_NOFS(ret_value) \ FINISH_MPE_LOG; \ H5TRACE_RETURN(ret_value); \ + if(err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ FUNC_LEAVE_API_THREADSAFE \ return (ret_value); \ } /*end scope from end of FUNC_ENTER*/ \ @@ -1896,6 +1949,7 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); /* Macro for "glueing" together items, for re-scanning macros */ #define H5_GLUE(x,y) x##y #define H5_GLUE3(x,y,z) x##y##z +#define H5_GLUE4(w,x,y,z) w##x##y##z /* Compile-time "assert" macro */ #define HDcompile_assert(e) do { enum { compile_assert__ = 1 / (e) }; } while(0) |