err = Gestalt(gestaltSystemVersion,&systemVersion); if (systemVersion < 0x00000A00) { CFragConnectionID	connID; Str255				errMessage; Ptr					interfaceLibAddr; CFragSymbolClass	symClass; UniversalProcPtr	(*getOSTrapAddressProc)(UInt16); void				(*setOSTrapAddressProc)(UniversalProcPtr, UInt16);   err = GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch, kFindCFrag, &connID, &interfaceLibAddr, errMessage); PR_ASSERT(err == noErr);   err = FindSymbol(connID, "\pGetOSTrapAddress", &(Ptr)getOSTrapAddressProc, &symClass); PR_ASSERT(err == noErr); PR_ASSERT(symClass == kTVectorCFragSymbol); if (err == noErr) { gStackSpacePatchCallThru = getOSTrapAddressProc(0x0065); }   err = FindSymbol(connID, "\pSetOSTrapAddress", &(Ptr)setOSTrapAddressProc, &symClass); PR_ASSERT(err == noErr); PR_ASSERT(symClass == kTVectorCFragSymbol); if (err == noErr && gStackSpacePatchCallThru) { gStackSpacePatchUPP = NewStackSpaceProc(StackSpacePatch); setOSTrapAddressProc(gStackSpacePatchUPP, 0x0065); } }
InstallStackSpacePatch();
void _MD_EarlyInit(){	Handle				environmentVariables;	long				systemVersion;	OSErr				err;#if !defined(MAC_NSPR_STANDALONE)	// MacintoshInitializeMemory();  Moved to mdmacmem.c: AllocateRawMemory(Size blockSize)#else	MacintoshInitializeMemory();#endif	MacintoshInitializeTime();		//	Install resource-controlled environment variables.		environmentVariables = GetResource('Envi', 128);	if (environmentVariables != NULL) {			Size 	resourceSize;		char	*currentPutEnvString = (char *)*environmentVariables,				*currentScanChar = currentPutEnvString;						resourceSize = GetHandleSize(environmentVariables);					DetachResource(environmentVariables);		HLock(environmentVariables);				while (resourceSize--) {					if ((*currentScanChar == '\n') || (*currentScanChar == '\r')) {				*currentScanChar = 0;				_MD_PutEnv (currentPutEnvString);				currentPutEnvString = currentScanChar + 1;			}					currentScanChar++;				}				DisposeHandle(environmentVariables);	}#ifdef PR_INTERNAL_LOGGING	_MD_PutEnv ("NSPR_LOG_MODULES=clock:6,cmon:6,io:6,mon:6,linker:6,cvar:6,sched:6,thread:6");#endif	err = Gestalt(gestaltSystemVersion,&systemVersion);	if (systemVersion < 0x00000A00)	// we still need to patch StackSpace()	{		CFragConnectionID	connID;		Str255				errMessage;		Ptr					interfaceLibAddr;		CFragSymbolClass	symClass;		UniversalProcPtr	(*getOSTrapAddressProc)(UInt16);		void				(*setOSTrapAddressProc)(UniversalProcPtr, UInt16);		// open connection to "InterfaceLib"		err = GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch, kFindCFrag,												&connID, &interfaceLibAddr, errMessage);		PR_ASSERT(err == noErr);		// get symbol GetOSTrapAddress and get trap address for StackSpace (A065)		err = FindSymbol(connID, "\pGetOSTrapAddress", &(Ptr)getOSTrapAddressProc, &symClass);		PR_ASSERT(err == noErr);		PR_ASSERT(symClass == kTVectorCFragSymbol);		if (err == noErr)		{			gStackSpacePatchCallThru = getOSTrapAddressProc(0x0065); 		}				// get symbol SetOSTrapAddress and set trap address for _StackSpace (A065)		err = FindSymbol(connID, "\pSetOSTrapAddress", &(Ptr)setOSTrapAddressProc, &symClass);		PR_ASSERT(err == noErr);		PR_ASSERT(symClass == kTVectorCFragSymbol);		if (err == noErr && gStackSpacePatchCallThru)		{			gStackSpacePatchUPP = NewStackSpaceProc(StackSpacePatch);			setOSTrapAddressProc(gStackSpacePatchUPP, 0x0065);		}	}}