Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mirage/mirage
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 24278a07f88d
Choose a base ref
...
head repository: mirage/mirage
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d440fd68588e
Choose a head ref
  • 4 commits
  • 4 files changed
  • 2 contributors

Commits on Sep 28, 2016

  1. simplify random device

    hannesm committed Sep 28, 2016
    Copy the full SHA
    092ae83 View commit details

Commits on Sep 30, 2016

  1. rename default_random to stdlib_random

    implementation thereof is provided by the mirage-stdlib-random package
    hannesm committed Sep 30, 2016
    Copy the full SHA
    540c881 View commit details
  2. nocrypto RNG

    hannesm committed Sep 30, 2016
    Copy the full SHA
    548ce90 View commit details

Commits on Oct 2, 2016

  1. Merge pull request #551 from hannesm/rondom

    [RFC] simplify random
    yomimono authored Oct 2, 2016
    Copy the full SHA
    d440fd6 View commit details
Showing with 32 additions and 20 deletions.
  1. +20 −5 lib/mirage.ml
  2. +4 −1 lib/mirage.mli
  3. +5 −14 types/V1.mli
  4. +3 −0 types/V1_LWT.mli
25 changes: 20 additions & 5 deletions lib/mirage.ml
Original file line number Diff line number Diff line change
@@ -100,14 +100,29 @@ let default_monotonic_clock = impl monotonic_clock_conf
type random = RANDOM
let random = Type RANDOM

let random_conf = object
let stdlib_random_conf = object
inherit base_configurable
method ty = random
method name = "random"
method module_name = "Random"
method module_name = "Stdlibrandom"
method packages = Key.pure ["mirage-stdlib-random"]
method libraries = Key.pure ["mirage-stdlib-random"]
method connect _ modname _args =
Printf.sprintf "Lwt.return (`Ok (%s.initialize ()))" modname
end

let stdlib_random = impl stdlib_random_conf

let nocrypto_random_conf = object
inherit base_configurable
method ty = random
method name = "random"
method module_name = "Nocrypto.Rng"
method packages = Key.pure ["nocrypto"]
method libraries = Key.pure ["nocrypto"]
end

let default_random = impl random_conf
let nocrypto_random = impl nocrypto_random_conf

type console = CONSOLE
let console = Type CONSOLE
@@ -655,7 +670,7 @@ end
let tcp_direct_func () = impl (tcp_direct_conf ())

let direct_tcp
?(clock=default_monotonic_clock) ?(random=default_random) ?(time=default_time) ip =
?(clock=default_monotonic_clock) ?(random=stdlib_random) ?(time=default_time) ip =
tcp_direct_func () $ ip $ time $ clock $ random

let tcpv4_socket_conf ipv4_key = object
@@ -729,7 +744,7 @@ let stackv4_direct_conf ?(group="") config = impl @@ object

let direct_stackv4_with_config
?(clock=default_monotonic_clock)
?(random=default_random)
?(random=stdlib_random)
?(time=default_time)
?group
network config =
5 changes: 4 additions & 1 deletion lib/mirage.mli
Original file line number Diff line number Diff line change
@@ -109,9 +109,12 @@ type random
val random: random typ
(** Implementations of the [V1.RANDOM] signature. *)

val default_random: random impl
val stdlib_random: random impl
(** Passthrough to the OCaml Random generator. *)

val nocrypto_random: random impl
(** Passthrough to the Fortuna PRNG implemented in nocrypto. *)


(** {2 Consoles} *)

19 changes: 5 additions & 14 deletions types/V1.mli
Original file line number Diff line number Diff line change
@@ -80,23 +80,14 @@ end

(** {1 Random}
Operations to generate randomness. This is currently a passthrough
to the OCaml Random generator, and will be deprecated and
turned into a proper DEVICE with blocking modes. *)
Operations to generate random numbers. *)
module type RANDOM = sig

val self_init: unit -> unit
(** Initialize the generator with a random seed chosen in a
system-dependent way. *)

val int: int -> int
(** [int bound] returns a random integer between 0 (inclusive) and
[bound] (exclusive). [bound] must be greater than 0 and less
than 2{^30}. *)
type buffer
(** The type for memory buffer. *)

val int32: int32 -> int32
(** [int32 bound] returns a random integer between 0 (inclusive) and
[bound] (exclusive). [bound] must be greater than 0. *)
val generate: int -> buffer
(** [generate n] is a buffer of length [n] filled with random. *)
end

(** {1 POSIX clock}
3 changes: 3 additions & 0 deletions types/V1_LWT.mli
Original file line number Diff line number Diff line change
@@ -21,6 +21,9 @@ open V1
module type TIME = TIME
with type 'a io = 'a Lwt.t

module type RANDOM = RANDOM
with type buffer = Cstruct.t

module type FLOW = FLOW
with type 'a io = 'a Lwt.t
and type buffer = Cstruct.t