static int MacintoshInit() { THz theZone = GetZone(); SysEnvRec sys; /* * There is a bug in systems earlier that 7.5.5, where a second BOA will * get a corrupted heap. This is the fix from TechNote 1070 */ SysEnvirons(1, &sys); if (sys.systemVersion < 0x0755) { if ( LMGetHeapEnd() != theZone->bkLim) { LMSetHeapEnd(theZone->bkLim); } } #if GENERATING68K && !GENERATINGCFM SetApplLimit(GetApplLimit() - (TCL_MAC_68K_STACK_GROWTH)); #endif MaxApplZone(); InitGraf((Ptr)&qd.thePort); /* No problems with initialization */ Tcl_MacSetEventProc(HandleHighLevelEvents); return TCL_OK; }
void BasicInit() #ifdef MAC { void InitColors(); #if MACB4CARBON short i; Ptr stackTop; // JLMextern _DataInit(); stackTop = GetApplLimit(); SetApplLimit((void *)(stackTop - (Ptr)30000)); // SetApplLimit((void *)(*(long *)csb - 30000)); MaxApplZone(); for (i = 1 ; i <= 16 ; i++) MoreMasters(); InitGraf(&qd.thePort); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(nil); FlushEvents(everyEvent, 0); #endif InitCursor(); InitColors(); }
/*************************************************************************** * NAME * increaseStackSize * ARGUMENTS * none * DESCRIPTION * increase the stack space allocation by 100K * RETURN VALUES * none */ void increaseStackSize() { unsigned long heapLimit; heapLimit = (unsigned long)GetApplLimit() - 102400L; SetApplLimit( (void *)heapLimit ); MaxApplZone(); }
static int MacintoshInit() { #if GENERATING68K && !GENERATINGCFM SetApplLimit(GetApplLimit() - (TCL_MAC_68K_STACK_GROWTH)); #endif MaxApplZone(); #if defined(THINK_C) /* Set options for Think C console package */ /* The console package calls the Mac init calls */ console_options.pause_atexit = 0; console_options.title = "\pTcl Interpreter"; #elif defined(__MWERKS__) /* Set options for CodeWarrior SIOUX package */ SIOUXSettings.autocloseonquit = true; SIOUXSettings.showstatusline = true; SIOUXSettings.asktosaveonclose = false; SIOUXSettings.wasteusetempmemory = true; InstallConsole(0); SIOUXSetTitle("\pTcl Interpreter"); #elif defined(applec) /* Init packages used by MPW SIOW package */ InitGraf((Ptr)&qd.thePort); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(nil); InitCursor(); #endif Tcl_MacSetEventProc((Tcl_MacConvertEventPtr) SIOUXHandleOneEvent); /* No problems with initialization */ return TCL_OK; }
main() { S2CINT *sp; #if MAC_CLASSIC STACKPTR( sp ); SetApplLimit( (char*)sp-57000 ); console_options.nrows = 30; console_options.title = "\pScheme->C"; #endif printf( "Embedded Scheme->C Test Bed\n0- " ); scheme2c( "(begin (set-stack-size! 57000) (set-time-slice! 100000))", &status, &result, &error ); if (status != 0) { printf( "Initialization failed!\n" ); exit( 1 ); } while (gets( line ) != NULL) { switch (s) { case 0: ev0(); break; case 1: ev1(); break; case 2: ev2(); break; case 3: ev3(); break; } s = (s + 1) & 3; if (*result != 0) printf( "%s\n", result ); if (*error != 0) printf( "%s", error ); printf( "%d- ", status ); fflush( stdout ); } printf( "\n" ); exit( 0 ); }
boolean initmacintosh (void) { /* the magic stuff that every Macintosh application needs to do before doing anything else. 4/24/91 dmb: added memory config resource stuff 3.0.4 dmb: use LMGetCurStackBase, not CurStackBase global 3.0.4 dmb: pass 0L to InitDialogs */ register short i; register hdlmemoryconfig h; register long ctbytes; //Code change by Timothy Paustian Thursday, June 8, 2000 3:45:13 PM // #if TARGET_API_MAC_CARBON == 0 long ctstack; #endif long ctheap, ctcode; short ctmasters; h = (hdlmemoryconfig) Get1Resource ('MCFG', 1); if (h == nil) clearbytes (&macmemoryconfig, sizeof (macmemoryconfig)); else macmemoryconfig = **h; //Code change by Timothy Paustian Saturday, June 3, 2000 10:13:20 PM //Changed to Opaque call for Carbon //we don't need this in carbon. #if TARGET_API_MAC_CARBON == 0 if (h != nil) { /*first check stack size*/ ctbytes = (**h).minstacksize; ctstack = LMGetCurStackBase () - GetApplLimit (); /*current stack size*/ if (ctbytes > ctstack) SetApplLimit (LMGetCurStackBase () - ctbytes); } MaxApplZone (); #endif if (h != nil) { /*check heap size and master pointers*/ ctbytes = (**h).minheapsize; //Code change by Timothy Paustian Thursday, June 8, 2000 3:04:31 PM //Changed to Opaque call for Carbon //This is meaningless for OS X since it has unlimited memory. #if TARGET_API_MAC_CARBON == 1 //we need to do somethings else. FreeMem is going to return some large value //of all the available system memory //This whole thing is pointless. We can get as much memory as we need. #pragma unused (ctmasters) #pragma unused (ctcode) #pragma unused (ctheap) #else ctheap = FreeMem (); if (ctbytes > ctheap) { return (false); } ctbytes = (**h).avghandlesize; ctcode = (**h).reserveforcode; if ((ctbytes > 0) && (ctheap > ctcode)) { ctmasters = ((ctheap - ctcode) / ctbytes) / kNumberOfMasters; ctmasters = min (ctmasters, 1024); /*7.1b37 PBS: You'd think 1024 calls would be enough. With large memory alottments on Mac Classic, we're calling MoreMasters in excess of 20,000 times. That makes the app take a minute or so to start up! So instead I've chosen an arbitrary limit.*/ for (i = 1; i < ctmasters; i++) MoreMasters (); } #endif ReleaseResource ((Handle) h); /*we're done with it*/ } //Code change by Timothy Paustian Thursday, June 8, 2000 3:21:06 PM //Changed to Opaque call for Carbon //we don't need this initialization in carbon #if TARGET_API_MAC_CARBON == 0 InitGraf (&qd.thePort); InitFonts (); FlushEvents (everyEvent, 0); InitWindows (); InitMenus (); TEInit (); InitDialogs (0L); #endif InitCursor (); //Code change by Timothy Paustian Thursday, June 8, 2000 3:22:57 PM //Changed to Opaque call for Carbon //this is obsolete, we should be using gestalt for this. { long quickDrawFeatures; OSErr theErr = Gestalt(gestaltSystemVersion, &gSystemVersion); if(oserror(theErr)) ExitToShell(); theErr = Gestalt(gestaltQuickdrawFeatures, &quickDrawFeatures); if(oserror(theErr)) ExitToShell(); gHasColorQD = (quickDrawFeatures & (1 << gestaltHasColor)); //Nav services has to be present and we want the 1.1 or greater version. gCanUseNavServ = (NavServicesAvailable() && (NavLibraryVersion() >= 0x01108000)); } //SysEnvirons (1, &macworld); //gee I bet this isn't required anymore either. for (i = 1; i <= 5; i++) { /*register with Multifinder*/ EventRecord ev; EventAvail (everyEvent, &ev); /*see TN180 -- splash screen*/ } /*for*/ #if TARGET_API_MAC_CARBON == 1 RegisterAppearanceClient (); #endif return (true); } /*initmacintosh*/
static int MacintoshInit() { int i; long result, mask = 0x0700; /* mask = system 7.x */ #if GENERATING68K && !GENERATINGCFM SetApplLimit(GetApplLimit() - (TK_MAC_68K_STACK_GROWTH)); #endif MaxApplZone(); for (i = 0; i < 4; i++) { (void) MoreMasters(); } /* * Tk needs us to set the qd pointer it uses. This is needed * so Tk doesn't have to assume the availablity of the qd global * variable. Which in turn allows Tk to be used in code resources. */ tcl_macQdPtr = &qd; /* * If appearance is present, then register Tk as an Appearance client * This means that the mapping from non-Appearance to Appearance cdefs * will be done for Tk regardless of the setting in the Appearance * control panel. */ if (TkMacHaveAppearance()) { RegisterAppearanceClient(); } InitGraf(&tcl_macQdPtr->thePort); InitFonts(); if (TkMacHaveAppearance() >= 0x110) { InitFloatingWindows(); } else { InitWindows(); } InitMenus(); InitDialogs((long) NULL); InitCursor(); /* * Make sure we are running on system 7 or higher */ if ((NGetTrapAddress(_Gestalt, ToolTrap) == NGetTrapAddress(_Unimplemented, ToolTrap)) || (((Gestalt(gestaltSystemVersion, &result) != noErr) || (result < mask)))) { panic("Tcl/Tk requires System 7 or higher."); } /* * Make sure we have color quick draw * (this means we can't run on 68000 macs) */ if (((Gestalt(gestaltQuickdrawVersion, &result) != noErr) || (result < gestalt32BitQD13))) { panic("Tk requires Color QuickDraw."); } FlushEvents(everyEvent, 0); SetEventMask(everyEvent); Tcl_MacSetEventProc(TkMacConvertEvent); return TCL_OK; }