This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


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

Re: Initialising gnuwin DLLs


On 03-Feb-1998, Matthew Brett <mbrett@wren.rpms.ac.uk> wrote:
> Dear Mikey,
> 
> "struct _reent for each dll needs to be initialized from
> main() before any calls to dll funcs that use the
> std file handles, see the perl5 patch for details."
> 
> Thanks for this reply.  Does this mean that for any program
> to use a gnuwin generated DLL, main() needs to know that it is
> a gnuwin DLL and initialise struct _reent?  This would mean 
> that you could not use gnuwin DLLs with code that did not
> know about _reent, I guess.  Could you not can you not 
> intialise _reent from the DLL code - e.g in the
> PROCESS_ATTACH routine - to initialise the Cygwin DLL from
> our new DLL?
>
> Does anyone have some skeletal code that does this?

Well, you can initialize each DLL's _impure_ptr so that
it points to reent_data -- this at least lets you use gnuwin
generated DLLs in gnuwin programs without main() needing to
jump through special hoops.  Of course, that won't initialize
the reent_data itself; I don't know if it's possible to do that
from within the dll_entry() function.

>From Makefile.DLLs version 0.6 (see
<http://www.cs.mu.oz.au/~fjh/gnu-win32/how-to-build-dlls.html>):

# Windows requires each DLL to have an initialization function
# that is called at certain points (thread/process attach/detach).
# This one just initializes `_impure_ptr'.
dll_init.c:
	echo '#include <stdio.h>' 				> dll_init.c
	echo 'extern struct _reent *_impure_ptr;'		>> dll_init.c
	echo 'extern struct _reent *__imp_reent_data;'		>> dll_init.c
	echo '__attribute__((stdcall))'				>> dll_init.c
	echo 'int dll_entry(int handle, int reason, void *ptr)'	>> dll_init.c
	echo '{ _impure_ptr=__imp_reent_data; return 1; }'	>> dll_init.c

-- 
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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