aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-02-06 19:06:43 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-02-06 19:06:43 +0100
commitca045c6110ecaf75221e8f8698c9888d232c2e6d (patch)
treec47dc42a107c053966444333ba229364f394439a /test/monniaux
parente8b35c4b975a46a5dc5e0c022897359cbfe2d72b (diff)
downloadcompcert-kvx-ca045c6110ecaf75221e8f8698c9888d232c2e6d.tar.gz
compcert-kvx-ca045c6110ecaf75221e8f8698c9888d232c2e6d.zip
test for float/double parameter passing
Diffstat (limited to 'test/monniaux')
-rw-r--r--test/monniaux/send_through/Makefile10
-rw-r--r--test/monniaux/send_through/send_through.h4
-rw-r--r--test/monniaux/send_through/send_through_ccomp.c14
-rw-r--r--test/monniaux/send_through/send_through_gcc.c12
4 files changed, 40 insertions, 0 deletions
diff --git a/test/monniaux/send_through/Makefile b/test/monniaux/send_through/Makefile
new file mode 100644
index 00000000..9e5a0cfd
--- /dev/null
+++ b/test/monniaux/send_through/Makefile
@@ -0,0 +1,10 @@
+send_through: send_through_gcc.k1c.o send_through_ccomp.k1c.o
+ ../../../ccomp -Wall $+ -o $@ -lm
+
+send_through_gcc.k1c.o send_through_ccomp.k1c.o: send_through.h
+
+send_through_gcc.k1c.o : send_through_gcc.c
+ k1-mbr-gcc -Wall -Wextra -std=c99 -Werror=implicit -c $< -o $@
+
+send_through_ccomp.k1c.o : send_through_ccomp.c
+ ../../../ccomp -Wall -fnone -fvararg-calls -c $< -o $@
diff --git a/test/monniaux/send_through/send_through.h b/test/monniaux/send_through/send_through.h
new file mode 100644
index 00000000..54b6c052
--- /dev/null
+++ b/test/monniaux/send_through/send_through.h
@@ -0,0 +1,4 @@
+typedef double op_int_double(int, double);
+
+double send_through(op_int_double f, int x, int y, double z);
+void print_from_ccomp(double x);
diff --git a/test/monniaux/send_through/send_through_ccomp.c b/test/monniaux/send_through/send_through_ccomp.c
new file mode 100644
index 00000000..99cb64c4
--- /dev/null
+++ b/test/monniaux/send_through/send_through_ccomp.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <math.h>
+#include "send_through.h"
+
+double send_through(op_int_double f, int x, int y, double z) {
+ double w= f(x, f(y, z));
+ int mu = 1;
+ return w;
+}
+
+void print_from_ccomp(double x) {
+ printf("x=%e x=%f x=%g x=%.03e x=%.03f x=%.03g x[rounded]=%d\n",
+ x, x, x, x, x, x, rint(x));
+}
diff --git a/test/monniaux/send_through/send_through_gcc.c b/test/monniaux/send_through/send_through_gcc.c
new file mode 100644
index 00000000..be70a566
--- /dev/null
+++ b/test/monniaux/send_through/send_through_gcc.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include "send_through.h"
+
+double sum_int_double(int x, double y) {
+ return x + y;
+}
+
+int main() {
+ double x = send_through(sum_int_double, 2, 3, 4.5);
+ printf("x[gcc] = %f\n", x);
+ print_from_ccomp(x);
+}