Commits

seanmcl  committed 4def14a

ocaml_inotify as packed module

  • Participants
  • Parent commits d62e18a

Comments (0)

Files changed (4)

 ocp-indent/ocp.ml
 ocp-indent/tuareg.ml
 elisp/omake/scratch.el
-ocaml/contrib/ocaml_inotify/test.inotify
+ocaml/contrib/ocaml_inotify/inotify_test

File ocaml/contrib/ocaml_inotify/Makefile

 OCAMLC = ocamlc
 OCAMLOPT = ocamlopt
 
+OS=$(shell uname)
+
+ifeq ($(OS), Darwin)
+  CC_OPTS=-bundle -flat_namespace -undefined suppress
+else
+  CC_OPTS=-shared
+endif
+
 # inotify.cmxa: inotify_stubs.o inotify.cmx inotify.cmo
 #	ocamlmklib -o inotify inotify_stubs.o inotify.cmx inotify.cmo
 #	ocamlopt -pack -o ocaml_inotify.cmxa unix.cmxa inotify_stubs.o inotify.cmx
 #	ocamlc -pack -o $@ inotify.cmo inotify_stubs.o
 #	ar rc libinotify.a inotify_stubs.o
 
-# inotify.cma: inotify_stubs.o inotify.cmx inotify.cmo
+# inotify.cma: inotify_stubs.o inotify.cmi inotify.cmx inotify.cmo
 # 	ocamlmklib -v -o inotify unix.cma inotify_stubs.o inotify.cmx inotify.cmo
 
 # inotify.cmxa: inotify_stubs.o inotify.cmi inotify.cmo inotify.cmx

File ocaml/contrib/ocaml_inotify/inotify_test.ml

+(* unit testing inotify *)
+
+module Inotify = Ocaml_inotify.Inotify
+open Printf
+
+let _ =
+  if Array.length Sys.argv < 2 then (
+    eprintf "usage: %s <path>\n" Sys.argv.(0);
+    exit 1
+  );
+
+  let fd = Inotify.init () in
+
+  let watches = ref 0 in
+
+  while true do
+    watches := !watches + 1;
+    if !watches mod 1000000 = 0 then Printf.printf "watches: %d\n%!" !watches;
+    ignore (Inotify.add_watch fd Sys.argv.(1) [ Inotify.S_All ]);
+  done;
+
+  let string_of_event ev =
+    let wd,mask,cookie,s = ev in
+    let mask = String.concat ":" (List.map Inotify.string_of_event mask) in
+    let s = match s with Some s -> s | None -> "\"\"" in
+    sprintf "wd [%u] mask[%s] cookie[%ld] %s" (Inotify.int_of_wd wd)
+      mask cookie s
+  in
+
+  let nb = ref 0 in
+  while true
+  do
+    let _, _, _ = Unix.select [ fd ] [] [] (-1.) in
+    let evs = Inotify.read fd in
+    List.iter (fun ev ->
+      printf "[%d] %s\n%!" !nb (string_of_event ev)) evs;
+    incr nb
+  done;
+
+  Unix.close fd

File ocaml/contrib/ocaml_inotify/test.inotify.ml

-(* unit testing inotify *)
-
-module Inotify = Ocaml_inotify.Inotify
-open Printf
-
-let _ =
-  if Array.length Sys.argv < 2 then (
-    eprintf "usage: %s <path>\n" Sys.argv.(0);
-    exit 1
-  );
-
-  let fd = Inotify.init () in
-
-  let watches = ref 0 in
-
-  while true do
-    watches := !watches + 1;
-    if !watches mod 1000000 = 0 then Printf.printf "watches: %d\n%!" !watches;
-    ignore (Inotify.add_watch fd Sys.argv.(1) [ Inotify.S_All ]);
-  done;
-
-  let string_of_event ev =
-    let wd,mask,cookie,s = ev in
-    let mask = String.concat ":" (List.map Inotify.string_of_event mask) in
-    let s = match s with Some s -> s | None -> "\"\"" in
-    sprintf "wd [%u] mask[%s] cookie[%ld] %s" (Inotify.int_of_wd wd)
-      mask cookie s
-  in
-
-  let nb = ref 0 in
-  while true
-  do
-    let _, _, _ = Unix.select [ fd ] [] [] (-1.) in
-    let evs = Inotify.read fd in
-    List.iter (fun ev ->
-      printf "[%d] %s\n%!" !nb (string_of_event ev)) evs;
-    incr nb
-  done;
-
-  Unix.close fd