aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@gcc.gnu.org>2013-11-14 18:30:19 +0000
committerUlrich Weigand <uweigand@gcc.gnu.org>2013-11-14 18:30:19 +0000
commit4f883df12fd8225c33e41eb34a43d5b05bd8a18c (patch)
treeea9be288c6c7207046a70f94d49166dc787036d8
parent8c8b21e4f737fdf0e75fcc4a414eee0d4ce56113 (diff)
downloadgcc-4f883df12fd8225c33e41eb34a43d5b05bd8a18c.zip
gcc-4f883df12fd8225c33e41eb34a43d5b05bd8a18c.tar.gz
gcc-4f883df12fd8225c33e41eb34a43d5b05bd8a18c.tar.bz2
Forgot to add file in last commit.
From-SVN: r204802
-rw-r--r--gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C54
1 files changed, 54 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C b/gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C
new file mode 100644
index 0000000..3256173
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C
@@ -0,0 +1,54 @@
+// { dg-do run { target { powerpc64*-*-linux* } } }
+// { dg-options "-fexceptions -fnon-call-exceptions" }
+
+#include <signal.h>
+#include <stdlib.h>
+#include <fenv.h>
+
+#define SET_CR(R,V) __asm__ __volatile__ ("mtcrf %0,%1" : : "n" (1<<(7-R)), "r" (V<<(4*(7-R))) : "cr" #R)
+#define GET_CR(R) ({ int tmp; __asm__ __volatile__ ("mfcr %0" : "=r" (tmp)); (tmp >> 4*(7-R)) & 15; })
+
+void sighandler (int signo, siginfo_t * si, void * uc)
+{
+ SET_CR(2, 3);
+ SET_CR(3, 2);
+ SET_CR(4, 1);
+
+ throw 0;
+}
+
+float test (float a, float b) __attribute__ ((__noinline__));
+float test (float a, float b)
+{
+ float x;
+ asm ("mtcrf %1,%2" : "=f" (x) : "n" (1 << (7-3)), "r" (0), "0" (b) : "cr3");
+ return a / x;
+}
+
+int main ()
+{
+ struct sigaction sa;
+ int status;
+
+ sa.sa_sigaction = sighandler;
+ sa.sa_flags = SA_SIGINFO;
+
+ status = sigaction (SIGFPE, & sa, NULL);
+
+ feenableexcept (FE_DIVBYZERO);
+
+ SET_CR(2, 6);
+ SET_CR(3, 9);
+ SET_CR(4, 12);
+
+ try {
+ test (1, 0);
+ }
+ catch (...) {
+ return GET_CR(2) != 6 || GET_CR(3) != 9 || GET_CR(4) != 12;
+ }
+
+ return 1;
+}
+
+