Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Question about CAMLparamx macros
@ 2008-04-10 16:20 Raj Bandyopadhyay
  2008-04-10 16:49 ` [Caml-list] " Mathias Kende
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Raj Bandyopadhyay @ 2008-04-10 16:20 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-11 13:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-10 16:20 Question about CAMLparamx macros Raj Bandyopadhyay
2008-04-10 16:49 ` [Caml-list] " Mathias Kende
2008-04-10 17:48 ` Richard Jones
2008-04-11 13:42 ` Damien Doligez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox