Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com X-Authentication-Warning: hp2.xraylith.wisc.edu: khan owned process doing -bs Date: Tue, 17 Jul 2001 16:11:55 -0500 (CDT) From: Mumit Khan To: cygwin AT cygwin DOT com Subject: Re: Linking to cygwin1.dll and msvcrt.dll ? In-Reply-To: <20010717160220.A11104@redhat.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 * 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); +#endif if (code == 0) { return TCL_ERROR; } else { return TCL_OK; } +#else + return TCL_ERROR; +#endif } /* @@ -151,7 +167,13 @@ void TclpThreadExit(status) int status; { +#ifdef TCL_THREADS +#if !defined(__GNUC__) || (defined(__GNUC__) && defined(__MSVCRT__)) _endthreadex((DWORD)status); +#else + ExitThread((DWORD)status); +#endif +#endif } Regards, Mumit -- 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/