/* MakeResumeCont: * * Build the resume fate for a signal or poll event handler. * This closure contains the address of the resume entry-point and * the registers from the Lib7 state. * * At least 4K avail. heap assumed. * * This gets called from MakeHandlerArg() below, * and also from src/runtime/main/run-runtime.c * */ lib7_val_t MakeResumeCont (lib7_state_t *lib7_state, lib7_val_t resume[]) { /* Allocate the resumption closure: */ LIB7_AllocWrite(lib7_state, 0, MAKE_DESC(10, DTAG_record)); LIB7_AllocWrite(lib7_state, 1, PTR_CtoLib7(resume)); LIB7_AllocWrite(lib7_state, 2, lib7_state->lib7_argument); LIB7_AllocWrite(lib7_state, 3, lib7_state->lib7_fate); LIB7_AllocWrite(lib7_state, 4, lib7_state->lib7_closure); LIB7_AllocWrite(lib7_state, 5, lib7_state->lib7_link_register); LIB7_AllocWrite(lib7_state, 6, lib7_state->lib7_program_counter); LIB7_AllocWrite(lib7_state, 7, lib7_state->lib7_exception_fate); LIB7_AllocWrite(lib7_state, 8, lib7_state->lib7_calleeSave[0]); /* John Reppy says not to do: LIB7_AllocWrite(lib7_state, 8, lib7_state->lib7_current_thread); */ LIB7_AllocWrite(lib7_state, 9, lib7_state->lib7_calleeSave[1]); LIB7_AllocWrite(lib7_state, 10, lib7_state->lib7_calleeSave[2]); /**/ return LIB7_Alloc(lib7_state, 10); }
/* _ml_Date_localtime : Int32.int -> (int * int * int * int * int * int * int * int * int) * * Takes a local time value (in seconds), and converts it to a 9-tuple with * the fields: tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, tm_wday, * tm_yday, and tm_isdst. */ ml_val_t _ml_Date_localtime (ml_state_t *msp, ml_val_t arg) { time_t t = (time_t)INT32_MLtoC(arg); struct tm *tm; tm = localtime (&t); if (tm == NULL) RAISE_SYSERR(msp,0); ML_AllocWrite(msp, 0, MAKE_DESC(DTAG_record, 9)); ML_AllocWrite(msp, 1, INT_CtoML(tm->tm_sec)); ML_AllocWrite(msp, 2, INT_CtoML(tm->tm_min)); ML_AllocWrite(msp, 3, INT_CtoML(tm->tm_hour)); ML_AllocWrite(msp, 4, INT_CtoML(tm->tm_mday)); ML_AllocWrite(msp, 5, INT_CtoML(tm->tm_mon)); ML_AllocWrite(msp, 6, INT_CtoML(tm->tm_year)); ML_AllocWrite(msp, 7, INT_CtoML(tm->tm_wday)); ML_AllocWrite(msp, 8, INT_CtoML(tm->tm_yday)); ML_AllocWrite(msp, 9, INT_CtoML(tm->tm_isdst)); return ML_Alloc(msp, 9); } /* end of _ml_Date_localtime */
PVT ml_val_t mkWord32(ml_state_t *msp, Word_t p) { ML_AllocWrite(msp, 0, MAKE_DESC(sizeof(Word_t), DTAG_string)); ML_AllocWrite(msp, 1, (ml_val_t)p); return ML_Alloc(msp, sizeof(Word_t)); }
void allocate_globals (lib7_state_t* lib7_state) { lib7_val_t RunVec; lib7_val_t CStruct; #ifdef SIZES_C64_LIB732 PatchAddresses (); #endif /* Allocate the RunVec: */ #define RUNVEC_SZ 12 LIB7_AllocWrite(lib7_state, 0, MAKE_DESC(RUNVEC_SZ, DTAG_record)); LIB7_AllocWrite(lib7_state, 1, PTR_CtoLib7(array_v+1)); LIB7_AllocWrite(lib7_state, 2, PTR_CtoLib7(bind_cfun_v+1)); LIB7_AllocWrite(lib7_state, 3, PTR_CtoLib7(callc_v+1)); LIB7_AllocWrite(lib7_state, 4, PTR_CtoLib7(create_b_v+1)); LIB7_AllocWrite(lib7_state, 5, PTR_CtoLib7(create_r_v+1)); LIB7_AllocWrite(lib7_state, 6, PTR_CtoLib7(create_s_v+1)); LIB7_AllocWrite(lib7_state, 7, PTR_CtoLib7(create_v_v+1)); LIB7_AllocWrite(lib7_state, 8, PTR_CtoLib7(floor_v+1)); LIB7_AllocWrite(lib7_state, 9, PTR_CtoLib7(logb_v+1)); LIB7_AllocWrite(lib7_state, 10, PTR_CtoLib7(scalb_v+1)); LIB7_AllocWrite(lib7_state, 11, PTR_CtoLib7(try_lock_v+1)); LIB7_AllocWrite(lib7_state, 12, PTR_CtoLib7(unlock_v+1)); RunVec = LIB7_Alloc(lib7_state, RUNVEC_SZ); /* Allocate the CStruct: */ #define CSTRUCT_SZ 12 LIB7_AllocWrite(lib7_state, 0, MAKE_DESC(CSTRUCT_SZ, DTAG_record)); LIB7_AllocWrite(lib7_state, 1, RunVec); LIB7_AllocWrite(lib7_state, 2, DivId); LIB7_AllocWrite(lib7_state, 3, OverflowId); LIB7_AllocWrite(lib7_state, 4, SysErrId); LIB7_AllocWrite(lib7_state, 5, ProfCurrent); /* prof_current in src/lib/core/init/runtime-system.api */ LIB7_AllocWrite(lib7_state, 6, PollEvent); /* poll_event in src/lib/core/init/runtime-system.api */ LIB7_AllocWrite(lib7_state, 7, PollFreq); /* poll_freq in src/lib/core/init/runtime-system.api */ LIB7_AllocWrite(lib7_state, 8, Lib7PollHandler); /* poll_handler in src/lib/core/init/runtime-system.api */ LIB7_AllocWrite(lib7_state, 9, ActiveProcs); /* active_procs in src/lib/core/init/runtime-system.api */ LIB7_AllocWrite(lib7_state, 10, PervasiveStruct); /* pstruct in src/lib/core/init/runtime-system.api */ LIB7_AllocWrite(lib7_state, 11, Lib7SignalHandler); /* sighandler in src/lib/core/init/runtime-system.api */ LIB7_AllocWrite(lib7_state, 12, LIB7_vector0); /* vector0 in src/lib/core/init/runtime-system.api */ CStruct = LIB7_Alloc(lib7_state, CSTRUCT_SZ); /* Allocate 1-elem SRECORD just containing the CStruct: */ REC_ALLOC1(lib7_state, runtimeCompileUnit, CStruct); #ifdef ASM_MATH #define MATHVEC_SZ 8 LIB7_AllocWrite(lib7_state, 0, MAKE_DESC(MATHVEC_SZ, DTAG_record)); LIB7_AllocWrite(lib7_state, 1, LnId); LIB7_AllocWrite(lib7_state, 2, SqrtId); LIB7_AllocWrite(lib7_state, 3, PTR_CtoLib7(arctan_v+1)); LIB7_AllocWrite(lib7_state, 4, PTR_CtoLib7(cos_v+1)); LIB7_AllocWrite(lib7_state, 5, PTR_CtoLib7(exp_v+1)); LIB7_AllocWrite(lib7_state, 6, PTR_CtoLib7(ln_v+1)); LIB7_AllocWrite(lib7_state, 7, PTR_CtoLib7(sin_v+1)); LIB7_AllocWrite(lib7_state, 8, PTR_CtoLib7(sqrt_v+1)); MathVec = LIB7_Alloc(lib7_state, MATHVEC_SZ); #endif } /* allocate_globals */