1 \section[SMstacks.lc]{Stack allocation (sequential)}
3 Routine that allocates the A and B stack (sequential only).
8 # include "SMinternal.h"
15 EXTDATA_RO(StkO_static_info);
24 * Allocate them if they don't exist. One space does for both stacks, since they
25 * grow towards each other
27 if (stks_space == 0) {
29 MainStkO = (P_) xmalloc((STKO_HS + SM_word_stk_size) * sizeof(W_));
30 stks_space = MainStkO + STKO_HS;
31 SET_STKO_HDR(MainStkO, StkO_static_info, CC_SUBSUMED);
32 STKO_SIZE(MainStkO) = SM_word_stk_size + STKO_VHS;
33 STKO_LINK(MainStkO) = Nil_closure;
34 STKO_RETURN(MainStkO) = NULL;
36 stks_space = (P_) xmalloc(SM_word_stk_size * sizeof(W_));
39 # if STACK_CHECK_BY_PAGE_FAULT
40 unmapMiddleStackPage((char *) stks_space, SM_word_stk_size * sizeof(W_));
43 /* Initialise Stack Info and pointers */
44 stackInfo.botA = STK_A_FRAME_BASE(stks_space, SM_word_stk_size);
45 stackInfo.botB = STK_B_FRAME_BASE(stks_space, SM_word_stk_size);
47 MAIN_SuA = MAIN_SpA = stackInfo.botA + AREL(1);
48 MAIN_SuB = MAIN_SpB = stackInfo.botB + BREL(1);
51 fprintf(stderr, "STACK init: botA, spa: 0x%lx, 0x%lx\n botB, spb: 0x%lx, 0x%lx\n",
52 (W_) stackInfo.botA, (W_) MAIN_SpA, (W_) stackInfo.botB, (W_) MAIN_SpB);
56 #endif /* not parallel */