char * WH_TempName(XP_FileType type, const char * prefix) { #define NS_BUFFER_SIZE 1024 static char buf [NS_BUFFER_SIZE]; /* protected by _pr_TempName_lock */ static char buf2 [100]; static unsigned int count = 0; char* result; #ifdef NSPR #ifndef NSPR20 XP_ASSERT(_pr_TempName_lock); PR_EnterMonitor(_pr_TempName_lock); #else if (_pr_TempName_lock == NULL) { _pr_TempName_lock = PR_NewNamedMonitor("TempName-lock"); } PR_EnterMonitor(_pr_TempName_lock); #endif /* NSPR20 */ #endif result = xp_TempName(type, prefix, buf, buf2, &count); if (result) result = XP_STRDUP(result); #ifdef NSPR PR_ExitMonitor(_pr_TempName_lock); #endif return result; }
PUBLIC char * WH_FileName (const char *name, XP_FileType type) { static char buf [1024]; /* protected by _pr_TempName_lock */ static char configBuf [1024]; /* protected by _pr_TempName_lock */ char* result; #ifdef NSPR #ifndef NSPR20 XP_ASSERT(_pr_TempName_lock); PR_EnterMonitor(_pr_TempName_lock); #else if (_pr_TempName_lock == NULL) { _pr_TempName_lock = PR_NewNamedMonitor("TempName-lock"); } PR_EnterMonitor(_pr_TempName_lock); #endif /* NSPR20 */ #endif /* reset */ buf[0] = '\0'; result = xp_FileName(name, type, buf, configBuf); if (result) result = XP_STRDUP(result); #ifdef NSPR PR_ExitMonitor(_pr_TempName_lock); #endif return result; }
char * WH_FilePlatformName(const char * name) { char* result; static char path[300]; /* Names longer than 300 are not dealt with in our stdio */ #ifdef NSPR #ifndef NSPR20 XP_ASSERT(_pr_TempName_lock); PR_EnterMonitor(_pr_TempName_lock); #else if (_pr_TempName_lock == NULL) { _pr_TempName_lock = PR_NewNamedMonitor("TempName-lock"); } PR_EnterMonitor(_pr_TempName_lock); #endif /* NSPR20 */ #endif result = xp_FilePlatformName(name, path); #ifdef NSPR PR_ExitMonitor(_pr_TempName_lock); #endif if (result) result = XP_STRDUP(result); return result; }
void jsd_LockSourceTextSubsystem(JSDContext* jsdc) { #ifndef JSD_SIMULATION if (jsd_text_mon == NULL) jsd_text_mon = PR_NewNamedMonitor("jsd-text-monitor"); PR_EnterMonitor(jsd_text_mon); #endif /* JSD_SIMULATION */ }
void _PR_InitLinker(void) { PRLibrary *lm = NULL; #if defined(XP_UNIX) || defined(XP_AMIGAOS) void *h; #endif if (!pr_linker_lock) { pr_linker_lock = PR_NewNamedMonitor("linker-lock"); } PR_EnterMonitor(pr_linker_lock); #if defined(XP_PC) lm = PR_NEWZAP(PRLibrary); lm->name = strdup("Executable"); #if defined(XP_OS2) lm->dlh = NULLHANDLE; #else /* A module handle for the executable. */ lm->dlh = GetModuleHandle(NULL); #endif /* ! XP_OS2 */ lm->refCount = 1; lm->staticTable = NULL; pr_exe_loadmap = lm; pr_loadmap = lm; #elif defined(XP_UNIX) || defined(XP_AMIGAOS) #ifdef HAVE_DLL #if defined(USE_DLFCN) && !defined(NO_DLOPEN_NULL) h = dlopen(0, RTLD_LAZY); if (!h) { char *error; DLLErrorInternal(_MD_ERRNO()); error = (char*)PR_MALLOC(PR_GetErrorTextLength()); (void) PR_GetErrorText(error); fprintf(stderr, "failed to initialize shared libraries [%s]\n", error); PR_DELETE(error); abort();/* XXX */ } #elif defined(USE_HPSHL) h = NULL; /* don't abort with this NULL */ #elif defined(USE_MACH_DYLD) || defined(NO_DLOPEN_NULL) h = NULL; /* XXXX toshok */ /* XXXX vlad */ #else #error no dll strategy #endif /* USE_DLFCN */ lm = PR_NEWZAP(PRLibrary); if (lm) { lm->name = strdup("a.out"); lm->refCount = 1; lm->dlh = h; lm->staticTable = NULL; } pr_exe_loadmap = lm; pr_loadmap = lm; #endif /* HAVE_DLL */ #endif /* XP_UNIX */ if (lm) { PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Loaded library %s (init)", lm->name)); } PR_ExitMonitor(pr_linker_lock); }