diff options
Diffstat (limited to 'testsuite/libffi.closures/ffitest.h')
-rw-r--r-- | testsuite/libffi.closures/ffitest.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/testsuite/libffi.closures/ffitest.h b/testsuite/libffi.closures/ffitest.h index 95d96a8..53b009c 100644 --- a/testsuite/libffi.closures/ffitest.h +++ b/testsuite/libffi.closures/ffitest.h @@ -5,6 +5,9 @@ #include <ffi.h> #include "fficonfig.h" +#include <float.h> +#include <math.h> + #if defined HAVE_STDINT_H #include <stdint.h> #endif @@ -23,6 +26,22 @@ } \ } while(0) +#define CHECK_FLOAT_EQ(x, y) \ + do { \ + if(fabs((x) - (y)) > FLT_EPSILON){ \ + printf("Check failed CHECK_FLOAT_EQ(%s, %s)\n", #x, #y); \ + abort(); \ + } \ + } while(0) + +#define CHECK_DOUBLE_EQ(x, y) \ + do { \ + if(fabs((x) - (y)) > DBL_EPSILON){ \ + printf("Check failed CHECK_FLOAT_EQ(%s, %s)\n", #x, #y); \ + abort(); \ + } \ + } while(0) + /* Define macros so that compilers other than gcc can run the tests. */ #undef __UNUSED__ #if defined(__GNUC__) |