summaryrefslogtreecommitdiffstats
path: root/src/H5private.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5private.h')
-rw-r--r--src/H5private.h106
1 files changed, 77 insertions, 29 deletions
diff --git a/src/H5private.h b/src/H5private.h
index d392548..7a7ec53 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -439,35 +439,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 {
@@ -764,6 +735,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)
@@ -773,6 +745,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) */
@@ -1237,6 +1210,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 */
@@ -1376,6 +1352,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 */