@@ -1984,10 +1984,10 @@ block (as given by the "identifier" field) to the output stream,
1984
1984
then call the user-provided "serialize" function. That function is
1985
1985
responsible for writing the data contained in the custom block, using
1986
1986
the "serialize_..." functions defined in "<caml/intext.h>" and listed
1987
- below . The user-provided "serialize" function must then store in its
1988
- "bsize_32" and "bsize_64" parameters the sizes in bytes of the data
1989
- part of the custom block on a 32-bit architecture and on a 64-bit
1990
- architecture, respectively.
1987
+ in section~\ref{ss:c-custom-serialization} . The user-provided "serialize"
1988
+ function must then store in its "bsize_32" and "bsize_64" parameters the sizes
1989
+ in bytes of the data part of the custom block on a 32-bit architecture and on a
1990
+ 64-bit architecture, respectively.
1991
1991
1992
1992
The "serialize" field can be set to "custom_serialize_default",
1993
1993
in which case the "Failure" exception is raised when attempting to
@@ -2000,12 +2000,12 @@ be deserialized (un-marshaled) using the OCaml functions "input_value"
2000
2000
or "Marshal.from_...". This user-provided function is responsible for
2001
2001
reading back the data written by the "serialize" operation, using the
2002
2002
"deserialize_..." functions defined in "<caml/intext.h>" and listed
2003
- below . It must then rebuild the data part of the custom block
2004
- and store it at the pointer given as the "dst" argument. Finally, it
2005
- returns the size in bytes of the data part of the custom block.
2006
- This size must be identical to the "wsize_32" result of
2007
- the "serialize" operation if the architecture is 32 bits, or
2008
- "wsize_64" if the architecture is 64 bits.
2003
+ in section~\ref{ss:c-custom-serialization} . It must then rebuild the data part
2004
+ of the custom block and store it at the pointer given as the "dst" argument.
2005
+ Finally, it returns the size in bytes of the data part of the custom block.
2006
+ This size must be identical to the "wsize_32" result of the "serialize"
2007
+ operation if the architecture is 32 bits, or "wsize_64" if the architecture is
2008
+ 64 bits.
2009
2009
2010
2010
The "deserialize" field can be set to "custom_deserialize_default"
2011
2011
to indicate that deserialization is not supported. In this case,
@@ -2023,13 +2023,16 @@ specified in the "fixed_length" structure, and do not consume space in
2023
2023
the serialized output.
2024
2024
\end{itemize}
2025
2025
2026
- Note: the "finalize", "compare", "hash", "serialize" and "deserialize"
2027
- functions attached to custom block descriptors must never access the
2028
- OCaml runtime. Within these functions, do not call any of the OCaml
2029
- allocation functions, and do not perform a callback into OCaml code.
2030
- Do not use "CAMLparam" to register the parameters to these functions,
2031
- and do not use "CAMLreturn" to return the result. Do not raise
2032
- exceptions, do not remove global roots, etc.
2026
+ Note: the "finalize", "compare", "hash", "serialize", and "deserialize"
2027
+ functions attached to custom blocks descriptors are only allowed limited
2028
+ interactions with the OCaml runtime. Within these functions, do not call any of
2029
+ the OCaml allocation functions, and do not perform any callback into OCaml
2030
+ code. Do not use "CAMLparam" to register the parameters to these functions, and
2031
+ do not use "CAMLreturn" to return the result. Do not raise exceptions (to
2032
+ signal an error during deserialization, use "caml_deserialize_error"). Do not
2033
+ remove global roots. When in doubt, err on the side of caution. Within
2034
+ "serialize" and "deserialize" functions, use of the corresponding functions
2035
+ from section~\ref{ss:c-custom-serialization} is allowed (and even recommended).
2033
2036
2034
2037
\subsection{ss:c-custom-alloc}{Allocating custom blocks}
2035
2038
0 commit comments