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 14-Feb-1998, Mikey <jeffdbREMOVETHIS@netzone.com> wrote:
> >> (C) call into each user dll to initialize it's copy of
> >> struct _reent with the values of the exe's copy of
> >> struct _reent.
> >
> >Step (C) is not necessary if you initialize it in dll_entry().
> 
> I see what you mean, the comments in Makefile.DLLs 0.6
> about initializing the _impure_ptr's from the main program misled me
> I wondered why I was never able to get it to work :).
> Do you think those could be changed to reflect
> the current setup?

Done.

> If I understand correctly then the only changes to existing vc++ .dll code
> that would really need to be made, to link with libcygwin.a are to
> 
> ( 1 ) add a .c file to the dll with just 
> 
> #ifdef __CYGWIN32__
> void *_impure_ptr;
> #endif
> 
> in it
> 
> ( 2 ) in the file that contains DllMain make sure to #include <stdio.h>
> /* stdio.h already contains extern struct _reent *_impure_ptr; */
> 
> (3 ) change
> 
> BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
> {
> 
> to
> 
> #ifdef __CYGWIN32__
> extern struct _reent *__imp_reent_data;
> #endif
> BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
> {
> #ifdef __CYGWIN32__ 
> _impure_ptr=__imp_reent_data;
> #endif

I'd be inclined to simplify this procedure slightly by combining (1) - (3)
into a single step:

    change

	BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
	{

    to

	#ifdef __CYGWIN32__
	struct _reent *_impure_ptr;
	extern struct _reent *__imp_reent_data;
	#endif
	BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
	{
	#ifdef __CYGWIN32__ 
	_impure_ptr=__imp_reent_data;
	#endif

> if linking against the original B18 cygwin.dll/libcygwin.a you MUST
> give a --image-base other than 0x10000000 even to relocatable
> dll's, B18's cygwin.dll won't get relocated NO MATTER WHAT.
> 
> Is that about it?

That agrees with my understanding of things.
Of course no promises ;-)

-- 
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]