Skip to content

Commit

Permalink
change mirage tool to apply Entropy_unix functor
Browse files Browse the repository at this point in the history
  • Loading branch information
pqwy committed Jul 6, 2014
1 parent ae3c966 commit a6fed2f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/mirage.ml
Expand Up @@ -436,10 +436,12 @@ module Entropy = struct
let name _ =
"entropy"

let module_name () =
let module_name () = "Entropy"

let construction () =
match !mode with
| `Unix -> "Entropy_unix"
| `Xen -> "Entropy_xen"
| `Unix -> "Entropy_unix.Make (OS.Time)"

This comment has been minimized.

Copy link
@pqwy

pqwy Jul 6, 2014

Author Contributor

I wasn't sure how to properly depend on another signature (i.e. how to parameterize on whatever actually provides TIME) but the signature is apparently fulfilled only by OS.Time.

Probably hackish, willing to improve.

This comment has been minimized.

Copy link
@samoht

samoht Jul 6, 2014

Member

Not sure that will work well as this is used later on in the code to connect the device (so doing a <module name>.connect), a good ways to test this is to try to generate a program with two different entropy modules: I think you'll have a name clash here with the Entropy module name.

If you look at other impl, the module_name is unique per implementation of the same sig and the rest of the mechanism is very close to what you already do (ie. create the functor in configure).

| `Xen -> "Entropy_xen"

let packages () =
match !mode with
Expand All @@ -449,6 +451,8 @@ module Entropy = struct
let libraries = packages

let configure t =
append_main "module %s = %s" (module_name t) (construction t) ;
newline_main () ;
append_main "let %s () =" (name t);
append_main " %s.connect ()" (module_name t);
newline_main ()
Expand Down

0 comments on commit a6fed2f

Please sign in to comment.