summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/dfp/fe-check.h
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/dfp/fe-check.h
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/dfp/fe-check.h')
-rw-r--r--gcc/testsuite/gcc.dg/dfp/fe-check.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/dfp/fe-check.h b/gcc/testsuite/gcc.dg/dfp/fe-check.h
new file mode 100644
index 000000000..9c5f0ff8c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dfp/fe-check.h
@@ -0,0 +1,68 @@
+/* Common support for checking that appropriate floating point exceptions
+ are raised for decimal float operations. These tests are here to test
+ the software decimal float support in libgcc. */
+
+#include "dfp-dbg.h"
+#include "dfp-except.h"
+
+#if defined(DBG) || defined(DBG2)
+#include <stdio.h>
+#undef FAILURE
+#define FAILURE(NUM,KIND,EXCEPT) \
+ { printf ("failed for test %d: %s %s\n", NUM, KIND, EXCEPT); failures++; }
+#else
+#undef FAILURE
+#define FAILURE(N,K,E) __builtin_abort ();
+#endif
+
+/* This is useful when modifying the test to make sure that tests are
+ actually run. */
+#if defined(DBG2)
+#define SUCCESS(NUM,EXCEPT) \
+ { printf ("passed for test %d: %s\n", NUM, EXCEPT); }
+#else
+#define SUCCESS(N,E) ;
+#endif
+
+#define CHECKFLAG(NUM,EXCEPT,GOT,WANT) \
+ if ((WANT & EXCEPT) != (GOT & EXCEPT)) \
+ { \
+ if ((WANT & EXCEPT) != 0) \
+ FAILURE (NUM, "missing", #EXCEPT) \
+ else \
+ FAILURE (NUM, "unexpected", #EXCEPT) \
+ } \
+ else \
+ SUCCESS (NUM, #EXCEPT)
+
+void
+checkflags (int num, int want)
+{
+ int got = DFP_TEST_EXCEPT (FE_ALL_EXCEPT);
+ CHECKFLAG (num, FE_INVALID, got, want)
+ CHECKFLAG (num, FE_OVERFLOW, got, want)
+ CHECKFLAG (num, FE_UNDERFLOW, got, want)
+ CHECKFLAG (num, FE_DIVBYZERO, got, want)
+ CHECKFLAG (num, FE_INEXACT, got, want)
+}
+
+#define BINOP(NUM,OP,VAR1,VAL1,VAR2,VAL2,VAR3,EXCEPT) \
+void \
+binop_##NUM (void) \
+{ \
+ VAR1 = VAL1; \
+ VAR2 = VAL2; \
+ DFP_CLEAR_EXCEPT (FE_ALL_EXCEPT); \
+ VAR3 = VAR1 OP VAR2; \
+ checkflags (NUM, EXCEPT); \
+}
+
+#define CONVERT(NUM,FROM,TO,VALUE,EXCEPT) \
+void \
+convert_##NUM (void) \
+{ \
+ FROM = VALUE; \
+ DFP_CLEAR_EXCEPT (FE_ALL_EXCEPT); \
+ TO = FROM; \
+ checkflags (NUM, EXCEPT); \
+}