From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21978 invoked by alias); 23 Apr 2004 07:34:49 -0000 Mailing-List: contact pthreads-win32-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sources.redhat.com Received: (qmail 21842 invoked from network); 23 Apr 2004 07:34:47 -0000 Received: from unknown (HELO callisto.canberra.edu.au) (137.92.14.50) by sources.redhat.com with SMTP; 23 Apr 2004 07:34:47 -0000 Received: from callisto.canberra.edu.au (nyx.canberra.edu.au [137.92.14.55]) by callisto.canberra.edu.au (8.11.6/8.11.6) with ESMTP id i3N7YXE15510; Fri, 23 Apr 2004 17:34:35 +1000 Message-ID: <4088C746.9090703@callisto.canberra.edu.au> Date: Fri, 23 Apr 2004 07:34:00 -0000 From: Ross Johnson Reply-To: rpj@callisto.canberra.edu.au User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 MIME-Version: 1.0 To: Meno Abels CC: pthreads-win32@sources.redhat.com Subject: Re: pthread library static linking References: <4088AD69.2010508@adviser.com> In-Reply-To: <4088AD69.2010508@adviser.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004/txt/msg00042.txt.bz2 One reason, and possibly the only reason, is that pthreads-win32 allows Win32 threads (those not started via pthread_create) to call pthreads routines. But to do this usually generates an on-the-fly pthread handle for the Win32 thread so that it can be managed. Effectively, any Win32 thread that calls a pthreads routine becomes a POSIX (DETACHED) thread from the library's point of view. The hooks in dllMain enable cleanup of these 'implicit' pthread handles because the library has no other way of knowing when they exit. The routines that dllMain calls were split out and are exported so that they could be called in statically linked applications. See dllMain.c and README.NONPORTABLE. Now, I could be wrong, but if Win32 threads never call pthreads routines then your statically linked application may not need to explicitly call these dllMain hooks. Threads created via pthread_create should be getting cleaned up at the end of ptw32_threadStart(). You could try it, but check for memory leaks. Ross Meno Abels wrote: > hello, > > i'am new here so one question is allowed-:) > I want to use pthread-win32 not as a dll. I want > to link the pthread-win32 functionality static > to my application just to make distribution of that > application easier. > So that is quite easy to get, but there are the DllMain. > In DllMain you use the DLL_THREAD_ATTACH/DLL_THREAD_DETACH. > These prevents to use your lib static linked. Not technical > but functional. The DLL_PROCESS_ATTACH/DETACH is simple to > simulate infact I will call it on startup and end of my > application direct. The thread stuff is more complex i have to > change the thread create and thread exit code of your library. > My basic question is why you choose this solution with > DllMain. The pthread library is a wrapper around the > windows functions so it would be obvious to add the needed > initialisation for the create and exit directly. > Why is this done with DllMain? > > Thanks in advance > > meno >