From 8caac67e05171dfa0e7e2f85529119553e14d9d1 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Mon, 18 May 2015 10:07:42 -0700 Subject: [PATCH] Eliminated last direct pointers from piers. --- i/n/a.h | 8 +++----- i/n/u.h | 1 + n/j.c | 4 ++-- n/m.c | 36 ++++++++++++++++++------------------ n/t.c | 6 +++--- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/i/n/a.h b/i/n/a.h index 541e24e5f..23e62ebaf 100644 --- a/i/n/a.h +++ b/i/n/a.h @@ -98,11 +98,9 @@ /* u3a_road: contiguous allocation and execution context. */ typedef struct _u3a_road { - struct _u3a_road* par_u; // parent road - - struct _u3a_road* kid_u; // child road list - struct _u3a_road* nex_u; // sibling road - struct _u3a_road* now_u; // current road pointer + u3p(struct _u3a_road) par_p; // parent road + u3p(struct _u3a_road) kid_p; // child road list + u3p(struct _u3a_road) nex_p; // sibling road u3p(c3_w) cap_p; // top of transient region u3p(c3_w) hat_p; // top of durable region diff --git a/i/n/u.h b/i/n/u.h index 9eb033ea3..46c9553af 100644 --- a/i/n/u.h +++ b/i/n/u.h @@ -104,5 +104,6 @@ /* u3to(), u3of(): offset/pointer conversion. */ # define u3to(type, x) ((type *) u3a_into(x)) +# define u3tn(type, x) (x == 0) ? (void *)0 : ((type *) u3a_into(x)) # define u3of(type, x) (u3a_outa((type *)x)) diff --git a/n/j.c b/n/j.c index 0e6db22b2..acc70703a 100644 --- a/n/j.c +++ b/n/j.c @@ -209,8 +209,8 @@ u3j_find(u3_noun bat) return jaw; } - if ( rod_u->par_u ) { - rod_u = rod_u->par_u; + if ( rod_u->par_p ) { + rod_u = u3to(u3_road, rod_u->par_p); } else return u3_none; } diff --git a/n/m.c b/n/m.c index d99f6872d..d2c85dd4b 100644 --- a/n/m.c +++ b/n/m.c @@ -149,7 +149,7 @@ _cm_signal_handle_term(int x) { // Ignore if we are using base memory from work memory, very rare. // - if ( (0 != u3H->rod_u.kid_u) && (&(u3H->rod_u) == u3R) ) { + if ( (0 != u3H->rod_u.kid_p) && (&(u3H->rod_u) == u3R) ) { _cm_emergency("ignored", c3__term); } else { @@ -184,7 +184,7 @@ _cm_signal_reset(void) u3R = &u3H->rod_u; u3R->cap_p = u3R->mat_p; u3R->ear_p = 0; - u3R->kid_u = 0; + u3R->kid_p = 0; } /* _cm_stack_recover(): recover stack trace, with lacunae. @@ -276,13 +276,13 @@ _cm_signal_recover(c3_l sig_l, u3_noun arg) u3R = &(u3H->rod_u); rod_u = u3R; - while ( rod_u->kid_u ) { + while ( rod_u->kid_p ) { #if 0 fprintf(stderr, "collecting %d frames\r\n", - u3kb_lent(rod_u->kid_u->bug.tax)); + u3kb_lent((u3to(u3_road, rod_u->kid_p)->bug.tax)); #endif - tax = u3kb_weld(_cm_stack_recover(rod_u->kid_u), tax); - rod_u = rod_u->kid_u; + tax = u3kb_weld(_cm_stack_recover(u3to(u3_road, rod_u->kid_p)), tax); + rod_u = u3to(u3_road, rod_u->kid_p); } } @@ -712,9 +712,9 @@ u3m_leap(c3_w pad_w) /* Attach the new road to its parents. */ { - c3_assert(0 == u3R->kid_u); - rod_u->par_u = u3R; - u3R->kid_u = rod_u; + c3_assert(0 == u3R->kid_p); + rod_u->par_p = u3of(u3_road, u3R); + u3R->kid_p = u3of(u3_road, rod_u); } /* Set up the new road. @@ -730,26 +730,26 @@ u3m_leap(c3_w pad_w) void u3m_fall() { - c3_assert(0 != u3R->par_u); + c3_assert(0 != u3R->par_p); #if 0 fprintf(stderr, "fall: from %s %p, to %s %p (cap %p, was %p)\r\n", _(u3a_is_north(u3R)) ? "north" : "south", u3R, _(u3a_is_north(u3R)) ? "north" : "south", - u3R->par_u, + u3to(u3_road, u3R->par_p), u3R->hat_w, u3R->rut_w); #endif /* The new cap is the old hat - it's as simple as that. */ - u3R->par_u->cap_p = u3R->hat_p; + u3to(u3_road, u3R->par_p)->cap_p = u3R->hat_p; /* And, we're back home. */ - u3R = u3R->par_u; - u3R->kid_u = 0; + u3R = u3to(u3_road, u3R->par_p); + u3R->kid_p = 0; } /* u3m_hate(): new, integrated leap mechanism (enter). @@ -951,8 +951,8 @@ u3m_soft_run(u3_noun fly, /* Configure the new road. */ { - u3R->ski.flu = u3nc(fly, u3R->par_u->ski.flu); - u3R->pro.don = u3R->par_u->pro.don; + u3R->ski.flu = u3nc(fly, u3to(u3_road, u3R->par_p)->ski.flu); + u3R->pro.don = u3to(u3_road, u3R->par_p)->pro.don; u3R->bug.tax = 0; } u3t_on(coy_o); @@ -1039,8 +1039,8 @@ u3m_soft_esc(u3_noun sam) /* Configure the new road. */ { - u3R->ski.flu = u3t(u3R->par_u->ski.flu); - u3R->pro.don = u3R->par_u->pro.don; + u3R->ski.flu = u3t(u3to(u3_road, u3R->par_p)->ski.flu); + u3R->pro.don = u3to(u3_road, u3R->par_p)->pro.don; u3R->bug.tax = 0; } diff --git a/n/t.c b/n/t.c index eeefb0ca3..ff937334b 100644 --- a/n/t.c +++ b/n/t.c @@ -113,8 +113,8 @@ _t_jet_label(u3a_road* rod_u, u3_noun bat) return u3h(u3t(u3t(u3h(cax)))); } - if ( rod_u->par_u ) { - rod_u = rod_u->par_u; + if ( rod_u->par_p ) { + rod_u = u3to(u3_road, rod_u->par_p); } else return u3_none; } @@ -175,7 +175,7 @@ _t_samp_process(u3_road* rod_u) } don = u3t(don); } - rod_u = rod_u->par_u; + rod_u = u3tn(u3_road, rod_u->par_p); } u3z(muf);