summaryrefslogtreecommitdiffstats
path: root/src/H5private.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5private.h')
-rw-r--r--src/H5private.h30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/H5private.h b/src/H5private.h
index 389b4a2..a8d2fa4 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -943,6 +943,9 @@ typedef off_t h5_stat_size_t;
#ifndef HDislower
#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/
#endif /* HDislower */
+#ifndef HDisnan
+ #define HDisnan(X) isnan(X)
+#endif /* HDisnan */
#ifndef HDisprint
#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/
#endif /* HDisprint */
@@ -1484,6 +1487,16 @@ extern char *strdup(const char *s);
#define HDpthread_self_ulong() ((unsigned long)pthread_self())
#endif /* HDpthread_self_ulong */
+/* Macro for "stringizing" an integer in the C preprocessor (use H5_TOSTRING) */
+/* (use H5_TOSTRING, H5_STRINGIZE is just part of the implementation) */
+#define H5_STRINGIZE(x) #x
+#define H5_TOSTRING(x) H5_STRINGIZE(x)
+
+/* 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
+
/*
* A macro for detecting over/under-flow when casting between types
*/
@@ -1517,7 +1530,7 @@ extern char *strdup(const char *s);
srctype _tmp_src = (srctype)(src); \
dsttype _tmp_dst = (dsttype)(_tmp_src); \
HDassert(_tmp_src >= 0); \
- HDassert(_tmp_src == _tmp_dst); \
+ HDassert(_tmp_src == (srctype)_tmp_dst); \
(dst) = _tmp_dst; \
}
@@ -1550,9 +1563,18 @@ extern char *strdup(const char *s);
/* Assign a variable to one of a different size (think safer dst = (dsttype)src").
* The code generated by the macro checks for overflows.
+ *
+ * Use w##x##y##z instead of H5_GLUE4(w, x, y, z) because srctype
+ * or dsttype on some systems (e.g., NetBSD 8 and earlier) may
+ * supply some standard types using a macro---e.g.,
+ * #defineĀ uint8_tĀ __uint8_t. The preprocessor will expand the
+ * macros before it evaluates H5_GLUE4(), and that will generate
+ * an unexpected name such as ASSIGN___uint8_t_TO___uint16_t.
+ * The preprocessor does not expand macros in w##x##y##z, so
+ * that will always generate the expected name.
*/
#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \
- H5_GLUE4(ASSIGN_,srctype,_TO_,dsttype)(dst,dsttype,src,srctype)\
+ ASSIGN_##srctype##_TO_##dsttype(dst,dsttype,src,srctype)\
#else /* NDEBUG */
#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \
@@ -2145,10 +2167,6 @@ static herr_t H5_INTERFACE_INIT_FUNC(void);
} /*end scope from beginning of FUNC_ENTER*/
-/* 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) ((void)sizeof(char[ !!(e) ? 1 : -1]))