Skip to content

Commit

Permalink
ocaml-evtchn: Split lwt-dependent and independent code into two separ…
Browse files Browse the repository at this point in the history
…ate modules

Signed-off-by: Andrii Sultanov <[email protected]>
  • Loading branch information
last-genius committed Oct 7, 2024
1 parent 32132ea commit 11ff051
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 37 deletions.
56 changes: 55 additions & 1 deletion ocaml-evtchn/dune-project
Original file line number Diff line number Diff line change
@@ -1,2 +1,56 @@
(lang dune 1.0)
(lang dune 3.15)
(name xen-evtchn)

(generate_opam_files true)

(maintainers "[email protected]")
(homepage "https://github.com/mirage/ocaml-evtchn")
(source (github mirage/ocaml-evtchn))

(package
(name xen-evtchn)
(authors "Vincent Hanquez" "Anil Madhavapeddy" "David Scott" "Jonathan Ludlam")
(tags ("org:mirage" "org:xapi-project"))
(synopsis "Xen event channel interface for MirageOS")
(description "
Event channels are the Xen equivalent of interrupts, used to signal
when data (or space) is available for processing. There are 2 distinct
implementations:
1. a Xen shared-memory + hypercall protocol for kernelspace
2. a binding to a set of libxc functions which access /dev/xen/evtchn
for userspace (see `xen-evtchn-unix` opam package)."
)
(depends
(ocaml (>= 4.03.0))
dune
lwt
lwt-dllist
cmdliner
)
)

(package
(name xen-evtchn-unix)
(authors "Vincent Hanquez" "Anil Madhavapeddy" "David Scott" "Jonathan Ludlam")
(tags ("org:mirage" "org:xapi-project"))
(synopsis "Xen event channel interface for Linux")
(depends
(ocaml (>= 4.03.0))
dune
(xen-evtchn (>= 2.0.0))
lwt-dllist
lwt
cmdliner
(ounit2 :with-test)
(conf-xen :build)
))

(package
(name xen-evtchn-unix-minimal)
(tags ("org:mirage" "org:xapi-project"))
(synopsis "Xen event channel interface for Linux, without Lwt dependencies")
(depends
dune
(xen-evtchn (>= 2.0.0))
))
14 changes: 11 additions & 3 deletions ocaml-evtchn/lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
(modules Eventchn Generation)
(wrapped false))

(library
(name xen_evtchn_unix_minimal)
(public_name xen-evtchn-unix-minimal)
(modules Unix_activations_minimal)
(foreign_stubs (language c) (names eventchn_stubs))
(c_library_flags -L/usr/lib/xen-4.2/lib -lxenctrl)
(libraries xen-evtchn)
(wrapped false))

(library
(name xen_evtchn_unix)
(public_name xen-evtchn-unix)
(modules Unix_activations)
(c_names eventchn_stubs)
(c_library_flags -L/usr/lib/xen-4.2/lib -lxenctrl)
(libraries unix lwt lwt-dllist lwt.unix bigarray xen-evtchn)
(libraries unix lwt lwt-dllist lwt.unix bigarray
xen-evtchn-unix-minimal)
(wrapped false))
4 changes: 1 addition & 3 deletions ocaml-evtchn/lib/unix_activations.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
wraps. Arguably if you have failed to notice 2bn (32-bit) wakeups then
you have bigger problems. *)

include Unix_activations_minimal
open Lwt.Infix

let nr_events = 1024
Expand All @@ -37,9 +38,6 @@ type port = {
c: unit Lwt_condition.t;
}

external fd: Eventchn.handle -> Unix.file_descr = "stub_evtchn_fd"
external pending: Eventchn.handle -> Eventchn.t = "stub_evtchn_pending"

let ports = Array.init nr_events (fun _ -> { counter = program_start; c = Lwt_condition.create () })

let event_cb = Array.init nr_events (fun _ -> Lwt_dllist.create ())
Expand Down
4 changes: 4 additions & 0 deletions ocaml-evtchn/lib/unix_activations_minimal.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

