Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
va_arg values
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-01-15 (22:38)
From: Bob Matcuk <Hamartiology@s...>
Subject: Re: [Caml-list] va_arg values
On Mon, 15 Jan 2007 10:44:07 +0000
Richard Jones <> wrote:

> The CAMLparam/CAMLlocal/CAMLreturn/CAMLxparam macros are pretty simple
> to understand.  I suggest you take some simple code using these
> macros, run it through cpp, and have a look at what these macros
> actually generate.  You will be able to make your own (possibly
> non-portable) variations which update caml_local_roots etc. directly.
> If that is necessary.

Indeed. As I said in my original e-mail, I have already written my own
code to do what CAMLparam/CAMLlocal/CAMLxparam do for variable
arguments. Basically, well... Lets start with the quickest question to
answer: is it even necessary?

IF my function is only to be called from other C functions AND if those
functions have already properly registered all of the values via
CAMLparam/CAMLlocal/CAMLxparam (a safe assumption assuming competent
programming) THEN: is it necessary for my function to bother
re-registering these values?

My guess would be no. Generally, it would seem to me that a function
should only have to bother with the
CAMLparam/CAMLlocal/CAMLxparam/CAMLreturn stuff if it makes allocations
via "caml_" functions (malloc and friends would be safe as they have no
hooks into the OCaml GC). Is this true?

Bob Matcuk

Explanation of My Return Address, GPG Key: