Merge branch 'test' into shell

Conflicts:
	urb/urbit.pill
This commit is contained in:
Philip C Monk 2014-11-04 15:30:16 -05:00
commit 35988a0ddf
16 changed files with 273 additions and 248 deletions

88
g/a.c
View File

@ -124,15 +124,16 @@ _me_road_all_hat(c3_w len_w)
}
if ( u3_yes == u3_co_is_north(u3R) ) {
c3_w* all_w;
u3_post all_p;
all_w = u3R->hat_w;
u3R->hat_w += len_w;
return all_w;
all_p = u3R->hat_p;
u3R->hat_p += len_w;
return u3_co_into(all_p);
}
else {
u3R->hat_w -= len_w;
return u3R->hat_w;
u3R->hat_p -= len_w;
return u3_co_into(u3R->hat_p);
}
}
@ -147,15 +148,15 @@ _me_road_all_cap(c3_w len_w)
}
if ( u3_yes == u3_co_is_north(u3R) ) {
u3R->cap_w -= len_w;
return u3R->cap_w;
u3R->cap_p -= len_w;
return u3_co_into(u3R->cap_p);
}
else {
c3_w* all_w;
u3_post all_p;
all_w = u3R->cap_w;
u3R->cap_w += len_w;
return all_w;
all_p = u3R->cap_p;
u3R->cap_p += len_w;
return u3_co_into(all_p);
}
}
#endif
@ -213,7 +214,7 @@ _ca_walloc(c3_w len_w)
break;
}
else {
/* Nothing in top free list. Chip away at the hat_w.
/* Nothing in top free list. Chip away at the hat.
*/
return u3_co_boxto(_box_make(_me_road_all_hat(siz_w), siz_w, 1));
}
@ -278,7 +279,7 @@ _ca_walloc(c3_w len_w)
int FOO;
/* u3_ca_walloc(): allocate storage words on hat_w.
/* u3_ca_walloc(): allocate storage words on hat.
*/
void*
u3_ca_walloc(c3_w len_w)
@ -372,7 +373,7 @@ u3_ca_free(void* tox_v)
if ( u3_yes == u3_co_is_north(u3R) ) {
/* Try to coalesce with the block below.
*/
if ( box_w != u3R->rut_w ) {
if ( box_w != u3_co_into(u3R->rut_p) ) {
c3_w laz_w = *(box_w - 1);
u3_cs_box* pox_u = (u3_cs_box*)(void *)(box_w - laz_w);
@ -387,8 +388,8 @@ u3_ca_free(void* tox_v)
/* Try to coalesce with the block above, or the wilderness.
*/
if ( (box_w + box_u->siz_w) == u3R->hat_w ) {
u3R->hat_w = box_w;
if ( (box_w + box_u->siz_w) == u3_co_into(u3R->hat_p) ) {
u3R->hat_p = u3_co_outa(box_w);
}
else {
u3_cs_box* nox_u = (u3_cs_box*)(void *)(box_w + box_u->siz_w);
@ -403,7 +404,7 @@ u3_ca_free(void* tox_v)
else {
/* Try to coalesce with the block above.
*/
if ( (box_w + box_u->siz_w) != u3R->rut_w ) {
if ( (box_w + box_u->siz_w) != u3_co_into(u3R->rut_p) ) {
u3_cs_box* nox_u = (u3_cs_box*)(void *)(box_w + box_u->siz_w);
if ( 0 == nox_u->use_w ) {
@ -414,8 +415,8 @@ u3_ca_free(void* tox_v)
/* Try to coalesce with the block below, or with the wilderness.
*/
if ( box_w == u3R->hat_w ) {
u3R->hat_w = (box_w + box_u->siz_w);
if ( box_w == u3_co_into(u3R->hat_p) ) {
u3R->hat_p = u3_co_outa(box_w + box_u->siz_w);
}
else {
c3_w laz_w = *(box_w - 1);
@ -1031,12 +1032,16 @@ c3_w
u3_ca_mark_ptr(void* ptr_v)
{
if ( u3_so(u3_co_is_north(u3R)) ) {
if ( !((ptr_v >= (void*)u3R->rut_w) && (ptr_v < (void*)u3R->hat_w)) ) {
if ( !((ptr_v >= u3_co_into(u3R->rut_p)) &&
(ptr_v < u3_co_into(u3R->hat_p))) )
{
return 0;
}
}
else {
if ( !((ptr_v >= (void*)u3R->hat_w) && (ptr_v < (void*)u3R->rut_w)) ) {
if ( !((ptr_v >= u3_co_into(u3R->hat_p)) &&
(ptr_v < u3_co_into(u3R->rut_p))) )
{
return 0;
}
}
@ -1150,8 +1155,8 @@ u3_ca_sweep(c3_c* cap_c)
c3_w i_w;
end_w = u3_so(u3_co_is_north(u3R))
? (u3R->hat_w - u3R->rut_w)
: (u3R->rut_w - u3R->hat_w);
? (u3R->hat_p - u3R->rut_p)
: (u3R->rut_p - u3R->hat_p);
for ( i_w = 0; i_w < u3_cc_fbox_no; i_w++ ) {
u3p(u3_cs_fbox) fre_p = u3R->all.fre_p[i_w];
@ -1170,10 +1175,13 @@ u3_ca_sweep(c3_c* cap_c)
*/
pos_w = leq_w = weq_w = 0;
{
c3_w* box_w = u3_so(u3_co_is_north(u3R)) ? u3R->rut_w : u3R->hat_w;
u3_post box_p = u3_so(u3_co_is_north(u3R)) ? u3R->rut_p : u3R->hat_p;
u3_post end_p = u3_so(u3_co_is_north(u3R)) ? u3R->hat_p : u3R->rut_p;
c3_w* box_w = u3_co_into(box_p);
c3_w* end_w = u3_co_into(end_p);
while ( box_w < (u3_so(u3_co_is_north(u3R)) ? u3R->hat_w : u3R->rut_w) ) {
u3_cs_box* box_u = (void *)box_w;
while ( box_w < end_w ) {
u3_cs_box* box_u = (void *)box_w;
#ifdef U3_MEMORY_DEBUG
if ( box_u->use_w != box_u->eus_w ) {
@ -1231,11 +1239,11 @@ u3_ca_sweep(c3_c* cap_c)
}
tot_w = u3_so(u3_co_is_north(u3R))
? u3R->mat_w - u3R->rut_w
: u3R->rut_w - u3R->mat_w;
? u3R->mat_p - u3R->rut_p
: u3R->rut_p - u3R->mat_p;
caf_w = u3_so(u3_co_is_north(u3R))
? u3R->mat_w - u3R->cap_w
: u3R->cap_w - u3R->mat_w;
? u3R->mat_p - u3R->cap_p
: u3R->cap_p - u3R->mat_p;
// u3_ca_print_memory("available", (tot_w - pos_w));
// u3_ca_print_memory("allocated", pos_w);
@ -1319,24 +1327,25 @@ u3_ca_moot(c3_w* sal_w)
return u3_co_to_pug(u3_co_outa(nov_w));
}
#if 0
/* _ca_detect(): in u3_ca_detect().
*/
static c3_d
_ca_detect(u3_ch_root* har_u, u3_noun fum, u3_noun som, c3_d axe_d)
_ca_detect(u3p(u3_ch_root) har_p, u3_noun fum, u3_noun som, c3_d axe_d)
{
while ( 1 ) {
if ( som == fum ) {
return axe_d;
}
else if ( u3_ne(u3du(fum)) || (u3_none != u3_ch_get(har_u, fum)) ) {
else if ( u3_ne(u3du(fum)) || (u3_none != u3_ch_get(har_p, fum)) ) {
return 0;
}
else {
c3_d eax_d;
u3_ch_put(har_u, fum, 0);
u3_ch_put(har_p, fum, 0);
if ( 0 != (eax_d = _ca_detect(har_u, u3h(fum), som, 2ULL * axe_d)) ) {
if ( 0 != (eax_d = _ca_detect(har_p, u3h(fum), som, 2ULL * axe_d)) ) {
return u3_yes;
}
else {
@ -1354,14 +1363,15 @@ _ca_detect(u3_ch_root* har_u, u3_noun fum, u3_noun som, c3_d axe_d)
c3_d
u3_ca_detect(u3_noun fum, u3_noun som)
{
u3_ch_root* har_u = u3_ch_new();
c3_o ret_o;
u3p(u3_ch_root) har_p = u3_ch_new();
c3_o ret_o;
ret_o = _ca_detect(har_u, fum, som, 1);
u3_ch_free(har_u);
ret_o = _ca_detect(har_p, fum, som, 1);
u3_ch_free(har_p);
return ret_o;
}
#endif
/* u3_ca_mint(): finish a measured proto-atom.
*/

4
g/e.c
View File

@ -864,8 +864,8 @@ u3_ce_init(c3_o chk_o)
void
u3_ce_grab(c3_c* cap_c, u3_noun som, ...) // terminate with u3_none
{
// u3_ch_free(u3R->cax.har_u);
// u3R->cax.har_u = u3_ch_new();
// u3_ch_free(u3R->cax.har_p);
// u3R->cax.har_p = u3_ch_new();
u3_cv_mark();
u3_cm_mark();

66
g/h.c
View File

@ -9,17 +9,18 @@ static void* _ch_some_new(c3_w lef_w);
/* u3_ch_new(): create hashtable.
*/
u3_ch_root*
u3p(u3_ch_root)
u3_ch_new(void)
{
u3_ch_root* har_u = u3_ca_walloc(c3_wiseof(u3_ch_root));
u3_ch_root* har_u = u3_ca_walloc(c3_wiseof(u3_ch_root));
u3p(u3_ch_root) har_p = u3of(u3_ch_root, har_u);
c3_w i_w;
har_u->clk_w = 0;
for ( i_w = 0; i_w < 64; i_w++ ) {
har_u->sot_w[i_w] = 0;
}
return har_u;
return har_p;
}
/* _ch_popcount(): number of bits set in word. A standard intrinsic.
@ -183,13 +184,14 @@ _ch_some_add(void* han_v, c3_w lef_w, c3_w rem_w, u3_noun kev)
** `key` is RETAINED; `val` is transferred.
*/
void
u3_ch_put(u3_ch_root* har_u, u3_noun key, u3_noun val)
u3_ch_put(u3p(u3_ch_root) har_p, u3_noun key, u3_noun val)
{
u3_noun kev = u3nc(u3k(key), val);
c3_w mug_w = u3_cr_mug(key);
c3_w inx_w = (mug_w >> 25);
c3_w rem_w = (mug_w & ((1 << 25) - 1));
c3_w sot_w = har_u->sot_w[inx_w];
u3_ch_root* har_u = u3to(u3_ch_root, har_p);
u3_noun kev = u3nc(u3k(key), val);
c3_w mug_w = u3_cr_mug(key);
c3_w inx_w = (mug_w >> 25);
c3_w rem_w = (mug_w & ((1 << 25) - 1));
c3_w sot_w = har_u->sot_w[inx_w];
if ( u3_so(u3_ch_slot_is_null(sot_w)) ) {
har_u->sot_w[inx_w] = u3_ch_noun_to_slot(kev);
@ -272,11 +274,12 @@ _ch_node_hum(u3_ch_node* han_u, c3_w lef_w, c3_w rem_w, c3_w mug_w)
** `key` is RETAINED.
*/
c3_o
u3_ch_hum(u3_ch_root* har_u, c3_w mug_w)
u3_ch_hum(u3p(u3_ch_root) har_p, c3_w mug_w)
{
c3_w inx_w = (mug_w >> 25);
c3_w rem_w = (mug_w & ((1 << 25) - 1));
c3_w sot_w = har_u->sot_w[inx_w];
u3_ch_root* har_u = u3to(u3_ch_root, har_p);
c3_w inx_w = (mug_w >> 25);
c3_w rem_w = (mug_w & ((1 << 25) - 1));
c3_w sot_w = har_u->sot_w[inx_w];
if ( u3_so(u3_ch_slot_is_null(sot_w)) ) {
return u3_no;
@ -358,12 +361,13 @@ _ch_node_get(u3_ch_node* han_u, c3_w lef_w, c3_w rem_w, u3_noun key)
** `key` is RETAINED.
*/
u3_weak
u3_ch_get(u3_ch_root* har_u, u3_noun key)
u3_ch_get(u3p(u3_ch_root) har_p, u3_noun key)
{
c3_w mug_w = u3_cr_mug(key);
c3_w inx_w = (mug_w >> 25);
c3_w rem_w = (mug_w & ((1 << 25) - 1));
c3_w sot_w = har_u->sot_w[inx_w];
u3_ch_root* har_u = u3to(u3_ch_root, har_p);
c3_w mug_w = u3_cr_mug(key);
c3_w inx_w = (mug_w >> 25);
c3_w rem_w = (mug_w & ((1 << 25) - 1));
c3_w sot_w = har_u->sot_w[inx_w];
if ( u3_so(u3_ch_slot_is_null(sot_w)) ) {
return u3_none;
@ -446,12 +450,13 @@ _ch_node_gut(u3_ch_node* han_u, c3_w lef_w, c3_w rem_w, u3_noun key)
** `key` is RETAINED.
*/
u3_weak
u3_ch_gut(u3_ch_root* har_u, u3_noun key)
u3_ch_gut(u3p(u3_ch_root) har_p, u3_noun key)
{
c3_w mug_w = u3_cr_mug(key);
c3_w inx_w = (mug_w >> 25);
c3_w rem_w = (mug_w & ((1 << 25) - 1));
c3_w sot_w = har_u->sot_w[inx_w];
u3_ch_root* har_u = u3to(u3_ch_root, har_p);
c3_w mug_w = u3_cr_mug(key);
c3_w inx_w = (mug_w >> 25);
c3_w rem_w = (mug_w & ((1 << 25) - 1));
c3_w sot_w = har_u->sot_w[inx_w];
if ( u3_so(u3_ch_slot_is_null(sot_w)) ) {
return u3_none;
@ -521,9 +526,10 @@ _ch_free_node(u3_ch_node* han_u, c3_w lef_w)
/* u3_ch_free(): free hashtable.
*/
void
u3_ch_free(u3_ch_root* har_u)
u3_ch_free(u3p(u3_ch_root) har_p)
{
c3_w i_w;
u3_ch_root* har_u = u3to(u3_ch_root, har_p);
c3_w i_w;
for ( i_w = 0; i_w < 64; i_w++ ) {
c3_w sot_w = har_u->sot_w[i_w];
@ -587,9 +593,10 @@ _ch_walk_node(u3_ch_node* han_u, c3_w lef_w, void (*fun_f)(u3_noun))
/* u3_ch_walk(): walk hashtable for gc.
*/
void
u3_ch_walk(u3_ch_root* har_u, void (*fun_f)(u3_noun))
u3_ch_walk(u3p(u3_ch_root) har_p, void (*fun_f)(u3_noun))
{
c3_w i_w;
u3_ch_root* har_u = u3to(u3_ch_root, har_p);
c3_w i_w;
for ( i_w = 0; i_w < 64; i_w++ ) {
c3_w sot_w = har_u->sot_w[i_w];
@ -655,9 +662,10 @@ _ch_mark_node(u3_ch_node* han_u, c3_w lef_w)
/* u3_ch_mark(): mark hashtable for gc.
*/
void
u3_ch_mark(u3_ch_root* har_u)
u3_ch_mark(u3p(u3_ch_root) har_p)
{
c3_w i_w;
u3_ch_root* har_u = u3to(u3_ch_root, har_p);
c3_w i_w;
for ( i_w = 0; i_w < 64; i_w++ ) {
c3_w sot_w = har_u->sot_w[i_w];

22
g/j.c
View File

@ -294,7 +294,7 @@ _cj_warm_fend(u3_noun bat)
u3_cs_road* rod_u = u3R;
while ( 1 ) {
u3_weak jaw = u3_ch_gut(rod_u->jed.har_u, bat);
u3_weak jaw = u3_ch_gut(rod_u->jed.har_p, bat);
if ( u3_none != jaw ) {
return jaw;
@ -431,7 +431,7 @@ _cj_warm_ream_be(c3_l jax_l,
u3_noun bat,
u3_noun huc)
{
u3_ch_put(u3R->jed.har_u,
u3_ch_put(u3R->jed.har_p,
bat,
u3nq(jax_l,
u3k(pax),
@ -468,7 +468,7 @@ _cj_warm_ream_un(u3_noun soh)
u3_noun cax;
c3_l jax_l;
if ( u3_none != (cax = u3_ch_get(u3R->jed.har_u, u3h(u3h(sab)))) ) {
if ( u3_none != (cax = u3_ch_get(u3R->jed.har_p, u3h(u3h(sab)))) ) {
jax_l = u3h(cax);
u3z(cax);
}
@ -538,8 +538,8 @@ _cj_warm_ream(void)
void
u3_cj_ream(void)
{
u3_ch_free(u3R->jed.har_u);
u3R->jed.har_u = u3_ch_new();
u3_ch_free(u3R->jed.har_p);
u3R->jed.har_p = u3_ch_new();
_cj_warm_ream();
}
@ -572,7 +572,7 @@ _cj_warm_mine(u3_noun clu, u3_noun cor)
c3_l jax_l = _cj_boil_mine(mop, cor);
// fprintf(stderr, "warm: bat %x\r\n", u3_cr_mug(bat));
u3_ch_put(u3R->jed.har_u,
u3_ch_put(u3R->jed.har_p,
bat,
u3nq(jax_l,
u3k(pax),
@ -611,7 +611,7 @@ _cj_find(u3_noun bat)
u3_cs_road* rod_u = u3R;
while ( 1 ) {
u3_weak jaw = u3_ch_gut(rod_u->jed.har_u, bat);
u3_weak jaw = u3_ch_gut(rod_u->jed.har_p, bat);
if ( u3_none != jaw ) {
u3_assure(u3_co_is_cat(u3h(jaw)));
@ -619,7 +619,7 @@ _cj_find(u3_noun bat)
#if 0
if ( rod_u != u3R ) {
fprintf(stderr, "got: %x in %p/%p, %d\r\n",
bat, rod_u, rod_u->jed.har_u, jax);
bat, rod_u, rod_u->jed.har_p, jax);
}
#endif
return (c3_l)u3h(jaw);
@ -975,7 +975,7 @@ _cj_warm_reap(u3_noun kev)
u3_ca_use(tab),
u3_cr_mug(xac));
#endif
u3_ch_put(u3R->jed.har_u, tab, xac);
u3_ch_put(u3R->jed.har_p, tab, xac);
u3z(tab);
}
}
@ -983,8 +983,8 @@ _cj_warm_reap(u3_noun kev)
/* u3_cj_reap(): promote jet state. RETAINS.
*/
void
u3_cj_reap(u3_noun das, u3_ch_root* har_u)
u3_cj_reap(u3_noun das, u3p(u3_ch_root) har_p)
{
_cj_cold_reap_in(u3t(das));
u3_ch_walk(har_u, _cj_warm_reap);
u3_ch_walk(har_p, _cj_warm_reap);
}

90
g/m.c
View File

@ -117,8 +117,8 @@ static void
_cm_signal_reset(void)
{
u3R = &u3H->rod_u;
u3R->cap_w = u3R->mat_w;
u3R->ear_w = 0;
u3R->cap_p = u3R->mat_p;
u3R->ear_p = 0;
u3R->kid_u = 0;
}
@ -305,11 +305,11 @@ _boot_north(c3_w* mem_w, c3_w siz_w, c3_w len_w)
// memset(mem_w, 0, 4 * len_w); // enable in case of corruption
memset(rod_u, 0, 4 * siz_w);
rod_u->rut_w = rut_w;
rod_u->hat_w = hat_w;
rod_u->rut_p = u3of(c3_w, rut_w);
rod_u->hat_p = u3of(c3_w, hat_w);
rod_u->mat_w = mat_w;
rod_u->cap_w = cap_w;
rod_u->mat_p = u3of(c3_w, mat_w);
rod_u->cap_p = u3of(c3_w, cap_w);
return rod_u;
}
@ -328,12 +328,12 @@ _boot_south(c3_w* mem_w, c3_w siz_w, c3_w len_w)
// memset(mem_w, 0, 4 * len_w); // enable in case of corruption
memset(rod_u, 0, 4 * siz_w);
rod_u->rut_w = rut_w;
rod_u->hat_w = hat_w;
rod_u->rut_p = u3of(c3_w, rut_w);
rod_u->hat_p = u3of(c3_w, hat_w);
rod_u->mat_p = u3of(c3_w, mat_w);
rod_u->cap_p = u3of(c3_w, cap_w);
rod_u->mat_w = mat_w;
rod_u->cap_w = cap_w;
return rod_u;
}
@ -342,8 +342,8 @@ _boot_south(c3_w* mem_w, c3_w siz_w, c3_w len_w)
static void
_boot_parts(void)
{
u3R->cax.har_u = u3_ch_new();
u3R->jed.har_u = u3_ch_new();
u3R->cax.har_p = u3_ch_new();
u3R->jed.har_p = u3_ch_new();
u3R->jed.das = u3nc(u3_nul, u3_nul);
}
@ -352,14 +352,14 @@ _boot_parts(void)
void
u3_cm_mark(void)
{
u3_ch_mark(u3R->jed.har_u);
u3_ch_mark(u3R->jed.har_p);
u3_ca_mark_noun(u3R->jed.das);
u3_ca_mark_noun(u3R->ski.flu);
u3_ca_mark_noun(u3R->bug.tax);
u3_ca_mark_noun(u3R->bug.mer);
u3_ca_mark_noun(u3R->pro.don);
u3_ca_mark_noun(u3R->pro.day);
u3_ch_mark(u3R->cax.har_u);
u3_ch_mark(u3R->cax.har_p);
}
/* u3_cm_boot(): instantiate or activate image.
@ -392,8 +392,8 @@ u3_cm_boot(c3_o nuu_o, c3_o bug_o)
void
u3_cm_clear(void)
{
u3_ch_free(u3R->cax.har_u);
u3_ch_free(u3R->jed.har_u);
u3_ch_free(u3R->cax.har_p);
u3_ch_free(u3R->jed.har_p);
u3_ca_lose(u3R->jed.das);
}
@ -572,29 +572,29 @@ u3_cm_leap(c3_w pad_w)
/* Allocate a region on the cap.
*/
{
c3_w* bot_w;
u3p(c3_w) bot_p;
if ( u3_yes == u3_co_is_north(u3R) ) {
bot_w = (u3R->cap_w - len_w);
u3R->cap_w -= len_w;
bot_p = (u3R->cap_p - len_w);
u3R->cap_p -= len_w;
rod_u = _boot_south(bot_w, c3_wiseof(u3_cs_road), len_w);
rod_u = _boot_south(u3_co_into(bot_p), c3_wiseof(u3_cs_road), len_w);
#if 0
fprintf(stderr, "leap: from north %p (cap %p), to south %p\r\n",
fprintf(stderr, "leap: from north %p (cap %x), to south %p\r\n",
u3R,
u3R->cap_w + len_w,
u3R->cap_p + len_p,
rod_u);
#endif
}
else {
bot_w = u3R->cap_w;
u3R->cap_w += len_w;
bot_p = u3R->cap_p;
u3R->cap_p += len_w;
rod_u = _boot_north(bot_w, c3_wiseof(u3_cs_road), len_w);
rod_u = _boot_north(u3_co_into(bot_p), c3_wiseof(u3_cs_road), len_w);
#if 0
fprintf(stderr, "leap: from north %p (cap %p), to south %p\r\n",
u3R,
u3R->cap_w - len_w,
u3R->cap_p - len_p,
rod_u);
#endif
}
@ -638,7 +638,7 @@ u3_cm_fall()
/* The new cap is the old hat - it's as simple as that.
*/
u3R->par_u->cap_w = u3R->hat_w;
u3R->par_u->cap_p = u3R->hat_p;
/* And, we're back home.
*/
@ -651,9 +651,9 @@ u3_cm_fall()
void
u3_cm_hate(c3_w pad_w)
{
c3_assert(0 == u3R->ear_w);
c3_assert(0 == u3R->ear_p);
u3R->ear_w = u3R->cap_w;
u3R->ear_p = u3R->cap_p;
u3_cm_leap(pad_w);
}
@ -662,35 +662,35 @@ u3_cm_hate(c3_w pad_w)
u3_noun
u3_cm_love(u3_noun pro)
{
u3_noun das = u3R->jed.das;
u3_ch_root* har_u = u3R->jed.har_u;
u3_noun das = u3R->jed.das;
u3p(u3_ch_root) har_p = u3R->jed.har_p;
u3_cm_fall();
pro = u3_ca_take(pro);
u3_cj_reap(das, har_u);
u3_cj_reap(das, har_p);
u3R->cap_w = u3R->ear_w;
u3R->ear_w = 0;
u3R->cap_p = u3R->ear_p;
u3R->ear_p = 0;
return pro;
}
/* u3_cm_golf(): record cap_w length for u3_flog().
/* u3_cm_golf(): record cap_p length for u3_flog().
*/
c3_w
u3_cm_golf(void)
{
if ( u3_yes == u3_co_is_north(u3R) ) {
return u3R->mat_w - u3R->cap_w;
return u3R->mat_p - u3R->cap_p;
}
else {
return u3R->cap_w - u3R->mat_w;
return u3R->cap_p - u3R->mat_p;
}
}
/* u3_cm_flog(): reset cap_w.
/* u3_cm_flog(): reset cap_p.
*/
void
u3_cm_flog(c3_w gof_w)
@ -698,18 +698,18 @@ u3_cm_flog(c3_w gof_w)
// Enable memsets in case of memory corruption.
//
if ( u3_yes == u3_co_is_north(u3R) ) {
c3_w* bot_w = (u3R->mat_w - gof_w);
u3_post bot_p = (u3R->mat_p - gof_w);
// c3_w len_w = (bot_w - u3R->cap_w);
// memset(u3R->cap_w, 0, 4 * len_w);
u3R->cap_w = bot_w;
u3R->cap_p = bot_p;
}
else {
c3_w* bot_w = u3R->mat_w + gof_w;
u3_post bot_p = u3R->mat_p + gof_w;
// c3_w len_w = (u3R->cap_w - bot_w);
// memset(bot_w, 0, 4 * len_w); //
u3R->cap_w = bot_w;
u3R->cap_p = bot_p;
}
}
@ -720,8 +720,8 @@ u3_cm_water(c3_w* low_w, c3_w* hig_w)
{
c3_assert(u3R == &u3H->rod_u);
*low_w = (u3H->rod_u.hat_w - u3H->rod_u.rut_w);
*hig_w = (u3H->rod_u.mat_w - u3H->rod_u.cap_w) + c3_wiseof(u3_cs_home);
*low_w = (u3H->rod_u.hat_p - u3H->rod_u.rut_p);
*hig_w = (u3H->rod_u.mat_p - u3H->rod_u.cap_p) + c3_wiseof(u3_cs_home);
}
/* u3_cm_soft_top(): top-level safety wrapper.

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);
}

20
g/z.c
View File

@ -12,7 +12,7 @@ u3_cz_find(u3_mote fun, u3_noun one)
u3_noun key = u3nc(fun, u3k(one));
u3_noun val;
val = u3_ch_get(u3R->cax.har_u, key);
val = u3_ch_get(u3R->cax.har_p, key);
u3z(key);
return val;
}
@ -22,7 +22,7 @@ u3_cz_find_2(u3_mote fun, u3_noun one, u3_noun two)
u3_noun key = u3nt(fun, u3k(one), u3k(two));
u3_noun val;
val = u3_ch_get(u3R->cax.har_u, key);
val = u3_ch_get(u3R->cax.har_p, key);
u3z(key);
return val;
}
@ -32,7 +32,7 @@ u3_cz_find_3(u3_mote fun, u3_noun one, u3_noun two, u3_noun tri)
u3_noun key = u3nq(fun, u3k(one), u3k(two), u3k(tri));
u3_noun val;
val = u3_ch_get(u3R->cax.har_u, key);
val = u3_ch_get(u3R->cax.har_p, key);
u3z(key);
return val;
}
@ -42,7 +42,7 @@ u3_cz_find_4(u3_mote fun, u3_noun one, u3_noun two, u3_noun tri, u3_noun qua)
u3_noun key = u3nc(fun, u3nq(u3k(one), u3k(two), u3k(tri), u3k(qua)));
u3_noun val;
val = u3_ch_get(u3R->cax.har_u, key);
val = u3_ch_get(u3R->cax.har_p, key);
u3z(key);
return val;
}
@ -54,7 +54,7 @@ u3_cz_save(u3_mote fun, u3_noun one, u3_noun val)
{
u3_noun key = u3nc(fun, u3k(one));
u3_ch_put(u3R->cax.har_u, key, u3k(val));
u3_ch_put(u3R->cax.har_p, key, u3k(val));
u3z(key);
return val;
}
@ -63,7 +63,7 @@ u3_cz_save_2(u3_mote fun, u3_noun one, u3_noun two, u3_noun val)
{
u3_noun key = u3nt(fun, u3k(one), u3k(two));
u3_ch_put(u3R->cax.har_u, key, u3k(val));
u3_ch_put(u3R->cax.har_p, key, u3k(val));
u3z(key);
return val;
}
@ -72,7 +72,7 @@ u3_cz_save_3(u3_mote fun, u3_noun one, u3_noun two, u3_noun tri, u3_noun val)
{
u3_noun key = u3nq(fun, u3k(one), u3k(two), u3k(tri));
u3_ch_put(u3R->cax.har_u, key, u3k(val));
u3_ch_put(u3R->cax.har_p, key, u3k(val));
u3z(key);
return val;
}
@ -86,7 +86,7 @@ u3_cz_save_4(u3_mote fun,
{
u3_noun key = u3nc(fun, u3nq(u3k(one), u3k(two), u3k(tri), u3k(qua)));
u3_ch_put(u3R->cax.har_u, key, u3k(val));
u3_ch_put(u3R->cax.har_p, key, u3k(val));
u3z(key);
return val;
}
@ -97,13 +97,13 @@ u3_noun
u3_cz_uniq(u3_noun som)
{
u3_noun key = u3nc(c3__uniq, u3k(som));
u3_noun val = u3_ch_get(u3R->cax.har_u, key);
u3_noun val = u3_ch_get(u3R->cax.har_p, key);
if ( u3_none != val ) {
u3z(key); u3z(som); return val;
}
else {
u3_ch_put(u3R->cax.har_u, key, u3k(som));
u3_ch_put(u3R->cax.har_p, key, u3k(som));
return som;
}
}

View File

@ -8,7 +8,7 @@
**/
/* u3_ch_new(): create hashtable.
*/
u3_ch_root*
u3p(u3_ch_root)
u3_ch_new(void);
/* u3_ch_put(): insert in hashtable.
@ -16,33 +16,33 @@
** `key` is RETAINED; `val` is transferred.
*/
void
u3_ch_put(u3_ch_root* har_u, u3_noun key, u3_noun val);
u3_ch_put(u3p(u3_ch_root) har_p, u3_noun key, u3_noun val);
/* u3_ch_get(): read from hashtable.
**
** `key` is RETAINED.
*/
u3_weak
u3_ch_get(u3_ch_root* har_u, u3_noun key);
u3_ch_get(u3p(u3_ch_root) har_p, u3_noun key);
/* u3_ch_gut(): read from hashtable, unifying key nouns.
**
** `key` is RETAINED.
*/
u3_weak
u3_ch_gut(u3_ch_root* har_u, u3_noun key);
u3_ch_gut(u3p(u3_ch_root) har_p, u3_noun key);
/* u3_ch_free(): free hashtable.
*/
void
u3_ch_free(u3_ch_root* har_u);
u3_ch_free(u3p(u3_ch_root) har_p);
/* u3_ch_mark(): mark hashtable for gc.
*/
void
u3_ch_mark(u3_ch_root* har_u);
u3_ch_mark(u3p(u3_ch_root) har_p);
/* u3_ch_walk(): traverse hashtable with key, value fn; RETAINS.
*/
void
u3_ch_walk(u3_ch_root* har_u, void (*fun_f)(u3_noun));
u3_ch_walk(u3p(u3_ch_root) har_p, void (*fun_f)(u3_noun));

View File

@ -66,4 +66,4 @@
/* u3_cj_reap(): promote jet state. RETAINS.
*/
void
u3_cj_reap(u3_noun das, u3_ch_root* har_u);
u3_cj_reap(u3_noun das, u3p(u3_ch_root) har_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

@ -125,11 +125,11 @@
struct _u3_cs_road* nex_u; // sibling road
struct _u3_cs_road* now_u; // current road pointer
c3_w* cap_w; // top of transient region
c3_w* hat_w; // top of durable region
c3_w* mat_w; // bottom of transient region
c3_w* rut_w; // bottom of durable region
c3_w* ear_w; // original cap if kid is live
u3p(c3_w) cap_p; // top of transient region
u3p(c3_w) hat_p; // top of durable region
u3p(c3_w) mat_p; // bottom of transient region
u3p(c3_w) rut_p; // bottom of durable region
u3p(c3_w) ear_p; // original cap if kid is live
c3_w fut_w[32]; // futureproof buffer
@ -150,8 +150,8 @@
} all;
struct { // jet dashboard
u3_ch_root* har_u; // jet index (old style)
u3_noun das; // dashboard (new style)
u3p(u3_ch_root) har_p; // jet index (old style)
u3_noun das; // dashboard (new style)
} jed;
struct { // namespace
@ -170,7 +170,7 @@
} pro;
struct { // memoization
u3_ch_root* har_u; // (map (pair term noun) noun)
u3p(u3_ch_root) har_p; // (map (pair term noun) noun)
} cax;
} u3_cs_road;
typedef u3_cs_road u3_road;
@ -192,32 +192,32 @@
# define u3to(type, x) ((type *) u3_co_into(x))
# define u3of(type, x) (u3_co_outa((type *)x))
# define u3_co_is_north(r) ((r->cap_w > r->hat_w) ? u3_yes : u3_no)
# define u3_co_is_north(r) ((r->cap_p > r->hat_p) ? u3_yes : u3_no)
# define u3_co_is_south(r) ((u3_so(u3_co_is_north(r))) ? u3_no : u3_yes)
# define u3_co_open(r) ( (u3_yes == u3_co_is_north(r)) \
? (c3_w)(r->cap_w - r->hat_w) \
: (c3_w)(r->hat_w - r->cap_w) )
? (c3_w)(r->cap_p - r->hat_p) \
: (c3_w)(r->hat_p - r->cap_p) )
# define u3_co_north_is_senior(r, dog) \
u3_say((u3_co_to_wtr(dog) < r->rut_w) || \
(u3_co_to_wtr(dog) >= r->mat_w))
u3_say((u3_co_to_off(dog) < r->rut_p) || \
(u3_co_to_off(dog) >= r->mat_p))
# define u3_co_north_is_junior(r, dog) \
u3_say((u3_co_to_wtr(dog) >= r->cap_w) && \
(u3_co_to_wtr(dog) < r->mat_w))
u3_say((u3_co_to_off(dog) >= r->cap_p) && \
(u3_co_to_off(dog) < r->mat_p))
# define u3_co_north_is_normal(r, dog) \
u3_and(u3_not(u3_co_north_is_senior(r, dog)), \
u3_not(u3_co_north_is_junior(r, dog)))
# define u3_co_south_is_senior(r, dog) \
u3_say((u3_co_to_wtr(dog) < r->mat_w) || \
(u3_co_to_wtr(dog) >= r->rut_w))
u3_say((u3_co_to_off(dog) < r->mat_p) || \
(u3_co_to_off(dog) >= r->rut_p))
# define u3_co_south_is_junior(r, dog) \
u3_say((u3_co_to_wtr(dog) < r->cap_w) && \
(u3_co_to_wtr(dog) >= r->mat_w))
u3_say((u3_co_to_off(dog) < r->cap_p) && \
(u3_co_to_off(dog) >= r->mat_p))
# define u3_co_south_is_normal(r, dog) \
u3_and(u3_not(u3_co_south_is_senior(r, dog)), \

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

@ -8,10 +8,10 @@
/* functions
*/
static u3_noun
_jam_in(u3_ch_root* har_u, u3_atom, u3_atom, u3_noun);
_jam_in(u3p(u3_ch_root) har_p, u3_atom, u3_atom, u3_noun);
static u3_noun
_jam_in_pair(u3_ch_root* har_u,
_jam_in_pair(u3p(u3_ch_root) har_p,
u3_atom h_a,
u3_atom t_a,
u3_atom b,
@ -19,14 +19,14 @@
{
u3_noun w = u3nc(u3nc(2, 1), u3k(l));
u3_noun x = u3_cqa_add(2, b);
u3_noun d = _jam_in(har_u, h_a, x, w);
u3_noun d = _jam_in(har_p, h_a, x, w);
u3_noun p_d, q_d, r_d;
u3_noun r;
u3_cr_trel(d, &p_d, &q_d, &r_d);
{
u3_noun y = u3_cqa_add(x, p_d);
u3_noun e = _jam_in(har_u, t_a, y, q_d);
u3_noun e = _jam_in(har_p, t_a, y, q_d);
u3_noun p_e, q_e, r_e;
u3_cr_trel(e, &p_e, &q_e, &r_e);
@ -48,7 +48,7 @@
}
static u3_noun
_jam_in_flat(u3_ch_root* har_u,
_jam_in_flat(u3p(u3_ch_root) har_p,
u3_atom a,
u3_noun l)
{
@ -63,7 +63,7 @@
}
static u3_noun
_jam_in_ptr(u3_ch_root* har_u,
_jam_in_ptr(u3p(u3_ch_root) har_p,
u3_atom u_c,
u3_noun l)
{
@ -80,29 +80,29 @@
}
static u3_noun
_jam_in(u3_ch_root* har_u,
_jam_in(u3p(u3_ch_root) har_p,
u3_noun a,
u3_atom b,
u3_noun l)
{
u3_noun c = u3_ch_get(har_u, a);
u3_noun c = u3_ch_get(har_p, a);
u3_noun x;
if ( u3_none == c ) {
u3_ch_put(har_u, a, u3k(b));
u3_ch_put(har_p, a, u3k(b));
if ( u3_yes == u3ud(a) ) {
x = _jam_in_flat(har_u, a, l);
x = _jam_in_flat(har_p, a, l);
} else {
x = _jam_in_pair(har_u, u3h(a), u3t(a), b, l);
x = _jam_in_pair(har_p, u3h(a), u3t(a), b, l);
}
}
else {
if ( u3_yes == u3ud(a) && u3_cr_met(0, a) <= u3_cr_met(0, c) ) {
x = _jam_in_flat(har_u, a, l);
x = _jam_in_flat(har_p, a, l);
}
else {
x = _jam_in_ptr(har_u, c, l);
x = _jam_in_ptr(har_p, c, l);
}
}
return x;
@ -111,15 +111,15 @@
u3_noun
u3_cqe_jam(u3_atom a)
{
u3_ch_root* har_u = u3_ch_new();
u3p(u3_ch_root) har_p = u3_ch_new();
u3_noun x = _jam_in(har_u, a, 0, u3_nul);
u3_noun x = _jam_in(har_p, a, 0, u3_nul);
u3_noun q = u3_cqb_flop(u3h(u3t(x)));
u3_noun r = u3_cqc_can(0, q);
u3z(x);
u3z(q);
u3_ch_free(har_u);
u3_ch_free(har_p);
return r;
}
u3_noun

View File

@ -4,7 +4,6 @@
*/
#include "all.h"
u3_noun
u3_cwe_mule(u3_noun cor)
{
@ -20,6 +19,6 @@
* C/Nock level, is identical to what a typed mule would produce,
* without running the formula twice.
*/
return u3_cn_slam_on(hok, u3k(tap));;
return u3_cn_slam_on(hok, u3k(tap));
}
}

View File

@ -116,19 +116,23 @@
}
_open_do_p(tssg) // =~
{
u3_noun tp_gen = u3t(p_gen);
u3_noun ip_gen = u3h(p_gen);
if ( u3_ne(u3du(p_gen)) ) {
return u3nc(0, 1);
} else {
u3_noun tp_gen = u3t(p_gen);
u3_noun ip_gen = u3h(p_gen);
if ( (u3_nul == p_gen) ) {
return u3nc(u3_blip, 1);
}
else if ( (u3_nul == tp_gen) ) {
return u3k(ip_gen);
}
else {
return u3nt(c3__tsgr,
u3k(ip_gen),
_open_in_tssg(ter, tp_gen));
if ( (u3_nul == p_gen) ) {
return u3nc(u3_blip, 1);
}
else if ( (u3_nul == tp_gen) ) {
return u3k(ip_gen);
}
else {
return u3nt(c3__tsgr,
u3k(ip_gen),
_open_in_tssg(ter, tp_gen));
}
}
}
/***

View File

@ -1621,16 +1621,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);
}
@ -1689,7 +1692,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);
@ -1697,28 +1700,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);
}
@ -1762,8 +1764,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;
@ -1780,14 +1784,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;