external fd: Eventchn.handle -> Unix.file_descr = "stub_evtchn_fd"
external pending: Eventchn.handle -> Eventchn.t = "stub_evtchn_pending"

4 changes: 2 additions & 2 deletions ocaml-evtchn/lib_test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
(names main)
(libraries xen-evtchn xen-evtchn-unix ounit2 lwt.unix))

(alias
(name runtest)
(rule
(alias runtest)
(package xen-evtchn-unix)
(deps
(:< main.exe))
Expand Down
27 changes: 27 additions & 0 deletions ocaml-evtchn/xen-evtchn-unix-minimal.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "Xen event channel interface for Linux, without Lwt dependencies"
maintainer: ["[email protected]"]
tags: ["org:mirage" "org:xapi-project"]
homepage: "https://github.com/mirage/ocaml-evtchn"
bug-reports: "https://github.com/mirage/ocaml-evtchn/issues"
depends: [
"dune" {>= "3.15"}
"xen-evtchn" {>= "2.0.0"}
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/mirage/ocaml-evtchn.git"
31 changes: 18 additions & 13 deletions ocaml-evtchn/xen-evtchn-unix.opam
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
maintainer: "[email protected]"
synopsis: "Xen event channel interface for Linux"
maintainer: ["[email protected]"]
authors: [
"Vincent Hanquez" "Anil Madhavapeddy" "David Scott" "Jonathan Ludlam"
]
tags: ["org:mirage" "org:xapi-project"]
homepage: "https://github.com/mirage/ocaml-evtchn"
bug-reports: "https://github.com/mirage/ocaml-evtchn/issues"
doc: "https://mirage.github.io/ocaml-evtchn/"
depends: [
"ocaml" {>= "4.03.0"}
"dune" {>= "1.0"}
"xen-evtchn" {>="2.0.0"}
"dune" {>= "3.15"}
"xen-evtchn" {>= "2.0.0"}
"lwt-dllist"
"lwt"
"cmdliner"
"ounit2" {with-test}
"conf-xen" {build}
"odoc" {with-doc}
]
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/mirage/ocaml-evtchn.git"
synopsis: "Xen event channel interface for Linux"
description: """
Event channels are the Xen equivalent of interrupts, used to signal
when data (or space) is available for processing. This implementation
is a binding to a set of libxc functions which access `/dev/xen/evtchn`
for userspace.
"""
41 changes: 26 additions & 15 deletions ocaml-evtchn/xen-evtchn.opam
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
maintainer: "[email protected]"
synopsis: "Xen event channel interface for MirageOS"
description: """

Event channels are the Xen equivalent of interrupts, used to signal
when data (or space) is available for processing. There are 2 distinct
implementations:

1. a Xen shared-memory + hypercall protocol for kernelspace
2. a binding to a set of libxc functions which access /dev/xen/evtchn
for userspace (see `xen-evtchn-unix` opam package)."""
maintainer: ["[email protected]"]
authors: [
"Vincent Hanquez" "Anil Madhavapeddy" "David Scott" "Jonathan Ludlam"
]
tags: ["org:mirage" "org:xapi-project"]
homepage: "https://github.com/mirage/ocaml-evtchn"
doc: "https://mirage.github.io/ocaml-evtchn/"
bug-reports: "https://github.com/mirage/ocaml-evtchn/issues"
depends: [
"ocaml" {>= "4.03.0"}
"dune" {>= "1.0"}
"dune" {>= "3.15"}
"lwt"
"lwt-dllist"
"cmdliner"
"odoc" {with-doc}
]
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/mirage/ocaml-evtchn.git"
synopsis: "Xen event channel interface for MirageOS"
description: """
Event channels are the Xen equivalent of interrupts, used to signal
when data (or space) is available for processing. There are 2 distinct
implementations:

1. a Xen shared-memory + hypercall protocol for kernelspace
2. a binding to a set of libxc functions which access /dev/xen/evtchn
for userspace (see `xen-evtchn-unix` opam package).
"""

0 comments on commit 11ff051

Please sign in to comment.