Plastic boots with -m.

This commit is contained in:
C. Guy Yarvin 2016-11-26 17:37:41 -08:00 committed by Raymond Pasco
parent 1548fc7f51
commit 2951c0bdf5
8 changed files with 157 additions and 81 deletions

View File

@ -7,7 +7,7 @@
/* u3m_boot(): start the u3 system.
*/
void
u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c);
u3m_boot(c3_o nuu_o, c3_o bug_o, c3_o mad_o, c3_c* dir_c, c3_c *pil_c);
/* u3m_bail(): bail out. Does not return.
**

View File

@ -64,6 +64,11 @@
u3_noun
u3v_do(const c3_c* txt_c, u3_noun arg);
/* u3v_boot(): make a new pier by loading a pill.
*/
void
u3v_boot(c3_c* pas_c);
/* u3v_make(): make a new pier by loading a pill.
*/
void

View File

@ -553,6 +553,7 @@
c3_o loh; // -L, local-only networking
c3_o pro; // -P, profile
c3_o veb; // -v, verbose (inverse of -q)
c3_o mad; // -m, mad pill
c3_o nuu; // -c, new pier
c3_o qui; // -q, quiet
c3_o vno; // -V, turn on +verb

View File

@ -1144,8 +1144,8 @@ u3m_grab(u3_noun som, ...) // terminate with u3_none
*/
u3_noun
u3m_soft(c3_w sec_w,
u3_funk fun_f,
u3_noun arg)
u3_funk fun_f,
u3_noun arg)
{
u3_noun why;
@ -1497,10 +1497,12 @@ _cm_init(c3_o chk_o)
}
}
/* _boot_home(): create ship directory. */
/* _boot_home(): create ship directory.
*/
static void
_boot_home(c3_c *dir_c, c3_c *pil_c)
_boot_home(c3_o mad_o, c3_c *dir_c, c3_c *pil_c)
{
c3_c* nam_c = _(mad_o) ? "events.pill" : "urbit.pill";
c3_c ful_c[2048];
/* Create subdirectories. */
@ -1524,7 +1526,7 @@ _boot_home(c3_c *dir_c, c3_c *pil_c)
{
{
struct stat s;
snprintf(ful_c, 2048, "%s/.urb/urbit.pill", dir_c);
snprintf(ful_c, 2048, "%s/.urb/%s", dir_c, nam_c);
if ( stat(ful_c, &s) == 0 ) {
/* we're in a "logical boot". awful hack, but bail here */
printf("%s confirmed to exist\r\n", ful_c);
@ -1532,8 +1534,8 @@ _boot_home(c3_c *dir_c, c3_c *pil_c)
}
}
if ( pil_c != 0 ) {
snprintf(ful_c, 2048, "cp %s %s/.urb/urbit.pill",
pil_c, dir_c);
snprintf(ful_c, 2048, "cp %s %s/.urb/%s",
pil_c, dir_c, nam_c);
printf("%s\r\n", ful_c);
if ( 0 != system(ful_c) ) {
fprintf(stderr, "could not %s\n", ful_c);
@ -1545,7 +1547,7 @@ _boot_home(c3_c *dir_c, c3_c *pil_c)
CURLcode result;
FILE *file;
snprintf(ful_c, 2048, "%s/.urb/urbit.pill", dir_c);
snprintf(ful_c, 2048, "%s/.urb/%s", dir_c, nam_c);
printf("fetching %s to %s\r\n", url_c, ful_c);
if ( !(curl = curl_easy_init()) ) {
fprintf(stderr, "failed to initialize libcurl\n");
@ -1574,7 +1576,7 @@ _boot_home(c3_c *dir_c, c3_c *pil_c)
/* u3m_boot(): start the u3 system.
*/
void
u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c)
u3m_boot(c3_o nuu_o, c3_o bug_o, c3_o mad_o, c3_c* dir_c, c3_c *pil_c)
{
/* Activate the loom.
*/
@ -1601,14 +1603,23 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c)
if ( _(nuu_o) ) {
c3_c ful_c[2048];
_boot_home(dir_c, pil_c);
_boot_home(mad_o, dir_c, pil_c);
snprintf(ful_c, 2048, "%s/.urb/urbit.pill", dir_c);
if ( _(mad_o) ) {
snprintf(ful_c, 2048, "%s/.urb/events.pill", dir_c);
printf("boot: loading %s\r\n", ful_c);
u3v_make(ful_c);
printf("boot: loading %s\r\n", ful_c);
u3v_boot(ful_c);
}
else {
snprintf(ful_c, 2048, "%s/.urb/urbit.pill", dir_c);
printf("boot: loading %s\r\n", ful_c);
u3v_make(ful_c);
u3v_jack();
}
u3v_jack();
}
else {
u3v_hose();

View File

@ -590,51 +590,66 @@ _sang_x(u3_noun a, u3_noun b)
static void
_sung_one(u3_noun* a, u3_noun* b)
{
if ( *a == *b ) {
return;
}
else {
c3_o asr_o = u3a_is_senior(u3R, *a);
c3_o bsr_o = u3a_is_senior(u3R, *b);
if ( _(asr_o) && _(bsr_o) ) {
// You shouldn't have let this happen. We don't want to
// descend down to a lower road and free there, because
// synchronization - though this could be revisited under
// certain circumstances.
} else {
u3_road* rod_u = u3R;
while ( 1 ) {
//
return;
}
if ( _(asr_o) && !_(bsr_o) ){
u3z(*b);
*b = *a;
}
if ( _(bsr_o) && !_(asr_o) ) {
u3z(*a);
*a = *b;
}
if ( u3a_is_north(u3R) ) {
if ( *a <= *b ) {
u3k(*a);
u3z(*b);
*b = *a;
} else {
u3k(*b);
u3z(*a);
*a = *b;
}
}
else {
if ( *a >= *b ) {
u3k(*a);
u3z(*b);
*b = *a;
} else {
u3k(*b);
u3z(*a);
*a = *b;
// we can't perform this kind of butchery on the home road,
// where asynchronous things can allocate.
//
if ( u3R == &u3H->rod_u ) {
break;
}
else {
c3_o asr_o = u3a_is_senior(u3R, *a);
c3_o bsr_o = u3a_is_senior(u3R, *b);
if ( _(asr_o) && _(bsr_o) ) {
//
// both are senior, so we address them on a higher road
// if possible.
//
u3R = u3to(u3_road, u3R->par_p);
continue;
}
if ( _(asr_o) && !_(bsr_o) ){
u3z(*b);
*b = *a;
}
if ( _(bsr_o) && !_(asr_o) ) {
u3z(*a);
*a = *b;
}
if ( u3a_is_north(u3R) ) {
if ( *a <= *b ) {
u3k(*a);
u3z(*b);
*b = *a;
} else {
u3k(*b);
u3z(*a);
*a = *b;
}
}
else {
if ( *a >= *b ) {
u3k(*a);
u3z(*b);
*b = *a;
} else {
u3k(*b);
u3z(*a);
*a = *b;
}
}
break;
}
}
u3R = rod_u;
}
}
@ -838,6 +853,13 @@ u3r_sing(u3_noun a, u3_noun b)
c3_o
u3r_sung(u3_noun a, u3_noun b)
{
if ( a == b ) { return c3y; }
#if 0
if ( u3r_mug(a) == u3r_mug(b) ) {
fprintf(stderr, "collision on %x: %x/%x\r\n", u3r_mug(a), a, b);
}
#endif
return _sung_x(a, b);
}

View File

@ -4,7 +4,6 @@
#include <stdio.h>
#include "all.h"
int WISH;
/* _cv_nock_wish(): call wish through hardcoded interface.
*/
static u3_noun
@ -12,10 +11,8 @@ _cv_nock_wish(u3_noun txt)
{
u3_noun fun, pro;
WISH = 1;
fun = u3n_nock_on(u3k(u3A->roc), u3k(u3x_at(20, u3A->roc)));
pro = u3n_slam_on(fun, txt);
WISH = 0;
return pro;
}
@ -33,31 +30,50 @@ u3v_make(c3_c* pas_c)
u3z(sys);
}
/* u3v_fire(): execute initial lifecycle.
*/
u3_noun
u3v_fire(u3_noun sys)
{
u3_noun fol = u3nt(2, u3nc(0, 3), u3nc(0, 2));
return u3n_nock_on(sys, fol);
}
/* u3v_load(): loading sequence.
*/
u3_noun
u3v_load(u3_noun pil)
{
u3_noun sys = u3ke_cue(pil);
u3_noun cor = u3v_fire(sys);
u3_noun pro;
pro = u3k(u3r_at(7, cor));
u3z(cor);
return pro;
}
/* u3v_boot(): correct bootstrap sequence.
*/
void
u3v_remake(c3_c* pas_c,
c3_c* who_c,
c3_c* why_c)
u3v_boot(c3_c* pas_c)
{
u3_noun sys = u3ke_cue(u3m_file(pas_c));
u3_noun eva; // event-one
u3_noun evb; // event-two
u3_noun evc; // compiler-formula
u3_noun evd; // compiler-source
u3_noun eve; // arvo-source
u3_noun evf; // main-sequence
u3_noun pil = u3m_file(pas_c);
u3_noun pru = u3m_soft(0, u3v_load, pil);
u3r_mean(sys, 2, &eva,
6, &evb,
14, &evc,
30, &evd,
if ( u3h(pru) != 0 ) {
fprintf(stderr, "boot failed\r\n");
exit(1);
}
if ( (c3n == u3r_mean(cor, u3x_sam_2, &gol,
u3x_sam_3, &gen,
u3x_con, &van,
0)) ||
fprintf(stderr, "final state %x\r\n", u3r_mug(u3t(pru)));
u3A->ken = 0;
u3A->roc = u3k(u3t(pru));
u3z(pru);
}
/* u3v_jack(): execute kernel formula to bind jets.

View File

@ -327,7 +327,7 @@ _lo_tape(FILE* fil_u, u3_noun tep)
{
u3_noun tap = tep;
while ( u3_nul != tap ) {
while ( c3y == u3du(tap) ) {
c3_c car_c;
if ( u3h(tap) >= 127 ) {
@ -380,9 +380,24 @@ u3_lo_punt(c3_l tab_l, u3_noun tac)
// We are calling nock here, but hopefully need no protection.
//
while ( c3y == u3r_du(cat) ) {
u3_noun wol = u3dc("wash", u3nc(tab_l, col_l), u3k(u3h(cat)));
if ( 0 == u3A->roc ) {
u3_noun act = u3h(cat);
_lo_wall(wol);
if ( c3__leaf == u3h(act) ) {
FILE* fil_u = u3_term_io_hija();
_lo_tape(fil_u, u3k(u3t(act)));
putc(13, fil_u);
putc(10, fil_u);
u3_term_io_loja(0);
}
}
else {
u3_noun wol = u3dc("wash", u3nc(tab_l, col_l), u3k(u3h(cat)));
_lo_wall(wol);
}
cat = u3t(cat);
}
u3z(tac);

View File

@ -68,6 +68,7 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.abo = c3n;
u3_Host.ops_u.bat = c3n;
u3_Host.ops_u.gab = c3n;
u3_Host.ops_u.mad = c3n;
u3_Host.ops_u.loh = c3n;
u3_Host.ops_u.dem = c3n;
u3_Host.ops_u.fog = c3n;
@ -82,7 +83,7 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.rep = c3n;
u3_Host.ops_u.kno_w = DefaultKernel;
while ( (ch_i=getopt(argc, argv,"G:B:A:I:w:t:f:k:l:n:p:r:LabcdgqvxFMPDXR")) != -1 ) {
while ( (ch_i=getopt(argc, argv,"G:B:A:I:w:t:f:k:l:n:p:r:LabcdgmqvxFMPDXR")) != -1 ) {
switch ( ch_i ) {
case 'M': {
u3_Host.ops_u.mem = c3y;
@ -117,6 +118,10 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.tex = c3y;
break;
}
case 'm': {
u3_Host.ops_u.mad = c3y;
break;
}
case 'X': {
u3_Host.ops_u.fog = c3y;
break;
@ -540,6 +545,7 @@ main(c3_i argc,
}
u3m_boot(u3_Host.ops_u.nuu,
u3_Host.ops_u.gab,
u3_Host.ops_u.mad,
u3_Host.dir_c,
u3_Host.ops_u.pil_c);