Skip to content

Commit

Permalink
[coq] Adapt Coq.Protect interface to incorporate an interruption to…
Browse files Browse the repository at this point in the history
…ken.

- We now conditionally depend on `memprof-limits` on OCaml 4.x
- Each call that can be interrupted now additionally takes a `Token.t`

There is still more work to be done so this can be properly used.

cc: #509
  • Loading branch information
ejgallego committed Mar 31, 2024
1 parent 2f9411f commit 032cdc9
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 4 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ jobs:
ocaml: 4.13.x
- os: ubuntu-latest
ocaml: 4.12.x
- os: ubuntu-latest
ocaml: 4.11.x
- os: ubuntu-latest
ocaml: 5.0.x
- os: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
- new option `--no_vo` for `fcc`, which will skip the `.vo` saving
step. `.vo` saving is now an `fcc` plugins, but for now, it is
enabled by default (@ejgallego, #650)
- depend on `memprof-limits` on OCaml 4.x (@ejgallego, #660)
- bump minimal OCaml version to 4.12 due to `memprof-limits`
(@ejgallego, #660)

# coq-lsp 0.1.8.1: Spring fix
-----------------------------
Expand Down
4 changes: 3 additions & 1 deletion coq-lsp.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ license: "LGPL-2.1-or-later"
doc: "https://ejgallego.github.io/coq-lsp/"

depends: [
"ocaml" { >= "4.11.0" }

("ocaml" {>= "5.0"} | ("ocaml" {<= "5.0"} & "memprof-limits" { >= "0.2.1" } ))

"dune" { >= "3.13.0" } # Version interval [3.8-3.12] was
# broken for composed builds with Coq

Expand Down
6 changes: 5 additions & 1 deletion coq/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
(inline_tests)
(preprocess
(pps ppx_compare ppx_hash ppx_inline_test))
(libraries lang coq-core.vernac coq-serapi.serlib))
(libraries
(select limits.ml from
(memprof-limits -> limits.mp.ml)
(!memprof-limits -> limits.dummy.ml))
lang coq-core.vernac coq-serapi.serlib))
10 changes: 10 additions & 0 deletions coq/limits.dummy.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Token = struct
type t = bool ref
let create () = ref false
let set r = r := true
let is_set r = !r
end

let start () = ()

let limit_with_token ~token:_ f = Result.Ok (f ())
12 changes: 12 additions & 0 deletions coq/limits.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(* This is a wrapper for the memprof-limits lib, as it is not
available in most setups *)
module Token : sig
type t
val create : unit -> t
val set : t -> unit
val is_set : t -> bool
end

val start : unit -> unit

val limit_with_token : token:Token.t -> (unit -> 'a) -> ('a, exn) Result.t
5 changes: 5 additions & 0 deletions coq/limits.mp.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Token = Memprof_limits.Token

let start = Memprof_limits.start_memprof_limits

let limit_with_token = Memprof_limits.limit_with_token

0 comments on commit 032cdc9

Please sign in to comment.