From a61aaefdace17345ae6f6216ce9f2d935a70987b Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Thu, 26 May 2022 14:48:02 +0100 Subject: [PATCH] Support OCaml 5 new Unix primitive names --- src/unix/dune | 7 +++++++ src/unix/{lwt_process.ml => lwt_process.cppo.ml} | 4 ++++ src/unix/lwt_unix.cppo.ml | 4 ++++ 3 files changed, 15 insertions(+) rename src/unix/{lwt_process.ml => lwt_process.cppo.ml} (99%) diff --git a/src/unix/dune b/src/unix/dune index 80b2917e68..b788a9e752 100644 --- a/src/unix/dune +++ b/src/unix/dune @@ -8,6 +8,13 @@ let preprocess = let () = Jbuild_plugin.V1.send @@ {| +(rule + (targets lwt_process.ml) + (deps (:ml lwt_process.cppo.ml)) + (action + (chdir %{project_root} + (run %{bin:cppo} -V OCAML:%{ocaml_version} %{ml} -o %{targets})))) + (rule (targets lwt_unix.ml) (deps (:ml lwt_unix.cppo.ml)) diff --git a/src/unix/lwt_process.ml b/src/unix/lwt_process.cppo.ml similarity index 99% rename from src/unix/lwt_process.ml rename to src/unix/lwt_process.cppo.ml index ecd5051f76..b722ba1f3e 100644 --- a/src/unix/lwt_process.ml +++ b/src/unix/lwt_process.cppo.ml @@ -136,7 +136,11 @@ let unix_redirect fd redirection = match redirection with Unix.dup2 fd' fd; Unix.close fd' +#if OCAML_VERSION >= (5, 0, 0) +external unix_exit : int -> 'a = "caml_unix_exit" +#else external unix_exit : int -> 'a = "unix_exit" +#endif let unix_spawn ?cwd diff --git a/src/unix/lwt_unix.cppo.ml b/src/unix/lwt_unix.cppo.ml index 448ff2ad04..92be62031b 100644 --- a/src/unix/lwt_unix.cppo.ml +++ b/src/unix/lwt_unix.cppo.ml @@ -2495,7 +2495,11 @@ let wait () = waitpid [] (-1) external system_job : string -> int job = "lwt_unix_system_job" +#if OCAML_VERSION >= (5, 0, 0) +external unix_exit : int -> 'a = "caml_unix_exit" +#else external unix_exit : int -> 'a = "unix_exit" +#endif let system cmd = if Sys.win32 then