···165165To write C code that operates on OCaml values, the following
166166include files are provided:
167167\begin{tableau}{|l|p{12cm}|}{Include file}{Provides}
168168-\entree{"caml/mlvalues.h"}{definition of the "value" type, and conversion
168168+\entree{"<caml/mlvalues.h>"}{definition of the "value" type, and conversion
169169macros}
170170-\entree{"caml/alloc.h"}{allocation functions (to create structured OCaml
170170+\entree{"<caml/alloc.h>"}{allocation functions (to create structured OCaml
171171objects)}
172172-\entree{"caml/memory.h"}{miscellaneous memory-related functions
172172+\entree{"<caml/memory.h>"}{miscellaneous memory-related functions
173173and macros (for GC interface, in-place modification of structures, etc).}
174174-\entree{"caml/fail.h"}{functions for raising exceptions
174174+\entree{"<caml/fail.h>"}{functions for raising exceptions
175175(see section~\ref{ss:c-exceptions})}
176176-\entree{"caml/callback.h"}{callback from C to OCaml (see
176176+\entree{"<caml/callback.h>"}{callback from C to OCaml (see
177177section~\ref{s:c-callback}).}
178178-\entree{"caml/custom.h"}{operations on custom blocks (see
178178+\entree{"<caml/custom.h>"}{operations on custom blocks (see
179179section~\ref{s:c-custom}).}
180180-\entree{"caml/intext.h"}{operations for writing user-defined
180180+\entree{"<caml/intext.h>"}{operations for writing user-defined
181181serialization and deserialization functions for custom blocks
182182(see section~\ref{s:c-custom}).}
183183-\entree{"caml/threads.h"}{operations for interfacing in the presence
183183+\entree{"<caml/threads.h>"}{operations for interfacing in the presence
184184 of multiple threads (see section~\ref{s:C-multithreading}).}
185185\end{tableau}
186186These files reside in the "caml/" subdirectory of the OCaml
···414414\section{s:c-value}{The \texttt{value} type}
415415416416All OCaml objects are represented by the C type "value",
417417-defined in the include file "caml/mlvalues.h", along with macros to
417417+defined in the include file "<caml/mlvalues.h>", along with macros to
418418manipulate values of that type. An object of type "value" is either:
419419\begin{itemize}
420420\item an unboxed integer;
···615615contains "h", second field "t".}
616616\end{tableau}
617617618618-As a convenience, "caml/mlvalues.h" defines the macros "Val_unit",
618618+As a convenience, "<caml/mlvalues.h>" defines the macros "Val_unit",
619619"Val_false", "Val_true" and "Val_emptylist" to refer to "()",
620620"false", "true" and "[]".
621621···864864according to their size as zero-sized blocks, small blocks (with size
865865less than or equal to \verb"Max_young_wosize"), and large blocks (with
866866size greater than \verb"Max_young_wosize"). The constant
867867-\verb"Max_young_wosize" is declared in the include file "mlvalues.h". It
867867+\verb"Max_young_wosize" is declared in the include file "<caml/mlvalues.h>". It
868868is guaranteed to be at least 64 (words), so that any block with
869869constant size less than or equal to 64 can be assumed to be small. For
870870blocks whose size is computed at run-time, the size must be compared
···936936\subsection{ss:c-simple-gc-harmony}{Simple interface}
937937938938All the macros described in this section are declared in the
939939-"memory.h" header file.
939939+"<caml/memory.h>" header file.
940940941941\begin{gcrule}
942942A function that has parameters or local variables of type "value" must
···15361536and macros:
15371537\begin{itemize}
15381538\item "value caml_get_value_or_raise(caml_result "\var{res}")"
15391539- (in "fail.h") returns the value contained in \var{res} or reraises
15391539+ (in "<caml/fail.h>") returns the value contained in \var{res} or reraises
15401540 the exception it contains. In particular,
15411541 "(void)caml_get_value_or_raise(res)" can be used to ignore an OCaml
15421542 result of type "unit", yet propagate exceptions to the caller.
1543154315441544-\item "Result_value(value "\var{v}")" (in "mlvalues.h") is the result
15441544+\item "Result_value(value "\var{v}")" (in "<caml/mlvalues.h>") is the result
15451545 that represents returning the value \var{v}.
1546154615471547-\item "Result_exception(value "\var{exn}")" (in "mlvalues.h") is the
15471547+\item "Result_exception(value "\var{exn}")" (in "<caml/mlvalues.h>") is the
15481548 result that represents raising the exception \var{exn}.
1549154915501550\item "int caml_result_is_exception(caml_result "\var{res}")"
15511551- (in "mlvalues.h") is true if \var{res} represents an exception.
15511551+ (in "<caml/mlvalues.h>") is true if \var{res} represents an exception.
1552155215531553-\item The macro "CAMLlocalresult(foo)" (in "memory.h") is the
15531553+\item The macro "CAMLlocalresult(foo)" (in "<caml/memory.h>") is the
15541554 "caml_result" counterpart of "CAMLlocal1": it declares a local
15551555 variable of type "caml_result", whose content is tracked by the
15561556 OCaml GC. Just like "CAMLlocal1", it can only be used between
···18861886by calling "Printexc.record_backtrace true" in the initialization of
18871887one of the OCaml modules. This can also be achieved from the C side
18881888by calling "caml_record_backtraces(1);" in the OCaml-C glue code.
18891889-("caml_record_backtraces" is declared in "backtrace.h")
18891889+("caml_record_backtraces" is declared in "<caml/backtrace.h>")
1890189018911891\paragraph{Unloading the runtime.}
18921892···19061906including "dynlink" plugins.
19071907\item Freeing the memory blocks that were allocated by the runtime with
19081908"malloc". Inside C primitives, it is advised to use "caml_stat_*" functions
19091909-from "memory.h" for managing static (that is, non-moving) blocks of heap
19091909+from "<caml/memory.h>" for managing static (that is, non-moving) blocks of heap
19101910memory, as all the blocks allocated with these functions are automatically
19111911freed by "caml_shutdown". For ensuring compatibility with legacy C stubs that
19121912have used "caml_stat_*" incorrectly, this behaviour is only enabled if the
···3023302330243024\subsection{ss:c-internal-macros}{OCaml version macros}
30253025Finally, if including the right headers is not enough, or if you need to support
30263026-version older than OCaml 4.04, the header file "caml/version.h" should help
30263026+version older than OCaml 4.04, the header file "<caml/version.h>" should help
30273027you to define your own compatibility layer.
30283028This file provides few macros defining the current OCaml version.
30293029In particular, the "OCAML_VERSION" macro describes the current version,