From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1541 invoked by alias); 6 Aug 2004 16:55:01 -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 1533 invoked from network); 6 Aug 2004 16:54:59 -0000 Received: from unknown (HELO callisto.canberra.edu.au) (137.92.14.50) by sourceware.org with SMTP; 6 Aug 2004 16:54:59 -0000 Received: from ise.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 i76GsvQ00842 for ; Sat, 7 Aug 2004 02:54:57 +1000 Message-ID: <4113B7D2.7090807@ise.canberra.edu.au> Date: Fri, 06 Aug 2004 16:55:00 -0000 From: Ross Johnson User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 MIME-Version: 1.0 To: pthreads-win32@sources.redhat.com Subject: Re: Borland C++Builder support References: <200408031004.i73A4qlB013157@www2.pochta.ru> <41138855.1010605@ecosm.com> In-Reply-To: <41138855.1010605@ecosm.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004/txt/msg00096.txt.bz2 Will Bryant wrote: > Gianluca wrote: > >> I have built the library with the Will Bryant's bmakefile. >> I've received a bunch of warnings but it was OK. >> I put the PthreadBC.dll on Windows directory, I included >> PthreadBC.lib in my .bpr project, I compiled and linked the program >> below. >> >> #include >> #include >> #include >> >> void* function( void* arg ) >> { >> printf( "This is thread %d\n", pthread_self() ); >> return( 0 ); >> } >> >> int main( void ) >> { >> pthread_attr_t attr; >> >> pthread_attr_init( &attr ); >> pthread_attr_setdetachstate( >> &attr, PTHREAD_CREATE_DETACHED ); >> pthread_create( NULL, &attr, &function, NULL ); >> >> > In general (ie. not for pthreads-win32 specifically), you need to > declare a pthread_id_t and pass it's address as the first argument to > pthread_create. Try making that change first. > There are pthreads implementations that allow a NULL thread parameter (Solaris - see below) and the question of a NULL value has been asked before on this list. My copy of the SUSV3 standard doesn't say that NULL can't be passed and doesn't require an error be returned. It appears to be left to the implementation. In pthreads-win32, a memory protection fault is raised if NULL is passed, but it also starts the thread before the fault is raised, which is probably a bug. I've run the following test on machines that I have access to: #include #include void * thr(void * arg) { printf("Inside thread\n"); /* Mandatory if we're going to be well behaved. */ pthread_detach(pthread_self()); } int main() { pthread_t t; int result = 0; result == pthread_create(NULL, NULL, thr, NULL); sleep(2); return result; } Linux (Redhat 9) segfaults without running the thread. Solaris 7 runs the thread and exits with no error or fault. Pthreads-win32 could probably emulate Solaris with a one line change. The question is:- which behaviour is preferrable? Ross