Commit 782fb3ea authored by Erwan Jahier's avatar Erwan Jahier
Browse files

Rename liblutin into lutin-utils

because i'd like to use that name for the ocaml/lutin lib.
parent 1ef2cb1d
......@@ -15,15 +15,15 @@ slink:
build: setup.data
ocaml setup.ml -build
setup.ml:_oasis polka/vector.ml Liblutin/src/liblutin.ml
setup.ml:_oasis polka/vector.ml lutin-utils/src/lutinutils.ml
oasis setup
# a clutch because oasis does not support camlidl
polka/vector.ml:
cd polka; make idl
Liblutin/src/liblutin.ml:
cd Liblutin/src/; make
lutin-utils/src/lutinutils.ml:
cd lutin-utils/src/; make
setup.data:configure
configure: setup.ml
......@@ -76,7 +76,7 @@ xxx:
.PHONY:install
oi:install
or:reinstall
ob:build
......@@ -85,7 +85,7 @@ clean:
ocaml setup.ml -clean
rm -f setup.data
cd polka; make clean
cd Liblutin/src/ ; make clean
cd lutin-utils/src/ ; make clean
distclean:
ocaml setup.ml -distclean
......
......@@ -19,7 +19,7 @@ BuildTools: ocamlbuild
Executable lutin
Path: lutin/src
MainIs: main.ml
BuildDepends: str,unix,num,rdbg-plugin,liblutin,ezdl,gbddml,polka,camlp4,camlidl
BuildDepends: str,unix,num,rdbg-plugin,lutin-utils,ezdl,gbddml,polka,camlp4,camlidl
Build: true
Install:true
CompiledObject: native
......@@ -29,12 +29,12 @@ Library lutin
XMETADescription: Provides an API to call Lutin from ocaml (and rdbg)
Path: lutin/src
Modules: LutinRun
BuildDepends: str,unix,num,rdbg-plugin,liblutin,ezdl,gbddml,polka,camlp4
BuildDepends: str,unix,num,rdbg-plugin,lutin-utils,ezdl,gbddml,polka,camlp4
Install:true
CompiledObject: native
XMETAEnable: true
InternalModules: Auto2Lucky,AutoGen,Bddd,CheckEnv,CheckType,CkIdentInfo,CkTypeEff,CoAlgExp,CoIdent,CoTraceExp,Constraint,Draw,Exp,ExpEval,Expand,ExprUtil,FGen,Fair_bddd,Formula_to_bdd,GenOcamlGlue,Glue,Gne,Guard,Lexeme,LoopWeights,Luc2alice,Luc2c,LucFGen,Lucky,LutErrors,LutExe,LutLexer,LutParser,LutPredef,LutProg,LutVersion,Main,MainArg,Ne,Parsers,Poly_draw,Polyhedron,Prevar,Prog,Reactive,Rif,Sol_nb,Solver,Store,Syntaxe,SyntaxeDump,Thickness,Type,Util,Utils,Value,Var,Verbose,Version
# DllLib: libgmp.so dllcamlidl.so
DllLib: libgmp.so dllcamlidl.so
Library lut4c
......@@ -43,16 +43,17 @@ Library lut4c
Path: lutin/src
Modules: Lut4c
FindlibParent: lutin
BuildDepends: str,unix,num,rdbg-plugin,liblutin,ezdl,gbddml,polka,camlp4
BuildDepends: str,unix,num,rdbg-plugin,lutin-utils,ezdl,gbddml,polka,camlp4
Install: true
CSources: lut4c_stubs.h,lut4c_stubs.c
CCOpt: -fPIC
Library liblutin
Path: Liblutin/src
Modules: Liblutin
Library "lutin-utils"
XMETADescription: Some C functions used by the lutin runtime
Path: lutin-utils/src
Modules: LutinUtils
Install: true
CSources: liblutin.h,liblutin_c.c,liblutin_stubs.c
CSources: lutinUtils.h,lutinUtils_c.c,lutinUtils_stubs.c
CCOpt: -fPIC -I$pkg_camlidl
Executable lurettetop_exe
......@@ -99,6 +100,7 @@ Library polka
vector_c.c, matrix_c.c, poly_c.c,
vector_caml.c, matrix_caml.c, poly_caml.c, polka_caml.c
CCOpt: -O3 -fPIC -DPOLKA_NUM=3 -I$pkg_camlidl
DllLib: libgmp.so dllcamlidl.so
......@@ -111,3 +113,11 @@ Executable "check-rif"
Install:true
CompiledObject: native
CCOpt: -fPIC
Executable "call-via-socket"
Path: ltop/src
MainIs: call-via-socket.ml
BuildDepends: str,unix
Build: true
Install:true
CompiledObject: native
# OASIS_START
# DO NOT EDIT (digest: 541237c860acc9505d2ac0799be32037)
# DO NOT EDIT (digest: 24d78dc091e9faf8e360054771c03d72)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
......@@ -14,12 +14,12 @@ true: annot, bin_annot
".git": not_hygienic
"_darcs": -traverse
"_darcs": not_hygienic
# Library liblutin
"Liblutin/src/liblutin.cmxs": use_liblutin
<Liblutin/src/*.ml{,i,y}>: oasis_library_liblutin_ccopt
"Liblutin/src/liblutin_c.c": oasis_library_liblutin_ccopt
"Liblutin/src/liblutin_stubs.c": oasis_library_liblutin_ccopt
<Liblutin/src/liblutin.{cma,cmxa}>: use_libliblutin_stubs
# Library lutin-utils
"lutin-utils/src/lutin-utils.cmxs": use_lutin-utils
<lutin-utils/src/*.ml{,i,y}>: oasis_library_lutin_utils_ccopt
"lutin-utils/src/lutinUtils_c.c": oasis_library_lutin_utils_ccopt
"lutin-utils/src/lutinUtils_stubs.c": oasis_library_lutin_utils_ccopt
<lutin-utils/src/lutin-utils.{cma,cmxa}>: use_liblutin-utils_stubs
# Library ezdl
"EZDL/ezdl.cmxs": use_ezdl
<EZDL/*.ml{,i,y}>: oasis_library_ezdl_ccopt
......@@ -52,6 +52,7 @@ true: annot, bin_annot
"polka/matrix_caml.c": oasis_library_polka_ccopt
"polka/poly_caml.c": oasis_library_polka_ccopt
"polka/polka_caml.c": oasis_library_polka_ccopt
<polka/polka.{cma,cmxa}>: oasis_library_polka_dlllib
<polka/polka.{cma,cmxa}>: use_libpolka_stubs
<polka/*.ml{,i,y}>: package(gmp)
"polka/polka_c.c": package(gmp)
......@@ -79,10 +80,11 @@ true: annot, bin_annot
"lutin/src/lut4c_stubs.c": package(unix)
"lutin/src/lut4c_stubs.c": use_ezdl
"lutin/src/lut4c_stubs.c": use_gbddml
"lutin/src/lut4c_stubs.c": use_liblutin
"lutin/src/lut4c_stubs.c": use_lutin-utils
"lutin/src/lut4c_stubs.c": use_polka
# Library lutin
"lutin/src/lutin.cmxs": use_lutin
"lutin/src/lutin.cmxa": oasis_library_lutin_dlllib
# Executable lurettetop_exe
<ltop/src/*.ml{,i,y}>: oasis_executable_lurettetop_exe_ccopt
"ltop/src/lurettetop.native": oasis_executable_lurettetop_exe_cclib
......@@ -97,16 +99,16 @@ true: annot, bin_annot
"ltop/src/lurettetop.native": package(unix)
"ltop/src/lurettetop.native": use_ezdl
"ltop/src/lurettetop.native": use_gbddml
"ltop/src/lurettetop.native": use_liblutin
"ltop/src/lurettetop.native": use_lutin
"ltop/src/lurettetop.native": use_lutin-utils
"ltop/src/lurettetop.native": use_polka
<ltop/src/*.ml{,i,y}>: package(camlidl)
<ltop/src/*.ml{,i,y}>: package(camlp4)
<ltop/src/*.ml{,i,y}>: package(dynlink)
<ltop/src/*.ml{,i,y}>: package(gmp)
<ltop/src/*.ml{,i,y}>: use_gbddml
<ltop/src/*.ml{,i,y}>: use_liblutin
<ltop/src/*.ml{,i,y}>: use_lutin
<ltop/src/*.ml{,i,y}>: use_lutin-utils
<ltop/src/*.ml{,i,y}>: use_polka
# Executable lutin
"lutin/src/main.native": oasis_executable_lutin_cclib
......@@ -119,7 +121,7 @@ true: annot, bin_annot
"lutin/src/main.native": package(unix)
"lutin/src/main.native": use_ezdl
"lutin/src/main.native": use_gbddml
"lutin/src/main.native": use_liblutin
"lutin/src/main.native": use_lutin-utils
"lutin/src/main.native": use_polka
<lutin/src/*.ml{,i,y}>: package(camlidl)
<lutin/src/*.ml{,i,y}>: package(camlp4)
......@@ -130,7 +132,7 @@ true: annot, bin_annot
<lutin/src/*.ml{,i,y}>: package(unix)
<lutin/src/*.ml{,i,y}>: use_ezdl
<lutin/src/*.ml{,i,y}>: use_gbddml
<lutin/src/*.ml{,i,y}>: use_liblutin
<lutin/src/*.ml{,i,y}>: use_lutin-utils
<lutin/src/*.ml{,i,y}>: use_polka
# Executable check-rif
<ltop/src/*.ml{,i,y}>: oasis_executable_check_rif_ccopt
......@@ -143,9 +145,12 @@ true: annot, bin_annot
<ltop/src/*.ml{,i,y}>: package(lustre-v6)
<ltop/src/*.ml{,i,y}>: package(num)
<ltop/src/*.ml{,i,y}>: package(rdbg-plugin)
<ltop/src/*.ml{,i,y}>: use_ezdl
# Executable call-via-socket
"ltop/src/call-via-socket.native": package(str)
"ltop/src/call-via-socket.native": package(unix)
<ltop/src/*.ml{,i,y}>: package(str)
<ltop/src/*.ml{,i,y}>: package(unix)
<ltop/src/*.ml{,i,y}>: use_ezdl
# OASIS_STOP
"ltop/src/cmd.ml": syntax_camlp4o
#"lutin/src/lut4c.ml": output_obj
......
......@@ -14,10 +14,13 @@ endif
# XXX pack all those modules into one
CMXA_LIB = unix.cmxa nums.cmxa str.cmxa \
ezdl.cmxa gbddml.cmxa polka.cmxa rdbg-plugin.cmxa liblutin.cmxa lutin.cmxa
ezdl.cmxa gbddml.cmxa polka.cmxa rdbg-plugin.cmxa lutin-utils.cmxa lutin.cmxa
CLIB=-ccopt -L$(shell ocamlc -where)/../camlidl -cclib -lcamlidl -cclib -lgmp
INCLUDE_DIR = -I +gmp -I +camlidl -I +polka -I +gbddml -I +rdbg-plugin -I +lutin -I +ezdl -I +liblutin
CLIB= `ocamlfind query camlidl -l-format` \
`ocamlfind query lutin-utils -i-format` \
-cclib -lcamlidl -cclib -lgmp
INCLUDE_DIR = -I +gmp -I +camlidl -I +polka -I +gbddml \
-I +rdbg-plugin -I +lutin -I +ezdl -I +lutin-utils
LUTIN=../../../bin/lutin$(EXE)
......
(*-----------------------------------------------------------------------
** Copyright (C) - Verimag.
** This file may only be copied under the terms of the GNU Library General
** Public License
**-----------------------------------------------------------------------
**
** File: call-via-socket.ml
** Author: jahier@imag.fr
*)
(* Launch prog and connect its stdin/stdout to sockets *)
let usage = "call-via-socket -addr <inet address> -port <port> [-serveur] \"<prog> <args>\"
Launch prog args connecting its stdin/stdout to a socket and stderr is to a log file.
Fails (with exit code 2) if the port is not available.
"
let client_mode = ref true
let inet_addr = ref (Unix.inet_addr_of_string "127.0.0.1")
let port = ref 2000
let usage_out speclist errmsg =
Printf.printf "%s" (Arg.usage_string speclist errmsg)
let rec speclist =
[
"-addr", Arg.String(fun str -> inet_addr := Unix.inet_addr_of_string str),
"<string>\tSocket inet address (127.0.0.1 by default)";
"-port", Arg.Int(fun str -> port := str),
"<int>\tSocket port (2000 by default)";
"-server", Arg.Unit(fun () -> client_mode := false),
"\tThe prog plays the role of the server (and the role if the client if unset)";
"--help", Arg.Unit (fun _ -> (usage_out speclist usage ; exit 0)),
"\tDisplay this list of options." ;
"-help", Arg.Unit (fun _ -> (usage_out speclist usage ; exit 0)),
"";
"-h", Arg.Unit (fun _ -> (usage_out speclist usage ; exit 0)),
""
]
(* Parsing command line args *)
let prog, args =
try
let prog = ref "" in
let set_prog str = prog := !prog ^ " " ^ str in
let prog =
Arg.parse speclist set_prog usage;
(Str.split (Str.regexp "[ \t]+") !prog)
in
List.hd prog, Array.of_list prog
with
| Failure(e) -> output_string stdout e; flush_all(); exit 2
| e -> output_string stdout (Printexc.to_string e); flush_all(); exit 2
let log_file = (prog ^ "-via-sockets-stderr.log")
let log = open_out log_file
let _ =
for i = 0 to Array.length Sys.argv -1 do
output_string log (Sys.argv.(i) ^ " ");
done;
output_string log "\n"; flush log;
if Array.length Sys.argv < 3 then (
print_string usage;
flush stdout;
close_out log;
exit 2
)
(*****************************************************************************)
(* Socket administration stuff *)
let sock = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0
let inet_addr = !inet_addr
let inet_addr_str = Unix.string_of_inet_addr inet_addr
let port = !port
let rec connect_loop sock addr k =
try Unix.connect sock addr
with _ ->
if k > 0 then (
output_string log " call-via-socket: connect failed... try once more \n"; flush log;
Unix.sleep 1;
connect_loop sock addr (k-1)
)
else
failwith "call-via-socket: cannot connect to the socket"
let (sock_in, sock_out) =
try
if !client_mode then
(
connect_loop sock (Unix.ADDR_INET(inet_addr, port)) 100 ;
(* connect ne marche que si il y a un accept en attente cot
serveur. Cela entraine une course critique entre le serveur
et le client. Pour y remdier, on essaie 10 fois en attendant
une seconde chaque essai. *)
Printf.fprintf log "call-via-socket: sock connection on %s:%d succeeded " inet_addr_str port;
(Unix.in_channel_of_descr sock, Unix.out_channel_of_descr sock)
)
else
( (* Serveur mode *)
Unix.bind sock (Unix.ADDR_INET(inet_addr, port));
Unix.listen sock 1;
let sock,_ = Unix.accept sock (* bloquant *) in
Printf.fprintf log "call-via-socket -server: sock connection on %s:%d accepted.\n" inet_addr_str port;
(Unix.in_channel_of_descr sock, Unix.out_channel_of_descr sock)
)
with
Unix.Unix_error(errcode, funcstr, paramstr) ->
output_string log "call-via-socket connect failure: ";
output_string log (Unix.error_message errcode);
output_string log ("(" ^ funcstr ^ " " ^ paramstr ^")\n");
flush log;
exit 2
(*****************************************************************************)
(* Forking *)
let pid =
output_string log ("call-via-socket "^prog^":");
output_string log " create child process with '";
for i = 0 to Array.length args -1 do
output_string log (args.(i)^ " ");
done;
output_string log "'\n";
flush log;
Unix.create_process prog args
(Unix.descr_of_in_channel sock_in)
(Unix.descr_of_out_channel sock_out)
(Unix.descr_of_out_channel log)
let _ =
output_string log ("call-via-socket "^prog^": the process creation succeeded.\n");
flush log;
let pid, pstatus = (Unix.waitpid [] pid) in
(* ignore(Unix.wait()); *)
output_string log ("call-via-socket "^prog^":");
(match pstatus with
Unix.WEXITED i -> output_string log (
" the process terminated with exit code " ^ (string_of_int i) ^"\n")
| Unix.WSIGNALED i -> output_string log (
" the process was killed by signal " ^ (string_of_int i) ^"\n")
| Unix.WSTOPPED i -> output_string log (
" the process was stopped by signal " ^ (string_of_int i) ^"\n")
);
output_string log ("call-via-socket "^prog^": bye. \n");
flush log;
close_out log
......@@ -50,22 +50,22 @@ let rec simp_num it = (
)
| Gcont (Ival i1, Ival i2, Ival i3) -> (
let i1,i2,i3=(Util.int_of_num i1, Util.int_of_num i2,Util.int_of_num i3) in
let i = Liblutin.gauss_continue i1 i2 i3 in
let i = LutinUtils.gauss_continue i1 i2 i3 in
Ival (Num.num_of_int i)
)
| Gstop (Ival i1, Ival i2, Ival i3) -> (
let i1,i2,i3=(Util.int_of_num i1, Util.int_of_num i2,Util.int_of_num i3) in
let i = Liblutin.gauss_stop i1 i2 i3 in
let i = LutinUtils.gauss_stop i1 i2 i3 in
Ival (Num.num_of_int i)
)
| Icont (Ival i1, Ival i2, Ival i3) -> (
let i1,i2,i3=(Util.int_of_num i1, Util.int_of_num i2,Util.int_of_num i3) in
let i = Liblutin.interval_continue i1 i2 i3 in
let i = LutinUtils.interval_continue i1 i2 i3 in
Ival (Num.num_of_int i)
)
| Istop (Ival i1, Ival i2, Ival i3) -> (
let i1,i2,i3=(Util.int_of_num i1, Util.int_of_num i2,Util.int_of_num i3) in
let i = Liblutin.interval_stop i1 i2 i3 in
let i = LutinUtils.interval_stop i1 i2 i3 in
Ival (Num.num_of_int i)
)
| Ite (True, a2, _) -> a2
......
......@@ -592,7 +592,7 @@ and
and (a2') = eval_int_arg input memory ctx_msg vl "gauss_continue" a2
and (a3') = eval_int_arg input memory ctx_msg vl "gauss_continue" a3
in
let i = Liblutin.gauss_continue a1' a2' a3' in
let i = LutinUtils.gauss_continue a1' a2' a3' in
(Gne.make
(Ne.make "" (I(Num.num_of_int i)))
true
......@@ -603,7 +603,7 @@ and
and (a2') = eval_int_arg input memory ctx_msg vl "gauss_stop" a2
and (a3') = eval_int_arg input memory ctx_msg vl "gauss_stop" a3
in
let i = Liblutin.gauss_stop a1' a2' a3' in
let i = LutinUtils.gauss_stop a1' a2' a3' in
(Gne.make
(Ne.make "" (I(Num.num_of_int i)))
true
......@@ -614,7 +614,7 @@ and
and (a2') = eval_int_arg input memory ctx_msg vl "interval_continue" a2
and (a3') = eval_int_arg input memory ctx_msg vl "interval_continue" a3
in
let i = Liblutin.interval_continue a1' a2' a3' in
let i = LutinUtils.interval_continue a1' a2' a3' in
(Gne.make
(Ne.make "" (I(Num.num_of_int i)))
true
......@@ -625,7 +625,7 @@ and
and (a2') = eval_int_arg input memory ctx_msg vl "interval_stop" a2
and (a3') = eval_int_arg input memory ctx_msg vl "interval_stop" a3
in
let i = Liblutin.interval_stop a1' a2' a3' in
let i = LutinUtils.interval_stop a1' a2' a3' in
(Gne.make
(Ne.make "" (I(Num.num_of_int i)))
true
......
......@@ -11,7 +11,7 @@ open LutErrors
open Value
open CoAlgExp
open CkTypeEff
open Liblutin
open LutinUtils
let dbg = Verbose.get_flag "Guard"
......
let str="1.57"
let sha="fbd316f"
let sha="1ef2cb1"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment