This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Q] automagic define/undefine with dynamic-link/dynamic-unlink


> Any way, now that I see that it *does* work, I have to say that I
> don't like it.  "_init" and "_fini" seem to be very magical names, but
> only with ELF.

I like it a lot.  Using _init means that you can avoid any sort of
connection between the name of the file to be linked and the name of
the entry point to initialize the contents of it.

If _init just calls a globally available registration function in
Guile and passes it the address of a static void function (the
initialization function) inside the library which then calls whatever
functions necessary to set up the environment, then everything will
work fine.

In a dynamically linked environment, the registration function
immediately calls the initialization function.  In a statically linked
environment, the registration function accumulates all initialization
functions and call them once Guile has been booted.  The choice
between the two can be made automatic.  A global flag (initially zero)
indicates whether Guile has been booted.  If not, then the
registration procedure accumulates pointers in a table, otherwise it
calls its argument.  Whenever Guile has been booted, the flag is set
to one and the accumulated pointers are called. 
	

-- 
Robert Strandh

---------------------------------------------------------------------
Greenspun's Tenth Rule of Programming: any sufficiently complicated C
or Fortran program contains an ad hoc informally-specified bug-ridden
slow implementation of half of Common Lisp.
---------------------------------------------------------------------