Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
verimag
synchrone
lustre-v6
Commits
acde7631
Commit
acde7631
authored
Feb 14, 2020
by
erwan
Browse files
Fix: The C code for arrays of arrays constants was generating a gcc warning
parent
6dd0fc32
Pipeline
#36569
passed with stages
in 3 minutes and 38 seconds
Changes
5
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
.merlin
View file @
acde7631
S src
S bin
S lib
S ../lutils/src
S ../rdbg/src
B _build/src
B _build/bin
B _build/lib
B ../lutils/_build/src
B ../rdbg/_build/src
bin/soc2c.ml
View file @
acde7631
(* Time-stamp: <modified the
29
/0
8
/20
19
(at 1
7:11
) by Erwan Jahier> *)
(* Time-stamp: <modified the
14
/0
2
/20
20
(at 1
4:03
) by Erwan Jahier> *)
(* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *)
...
...
@@ -119,19 +119,23 @@ let (step2c : Soc.tbl -> 'a soc_pp -> Soc.step_method -> unit) =
(
match
sp
.
soc
.
key
with
|
(
"Lustre::eq"
,
(
Array
_
)
::_,_
)
->
let
str
=
Printf
.
sprintf
" *out = memcmp((const void *) i1, (const void *) i2, %s)==0;
\n
"
ctype
in
" *out = memcmp((const void *) i1, (const void *) i2, %s)==0;
\n
"
ctype
in
sp
.
cput
str
|
(
"Lustre::eq"
,
(
Struct
_
)
::_,_
)
->
let
str
=
Printf
.
sprintf
" *out = memcmp((const void *) &i1, (const void *) &i2, %s)==0;
\n
"
ctype
in
" *out = memcmp((const void *) &i1, (const void *) &i2, %s)==0;
\n
"
ctype
in
sp
.
cput
str
|
(
"Lustre::neq"
,
(
Array
_
)
::_,_
)
->
let
str
=
Printf
.
sprintf
" *out = !memcmp((const void *) i1, (const void *) i2, %s)==0;
\n
"
ctype
in
" *out = !memcmp((const void *) i1, (const void *) i2, %s)==0;
\n
"
ctype
in
sp
.
cput
str
|
(
"Lustre::neq"
,
(
Struct
_
)
::_,_
)
->
let
str
=
Printf
.
sprintf
" *out = !memcmp((const void *) &i1, (const void *) &i2, %s)==0;
\n
"
ctype
in
" *out = !memcmp((const void *) &i1, (const void *) &i2, %s)==0;
\n
"
ctype
in
sp
.
cput
str
|
n
->
sp
.
cput
(
Soc2cDep
.
get_predef_op
n
)
)
...
...
@@ -452,31 +456,44 @@ let rec (const_to_c: Lic.const -> string) =
Indeed, arrays constant need to be defined in a .c
*)
let
(
constdef
:
LicPrg
.
t
->
string
*
string
)
=
fun
licprg
->
let
to_c
k
=
function
|
Lic
.
Extern_const_eff
_
->
""
,
""
(* | Lic.Array_const_eff (ctab, Array_type_eff(_t,s)) -> ( *)
|
Lic
.
Array_const_eff
(
ctab
,
_t
)
->
(
fun
licprg
->
let
rec
(
array_type_to_c
:
string
->
string
->
int
->
Lic
.
type_
->
string
)
=
fun
name
acc
s
t
->
match
t
with
|
Lic
.
Array_type_eff
(
t2
,
s2
)
->
array_type_to_c
name
(
Printf
.
sprintf
"%s [%i]"
acc
s
)
s2
t2
|
Lic
.
Bool_type_eff
->
Printf
.
sprintf
"_boolean %s %s[%i]"
name
acc
s
|
Lic
.
Int_type_eff
->
Printf
.
sprintf
"_integer %s %s[%i]"
name
acc
s
|
Lic
.
Real_type_eff
->
Printf
.
sprintf
"_real %s %s[%i]"
name
acc
s
|
Lic
.
External_type_eff
_
->
assert
false
|
Lic
.
Abstract_type_eff
_
->
assert
false
|
Lic
.
Enum_type_eff
_
->
assert
false
|
Lic
.
Struct_type_eff
_
->
assert
false
|
Lic
.
TypeVar
_
->
assert
false
in
let
to_c
k
=
function
|
Lic
.
Extern_const_eff
_
->
""
,
""
(* | Lic.Array_const_eff (ctab, Array_type_eff(_t,s)) -> ( *)
|
Lic
.
Array_const_eff
(
ctab
,
t
)
->
(
let
vl
=
List
.
map
const_to_c
ctab
in
let
s
=
List
.
length
vl
in
let
tab_exp
=
"{"
^
(
String
.
concat
", "
vl
)
^
"}"
in
Printf
.
sprintf
"const %s
[%i];
\n
"
(
long2s
k
)
s
,
Printf
.
sprintf
"const %s
[%i]
= %s;
\n
"
(
long2s
k
)
s
tab_exp
Printf
.
sprintf
"const %s
;
\n
"
(
array_type_to_c
(
long2s
k
)
""
s
t
)
,
Printf
.
sprintf
"const %s = %s;
\n
"
(
array_type_to_c
(
long2s
k
)
""
s
t
)
tab_exp
)
|
c
->
|
c
->
Printf
.
sprintf
"#define %s %s
\n
"
(
long2s
k
)
(
const_to_c
c
)
,
""
in
let
strh
,
strc
=
LicPrg
.
fold_consts
(
fun
k
t
(
acc_h
,
acc_c
)
->
let
h
,
c
=
to_c
k
t
in
(
acc_h
^
h
,
acc_c
^
c
))
licprg
(
""
,
""
)
in
(
if
strh
=
""
then
""
else
"
\n
// Constant definitions
\n
"
^
strh
)
,
(
if
strc
=
""
then
""
else
"
\n
// Constant definitions
\n
"
^
strc
)
in
let
strh
,
strc
=
LicPrg
.
fold_consts
(
fun
k
t
(
acc_h
,
acc_c
)
->
let
h
,
c
=
to_c
k
t
in
(
acc_h
^
h
,
acc_c
^
c
))
licprg
(
""
,
""
)
in
(
if
strh
=
""
then
""
else
"
\n
// Constant definitions
\n
"
^
strh
)
,
(
if
strc
=
""
then
""
else
"
\n
// Constant definitions
\n
"
^
strc
)
(****************************************************************************)
...
...
@@ -923,6 +940,7 @@ let (f : Lv6MainArgs.t -> Soc.key -> Soc.tbl -> LicPrg.t -> unit) =
Soc2cExtern
.
gen_files
main_soc
stbl
licprg
ext_cfile
ext_hfile
hfile
in
Lv6util
.
entete
consts_h_oc
"/*"
"*/"
;
output_string
consts_h_oc
"#include
\"
lustre_types.h
\"
"
;
output_string
consts_h_oc
const_def_h
;
Lv6util
.
entete
consts_c_oc
"/*"
"*/"
;
output_string
consts_c_oc
"#include
\"
lustre_consts.h
\"
"
;
...
...
@@ -966,7 +984,6 @@ typedef float _float;
#include <stdlib.h>
#include <string.h>
#include
\"
lustre_types.h
\"
#include
\"
lustre_consts.h
\"
"
;
...
...
lv6-ref-man/lv6-ref-man.pdf
deleted
100644 → 0
View file @
6dd0fc32
File deleted
test/lus2lic.sum
View file @
acde7631
==> lus2lic0.sum <==
Test run by jahier on Fri Feb 14 11:
11:29
Test run by jahier on Fri Feb 14 11:
52:31
Native configuration is x86_64-pc-linux-gnu
=== lus2lic0 tests ===
...
...
@@ -66,7 +66,7 @@ XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/lecte
XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/s.lus
==> lus2lic1.sum <==
Test run by jahier on Fri Feb 14 11:
11:29
Test run by jahier on Fri Feb 14 11:
52:32
Native configuration is x86_64-pc-linux-gnu
=== lus2lic1 tests ===
...
...
@@ -343,6 +343,9 @@ PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c matrice.lus {}
PASS: ./lus2lic {-2c matrice2.lus -n matrice2}
PASS: sh matrice2.sh
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c matrice2.lus {}
PASS: ./lus2lic {-2c matrix_constant.lus -n matrix_constant}
PASS: sh matrix_constant.sh
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c matrix_constant.lus {}
PASS: ./lus2lic {-2c minmax1.lus -n minmax1}
PASS: sh minmax1.sh
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c minmax1.lus {}
...
...
@@ -409,7 +412,7 @@ PASS: sh multipar.sh
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c multipar.lus {}
==> lus2lic2.sum <==
Test run by jahier on Fri Feb 14 11:
11:54
Test run by jahier on Fri Feb 14 11:
53:00
Native configuration is x86_64-pc-linux-gnu
=== lus2lic2 tests ===
...
...
@@ -749,7 +752,7 @@ PASS: sh zzz2.sh
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c zzz2.lus {}
==> lus2lic3.sum <==
Test run by jahier on Fri Feb 14 11:
12:25
Test run by jahier on Fri Feb 14 11:
53:34
Native configuration is x86_64-pc-linux-gnu
=== lus2lic3 tests ===
...
...
@@ -1147,6 +1150,10 @@ PASS: ./lus2lic {} {-lic -o matrice2.lic matrice2.lus}
PASS: ./lus2lic {-ec -o matrice2.ec matrice2.lus}
PASS: ./myec2c {-o matrice2.c matrice2.ec}
PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node matrice2.lus {}
PASS: ./lus2lic {} {-lic -o matrix_constant.lic matrix_constant.lus}
PASS: ./lus2lic {-ec -o matrix_constant.ec matrix_constant.lus}
PASS: ./myec2c {-o matrix_constant.c matrix_constant.ec}
PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node matrix_constant.lus {}
PASS: ./lus2lic {} {-lic -o minmax1.lic minmax1.lus}
PASS: ./lus2lic {-ec -o minmax1.ec minmax1.lus}
PASS: ./myec2c {-o minmax1.c minmax1.ec}
...
...
@@ -1259,7 +1266,7 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node multipar.lus {}
==> lus2lic4.sum <==
Test run by jahier on Fri Feb 14 11:
13:0
5
Test run by jahier on Fri Feb 14 11:
54:1
5
Native configuration is x86_64-pc-linux-gnu
=== lus2lic4 tests ===
...
...
@@ -1751,7 +1758,7 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node zzz2.lus {}
=== lus2lic1 Summary ===
# of expected passes 33
0
# of expected passes 33
3
# of unexpected failures 1
==> lus2lic2.sum <==
...
...
@@ -1764,7 +1771,7 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node zzz2.lus {}
==> lus2lic3.sum <==
=== lus2lic3 Summary ===
# of expected passes 49
1
# of expected passes 49
5
# of unexpected failures 5
# of unresolved testcases 1
...
...
@@ -1776,14 +1783,14 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node zzz2.lus {}
# of unexpected failures 7
===============================
# Total number of failures: 15
lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in
0
seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 2
5
seconds
lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 3
1
seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 4
0
seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 1
6
seconds
lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in
1
seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 2
8
seconds
lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 3
4
seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 4
1
seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 1
8
seconds
* Ref time:
6
0.6
6user
19.96
system
1:52.11
elapsed 7
1
%CPU (0avgtext+0avgdata 28
4016
maxresident)k
0inputs+14
1512
outputs (0major+11
144113
minor)pagefaults 0swaps
6
6.8
6user
22.59
system
2:01.44
elapsed 7
3
%CPU (0avgtext+0avgdata 28
3984
maxresident)k
0inputs+14
2256
outputs (0major+11
205615
minor)pagefaults 0swaps
* Quick time (-j 4):
67.26
user 2
1.07
system 1:1
1.03
elapsed 12
4
%CPU (0avgtext+0avgdata 28
3796
maxresident)k
0inputs+1
36976
outputs (0major+1
0867311
minor)pagefaults 0swaps
76.54
user 2
4.41
system 1:1
8.16
elapsed 12
9
%CPU (0avgtext+0avgdata 28
2848
maxresident)k
0inputs+1
41112
outputs (0major+1
1127257
minor)pagefaults 0swaps
test/should_work/matrix_constant.lus
0 → 100644
View file @
acde7631
const
f
=
false
;
const
t
=
true
;
const
mask
=
[
[
f
,
t
,
f
,
f
,
f
,
f
,
t
]
,
[
t
,
f
,
t
,
f
,
f
,
f
,
f
]
,
[
f
,
t
,
f
,
t
,
f
,
f
,
f
]
,
[
t
,
f
,
f
,
f
,
f
,
t
,
f
]];
node
matrix_constant
(
x
:
bool
^
7
^
4
)
returns
(
z
:
bool
^
7
^
4
);
let
z
=
map
<<
map
<<
or
,
7
>>,
4
>>
(
mask
,
x
);
tel
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment