Browse thread
Question about CAMLparamx macros
- Raj Bandyopadhyay
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Raj Bandyopadhyay <rajb@r...> |
| Subject: | Question about CAMLparamx macros |
Hi
I am programming using the OCaml-C interface, and occasionally, my
program segfaults in the OCaml function 'caml_oldify_local_roots()'
From previous experience, I know that this usually means that I'm not
using the CAMLparam/CAMLreturn macros correctly somewhere, causing the
OCaml gc to find NULL pointers.
My question is, when do I have to use or not use these macros? I know I
need to use these when my C function accepts AND returns OCaml 'value'
types, but what about the following cases?
1) When the C function takes a value as parameter or creates a value
local variable, but returns something else e.g.
char *foo(value v, int x)
2) When the C function does not create a value local variable explicitly
or takes a value as a parameter but returns the result of a callback to
the OCaml runtime
e.g.
value foo(int x) {return caml_callback_exn(*caml_named_value(...),...)}
Do I have to use the CAMLparamx/CAMLlocalx/CAMLreturnx macros in the
above cases? Would it cause problems if I used them anyway?
Thanks
Raj