diff options
| author | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2014-05-02 06:19:55 +0000 |
|---|---|---|
| committer | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2014-05-02 06:19:55 +0000 |
| commit | 52132f3df50d9d164056d4e64280a4a5df663f55 (patch) | |
| tree | 09c691c974516f85b1ac2086281b387004c775a9 /otherlibs | |
| parent | fc048b45c61cb7cf91e7288ddac3215c96452aca (diff) | |
| download | ocaml-52132f3df50d9d164056d4e64280a4a5df663f55.tar.gz | |
revert commit 14719
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14723 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs')
| -rw-r--r-- | otherlibs/dynlink/dynlink.ml | 31 | ||||
| -rw-r--r-- | otherlibs/dynlink/natdynlink.ml | 51 |
2 files changed, 36 insertions, 46 deletions
diff --git a/otherlibs/dynlink/dynlink.ml b/otherlibs/dynlink/dynlink.ml index 47409ad361..15febc3c89 100644 --- a/otherlibs/dynlink/dynlink.ml +++ b/otherlibs/dynlink/dynlink.ml @@ -79,16 +79,13 @@ let allow_extension = ref true let check_consistency file_name cu = try List.iter - (fun (name, crco) -> - match crco with - None -> () - | Some crc -> - if name = cu.cu_name then - Consistbl.set !crc_interfaces name crc file_name - else if !allow_extension then - Consistbl.check !crc_interfaces name crc file_name - else - Consistbl.check_noadd !crc_interfaces name crc file_name) + (fun (name, crc) -> + if name = cu.cu_name then + Consistbl.set !crc_interfaces name crc file_name + else if !allow_extension then + Consistbl.check !crc_interfaces name crc file_name + else + Consistbl.check_noadd !crc_interfaces name crc file_name) cu.cu_imports with Consistbl.Inconsistency(name, user, auth) -> raise(Error(Inconsistent_import name)) @@ -116,21 +113,15 @@ let prohibit names = (* Initialize the crc_interfaces table with a list of units with fixed CRCs *) let add_available_units units = - List.iter - (fun (unit, crc) -> Consistbl.set !crc_interfaces unit crc "") - units + List.iter (fun (unit, crc) -> Consistbl.set !crc_interfaces unit crc "") + units (* Default interface CRCs: those found in the current executable *) let default_crcs = ref [] let default_available_units () = clear_available_units(); - List.iter - (fun (unit, crco) -> - match crco with - None -> () - | Some crc -> Consistbl.set !crc_interfaces unit crc "") - !default_crcs; + add_available_units !default_crcs; allow_extension := true (* Initialize the linker tables and everything *) @@ -172,7 +163,7 @@ let digest_interface unit loadpath = close_in ic; let crc = match cmi.Cmi_format.cmi_crcs with - (_, Some crc) :: _ -> crc + (_, crc) :: _ -> crc | _ -> raise(Error(Corrupted_interface filename)) in crc diff --git a/otherlibs/dynlink/natdynlink.ml b/otherlibs/dynlink/natdynlink.ml index 597d60fb5f..0ae24fa681 100644 --- a/otherlibs/dynlink/natdynlink.ml +++ b/otherlibs/dynlink/natdynlink.ml @@ -41,7 +41,11 @@ exception Error of error open Cmx_format (* Copied from config.ml to avoid dependencies *) -let cmxs_magic_number = "Caml2007D002" +let cmxs_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 @@ -110,26 +114,23 @@ let init () = let add_check_ifaces allow_ext filename ui ifaces = List.fold_left - (fun ifaces (name, crco) -> - match crco with - None -> ifaces - | Some crc -> - if name = ui.dynu_name - then StrMap.add name (crc,filename) ifaces - else - try - let (old_crc,old_src) = StrMap.find name ifaces in - if old_crc <> crc - then raise(Error(Inconsistent_import(name))) - else ifaces - with Not_found -> - if allow_ext then StrMap.add name (crc,filename) ifaces - else raise (Error(Unavailable_unit name)) + (fun ifaces (name, crc) -> + if name = ui.dynu_name + then StrMap.add name (crc,filename) ifaces + else + try + let (old_crc,old_src) = StrMap.find name ifaces in + if old_crc <> crc + then raise(Error(Inconsistent_import(name))) + else ifaces + with Not_found -> + if allow_ext then StrMap.add name (crc,filename) ifaces + else raise (Error(Unavailable_unit name)) ) ifaces ui.dynu_imports_cmi let check_implems filename ui implems = List.iter - (fun (name, crco) -> + (fun (name, crc) -> match name with |"Out_of_memory" |"Sys_error" @@ -146,15 +147,13 @@ let check_implems filename ui implems = | _ -> try let (old_crc,old_src,state) = StrMap.find name implems in - match crco with - Some crc when old_crc <> crc -> - raise(Error(Inconsistent_implementation(name))) - | _ -> - match state with - | Check_inited i -> - if ndl_globals_inited() < i - then raise(Error(Unavailable_unit name)) - | Loaded -> () + if crc <> cmx_not_found_crc && old_crc <> crc + then raise(Error(Inconsistent_implementation(name))) + else match state with + | Check_inited i -> + if ndl_globals_inited() < i + then raise(Error(Unavailable_unit name)) + | Loaded -> () with Not_found -> raise (Error(Unavailable_unit name)) ) ui.dynu_imports_cmx |
