static void __CDECL startup(register BASEPAGE *b) { register int (*func)(long); register long arg; _setstack(((char *)b) + SIZE); func = (int (*)(long))b->p_dbase; arg = b->p_dlen; /* If this is a thread, it doesn't need * own copy of the environment, right? */ Mfree(b->p_env); b->p_env = _base->p_env; /* copy from parents basepage for debuggers... */ b->p_tbase = _base->p_tbase; b->p_tlen = _base->p_tlen; b->p_dbase = _base->p_dbase; b->p_dlen = _base->p_dlen; b->p_bbase = _base->p_bbase; b->p_blen = _base->p_blen; Pterm((*func)(arg)); }
void _acc_main(void) { static char *acc_argv[] = { "", NULL }; /* no name and no arguments */ if (_stksize == 0 || _stksize == -1L) _stksize = MINKEEP; if (_stksize < 0) _stksize = -_stksize; // if ((s = getenv("STACKSIZE")) != 0) // _stksize = atoi(s); /* stack on word boundary */ _stksize &= 0xfffffffeL; if (_heapbase == 0) { _heapbase = (void *)Malloc(_stksize); } _setstack((char *) _heapbase + _stksize); /* this is an accessory */ _app = 0; _main(1L, acc_argv, acc_argv); /*NOTREACHED*/ }
void _crtinit(void) { register BASEPAGE *bp; register long m; register long freemem; bp = _base; /* m = # bytes used by environment + args */ m = parseargs(bp); /* make m the total number of bytes required by program sans stack/heap */ m += (bp->p_tlen + bp->p_dlen + bp->p_blen + sizeof(BASEPAGE)); m = (m + 3L) & (~3L); /* freemem the amount of free mem accounting for MINFREE at top */ if ((freemem = (long)bp->p_hitpa - (long)bp - MINFREE - m) <= 0L) goto notenough; /* make m the total number of bytes including stack */ m += _stksize; /* make sure there's enough room for the stack */ if (((long)bp + m) > ((long)bp->p_hitpa - MINFREE)) goto notenough; /* set up the new stack to bp + m */ _setstack((char *)bp + m); /* shrink the TPA */ (void)Mshrink(0, bp, m); Pterm(main()); __builtin_unreachable(); notenough: (void) Cconws("Fatal error: insufficient memory\r\n" "Hint: either decrease stack size using 'stack' command (not recomended)\r\n" " or increase TPA_INITIALMEM value in mint.cnf.\r\n"); Pterm(-1); __builtin_unreachable(); }