Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: Warp <warplayer@free.fr>
Cc: OCaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Callback in DLL
Date: Thu, 3 Jan 2002 15:34:12 +0100	[thread overview]
Message-ID: <20020103153412.A20919@pauillac.inria.fr> (raw)
In-Reply-To: <004001c18f9e$e3f58e10$f7fdfdc1@warp>; from warplayer@free.fr on Fri, Dec 28, 2001 at 01:55:12PM +0100

> > If you're building a DLL whose purpose is to be loaded inside
> > ocamlrun, then you should link with ocamlrun.lib, which is an "import
> > library" around the DLL entry points exported by ocamlrun.
> 
> 1) if I only link ocamlrun.lib, it can't find external "local_roots" needed
> in CAMLparamX

You probably forgot to compile your C code with the /MD flag (meaning
"multithreaded DLL").

Explanation: the Win32 dynamic linker cannot cope with shared global
variables, so these need to be accessed by calls to shared functions.
The C compiler generates the calls provided the global variable is
declared "dllimport".  The Caml header files add the proper
declaration provided the _DLL symbol is defined.  The C compiler
defines _DLL if it is invoked with the /MD flag.  End of inference :-)

> so I have to use my caml_init_func (dll entry point) and a modified
> interpreter
> which call the entry point passing the adress of local_roots.

No you don't have to modify anything.  Just read carefully the
makefiles in the system sources and follow what's done there.

> > Of course.  You didn't tell it that you've kept a pointer to "v" in
> > the window data.  So, as far as the GC is concerned, nobody is
> > pointing to "v", so it can be freed.
> 
> Actually , "v" is returned to the caml, and then let-stored. So it is
> referenced.

All right, but the GC also moves live blocks around, so it really
needs to know all the pointers to the block.

- Xavier Leroy
-------------------
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


      reply	other threads:[~2002-01-03 14:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-26 18:42 Warp
2001-12-28  8:49 ` Xavier Leroy
2001-12-28 12:55   ` Warp
2002-01-03 14:34     ` Xavier Leroy [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=20020103153412.A20919@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=warplayer@free.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