All pointers now eradicated.

This commit is contained in:
C. Guy Yarvin 2014-11-04 10:39:56 -08:00
parent 49bf64733d
commit 9659726fbf
4 changed files with 59 additions and 55 deletions

23
g/v.c
View File

@ -61,17 +61,18 @@ u3_cv_jack(void)
void
u3_cv_hose(void)
{
u3_cs_cart* egg_u = u3A->ova.egg_u;
u3p(u3_cs_cart) egg_p = u3A->ova.egg_p;
while ( egg_u ) {
u3_cs_cart* nex_u = egg_u->nex_u;
while ( egg_p ) {
u3_cs_cart* egg_u = u3to(u3_cs_cart, egg_p);
u3p(u3_cs_cart) nex_p = egg_u->nex_p;
u3_ca_lose(egg_u->vir);
u3_ca_free(egg_u);
egg_u = nex_u;
egg_p = nex_p;
}
u3A->ova.egg_u = u3A->ova.geg_u = 0;
u3A->ova.egg_p = u3A->ova.geg_p = 0;
u3z(u3A->roe);
u3A->roe = u3_nul;
}
@ -495,13 +496,15 @@ u3_cv_louse(c3_m how_m)
/* _cv_mark_ova(): mark ova queue.
*/
static void
_cv_mark_ova(u3_cs_cart* egg_u)
_cv_mark_ova(u3p(u3_cs_cart) egg_p)
{
while ( egg_u ) {
u3_ca_mark_ptr(egg_u);
while ( egg_p ) {
u3_cs_cart* egg_u = u3to(u3_cs_cart, egg_p);
u3_ca_mark_ptr(egg_u);
u3_ca_mark_noun(egg_u->vir);
egg_u = egg_u->nex_u;
egg_p = egg_u->nex_p;
}
}
@ -524,5 +527,5 @@ u3_cv_mark(void)
u3_ca_mark_noun(arv_u->ken);
u3_ca_mark_noun(arv_u->roc);
_cv_mark_ova(arv_u->ova.egg_u);
_cv_mark_ova(arv_u->ova.egg_p);
}

View File

@ -9,11 +9,11 @@
struct _u3_cs_arvo;
typedef struct _u3_cs_cart {
u3_noun vir; // effects of ovum
u3_bean did; // cart considered for commit?
u3_bean cit; // cart committed?
c3_d ent_d; // entry in raft queue?
struct _u3_cs_cart* nex_u; // next in queue
u3_noun vir; // effects of ovum
u3_bean did; // cart considered for commit?
u3_bean cit; // cart committed?
c3_d ent_d; // entry in raft queue?
u3p(struct _u3_cs_cart) nex_p;
} u3_cs_cart;
/* u3_cs_arvo: modern arvo structure.
@ -33,11 +33,8 @@
u3_noun ken; // kernel formula
u3_noun roc; // kernel core
union {
struct { uint64_t a; uint64_t b; };
struct {
struct _u3_cs_cart* egg_u; // exit of ovum queue
struct _u3_cs_cart* geg_u; // entry of ovum queue
} ova;
};
struct { // ova waiting to process
u3p(u3_cs_cart) egg_p; // exit of ovum queue
u3p(u3_cs_cart) geg_p; // entry of ovum queue
} ova;
} u3_cs_arvo;

View File

@ -6,9 +6,9 @@
static u3_noun
_cue_in(u3_ch_root* har_u,
u3_atom a,
u3_atom b)
_cue_in(u3p(u3_ch_root) har_p,
u3_atom a,
u3_atom b)
{
u3_noun p, q;
@ -19,7 +19,7 @@
p = u3_cqa_inc(u3k(u3h(c)));
q = u3k(u3t(c));
u3_ch_put(har_u, u3k(b), u3k(q));
u3_ch_put(har_p, u3k(b), u3k(q));
u3z(c);
u3z(x);
@ -32,22 +32,22 @@
u3_noun u, v, w;
u3_noun x, y;
u = _cue_in(har_u, a, c);
u = _cue_in(har_p, a, c);
x = u3_cqa_add(u3h(u), c);
v = _cue_in(har_u, a, x);
v = _cue_in(har_p, a, x);
w = u3nc(u3k(u3h(u3t(u))), u3k(u3h(u3t(v))));
y = u3_cqa_add(u3h(u), u3h(v));
p = u3_cqa_add(2, y);
q = w;
u3_ch_put(har_u, u3k(b), u3k(q));
u3_ch_put(har_p, u3k(b), u3k(q));
u3z(u); u3z(v); u3z(x); u3z(y);
}
else {
u3_noun d = u3_cqe_rub(c, a);
u3_noun x = u3_ch_get(har_u, u3k(u3t(d)));
u3_noun x = u3_ch_get(har_p, u3k(u3t(d)));
p = u3_cqa_add(2, u3h(d));
if ( u3_none == x ) {
@ -65,12 +65,12 @@
u3_noun
u3_cqe_cue(u3_atom a)
{
u3_ch_root* har_u = u3_ch_new();
u3p(u3_ch_root) har_p = u3_ch_new();
u3_noun x = _cue_in(har_u, a, 0);
u3_noun x = _cue_in(har_p, a, 0);
u3_noun y = u3k(u3h(u3t(x)));
u3_ch_free(har_u);
u3_ch_free(har_p);
u3z(x);
return y;

View File

@ -1620,16 +1620,19 @@ _raft_punk(u3_noun ovo)
static void
_raft_comm(c3_d bid_d)
{
u3_cs_cart* egg_u;
u3p(u3_cs_cart) egg_p;
u3_lo_open();
egg_u = u3A->ova.egg_u;
while ( egg_u ) {
egg_p = u3A->ova.egg_p;
while ( egg_p ) {
u3_cs_cart* egg_u = u3to(u3_cs_cart, egg_p);
if ( egg_u->ent_d <= bid_d ) {
egg_u->cit = u3_yes;
} else break;
egg_u = egg_u->nex_u;
egg_p = egg_u->nex_p;
}
u3_lo_shut(u3_yes);
}
@ -1688,7 +1691,7 @@ void
u3_raft_work(void)
{
if ( u3Z->typ_e != u3_raty_lead ) {
c3_assert(u3A->ova.egg_u == 0);
c3_assert(u3A->ova.egg_p == 0);
if ( u3_nul != u3A->roe ) {
uL(fprintf(uH, "raft: dropping roe!!\n"));
u3z(u3A->roe);
@ -1696,28 +1699,27 @@ u3_raft_work(void)
}
}
else {
u3_cs_cart* egg_u;
u3_noun ova;
u3_noun vir;
u3_noun nex;
// Delete finished events.
//
while ( u3A->ova.egg_u ) {
egg_u = u3A->ova.egg_u;
while ( u3A->ova.egg_p ) {
u3p(u3_cs_cart) egg_p = u3A->ova.egg_p;
u3_cs_cart* egg_u = u3to(u3_cs_cart, u3A->ova.egg_p);
if ( u3_yes == egg_u->did ) {
vir = egg_u->vir;
if ( egg_u == u3A->ova.geg_u ) {
c3_assert(egg_u->nex_u == 0);
u3A->ova.geg_u = u3A->ova.egg_u = 0;
if ( egg_p == u3A->ova.geg_p ) {
c3_assert(egg_u->nex_p == 0);
u3A->ova.geg_p = u3A->ova.egg_p = 0;
}
else {
c3_assert(egg_u->nex_u != 0);
u3A->ova.egg_u = egg_u->nex_u;
c3_assert(egg_u->nex_p != 0);
u3A->ova.egg_p = egg_u->nex_p;
}
egg_u->cit = u3_yes;
u3_ca_free(egg_u);
}
@ -1761,8 +1763,10 @@ u3_raft_work(void)
u3z(ova); ova = nex;
if ( u3_nul != ovo ) {
egg_u = u3_ca_malloc(sizeof(*egg_u));
egg_u->nex_u = 0;
u3_cs_cart* egg_u = u3_ca_malloc(sizeof(*egg_u));
u3p(u3_cs_cart) egg_p = u3of(u3_cs_cart, egg_u);
egg_u->nex_p = 0;
egg_u->cit = u3_no;
egg_u->did = u3_no;
egg_u->vir = vir;
@ -1779,14 +1783,14 @@ u3_raft_work(void)
bid_d = _raft_push(u3Z, bob_w, len_w);
egg_u->ent_d = bid_d;
if ( 0 == u3A->ova.geg_u ) {
c3_assert(0 == u3A->ova.egg_u);
u3A->ova.geg_u = u3A->ova.egg_u = egg_u;
if ( 0 == u3A->ova.geg_p ) {
c3_assert(0 == u3A->ova.egg_p);
u3A->ova.geg_p = u3A->ova.egg_p = egg_p;
}
else {
c3_assert(0 == u3A->ova.geg_u->nex_u);
u3A->ova.geg_u->nex_u = egg_u;
u3A->ova.geg_u = egg_u;
c3_assert(0 == u3to(u3_cs_cart, u3A->ova.geg_p)->nex_p);
u3to(u3_cs_cart, u3A->ova.geg_p)->nex_p = egg_p;
u3A->ova.geg_p = egg_p;
}
_raft_kick_all(vir);
egg_u->did = u3_yes;