aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/longjmp
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-04-11 08:08:26 +0200
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-04-11 08:08:26 +0200
commit466767d23cbc816b5787e6768e5f9a98a95abca9 (patch)
treed08adb311cebc8f5a897c8d8632a7b0060dc06fb /test/monniaux/longjmp
parent696d150a5ec5387e78b2aae941a77a190af58562 (diff)
downloadcompcert-kvx-466767d23cbc816b5787e6768e5f9a98a95abca9.tar.gz
compcert-kvx-466767d23cbc816b5787e6768e5f9a98a95abca9.zip
fix types for k1 builtins
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;
+}