ocamllabs/ocaml-ctypes — pull request #80 by yallop (2013-10-29 12:19:52+00:00)
Title: Optional threading support

Functorize the `foreign` package to provide a thread-safe version and a version that doesn't use threads. The `META` file is set up so that ocamlfind will link against the right version according to the flags used to build the client library.

Without `-thread`:
```
$ ocamlfind ocamlc -verbose -linkpkg -package ctypes.foreign tst.cmo -o tst
Effective set of compiler predicates: pkg_unix,pkg_bigarray,pkg_ctypes,\
pkg_ctypes.foreign-base,pkg_ctypes.foreign,autolink,byte
+ ocamlc.opt -verbose -o tst -I /home/jeremy/.opam/4.01.0/lib/ctypes \
/home/jeremy/.opam/4.01.0/lib/ocaml/unix.cma \
/home/jeremy/.opam/4.01.0/lib/ocaml/bigarray.cma \
/home/jeremy/.opam/4.01.0/lib/ctypes/ctypes.cma \
/home/jeremy/.opam/4.01.0/lib/ctypes/ctypes-foreign-base.cma \
/home/jeremy/.opam/4.01.0/lib/ctypes/ctypes-foreign-unthreaded.cma \
tst.cmo
```

With `-thread`:
```
$ ocamlfind ocamlc -verbose -thread -linkpkg -package ctypes.foreign tst.cmo -o tst
Effective set of compiler predicates: pkg_unix,pkg_threads.posix,pkg_threads,pkg_bigarray,pkg_ctypes,\
pkg_ctypes.foreign-base,pkg_ctypes.foreign,autolink,mt,mt_posix,byte
+ ocamlc.opt -verbose -o tst -thread -I /home/jeremy/.opam/4.01.0/lib/ctypes \
/home/jeremy/.opam/4.01.0/lib/ocaml/unix.cma \
/home/jeremy/.opam/4.01.0/lib/ocaml/threads/threads.cma \
/home/jeremy/.opam/4.01.0/lib/ocaml/bigarray.cma \
/home/jeremy/.opam/4.01.0/lib/ctypes/ctypes.cma \
/home/jeremy/.opam/4.01.0/lib/ctypes/ctypes-foreign-base.cma \
/home/jeremy/.opam/4.01.0/lib/ctypes/ctypes-foreign-threaded.cma \
tst.cmo
```