aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/longjmp
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-03 08:17:40 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-03 08:17:40 +0100
commit1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68 (patch)
tree210ffc156c83f04fb0c61a40b4f9037d7ba8a7e1 /test/monniaux/longjmp
parent222c9047d61961db9c6b19fed5ca49829223fd33 (diff)
parent12be46d59a2483a10d77fa8ee67f7e0ca1bd702f (diff)
downloadcompcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.tar.gz
compcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.zip
Merge branch 'mppa-cse2' of gricad-gitlab.univ-grenoble-alpes.fr:sixcy/CompCert into mppa-work
Diffstat (limited to 'test/monniaux/longjmp')
-rw-r--r--test/monniaux/longjmp/example.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/monniaux/longjmp/example.c b/test/monniaux/longjmp/example.c
new file mode 100644
index 00000000..d3debfaf
--- /dev/null
+++ b/test/monniaux/longjmp/example.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <setjmp.h>
+
+jmp_buf bufferA, bufferB;
+
+void routineB(); // forward declaration
+
+void routineA()
+{
+ int r ;
+
+ printf("(A1)\n");
+
+ r = setjmp(bufferA);
+ if (r == 0) routineB();
+
+ printf("(A2) r=%d\n",r);
+
+ r = setjmp(bufferA);
+ if (r == 0) longjmp(bufferB, 20001);
+
+ printf("(A3) r=%d\n",r);
+
+ r = setjmp(bufferA);
+ if (r == 0) longjmp(bufferB, 20002);
+
+ printf("(A4) r=%d\n",r);
+}
+
+void routineB()
+{
+ int r;
+
+ printf("(B1)\n");
+
+ r = setjmp(bufferB);
+ if (r == 0) longjmp(bufferA, 10001);
+
+ printf("(B2) r=%d\n", r);
+
+ r = setjmp(bufferB);
+ if (r == 0) longjmp(bufferA, 10002);
+
+ printf("(B3) r=%d\n", r);
+
+ r = setjmp(bufferB);
+ if (r == 0) longjmp(bufferA, 10003);
+}
+
+
+int main(int argc, char **argv)
+{
+ routineA();
+ return 0;
+}