From 3ae323e43e4be43ff1bd4c8852b49dae6f4f32d2 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Dec 2018 13:39:32 -0500 Subject: [PATCH 01/27] updates subprojects to not install static libs and headers --- subprojects/argon2 | 2 +- subprojects/ed25519 | 2 +- subprojects/libh2o | 2 +- subprojects/libscrypt | 2 +- subprojects/libsni | 2 +- subprojects/libuv | 2 +- subprojects/murmur3 | 2 +- subprojects/secp256k1 | 2 +- subprojects/softfloat3 | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/subprojects/argon2 b/subprojects/argon2 index 6e7d7e3a92..4da94a611e 160000 --- a/subprojects/argon2 +++ b/subprojects/argon2 @@ -1 +1 @@ -Subproject commit 6e7d7e3a92361f11942f0c743d154ab426d1530e +Subproject commit 4da94a611ee62bad87ab2b131ffda3bcc0723d9c diff --git a/subprojects/ed25519 b/subprojects/ed25519 index ba4777acac..76385f2ebb 160000 --- a/subprojects/ed25519 +++ b/subprojects/ed25519 @@ -1 +1 @@ -Subproject commit ba4777acac5694925ab78f38577b059cd4a3e8e6 +Subproject commit 76385f2ebbbc9580a9c236952d68d11d73a6135c diff --git a/subprojects/libh2o b/subprojects/libh2o index 41958a8aed..3b1f53c86b 160000 --- a/subprojects/libh2o +++ b/subprojects/libh2o @@ -1 +1 @@ -Subproject commit 41958a8aedb3aa2a85332bc8ac0ac389aa725a09 +Subproject commit 3b1f53c86b71f6fdc099b3b378de6f379b4b8412 diff --git a/subprojects/libscrypt b/subprojects/libscrypt index 4ebe362f39..029693ff1c 160000 --- a/subprojects/libscrypt +++ b/subprojects/libscrypt @@ -1 +1 @@ -Subproject commit 4ebe362f390025e5448e9fcf777c1f38630bc011 +Subproject commit 029693ff1cbe4f69d3a2da87d0f4f034f92cc0c2 diff --git a/subprojects/libsni b/subprojects/libsni index a59901c38a..173beb88ee 160000 --- a/subprojects/libsni +++ b/subprojects/libsni @@ -1 +1 @@ -Subproject commit a59901c38a67660039ee93a6170a338634d76ec0 +Subproject commit 173beb88ee62bddd13874ca04ab338cdec704928 diff --git a/subprojects/libuv b/subprojects/libuv index 9e3aece814..0c3a346a60 160000 --- a/subprojects/libuv +++ b/subprojects/libuv @@ -1 +1 @@ -Subproject commit 9e3aece8147d28246c57b84731dad26130c7d1c1 +Subproject commit 0c3a346a60f0b3bb42445b2c63198a6e0f94c89b diff --git a/subprojects/murmur3 b/subprojects/murmur3 index 001378cbe3..71a75d57ca 160000 --- a/subprojects/murmur3 +++ b/subprojects/murmur3 @@ -1 +1 @@ -Subproject commit 001378cbe3681af1137553ed7220c79273850d6a +Subproject commit 71a75d57ca4e7ca0f7fc2fd84abd93595b0624ca diff --git a/subprojects/secp256k1 b/subprojects/secp256k1 index 9989e23ce8..66a72cf208 160000 --- a/subprojects/secp256k1 +++ b/subprojects/secp256k1 @@ -1 +1 @@ -Subproject commit 9989e23ce8a02a51a1f90a2d5e391ba7d16bef39 +Subproject commit 66a72cf2084799d0799874d4fa3c530a73713d81 diff --git a/subprojects/softfloat3 b/subprojects/softfloat3 index 9d4342099a..ec4c7e31b3 160000 --- a/subprojects/softfloat3 +++ b/subprojects/softfloat3 @@ -1 +1 @@ -Subproject commit 9d4342099a54cefc3a4117ce0d0c71cff4e48783 +Subproject commit ec4c7e31b32e07aad80e52f65ff46ac6d6aad986 From 626638810904fad9501e442b319f25c70d572b6a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Dec 2018 16:03:37 -0500 Subject: [PATCH 02/27] removes commonmark and the markdown jet --- .gitmodules | 3 - include/jets/w.h | 4 - include/jets/y.h | 4 - jets/g/down.c | 220 ---------------------------------- jets/tree.c | 13 +- meson.build | 9 +- subprojects/commonmark-legacy | 1 - 7 files changed, 3 insertions(+), 251 deletions(-) delete mode 100644 jets/g/down.c delete mode 160000 subprojects/commonmark-legacy diff --git a/.gitmodules b/.gitmodules index 54f5235117..83769058b1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "subprojects/softfloat3"] path = subprojects/softfloat3 url = https://github.com/urbit/berkeley-softfloat-3.git -[submodule "subprojects/commonmark-legacy"] - path = subprojects/commonmark-legacy - url = https://github.com/urbit/commonmark-legacy.git [submodule "subprojects/ed25519"] path = subprojects/ed25519 url = https://github.com/urbit/ed25519.git diff --git a/include/jets/w.h b/include/jets/w.h index d8b5d8017e..dae4c80eeb 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -289,7 +289,3 @@ u3_noun u3wfu_snub(u3_noun); u3_noun u3wfu_toss(u3_noun); u3_noun u3wfu_wrap(u3_noun); - - /** Tier 7. - **/ - u3_noun u3wg_down(u3_noun); diff --git a/include/jets/y.h b/include/jets/y.h index f106e2b3dc..58b2595512 100644 --- a/include/jets/y.h +++ b/include/jets/y.h @@ -327,7 +327,3 @@ u3_noun u3wzu_snub(u3_noun); u3_noun u3wzu_toss(u3_noun); u3_noun u3wzu_wrap(u3_noun); - - /** Tier 7. - **/ - u3_noun u3yg_down(u3_noun); diff --git a/jets/g/down.c b/jets/g/down.c deleted file mode 100644 index 5f80290fb6..0000000000 --- a/jets/g/down.c +++ /dev/null @@ -1,220 +0,0 @@ -/* j/g/down.c -** -*/ -#include "all.h" -#include -#include -#include - -static u3_noun node_to_noun(cmark_node * nod); - -static u3_noun list_elems_to_noun(cmark_node * nod) -{ - u3_noun elems = u3_nul; - - cmark_node * child; - for ( child = nod->last_child; child; child = child->prev ) { - elems = u3nc(node_to_noun(child),elems); - } - - return elems; -} - -static u3_noun document_to_noun(cmark_node * nod) -{ - return list_elems_to_noun(nod); -} - -static u3_noun block_quote_to_noun(cmark_node * nod) -{ - return u3nc(u3nc(c3__bloq,u3_nul),list_elems_to_noun(nod)); -} - -static u3_noun list_to_noun(cmark_node * nod) -{ - return - u3nc( - u3nt( - c3__list, - __(nod->as.list.tight), - (nod->as.list.list_type == CMARK_BULLET_LIST) - ? nod->as.list.bullet_char /* XX convert? */ - : u3nc(nod->as.list.start, - (nod->as.list.delimiter == CMARK_PERIOD_DELIM) - ? '.' - : ')')), - list_elems_to_noun(nod)); -} - -static u3_noun list_item_to_noun(cmark_node * nod) -{ - return u3nc(u3nc(c3__item,u3_nul),list_elems_to_noun(nod)); -} - -static u3_noun code_block_to_noun(cmark_node * nod) -{ - u3_atom str = u3i_string((c3_c *) nod->string_content.ptr); /* XX u3i_bytes */ - u3_noun res = - u3nt( - c3__code, - nod->as.code.fenced - ? u3nq( - u3_nul, - nod->as.code.fence_char, - nod->as.code.fence_length, - u3i_tape((c3_c *) nod->as.code.info.ptr) - ) - : u3_nul, - u3qe_lore(str)); - u3z(str); - return res; -} - -static u3_noun html_to_noun(cmark_node * nod) -{ - u3_atom str = u3i_string((c3_c *) nod->string_content.ptr); /* XX u3i_bytes */ - u3_noun res = u3nc(c3__html, u3qe_lore(str)); - u3z(str); - return res; -} - -static u3_noun paragraph_to_noun(cmark_node * nod) -{ - return u3nc(c3__para, list_elems_to_noun(nod)); -} - -static u3_noun header_to_noun(cmark_node * nod) -{ - /* see also nod->as.header.setext */ - return u3nt(c3__head, nod->as.header.level, list_elems_to_noun(nod)); -} - -static u3_noun hrule_to_noun(cmark_node * nod) -{ - return u3nc(c3__hrul, u3_nul); -} - -static u3_noun reference_def_to_noun(cmark_node * nod) -{ - return u3nc(c3__defn, u3_nul); -} - -static u3_noun text_to_noun(cmark_node * nod) -{ - return u3nc(u3_blip, u3i_tape((c3_c *) cmark_chunk_to_cstr(&nod->as.literal))); -} - -static u3_noun softbreak_to_noun(cmark_node * nod) // XXX -{ - return u3nt(0, 10, 0); -} - -static u3_noun linebreak_to_noun(cmark_node * nod) -{ - return u3nc(c3__line, u3_nul); -} - -static u3_noun inline_code_to_noun(cmark_node * nod) -{ - return u3nc(c3__code, u3i_tape((c3_c *) cmark_chunk_to_cstr(&nod->as.literal))); -} - -static u3_noun inline_html_to_noun(cmark_node * nod) // XXX -{ - return u3nc(c3__htmt, u3i_string((c3_c *) cmark_chunk_to_cstr(&nod->as.literal))); -} - -static u3_noun emph_to_noun(cmark_node * nod) -{ - return u3nc(u3nc(c3__emph, c3n), list_elems_to_noun(nod)); -} - -static u3_noun strong_to_noun(cmark_node * nod) -{ - return u3nc(u3nc(c3__emph, c3y), list_elems_to_noun(nod)); -} - -static u3_noun link_to_noun(cmark_node * nod) -{ - return u3nc(u3nt(c3__link, - nod->as.link.url - ? u3i_tape((c3_c *) nod->as.link.url) - : u3_nul, - nod->as.link.title - ? u3nc(u3_nul, u3i_tape((c3_c *) nod->as.link.title)) - : u3_nul), - list_elems_to_noun(nod)); -} - -static u3_noun image_to_noun(cmark_node * nod) -{ - return u3nc(u3nt(c3__blot, - u3i_tape((c3_c *) nod->as.link.url), - nod->as.link.title - ? u3nc(u3_nul, u3i_tape((c3_c *) nod->as.link.title)) - : u3_nul), - list_elems_to_noun(nod)); -} - -static u3_noun node_to_noun(cmark_node * nod) -{ - if (!nod) { - fprintf(stderr, "markdown null node"); - return u3m_bail(c3__fail); - } - switch ( nod->type ) { - /* Block */ - case CMARK_NODE_DOCUMENT: return document_to_noun(nod); - case CMARK_NODE_BLOCK_QUOTE: return block_quote_to_noun(nod); - case CMARK_NODE_LIST: return list_to_noun(nod); - case CMARK_NODE_LIST_ITEM: return list_item_to_noun(nod); - case CMARK_NODE_CODE_BLOCK: return code_block_to_noun(nod); - case CMARK_NODE_HTML: return html_to_noun(nod); - case CMARK_NODE_PARAGRAPH: return paragraph_to_noun(nod); - case CMARK_NODE_HEADER: return header_to_noun(nod); - case CMARK_NODE_HRULE: return hrule_to_noun(nod); - case CMARK_NODE_REFERENCE_DEF: return reference_def_to_noun(nod); - /* Inline */ - case CMARK_NODE_TEXT: return text_to_noun(nod); - case CMARK_NODE_SOFTBREAK: return softbreak_to_noun(nod); - case CMARK_NODE_LINEBREAK: return linebreak_to_noun(nod); - case CMARK_NODE_INLINE_CODE: return inline_code_to_noun(nod); - case CMARK_NODE_INLINE_HTML: return inline_html_to_noun(nod); - case CMARK_NODE_EMPH: return emph_to_noun(nod); - case CMARK_NODE_STRONG: return strong_to_noun(nod); - case CMARK_NODE_LINK: return link_to_noun(nod); - case CMARK_NODE_IMAGE: return image_to_noun(nod); - default: fprintf(stderr, "bad markdown parsing"); - return u3m_bail(c3__fail); - } -} - -/* functions -*/ - u3_noun - u3qg_down(u3_atom a) - { - c3_c *tex = u3r_string(a); - - /* XX better strlen */ - cmark_node * doc = cmark_parse_document(tex, strlen(tex)); - - u3_noun res = document_to_noun(doc); - - cmark_node_free(doc); - // free out, tex? - return res; - } - u3_noun - u3wg_down(u3_noun cor) - { - u3_noun a; - - if ( (u3_none == (a = u3r_at(u3x_sam, cor))) || - (c3n == u3ud(a)) ) - { - return u3m_bail(c3__exit); - } else { - return u3qg_down(a); - } - } diff --git a/jets/tree.c b/jets/tree.c index 254a7b4654..0bfe6cf7eb 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -81,15 +81,6 @@ static u3j_core _141_hex_aes_d[] = }; static c3_c* _141_hex_aes_ha[] = {0}; -static u3j_harm _141_hex_down_mark_a[] = {{".2", u3wg_down, c3y}, {}}; -static c3_c* _141_hex_down_mark_ha[] = {0}; - - static u3j_core _141_hex_down_d[] = - { { "mark", 7, _141_hex_down_mark_a, 0, _141_hex_down_mark_ha }, - {} - }; -static c3_c* _141_hex_down_ha[] = {0}; - static u3j_harm _141_hex_lore_a[] = {{".2", u3we_lore}, {}}; static c3_c* _141_hex_lore_ha[] = {0}; static u3j_harm _141_hex_loss_a[] = {{".2", u3we_loss}, {}}; @@ -181,9 +172,7 @@ static c3_c* _141_hex_ripe_ha[] = {0}; static u3j_core _141_hex_d[] = -{ { "down", 8063, 0, _141_hex_down_d, _141_hex_down_ha }, - - { "lore", 63, _141_hex_lore_a, 0, _141_hex_lore_ha }, +{ { "lore", 63, _141_hex_lore_a, 0, _141_hex_lore_ha }, { "loss", 63, _141_hex_loss_a, 0, _141_hex_loss_ha }, { "lune", 127, _141_hex_lune_a, 0, _141_hex_lune_ha }, diff --git a/meson.build b/meson.build index a4925d434f..d023d4adac 100644 --- a/meson.build +++ b/meson.build @@ -179,10 +179,6 @@ jets_f_ut_src = [ 'jets/f/ut_wrap.c' ] -jets_g_src = [ -'jets/g/down.c' -] - jets_src = [ 'jets/tree.c' ] @@ -192,7 +188,8 @@ jets_all_src = [ jets_c_src, jets_d_src, jets_e_src, jets_e_ed_src, jets_f_src, jets_f_ut_src, - jets_g_src, jets_src] + jets_src +] noun_src = [ 'noun/allocate.c', @@ -315,7 +312,6 @@ else endif # For these libs we provide fallback bundle -cmark_dep = dependency('libcmark', version: '0.12.0', fallback: ['commonmark-legacy', 'cmark_dep']) urbitscrypt_dep = dependency('libscrypt', version: '>=0.1.21', fallback: ['libscrypt', 'libscrypt_dep']) ed25519_dep = dependency('ed25519', version: '>=0.1.0', fallback: ['ed25519', 'ed25519_dep']) @@ -332,7 +328,6 @@ deps = [openssl_dep, curl_dep, libuv_dep, libh2o_dep, - cmark_dep, secp256k1_dep, gmp_dep, sigsegv_dep, diff --git a/subprojects/commonmark-legacy b/subprojects/commonmark-legacy deleted file mode 160000 index 8555ef14c4..0000000000 --- a/subprojects/commonmark-legacy +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8555ef14c4a503f57a0d192bb120159239f4322c From de7df542c91800503b72dd7453da13c4e1fc3a5b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Dec 2018 17:04:48 -0500 Subject: [PATCH 03/27] updates c3_assert() to print assertion/file/line before bail --- include/c/defs.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/c/defs.h b/include/c/defs.h index c0eb6e5701..74dfeeb339 100644 --- a/include/c/defs.h +++ b/include/c/defs.h @@ -17,8 +17,17 @@ **/ /* Assert. Good to capture. */ -// # define c3_assert(x) assert(x) -# define c3_assert(x) ( (x) ? 0 : c3_cooked(), assert(x) ) +# define c3_assert(x) \ + do { \ + if (!(x)) { \ + fprintf(stderr, \ + "\rAssertion '%s' failed " \ + "in %s:%d\n", \ + #x, __FILE__, __LINE__); \ + c3_cooked(); \ + assert(x); \ + } \ + } while(0) /* Stub. */ From 98604d04d0cc2da30901697d01e717e40ed6cee5 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Dec 2018 17:49:05 -0500 Subject: [PATCH 04/27] fix (my own) use-after-free in unix dir/file watch --- vere/unix.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vere/unix.c b/vere/unix.c index 5903d22000..7ee2f39182 100644 --- a/vere/unix.c +++ b/vere/unix.c @@ -590,7 +590,8 @@ _unix_watch_file(u3_ufil* fil_u, u3_udir* par_u, c3_c* pax_c) fil_u->dir = c3n; fil_u->dry = c3n; - fil_u->pax_c = pax_c; + fil_u->pax_c = c3_malloc(1 + strlen(pax_c)); + strcpy(fil_u->pax_c, pax_c); fil_u->par_u = par_u; fil_u->nex_u = NULL; fil_u->mug_w = 0; @@ -627,7 +628,8 @@ _unix_watch_dir(u3_udir* dir_u, u3_udir* par_u, c3_c* pax_c) dir_u->dir = c3y; dir_u->dry = c3n; - dir_u->pax_c = pax_c; + dir_u->pax_c = c3_malloc(1 + strlen(pax_c)); + strcpy(dir_u->pax_c, pax_c); dir_u->par_u = par_u; dir_u->nex_u = NULL; dir_u->kid_u = NULL; From fc2eaf1132181341e0386218e74bf06ecbbfe999 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Dec 2018 18:02:37 -0500 Subject: [PATCH 05/27] ensure file path is always freed --- vere/unix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vere/unix.c b/vere/unix.c index 7ee2f39182..0b5f9002f7 100644 --- a/vere/unix.c +++ b/vere/unix.c @@ -371,6 +371,8 @@ _unix_scan_mount_point(u3_umon* mon_u) _unix_watch_file(fil_u, &mon_u->dir_u, pax_c); } } + + free(pax_c); } } } From a2a6b7e810196c174237aef8c55acb6827df1323 Mon Sep 17 00:00:00 2001 From: Joseph Bryan Date: Sat, 24 Feb 2018 01:59:53 -0500 Subject: [PATCH 06/27] disables tracing exit printf when tracing is off --- noun/trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noun/trace.c b/noun/trace.c index af3b1a23d8..d2a9e9a0c3 100644 --- a/noun/trace.c +++ b/noun/trace.c @@ -531,10 +531,10 @@ u3t_print_steps(c3_c* cap_c, c3_d sep_d) void u3t_damp(void) { - fprintf(stderr, "\r\n"); - if ( 0 != u3R->pro.day ) { u3_noun wol = u3do("pi-tell", u3R->pro.day); + + fprintf(stderr, "\r\n"); u3_term_wall(wol); /* bunt a +doss From cf935baf0fb91cc0029e24834f22ae0e860d27d5 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Tue, 19 Dec 2017 05:11:55 -0800 Subject: [PATCH 07/27] Synchronous egg commitment --- vere/raft.c | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/vere/raft.c b/vere/raft.c index e14e065233..5e5de9ea23 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1622,35 +1622,6 @@ _raft_punk(u3_noun ovo) } -static void -_raft_comm(c3_d bid_d) -{ - u3p(u3v_cart) egg_p; - - u3_lo_open(); - - egg_p = u3A->ova.egg_p; - while ( egg_p ) { - u3v_cart* egg_u = u3to(u3v_cart, egg_p); - - if ( egg_u->ent_d <= bid_d ) { - egg_u->cit = c3y; - } else break; - - egg_p = egg_u->nex_p; - } - u3_lo_shut(c3y); -} - -static void -_raft_comm_cb(uv_timer_t* tim_u) -{ - u3_raft* raf_u = tim_u->data; - - _raft_comm(raf_u->ent_d); -} - - static c3_d _raft_push(u3_raft* raf_u, c3_w* bob_w, c3_w len_w) { @@ -1664,8 +1635,17 @@ _raft_push(u3_raft* raf_u, c3_w* bob_w, c3_w len_w) u3t_event_trace("Recording", 'e'); raf_u->lat_w = raf_u->tem_w; // XX - if ( !uv_is_active((uv_handle_t*)&raf_u->tim_u) ) { - uv_timer_start(&raf_u->tim_u, _raft_comm_cb, 0, 0); + u3p(u3v_cart) egg_p; + + egg_p = u3A->ova.egg_p; + while ( egg_p ) { + u3v_cart* egg_u = u3to(u3v_cart, egg_p); + + if ( egg_u->ent_d <= raf_u->ent_d ) { + egg_u->cit = c3y; + } else break; + + egg_p = egg_u->nex_p; } return raf_u->ent_d; From 43d18fd0a35b85efc7cd853787bbddcb6db7aa9a Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Tue, 19 Dec 2017 05:25:33 -0800 Subject: [PATCH 08/27] uncouple roe mutation --- vere/raft.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/vere/raft.c b/vere/raft.c index 5e5de9ea23..d86ec9104f 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1445,17 +1445,19 @@ u3_raft_init() /* _raft_sure(): apply and save an input ovum and its result. */ -static void +static u3_noun _raft_sure(u3_noun ovo, u3_noun vir, u3_noun cor) { // Whatever worked, save it. (XX - should be concurrent with execute.) // We'd like more events that don't change the state but need work here. { + u3_noun ret; + u3r_mug(cor); u3r_mug(u3A->roc); if ( c3n == u3r_sing(cor, u3A->roc) ) { - u3A->roe = u3nc(u3nc(vir, ovo), u3A->roe); + ret = u3nc(vir, ovo); u3z(u3A->roc); u3A->roc = cor; @@ -1464,19 +1466,21 @@ _raft_sure(u3_noun ovo, u3_noun vir, u3_noun cor) u3z(ovo); // push a new event into queue - u3A->roe = u3nc(u3nc(vir, u3_nul), u3A->roe); + ret = u3nc(vir, u3_nul); u3z(cor); } + return ret; } } /* _raft_lame(): handle an application failure. */ -static void +static u3_weak _raft_lame(u3_noun ovo, u3_noun why, u3_noun tan) { u3_noun bov, gon; + u3_noun ret; #if 0 { @@ -1509,10 +1513,12 @@ _raft_lame(u3_noun ovo, u3_noun why, u3_noun tan) gon = u3m_soft(0, u3v_poke, u3k(bov)); if ( u3_blip == u3h(gon) ) { - _raft_sure(bov, u3k(u3h(u3t(gon))), u3k(u3t(u3t(gon)))); + ret = _raft_sure(bov, u3k(u3h(u3t(gon))), u3k(u3t(u3t(gon)))); u3z(tan); u3z(gon); + + return ret; } else { u3z(gon); @@ -1522,9 +1528,11 @@ _raft_lame(u3_noun ovo, u3_noun why, u3_noun tan) u3_noun nog = u3m_soft(0, u3v_poke, u3k(vab)); if ( u3_blip == u3h(nog) ) { - _raft_sure(vab, u3k(u3h(u3t(nog))), u3k(u3t(u3t(nog)))); + ret = _raft_sure(vab, u3k(u3h(u3t(nog))), u3k(u3t(u3t(nog)))); u3z(tan); u3z(nog); + + return ret; } else { u3z(nog); @@ -1534,6 +1542,8 @@ _raft_lame(u3_noun ovo, u3_noun why, u3_noun tan) u3_lo_punt(2, u3kb_flop(u3k(tan))); uL(fprintf(uH, "crude: punted\n")); // c3_assert(!"crud"); + + return u3_nul; } } } @@ -1541,7 +1551,7 @@ _raft_lame(u3_noun ovo, u3_noun why, u3_noun tan) /* _raft_punk(): insert and apply an input ovum (unprotected). */ -static void +static u3_weak _raft_punk(u3_noun ovo) { #ifdef GHETTO @@ -1592,7 +1602,7 @@ _raft_punk(u3_noun ovo) u3_noun tan = u3k(u3t(gon)); u3z(gon); - _raft_lame(ovo, why, tan); + return _raft_lame(ovo, why, tan); } else { u3_noun vir = u3k(u3h(u3t(gon))); @@ -1607,14 +1617,14 @@ _raft_punk(u3_noun ovo) u3_noun tan = u3k(u3t(nug)); u3z(nug); - _raft_lame(ovo, why, tan); + return _raft_lame(ovo, why, tan); } else { vir = u3k(u3h(u3t(nug))); cor = u3k(u3t(u3t(nug))); u3z(nug); - _raft_sure(ovo, vir, cor); + return _raft_sure(ovo, vir, cor); } } // uL(fprintf(uH, "punk oot %s\n", txt_c)); @@ -1969,7 +1979,10 @@ u3_raft_work(void) } while ( u3_nul != ova ) { - _raft_punk(u3k(u3t(u3h(ova)))); + u3_noun sur = _raft_punk(u3k(u3t(u3h(ova)))); + if ( u3_nul != sur) { + u3A->roe = u3nc(sur, u3A->roe); + } c3_assert(u3_nul == u3h(u3h(ova))); nex = u3k(u3t(ova)); From 94cacc5629fbd64100ca3ac247d6d20a1d1f7897 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Tue, 19 Dec 2017 05:36:03 -0800 Subject: [PATCH 09/27] factored out _raft_crop() and _raft_poke() --- vere/raft.c | 122 +++++++++++++++++++++++++++++----------------------- 1 file changed, 69 insertions(+), 53 deletions(-) diff --git a/vere/raft.c b/vere/raft.c index d86ec9104f..fc7be85ede 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1922,6 +1922,69 @@ _raft_grab(u3_noun ova) int FOO; +/* _raft_crop(): Delete finished events. +*/ +static void +_raft_crop(void) +{ + while ( u3A->ova.egg_p ) { + u3p(u3v_cart) egg_p = u3A->ova.egg_p; + u3v_cart* egg_u = u3to(u3v_cart, u3A->ova.egg_p); + + if ( c3y == egg_u->did ) { + 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_p != 0); + u3A->ova.egg_p = egg_u->nex_p; + } + egg_u->cit = c3y; + u3a_free(egg_u); + } + else break; + } +} + + +/* _raft_poke(): Poke pending events, leaving the poked events + * and errors on u3A->roe. +*/ +static void +_raft_poke(void) +{ + u3_noun ova, nex; + + if ( 0 == u3Z->lug_u.len_d ) { + return; + } + ova = u3kb_flop(u3A->roe); + u3A->roe = u3_nul; + + u3_noun hed = (u3_nul == ova) ? u3_nul : u3h(ova); + + if ( u3_nul != hed ) { + u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3k(hed)), u3_nul)); + } + + while ( u3_nul != ova ) { + u3_noun sur = _raft_punk(u3k(u3t(u3h(ova)))); + if ( u3_nul != sur) { + u3A->roe = u3nc(sur, u3A->roe); + } + c3_assert(u3_nul == u3h(u3h(ova))); + + nex = u3k(u3t(ova)); + u3z(ova); ova = nex; + } + + if ( u3_nul != hed ) { + u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3_nul), u3_nul)); + } +} + + /* u3_raft_work(): work. */ void @@ -1936,63 +1999,13 @@ u3_raft_work(void) } } else { - u3_noun ova; - u3_noun vir; - u3_noun nex; - // Delete finished events. // - while ( u3A->ova.egg_p ) { - u3p(u3v_cart) egg_p = u3A->ova.egg_p; - u3v_cart* egg_u = u3to(u3v_cart, u3A->ova.egg_p); - - if ( c3y == egg_u->did ) { - vir = egg_u->vir; - - 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_p != 0); - u3A->ova.egg_p = egg_u->nex_p; - } - egg_u->cit = c3y; - u3a_free(egg_u); - } - else break; - } + _raft_crop(); // Poke pending events, leaving the poked events and errors on u3A->roe. // - { - if ( 0 == u3Z->lug_u.len_d ) { - return; - } - ova = u3kb_flop(u3A->roe); - u3A->roe = u3_nul; - - u3_noun hed = (u3_nul == ova) ? u3_nul : u3h(ova); - - if ( u3_nul != hed ) { - u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3k(hed)), u3_nul)); - } - - while ( u3_nul != ova ) { - u3_noun sur = _raft_punk(u3k(u3t(u3h(ova)))); - if ( u3_nul != sur) { - u3A->roe = u3nc(sur, u3A->roe); - } - c3_assert(u3_nul == u3h(u3h(ova))); - - nex = u3k(u3t(ova)); - u3z(ova); ova = nex; - } - - if ( u3_nul != hed ) { - u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3_nul), u3_nul)); - } - } + _raft_poke(); // Cartify, jam, and encrypt this batch of events. Take a number, Raft will // be with you shortly. @@ -2000,8 +2013,11 @@ u3_raft_work(void) c3_d bid_d; c3_w len_w; c3_w* bob_w; - u3_noun ron; + u3_noun ova; u3_noun ovo; + u3_noun vir; + u3_noun nex; + u3_noun ron; ova = u3kb_flop(u3A->roe); u3A->roe = u3_nul; From 0a66673134c7f66110d8dfa9d2c55d3b64e08c33 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Tue, 19 Dec 2017 05:44:07 -0800 Subject: [PATCH 10/27] factor out raft_pump() --- vere/raft.c | 83 +++++++++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/vere/raft.c b/vere/raft.c index fc7be85ede..5c20653d5a 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1985,6 +1985,51 @@ _raft_poke(void) } +/* _raft_pump(): Cartify, jam, and save an ovum, then perform its effects. +*/ +static void +_raft_pump(ovo, vir) +{ + u3v_cart* egg_u = u3a_malloc(sizeof(*egg_u)); + u3p(u3v_cart) egg_p = u3of(u3v_cart, egg_u); + u3_noun ron; + c3_d bid_d; + c3_w len_w; + c3_w* bob_w; + + egg_u->nex_p = 0; + egg_u->cit = c3n; + egg_u->did = c3n; + egg_u->vir = vir; + + ron = u3ke_jam(u3nc(u3k(u3A->now), ovo)); + c3_assert(u3A->key); + // don't encrypt for the moment, bootstrapping + // ron = u3dc("en:crua", u3k(u3A->key), ron); + + len_w = u3r_met(5, ron); + bob_w = c3_malloc(len_w * 4L); + u3r_words(0, len_w, bob_w, ron); + u3z(ron); + + bid_d = _raft_push(u3Z, bob_w, len_w); + egg_u->ent_d = bid_d; + + 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 == u3to(u3v_cart, u3A->ova.geg_p)->nex_p); + u3to(u3v_cart, u3A->ova.geg_p)->nex_p = egg_p; + u3A->ova.geg_p = egg_p; + } + _raft_kick_all(vir); + egg_u->did = c3y; + egg_u->vir = 0; +} + + /* u3_raft_work(): work. */ void @@ -2010,14 +2055,10 @@ u3_raft_work(void) // Cartify, jam, and encrypt this batch of events. Take a number, Raft will // be with you shortly. { - c3_d bid_d; - c3_w len_w; - c3_w* bob_w; u3_noun ova; u3_noun ovo; u3_noun vir; u3_noun nex; - u3_noun ron; ova = u3kb_flop(u3A->roe); u3A->roe = u3_nul; @@ -2029,39 +2070,7 @@ u3_raft_work(void) u3z(ova); ova = nex; if ( u3_nul != ovo ) { - u3v_cart* egg_u = u3a_malloc(sizeof(*egg_u)); - u3p(u3v_cart) egg_p = u3of(u3v_cart, egg_u); - - egg_u->nex_p = 0; - egg_u->cit = c3n; - egg_u->did = c3n; - egg_u->vir = vir; - - ron = u3ke_jam(u3nc(u3k(u3A->now), ovo)); - c3_assert(u3A->key); - // don't encrypt for the moment, bootstrapping - // ron = u3dc("en:crua", u3k(u3A->key), ron); - - len_w = u3r_met(5, ron); - bob_w = c3_malloc(len_w * 4L); - u3r_words(0, len_w, bob_w, ron); - u3z(ron); - - bid_d = _raft_push(u3Z, bob_w, len_w); - egg_u->ent_d = bid_d; - - 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 == u3to(u3v_cart, u3A->ova.geg_p)->nex_p); - u3to(u3v_cart, u3A->ova.geg_p)->nex_p = egg_p; - u3A->ova.geg_p = egg_p; - } - _raft_kick_all(vir); - egg_u->did = c3y; - egg_u->vir = 0; + _raft_pump(ovo, vir); _raft_grab(ova); } From 97408e42f490b4a933ba77de74749b49f17ff8f4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 11 Dec 2018 15:54:06 -0500 Subject: [PATCH 11/27] handles effect/event pairs singly while iterating queue --- vere/raft.c | 90 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/vere/raft.c b/vere/raft.c index 5c20653d5a..7e89aeeb93 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1476,7 +1476,7 @@ _raft_sure(u3_noun ovo, u3_noun vir, u3_noun cor) /* _raft_lame(): handle an application failure. */ -static u3_weak +static u3_noun _raft_lame(u3_noun ovo, u3_noun why, u3_noun tan) { u3_noun bov, gon; @@ -1551,7 +1551,7 @@ _raft_lame(u3_noun ovo, u3_noun why, u3_noun tan) /* _raft_punk(): insert and apply an input ovum (unprotected). */ -static u3_weak +static u3_noun _raft_punk(u3_noun ovo) { #ifdef GHETTO @@ -1631,7 +1631,8 @@ _raft_punk(u3_noun ovo) // free(txt_c); } - +/* _raft_push(): save an event +*/ static c3_d _raft_push(u3_raft* raf_u, c3_w* bob_w, c3_w len_w) { @@ -1947,6 +1948,26 @@ _raft_crop(void) } } +/* _raft_pop_roe(): pop the next [(list effects) event] pair of the queue +*/ +static u3_weak +_raft_pop_roe(void) +{ + if ( u3_nul == u3A->roe ) { + return u3_none; + } + + u3_noun ovo; + + { + u3_noun ova = u3kb_flop(u3A->roe); + u3A->roe = u3qb_flop(u3t(ova)); + ovo = u3k(u3h(ova)); + u3z(ova); + } + + return ovo; +} /* _raft_poke(): Poke pending events, leaving the poked events * and errors on u3A->roe. @@ -1954,41 +1975,44 @@ _raft_crop(void) static void _raft_poke(void) { - u3_noun ova, nex; - if ( 0 == u3Z->lug_u.len_d ) { return; } - ova = u3kb_flop(u3A->roe); - u3A->roe = u3_nul; - u3_noun hed = (u3_nul == ova) ? u3_nul : u3h(ova); + c3_o bee_o = c3n; + u3_noun oer = u3_nul; + u3_weak rus; - if ( u3_nul != hed ) { - u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3k(hed)), u3_nul)); - } + while ( u3_none != (rus = _raft_pop_roe()) ) { + u3_noun ovo, vir, sur; - while ( u3_nul != ova ) { - u3_noun sur = _raft_punk(u3k(u3t(u3h(ova)))); - if ( u3_nul != sur) { - u3A->roe = u3nc(sur, u3A->roe); + if ( c3n == bee_o ) { + u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3k(rus)), u3_nul)); + bee_o = c3y; } - c3_assert(u3_nul == u3h(u3h(ova))); - nex = u3k(u3t(ova)); - u3z(ova); ova = nex; + u3x_cell(rus, &vir, &ovo); + c3_assert( u3_nul == vir ); + + sur = _raft_punk(u3k(ovo)); + u3z(rus); + + if ( u3_nul != sur) { + oer = u3nc(sur, oer); + } } - if ( u3_nul != hed ) { + u3A->roe = oer; + + if ( c3y == bee_o ) { u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3_nul), u3_nul)); } } - /* _raft_pump(): Cartify, jam, and save an ovum, then perform its effects. */ static void -_raft_pump(ovo, vir) +_raft_pump(u3_noun ovo, u3_noun vir) { u3v_cart* egg_u = u3a_malloc(sizeof(*egg_u)); u3p(u3v_cart) egg_p = u3of(u3v_cart, egg_u); @@ -2029,7 +2053,6 @@ _raft_pump(ovo, vir) egg_u->vir = 0; } - /* u3_raft_work(): work. */ void @@ -2055,25 +2078,18 @@ u3_raft_work(void) // Cartify, jam, and encrypt this batch of events. Take a number, Raft will // be with you shortly. { - u3_noun ova; - u3_noun ovo; - u3_noun vir; - u3_noun nex; + u3_weak rus; - ova = u3kb_flop(u3A->roe); - u3A->roe = u3_nul; - - while ( u3_nul != ova ) { - ovo = u3k(u3t(u3h(ova))); - vir = u3k(u3h(u3h(ova))); - nex = u3k(u3t(ova)); - u3z(ova); ova = nex; + while ( u3_none != (rus = _raft_pop_roe()) ) { + u3_noun ovo, vir; + u3x_cell(rus, &vir, &ovo); if ( u3_nul != ovo ) { - _raft_pump(ovo, vir); - - _raft_grab(ova); + _raft_pump(u3k(ovo), u3k(vir)); + _raft_grab(u3A->roe); } + + u3z(rus); } } } From 6e77f2b2c1b62980ebcfc84a0ebb16657592a933 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Tue, 19 Dec 2017 06:37:10 -0800 Subject: [PATCH 12/27] synchronously processes each event singly --- vere/raft.c | 95 ++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/vere/raft.c b/vere/raft.c index 7e89aeeb93..3b4a005053 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1969,44 +1969,36 @@ _raft_pop_roe(void) return ovo; } -/* _raft_poke(): Poke pending events, leaving the poked events - * and errors on u3A->roe. +/* _raft_poke(): Peel one ovum off u3A->roe and poke Arvo with it. */ -static void +static u3_weak _raft_poke(void) { - if ( 0 == u3Z->lug_u.len_d ) { - return; - } - - c3_o bee_o = c3n; - u3_noun oer = u3_nul; u3_weak rus; - while ( u3_none != (rus = _raft_pop_roe()) ) { - u3_noun ovo, vir, sur; + // XX what is this condition? + // + if ( 0 == u3Z->lug_u.len_d ) { + fprintf(stderr, "_raft_poke ret early\r\n"); + return u3_none; + } - if ( c3n == bee_o ) { - u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3k(rus)), u3_nul)); - bee_o = c3y; - } + if ( u3_none != (rus = _raft_pop_roe()) ) { + u3_noun ovo, vir; + + u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3k(rus)), u3_nul)); u3x_cell(rus, &vir, &ovo); c3_assert( u3_nul == vir ); - - sur = _raft_punk(u3k(ovo)); + u3k(ovo); u3z(rus); - if ( u3_nul != sur) { - oer = u3nc(sur, oer); - } - } + rus = _raft_punk(ovo); - u3A->roe = oer; - - if ( c3y == bee_o ) { u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3_nul), u3_nul)); } + + return rus; } /* _raft_pump(): Cartify, jam, and save an ovum, then perform its effects. @@ -2053,7 +2045,32 @@ _raft_pump(u3_noun ovo, u3_noun vir) egg_u->vir = 0; } -/* u3_raft_work(): work. +/* u3_raft_chip(): chip one event off for processing. +*/ +void +u3_raft_chip(void) +{ + u3_weak rus = _raft_poke(); + + _raft_crop(); + + if ( u3_none != rus ) { + u3_noun ovo, vir; + u3x_cell(rus, &vir, &ovo); + + if ( u3_nul != ovo ) { + _raft_pump(u3k(ovo), u3k(vir)); + + // XX should be vir + // + _raft_grab(u3A->roe); + } + + u3z(rus); + } +} + +/* u3_raft_work(): work, either synchronously or asynchronously. */ void u3_raft_work(void) @@ -2067,30 +2084,12 @@ u3_raft_work(void) } } else { - // Delete finished events. + + // Cartify, jam, and encrypt this batch of events. + // Take a number, Raft will be with you shortly. // - _raft_crop(); - - // Poke pending events, leaving the poked events and errors on u3A->roe. - // - _raft_poke(); - - // Cartify, jam, and encrypt this batch of events. Take a number, Raft will - // be with you shortly. - { - u3_weak rus; - - while ( u3_none != (rus = _raft_pop_roe()) ) { - u3_noun ovo, vir; - u3x_cell(rus, &vir, &ovo); - - if ( u3_nul != ovo ) { - _raft_pump(u3k(ovo), u3k(vir)); - _raft_grab(u3A->roe); - } - - u3z(rus); - } + while ( u3_nul != u3A->roe ) { + u3_raft_chip(); } } } From d8b70683451ddfe25926ea6d368742118c2740b8 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Tue, 19 Dec 2017 07:22:02 -0800 Subject: [PATCH 13/27] updates u3_raft_work() to be async, adds sync u3_raft_play() --- include/vere/vere.h | 7 ++++++- vere/loop.c | 1 + vere/raft.c | 44 ++++++++++++++++++++++++++++---------------- vere/sist.c | 8 +++++--- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 9d81e4e830..fe54c6f3a1 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -1104,7 +1104,12 @@ void u3_raft_init(void); - /* u3_raft_work(): poke, kick, and push pending events. + /* u3_raft_play(): synchronously poke, kick, and push pending events. + */ + void + u3_raft_play(void); + + /* u3_raft_work(): asynchronously poke, kick, and push pending events. */ void u3_raft_work(void); diff --git a/vere/loop.c b/vere/loop.c index 59cc76f70a..a8f9a0bdd8 100644 --- a/vere/loop.c +++ b/vere/loop.c @@ -442,6 +442,7 @@ u3_lo_shut(c3_o inn) if ( c3n == u3_Host.liv ) { // direct save and die // + u3_raft_play(); // u3_lo_grab("lo_exit", u3_none); // u3_loom_save(u3A->ent_d); // u3_loom_exit(); diff --git a/vere/raft.c b/vere/raft.c index 3b4a005053..3149a22730 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -2070,26 +2070,38 @@ u3_raft_chip(void) } } -/* u3_raft_work(): work, either synchronously or asynchronously. +/* u3_raft_play(): synchronously process events. +*/ +void +u3_raft_play(void) +{ + c3_assert( u3Z->typ_e == u3_raty_lead ); + + u3_raft_chip(); + + if ( u3_nul != u3A->roe ) { + u3_raft_play(); + } +} + +/* _raft_work_cb(): callback to recurse into u3_raft_work(). +*/ +static void +_raft_work_cb(uv_timer_t* tim_u) +{ + u3_raft_work(); +} + +/* u3_raft_work(): asynchronously process events. */ void u3_raft_work(void) { - if ( u3Z->typ_e != u3_raty_lead ) { - c3_assert(u3A->ova.egg_p == 0); - if ( u3_nul != u3A->roe ) { - uL(fprintf(uH, "raft: dropping roe!!\n")); - u3z(u3A->roe); - u3A->roe = u3_nul; - } - } - else { + c3_assert( u3Z->typ_e == u3_raty_lead ); - // Cartify, jam, and encrypt this batch of events. - // Take a number, Raft will be with you shortly. - // - while ( u3_nul != u3A->roe ) { - u3_raft_chip(); - } + u3_raft_chip(); + + if ( u3_nul != u3A->roe ) { + uv_timer_start(&u3Z->tim_u, _raft_work_cb, 0, 0); } } diff --git a/vere/sist.c b/vere/sist.c index 75acb393aa..e14b5bdb1c 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -595,7 +595,8 @@ _sist_zest() } // Work through the boot events. - u3_raft_work(); + // + u3_raft_play(); } /* _sist_rest_nuu(): upgrade log from previous format. @@ -1223,8 +1224,9 @@ u3_sist_boot(void) u3C.wag_w |= u3o_hashless; } - // process pending events - u3_raft_work(); + // process pending events + // + u3_raft_play(); } else { u3_noun pig, who; From 594b059b620989f5cc3249ff0efc5d90aaa711b6 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Tue, 11 Dec 2018 14:26:57 -0800 Subject: [PATCH 14/27] set alarm for behn timers --- vere/behn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vere/behn.c b/vere/behn.c index e934d26201..bb1021dbbb 100644 --- a/vere/behn.c +++ b/vere/behn.c @@ -77,7 +77,8 @@ u3_behn_ef_doze(u3_noun wen) u3_noun now = u3_time_in_tv(&tim_tv); c3_d gap_d = u3_time_gap_ms(now, u3k(u3t(wen))); - + + teh_u->alm = c3y; uv_timer_start(&teh_u->tim_u, _behn_time_cb, gap_d, 0); } From d23e55356fa01a9901dde8da3f70cf4b62de7077 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 7 Jun 2018 22:53:43 -0400 Subject: [PATCH 15/27] updates ames to always allocate 2K bytes on read --- vere/ames.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vere/ames.c b/vere/ames.c index a28e21e192..ad9094a790 100644 --- a/vere/ames.c +++ b/vere/ames.c @@ -30,8 +30,11 @@ _ames_alloc(uv_handle_t* had_u, uv_buf_t* buf ) { - void* ptr_v = c3_malloc(len_i); - *buf = uv_buf_init(ptr_v, len_i); + // we allocate 2K, which gives us plenty of space + // for a single ames packet (max size 1060 bytes) + // + void* ptr_v = c3_malloc(2048); + *buf = uv_buf_init(ptr_v, 2048); } /* _ames_free(): contrasting free. From 2f24bb1d1bbca704600d07774fc10eaf936df0be Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 7 Jun 2018 22:54:17 -0400 Subject: [PATCH 16/27] updates terminal to always 32 bytes on read --- vere/term.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vere/term.c b/vere/term.c index 3e2acef453..2c768002b0 100644 --- a/vere/term.c +++ b/vere/term.c @@ -41,14 +41,19 @@ _term_msc_out_host() return 1000000ULL * tim_tv.tv_sec + tim_tv.tv_usec; } +/* _term_alloc(): libuv buffer allocator. +*/ static void _term_alloc(uv_handle_t* had_u, size_t len_i, uv_buf_t* buf ) { - void* ptr_v = c3_malloc(len_i); - *buf = uv_buf_init(ptr_v, len_i); + // this read can range from a single byte to a paste buffer + // 32 bytes has been chosen heuristically + // + void* ptr_v = c3_malloc(32); + *buf = uv_buf_init(ptr_v, 32); } From 302704bd227c3c13f5387c1230f3d0500fc86c0a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 11 Dec 2018 18:03:14 -0500 Subject: [PATCH 17/27] separates effects and persistence and always apply effects, even if the state didn't change --- vere/raft.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/vere/raft.c b/vere/raft.c index 3149a22730..6c2778a21a 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1456,6 +1456,9 @@ _raft_sure(u3_noun ovo, u3_noun vir, u3_noun cor) u3r_mug(cor); u3r_mug(u3A->roc); + // XX review this, and confirm it's actually an optimization + // Seems like it could be very expensive in some cases + // if ( c3n == u3r_sing(cor, u3A->roc) ) { ret = u3nc(vir, ovo); @@ -1465,7 +1468,8 @@ _raft_sure(u3_noun ovo, u3_noun vir, u3_noun cor) else { u3z(ovo); - // push a new event into queue + // we return ~ in place of the event ovum to skip persistence + // ret = u3nc(vir, u3_nul); u3z(cor); @@ -1669,10 +1673,10 @@ _raft_push(u3_raft* raf_u, c3_w* bob_w, c3_w len_w) } -/* _raft_kick_all(): kick a list of events, transferring. +/* _raft_kick(): kick a list of effects, transferring. */ static void -_raft_kick_all(u3_noun vir) +_raft_kick(u3_noun vir) { while ( u3_nul != vir ) { u3_noun ovo = u3k(u3h(vir)); @@ -2001,10 +2005,10 @@ _raft_poke(void) return rus; } -/* _raft_pump(): Cartify, jam, and save an ovum, then perform its effects. +/* _raft_pump(): Cartify, jam, and save an ovum. */ static void -_raft_pump(u3_noun ovo, u3_noun vir) +_raft_pump(u3_noun ovo) { u3v_cart* egg_u = u3a_malloc(sizeof(*egg_u)); u3p(u3v_cart) egg_p = u3of(u3v_cart, egg_u); @@ -2016,7 +2020,7 @@ _raft_pump(u3_noun ovo, u3_noun vir) egg_u->nex_p = 0; egg_u->cit = c3n; egg_u->did = c3n; - egg_u->vir = vir; + egg_u->vir = 0; ron = u3ke_jam(u3nc(u3k(u3A->now), ovo)); c3_assert(u3A->key); @@ -2040,9 +2044,8 @@ _raft_pump(u3_noun ovo, u3_noun vir) u3to(u3v_cart, u3A->ova.geg_p)->nex_p = egg_p; u3A->ova.geg_p = egg_p; } - _raft_kick_all(vir); + egg_u->did = c3y; - egg_u->vir = 0; } /* u3_raft_chip(): chip one event off for processing. @@ -2059,13 +2062,12 @@ u3_raft_chip(void) u3x_cell(rus, &vir, &ovo); if ( u3_nul != ovo ) { - _raft_pump(u3k(ovo), u3k(vir)); - - // XX should be vir - // - _raft_grab(u3A->roe); + _raft_pump(u3k(ovo)); } + _raft_kick(u3k(vir)); + _raft_grab(vir); + u3z(rus); } } From d448340a76df9e070a3c233fd55a2329809123df Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 11 Dec 2018 18:17:13 -0500 Subject: [PATCH 18/27] adds and corrects some raft comments --- vere/raft.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vere/raft.c b/vere/raft.c index 6c2778a21a..e4134c29ad 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1952,7 +1952,10 @@ _raft_crop(void) } } -/* _raft_pop_roe(): pop the next [(list effects) event] pair of the queue +/* _raft_pop_roe(): pop the next [~ event] off the queue. +** +** effects are no longer stored on u3A->roe; the head of +** each pair is always null. */ static u3_weak _raft_pop_roe(void) @@ -1973,17 +1976,16 @@ _raft_pop_roe(void) return ovo; } -/* _raft_poke(): Peel one ovum off u3A->roe and poke Arvo with it. +/* _raft_poke(): poke Arvo with the next queued event. */ static u3_weak _raft_poke(void) { u3_weak rus; - // XX what is this condition? + // defer event processing until storage is initialized // if ( 0 == u3Z->lug_u.len_d ) { - fprintf(stderr, "_raft_poke ret early\r\n"); return u3_none; } From 918e1cb38f9166d11da281ca6a39d3dc8d713885 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Tue, 11 Dec 2018 18:42:38 -0800 Subject: [PATCH 19/27] trailing whitespace --- vere/behn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vere/behn.c b/vere/behn.c index bb1021dbbb..9d7bd8b2d4 100644 --- a/vere/behn.c +++ b/vere/behn.c @@ -77,7 +77,7 @@ u3_behn_ef_doze(u3_noun wen) u3_noun now = u3_time_in_tv(&tim_tv); c3_d gap_d = u3_time_gap_ms(now, u3k(u3t(wen))); - + teh_u->alm = c3y; uv_timer_start(&teh_u->tim_u, _behn_time_cb, gap_d, 0); } From dfecb3a1cb33f65209368a8ff56494163f631b0e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 12 Dec 2018 00:37:56 -0500 Subject: [PATCH 20/27] refactors event poke, removing unnecessary effect traversal --- vere/raft.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/vere/raft.c b/vere/raft.c index e4134c29ad..508dddb6da 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1601,38 +1601,26 @@ _raft_punk(u3_noun ovo) free(txt_c); #endif - if ( u3_blip != u3h(gon) ) { - u3_noun why = u3k(u3h(gon)); - u3_noun tan = u3k(u3t(gon)); + { + u3_noun hed, tal; + u3x_cell(gon, &hed, &tal); + u3k(hed); u3k(tal); u3z(gon); - return _raft_lame(ovo, why, tan); - } - else { - u3_noun vir = u3k(u3h(u3t(gon))); - u3_noun cor = u3k(u3t(u3t(gon))); - u3_noun nug; - u3z(gon); - nug = u3v_nick(vir, cor); - - if ( u3_blip != u3h(nug) ) { - u3_noun why = u3k(u3h(nug)); - u3_noun tan = u3k(u3t(nug)); - - u3z(nug); - return _raft_lame(ovo, why, tan); + if ( u3_blip != hed ) { + return _raft_lame(ovo, hed, tal); } else { - vir = u3k(u3h(u3t(nug))); - cor = u3k(u3t(u3t(nug))); + u3_noun vir, cor; + u3x_cell(tal, &vir, &cor); + + u3k(vir); u3k(cor); + u3z(tal); - u3z(nug); return _raft_sure(ovo, vir, cor); } } - // uL(fprintf(uH, "punk oot %s\n", txt_c)); - // free(txt_c); } /* _raft_push(): save an event From a848191c504082378d2ac2599a0ad6428b6936cc Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 12 Dec 2018 00:39:31 -0500 Subject: [PATCH 21/27] refactors event replay, removing unnecessary effect traversal --- vere/sist.c | 58 ++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index e14b5bdb1c..f20b1d4b22 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -237,42 +237,42 @@ _sist_sing(u3_noun ovo) { u3_noun gon = u3m_soft(0, u3v_poke, u3k(ovo)); - if ( u3_blip != u3h(gon) ) { - _sist_suck(ovo, gon); - } - else { - u3_noun vir = u3k(u3h(u3t(gon))); - u3_noun cor = u3k(u3t(u3t(gon))); - u3_noun nug; + { + u3_noun hed, tal; + u3x_cell(gon, &hed, &tal); - u3z(gon); - nug = u3v_nick(vir, cor); - - if ( u3_blip != u3h(nug) ) { - _sist_suck(ovo, nug); + if ( u3_blip != hed ) { + _sist_suck(ovo, gon); } else { - vir = u3h(u3t(nug)); - cor = u3k(u3t(u3t(nug))); + u3_noun vir, cor; + u3x_cell(tal, &vir, &cor); - while ( u3_nul != vir ) { - u3_noun fex = u3h(vir); - u3_noun fav = u3t(fex); - - if ( c3__init == u3h(fav) ) { - u3A->own = u3k(u3t(fav)); - // note: c3__boot == u3h(u3t(ovo)) - u3A->fak = ( c3__fake == u3h(u3t(u3t(ovo))) ) ? c3y : c3n; - } - - vir = u3t(vir); - } - u3z(nug); u3z(u3A->roc); - u3A->roc = cor; + u3A->roc = u3k(cor); + + { + u3_noun tag, dat; + u3x_trel(ovo, 0, &tag, &dat); + + if ( c3__boot == tag ) { + while ( u3_nul != vir ) { + u3_noun fav = u3t(u3h(vir)); + + if ( c3__init == u3h(fav) ) { + u3A->own = u3k(u3t(fav)); + u3A->fak = ( c3__fake == u3h(tag) ) ? c3y : c3n; + } + + vir = u3t(vir); + } + } + } } - u3z(ovo); } + + u3z(gon); + u3z(ovo); } /* _sist_cask(): ask for a passcode. From f18d6cbc103e0457c8da9b21e48af023415b4d44 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 12 Dec 2018 00:40:04 -0500 Subject: [PATCH 22/27] removes unused u3v_nick (effect traversal) and u3v_http_request --- include/noun/vortex.h | 10 ------- noun/vortex.c | 67 ------------------------------------------- 2 files changed, 77 deletions(-) diff --git a/include/noun/vortex.h b/include/noun/vortex.h index d84dbf2c60..dfb7e8bae4 100644 --- a/include/noun/vortex.h +++ b/include/noun/vortex.h @@ -84,11 +84,6 @@ u3_noun u3v_pike(u3_noun ovo, u3_noun cor); - /* u3v_nick(): transform enveloped packets, [vir cor]. - */ - u3_noun - u3v_nick(u3_noun vir, u3_noun cor); - /* u3v_do(): use a kernel function. */ u3_noun @@ -119,11 +114,6 @@ u3_noun u3v_poke(u3_noun ovo); - /* u3v_http_request(): hear http request on channel (unprotected). - */ - void - u3v_http_request(c3_o sec, u3_noun pox, u3_noun req); - /* u3v_tank(): dump single tank. */ void diff --git a/noun/vortex.c b/noun/vortex.c index a23f95f30b..c40fd3fcf9 100644 --- a/noun/vortex.c +++ b/noun/vortex.c @@ -139,64 +139,6 @@ u3v_pike(u3_noun ovo, u3_noun cor) return _cv_mung(0, fun, sam); } -/* u3v_nick(): transform enveloped packets, [vir cor]. -*/ -u3_noun -u3v_nick(u3_noun vir, u3_noun cor) -{ - if ( u3_nul == vir ) { - return u3nt(u3_blip, vir, cor); - } - else { - u3_noun i_vir = u3h(vir); - u3_noun pi_vir, qi_vir; - u3_noun vix; - - if ( (c3y == u3r_cell(i_vir, &pi_vir, &qi_vir)) && - (c3y == u3du(qi_vir)) && - (c3__hear == u3h(qi_vir)) ) - { - u3_noun gon; - - gon = u3v_pike(u3k(i_vir), cor); - if ( u3_blip != u3h(gon) ) { - u3z(vir); - return gon; - } - else { - u3_noun viz; - - vix = u3k(u3h(u3t(gon))); - cor = u3k(u3t(u3t(gon))); - u3z(gon); - - viz = u3kb_weld(vix, u3k(u3t(vir))); - u3z(vir); - - return u3v_nick(viz, cor); - } - } - else { - u3_noun nez = u3v_nick(u3k(u3t(vir)), cor); - - if ( u3_blip != u3h(nez) ) { - u3z(vir); - return nez; - } else { - u3_noun viz; - - viz = u3nc(u3k(i_vir), u3k(u3h(u3t(nez)))); - cor = u3k(u3t(u3t(nez))); - - u3z(vir); - u3z(nez); - - return u3nt(u3_blip, viz, cor); - } - } - } -} - /* _cv_nock_poke(): call poke through hardcoded interface. */ static u3_noun @@ -374,15 +316,6 @@ u3v_poke(u3_noun ovo) return _cv_nock_poke(ovo); } -/* u3v_http_request(): hear http request on channel (unprotected). -*/ -void -u3v_http_request(c3_o sec, u3_noun pox, u3_noun req) -{ - // uL(fprintf(uH, "http: request\n")); - u3v_plan(pox, u3nq(c3__this, sec, 0, req)); -} - /* u3v_tank(): dump single tank. */ void From 958e857476f755c1e2301de61224d8ba6cef1b02 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 12 Dec 2018 02:24:13 -0500 Subject: [PATCH 23/27] calls u3_raft_work on leader promotion (for eager restart effects) --- vere/raft.c | 1 + 1 file changed, 1 insertion(+) diff --git a/vere/raft.c b/vere/raft.c index e4134c29ad..5c0ec25e5a 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -179,6 +179,7 @@ _raft_promote(u3_raft* raf_u) u3_sist_boot(); if ( c3n == u3_Host.ops_u.bat ) { u3_lo_lead(); + u3_raft_work(); } } else { From 6b3c9f8dffc3c72a823d29c942db57251cb394a3 Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Wed, 12 Dec 2018 18:19:54 -0800 Subject: [PATCH 24/27] fit UTF-8 tape bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You should be able to do this in dojo: ``` > "Some UTF-8: ἄλφα" "Some UTF-8: ἄλφα" ``` Now you can. @joemfb told me where to find the problem. --- vere/term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vere/term.c b/vere/term.c index 2c768002b0..54cb0a222b 100644 --- a/vere/term.c +++ b/vere/term.c @@ -657,7 +657,7 @@ _term_io_suck_char(u3_utty* uty_u, c3_y cay_y) // uL(fprintf(uH, "muck-utf8 len %d\n", tat_u->fut.len_w)); // uL(fprintf(uH, "muck-utf8 %x\n", huv)); - wug = u3do("turf", huv); + wug = u3do("taft", huv); // uL(fprintf(uH, "muck-utf32 %x\n", tat_u->fut.len_w)); tat_u->fut.len_w = tat_u->fut.wid_w = 0; From aea2139261049d68470e452d24f3e8254fe4b094 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 12 Dec 2018 16:27:09 -0800 Subject: [PATCH 25/27] Add a jet for +del:by --- include/jets/w.h | 1 + jets/d/by_del.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++ jets/tree.c | 3 ++ meson.build | 1 + 4 files changed, 109 insertions(+) create mode 100644 jets/d/by_del.c diff --git a/include/jets/w.h b/include/jets/w.h index dae4c80eeb..65a7cef8d6 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -79,6 +79,7 @@ /** Tier 4. **/ u3_noun u3wdb_bif(u3_noun); + u3_noun u3wdb_del(u3_noun); u3_noun u3wdb_dif(u3_noun); u3_noun u3wdb_gas(u3_noun); u3_noun u3wdb_get(u3_noun); diff --git a/jets/d/by_del.c b/jets/d/by_del.c new file mode 100644 index 0000000000..ea87c1862f --- /dev/null +++ b/jets/d/by_del.c @@ -0,0 +1,104 @@ +/* j/4/by_del.c +** +*/ +#include "all.h" + +/* functions +*/ + static u3_noun + _rebalance(u3_noun a) + { + u3_noun l_a, n_a, r_a; + + if ( c3n == u3r_trel(a, &n_a, &l_a, &r_a) ) { + return u3m_bail(c3__exit); + } else { + if ( u3_nul == l_a) { + return u3k(r_a); + } else if ( u3_nul == r_a) { + return u3k(l_a); + } else { + u3_noun n_l_a, l_l_a, r_l_a; + u3_noun n_r_a, l_r_a, r_r_a; + + if ( (c3n == u3r_trel(l_a, &n_l_a, &l_l_a, &r_l_a) ) || + (c3n == u3r_trel(r_a, &n_r_a, &l_r_a, &r_r_a) ) || + (c3n == u3du(n_l_a)) || + (c3n == u3du(n_r_a)) ) { + return u3m_bail(c3__exit); + } else { + if ( c3y == u3qc_vor(u3h(n_l_a), u3h(n_r_a)) ) { + u3_noun new_right = u3nt(u3k(n_a), + u3k(r_l_a), + u3k(r_a)); + + u3_noun ret = u3nt(u3k(n_l_a), + u3k(l_l_a), + _rebalance(new_right)); + u3z(new_right); + + return ret; + } else { + u3_noun new_left = u3nt(u3k(n_a), + u3k(l_a), + u3k(l_r_a)); + + u3_noun ret = u3nt(u3k(n_r_a), + _rebalance(new_left), + u3k(r_r_a)); + u3z(new_left); + + return ret; + } + } + } + } + } + + u3_noun + u3qdb_del(u3_noun a, + u3_noun b) + { + if ( u3_nul == a ) { + return u3_nul; + } + else { + u3_noun l_a, n_a, r_a, pn_a, qn_a; + + if ( (c3n == u3r_trel(a, &n_a, &l_a, &r_a)) || + (c3n == u3r_cell(n_a, &pn_a, &qn_a)) ) + { + return u3m_bail(c3__exit); + } + else if ( c3n == u3r_sing(pn_a, b) ) { + if ( c3y == u3qc_gor(b, pn_a) ) { + return u3nt(u3k(n_a), + u3qdb_del(l_a, b), + u3k(r_a)); + } else { + return u3nt(u3k(n_a), + u3k(l_a), + u3qdb_del(r_a, b)); + } + } + else { + return _rebalance(a); + } + } + } + + u3_noun + u3wdb_del(u3_noun cor) + { + u3_noun a, b; + + if ( c3n == u3r_mean(cor, u3x_sam, &b, + u3x_con_sam, &a, 0) ) { + return u3m_bail(c3__exit); + } else { + u3_noun n = u3qdb_del(a, b); + return n; + } + } + + diff --git a/jets/tree.c b/jets/tree.c index 0bfe6cf7eb..c0da86ffd2 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -892,6 +892,8 @@ static c3_c* _141_two__in_ha[] = {0}; static u3j_harm _141_two__by_bif_a[] = {{".2", u3wdb_bif, c3y}, {}}; static c3_c* _141_two__by_bif_ha[] = {0}; + static u3j_harm _141_two__by_del_a[] = {{".2", u3wdb_del, c3y}, {}}; + static c3_c* _141_two__by_del_ha[] = {0}; static u3j_harm _141_two__by_dif_a[] = {{".2", u3wdb_dif, c3y}, {}}; static c3_c* _141_two__by_dif_ha[] = {0}; static u3j_harm _141_two__by_gas_a[] = {{".2", u3wdb_gas, c3y}, {}}; @@ -918,6 +920,7 @@ static c3_c* _141_two__in_ha[] = {0}; static u3j_core _141_two__by_d[] = { { "bif", 7, _141_two__by_bif_a, 0, _141_two__by_bif_ha }, + { "del", 7, _141_two__by_del_a, 0, _141_two__by_del_ha }, { "dif", 7, _141_two__by_dif_a, 0, _141_two__by_dif_ha }, { "gas", 7, _141_two__by_gas_a, 0, _141_two__by_gas_ha }, { "get", 7, _141_two__by_get_a, 0, _141_two__by_get_ha }, diff --git a/meson.build b/meson.build index d023d4adac..71b9029999 100644 --- a/meson.build +++ b/meson.build @@ -90,6 +90,7 @@ jets_d_src = [ 'jets/d/in_wyt.c', 'jets/d/in_bif.c', 'jets/d/in_dif.c', +'jets/d/by_del.c', 'jets/d/by_gas.c', 'jets/d/by_get.c', 'jets/d/by_has.c', From df40b0252f2e57e2a3844ffaa82bc3fa0983ef73 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 12 Dec 2018 16:45:38 -0800 Subject: [PATCH 26/27] [CI] Update arvo --- .travis/pin-arvo-commit.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/pin-arvo-commit.txt b/.travis/pin-arvo-commit.txt index 9d21e4199e..a59368215f 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -6a1f32bb1984fa9329c072de09ba67b212c8dbed +00c79de3df4ecae9f499053990471d420f0e79a0 From 6c1e20dcbd2828368ed1fec1c5602c820db1fd66 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 13 Dec 2018 11:29:36 -0800 Subject: [PATCH 27/27] Style nits --- jets/d/by_del.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/jets/d/by_del.c b/jets/d/by_del.c index ea87c1862f..90e11b37cf 100644 --- a/jets/d/by_del.c +++ b/jets/d/by_del.c @@ -12,12 +12,15 @@ if ( c3n == u3r_trel(a, &n_a, &l_a, &r_a) ) { return u3m_bail(c3__exit); - } else { + } + else { if ( u3_nul == l_a) { return u3k(r_a); - } else if ( u3_nul == r_a) { + } + else if ( u3_nul == r_a) { return u3k(l_a); - } else { + } + else { u3_noun n_l_a, l_l_a, r_l_a; u3_noun n_r_a, l_r_a, r_r_a; @@ -26,7 +29,8 @@ (c3n == u3du(n_l_a)) || (c3n == u3du(n_r_a)) ) { return u3m_bail(c3__exit); - } else { + } + else { if ( c3y == u3qc_vor(u3h(n_l_a), u3h(n_r_a)) ) { u3_noun new_right = u3nt(u3k(n_a), u3k(r_l_a), @@ -38,7 +42,8 @@ u3z(new_right); return ret; - } else { + } + else { u3_noun new_left = u3nt(u3k(n_a), u3k(l_a), u3k(l_r_a)); @@ -75,7 +80,8 @@ return u3nt(u3k(n_a), u3qdb_del(l_a, b), u3k(r_a)); - } else { + } + else { return u3nt(u3k(n_a), u3k(l_a), u3qdb_del(r_a, b)); @@ -95,7 +101,8 @@ if ( c3n == u3r_mean(cor, u3x_sam, &b, u3x_con_sam, &a, 0) ) { return u3m_bail(c3__exit); - } else { + } + else { u3_noun n = u3qdb_del(a, b); return n; }