diff options
Diffstat (limited to 'src/H5private.h')
-rw-r--r-- | src/H5private.h | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/src/H5private.h b/src/H5private.h index 8cc5218..7ede979 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -27,8 +27,6 @@ #include <errno.h> #include <fcntl.h> #include <fenv.h> -#include <float.h> -#include <math.h> #include <setjmp.h> #include <signal.h> #include <stdio.h> @@ -36,6 +34,11 @@ #include <string.h> #include <time.h> +/* Define __STDC_WANT_IEC_60559_TYPES_EXT__ for _FloatN support, if available */ +#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include <float.h> +#include <math.h> + /* POSIX headers */ #ifdef H5_HAVE_SYS_TIME_H #include <sys/time.h> @@ -459,10 +462,26 @@ #define H5_DBL_ABS_EQUAL(X, Y) (fabs((X) - (Y)) < DBL_EPSILON) #define H5_LDBL_ABS_EQUAL(X, Y) (fabsl((X) - (Y)) < LDBL_EPSILON) +#ifdef H5_HAVE__FLOAT16 +#ifdef H5_HAVE_FABSF16 +#define H5_FLT16_ABS_EQUAL(X, Y) (fabsf16((X) - (Y)) < FLT16_EPSILON) +#else +#define H5_FLT16_ABS_EQUAL(X, Y) H5_FLT_ABS_EQUAL((float)X, (float)Y) +#endif +#endif + #define H5_FLT_REL_EQUAL(X, Y, M) (fabsf(((Y) - (X)) / (X)) < (M)) #define H5_DBL_REL_EQUAL(X, Y, M) (fabs(((Y) - (X)) / (X)) < (M)) #define H5_LDBL_REL_EQUAL(X, Y, M) (fabsl(((Y) - (X)) / (X)) < (M)) +#ifdef H5_HAVE__FLOAT16 +#ifdef H5_HAVE_FABSF16 +#define H5_FLT16_REL_EQUAL(X, Y, M) (fabsf16(((Y) - (X)) / (X)) < (M)) +#else +#define H5_FLT16_REL_EQUAL(X, Y, M) H5_FLT_REL_EQUAL((float)X, (float)Y, M) +#endif +#endif + /* KiB, MiB, GiB, TiB, PiB, EiB - Used in profiling and timing code */ #define H5_KB (1024.0F) #define H5_MB (1024.0F * 1024.0F) @@ -540,6 +559,19 @@ #define H5_GCC_CLANG_DIAG_ON(x) #endif +/* If necessary, create a typedef for library usage of the + * _Float16 type to avoid issues when compiling the library + * with the -pedantic flag or similar where we get warnings + * about _Float16 not being an ISO C type. + */ +#ifdef H5_HAVE__FLOAT16 +#if defined(__GNUC__) +__extension__ typedef _Float16 H5__Float16; +#else +typedef _Float16 H5__Float16; +#endif +#endif + /* Function pointer typedef for qsort */ typedef int (*H5_sort_func_cb_t)(const void *, const void *); @@ -869,7 +901,7 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifdef H5_HAVE_VASPRINTF #define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A) #else -H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); +H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); #endif #endif |