This is the mail archive of the pthreads-win32@sourceware.cygnus.com mailing list for the pthreas-win32 project.


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

Re: Success with pthreads-win32 + gcc/mingw


On Tue, 17 Aug 1999, Bossom, John wrote:

> Yikes! DllMainCRTStartup is not the same as DllMain.
> Are you replacing DllMainCRTStartup with the DllMain provided by
> pthreads-win32?

I should've pointed out that I *am* using DllMain provided by pthreads,
and not replacing it in any way. In fact, my changes to pthreads are just 
a few lines.

What I'm pointing out is that DllMain is *not* the entry point. This is 
a common misconception that DllMain is somehow the entry point; in fact, 
DllMain is just something called by the entry point (just like main or
WinMain@16 is called by the entry point), which needs to do some magic 
beforehand. The Mingw runtime provides DllMainCRTStarutp, the entry point, 
and very rarely do you need to change. 

Essentially all that needs to be done is to remove the -e DllMain@12
argument, and then the startup calls DllMain@12 correctly and everything
works. 

If you provide a DllMain, startup calls that (as is the case here); if you
don't, the library provides a default stub.

> Without the DllMain, thread cleanup and tsd destructors will not happen.

Yes, I know.

> _beginthreadex is responsible for ensuring that the CRT is initialized for
> the
> thread.

I know. CRTDLL uses beginthread and MSVCRT _beginthreadex, and there are
small, but very important, differences. 

Regards,
Mumit



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