summaryrefslogtreecommitdiffstats
path: root/otherlibs/dynlink
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2010-05-19 11:29:38 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2010-05-19 11:29:38 +0000
commit2adec7d7470c13917fabafc8b6a280341c817bb7 (patch)
treeee67d5eb7f2bc516e401570fb852665e03b91a1f /otherlibs/dynlink
parentfc2dea6d3d7df858e22b50694464fb3a8d56b141 (diff)
PR#5033: tools/objinfo made more general.
tools/dumpapprox removed, now subsumed by tools/objinfo. Introduced asmcomp/cmx_format.mli and used consistently in asmcomp, tools/objinfo, and otherlibs/dynlink Note: ocamlbuild -based build procedure not updated yet. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10424 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/dynlink')
-rw-r--r--otherlibs/dynlink/Makefile2
-rw-r--r--otherlibs/dynlink/natdynlink.ml36
2 files changed, 14 insertions, 24 deletions
diff --git a/otherlibs/dynlink/Makefile b/otherlibs/dynlink/Makefile
index 21771b598..9b72fe598 100644
--- a/otherlibs/dynlink/Makefile
+++ b/otherlibs/dynlink/Makefile
@@ -19,7 +19,7 @@ include ../../config/Makefile
CAMLC=../../boot/ocamlrun ../../ocamlc
CAMLOPT=../../ocamlcompopt.sh
-INCLUDES=-I ../../utils -I ../../typing -I ../../bytecomp
+INCLUDES=-I ../../utils -I ../../typing -I ../../bytecomp -I ../../asmcomp
COMPFLAGS=-warn-error A -I ../../stdlib $(INCLUDES)
OBJS=dynlinkaux.cmo dynlink.cmo
diff --git a/otherlibs/dynlink/natdynlink.ml b/otherlibs/dynlink/natdynlink.ml
index 184093a39..6ab9b9850 100644
--- a/otherlibs/dynlink/natdynlink.ml
+++ b/otherlibs/dynlink/natdynlink.ml
@@ -40,22 +40,14 @@ type error =
exception Error of error
-(* Copied from other places to avoid dependencies *)
-
-type dynunit = {
- name: string;
- crc: Digest.t;
- imports_cmi: (string * Digest.t) list;
- imports_cmx: (string * Digest.t) list;
- defines: string list;
-}
+open Cmx_format
-type dynheader = {
- magic: string;
- units: dynunit list;
-}
+(* Copied from config.ml to avoid dependencies *)
+let cmxs_magic_number = "Caml2007D001"
-let dyn_magic_number = "Caml2007D001"
+(* Copied from compilenv.ml to avoid dependencies *)
+let cmx_not_found_crc =
+ "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
let dll_filename fname =
if Filename.is_implicit fname then Filename.concat (Sys.getcwd ()) fname
@@ -70,12 +62,10 @@ let read_file filename priv =
then raise (Error (Cannot_open_dll (Obj.magic res)));
let header : dynheader = Marshal.from_string data 0 in
- if header.magic <> dyn_magic_number
+ if header.dynu_magic <> cmxs_magic_number
then raise(Error(Not_a_bytecode_file dll));
- (dll, handle, header.units)
+ (dll, handle, header.dynu_units)
-let cmx_not_found_crc =
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
(* Management of interface and implementation CRCs *)
@@ -127,7 +117,7 @@ let init () =
let add_check_ifaces allow_ext filename ui ifaces =
List.fold_left
(fun ifaces (name, crc) ->
- if name = ui.name
+ if name = ui.dynu_name
then StrMap.add name (crc,filename) ifaces
else
try
@@ -138,7 +128,7 @@ let add_check_ifaces allow_ext filename ui ifaces =
with Not_found ->
if allow_ext then StrMap.add name (crc,filename) ifaces
else raise (Error(Unavailable_unit name))
- ) ifaces ui.imports_cmi
+ ) ifaces ui.dynu_imports_cmi
let check_implems filename ui implems =
List.iter
@@ -168,7 +158,7 @@ let check_implems filename ui implems =
| Loaded -> ()
with Not_found ->
raise (Error(Unavailable_unit name))
- ) ui.imports_cmx
+ ) ui.dynu_imports_cmx
let loadunits filename handle units state =
let new_ifaces =
@@ -179,10 +169,10 @@ let loadunits filename handle units state =
List.fold_left
(fun accu ui ->
check_implems filename ui accu;
- StrMap.add ui.name (ui.crc,filename,Loaded) accu)
+ StrMap.add ui.dynu_name (ui.dynu_crc,filename,Loaded) accu)
state.implems units in
- let defines = List.flatten (List.map (fun ui -> ui.defines) units) in
+ let defines = List.flatten (List.map (fun ui -> ui.dynu_defines) units) in
ndl_run handle "_shared_startup";
List.iter (ndl_run handle) defines;