Re: [R] registration of C routines

About this list Date view Thread view Subject view Author view Attachment view

From: Duncan Temple Lang (duncan@research.bell-labs.com)
Date: Fri 20 Jul 2001 - 00:07:28 EST


Message-id: <20010719100727.G17865@jessie.research.bell-labs.com>


Hi,,

  There are 3 different places you can find out more about the
registration mechanism. The place to find code examples
is in the libraries in the R distribution. For example, take a
look at
  src/library/ctest/src/init.c

Also, I have collected the descriptions (drafts) I have written
about this. They are available from
  http://cm.bell-labs.com/stat/duncan/R

The C routine R_FindSymbol() is the internal mechanism that finds a
native symbol by name in a package. It is not in the official API, so
is subject to change. Hence it is not a good idea to write your code
to depend on it, but your mileage may vary depending on the context,
etc.

Personally, I would think that it might be better to avoid this
low-level dependency. You might be better off linking the DLL/.so from
the secondary package with that in the first package. Alternatively,
on some platforms, you can specify the value of the local argument as
FALSE for dyn.load() and library.dynam() and that makes the symbols in
that library visible to all the others. Then your C code can call the
routine directly. This has potential danger based on how dlopen()
works on each system and the order in which the libraries have been
loaded.

  D.

Setzer.Woodrow@epamail.epa.gov wrote:
> Almost at the end of the News for R-1.3.0 is the following section:
>
> o New mechanism for explicitly registering native routines in a
> DLL/shared library accessible via .C(), .Call(), .Fortran() and
> .External(). This is potentially more robust than the existing
> dynamic lookup, since it checks the number of arguments, type of
> the routine.
>
> How do I learn how to use this mechanism? Also, is there a sanctioned way
> to find and use, in C-code loaded via dyn.load and executed using one of
> the calls .C(), etc., functions defined in a separate DLL/shared library
> and also loaded with dyn.load?
>
> R. Woodrow Setzer, Jr. Phone:
> (919) 541-0128
> Experimental Toxicology Division Fax: (919) 541-5394
> Pharmacokinetics Branch
> NHEERL MD-74; US EPA; RTP, NC 27711
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
_______________________________________________________________

Duncan Temple Lang duncan@research.bell-labs.com Bell Labs, Lucent Technologies office: (908)582-3217 700 Mountain Avenue, Room 2C-259 fax: (908)582-3340 Murray Hill, NJ 07974-2070 http://cm.bell-labs.com/stat/duncan -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Wed 10 Mar 2004 - 08:18:20 EST