From 1e9cf5b06a9eeed3dcdc49efa59f70eff53457fb Mon Sep 17 00:00:00 2001 From: Virgile Prevosto <virgile.prevosto@m4x.org> Date: Thu, 5 Mar 2020 16:51:28 +0100 Subject: [PATCH] [extlib] remove usleep, as sleepf introduced in 4.03.0 does the same thing --- src/libraries/stdlib/extlib.ml | 9 ++------- src/libraries/stdlib/extlib.mli | 5 ----- src/libraries/utils/c_bindings.c | 6 ------ src/libraries/utils/command.ml | 2 +- src/libraries/utils/task.ml | 5 +++-- 5 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/libraries/stdlib/extlib.ml b/src/libraries/stdlib/extlib.ml index 3b0ee2265e7..832dbc10bfb 100644 --- a/src/libraries/stdlib/extlib.ml +++ b/src/libraries/stdlib/extlib.ml @@ -436,17 +436,12 @@ let temp_dir_cleanup_at_exit ?(debug=false) base = in try_dir_cleanup_at_exit 10 base -(* replace "noalloc" with [@@noalloc] for OCaml version >= 4.03.0 *) -[@@@ warning "-3"] -external usleep: int -> unit = "ml_usleep" "noalloc" - (* In ../utils/c_bindings.c ; man usleep for details. *) - (* ************************************************************************* *) (** Strings *) (* ************************************************************************* *) -external compare_strings: string -> string -> int -> bool = "compare_strings" "noalloc" -[@@@ warning "+3"] +external compare_strings: string -> string -> int -> bool = + "compare_strings" [@@noalloc] let string_prefix ?(strict=false) prefix s = let add = if strict then 1 else 0 in diff --git a/src/libraries/stdlib/extlib.mli b/src/libraries/stdlib/extlib.mli index 6b8084f6922..50d3745f550 100644 --- a/src/libraries/stdlib/extlib.mli +++ b/src/libraries/stdlib/extlib.mli @@ -382,11 +382,6 @@ val safe_remove: string -> unit val safe_remove_dir: string -> unit -val usleep: int -> unit - (** Unix function that sleep for [n] microseconds. - See [man usleep] for details. - Should not be used under Win32. *) - (* ************************************************************************* *) (** Comparison functions *) (* ************************************************************************* *) diff --git a/src/libraries/utils/c_bindings.c b/src/libraries/utils/c_bindings.c index b03878d2dce..743f47dbda4 100644 --- a/src/libraries/utils/c_bindings.c +++ b/src/libraries/utils/c_bindings.c @@ -253,9 +253,3 @@ value single_precision_of_string(value str) double d = f; return caml_copy_double(d); } - -value ml_usleep(value v) -{ - usleep( Int_val(v) ); - return Val_unit ; -} diff --git a/src/libraries/utils/command.ml b/src/libraries/utils/command.ml index be4593d70d7..22ab26bbb6a 100644 --- a/src/libraries/utils/command.ml +++ b/src/libraries/utils/command.ml @@ -259,7 +259,7 @@ let command ?(timeout=0) ?stdout ?stderr cmd args = | Result r -> res := r; false - in while running () do Extlib.usleep 100000 (* 0.1s *) done ; !res + in while running () do Unix.sleepf 0.1 done ; !res else let f = command_generic ~async:false ?stdout ?stderr cmd args in match f () with diff --git a/src/libraries/utils/task.ml b/src/libraries/utils/task.ml index 6dd5eb96cff..164a847defb 100644 --- a/src/libraries/utils/task.ml +++ b/src/libraries/utils/task.ml @@ -109,7 +109,8 @@ struct let rec wait = function | UNIT a -> a | YIELD f -> Db.yield() ; wait (f Coin) - | WAIT(ms,f) -> Db.yield() ; Extlib.usleep ms ; wait (f Coin) + | WAIT(ms,f) -> + Db.yield() ; Unix.sleepf (float_of_int ms /. 1_000_000.); wait (f Coin) let finished = function UNIT a -> Some a | YIELD _ | WAIT _ -> None @@ -341,7 +342,7 @@ let share sh = todo let on_idle = ref (fun f -> try - while f () do Extlib.usleep 50000 (* wait for 50ms *) done + while f () do Unix.sleepf 0.05 (* wait for 50ms *) done with Db.Cancel -> ()) (* -------------------------------------------------------------------------- *) -- GitLab