From: "Christoph Höger" <christoph.hoeger@tu-berlin.de>
To: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Save callbacks from OCaml to C
Date: Wed, 3 Feb 2016 15:38:01 +0100 [thread overview]
Message-ID: <56B210C9.3050703@tu-berlin.de> (raw)
In-Reply-To: <CANhEzE4AHvaOv9GLZrOLJvv_p4sv1v7Tsu1w4xX6puWOyQmGqw@mail.gmail.com>
Am 03.02.2016 um 14:49 schrieb Jeremie Dimino:
> CAMLparam0 is for when you have no [value] arguments but have some local
> [value] variables. CAMLlocalN must be preceded by a CAMLparamY, that's
> why you need the CAMLparam0.
Thanks. I wasn't sure about that, since I tried before and my stack
values were overwritten (I assumed it was the GC at that time).
> So if the GC ends up moving [g], it needs to know that it must update
> [user_data->g] to point to the new location.
Even more subtle. user_data was a pointer to the body of a custom
allocated block. My huge mistake was to use the custom_val directly
(i.e. I allocated n bytes and passed around the pointer to these n
bytes). As it turns out, the GC may move a custom block by memcopying
its body. So in that body I needed pointers to allocated data not the
allocated data itself.
Thanks again!
--
Christoph Höger
Technische Universität Berlin
Fakultät IV - Elektrotechnik und Informatik
Übersetzerbau und Programmiersprachen
Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin
Tel.: +49 (30) 314-24890
E-Mail: christoph.hoeger@tu-berlin.de
prev parent reply other threads:[~2016-02-03 14:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-03 10:54 Christoph Höger
2016-02-03 11:48 ` Jeremie Dimino
2016-02-03 12:26 ` Malcolm Matalka
2016-02-03 13:44 ` David Sheets
2016-02-03 18:02 ` Jeremy Yallop
2016-02-03 20:15 ` Malcolm Matalka
2016-02-04 0:14 ` Jeremy Yallop
2016-02-04 7:26 ` Malcolm Matalka
2016-02-04 19:29 ` Jeremy Yallop
[not found] ` <56B1EC33.2090303@tu-berlin.de>
2016-02-03 13:49 ` Jeremie Dimino
2016-02-03 14:38 ` Christoph Höger [this message]
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=56B210C9.3050703@tu-berlin.de \
--to=christoph.hoeger@tu-berlin.de \
--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