caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Callback.register equivalent before runtime is initialized?
@ 2013-08-15  7:04 Evgeny Roubinchtein
  2013-08-15  7:33 ` David Allsopp
  2013-08-22  5:47 ` [Caml-list] Callback.register equivalent before runtime is oleg
  0 siblings, 2 replies; 4+ messages in thread
From: Evgeny Roubinchtein @ 2013-08-15  7:04 UTC (permalink / raw)
  To: caml-list

Hello, everyone,

I am learning about run-time compilation, and using OCaml as a base for
my experiments.  So far, I have a really simple C primitive that just
calls back into a simple OCaml wrapper around Toplevel.load_lambda (it
passes a Lambda.lambda that has been marshalled to a string constant).
Since the C primitive is in the run-time (libcamlrun) library, and the
wrapper is in the Toplevel, I am using Callback.register to pass the
address of the wrapper to the C primitive.  That set-up works pretty
well in the toplevel because I can call Callback.register when the
toplevel is being initialized, i.e., before any code is read from the
user.  

However, I am now trying to move to producing bytecode executables, so,
if I stay with my current set-up I would need to do the equivalent of
Callback.register (i.e., put the address of the wrapper into the hash
table maintained by caml_callback_register) before any of the "user
code" in the executable starts to run.  I have been looking at the
(bytecode) linker and also the caml_startup function to understand how
the running of bytecode "gets started", and I have also modified tools/objinfo
to print the contens of the SYMB section in bytecode executables and the
relocations table in .cmo's to see if inspiration strikes ;-) -- but so
far I am not quite seeing "how things work."

I'll keep looking, but I though I'd ask for advice here in case someone
has some advice to offer.

-- 
Best,
Evgeny


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

end of thread, other threads:[~2013-08-23 20:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-15  7:04 [Caml-list] Callback.register equivalent before runtime is initialized? Evgeny Roubinchtein
2013-08-15  7:33 ` David Allsopp
2013-08-22  5:47 ` [Caml-list] Callback.register equivalent before runtime is oleg
2013-08-23 20:39   ` Evgeny Roubinchtein

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).