This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
4
unikernel/duniverse/mirage-unix/lib/dune
Normal file
4
unikernel/duniverse/mirage-unix/lib/dune
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(library
|
||||
(name unix_os)
|
||||
(public_name mirage-unix)
|
||||
(libraries duration lwt lwt.unix mirage-runtime))
|
||||
4
unikernel/duniverse/mirage-unix/lib/lifecycle.ml
Normal file
4
unikernel/duniverse/mirage-unix/lib/lifecycle.ml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[@@@warning "-27"]
|
||||
(* No shutdown events on Unix. *)
|
||||
let await_shutdown_request ?(can_poweroff:_) ?(can_reboot:_) () =
|
||||
fst (Lwt.wait ())
|
||||
26
unikernel/duniverse/mirage-unix/lib/lifecycle.mli
Normal file
26
unikernel/duniverse/mirage-unix/lib/lifecycle.mli
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
(*
|
||||
* Copyright (c) 2015 Thomas Leonard <talex5@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*)
|
||||
|
||||
val await_shutdown_request :
|
||||
?can_poweroff:bool ->
|
||||
?can_reboot:bool ->
|
||||
unit -> [`Poweroff | `Reboot] Lwt.t
|
||||
(** [await_shutdown_request ()] is thread that resolves when the domain is
|
||||
asked to shut down.
|
||||
The optional [poweroff] (default:[true]) and [reboot] (default:[false])
|
||||
arguments can be used to indicate which features the caller wants to
|
||||
advertise (however, you can still get a request for a mode you didn't claim
|
||||
to support). *)
|
||||
34
unikernel/duniverse/mirage-unix/lib/main.ml
Normal file
34
unikernel/duniverse/mirage-unix/lib/main.ml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
(* From lwt/src/unix/lwt_main.ml *)
|
||||
let rec run t =
|
||||
(* Wakeup paused threads now. *)
|
||||
Lwt.wakeup_paused ();
|
||||
match Lwt.poll t with
|
||||
| Some x -> x
|
||||
| None ->
|
||||
(* Call enter hooks. *)
|
||||
Mirage_runtime.run_enter_iter_hooks ();
|
||||
(* Do the main loop call. *)
|
||||
Lwt_engine.iter (Lwt.paused_count () = 0);
|
||||
(* Wakeup paused threads again. *)
|
||||
Lwt.wakeup_paused ();
|
||||
(* Call leave hooks. *)
|
||||
Mirage_runtime.run_leave_iter_hooks ();
|
||||
run t
|
||||
|
||||
(* If the platform doesn't have SIGPIPE, then Sys.set_signal will
|
||||
raise an Invalid_argument exception. If the signal does not exist
|
||||
then we don't need to ignore it, so it's safe to continue. *)
|
||||
let ignore_sigpipe () =
|
||||
try Sys.(set_signal sigpipe Signal_ignore) with Invalid_argument _ -> ()
|
||||
|
||||
(* Main runloop, which registers a callback so it can be invoked
|
||||
when timeouts expire. Thus, the program may only call this function
|
||||
once and once only. *)
|
||||
let run t =
|
||||
ignore_sigpipe ();
|
||||
run t
|
||||
|
||||
let () =
|
||||
at_exit (fun () ->
|
||||
Lwt.abandon_wakeups ();
|
||||
run (Mirage_runtime.run_exit_hooks ()))
|
||||
17
unikernel/duniverse/mirage-unix/lib/main.mli
Normal file
17
unikernel/duniverse/mirage-unix/lib/main.mli
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
(*
|
||||
* Copyright (c) 2010 Anil Madhavapeddy <anil@recoil.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.
|
||||
*)
|
||||
|
||||
val run : unit Lwt.t -> unit
|
||||
2
unikernel/duniverse/mirage-unix/lib/time.ml
Normal file
2
unikernel/duniverse/mirage-unix/lib/time.ml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
let sleep_ns x = Lwt_unix.sleep (Duration.to_f x)
|
||||
20
unikernel/duniverse/mirage-unix/lib/time.mli
Normal file
20
unikernel/duniverse/mirage-unix/lib/time.mli
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
(*
|
||||
* Copyright (c) 2010 Anil Madhavapeddy <anil@recoil.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.
|
||||
*)
|
||||
|
||||
(** Timeout operations. *)
|
||||
|
||||
val sleep_ns : int64 -> unit Lwt.t
|
||||
(** [sleep_ns n] Block the current thread for n nanoseconds. *)
|
||||
3
unikernel/duniverse/mirage-unix/lib/unix_os.ml
Normal file
3
unikernel/duniverse/mirage-unix/lib/unix_os.ml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module Lifecycle = Lifecycle
|
||||
module Main = Main
|
||||
module Time = Time
|
||||
22
unikernel/duniverse/mirage-unix/lib/unix_os.mli
Normal file
22
unikernel/duniverse/mirage-unix/lib/unix_os.mli
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(** MirageOS Unix implementation of the [OS] module *)
|
||||
|
||||
module Lifecycle : sig
|
||||
val await_shutdown_request :
|
||||
?can_poweroff:bool ->
|
||||
?can_reboot:bool ->
|
||||
unit -> [`Poweroff | `Reboot] Lwt.t
|
||||
(** [await_shutdown_request ()] is thread that resolves when the domain is
|
||||
asked to shut down. The optional [poweroff] (default:[true]) and
|
||||
[reboot] (default:[false]) arguments can be used to indicate which
|
||||
features the caller wants to advertise (however, you can still get a
|
||||
request for a mode you didn't claim to support). *)
|
||||
end
|
||||
|
||||
module Main : sig
|
||||
val run : unit Lwt.t -> unit
|
||||
end
|
||||
|
||||
module Time : sig
|
||||
val sleep_ns : int64 -> unit Lwt.t
|
||||
(** [sleep_ns d] Block the current thread for [n] nanoseconds. *)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue