From e5d774286eb0bab87fcae05452755e38425c69a6 Mon Sep 17 00:00:00 2001
From: ploc <ploc@garoche.net>
Date: Thu, 9 May 2019 10:19:22 +0200
Subject: [PATCH] Solved issue btw mpfr and conv functions (int_to_real was not
 handled)

---
 include/conv.lusi        | 15 ++++++++-------
 include/mpfr_lustre.c    |  6 ++++++
 include/mpfr_lustre.lusi |  3 +++
 src/plugins/mpfr/mpfr.ml |  2 ++
 4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/include/conv.lusi b/include/conv.lusi
index 6fec9a0f..bd531118 100644
--- a/include/conv.lusi
+++ b/include/conv.lusi
@@ -1,9 +1,10 @@
 function real_to_int (in1: real) returns (out: int) prototype C;
-function _Floor (in1: real) returns (out: int) prototype C;
-function _floor (in1: real) returns (out: real) prototype C;
-function _Ceiling (in1: real) returns (out: int) prototype C;
-function _ceil (in1: real) returns (out: real) prototype C;
-function _Round (in1: real) returns (out: int) prototype C;
-function _round (in1: real) returns (out: real) prototype C;
-
 function int_to_real (in1: int) returns (out: real) prototype C;
+
+function _Floor (in1: real) returns (out: int) prototype C lib m;
+function _floor (in1: real) returns (out: real) prototype C lib m;
+function _Ceiling (in1: real) returns (out: int) prototype C lib m;
+function _ceil (in1: real) returns (out: real) prototype C lib m;
+function _Round (in1: real) returns (out: int) prototype C lib m;
+function _round (in1: real) returns (out: real) prototype C lib m;
+
diff --git a/include/mpfr_lustre.c b/include/mpfr_lustre.c
index 3d32f624..bea22e57 100644
--- a/include/mpfr_lustre.c
+++ b/include/mpfr_lustre.c
@@ -95,6 +95,12 @@ void MPFRClear(mpfr_t i)
   mpfr_clear(i);
 }
 
+// functions of conv
+
+void MPFRint_to_real_step (int i, mpfr_t out)
+{
+  mpfr_set_si(out, i, MPFR_RNDN);
+}
 // functions of lustrec_math
 void MPFRacos_step (mpfr_t i, 
                              mpfr_t out
diff --git a/include/mpfr_lustre.lusi b/include/mpfr_lustre.lusi
index 6f0e2c3a..801d53af 100644
--- a/include/mpfr_lustre.lusi
+++ b/include/mpfr_lustre.lusi
@@ -20,6 +20,9 @@ function MPFREq(i1, i2: real) returns (out: bool);
 
 function MPFRNeq(i1, i2: real) returns (out: bool);
 
+-- Functions already available in conv
+function MPFRint_to_real (x: int) returns (y: real);
+
 -- Functions already available in lustrec_math
 
 function MPFRacos (x: real) returns (y: real) ;
diff --git a/src/plugins/mpfr/mpfr.ml b/src/plugins/mpfr/mpfr.ml
index a3a523e7..76ea13bf 100644
--- a/src/plugins/mpfr/mpfr.ml
+++ b/src/plugins/mpfr/mpfr.ml
@@ -97,6 +97,8 @@ let base_inject_op id =
   | ">"      -> "MPFRGt"
   | "="      -> "MPFREq"
   | "!="     -> "MPFRNeq"
+  (* Conv functions *)
+  | "int_to_real" -> "MPFRint_to_real"
   (* Math library functions *)
   | "acos" -> "MPFRacos"
   | "acosh" -> "MPFRacosh"
-- 
GitLab