Move some common functionality into utils module
[llpp/slowscroll.git] / utils.ml
blobbbfea1038eb5acb5abd71b70f28ef4edb2c00552
1 let tempfailureretry f a =
2 let rec g () =
3 try f a with Unix.Unix_error (Unix.EINTR, _, _) -> g ()
4 in g ()
5 ;;
7 external cloexec : Unix.file_descr -> unit = "ml_cloexec";;
8 external hasdata : Unix.file_descr -> bool = "ml_hasdata";;
9 external toutf8 : int -> string = "ml_keysymtoutf8";;
10 external mbtoutf8 : string -> string = "ml_mbtoutf8";;
12 let dolog fmt = Format.kprintf prerr_endline fmt;;
14 let exntos = function
15 | Unix.Unix_error (e, s, a) -> Printf.sprintf "%s(%s) : %s (%d)"
16 s a (Unix.error_message e) (Obj.magic e)
17 | exn -> Printexc.to_string exn;
20 let error fmt = Printf.kprintf failwith fmt;;
22 let now = Unix.gettimeofday;;