From: simonmar Date: Wed, 24 Sep 2003 11:06:54 +0000 (+0000) Subject: [project @ 2003-09-24 11:06:54 by simonmar] X-Git-Tag: nhc98-1-18-release~493 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=9b091691ed951f7ee12e74ab6abe59e3e0f9be91;p=ghc-base.git [project @ 2003-09-24 11:06:54 by simonmar] Move forkOS_createThread into the RTS so its implementation can be dependent on RTS_SUPPORTS_THREADS, which means we can provide a stub implementation in the !RTS_SUPPORTS_THREADS case, and hence not depend on pthread_create, which requires -lpthread. The upshot is that GHCi now works again when !RTS_SUPPORTS_THREADS. --- diff --git a/cbits/forkOS.c b/cbits/forkOS.c deleted file mode 100644 index 4e35738..0000000 --- a/cbits/forkOS.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * (c) The GHC Team 2003 - * - * $Id: forkOS.c,v 1.2 2003/09/23 16:18:03 sof Exp $ - * - * Helper function for Control.Concurrent.forkOS - */ - -#include "HsBase.h" -#include "RtsAPI.h" - -#if defined(HAVE_PTHREAD_H) && !defined(WANT_NATIVE_WIN32_THREADS) -#include - -static void * -forkOS_createThreadWrapper ( void * entry ) -{ - rts_lock(); - rts_evalStableIO((HsStablePtr) entry, NULL); - rts_unlock(); - return NULL; -} - -int -forkOS_createThread ( HsStablePtr entry ) -{ - pthread_t tid; - int result = pthread_create(&tid, NULL, - forkOS_createThreadWrapper, (void*)entry); - if(!result) - pthread_detach(tid); - return result; -} - -#elif defined(HAVE_WINDOWS_H) -#include -/* For reasons not yet clear, the entire contents of process.h is protected - * by __STRICT_ANSI__ not being defined. - */ -#undef __STRICT_ANSI__ -#include - -static unsigned __stdcall -forkOS_createThreadWrapper ( void * entry ) -{ - rts_lock(); - rts_evalStableIO((HsStablePtr) entry, NULL); - rts_unlock(); - return 0; -} - -int -forkOS_createThread ( HsStablePtr entry ) -{ - unsigned long pId; - return (_beginthreadex ( NULL, /* default security attributes */ - 0, - forkOS_createThreadWrapper, - (void*)entry, - 0, - (unsigned*)&pId) == 0); -} - -#else -#endif diff --git a/include/HsBase.h b/include/HsBase.h index 47d028d..d9ef002 100644 --- a/include/HsBase.h +++ b/include/HsBase.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: HsBase.h,v 1.28 2003/09/24 10:32:12 simonmar Exp $ + * $Id: HsBase.h,v 1.29 2003/09/24 11:06:54 simonmar Exp $ * * (c) The University of Glasgow 2001-2002 * @@ -129,9 +129,6 @@ int inputReady(int fd, int msecs, int isSock); /* in writeError.c */ void writeErrString__(HsAddr msg_hdr, HsAddr msg, HsInt len); -/* in forkOS.c */ -int forkOS_createThread ( HsStablePtr entry ); - /* in Signals.c */ extern HsInt nocldstop;