From 838b0acc7001d5a9c06a50a1deeab93347d3e06d Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Tue, 7 May 2024 16:39:25 +0200 Subject: [PATCH] mirage-time is now a variant --- mirage-crypto-rng-mirage.opam | 4 +--- rng/mirage/mirage_crypto_rng_mirage.ml | 4 ++-- rng/mirage/mirage_crypto_rng_mirage.mli | 2 +- tests/dune | 3 +-- tests/test_entropy_collection.ml | 4 ++-- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/mirage-crypto-rng-mirage.opam b/mirage-crypto-rng-mirage.opam index 0c5872eb..04fdd1a6 100644 --- a/mirage-crypto-rng-mirage.opam +++ b/mirage-crypto-rng-mirage.opam @@ -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: """ diff --git a/rng/mirage/mirage_crypto_rng_mirage.ml b/rng/mirage/mirage_crypto_rng_mirage.ml index f363b3d0..a88666d2 100644 --- a/rng/mirage/mirage_crypto_rng_mirage.ml +++ b/rng/mirage/mirage_crypto_rng_mirage.ml @@ -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 = @@ -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 ()) diff --git a/rng/mirage/mirage_crypto_rng_mirage.mli b/rng/mirage/mirage_crypto_rng_mirage.mli index 7bc83b8f..e4dddc54 100644 --- a/rng/mirage/mirage_crypto_rng_mirage.mli +++ b/rng/mirage/mirage_crypto_rng_mirage.mli @@ -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 diff --git a/tests/dune b/tests/dune index a063e0e1..d4d32c66 100644 --- a/tests/dune +++ b/tests/dune @@ -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) diff --git a/tests/test_entropy_collection.ml b/tests/test_entropy_collection.ml index 631f156c..565f3543 100644 --- a/tests/test_entropy_collection.ml +++ b/tests/test_entropy_collection.ml @@ -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 () -> @@ -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)))