delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/07/17/20:05:53

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Wed, 18 Jul 2001 00:04:23 +0200
From: Corinna Vinschen <cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Linking to cygwin1.dll and msvcrt.dll ?
Message-ID: <20010718000423.A730@cygbert.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20010717160220 DOT A11104 AT redhat DOT com> <Pine DOT HPP DOT 3 DOT 96 DOT 1010717160558 DOT 9202A-100000 AT hp2 DOT xraylith DOT wisc DOT edu>
Mime-Version: 1.0
User-Agent: Mutt/1.2.5i
In-Reply-To: <Pine.HPP.3.96.1010717160558.9202A-100000@hp2.xraylith.wisc.edu>; from khan@NanoTech.Wisc.EDU on Tue, Jul 17, 2001 at 04:11:55PM -0500

On Tue, Jul 17, 2001 at 04:11:55PM -0500, Mumit Khan wrote:
> On Tue, 17 Jul 2001, Christopher Faylor wrote:
> 
> > On Tue, Jul 17, 2001 at 12:59:46PM -0700, Mo DeJong wrote:
> > >I am trying to figure out how to create a .dll that depends on
> > >cygwin1.dll and msvcrt.dll.  Here is the link time error I am currently
> > >seeing:
> > 
> > You can't do that.  You can't mix two different runtime systems
> > they are mutually exclusive.
> 
> 
> In this particular case however, you need to replace _beginthreadex and
> _endthreadex with Windows32 API "equivalents" -- Create/EndThread. Here's
> the bit from my local tree, based on tcl 8.3. Caveat noted in the source.
> 
> 2000-02-22  Mumit Khan  <khan AT xraylith DOT wisc DOT edu>
> 	
> 	* win/tclWinThrd.c (TclpThreadCreate): Conditionalize on 
> 	TCL_THREADS. Add workaround for lack of _beginthreadex under 
> 	CRTDLL runtime. 
> 	(TclpThreadExit): Likewise.
> 
> Index: win/tclWinThrd.c
> ===================================================================
> RCS file: /homes/khan/src/CVSROOT/tcl8.3.0/win/tclWinThrd.c,v
> retrieving revision 1.1.1.1
> retrieving revision 1.3
> diff -u -3 -p -r1.1.1.1 -r1.3
> --- win/tclWinThrd.c	2000/02/16 21:47:46	1.1.1.1
> +++ win/tclWinThrd.c	2000/02/22 04:15:06	1.3
> @@ -120,15 +120,31 @@ TclpThreadCreate(idPtr, proc, clientData
>      Tcl_ThreadCreateProc proc;		/* Main() function of the thread */
>      ClientData clientData;		/* The one argument to Main() */
>  {
> +#ifdef TCL_THREADS
>      unsigned long code;
>  
> +#if !defined(__GNUC__) || (defined(__GNUC__) && defined(__MSVCRT__))
>      code = _beginthreadex(NULL, 0, (LPTHREAD_START_ROUTINE) proc,
>  		(void *)clientData, 0, (unsigned *)idPtr);
> +#else
> +    /* 
> +     * MS CRTDLL runtime, one of two supported GCC/Mingw, does not support 
> +     * the _beginthreadex and endthreadex interfaces, and we resort to using
> +     * Win32 API CreateThread and ExitThread interfaces instead. A side 
> +     * effect is that there is a potential resource leak after each thread 
> +     * exits. 
> +     */
> +    code = (unsigned long) CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) proc,
> +		(DWORD *)clientData, 0, (DWORD *)idPtr);

I'm somehow missing a

       CloseHandle ((HANDLE)code);

at this point which at least closes the handle to the thread. Otherwise
the following from MSDN is valid:

    The thread object remains in the system until the thread has
    terminated and all handles to it have been closed through a
    call to CloseHandle.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019