From: mlx AT san DOT rr DOT com (Steve Biskis) Subject: Re: Initializing gnuwin DLLs 22 Feb 1998 09:39:09 -0800 Message-ID: <199802221725.JAA02551.cygnus.gnu-win32@proxyb2.san.rr.com> Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To: ---------- > From: Fergus Henderson > To: jeffdbREMOVETHIS AT netzone DOT com > Cc: gnu-win32 AT cygnus DOT com > Subject: Re: Initialising gnuwin DLLs > Date: Saturday, February 14, 1998 8:56 PM > > On 14-Feb-1998, Mikey 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 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 | "I have always known that the pursuit > WWW: | of excellence is a lethal habit" > PGP: finger fjh AT 128 DOT 250 DOT 37 DOT 3 | -- the last words of T. S. Garp. > - > For help on using this list (especially unsubscribing), send a message to > "gnu-win32-request AT cygnus DOT com" with one line of text: "help". Hi, I've been quietly following this list for some time, haven't really had any problems that I couldn't eventually overcome (w/list's help) till now. Here's my problem: Trying to initialize the cygwin32 runtime via a call from my own dll. I've got a cygwin generated dll of my own home-brew that works fine in delphi executables until I try to call malloc & the like. So I've turned to trying to init cygwin.dll from my dll. I know about setting the reent pointer but that ain't gonna cut it if contents never get initialized. How do I reproduce the steps that happen within cygwin.dll at the start-up of a gnu-win32 app. I never have any trouble using my dll in gnu-win32 apps. Thanks in advance. da bisk. - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".