-
-
Save anonymous/90f4107cf5008b12d356 to your computer and use it in GitHub Desktop.
Mirage: Infinite timestamp logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mirage configure --unix | |
Mirage Using scanned config file: config.ml | |
Mirage Processing: /home/jake/prog/mirage-experiments/broadcast-streams/timestamp/config.ml | |
Mirage => rm -rf /home/jake/prog/mirage-experiments/broadcast-streams/timestamp/_build/config.* | |
Mirage => cd /home/jake/prog/mirage-experiments/broadcast-streams/timestamp && ocamlbuild -use-ocamlfind -tags annot,bin_annot -pkg mirage config.cmxs | |
console Using configuration: /home/jake/prog/mirage-experiments/broadcast-streams/timestamp/config.ml | |
console 1 job [Unikernel.Main] | |
console Generating: main.ml | |
console Now run 'make depend' to install the package dependencies for this unikernel. | |
$ make depend | |
opam install mirage-clock-unix mirage-console-unix mirage-unix --verbose | |
[NOTE] Package mirage-unix is already installed (current version is 1.1.0). | |
[NOTE] Package mirage-console-unix is already installed (current version is 1.0.0). | |
[NOTE] Package mirage-clock-unix is already installed (current version is 1.0.0). | |
$ make | |
ocamlbuild -classic-display -use-ocamlfind -pkgs lwt.syntax,mirage-clock-unix,mirage-console-unix,mirage-types.lwt -tags "syntax(camlp4o),annot,bin_annot,strict_sequence,principal" -cflag -g -lflags -g,-linkpkg main.native | |
ocamlfind ocamldep -package mirage-types.lwt -package mirage-console-unix -package mirage-clock-unix -package lwt.syntax -syntax camlp4o -modules main.ml > main.ml.depends | |
ocamlfind ocamldep -package mirage-types.lwt -package mirage-console-unix -package mirage-clock-unix -package lwt.syntax -syntax camlp4o -modules unikernel.ml > unikernel.ml.depends | |
ocamlfind ocamlc -c -g -annot -bin-annot -principal -strict-sequence -package mirage-types.lwt -package mirage-console-unix -package mirage-clock-unix -package lwt.syntax -syntax camlp4o -o unikernel.cmo unikernel.ml | |
+ ocamlfind ocamlc -c -g -annot -bin-annot -principal -strict-sequence -package mirage-types.lwt -package mirage-console-unix -package mirage-clock-unix -package lwt.syntax -syntax camlp4o -o unikernel.cmo unikernel.ml | |
File "unikernel.ml", line 7, characters 20-200: | |
Warning 40: this record of type CLK.tm contains fields that are | |
not visible in the current scope: tm_sec tm_min tm_hour tm_mday tm_mon tm_year tm_wday tm_yday tm_isdst. | |
They will not be selected if the type becomes unknown. | |
ocamlfind ocamlc -c -g -annot -bin-annot -principal -strict-sequence -package mirage-types.lwt -package mirage-console-unix -package mirage-clock-unix -package lwt.syntax -syntax camlp4o -o main.cmo main.ml | |
+ ocamlfind ocamlc -c -g -annot -bin-annot -principal -strict-sequence -package mirage-types.lwt -package mirage-console-unix -package mirage-clock-unix -package lwt.syntax -syntax camlp4o -o main.cmo main.ml | |
File "main.ml", line 17, characters 2-7: | |
Error: Unbound value clock | |
Command exited with code 2. | |
make: *** [main.native] Error 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Mirage | |
let main = | |
foreign "Unikernel.Main" (console @-> clock @-> job) | |
let () = | |
register "console" [ main $ default_console $ default_clock ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Generated by Mirage (Tue, 2 Sep 2014 19:22:32 GMT). *) | |
open Lwt | |
let _ = Printexc.record_backtrace true | |
let console1 () = | |
Console.connect "0" | |
module M2 = Unikernel.Main(Console) | |
let t2 = console1 | |
module M1 = Unikernel.Main(Console)(Clock) | |
let t1 () = | |
clock () >>= function | |
| `Error e -> fail (Failure "clock") | |
| `Ok clock -> | |
console1 () >>= function | |
| `Error e -> fail (Failure "console1") | |
| `Ok console1 -> | |
M1.start console1 clock | |
let () = | |
OS.Main.run (join [t1 ()]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open V1 | |
open Lwt | |
module Main (C: CONSOLE)(CLK: CLOCK) = struct | |
let current_time () = | |
let tm_to_string ({ | |
tm_sec = sec; tm_min = min; tm_hour = hour; | |
tm_mday = mday; tm_mon = mon; tm_year = year; | |
tm_wday = wday; tm_yday = yday; tm_isdst = isdst | |
} : CLK.tm) = | |
Printf.sprintf "[%d-%d-%d %d:%d:%d]" (year+1900) (mon+1) mday hour min sec | |
in | |
let (|>) x f = f x in | |
CLK.time () |> CLK.gmtime |> tm_to_string | |
let start console clock = | |
while true do | |
C.log console (current_time ()) | |
done ; | |
return () | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment