aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/lustrev4_lustrec_heater_control/heater_control_main.c
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-05-15 13:13:46 +0200
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-05-15 13:13:46 +0200
commit8a456dbb08948c1c24076cea6b87dc938276263b (patch)
tree88a203b846f4d01dc6a673dec12027b4a6c499ce /test/monniaux/lustrev4_lustrec_heater_control/heater_control_main.c
parent76abb605749d1b8ddcc842cecb258fa755d63ccf (diff)
downloadcompcert-kvx-8a456dbb08948c1c24076cea6b87dc938276263b.tar.gz
compcert-kvx-8a456dbb08948c1c24076cea6b87dc938276263b.zip
example from Lustre v4 compiled with ONERA's lustrec compiler
Diffstat (limited to 'test/monniaux/lustrev4_lustrec_heater_control/heater_control_main.c')
-rw-r--r--test/monniaux/lustrev4_lustrec_heater_control/heater_control_main.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/monniaux/lustrev4_lustrec_heater_control/heater_control_main.c b/test/monniaux/lustrev4_lustrec_heater_control/heater_control_main.c
new file mode 100644
index 00000000..f985e2af
--- /dev/null
+++ b/test/monniaux/lustrev4_lustrec_heater_control/heater_control_main.c
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <assert.h>
+#include "heater_control_alloc.h"
+#include "../dm_random.c"
+
+static double _get_double(void) {
+ return (dm_random_uint32()%70000U) * 1E-3 -20.0;
+}
+
+static void _put_bool(const char *name, _Bool b) {
+ printf("%s: %d\n", name, b);
+}
+
+/* C code generated by lustrec
+ Version number 1.6-@GITBRANCH@
+ Code is C99 compliant
+ Using (double) floating-point numbers */
+
+int main (int argc, char *argv[]) {
+
+ /* Main memory allocation */
+ heater_control_ALLOC(static,main_mem);
+
+ /* Initialize the main memory */
+ heater_control_reset(&main_mem);
+
+ /* Infinite loop */
+ while(1){
+ double T = _get_double();
+ double T1 = _get_double();
+ double T2 = _get_double();
+ double T3 = _get_double();
+ _Bool Heat_on;
+ heater_control_step (T, T1, T2, T3, &Heat_on, &main_mem);
+ _put_bool("Heat_on", Heat_on);
+ }
+
+
+ return 1;
+}