Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Raj Bandyopadhyay <rajb@rice.edu>
To: caml-list@yquem.inria.fr
Subject: Question about CAMLparamx macros
Date: Thu, 10 Apr 2008 11:20:53 -0500	[thread overview]
Message-ID: <47FE3E65.7030907@rice.edu> (raw)

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


             reply	other threads:[~2008-04-10 16:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-10 16:20 Raj Bandyopadhyay [this message]
2008-04-10 16:49 ` [Caml-list] " Mathias Kende
2008-04-10 17:48 ` Richard Jones
2008-04-11 13:42 ` Damien Doligez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47FE3E65.7030907@rice.edu \
    --to=rajb@rice.edu \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox