Karim BELABAS on Wed, 27 Nov 2002 10:58:48 +0100 (MET)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Patch for install: allow to change prototype


On Tue, 26 Nov 2002, Ilya Zakharevich wrote:

> On Tue, Nov 26, 2002 at 02:55:33PM +0100, Karim BELABAS wrote:
> > > BTW, I see no reason to have the warning at all.  How is it different from
>
> > >  ? f() = 12
> > >  ? f() = 12
> >
> > I don't know how to safely "reload" a symbol from an external library. In
> > particular, you cannot recompile an external module, and re-install a
> > routine. You can kill() its GP wrapper, then formally re-install it, but
> > unless dlclose() is called first, you install the old version (still loaded
> > in memory).
>
> If I understand it correct, the *only* information we keep about the
> address space of the external library is an entry in entree.

This is correct.

> Thus it should be safe to do dlclose() at the appropriate time.

The "appropriate time" never occurs unless we explicitly kill everything from
that particular DLL first. I don't see a sane way of having install() cleanly
overwrite a single definition [ from the same DLL ].

The following is doable but very awkward.
  install(f) + kill(f) [ + kill(f2) + ... + kill(fn) ] + install(f)

Only way out I see is to implement (not necessarily export to GP):

  killDLL({F}): kill all symbols associated to the DLL 'F' then unload the
  DLL from memory. If F is omitted, kill all symbols installed from the pari
  library. For convenience, F is allowed to be the name of an installed
  function, in which case, the associated DLL (and all its symbols) is
  unloaded.

[ Need to maintain a hash of DLL filenames, associated to the list of loaded
symbols ]

This way, it is possible to have install(f) call killDLL(f) first if f is
already there, and cancel the warning. All the above implicitly assumes that
no routine from the DLL returns a reference to static data...

    Karim.
-- 
Karim Belabas                    Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 425  Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud             Email: Karim.Belabas@math.u-psud.fr
F-91405 Orsay (France)           http://www.math.u-psud.fr/~belabas/
--
PARI/GP Home Page: http://www.parigp-home.de/