From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: avv@quasar.ipa.nw.ru
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] GC and interoperability with C
Date: Mon, 09 Jul 2001 15:59:00 +0900 [thread overview]
Message-ID: <20010709155900C.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <3B493A40.1B2985FE@quasar.ipa.nw.ru>
> From what I see in the documentation, I see no way to 'lock' an OCaml
> value on the heap so that it can be safely accessed from C code, and
> then 'unlock' it, say, in the finalization function of some
> Custom_block. In contrast to Python, e.g., where you just increment and
> decrement the reference count.
Yes, Python uses (used?) reference counting. More clever (and faster)
GC's, like that of caml, have to move things around.
> If this is right, the interaction of OCaml to C becomes one-way, you
> cannot safely access OCaml world from arbitrary C code.
Yes, you can. You just have to register a pointer with the GC, and
everytime the target is moved around, the pointer will be updated.
See
void register_global_root (value *);
void remove_global_root (value *);
in memory.h.
After that, you must be careful of always accessing values through the
pointer, not directly.
Jacques Garrigue
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
next prev parent reply other threads:[~2001-07-09 6:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-09 4:59 Alexander V. Voinov
2001-07-09 6:59 ` Jacques Garrigue [this message]
[not found] ` <3B49C748.9CFB4E6@quasar.ipa.nw.ru>
[not found] ` <20010710094419W.garrigue@kurims.kyoto-u.ac.jp>
2001-07-10 0:46 ` Alexander V. Voinov
2001-07-12 5:47 ` Alexander V. Voinov
2001-07-12 7:34 ` Xavier Leroy
2001-07-12 15:42 ` Alexander V. Voinov
2001-07-09 22:08 Alexander V. Voinov
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=20010709155900C.garrigue@kurims.kyoto-u.ac.jp \
--to=garrigue@kurims.kyoto-u.ac.jp \
--cc=avv@quasar.ipa.nw.ru \
--cc=caml-list@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;
as well as URLs for NNTP newsgroup(s).