Subj : Re: Building thread-safe SpiderMonkey for Win32 To : netscape.public.mozilla.jseng From : developir@yahoo.com (J. Wilson) Date : Wed Mar 17 2004 05:19 pm Brendan Eich wrote in message news:... > Bob Kline wrote: > > > > There actually is support for using gmake on Windows under cygwin. It's > > just broken by a disconnect between the SpiderMonkey and NSPR > > assumptions about where the NSPR components can be found. See my last > > two responses to Benjamin Smedberg in this ng thread. Can a thread-safe > > SpiderMonkey be built without NSPR? > > Not without emulating a bunch of NSPR thread, lock, and condvar APIs on > top of native threads -- which amounts to reimplementing NSPR in those > repects, which is silly given NSPR's portability. I did exactly this to avoid using NSPR. It's quite simple - you only have to implement 12 functions... pratom.h: #include "spider_threads.h" prcvar.h: #include "spider_threads.h" prlock.h: #include "spider_threads.h" prthread.h: #include "spider_threads.h" spider_threads.h: #ifndef __spider_threads_h__ #define __spider_threads_h__ #ifdef __cplusplus extern "C" { #endif /* Structs are forward declared here. * Full declaration inside spider_threads.c */ typedef struct PRCondVar PRCondVar; typedef struct PRLock PRLock; typedef struct PRThread PRThread; typedef int PRInt32; typedef unsigned long PRIntervalTime; #define PR_INTERVAL_NO_TIMEOUT (0xffffffffUL) typedef enum { PR_SUCCESS = 0, PR_FAILURE = -1 } PRStatus; extern PRThread* PR_GetCurrentThread(); extern PRLock* PR_NewLock(void); extern void PR_DestroyLock(PRLock* lock); extern void PR_Lock(PRLock* lock); extern PRStatus PR_Unlock(PRLock* lock); extern PRCondVar* PR_NewCondVar(PRLock* lock); extern void PR_DestroyCondVar(PRCondVar* cvar); extern PRStatus PR_WaitCondVar(PRCondVar* cvar, PRIntervalTime timeout); extern PRStatus PR_NotifyCondVar(PRCondVar* cvar); extern PRStatus PR_NotifyAllCondVar(PRCondVar* cvar); extern PRInt32 PR_AtomicIncrement(PRInt32* val); extern PRInt32 PR_AtomicDecrement(PRInt32* val); #ifdef __cplusplus }; #endif #endif spider_threads.c: #include "spider_threads.h" /* Put your OS-specific implementation of the PR_XXX() functions here. Implement the PRCondVar, PRLock and PRThread structs in this file any way you like. */ .