[ocaml-ctypes] Spinning process on osx

Daniel Bünzli daniel.buenzli at erratique.ch
Tue Feb 11 19:13:44 GMT 2014


Excellent ! I can now even rule out SDL, mach_absolute_time [1] does the job. 

The minimal so far, completely self-contained is at the end of the file. Note that slightly tweaking the program (e.g. print the results in the loop) makes the program work.

Best,

Daniel

[1] http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/osfmk/mach/mach_time.h


--- bug.ml ---
(* 
   The annoying bug.
   Compile with
   ocamlfind ocamlopt -package ctypes,ctypes.foreign -linkpkg \
             -o bug.native bug.ml
*)

open Ctypes
open Foreign

let mach_absolute_time = 
  foreign "mach_absolute_time" (void @-> returning uint64_t)

let main () = 
  Printf.printf "Enter%!";
  while true do ignore (mach_absolute_time ()) done
          
let () = main ()

----








More information about the Ctypes mailing list