diff options
Diffstat (limited to 'test/monniaux/send_through')
-rw-r--r-- | test/monniaux/send_through/Makefile | 10 | ||||
-rw-r--r-- | test/monniaux/send_through/send_through.h | 6 | ||||
-rw-r--r-- | test/monniaux/send_through/send_through_ccomp.c | 20 | ||||
-rw-r--r-- | test/monniaux/send_through/send_through_gcc.c | 18 |
4 files changed, 54 insertions, 0 deletions
diff --git a/test/monniaux/send_through/Makefile b/test/monniaux/send_through/Makefile new file mode 100644 index 00000000..72b84654 --- /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-cos-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..03714fec --- /dev/null +++ b/test/monniaux/send_through/send_through.h @@ -0,0 +1,6 @@ +typedef double op_int_double(int, double); +typedef float op_int_float(int, float); + +double send_through_double(op_int_double f, int x, int y, double z); +float send_through_float(op_int_float f, int x, int y, float 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..a683dd82 --- /dev/null +++ b/test/monniaux/send_through/send_through_ccomp.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <math.h> +#include "send_through.h" + +double send_through_double(op_int_double f, int x, int y, double z) { + double w= f(x, f(y, z)); + int mu = 1; + return w; +} + +float send_through_float(op_int_float f, int x, int y, float z) { + float 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]=%ld\n", + x, x, x, x, x, x, lrint(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..83541cee --- /dev/null +++ b/test/monniaux/send_through/send_through_gcc.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include "send_through.h" + +double sum_int_double(int x, double y) { + return x + y; +} + +float sum_int_float(int x, float y) { + return x + y; +} + +int main() { + double x = send_through_double(sum_int_double, 2, 3, 4.5); + float y = send_through_float(sum_int_float, 2, 3, 4.5f); + printf("x[gcc] = %f\n", x); + printf("y[gcc] = %f\n", y); + print_from_ccomp(x); +} |