Skip to content

Commit

Permalink
Resolve issue with Seq.length for ocaml < 4.14
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrm committed Oct 29, 2024
1 parent d89e669 commit a96f28c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src_lockfree/dune
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ let () =
(action
(copy domain.ocaml4.ml domain.ml)))

(rule
(enabled_if
(< %{ocaml_version} 4.14.0))
(action
(copy seq.ocaml4.13.ml seq.ml)))

(rule
(enabled_if
(< %{ocaml_version} 5.2.0))
Expand All @@ -34,6 +40,5 @@ let () =
(enabled_if
(<> %{os_type} Win32))
(libraries saturn_lockfree)
(files bounded_stack.mli))

(files treiber_stack.mli))
|}
6 changes: 6 additions & 0 deletions src_lockfree/seq.ocaml4.13.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include Seq

let rec length_aux accu xs =
match xs () with Nil -> accu | Cons (_, xs) -> length_aux (accu + 1) xs

let[@inline] length xs = length_aux 0 xs

0 comments on commit a96f28c

Please sign in to comment.