Skip to content
Snippets Groups Projects
Commit 3ec70885 authored by Julien Signoles's avatar Julien Signoles
Browse files

[e-acsl] implement options for direct linking with GMP

[e-acsl] Makefile's target 'install'
[e-acsl] test GMP linkage in non-regression suite ('make tests' now requires GMP >= 4.3.2)
[e-acsl] fixed bugs of GMP compatibility
parent d518b849
No related branches found
No related tags found
No related merge requests found
Showing
with 567 additions and 435 deletions
...@@ -44,7 +44,6 @@ $(PLUGIN_DIR)/local_config.ml: $(PLUGIN_DIR)/Makefile.in ...@@ -44,7 +44,6 @@ $(PLUGIN_DIR)/local_config.ml: $(PLUGIN_DIR)/Makefile.in
$(ECHO) "(* This file was automatically generated from $<. Don't edit it. *)" >> $@ $(ECHO) "(* This file was automatically generated from $<. Don't edit it. *)" >> $@
$(ECHO) "let may_compile_with_cc = @MAY_COMPILE_WITH_CC@" >> $@ $(ECHO) "let may_compile_with_cc = @MAY_COMPILE_WITH_CC@" >> $@
$(ECHO) "let may_use_assert = @MAY_USE_ASSERT@" >> $@ $(ECHO) "let may_use_assert = @MAY_USE_ASSERT@" >> $@
$(ECHO) "let gmpsrc_dir = \"@GMPSRC_DIR@\"" >> $@
$(CHMOD_RO) $@ $(CHMOD_RO) $@
PLUGIN_GENERATED:= $(PLUGIN_DIR)/local_config.ml PLUGIN_GENERATED:= $(PLUGIN_DIR)/local_config.ml
...@@ -67,6 +66,14 @@ tests:: tests/test_config ...@@ -67,6 +66,14 @@ tests:: tests/test_config
endif endif
###########
# Install #
###########
install::
$(PRINT_CP) E-ACSL share files
$(CP) -R share/e-acsl $(FRAMAC_SHARE)
################ ################
# Generic part # # Generic part #
################ ################
......
...@@ -60,7 +60,7 @@ fi ...@@ -60,7 +60,7 @@ fi
if test -z $HAVE_STDIO_H; then if test -z $HAVE_STDIO_H; then
MAY_COMPILE_WITH_CC=false MAY_COMPILE_WITH_CC=false
MAY_RUN_TESTS=no MAY_RUN_TESTS=no
AC_MSG_WARN([stdio.h missing: cannot use option -e-acsl-link-headers.]) AC_MSG_WARN([stdio.h missing: cannot use option -e-acsl-include-headers.])
AC_MSG_WARN([stdio.h missing: non-regression tests unavailable.]) AC_MSG_WARN([stdio.h missing: non-regression tests unavailable.])
fi fi
...@@ -84,31 +84,10 @@ AC_CHECK_LIB(gmp,__gmpz_init,HAVE_GMP=yes,) # also set LIBS ...@@ -84,31 +84,10 @@ AC_CHECK_LIB(gmp,__gmpz_init,HAVE_GMP=yes,) # also set LIBS
if test -z $HAVE_GMP; then if test -z $HAVE_GMP; then
MAY_COMPILE_WITH_CC=false MAY_COMPILE_WITH_CC=false
MAY_RUN_TESTS=no MAY_RUN_TESTS=no
AC_MSG_WARN([GMP library missing: cannot use E-ACSL option -e-acsl-link-headers.]) AC_MSG_WARN([GMP library missing: cannot use E-ACSL option -e-acsl-include-headers.])
AC_MSG_WARN([GMP library missing: non-regression tests unavailable.]) AC_MSG_WARN([GMP library missing: non-regression tests unavailable.])
fi fi
# GMP sources
#############
GMPSRC_DIR=
AC_ARG_WITH(gmp-src,
AC_HELP_STRING(
[--with-gmp-src],
[directory containing the source of the GMP library]
))
if test "$with_gmp_src" = "yes" -o "$with_gmp_src" = "no" -o "$with_gmp_src" = ""; \
then
AC_MSG_WARN([GMP sources missing: cannot use E-ACSL option -e-acsl-link-gmpsrc. Set the directory containing these sources with --with-gmp-src=<dirname>. Sources are available from ftp://ftp.gmplib.org/pub/gmp-4.3.2/gmp-4.3.2.tar.bz2])
else
GMPSRC_DIR=$with_gmp_src
AC_CHECK_FILE($GMPSRC_DIR/mpz/init.c,
AC_MSG_NOTICE([GMP sources got from $GMPSRC_DIR]),
AC_MSG_ERROR([Directory $GMPSRC_DIR does not contain GMP sources.]))
fi
####################### #######################
# Generating Makefile # # Generating Makefile #
####################### #######################
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
val may_compile_with_cc: bool val may_compile_with_cc: bool
val may_use_assert: bool val may_use_assert: bool
val gmpsrc_dir: string
(* (*
Local Variables: Local Variables:
......
...@@ -56,10 +56,7 @@ module Resulting_projects = ...@@ -56,10 +56,7 @@ module Resulting_projects =
let size = 7 let size = 7
let kind = `Correctness let kind = `Correctness
let dependencies = let dependencies =
[ Ast.self; [ Ast.self; Options.Include_headers.self; Options.Use_assert.self ]
Options.H_link.self;
Options.Gmpsrc_link.self;
Options.Use_assert.self ]
end) end)
let generate_code = let generate_code =
...@@ -67,7 +64,20 @@ let generate_code = ...@@ -67,7 +64,20 @@ let generate_code =
(fun name -> (fun name ->
try try
let visit prj = Visit.do_visit ~prj true in let visit prj = Visit.do_visit ~prj true in
File.create_rebuilt_project_from_visitor name visit let preprocess =
if Options.Include_headers.get () then
if Local_config.may_compile_with_cc then begin
if Local_config.may_use_assert then Options.Use_assert.on ();
true
end else begin
Options.warning "option `-e-acsl-include-headers' not available \
(see configure warning) : ignoring it.";
false
end
else
false
in
File.create_rebuilt_project_from_visitor ~preprocess name visit
with Visit.Typing_error s -> with Visit.Typing_error s ->
Options.abort ~current:true "%s" s) Options.abort ~current:true "%s" s)
......
...@@ -46,24 +46,15 @@ module Project_name = ...@@ -46,24 +46,15 @@ module Project_name =
let arg_name = "prj" let arg_name = "prj"
end) end)
module H_link = module Include_headers =
False False
(struct (struct
let option_name = "-e-acsl-link-headers" let option_name = "-e-acsl-include-headers"
let help = "include standard headers in the new project \ let help = "include standard headers in the new project \
(unset by default)" (unset by default)"
let kind = `Correctness let kind = `Correctness
end) end)
module Gmpsrc_link =
False
(struct
let option_name = "-e-acsl-link-gmpsrc"
let help = "link against GMP source code in the new project \
(unset by default)"
let kind = `Correctness
end)
module Use_assert = module Use_assert =
False False
(struct (struct
......
...@@ -26,8 +26,7 @@ include S (** implementation of Log.S for E-ACSL *) ...@@ -26,8 +26,7 @@ include S (** implementation of Log.S for E-ACSL *)
module Check: BOOL module Check: BOOL
module Project_name: STRING module Project_name: STRING
module H_link: BOOL module Include_headers: BOOL
module Gmpsrc_link: BOOL
module Use_assert: BOOL module Use_assert: BOOL
(* (*
......
...@@ -19,13 +19,12 @@ ...@@ -19,13 +19,12 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
let text = let put_file_in_buffer fname buf =
let buf = Buffer.create 97 in
fun () ->
if Buffer.length buf = 0 then begin
let fname = Filename.concat Config.datadir "e_acsl.h" in
try try
let cin = open_in fname in let cin =
open_in
(Filename.concat Config.datadir (Filename.concat "e-acsl" fname))
in
try try
while true do while true do
let l = input_line cin in let l = input_line cin in
...@@ -36,6 +35,25 @@ let text = ...@@ -36,6 +35,25 @@ let text =
close_in cin close_in cin
with Sys_error s -> with Sys_error s ->
Options.abort "cannot read file `%s': %s" fname s Options.abort "cannot read file `%s': %s" fname s
(* TODO: must be project-compliant. The memoized buffer should be reset when we
have to redo the visitor in a different setting. *)
let add_include buf hfile =
Buffer.add_string buf (Format.sprintf "#include %S\n" hfile)
let text =
let buf = Buffer.create 97 in
fun () ->
if Buffer.length buf = 0 then begin
if Options.Include_headers.get () then begin
add_include buf "stdio.h";
if Options.Use_assert.get () then add_include buf "assert.h";
add_include buf "gmp.h";
end else
put_file_in_buffer "e_acsl_gmp_types.h" buf;
put_file_in_buffer "e_acsl_gmp.h" buf;
put_file_in_buffer "e_acsl.h" buf
end; end;
Buffer.contents buf Buffer.contents buf
......
// TODO: remplacer par un e_acsl.h.in
// faire gnrer par le makefile un e_acsl.h
// avec des #include "FRAMAC_SHARE/libc/stdio.h", etc
// [TODO] ne pas gnrer les typedef si on veut linker avec GMP derrire
// [TODO] utiliser un champ modle de type integer pour modliser
// l'entier exact correspondant un mpz_t.
// Not yet implemented in ACSL.
/************************/
/* Standard C functions */
/************************/
/*@ terminates \false;
@ assigns \nothing;
@ ensures \false; */
extern void exit(int status);
/*@ assigns \nothing; */
extern int printf(const char *, ...);
/*****************************/
/* Dedicated E-ACSL function */
/*****************************/
void e_acsl_fail(char *msg) { printf("%s\n", msg); exit(1); }
// TODO: remplacer par un e_acsl.h.in
// faire gnrer par le makefile un e_acsl.h
// avec des #include "FRAMAC_SHARE/libc/stdio.h", etc
/*************/
/* GMP types */
/*************/
// [TODO] ne pas gnrer les typedef si on veut linker avec GMP derrire
// [TODO] utiliser un champ modle de type integer pour modliser
// l'entier exact correspondant un mpz_t.
// Not yet implemented in ACSL.
typedef struct {
int _mp_alloc;
int _mp_size;
unsigned long int *_mp_d;
} __mpz_struct;
typedef __mpz_struct mpz_t[1];
/*****************/ /*****************/
/* GMP functions */ /* GMP functions */
...@@ -40,7 +19,7 @@ extern void mpz_init_set_si(mpz_t z, signed long int n); ...@@ -40,7 +19,7 @@ extern void mpz_init_set_si(mpz_t z, signed long int n);
/*@ ensures \valid(z); /*@ ensures \valid(z);
@ assigns *z; */ @ assigns *z; */
extern void mpz_init_set_str(mpz_t z, const char *str, int base); extern int mpz_init_set_str(mpz_t z, const char *str, int base);
// finalizer // finalizer
...@@ -63,52 +42,34 @@ extern int mpz_comp(mpz_t z1, const mpz_t z2); ...@@ -63,52 +42,34 @@ extern int mpz_comp(mpz_t z1, const mpz_t z2);
/*@ requires \valid(z1); /*@ requires \valid(z1);
@ requires \valid(z2); @ requires \valid(z2);
@ assigns *z1; */ @ assigns *z1; */
extern int mpz_neg(mpz_t z1, const mpz_t z2); extern void mpz_neg(mpz_t z1, const mpz_t z2);
/*@ requires \valid(z1); /*@ requires \valid(z1);
@ requires \valid(z2); @ requires \valid(z2);
@ requires \valid(z3); @ requires \valid(z3);
@ assigns *z1; */ @ assigns *z1; */
extern int mpz_add(mpz_t z1, const mpz_t z2, const mpz_t z3); extern void mpz_add(mpz_t z1, const mpz_t z2, const mpz_t z3);
/*@ requires \valid(z1); /*@ requires \valid(z1);
@ requires \valid(z2); @ requires \valid(z2);
@ requires \valid(z3); @ requires \valid(z3);
@ assigns *z1; */ @ assigns *z1; */
extern int mpz_sub(mpz_t z1, const mpz_t z2, const mpz_t z3); extern void mpz_sub(mpz_t z1, const mpz_t z2, const mpz_t z3);
/*@ requires \valid(z1); /*@ requires \valid(z1);
@ requires \valid(z2); @ requires \valid(z2);
@ requires \valid(z3); @ requires \valid(z3);
@ assigns *z1; */ @ assigns *z1; */
extern int mpz_mul(mpz_t z1, const mpz_t z2, const mpz_t z3); extern void mpz_mul(mpz_t z1, const mpz_t z2, const mpz_t z3);
/*@ requires \valid(z1); /*@ requires \valid(z1);
@ requires \valid(z2); @ requires \valid(z2);
@ requires \valid(z3); @ requires \valid(z3);
@ assigns *z1; */ @ assigns *z1; */
extern int mpz_cdiv_q(mpz_t z1, const mpz_t z2, const mpz_t z3); extern void mpz_cdiv_q(mpz_t z1, const mpz_t z2, const mpz_t z3);
/*@ requires \valid(z1); /*@ requires \valid(z1);
@ requires \valid(z2); @ requires \valid(z2);
@ requires \valid(z3); @ requires \valid(z3);
@ assigns *z1; */ @ assigns *z1; */
extern int mpz_mod(mpz_t z1, const mpz_t z2, const mpz_t z3); extern void mpz_mod(mpz_t z1, const mpz_t z2, const mpz_t z3);
/************************/
/* Standard C functions */
/************************/
/*@ terminates \false;
@ assigns \nothing;
@ ensures \false; */
extern void exit(int status);
/*@ assigns \nothing; */
extern int printf(const char *, ...);
/*****************************/
/* Dedicated E-ACSL function */
/*****************************/
void e_acsl_fail(char *msg) { printf(msg); exit(1); }
/*************/
/* GMP types */
/*************/
typedef struct {
int _mp_alloc;
int _mp_size;
unsigned long int *_mp_d;
} __mpz_struct;
typedef __mpz_struct mpz_t[1];
/* run.config /* run.config
COMMENT: addrOf */ COMMENT: addrOf
EXECNOW: LOG gen_addrOf.c BIN gen_addrOf.out FRAMAC_SHARE=./share frama-c -load-module E_ACSL ./tests/e-acsl-runtime/addrOf.i -e-acsl-project p -e-acsl-include-headers -then-on p -print -ocode ./tests/e-acsl-runtime/result/gen_addrOf.c > /dev/null && gcc -o ./tests/e-acsl-runtime/result/gen_addrOf.out ./tests/e-acsl-runtime/result/gen_addrOf.c
*/
void main() { void main() {
int x = 0; int x = 0;
/*@ assert &x == &x; */ ; /*@ assert &x == &x; */ ;
......
/* run.config /* run.config
COMMENT: arithmetic operations COMMENT: arithmetic operations
COMMENT: add the last assertion when fixing BTS #751 */ COMMENT: add the last assertion when fixing BTS #751
EXECNOW: LOG gen_arith.c BIN gen_arith.out FRAMAC_SHARE=./share frama-c -load-module E_ACSL ./tests/e-acsl-runtime/arith.i -e-acsl-project p -e-acsl-include-headers -then-on p -print -ocode ./tests/e-acsl-runtime/result/gen_arith.c > /dev/null && gcc -o ./tests/e-acsl-runtime/result/gen_arith.out -lgmp ./tests/e-acsl-runtime/result/gen_arith.c
*/
void main() { void main() {
int x = -3; int x = -3;
......
/* run.config /* run.config
COMMENT: cast */ COMMENT: cast
EXECNOW: LOG gen_cast.c BIN gen_cast.out FRAMAC_SHARE=./share frama-c -load-module E_ACSL ./tests/e-acsl-runtime/cast.i -e-acsl-project p -e-acsl-include-headers -then-on p -print -ocode ./tests/e-acsl-runtime/result/gen_cast.c > /dev/null && gcc -o ./tests/e-acsl-runtime/result/gen_cast.out ./tests/e-acsl-runtime/result/gen_cast.c
*/
void main() { void main() {
long x = 0; long x = 0;
......
/* run.config /* run.config
COMMENT: comparison operators */ COMMENT: comparison operators
EXECNOW: LOG gen_comparison.c BIN gen_comparison.out FRAMAC_SHARE=./share frama-c -load-module E_ACSL ./tests/e-acsl-runtime/comparison.i -e-acsl-project p -e-acsl-include-headers -then-on p -print -ocode ./tests/e-acsl-runtime/result/gen_comparison.c > /dev/null && gcc -o ./tests/e-acsl-runtime/result/gen_comparison.out -lgmp ./tests/e-acsl-runtime/result/gen_comparison.c
*/
void main() { void main() {
int x = 0, y = 1; int x = 0, y = 1;
......
/* run.config /* run.config
COMMENT: empty file COMMENT: empty file
OPT: -e-acsl-project p -then-on p -print */ OPT: -e-acsl-check -e-acsl-project p -then-on p -print */
/* run.config /* run.config
COMMENT: assert \false */ COMMENT: assert \false
EXECNOW: LOG gen_false.c BIN gen_false.out FRAMAC_SHARE=./share frama-c -load-module E_ACSL ./tests/e-acsl-runtime/false.i -e-acsl-project p -e-acsl-include-headers -then-on p -print -ocode ./tests/e-acsl-runtime/result/gen_false.c > /dev/null && gcc -o ./tests/e-acsl-runtime/result/gen_false.out ./tests/e-acsl-runtime/result/gen_false.c
*/
void main() { void main() {
int x = 0; int x = 0;
if (x) /*@ assert \false; */ ; if (x) /*@ assert \false; */ ;
......
/* run.config /* run.config
COMMENT: integer constant COMMENT: integer constant
COMMENT: waiting for fixing BTS #745 */ COMMENT: waiting for fixing BTS #745
EXECNOW: LOG gen_integer_constant.c BIN gen_integer_constant.out FRAMAC_SHARE=./share frama-c -load-module E_ACSL ./tests/e-acsl-runtime/integer_constant.i -e-acsl-project p -e-acsl-include-headers -then-on p -print -ocode ./tests/e-acsl-runtime/result/gen_integer_constant.c > /dev/null && gcc -o ./tests/e-acsl-runtime/result/gen_integer_constant.out -lgmp ./tests/e-acsl-runtime/result/gen_integer_constant.c
*/
void main() { void main() {
/*@ assert 0 == 0; */ /*@ assert 0 == 0; */
/*@ assert 0 != 1; */ /*@ assert 0 != 1; */
......
/* run.config /* run.config
COMMENT: predicate [!p] */ COMMENT: predicate [!p]
EXECNOW: LOG gen_not.c BIN gen_not.out FRAMAC_SHARE=./share frama-c -load-module E_ACSL ./tests/e-acsl-runtime/not.i -e-acsl-project p -e-acsl-include-headers -then-on p -print -ocode ./tests/e-acsl-runtime/result/gen_not.c > /dev/null && gcc -o ./tests/e-acsl-runtime/result/gen_not.out ./tests/e-acsl-runtime/result/gen_not.c
*/
void main() { void main() {
int x = 0; int x = 0;
/*@ assert ! x; */ /*@ assert ! x; */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
[value] Computing initial state [value] Computing initial state
[value] Initial state computed [value] Initial state computed
[value] Values of globals at initialization [value] Values of globals at initialization
PROJECT_FILE:121:[value] Assertion got status valid. PROJECT_FILE.i:121:[value] Assertion got status valid.
[value] Recording results for main [value] Recording results for main
[value] done for function main [value] done for function main
[dominators] computing for function main [dominators] computing for function main
...@@ -19,7 +19,7 @@ extern void exit(int status ) ; ...@@ -19,7 +19,7 @@ extern void exit(int status ) ;
extern int printf(char const * , ...) ; extern int printf(char const * , ...) ;
void e_acsl_fail(char *msg ) void e_acsl_fail(char *msg )
{ {
printf((char const *)msg); printf("%s\n",msg);
exit(1); exit(1);
return; return;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment