/* u2_lo_soft(): standard soft wrapper. unifies unix and nock errors. ** ** Produces [%$ result] or [%error (list tank)]. */ u2_noun u2_lo_soft(u2_reck* rec_u, c3_w sec_w, u2_funk fun_f, u2_noun arg) { u2_noun hoe, pro, rop; u2_rl_leap(u2_Wire, c3__rock); // system level setjmp, for signals // c3_assert(u2_nul == u2_wire_tax(u2_Wire)); c3_assert(0 == u2_wire_kit_r(u2_Wire)); // stop signals // u2_unix_ef_hold(); _lo_signal_deep(sec_w); if ( 0 != sigsetjmp(Signal_buf, 1) ) { u2_noun tax, pre, mok; // return to blank state // _lo_signal_done(); // acquire trace and reset memory // tax = u2_wire_tax(u2_Wire); u2_rl_fall(u2_Wire); u2z(arg); tax = u2_rl_take(u2_Wire, tax); u2_wire_tax(u2_Wire) = u2_nul; mok = u2_dc("mook", 2, tax); // other ugly disgusting cleanups { u2_wire_kit_r(u2_Wire) = 0; u2_hevx_be(u2_wire_hev_r(u2_Wire), u2_pryr, god) = 0; u2_hevx_at(u2_wire_hev_r(u2_Wire), lad) = 0; } switch ( Sigcause ) { default: pre = c3__wyrd; break; case sig_none: pre = c3__none; break; case sig_overflow: pre = c3__over; break; case sig_interrupt: pre = c3__intr; break; case sig_terminate: pre = c3__term; break; case sig_memory: pre = c3__full; break; case sig_assert: pre = c3__lame; break; case sig_timer: fprintf(stderr, "timer!!\r\n"); pre = c3__slow; break; } rop = u2nc(pre, u2k(u2t(mok))); u2z(mok); fprintf(stderr, "error computed\r\n"); return rop; } if ( 0 != (hoe = u2_cm_trap()) ) { u2_noun mok; u2_rl_fall(u2_Wire); hoe = u2_rl_take(u2_Wire, hoe); u2_rl_flog(u2_Wire); mok = u2_dc("mook", 2, u2k(u2t(hoe))); rop = u2nc(u2k(u2h(hoe)), u2k(u2t(mok))); u2z(arg); u2z(hoe); u2z(mok); } else { u2_noun pro = fun_f(rec_u, arg); _lo_signal_done(); u2_cm_done(); u2_rl_fall(u2_Wire); pro = u2_rl_take(u2_Wire, pro); u2_rl_flog(u2_Wire); u2z(arg); rop = u2nc(u2_blip, pro); } pro = rop; return pro; }
/* u2_wr_init(): ** ** Install an empty wire within `hat_r` and `mat_r` in the loom, ** with memory model `hip`. ** ** Returns ray to wire, which always equalls the passed `mat_r`. */ u2_ray u2_wr_init(c3_m hip_m, u2_ray hat_r, u2_ray mat_r) { u2_ray wir_r; wir_r = u2_rl_init(hip_m, hat_r, mat_r); u2_rail_hat_r(wir_r) += (c3_wiseof(u2_loom_wire) - c3_wiseof(u2_loom_rail)); #if 1 u2_wire_bas_r(wir_r) = 0; #endif u2_wire_kit_r(wir_r) = 0; u2_cs_init(u2_wire_des_r(wir_r)); /* Trace stack, garbage. */ { u2_wire_tax(wir_r) = u2_nul; u2_wire_lan(wir_r) = u2_yes; } /* Permanent basket = 1/16 of address space. */ { u2_ray bas_r; bas_r = u2_rl_leap_part(wir_r, c3__sand, 1, 16, 0); u2_wire_bas_r(wir_r) = bas_r; #if 0 fprintf(stderr, "bas_r %d, hat %d, mat %d, cap %d, rut %d\n", bas_r >> LoomPageWords, u2_rail_hat_r(bas_r) >> LoomPageWords, u2_rail_mat_r(bas_r) >> LoomPageWords, u2_rail_cap_r(bas_r) >> LoomPageWords, u2_rail_rut_r(bas_r) >> LoomPageWords); fprintf(stderr, "wir_r %d, hat %d, mat %d, cap %d, rut %d\n", wir_r >> LoomPageWords, u2_rail_hat_r(wir_r) >> LoomPageWords, u2_rail_mat_r(wir_r) >> LoomPageWords, u2_rail_cap_r(wir_r) >> LoomPageWords, u2_rail_rut_r(wir_r) >> LoomPageWords); #endif // u2_ba_init(wir_r, 0); } #if 1 /* Host control. */ { u2_ho_push(); } #endif /* Basic performance tracking. */ { u2_wire_bex_r(wir_r) = u2_rl_ralloc(wir_r, c3_wiseof(u2_loom_benx)); u2_bx_boot(wir_r); } /* New performance tracking. */ { u2_wire_rac_r(wir_r) = u2_tx_init(wir_r); } /* Global namespace. */ { u2_wire_hev_r(wir_r) = u2_hv_init(wir_r); } /* OS kernel. */ { u2_wire_arv_r(wir_r) = u2_rl_ralloc(wir_r, c3_wiseof(u2_reck)); } return wir_r; }