Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mirage-time is now a variant #229

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions mirage-crypto-rng-mirage.opam
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ depends: [
"logs"
"lwt" {>= "4.0.0"}
"mirage-runtime" {>= "3.8.0"}
"mirage-time" {>= "2.0.0"}
"mirage-time" {>= "4.0.0"}
"mirage-clock" {>= "3.0.0"}
"mirage-unix" {with-test & >= "5.0.0"}
"mirage-time-unix" {with-test & >= "2.0.0"}
"mirage-clock-unix" {with-test & >= "3.0.0"}
]
description: """
Expand Down
4 changes: 2 additions & 2 deletions rng/mirage/mirage_crypto_rng_mirage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
let src = Logs.Src.create "mirage-crypto-rng-mirage" ~doc:"Mirage crypto RNG mirage"
module Log = (val Logs.src_log src : Logs.LOG)

module Make (T : Mirage_time.S) (M : Mirage_clock.MCLOCK) = struct
module Make (M : Mirage_clock.MCLOCK) = struct
include Mirage_crypto_rng

let rdrand_task delta =
Expand All @@ -42,7 +42,7 @@ module Make (T : Mirage_time.S) (M : Mirage_clock.MCLOCK) = struct
Lwt.async (fun () ->
let rec one () =
rdrand ();
T.sleep_ns delta >>=
Mirage_time.sleep_ns delta >>=
one
in
one ())
Expand Down
2 changes: 1 addition & 1 deletion rng/mirage/mirage_crypto_rng_mirage.mli
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)

module Make (T : Mirage_time.S) (M : Mirage_clock.MCLOCK) : sig
module Make (M : Mirage_clock.MCLOCK) : sig
val initialize :
?g:'a -> ?sleep:int64 -> 'a Mirage_crypto_rng.generator -> unit Lwt.t
(** [initialize ~g ~sleep generator] sets the default generator to the
Expand Down
3 changes: 1 addition & 2 deletions tests/dune
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
(name test_entropy_collection)
(modules test_entropy_collection)
(package mirage-crypto-rng-mirage)
(libraries mirage-crypto-rng-mirage mirage-unix mirage-time-unix
mirage-clock-unix duration))
(libraries mirage-crypto-rng-mirage mirage-time mirage-clock-unix duration lwt.unix))

(test
(name test_entropy_collection_async)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_entropy_collection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Printing_rng = struct
let pools = 1
end

module E = Mirage_crypto_rng_mirage.Make(Time)(Mclock)
module E = Mirage_crypto_rng_mirage.Make(Mclock)

let with_entropy act =
E.initialize (module Printing_rng) >>= fun () ->
Expand All @@ -35,4 +35,4 @@ let with_entropy act =
act ()

let () =
Unix_os.(Main.run (with_entropy (fun () -> Time.sleep_ns (Duration.of_sec 3))))
Lwt_main.run (with_entropy (fun () -> Mirage_time.sleep_ns (Duration.of_sec 3)))