This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,6 @@
_build
*~
\.\#*
\#*#
.merlin
*.install

View file

@ -0,0 +1,40 @@
## v4.1.0 (2025-09-01)
* Add support for unikraft (#1 @shym @fabbing @Firobe)
## v4.0.0 (2025-01-30)
* Renamed to mirage-sleep, use dune variants
## v3.0.0 (2021-11-15)
* Remove Mirage_time_lwt module (#13 @hannesm)
## v2.0.1 (2019-11-04)
* provide deprecated Mirage_time_lwt for smooth transition (#12 @hannesm)
## v2.0.0 (2019-10-21)
* remove mirage-time-lwt (#10 @hannesm)
* specialise mirage-time to io being Lwt.t directly (#10 @hannesm)
* raise OCaml lower bound to 4.06.0 (#10 @hannesm)
## v1.3.0 (2019-06-18)
* Upgrade opam metadata to 2.0 format (#7 @hannesm)
* Upgrade to dune from jbuilder (#7 @hannesm)
* Improve test matrix to OCaml 4.07 and minimum is 4.04+ (@hannesm)
## v1.2.0 (2017-07-21)
* Add a mirage-time-unix module defining a `Time` module (#4, @samoht)
## v1.1.0 (2017-06-05)
* Port to [Jbuilder](https://github.com/janestreet/jbuilder) packaging.
* Add Travis CI tests.
## v1.0.0 (2016-12-20)
* Initial version, code imported from https://github.com/mirage/mirage

View file

@ -0,0 +1,11 @@
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View file

@ -0,0 +1,16 @@
## mirage-sleep -- Sleep operations for MirageOS
The mirage-sleep repository defines [Mirage_sleep][1], the signature for
sleep-related operations for MirageOS. This is for now only the function
`ns` to sleep an amount of nanoseconds.
[1]: https://mirage.github.io/mirage-sleep/mirage-sleep/Mirage_sleep
### Installation
`mirage-sleep` can be installed with `opam`:
opam install mirage-sleep
If you don't use `opam` consult the [`opam`](opam) file for build
instructions.

View file

@ -0,0 +1,3 @@
(lang dune 2.6)
(name mirage-sleep)
(version v4.1.0)

View file

@ -0,0 +1,36 @@
version: "4.1.0"
opam-version: "2.0"
maintainer: "hannes@mehnert.org"
authors: [
"Thomas Gazagnaire"
"Anil Madhavapeddy"
"Gabriel Radanne"
"Mindy Preston"
"Thomas Leonard"
"Nicolas Ojeda Bar"
"Dave Scott"
"David Kaloper"
"Hannes Mehnert"
"Richard Mortier"
]
license: "ISC"
tags: "org:mirage"
homepage: "https://github.com/mirage/mirage-sleep"
doc: "https://mirage.github.io/mirage-sleep/"
bug-reports: "https://github.com/mirage/mirage-sleep/issues"
depends: [
"ocaml" {>= "4.08.0"}
"dune" {>= "2.6"}
"lwt" {>= "4.0.0"}
"duration"
]
build: [
["dune" "subst"] {dev}
["dune" "build" "-p" name "-j" jobs]
]
dev-repo: "git+https://github.com/mirage/mirage-sleep.git"
synopsis: "Sleep operation for MirageOS"
description: """
Mirage_sleep defines the single function `ns`.
"""
x-maintenance-intent: [ "(latest)" ]

View file

@ -0,0 +1,5 @@
(library
(name mirage_sleep_solo5)
(public_name mirage-sleep.solo5)
(implements mirage-sleep)
(optional))

View file

@ -0,0 +1,18 @@
external time : unit -> int64 = "caml_get_monotonic_time"
type t = { time : int64; mutable canceled : bool; thread : unit Lwt.u }
let sleepers = ref []
let ns d =
let res, w = Lwt.task () in
let time = Int64.add (time ()) d in
let sleeper = { time; canceled = false; thread = w } in
sleepers := sleeper :: !sleepers;
Lwt.on_cancel res (fun _ -> sleeper.canceled <- true);
res
let new_sleepers () =
let sl = !sleepers in
sleepers := [];
sl

View file

@ -0,0 +1,6 @@
(library
(name mirage_sleep)
(public_name mirage-sleep)
(virtual_modules mirage_sleep)
(default_implementation mirage-sleep.unix)
(libraries lwt))

View file

@ -0,0 +1,35 @@
(*
* Copyright (c) 2011-2015 Anil Madhavapeddy <anil@recoil.org>
* Copyright (c) 2013-2015 Thomas Gazagnaire <thomas@gazagnaire.org>
* Copyright (c) 2013 Citrix Systems Inc
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)
(** {1 Time device}
This module defines a target-agnostic MirageOS sleep operation. *)
val ns: int64 -> unit Lwt.t
(** [sleep_ns n] blocks the current task for [n] nanoseconds, treating [n] as
unsigned. *)
(** {1 Values used by the schedulers} *)
type t = { time : int64; mutable canceled : bool; thread : unit Lwt.u }
(** The type for a sleeping task. *)
val new_sleepers : unit -> t list
(** [new_sleepers ()] is used by the scheduler to find at their convenience
the tasks that need to be enqueued into their task set. This also empties
the list of sleepers. *)

View file

@ -0,0 +1,8 @@
(library
(name mirage_sleep_unikraft)
(public_name mirage-sleep.unikraft)
(implements mirage-sleep)
(optional))
(rule
(copy# %{project_root}/solo5/mirage_sleep.ml mirage_sleep.ml))

View file

@ -0,0 +1,5 @@
(library
(name mirage_sleep_unix)
(public_name mirage-sleep.unix)
(implements mirage-sleep)
(libraries lwt.unix duration))

View file

@ -0,0 +1,21 @@
(*
* Copyright (c) 2017 Thomas Gazagnaire <thomas@gazagnaire.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)
let ns ns = Lwt_unix.sleep (Duration.to_f ns)
type t = { time : int64; mutable canceled : bool; thread : unit Lwt.u }
let new_sleepers () = []