From 9fc16d028908032939dd9cccd7721538d09f090c Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Tue, 23 Apr 2024 17:59:57 +0100 Subject: [PATCH 1/4] use dune variants --- lib_test/dune | 4 ++-- lib_test/portable.ml | 2 ++ solo5/dune | 5 ++--- solo5/mclock.mli | 22 ---------------------- solo5/pclock.mli | 21 --------------------- src/dune | 3 ++- src/{mirage_clock.ml => mirage_clock.mli} | 4 ++-- unix/dune | 6 +++--- unix/mclock.mli | 21 --------------------- unix/pclock.mli | 20 -------------------- 10 files changed, 13 insertions(+), 95 deletions(-) delete mode 100644 solo5/mclock.mli delete mode 100644 solo5/pclock.mli rename src/{mirage_clock.ml => mirage_clock.mli} (97%) delete mode 100644 unix/mclock.mli delete mode 100644 unix/pclock.mli diff --git a/lib_test/dune b/lib_test/dune index 02f0a22..80c2894 100644 --- a/lib_test/dune +++ b/lib_test/dune @@ -1,4 +1,4 @@ (test (name portable) - (package mirage-clock-unix) - (libraries mirage-clock-unix)) + (package mirage-clock) + (libraries mirage-clock.unix)) diff --git a/lib_test/portable.ml b/lib_test/portable.ml index f1e5944..656106a 100644 --- a/lib_test/portable.ml +++ b/lib_test/portable.ml @@ -1,3 +1,5 @@ +open Mirage_clock + let print_time c = let d, ps = Pclock.now_d_ps c in Printf.printf "The time is %d days and %Ld picoseconds since the epoch.\n" d diff --git a/solo5/dune b/solo5/dune index 9223bf4..6c04097 100644 --- a/solo5/dune +++ b/solo5/dune @@ -1,8 +1,7 @@ (library (name mirage_clock_solo5) - (wrapped false) - (public_name mirage-clock-solo5) - (libraries mirage-clock) + (public_name mirage-clock.solo5) + (implements mirage-clock) (foreign_stubs (language c) (names clock_stubs))) diff --git a/solo5/mclock.mli b/solo5/mclock.mli deleted file mode 100644 index fbbd0c2..0000000 --- a/solo5/mclock.mli +++ /dev/null @@ -1,22 +0,0 @@ -(* - * Copyright (c) 2015 Daniel C. Bünzli. - * - * 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. - *) - -(** Monotonic clock for MirageOS using paravirtual interfaces - - Clock returning monotonic time since an arbitrary point. To be used for eg. - profiling. *) - -include Mirage_clock.MCLOCK diff --git a/solo5/pclock.mli b/solo5/pclock.mli deleted file mode 100644 index bdef054..0000000 --- a/solo5/pclock.mli +++ /dev/null @@ -1,21 +0,0 @@ -(* - * Copyright (c) 2015 Daniel C. Bünzli - * - * 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. - *) - -(** POSIX clock for MirageOS using paravirtual interfaces - - Clock counting time since the Unix epoch. Subject to adjustment by e.g. NTP. *) - -include Mirage_clock.PCLOCK diff --git a/src/dune b/src/dune index 5133e38..f29a728 100644 --- a/src/dune +++ b/src/dune @@ -1,3 +1,4 @@ (library (name mirage_clock) - (public_name mirage-clock)) + (public_name mirage-clock) + (virtual_modules mirage_clock)) diff --git a/src/mirage_clock.ml b/src/mirage_clock.mli similarity index 97% rename from src/mirage_clock.ml rename to src/mirage_clock.mli index a2cfa25..f87f2b6 100644 --- a/src/mirage_clock.ml +++ b/src/mirage_clock.mli @@ -22,7 +22,7 @@ (** {2 POSIX clock} Clock counting time since the Unix epoch. Subject to adjustment by e.g. NTP. *) -module type PCLOCK = sig +module Pclock : sig val now_d_ps : unit -> int * int64 (** [now_d_ps ()] is [(d, ps)] representing the POSIX time occurring at [d] * 86'400e12 + [ps] POSIX picoseconds from the epoch 1970-01-01 00:00:00 UTC. @@ -43,7 +43,7 @@ end Clock returning monotonic time since an arbitrary point. To be used for e.g. profiling. *) -module type MCLOCK = sig +module Mclock : sig val elapsed_ns : unit -> int64 (** [elapsed_ns ()] is a monotonically increasing count of nanoseconds elapsed since some arbitrary point *) diff --git a/unix/dune b/unix/dune index e03be8e..877a2ca 100644 --- a/unix/dune +++ b/unix/dune @@ -1,8 +1,8 @@ (library (name mirage_clock_unix) - (wrapped false) - (public_name mirage-clock-unix) - (libraries mirage-clock unix) + (public_name mirage-clock.unix) + (implements mirage-clock) + (libraries unix) (foreign_stubs (language c) (flags diff --git a/unix/mclock.mli b/unix/mclock.mli deleted file mode 100644 index dab1720..0000000 --- a/unix/mclock.mli +++ /dev/null @@ -1,21 +0,0 @@ -(* - * Copyright (c) 2015 Daniel C. Bünzli. - * - * 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. - *) - -include Mirage_clock.MCLOCK -(** Monotonic clock for Unix using MirageOS interfaces - - Clock returning monotonic time since an arbitrary point. To be used for eg. - profiling. *) diff --git a/unix/pclock.mli b/unix/pclock.mli deleted file mode 100644 index f01b8ee..0000000 --- a/unix/pclock.mli +++ /dev/null @@ -1,20 +0,0 @@ -(* - * Copyright (c) 2015 Daniel C. Bünzli - * - * 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. - *) - -include Mirage_clock.PCLOCK -(** POSIX clock for MirageOS using Unix interfaces - - Clock counting time since the Unix epoch. Subject to adjustment by e.g. NTP. *) From 6a2bca7554b0eda0d5202eb1309e235e56f173d8 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Wed, 24 Apr 2024 13:08:13 +0100 Subject: [PATCH 2/4] fixes, plus unix is the default --- lib_test/dune | 2 +- solo5/mirage_clock.ml | 2 ++ src/dune | 3 ++- unix/mirage_clock.ml | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 solo5/mirage_clock.ml create mode 100644 unix/mirage_clock.ml diff --git a/lib_test/dune b/lib_test/dune index 80c2894..dd0ee15 100644 --- a/lib_test/dune +++ b/lib_test/dune @@ -1,4 +1,4 @@ (test (name portable) (package mirage-clock) - (libraries mirage-clock.unix)) + (libraries mirage-clock)) diff --git a/solo5/mirage_clock.ml b/solo5/mirage_clock.ml new file mode 100644 index 0000000..4afb665 --- /dev/null +++ b/solo5/mirage_clock.ml @@ -0,0 +1,2 @@ +module Pclock = Pclock +module Mclock = Mclock diff --git a/src/dune b/src/dune index f29a728..570cff5 100644 --- a/src/dune +++ b/src/dune @@ -1,4 +1,5 @@ (library (name mirage_clock) (public_name mirage-clock) - (virtual_modules mirage_clock)) + (virtual_modules mirage_clock) + (default_implementation mirage-clock.unix)) diff --git a/unix/mirage_clock.ml b/unix/mirage_clock.ml new file mode 100644 index 0000000..4afb665 --- /dev/null +++ b/unix/mirage_clock.ml @@ -0,0 +1,2 @@ +module Pclock = Pclock +module Mclock = Mclock From 3026a051bbda7956f6b3f89becaa27ddcd93a942 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Tue, 23 Apr 2024 21:30:30 +0100 Subject: [PATCH 3/4] minor --- .github/workflows/esy.yml | 4 ---- appveyor.yml | 4 ++-- config/discover.ml | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/esy.yml b/.github/workflows/esy.yml index f5313b6..11f0d20 100644 --- a/.github/workflows/esy.yml +++ b/.github/workflows/esy.yml @@ -30,14 +30,10 @@ jobs: "dependencies": { "ocaml": "4.12.x", "@opam/mirage-clock": "*", - "@opam/mirage-clock-unix": "*", - "@opam/mirage-clock-solo5": "*", "reason-mobile": "github:EduardoRFS/reason-mobile:generate.json#7ba258319b87943d2eb0d8fb84562d0afeb2d41f" }, "resolutions": { "@opam/mirage-clock": "./mirage-clock.opam", - "@opam/mirage-clock-unix": "./mirage-clock-unix.opam", - "@opam/mirage-clock-solo5": "./mirage-clock-solo5.opam" } }' > esy.json diff --git a/appveyor.yml b/appveyor.yml index f6a3eb6..c03cfbb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,8 +6,8 @@ environment: FORK_BRANCH: master CYG_ROOT: C:\cygwin64 OPAM_SWITCH: 4.08.0+mingw64c - PINS: "mirage-clock.dev:. mirage-clock-unix.dev:." - PACKAGE: "mirage-clock-unix" + PINS: "mirage-clock.dev:." + PACKAGE: "mirage-clock" install: - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/$env:FORK_USER/ocaml-ci-scripts/$env:FORK_BRANCH/appveyor-install.ps1")) diff --git a/config/discover.ml b/config/discover.ml index 8e8f03d..d157c02 100644 --- a/config/discover.ml +++ b/config/discover.ml @@ -1,9 +1,9 @@ module C = Configurator.V1 let () = - C.main ~name:"mirage-clock-unix" (fun c -> + C.main ~name:"mirage-clock" (fun c -> let is_android = - let defines = + let android_defines = C.C_define.import c ~includes:[] [ ("__ANDROID__", Switch) ] in match defines with (_, Switch true) :: _ -> true | _ -> false From 4febaf04406c46c16dc3fba7fedd2c320b875a96 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Wed, 24 Apr 2024 17:27:04 +0100 Subject: [PATCH 4/4] fix --- config/discover.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/discover.ml b/config/discover.ml index d157c02..f0bed21 100644 --- a/config/discover.ml +++ b/config/discover.ml @@ -3,7 +3,7 @@ module C = Configurator.V1 let () = C.main ~name:"mirage-clock" (fun c -> let is_android = - let android_defines = + let defines = C.C_define.import c ~includes:[] [ ("__ANDROID__", Switch) ] in match defines with (_, Switch true) :: _ -> true | _ -> false