From 5189295d029d0559c3680787a3d674872ee9098a Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 13 Jul 2018 01:56:56 +0200 Subject: [PATCH 001/157] Add k versions for the mix, rep and rip jets. This makes upcoming work a bit easier. --- include/jets/k.h | 15 +++++++++++++++ jets/c/mix.c | 9 ++++++++- jets/c/rep.c | 9 ++++++++- jets/c/rip.c | 9 +++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/include/jets/k.h b/include/jets/k.h index d9171a511..3edde2142 100644 --- a/include/jets/k.h +++ b/include/jets/k.h @@ -18,6 +18,11 @@ /* u3kc: tier 3 functions */ + /* u3kc_mix(): binary xor. + */ + u3_noun + u3kc_mix(u3_atom a, u3_atom b); + /* u3kc_lsh(): left shift. */ u3_noun @@ -28,6 +33,16 @@ u3_noun u3kc_rsh(u3_noun a, u3_noun b, u3_noun c); + /* u3kc_rep(): assemble single. + */ + u3_noun + u3kc_rep(u3_atom a, u3_noun b); + + /* u3kc_rip(): disassemble. + */ + u3_noun + u3kc_rip(u3_atom a, u3_atom b); + /* u3kd: tier 4 functions */ /* u3kdb_get(): map get for key `b` in map `a` with u3_none. diff --git a/jets/c/mix.c b/jets/c/mix.c index 57addfe7e..6c734f703 100644 --- a/jets/c/mix.c +++ b/jets/c/mix.c @@ -48,4 +48,11 @@ return u3qc_mix(a, b); } } - + u3_noun + u3kc_mix(u3_atom a, + u3_atom b) + { + u3_noun res = u3qc_mix(a, b); + u3z(a); u3z(b); + return res; + } diff --git a/jets/c/rep.c b/jets/c/rep.c index 361bb2533..657f2a413 100644 --- a/jets/c/rep.c +++ b/jets/c/rep.c @@ -84,4 +84,11 @@ return pro; } } - + u3_noun + u3kc_rep(u3_atom a, + u3_noun b) + { + u3_noun res = u3qc_rep(a, b); + u3z(a); u3z(b); + return res; + } diff --git a/jets/c/rip.c b/jets/c/rip.c index c938f7816..30cee3dd6 100644 --- a/jets/c/rip.c +++ b/jets/c/rip.c @@ -81,3 +81,12 @@ return u3qc_rip(a, b); } } + u3_noun + u3kc_rip(u3_atom a, + u3_atom b) + { + u3_noun res = u3qc_rip(a, b); + + u3z(a); u3z(b); + return res; + } From b8712677ea7805fd35626faec74b69f97f5d1dcf Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 13 Jul 2018 01:58:32 +0200 Subject: [PATCH 002/157] Implement jet for ++swp. --- include/jets/k.h | 5 +++++ include/jets/q.h | 1 + include/jets/w.h | 1 + jets/c/swp.c | 39 +++++++++++++++++++++++++++++++++++++++ jets/tree.c | 3 +++ meson.build | 1 + 6 files changed, 50 insertions(+) create mode 100644 jets/c/swp.c diff --git a/include/jets/k.h b/include/jets/k.h index 3edde2142..0d06a9a64 100644 --- a/include/jets/k.h +++ b/include/jets/k.h @@ -43,6 +43,11 @@ u3_noun u3kc_rip(u3_atom a, u3_atom b); + /* u3kc_swp(): reverse block order. + */ + u3_noun + u3kc_swp(u3_atom a, u3_atom b); + /* u3kd: tier 4 functions */ /* u3kdb_get(): map get for key `b` in map `a` with u3_none. diff --git a/include/jets/q.h b/include/jets/q.h index 48db0ea5e..6a7763a85 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -66,6 +66,7 @@ u3_noun u3qc_rep(u3_atom, u3_noun); u3_noun u3qc_rip(u3_atom, u3_atom); u3_noun u3qc_rsh(u3_atom, u3_atom, u3_atom); + u3_noun u3qc_swp(u3_atom, u3_atom); u3_noun u3qc_sqt(u3_atom); u3_noun u3qc_vor(u3_atom, u3_atom); diff --git a/include/jets/w.h b/include/jets/w.h index 693cff4ba..0993ab563 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -66,6 +66,7 @@ u3_noun u3wc_rep(u3_noun); u3_noun u3wc_rip(u3_noun); u3_noun u3wc_rsh(u3_noun); + u3_noun u3wc_swp(u3_noun); u3_noun u3wc_sqt(u3_noun); u3_noun u3wc_vor(u3_noun); diff --git a/jets/c/swp.c b/jets/c/swp.c new file mode 100644 index 000000000..1b10dca2b --- /dev/null +++ b/jets/c/swp.c @@ -0,0 +1,39 @@ +/* j/3/swp.c +** +*/ +#include "all.h" + +/* functions +*/ + + u3_noun + u3qc_swp(u3_atom a, + u3_atom b) + { + //XX write a proper c-style swp, maybe + return u3kc_rep(u3k(a), u3kb_flop(u3qc_rip(a, b))); + } + + u3_noun + u3wc_swp(u3_noun cor) + { + u3_noun a, b; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) || + (c3n == u3ud(a)) || + (c3n == u3ud(b)) ) + { + return u3m_bail(c3__exit); + } else { + return u3qc_swp(a, b); + } + } + + u3_noun + u3kc_swp(u3_atom a, + u3_atom b) + { + u3_noun res = u3qc_swp(a, b); + u3z(a); u3z(b); + return res; + } diff --git a/jets/tree.c b/jets/tree.c index 784ae0607..e82317c87 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -512,6 +512,7 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two_rep_a[] = {{".2", u3wc_rep, c3y}, {}}; static u3j_harm _143_two_rip_a[] = {{".2", u3wc_rip, c3y}, {}}; static u3j_harm _143_two_rsh_a[] = {{".2", u3wc_rsh, c3y}, {}}; + static u3j_harm _143_two_swp_a[] = {{".2", u3wc_swp, c3y}, {}}; static u3j_harm _143_two_sqt_a[] = {{".2", u3wc_sqt, c3y}, {}}; static u3j_harm _143_two_vor_a[] = {{".2", u3wc_vor, c3y}, {}}; static u3j_harm _143_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; @@ -618,12 +619,14 @@ static u3j_core _143_two_d[] = { "rub", _143_two_rub_a }, { "peg", _143_two_peg_a }, { "pow", _143_two_pow_a }, + { "swp", _143_two_swp_a }, { "sqt", _143_two_sqt_a }, { "vor", _143_two_vor_a }, { "xeb", _143_two_xeb_a }, { "by", 0, _143_two__by_d }, { "in", 0, _143_two__in_d }, + {} }; diff --git a/meson.build b/meson.build index e89ab0793..772c84c63 100644 --- a/meson.build +++ b/meson.build @@ -73,6 +73,7 @@ jets_c_src = [ 'jets/c/rep.c', 'jets/c/rip.c', 'jets/c/rsh.c', +'jets/c/swp.c', 'jets/c/sqt.c', 'jets/c/vor.c', ] From 919780c5707cfe7d74ca273d75edd5bf4b636c8d Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 13 Jul 2018 01:59:56 +0200 Subject: [PATCH 003/157] Implement jet for ++rev. --- include/jets/k.h | 5 +++++ include/jets/q.h | 1 + include/jets/w.h | 1 + jets/c/rev.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ jets/tree.c | 2 ++ meson.build | 1 + 6 files changed, 60 insertions(+) create mode 100644 jets/c/rev.c diff --git a/include/jets/k.h b/include/jets/k.h index 0d06a9a64..3eeb4d227 100644 --- a/include/jets/k.h +++ b/include/jets/k.h @@ -43,6 +43,11 @@ u3_noun u3kc_rip(u3_atom a, u3_atom b); + /* u3kc_rev(): reverse block order, accounting for leading zeroes. + */ + u3_noun + u3kc_rev(u3_atom boz, u3_atom len, u3_atom dat); + /* u3kc_swp(): reverse block order. */ u3_noun diff --git a/include/jets/q.h b/include/jets/q.h index 6a7763a85..09a3a0c24 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -64,6 +64,7 @@ u3_noun u3qc_pow(u3_atom, u3_atom); u3_noun u3qc_rap(u3_atom, u3_noun); u3_noun u3qc_rep(u3_atom, u3_noun); + u3_noun u3qc_rev(u3_atom, u3_atom, u3_atom); u3_noun u3qc_rip(u3_atom, u3_atom); u3_noun u3qc_rsh(u3_atom, u3_atom, u3_atom); u3_noun u3qc_swp(u3_atom, u3_atom); diff --git a/include/jets/w.h b/include/jets/w.h index 0993ab563..c656d4172 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -64,6 +64,7 @@ u3_noun u3wc_pow(u3_noun); u3_noun u3wc_rap(u3_noun); u3_noun u3wc_rep(u3_noun); + u3_noun u3wc_rev(u3_noun); u3_noun u3wc_rip(u3_noun); u3_noun u3wc_rsh(u3_noun); u3_noun u3wc_swp(u3_noun); diff --git a/jets/c/rev.c b/jets/c/rev.c new file mode 100644 index 000000000..eb2e9ef98 --- /dev/null +++ b/jets/c/rev.c @@ -0,0 +1,50 @@ +/* j/3/rev.c +** +*/ +#include "all.h" + +/* functions +*/ + + u3_noun + u3qc_rev(u3_atom boz, + u3_atom len, + u3_atom dat) + { + if ( !_(u3a_is_cat(boz)) || (boz >= 32) || + !_(u3a_is_cat(len)) ) { + return u3m_bail(c3__fail); + } + + dat = u3qc_end(boz, len, dat); + c3_w met = u3r_met(boz, dat); + return u3kc_lsh(u3k(boz), (len - met), u3kc_swp(u3k(boz), dat)); + } + + u3_noun + u3wc_rev(u3_noun cor) + { + u3_noun boz, len, dat; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &boz, + u3x_sam_6, &len, + u3x_sam_7, &dat, 0)) || + (c3n == u3ud(boz)) || + (c3n == u3ud(len)) || + (c3n == u3ud(dat)) ) + { + return u3m_bail(c3__exit); + } else { + return u3qc_rev(boz, len, dat); + } + } + + u3_noun + u3kc_rev(u3_atom boz, + u3_atom len, + u3_atom dat) + { + u3_noun res = u3qc_rev(boz, len, dat); + u3z(boz); u3z(len); u3z(dat); + return res; + } diff --git a/jets/tree.c b/jets/tree.c index e82317c87..ef71fb74d 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -510,6 +510,7 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two_pow_a[] = {{".2", u3wc_pow, c3y}, {}}; static u3j_harm _143_two_rap_a[] = {{".2", u3wc_rap, c3y}, {}}; static u3j_harm _143_two_rep_a[] = {{".2", u3wc_rep, c3y}, {}}; + static u3j_harm _143_two_rev_a[] = {{".2", u3wc_rev, c3y}, {}}; static u3j_harm _143_two_rip_a[] = {{".2", u3wc_rip, c3y}, {}}; static u3j_harm _143_two_rsh_a[] = {{".2", u3wc_rsh, c3y}, {}}; static u3j_harm _143_two_swp_a[] = {{".2", u3wc_swp, c3y}, {}}; @@ -614,6 +615,7 @@ static u3j_core _143_two_d[] = { "muk", _143_two_muk_a }, { "rap", _143_two_rap_a }, { "rep", _143_two_rep_a }, + { "rev", _143_two_rev_a }, { "rip", _143_two_rip_a }, { "rsh", _143_two_rsh_a }, { "rub", _143_two_rub_a }, diff --git a/meson.build b/meson.build index 772c84c63..21311ab86 100644 --- a/meson.build +++ b/meson.build @@ -71,6 +71,7 @@ jets_c_src = [ 'jets/c/pow.c', 'jets/c/rap.c', 'jets/c/rep.c', +'jets/c/rev.c', 'jets/c/rip.c', 'jets/c/rsh.c', 'jets/c/swp.c', From d969775d8fdae6fe01bd5bd50a81cba318287ea8 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 13 Jul 2018 02:01:31 +0200 Subject: [PATCH 004/157] Implement jet for ++sha-1:sha. --- include/jets/q.h | 1 + include/jets/w.h | 1 + jets/e/sha1.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ jets/tree.c | 7 ++++++ meson.build | 1 + 5 files changed, 72 insertions(+) create mode 100644 jets/e/sha1.c diff --git a/include/jets/q.h b/include/jets/q.h index 09a3a0c24..bf9ff4cce 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -134,6 +134,7 @@ u3_noun u3qe_shay(u3_atom, u3_atom); u3_noun u3qe_shas(u3_atom, u3_atom); u3_noun u3qe_shal(u3_atom, u3_atom); + u3_noun u3qe_sha1(u3_atom, u3_atom); u3_noun u3qeo_raw(u3_atom, u3_atom); diff --git a/include/jets/w.h b/include/jets/w.h index c656d4172..1d8f55cf8 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -145,6 +145,7 @@ u3_noun u3we_shay(u3_noun); u3_noun u3we_shas(u3_noun); u3_noun u3we_shal(u3_noun); + u3_noun u3we_sha1(u3_noun); u3_noun u3weo_raw(u3_noun); diff --git a/jets/e/sha1.c b/jets/e/sha1.c new file mode 100644 index 000000000..2910c1fbe --- /dev/null +++ b/jets/e/sha1.c @@ -0,0 +1,62 @@ +/* j/5/sha1.c +** +*/ +#include "all.h" + + +#if defined(U3_OS_osx) +#include +#else +#include +#endif + +/* functions +*/ + + u3_noun + u3qe_sha1(u3_atom wid, + u3_atom dat) + { + c3_assert(_(u3a_is_cat(wid))); + dat = u3qc_rev(3, wid, dat); + + //NOTE XX fixme we shouldn't c3_malloc in inner road, + // this is also done in other SHA jets + c3_y* fat_y = c3_malloc(wid + 1); + u3r_bytes(0, wid, fat_y, dat); + { + c3_y dig_y[32]; +#if defined(U3_OS_osx) + CC_SHA1_CTX ctx_h; + + CC_SHA1_Init(&ctx_h); + CC_SHA1_Update(&ctx_h, fat_y, wid); + CC_SHA1_Final(dig_y, &ctx_h); +#else + SHA1_CTX ctx_h; + + SHA1_Init(&ctx_h); + SHA1_Update(&ctx_h, fat_y, wid); + SHA1_Final(dig_y, &ctx_h); +#endif + free(fat_y); + u3z(dat); + return u3kc_rev(3, 20, u3i_bytes(20, dig_y)); + } + } + + u3_noun + u3we_sha1(u3_noun cor) + { + u3_noun wid, dat; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &wid, u3x_sam_3, &dat, 0)) || + (c3n == u3ud(wid)) || + (c3n == u3a_is_cat(wid)) || + (c3n == u3ud(dat)) ) + { + return u3m_bail(c3__exit); + } else { + return u3qe_sha1(wid, dat); + } + } diff --git a/jets/tree.c b/jets/tree.c index ef71fb74d..2c36b6419 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -446,6 +446,12 @@ static u3j_core _143_qua_d[] = {} }; + static u3j_harm _143_tri__sha_sha1_a[] = {{".2", u3we_sha1}, {}}; + static u3j_core _143_tri__sha_d[] = + { { "sha1", _143_tri__sha_sha1_a }, + {} + }; + static u3j_harm _143_tri_shax_a[] = {{".2", u3we_shax}, {}}; static u3j_harm _143_tri_shay_a[] = {{".2", u3we_shay}, {}}; static u3j_harm _143_tri_shas_a[] = {{".2", u3we_shas}, {}}; @@ -460,6 +466,7 @@ static u3j_core _143_tri_d[] = { "rq", 0, _143_tri__rq_d }, { "rh", 0, _143_tri__rh_d }, { "og", 0, _143_tri__og_d }, + { "sha", 0, _143_tri__sha_d }, { "shax", _143_tri_shax_a }, { "shay", _143_tri_shay_a }, { "shas", _143_tri_shas_a }, diff --git a/meson.build b/meson.build index 21311ab86..bcc3e3da1 100644 --- a/meson.build +++ b/meson.build @@ -118,6 +118,7 @@ jets_e_src = [ 'jets/e/rub.c', 'jets/e/scr.c', 'jets/e/shax.c', +'jets/e/sha1.c', 'jets/e/lore.c', 'jets/e/loss.c', 'jets/e/lune.c', From 9498336f2a3827eebdb6b1a0b6839cf6da8716d6 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 13 Jul 2018 02:03:08 +0200 Subject: [PATCH 005/157] Implement jet for ++hmac:hmac:crypto. --- include/jets/q.h | 3 ++ include/jets/w.h | 2 ++ jets/e/hmac.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ jets/tree.c | 8 +++++ meson.build | 1 + 5 files changed, 102 insertions(+) create mode 100644 jets/e/hmac.c diff --git a/include/jets/q.h b/include/jets/q.h index bf9ff4cce..dcfee4bdc 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -136,6 +136,9 @@ u3_noun u3qe_shal(u3_atom, u3_atom); u3_noun u3qe_sha1(u3_atom, u3_atom); + u3_noun u3qe_hmac(u3_noun, u3_atom, u3_atom, + u3_atom, u3_atom, u3_atom, u3_atom); + u3_noun u3qeo_raw(u3_atom, u3_atom); u3_noun u3qef_drg(u3_noun, u3_atom); diff --git a/include/jets/w.h b/include/jets/w.h index 1d8f55cf8..1eaf7cd7e 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -154,6 +154,8 @@ u3_noun u3wee_veri(u3_noun); u3_noun u3wee_shar(u3_noun); + u3_noun u3we_hmac(u3_noun); + u3_noun u3we_bend_fun(u3_noun); u3_noun u3we_cold_fun(u3_noun); u3_noun u3we_cook_fun(u3_noun); diff --git a/jets/e/hmac.c b/jets/e/hmac.c new file mode 100644 index 000000000..3b3a1af99 --- /dev/null +++ b/jets/e/hmac.c @@ -0,0 +1,88 @@ +/* j/5/hmac.c +** +*/ +#include "all.h" + +/* functions +*/ + + u3_noun + u3qe_hmac(u3_noun haj, + u3_atom boq, + u3_atom out, + u3_atom wik, + u3_atom key, + u3_atom wid, + u3_atom dat) + { + c3_assert(_(u3a_is_cat(boq)) && _(u3a_is_cat(wik)) && _(u3a_is_cat(wid))); + + // ensure key and message fit signaled lengths + key = u3qc_end(3, wik, key); + dat = u3qc_end(3, wid, dat); + + // keys longer than block size are shortened by hashing + if (wik > boq) { + key = u3n_slam_on(u3k(haj), u3nc(wik, key)); + wik = out; + } + + // keys shorter than block size are right-padded + if (wik < boq) { + key = u3kc_lsh(3, (boq - wik), key); + } + + // pad key, inner and outer + c3_y trail = (boq % 4); + c3_y padwords = (boq / 4) + (trail == 0 ? 0 : 1); + c3_w innpad[padwords], outpad[padwords]; + memset(innpad, 0x36, padwords * 4); + memset(outpad, 0x5c, padwords * 4); + if (trail > 0) { + innpad[padwords-1] = 0x36363636 >> (8 * (4 - trail)); + outpad[padwords-1] = 0x5c5c5c5c >> (8 * (4 - trail)); + } + u3_atom innkey = u3kc_mix(u3k(key), u3i_words(padwords, innpad)); + u3_atom outkey = u3kc_mix( key , u3i_words(padwords, outpad)); + + // append inner padding to message, then hash + u3_atom innmsg = u3ka_add(u3kc_lsh(3, wid, innkey), u3k(dat)); + u3_atom innhaj = u3n_slam_on(u3k(haj), u3nc((wid + boq), innmsg)); + + // prepend outer padding to result, hash again + u3_atom outmsg = u3ka_add(u3kc_lsh(3, out, outkey), innhaj); + u3_atom outhaj = u3n_slam_on(u3k(haj), u3nc((out + boq), outmsg)); + + fprintf(stderr, "\naaaaaa\n"); + return outhaj; + } + + u3_noun + u3we_hmac(u3_noun cor) + { + u3_noun haj, boq, out, wik, key, wid, dat; + + // sample is [[haj boq out] [wik key] [wid dat]] + if ( (c3n == u3r_mean(cor, u3x_sam_4, &haj, + 50, &boq, // +<->- + 51, &out, // +<->+ + u3x_sam_12, &wik, + u3x_sam_13, &key, + u3x_sam_14, &wid, + u3x_sam_15, &dat, 0)) || + (c3n == u3ud(boq)) || + (c3n == u3a_is_cat(boq)) || + (c3n == u3ud(out)) || + (c3n == u3a_is_cat(out)) || + (c3n == u3ud(wik)) || + (c3n == u3a_is_cat(wik)) || + (c3n == u3ud(key)) || + (c3n == u3ud(wid)) || + (c3n == u3a_is_cat(wid)) || + (c3n == u3ud(dat)) ) + { + return u3m_bail(c3__exit); + } else { + return u3qe_hmac(haj, boq, out, wik, key, wid, dat); + } + } diff --git a/jets/tree.c b/jets/tree.c index 2c36b6419..2dee91537 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -89,6 +89,13 @@ static u3j_core _143_hex_coed_d[] = {} }; + static u3j_harm _143_hex_hmac_a[] = {{".2", u3we_hmac}, {}}; + + static u3j_core _143_hex_hmac_d[] = + { { "hmac", _143_hex_hmac_a }, + {} + }; + static u3j_core _143_hex_d[] = { { "down", 0, _143_hex_down_d }, { "lore", _143_hex_lore_a }, @@ -96,6 +103,7 @@ static u3j_core _143_hex_d[] = { "lune", _143_hex_lune_a }, { "coed", 0, _143_hex_coed_d }, { "aes", 0, _143_hex_aes_d }, + { "hmac", 0, _143_hex_hmac_d }, {} }; diff --git a/meson.build b/meson.build index bcc3e3da1..b7218d4f4 100644 --- a/meson.build +++ b/meson.build @@ -106,6 +106,7 @@ jets_e_src = [ 'jets/e/aesc.c', 'jets/e/cue.c', 'jets/e/fl.c', +'jets/e/hmac.c', 'jets/e/jam.c', 'jets/e/mat.c', 'jets/e/mink.c', From e8103edb06f6d763db87ec3015773d043c786585 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 13 Jul 2018 15:55:37 +0200 Subject: [PATCH 006/157] Fix compile-time issue with OpenSSL version of SHA-1 jet. --- jets/e/sha1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jets/e/sha1.c b/jets/e/sha1.c index 2910c1fbe..32aeb7da9 100644 --- a/jets/e/sha1.c +++ b/jets/e/sha1.c @@ -33,7 +33,7 @@ CC_SHA1_Update(&ctx_h, fat_y, wid); CC_SHA1_Final(dig_y, &ctx_h); #else - SHA1_CTX ctx_h; + SHA_CTX ctx_h; SHA1_Init(&ctx_h); SHA1_Update(&ctx_h, fat_y, wid); From ea3aa7d2bd705da3938fbfe607a3f58723cf8d19 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 20 Jul 2018 01:48:07 +0200 Subject: [PATCH 007/157] Implement jet for ++argon2:argon2:crypto --- .gitmodules | 3 + include/jets/q.h | 5 ++ include/jets/w.h | 2 + jets/e/argon2.c | 145 +++++++++++++++++++++++++++++++++++++++++++++ jets/tree.c | 8 +++ meson.build | 3 + subprojects/argon2 | 1 + 7 files changed, 167 insertions(+) create mode 100644 jets/e/argon2.c create mode 160000 subprojects/argon2 diff --git a/.gitmodules b/.gitmodules index 53a902eeb..33e89d84f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,6 @@ [submodule "subprojects/h2o"] path = subprojects/libh2o url = https://github.com/urbit/h2o.git +[submodule "subprojects/argon2"] + path = subprojects/argon2 + url = https://github.com/urbit/argon2.git diff --git a/include/jets/q.h b/include/jets/q.h index dcfee4bdc..aebe6abe3 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -139,6 +139,11 @@ u3_noun u3qe_hmac(u3_noun, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom); + u3_noun u3qe_argon2(u3_atom, u3_atom, u3_atom, + u3_atom, u3_atom, u3_atom, + u3_atom, u3_atom, u3_atom, u3_atom, + u3_atom, u3_atom, u3_atom, u3_atom); + u3_noun u3qeo_raw(u3_atom, u3_atom); u3_noun u3qef_drg(u3_noun, u3_atom); diff --git a/include/jets/w.h b/include/jets/w.h index 1eaf7cd7e..a1795b12e 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -156,6 +156,8 @@ u3_noun u3we_hmac(u3_noun); + u3_noun u3we_argon2(u3_noun); + u3_noun u3we_bend_fun(u3_noun); u3_noun u3we_cold_fun(u3_noun); u3_noun u3we_cook_fun(u3_noun); diff --git a/jets/e/argon2.c b/jets/e/argon2.c new file mode 100644 index 000000000..896b1f5d5 --- /dev/null +++ b/jets/e/argon2.c @@ -0,0 +1,145 @@ +/* j/5/argon2.c +** +*/ +#include "all.h" + +#include + +/* functions +*/ + + u3_noun + u3qe_argon2(// configuration params, + u3_atom out, u3_atom type, u3_atom version, + u3_atom threads, u3_atom mem_cost, u3_atom time_cost, + u3_atom wik, u3_atom key, u3_atom wix, u3_atom extra, + // input params + u3_atom wid, u3_atom dat, u3_atom wis, u3_atom sat) + { + c3_assert(_(u3a_is_cat(out)) && _(u3a_is_cat(type)) && + _(u3a_is_cat(version)) && _(u3a_is_cat(threads)) && + _(u3a_is_cat(mem_cost)) && _(u3a_is_cat(time_cost)) && + _(u3a_is_cat(wik)) && _(u3a_is_cat(wix)) && + _(u3a_is_cat(wid)) && _(u3a_is_cat(wis))); + + // flip endianness for argon2 + key = u3qc_rev(3, wik, key); + extra = u3qc_rev(3, wix, extra); + dat = u3qc_rev(3, wid, dat); + sat = u3qc_rev(3, wis, sat); + + // atoms to byte arrays + c3_y bytes_key[wik]; + u3r_bytes(0, wik, bytes_key, key); + c3_y bytes_extra[wix]; + u3r_bytes(0, wix, bytes_extra, extra); + c3_y bytes_dat[wid]; + u3r_bytes(0, wid, bytes_dat, dat); + c3_y bytes_sat[wis]; + u3r_bytes(0, wis, bytes_sat, sat); + + c3_y outhash[out]; + argon2_context context = { + outhash, // output array, at least [digest length] in size + out, // digest length + bytes_dat, // password array + wid, // password length + bytes_sat, // salt array + wis, // salt length + bytes_key, wik, // optional secret data + bytes_extra, wix, // optional associated data + time_cost, mem_cost, threads, threads, // performance cost configuration + version, // algorithm version + NULL, NULL, // custom memory allocation / deallocation functions + ARGON2_DEFAULT_FLAGS // by default only internal memory is cleared + }; + + int argon_res; + switch(type) + { + case 100: // %d + argon_res = argon2d_ctx(&context); + break; + // + case 105: // %i + argon_res = argon2i_ctx(&context); + break; + // + case 117: // %u + argon_res = argon2u_ctx(&context); + break; + // + case 25705: // %id + argon_res = argon2id_ctx(&context); + break; + // + default: + fprintf(stderr, "\nunjetted argon2 variant %i\n", type); + u3m_bail(c3__exit); + } + + if(ARGON2_OK != argon_res) { + fprintf(stderr, "\nargon2 error: %s\n", argon2_error_message(argon_res)); + u3m_bail(c3__exit); + } + + u3z(key); u3z(extra); u3z(dat); u3z(sat); + return u3kc_rev(3, out, u3i_bytes(out, outhash)); + } + + u3_noun + u3we_argon2(u3_noun cor) + { + u3_noun // configuration params + out, type, version, + threads, mem_cost, time_cost, + wik, key, wix, extra, + // input params + wid, dat, wis, sat; + + // the hoon code for argon2 takes configuration parameters, + // and then produces a gate. we jet that inner gate. + // this does mean that the config params have gotten buried + // pretty deep in the subject, so we have to use large + // tree addresses to get at them. + if ( (c3n == u3r_mean(cor, u3x_sam_4, &wid, + u3x_sam_5, &dat, + u3x_sam_6, &wis, + u3x_sam_7, &sat, + // + 1020, &out, + 2042, &type, + 4086, &version, + // + 8174, &threads, + 16350, &mem_cost, + 32702, &time_cost, + // + 130812, &wik, + 130813, &key, + 130814, &wix, + 130815, &extra, 0)) || + (c3n == u3ud(out)) || + (c3n == u3ud(type)) || + (c3n == u3ud(version)) || + (c3n == u3ud(threads)) || + (c3n == u3ud(mem_cost)) || + (c3n == u3ud(time_cost)) || + (c3n == u3ud(wik)) || + (c3n == u3ud(key)) || + (c3n == u3ud(wix)) || + (c3n == u3ud(extra)) || + (c3n == u3ud(wid)) || + (c3n == u3ud(dat)) || + (c3n == u3ud(wis)) || + (c3n == u3ud(sat)) + ) + { + return u3m_bail(c3__exit); + } else { + return u3qe_argon2(out, type, version, + threads, mem_cost, time_cost, + wik, key, wix, extra, + wid, dat, wis, sat); + } + } diff --git a/jets/tree.c b/jets/tree.c index 2dee91537..08c1d8584 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -96,6 +96,13 @@ static u3j_core _143_hex_coed_d[] = {} }; + static u3j_harm _143_hex_argon2_a[] = {{".2", u3we_argon2, c3n}, {}}; + + static u3j_core _143_hex_argon_d[] = + { { "argon2", _143_hex_argon2_a }, + {} + }; + static u3j_core _143_hex_d[] = { { "down", 0, _143_hex_down_d }, { "lore", _143_hex_lore_a }, @@ -104,6 +111,7 @@ static u3j_core _143_hex_d[] = { "coed", 0, _143_hex_coed_d }, { "aes", 0, _143_hex_aes_d }, { "hmac", 0, _143_hex_hmac_d }, + { "argon", 0, _143_hex_argon_d }, {} }; diff --git a/meson.build b/meson.build index b7218d4f4..f145720a3 100644 --- a/meson.build +++ b/meson.build @@ -104,6 +104,7 @@ jets_e_src = [ 'jets/e/aes_ecb.c', 'jets/e/aes_cbc.c', 'jets/e/aesc.c', +'jets/e/argon2.c', 'jets/e/cue.c', 'jets/e/fl.c', 'jets/e/hmac.c', @@ -309,6 +310,7 @@ murmur3_dep = dependency('murmur3', version: '>=0.1.0', fallback: ['murmur3', 'm softfloat3_dep = dependency('softfloat3', version: '>=3.0.0', fallback: ['softfloat3', 'softfloat3_dep']) libuv_dep = dependency('libuv', version: '>=1.8.0', fallback:['libuv', 'libuv_dep']) libh2o_dep = dependency('libh2o', version: '>=0.13.3', fallback: ['libh2o', 'libh2o_dep']) +argon2_dep = dependency('argon2', version: '>=1', fallback: ['argon2', 'argon2_dep']) executable('urbit', sources : sources, @@ -325,5 +327,6 @@ dependencies: [openssl_dep, urbitscrypt_dep, ed25519_dep, murmur3_dep, + argon2_dep, softfloat3_dep] + os_deps, install: true) diff --git a/subprojects/argon2 b/subprojects/argon2 new file mode 160000 index 000000000..a936ac9e1 --- /dev/null +++ b/subprojects/argon2 @@ -0,0 +1 @@ +Subproject commit a936ac9e132cfe1c21bcc5d851382ed5b7d60b66 From 3ddcf1290a8ab398e2390baaaca76cb273e253a5 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 20 Jul 2018 01:48:44 +0200 Subject: [PATCH 008/157] Remove unnecessary u3k's in ++rev jet --- jets/c/rev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jets/c/rev.c b/jets/c/rev.c index eb2e9ef98..73ece5baa 100644 --- a/jets/c/rev.c +++ b/jets/c/rev.c @@ -18,7 +18,7 @@ dat = u3qc_end(boz, len, dat); c3_w met = u3r_met(boz, dat); - return u3kc_lsh(u3k(boz), (len - met), u3kc_swp(u3k(boz), dat)); + return u3kc_lsh(boz, (len - met), u3kc_swp(boz, dat)); } u3_noun From 34629b9d875717a95805db3ab9e1d7f1dc6c480f Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 20 Jul 2018 02:12:27 +0200 Subject: [PATCH 009/157] Disable testing for argon2 jet --- jets/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jets/tree.c b/jets/tree.c index 08c1d8584..3f17b3106 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -96,7 +96,7 @@ static u3j_core _143_hex_coed_d[] = {} }; - static u3j_harm _143_hex_argon2_a[] = {{".2", u3we_argon2, c3n}, {}}; + static u3j_harm _143_hex_argon2_a[] = {{".2", u3we_argon2}, {}}; static u3j_core _143_hex_argon_d[] = { { "argon2", _143_hex_argon2_a }, From fd78579e24cd8fe697fac347d0c0c30efc503361 Mon Sep 17 00:00:00 2001 From: BernardoDeLaPlaz Date: Thu, 19 Jul 2018 17:33:57 -0400 Subject: [PATCH 010/157] secp256 jetted --- .gitignore | 1 + .gitmodules | 4 + include/jets/q.h | 6 + include/jets/w.h | 6 + jets/e/hmac.c | 1 - jets/e/secp.c | 317 ++++++++++++++++++++++++++++++++++++++++++ jets/tree.c | 24 ++++ meson.build | 3 + subprojects/secp256k1 | 1 + 9 files changed, 362 insertions(+), 1 deletion(-) create mode 100644 jets/e/secp.c create mode 160000 subprojects/secp256k1 diff --git a/.gitignore b/.gitignore index d5a38529c..40815038b 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ node_modules/ /inst cscope.* build/ +TAGS diff --git a/.gitmodules b/.gitmodules index 33e89d84f..42e97f039 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,7 @@ [submodule "subprojects/argon2"] path = subprojects/argon2 url = https://github.com/urbit/argon2.git +[submodule "subprojects/secp256k1"] + path = subprojects/secp256k1 + url = https://github.com/urbit/secp256k1.git + diff --git a/include/jets/q.h b/include/jets/q.h index aebe6abe3..c5f7ffbbb 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -139,11 +139,17 @@ u3_noun u3qe_hmac(u3_noun, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom); + u3_noun u3qe_argon2(u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom); + u3_noun u3qe_make(u3_atom has, u3_atom prv); + u3_noun u3qe_reco(u3_atom has, u3_atom sig_v, u3_atom sig_r, u3_atom sig_s); + u3_noun u3qe_sign(u3_atom has, u3_atom prv); + + u3_noun u3qeo_raw(u3_atom, u3_atom); u3_noun u3qef_drg(u3_noun, u3_atom); diff --git a/include/jets/w.h b/include/jets/w.h index a1795b12e..0d9f4e307 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -156,8 +156,14 @@ u3_noun u3we_hmac(u3_noun); + u3_noun u3we_argon2(u3_noun); + u3_noun u3we_make(u3_noun); + u3_noun u3we_sign(u3_noun); + u3_noun u3we_reco(u3_noun); + + u3_noun u3we_bend_fun(u3_noun); u3_noun u3we_cold_fun(u3_noun); u3_noun u3we_cook_fun(u3_noun); diff --git a/jets/e/hmac.c b/jets/e/hmac.c index 3b3a1af99..753011823 100644 --- a/jets/e/hmac.c +++ b/jets/e/hmac.c @@ -53,7 +53,6 @@ u3_atom outmsg = u3ka_add(u3kc_lsh(3, out, outkey), innhaj); u3_atom outhaj = u3n_slam_on(u3k(haj), u3nc((out + boq), outmsg)); - fprintf(stderr, "\naaaaaa\n"); return outhaj; } diff --git a/jets/e/secp.c b/jets/e/secp.c new file mode 100644 index 000000000..3b4ded828 --- /dev/null +++ b/jets/e/secp.c @@ -0,0 +1,317 @@ + /* j/5/secp.c +** +*/ +#include "all.h" +#include "../include/secp256k1.h" +#include "../include/secp256k1_recovery.h" + +/* util funcs + */ + +/* no guarantees if 'in' and 'out' overlap / are the same */ +static void byte_reverse(c3_y *i_y, /* in */ + c3_y *o_y, /* out */ + c3_w n_w) /* size */ +{ + c3_w j_w; + for (j_w = 0; j_w < n_w; j_w++){ + o_y[n_w - 1 - j_w] = i_y[j_w]; + } + + return; +} + +/* Identical to u3r_bytes, but reverses bytes in place. + could be cleaner if we modified u3r_bytes(), but not gonna do that. + + This func exists bc Urbit code base is explicitly little-endian, + and secp256k1 library is explicitly big-endian. + + Several times below we do the pattern of (1) invoke u3r_bytes, (2) invert. Do it in a func. +*/ + + +static void u3r_bytes_reverse(c3_w a_w, + c3_w b_w, + c3_y* c_y, /* out */ + u3_atom d) /* in */ +{ + u3r_bytes(a_w, b_w, c_y, d); + c3_w i_w; + for (i_w = 0; i_w < ((b_w - a_w) / 2) ; i_w++) { + c3_y lo = c_y[i_w]; + c3_y hi = c_y[b_w - i_w - 1]; + c_y[i_w] = hi; + c_y[b_w - i_w - 1] = lo; + } + + return; +} + + +/* sign hash with priv key + */ + +u3_noun +u3we_sign(u3_noun cor) +{ + + u3_noun has, prv; + + if ( (c3n == u3r_mean(cor, + u3x_sam_2, &has, + u3x_sam_3, &prv, + 0)) || + (c3n == u3ud(has)) || + (c3n == u3ud(prv))) { + fprintf(stderr, "\rsecp jet: crypto package error\n"); + return u3m_bail(c3__exit); + } else { + return (u3qe_sign(has, prv)); + } +} + +u3_noun +u3qe_sign(u3_atom has, + u3_atom prv) +{ + /* build library context object once (and only once) */ + static secp256k1_context * ctx_u = NULL; + if (NULL == ctx_u) { + ctx_u = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); + } + + /* parse arguments, convert endianness */ + c3_y has_y[32]; /* hash */ + c3_y prv_y[32]; /* private key */ + u3r_bytes_reverse(0, 32, has_y, has); + u3r_bytes_reverse(0, 32, prv_y, prv); + + + /* sign + N.B. if we want the 'v' field we can't use default secp256k1_ecdsa_sign(), + but must use secp256k1_ecdsa_sign_recoverable() */ + c3_ws ret; + secp256k1_ecdsa_recoverable_signature sig_u; + ret = secp256k1_ecdsa_sign_recoverable(ctx_u, /* IN: context object */ + & sig_u, /* OUT: signature */ + (const c3_y *) has_y, /* IN: 32 byte hash to be signed */ + (const c3_y *) prv_y, /* IN: 32 byte secret key */ + (secp256k1_nonce_function) NULL, /* IN: nonce-function ptr ; NULL = default */ + (const void *) NULL); /* IN: data for nonce function; not used */ + if (1 != ret) { + fprintf(stderr, "\rsecp jet: crypto package error\n"); + return u3m_bail(c3__exit); + } + + /* convert opaque 65 byte signature into v + [r + s] + convert endianness while we're at it */ + c3_y rec_y[64]; + c3_ws v = 0; + ret = secp256k1_ecdsa_recoverable_signature_serialize_compact(ctx_u, + rec_y, /* OUT: 64 byte sig (r,s) */ + & v, /* OUT: v */ + & sig_u); /* IN: 65 byte sig */ + if (1 != ret) { + fprintf(stderr, "\rsecp jet: crypto package error\n"); + return u3m_bail(c3__exit); + } + + c3_y s_y[32]; + c3_y r_y[32]; + byte_reverse(rec_y, r_y, 32); + byte_reverse(rec_y + 32, s_y, 32); + + /* package s,r,v signature for return */ + v += 27; + u3_noun s = u3i_words(8, (const c3_w*) s_y); + u3_noun r = u3i_words(8, (const c3_w*) r_y); + return (u3nt(v, r, s)); +} + + +/* recover pubkey from signature (which is how we verify signatures) +*/ + +u3_noun +u3we_reco(u3_noun cor) +{ + u3_noun has, /* hash */ + siv, sir, sis; /* signature: v, r, s */ + + if ( (c3n == u3r_mean(cor, + u3x_sam_2, &has, + u3x_sam_6, &siv, + u3x_sam_14, &sir, + u3x_sam_15, &sis, + 0)) || + (c3n == u3ud(has)) || + (c3n == u3ud(siv)) || + (c3n == u3ud(sir)) || + (c3n == u3ud(sis)) ) + { + fprintf(stderr, "\rsecp jet: crypto package error\n"); + return u3m_bail(c3__exit); + } else { + return u3qe_reco(has, siv, sir, sis); + } +} + +u3_noun +u3qe_reco(u3_atom has, + u3_atom siv, /* signature: v */ + u3_atom sir, /* signature: r */ + u3_atom sis) /* signature: s */ +{ + + /* build library context object once (and only once) */ + static secp256k1_context * ctx_u = NULL; + if (NULL == ctx_u) { + ctx_u = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY); + } + + /* parse arguments, convert endianness */ + c3_y has_y[32]; + c3_y sir_y[32]; + c3_y sis_y[32]; + c3_y siv_y[1]; + u3r_bytes_reverse(0, 32, has_y, has); + u3r_bytes_reverse(0, 32, sir_y, sir); + u3r_bytes_reverse(0, 32, sis_y, sis); + u3r_bytes_reverse(0, 1, siv_y, siv); + + /* build the signature object */ + c3_y ras_y[64]; /* priv key: r and s components */ + c3_ws i_ws; + for (i_ws = 0; i_ws < 32; i_ws++) { + ras_y[i_ws] = sir_y[i_ws] ; + } + for (i_ws = 0; i_ws < 32; i_ws++) { + ras_y[i_ws + 32] = sis_y[i_ws] ; + } + + c3_ws siv_ws = siv_y[0]; + siv_ws -= 27; + secp256k1_ecdsa_recoverable_signature sig_u; + memset( (void *) & sig_u, 0, sizeof(secp256k1_ecdsa_recoverable_signature) ); + c3_ws ret = secp256k1_ecdsa_recoverable_signature_parse_compact(ctx_u, /* IN: context */ + & sig_u, /* OUT: sig */ + ras_y, /* IN: r/s */ + siv_ws); /* IN: v */ + if (1 != ret) { + fprintf(stderr, "\rsecp jet: crypto package error\n"); + return u3m_bail(c3__exit); + } + + /* turn sign into puk_u */ + secp256k1_pubkey puk_u; + memset((void *) & puk_u, 0, sizeof(secp256k1_pubkey) ); + ret = secp256k1_ecdsa_recover(ctx_u, /* IN: context */ + & puk_u, /* OUT: pub key */ + & sig_u, /* IN: signature */ + (const c3_y *) & has); /* IN: message has */ + + if (1 != ret) { + fprintf(stderr, "\rsecp jet: crypto package error\n"); + return u3m_bail(c3__exit); + } + + /* convert puk_u into serialized form that we can get x,y out of */ + c3_y puk_y[65]; + size_t outputlen = 65; + memset((void *) puk_y, 0, 65); + + ret = secp256k1_ec_pubkey_serialize( ctx_u, /* IN: */ + puk_y, /* OUT: */ + & outputlen, /* OUT: */ + & puk_u, /* IN: */ + SECP256K1_EC_UNCOMPRESSED); /* IN: flags */ + + if (1 != ret) { + fprintf(stderr, "\rsecp jet: crypto package error\n"); + return u3m_bail(c3__exit); + } + + /* in file + subprojects/secp256k1/src/eckey_impl.h + func + secp256k1_eckey_puk_u_parse() + we can see + byte 0: signal bits (???) + bytes 1-32: x + bytes 33-64: y + + convert endianness while we're at it */ + + c3_y x_y[32]; + for (i_ws = 0; i_ws < 32; i_ws++) { + x_y[i_ws] = puk_y[32 - i_ws]; + } + u3_noun x = u3i_bytes(32, x_y); + + c3_y y_y[32]; + for (i_ws = 0; i_ws < 32; i_ws++) { + y_y[i_ws] = puk_y[64 - i_ws]; + } + u3_noun y = u3i_bytes(32, y_y); + + /* returns x,y */ + return(u3nc(x, y)); +} + + +u3_noun +u3we_make(u3_noun cor) +{ + u3_noun has, prv; + if ( (c3n == u3r_mean(cor, + u3x_sam_2, &has, + u3x_sam_3, &prv, + 0)) || + (c3n == u3ud(has)) || + (c3n == u3ud(prv)) ) + { + fprintf(stderr, "\rsecp jet: crypto package error\n"); + return u3m_bail(c3__exit); + } else { + return u3qe_make(has, prv); + } +} + + + +u3_noun +u3qe_make(u3_atom has, + u3_atom prv) +{ + + c3_y hel_y[32]; /* hash, little endian */ + c3_y heb_y[32]; /* hash, big endian */ + u3r_bytes(0, 32, hel_y, has); + byte_reverse(hel_y, heb_y, 32); + + c3_y pel_y[32]; /* priv key, little endian */ + c3_y peb_y[32]; /* priv key, big endian */ + u3r_bytes(0, 32, pel_y, prv); + byte_reverse(pel_y, peb_y, 32); + + + c3_ws ret_ws; + c3_y neb_y[32]; /* nonce */ + ret_ws = secp256k1_nonce_function_rfc6979(neb_y, /* OUT: return arg for nonce */ + (const c3_y *) heb_y, /* IN: message / hash */ + (const c3_y *) peb_y, /* IN: key32 */ + NULL, /* IN: algorithm (NULL == ECDSA) */ + (void *) NULL, /* IN: arbitrary data pointer (unused) */ + 0); /* IN: attempt number (0 == normal) */ + if (1 != ret_ws) { + fprintf(stderr, "\rsecp jet: crypto package error\n"); + return u3m_bail(c3__exit); + } + + c3_y nel_y[32]; + byte_reverse(neb_y, nel_y, 32); + u3_noun non = u3i_words(8, (const c3_w*) nel_y); + return(non); +} + diff --git a/jets/tree.c b/jets/tree.c index 3f17b3106..8cd2b9a7e 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -103,6 +103,29 @@ static u3j_core _143_hex_coed_d[] = {} }; + static u3j_harm _143_hex_secp_make_a[] = {{".2", u3we_make, c3y}, {}}; + static u3j_harm _143_hex_secp_sign_a[] = {{".2", u3we_sign, c3y}, {}}; + static u3j_harm _143_hex_secp_reco_a[] = {{".2", u3we_reco, c3y}, {}}; + + static u3j_core _143_hex_secp_secp_helper_d[] = + { { "make-k", _143_hex_secp_make_a }, + { "ecdsa-raw-sign", _143_hex_secp_sign_a }, + { "ecdsa-raw-recover", _143_hex_secp_reco_a }, + {} + }; + + static u3j_core _143_hex_secp_secp_d[] = + { { "helper", 0, _143_hex_secp_secp_helper_d }, + {} + }; + + static u3j_core _143_hex_secp_d[] = + { { "secp", 0, _143_hex_secp_secp_d }, + {} + }; + + + static u3j_core _143_hex_d[] = { { "down", 0, _143_hex_down_d }, { "lore", _143_hex_lore_a }, @@ -112,6 +135,7 @@ static u3j_core _143_hex_d[] = { "aes", 0, _143_hex_aes_d }, { "hmac", 0, _143_hex_hmac_d }, { "argon", 0, _143_hex_argon_d }, + { "secp", 0, _143_hex_secp_d }, {} }; diff --git a/meson.build b/meson.build index f145720a3..0a2e80af8 100644 --- a/meson.build +++ b/meson.build @@ -119,6 +119,7 @@ jets_e_src = [ 'jets/e/rh.c', 'jets/e/rub.c', 'jets/e/scr.c', +'jets/e/secp.c', 'jets/e/shax.c', 'jets/e/sha1.c', 'jets/e/lore.c', @@ -311,6 +312,7 @@ softfloat3_dep = dependency('softfloat3', version: '>=3.0.0', fallback: ['softfl libuv_dep = dependency('libuv', version: '>=1.8.0', fallback:['libuv', 'libuv_dep']) libh2o_dep = dependency('libh2o', version: '>=0.13.3', fallback: ['libh2o', 'libh2o_dep']) argon2_dep = dependency('argon2', version: '>=1', fallback: ['argon2', 'argon2_dep']) +secp256k1_dep = dependency('libsecp256k1', version: '>=0.1.0', fallback: ['secp256k1', 'secp256k1_dep']) executable('urbit', sources : sources, @@ -322,6 +324,7 @@ dependencies: [openssl_dep, libuv_dep, libh2o_dep, cmark_dep, + secp256k1_dep, gmp_dep, sigsegv_dep, urbitscrypt_dep, diff --git a/subprojects/secp256k1 b/subprojects/secp256k1 new file mode 160000 index 000000000..9989e23ce --- /dev/null +++ b/subprojects/secp256k1 @@ -0,0 +1 @@ +Subproject commit 9989e23ce8a02a51a1f90a2d5e391ba7d16bef39 From 10bdf51640d25c569707d36e578a4668801c8b8a Mon Sep 17 00:00:00 2001 From: BernardoDeLaPlaz Date: Fri, 10 Aug 2018 14:04:03 -0400 Subject: [PATCH 011/157] crypto (blake, ripe) jetted --- include/jets/q.h | 4 ++ include/jets/w.h | 4 ++ jets/e/blake.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++ jets/e/ripe.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++ jets/tree.c | 17 ++++++ meson.build | 2 + 6 files changed, 290 insertions(+) create mode 100644 jets/e/blake.c create mode 100644 jets/e/ripe.c diff --git a/include/jets/q.h b/include/jets/q.h index aebe6abe3..d30edfefe 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -144,6 +144,10 @@ u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom); + u3_noun u3qe_blake(u3_atom msg, u3_atom key, u3_atom out); + + u3_noun u3qe_ripe(u3_atom byts); + u3_noun u3qeo_raw(u3_atom, u3_atom); u3_noun u3qef_drg(u3_noun, u3_atom); diff --git a/include/jets/w.h b/include/jets/w.h index a1795b12e..391dc33ed 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -158,6 +158,10 @@ u3_noun u3we_argon2(u3_noun); + u3_noun u3we_blake(u3_noun); + + u3_noun u3we_ripe(u3_noun); + u3_noun u3we_bend_fun(u3_noun); u3_noun u3we_cold_fun(u3_noun); u3_noun u3we_cook_fun(u3_noun); diff --git a/jets/e/blake.c b/jets/e/blake.c new file mode 100644 index 000000000..288213d74 --- /dev/null +++ b/jets/e/blake.c @@ -0,0 +1,131 @@ +/* j/5/blake.c +** +*/ +#include "all.h" + +#include +#include "../src/blake2/blake2.h" + +// `@ux`(blake2b:blake:crypto 1^0xaa 2^0xbbcc 32) + +static void pretty_print_hex(char * headline, + c3_y * ptr, + c3_w num_bytes) +{ + fprintf(stderr, "\r%s:\n\r ", headline); + for (c3_ws ii=0 ; ii < num_bytes; ii++) { + fprintf(stderr, "%02x", ptr[ii]); + if (0 == (ii + 1) % 16){ + fprintf(stderr, "\n\r "); + } else { + fprintf(stderr, ", "); + } + } + fprintf(stderr, "\n\r"); + +} + + +u3_noun +u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) +{ + /* msg + */ + u3_noun men; /* msg length */ + u3_noun mod; /* msg body */ + + u3r_mean(msg, + 2, &men, + 3, &mod, + 0); + + c3_w met_w = u3r_met(3, men); /* meta length: length of the length */ + + if (met_w > 4){ + fprintf(stderr, "\rblake jet: msg size size too big\n"); + return u3m_bail(c3__exit); + } + + c3_w men_w; + men_w = u3r_word(0, men); + + c3_y * mod_y = (c3_y * ) u3a_malloc(men_w); + u3r_bytes(0, men, (void *) mod_y, mod); + + pretty_print_hex("mod_y (message body bytes)", mod_y, men); + + /* key + */ + + u3_noun ken; /* key length */ + u3_noun kod; /* key body */ + + u3r_mean(key, + 2, &ken, + 3, &kod, + 0); + + c3_w mek_w = u3r_met(3, ken); /* meta length: length of the length */ + + if (mek_w > 4){ + fprintf(stderr, "\rblake jet: key size size too big\n"); + return u3m_bail(c3__exit); + } + + c3_w ken_w; + ken_w = u3r_word(0, ken); + + c3_y * kod_y = (c3_y * ) u3a_malloc(ken_w); + u3r_bytes(0, ken, (void *) kod_y, kod); + + pretty_print_hex("kod_y (message body bytes)", kod_y, ken); + + + int ret; + c3_y out_y[64]; + ret = blake2b(out_y, // OUT: output + (size_t) 64, // IN: max output size + mod_y, // IN: msg body + men_w, // IN: msg len + kod_y, // IN: key body + ken_w); // IN: key len + + /* free() BEFORE checking error code; we don't want to leak memory if we return early */ + u3a_free(mod_y ); + u3a_free(kod_y ); + pretty_print_hex("out", out_y, 64); + + if (ret != 0){ + fprintf(stderr, "\rblake jet: cryto lib error\n"); + return u3m_bail(c3__exit); + } + + u3_noun sig = u3i_bytes(64, out_y); + + return(sig); +} + + + +u3_noun +u3we_blake(u3_noun cor) +{ + u3_noun msg, byt, out; + + if ( (c3n == u3r_mean(cor, + u3x_sam_2, &msg, + u3x_sam_6, &byt, + u3x_sam_7, &out, + 0)) || + (c3n == u3du(msg)) || + (c3n == u3du(byt)) || + (c3n == u3ud(out)) ) + { + fprintf(stderr, "\rblake jet: arguments error\n\r\n\r"); + return u3m_bail(c3__exit); + } else { + return u3qe_blake(msg, byt, out); + } + + return(99); +} diff --git a/jets/e/ripe.c b/jets/e/ripe.c new file mode 100644 index 000000000..43090d4ef --- /dev/null +++ b/jets/e/ripe.c @@ -0,0 +1,132 @@ +/* j/5/ripe.c +** +*/ +#include "all.h" +#include + +static void byte_reverse_in_place(c3_y *c_y, /* in */ + c3_w n_w) /* size */ +{ + c3_w i_w; + + for (i_w = 0; i_w < (n_w / 2) ; i_w++) { + c3_y lo = c_y[i_w]; + c3_y hi = c_y[n_w - i_w - 1]; + c_y[i_w] = hi; + c_y[n_w - i_w - 1] = lo; + } + +} + + + +u3_noun +u3qe_ripe(u3_atom msg) +{ + + /* decompose + input + */ + + u3_noun men; /* msg length */ + u3_noun mod; /* msg body */ + + u3r_mean(msg, + 2, & men, + 3, & mod, + 0); + + c3_w met_w = u3r_met(3, men); /* meta length: length of the length */ + + if (met_w > 4){ + fprintf(stderr, "\rripe jet: msg meta-size too big\n"); + return u3m_bail(c3__exit); + } + + c3_w men_w; /* msg length in bits */ + men_w = u3r_word(0, men); + + if (0 != men_w % 8) { + fprintf(stderr, "\rripe jet: input size was not an even number of bytesn"); + return u3m_bail(c3__exit); + } + men_w = men_w / 8; + + + c3_y * mod_y = (c3_y * ) u3a_malloc(men_w); /* msg body */ + u3r_bytes(0, men, (void *) mod_y, mod); + + /* endian + convert + input + */ + + byte_reverse_in_place(mod_y, men_w); + + const EVP_MD *rip_u = EVP_ripemd160(); /* ripem algorithm */ + EVP_MD_CTX * con_u = NULL; /* context */ + + /* build library context object + once (and only once) + */ + if (NULL == con_u) { + con_u = EVP_MD_CTX_create(); + } + + /* perform + signature + */ + c3_y sib_y[20]; /* signature body */ + c3_w sil_w; /* signature length */ + c3_w ret_w; /* return code */ + + ret_w = EVP_DigestInit_ex (con_u, rip_u, NULL); + if (ret_w != 1) { + u3a_free(mod_y ); + fprintf(stderr, "\rripe jet: crypto library fail 1\n"); + return u3m_bail(c3__exit); + } + + ret_w = EVP_DigestUpdate (con_u, (void *) mod_y, men_w); + + u3a_free(mod_y ); + + if (ret_w != 1) { + fprintf(stderr, "\rripe jet: crypto library fail 2\n"); + return u3m_bail(c3__exit); + } + ret_w = EVP_DigestFinal_ex (con_u, sib_y, &sil_w); + if (ret_w != 1) { + fprintf(stderr, "\rripe jet: crypto library fail 3\n"); + return u3m_bail(c3__exit); + } + + /* endian conversion ; + turn into noun for return + */ + + byte_reverse_in_place(sib_y, 20); + u3_noun sig = u3i_bytes(sil_w, sib_y); + + return(sig); +} + + +u3_noun +u3we_ripe(u3_noun cor) +{ + u3_noun msg; /* hash */ + + fprintf(stderr, "HERE\n\r"); + + if ( (c3n == u3r_mean(cor, + u3x_sam_1, &msg, + 0)) || + (c3n == u3du(msg)) ) + { + fprintf(stderr, "\rripe jet: argument error\n"); + return u3m_bail(c3__exit); + } else { + return u3qe_ripe(msg); + } +} diff --git a/jets/tree.c b/jets/tree.c index 3f17b3106..6564a42ab 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -103,6 +103,21 @@ static u3j_core _143_hex_coed_d[] = {} }; + static u3j_harm _143_hex_blake2b_a[] = {{".2", u3we_blake, c3y}, {}}; + + static u3j_core _143_hex_blake_d[] = + { { "blake2b", _143_hex_blake2b_a }, + {} + }; + + static u3j_harm _143_hex_ripemd_160_a[] = {{".2", u3we_ripe, c3y}, {}}; + + static u3j_core _143_hex_ripe_d[] = + { { "ripemd160", _143_hex_ripemd_160_a }, + {} + }; + + static u3j_core _143_hex_d[] = { { "down", 0, _143_hex_down_d }, { "lore", _143_hex_lore_a }, @@ -112,6 +127,8 @@ static u3j_core _143_hex_d[] = { "aes", 0, _143_hex_aes_d }, { "hmac", 0, _143_hex_hmac_d }, { "argon", 0, _143_hex_argon_d }, + { "blake2b", 0, _143_hex_blake_d }, + { "ripemd", 0, _143_hex_ripe_d }, {} }; diff --git a/meson.build b/meson.build index f145720a3..414c4cc48 100644 --- a/meson.build +++ b/meson.build @@ -105,6 +105,7 @@ jets_e_src = [ 'jets/e/aes_cbc.c', 'jets/e/aesc.c', 'jets/e/argon2.c', +'jets/e/blake.c', 'jets/e/cue.c', 'jets/e/fl.c', 'jets/e/hmac.c', @@ -125,6 +126,7 @@ jets_e_src = [ 'jets/e/loss.c', 'jets/e/lune.c', 'jets/e/trip.c' +'jets/e/ripe.c' ] jets_e_ed_src = [ From 9396f7cc22f2e82071fc6ace9a2fb91be018e5d1 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 4 Sep 2018 18:17:52 +0200 Subject: [PATCH 012/157] Remove nonstandard 27 minimum value from ecdsa signature v As per urbit/arvo/b2365db. --- jets/e/secp.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/jets/e/secp.c b/jets/e/secp.c index 3b4ded828..88c7c2ea5 100644 --- a/jets/e/secp.c +++ b/jets/e/secp.c @@ -123,7 +123,6 @@ u3qe_sign(u3_atom has, byte_reverse(rec_y + 32, s_y, 32); /* package s,r,v signature for return */ - v += 27; u3_noun s = u3i_words(8, (const c3_w*) s_y); u3_noun r = u3i_words(8, (const c3_w*) r_y); return (u3nt(v, r, s)); @@ -191,7 +190,6 @@ u3qe_reco(u3_atom has, } c3_ws siv_ws = siv_y[0]; - siv_ws -= 27; secp256k1_ecdsa_recoverable_signature sig_u; memset( (void *) & sig_u, 0, sizeof(secp256k1_ecdsa_recoverable_signature) ); c3_ws ret = secp256k1_ecdsa_recoverable_signature_parse_compact(ctx_u, /* IN: context */ From ebba09ac15a4e8845b273b436b0dfdc3a9f8647a Mon Sep 17 00:00:00 2001 From: TJamesCorcoran Date: Fri, 7 Sep 2018 14:24:56 -0400 Subject: [PATCH 013/157] code review --- jets/e/blake.c | 9 ++------- meson.build | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/jets/e/blake.c b/jets/e/blake.c index 288213d74..d6b7a9ea2 100644 --- a/jets/e/blake.c +++ b/jets/e/blake.c @@ -7,7 +7,7 @@ #include "../src/blake2/blake2.h" // `@ux`(blake2b:blake:crypto 1^0xaa 2^0xbbcc 32) - +#if 0 static void pretty_print_hex(char * headline, c3_y * ptr, c3_w num_bytes) @@ -24,7 +24,7 @@ static void pretty_print_hex(char * headline, fprintf(stderr, "\n\r"); } - +#endif u3_noun u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) @@ -52,8 +52,6 @@ u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) c3_y * mod_y = (c3_y * ) u3a_malloc(men_w); u3r_bytes(0, men, (void *) mod_y, mod); - pretty_print_hex("mod_y (message body bytes)", mod_y, men); - /* key */ @@ -78,8 +76,6 @@ u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) c3_y * kod_y = (c3_y * ) u3a_malloc(ken_w); u3r_bytes(0, ken, (void *) kod_y, kod); - pretty_print_hex("kod_y (message body bytes)", kod_y, ken); - int ret; c3_y out_y[64]; @@ -93,7 +89,6 @@ u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) /* free() BEFORE checking error code; we don't want to leak memory if we return early */ u3a_free(mod_y ); u3a_free(kod_y ); - pretty_print_hex("out", out_y, 64); if (ret != 0){ fprintf(stderr, "\rblake jet: cryto lib error\n"); diff --git a/meson.build b/meson.build index 414c4cc48..20bdcfd32 100644 --- a/meson.build +++ b/meson.build @@ -125,7 +125,7 @@ jets_e_src = [ 'jets/e/lore.c', 'jets/e/loss.c', 'jets/e/lune.c', -'jets/e/trip.c' +'jets/e/trip.c', 'jets/e/ripe.c' ] From cce78f57d4bdef13affdb606977d9d14b287f98e Mon Sep 17 00:00:00 2001 From: BernardoDeLaPlaz Date: Fri, 7 Sep 2018 14:27:14 -0400 Subject: [PATCH 014/157] code review --- jets/e/blake.c | 9 ++------- meson.build | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/jets/e/blake.c b/jets/e/blake.c index 288213d74..d6b7a9ea2 100644 --- a/jets/e/blake.c +++ b/jets/e/blake.c @@ -7,7 +7,7 @@ #include "../src/blake2/blake2.h" // `@ux`(blake2b:blake:crypto 1^0xaa 2^0xbbcc 32) - +#if 0 static void pretty_print_hex(char * headline, c3_y * ptr, c3_w num_bytes) @@ -24,7 +24,7 @@ static void pretty_print_hex(char * headline, fprintf(stderr, "\n\r"); } - +#endif u3_noun u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) @@ -52,8 +52,6 @@ u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) c3_y * mod_y = (c3_y * ) u3a_malloc(men_w); u3r_bytes(0, men, (void *) mod_y, mod); - pretty_print_hex("mod_y (message body bytes)", mod_y, men); - /* key */ @@ -78,8 +76,6 @@ u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) c3_y * kod_y = (c3_y * ) u3a_malloc(ken_w); u3r_bytes(0, ken, (void *) kod_y, kod); - pretty_print_hex("kod_y (message body bytes)", kod_y, ken); - int ret; c3_y out_y[64]; @@ -93,7 +89,6 @@ u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) /* free() BEFORE checking error code; we don't want to leak memory if we return early */ u3a_free(mod_y ); u3a_free(kod_y ); - pretty_print_hex("out", out_y, 64); if (ret != 0){ fprintf(stderr, "\rblake jet: cryto lib error\n"); diff --git a/meson.build b/meson.build index 414c4cc48..20bdcfd32 100644 --- a/meson.build +++ b/meson.build @@ -125,7 +125,7 @@ jets_e_src = [ 'jets/e/lore.c', 'jets/e/loss.c', 'jets/e/lune.c', -'jets/e/trip.c' +'jets/e/trip.c', 'jets/e/ripe.c' ] From 179c49429a48bac917cf411b021a3f5c199853ee Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 4 Nov 2018 09:44:53 -0800 Subject: [PATCH 015/157] Use u3a_malloc instead of c3_malloc --- jets/e/sha1.c | 6 ++---- jets/e/shax.c | 12 ++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/jets/e/sha1.c b/jets/e/sha1.c index 32aeb7da9..231968ee8 100644 --- a/jets/e/sha1.c +++ b/jets/e/sha1.c @@ -20,9 +20,7 @@ c3_assert(_(u3a_is_cat(wid))); dat = u3qc_rev(3, wid, dat); - //NOTE XX fixme we shouldn't c3_malloc in inner road, - // this is also done in other SHA jets - c3_y* fat_y = c3_malloc(wid + 1); + c3_y* fat_y = u3a_malloc(wid + 1); u3r_bytes(0, wid, fat_y, dat); { c3_y dig_y[32]; @@ -39,7 +37,7 @@ SHA1_Update(&ctx_h, fat_y, wid); SHA1_Final(dig_y, &ctx_h); #endif - free(fat_y); + u3a_free(fat_y); u3z(dat); return u3kc_rev(3, 20, u3i_bytes(20, dig_y)); } diff --git a/jets/e/shax.c b/jets/e/shax.c index 3d186c940..927dbb733 100644 --- a/jets/e/shax.c +++ b/jets/e/shax.c @@ -18,7 +18,7 @@ u3_atom b) { c3_assert(_(u3a_is_cat(a))); - c3_y* fat_y = c3_malloc(a + 1); + c3_y* fat_y = u3a_malloc(a + 1); u3r_bytes(0, a, fat_y, b); { @@ -36,7 +36,7 @@ SHA256_Update(&ctx_h, fat_y, a); SHA256_Final(dig_y, &ctx_h); #endif - free(fat_y); + u3a_free(fat_y); return u3i_bytes(32, dig_y); } } @@ -53,7 +53,7 @@ u3_noun u3qe_shax(u3_atom a) { c3_w met_w = u3r_met(3, a); - c3_y* fat_y = c3_malloc(met_w + 1); + c3_y* fat_y = u3a_malloc(met_w + 1); u3r_bytes(0, met_w, fat_y, a); { @@ -71,7 +71,7 @@ u3_noun SHA256_Update(&ctx_h, fat_y, met_w); SHA256_Final(dig_y, &ctx_h); #endif - free(fat_y); + u3a_free(fat_y); return u3i_bytes(32, dig_y); } } @@ -83,7 +83,7 @@ u3_noun u3_atom b) { c3_assert(_(u3a_is_cat(a))); - c3_y* fat_y = c3_malloc(a + 1); + c3_y* fat_y = u3a_malloc(a + 1); u3r_bytes(0, a, fat_y, b); { @@ -101,7 +101,7 @@ u3_noun SHA512_Update(&ctx_h, fat_y, a); SHA512_Final(dig_y, &ctx_h); #endif - free(fat_y); + u3a_free(fat_y); return u3i_bytes(64, dig_y); } } From 451bc588da404a0e596fd886dc91878455e01684 Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 4 Nov 2018 09:55:25 -0800 Subject: [PATCH 016/157] Make blake adhere to desired output length And makes sure to return in the correct byte order. --- jets/e/blake.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jets/e/blake.c b/jets/e/blake.c index d6b7a9ea2..4bdc67e87 100644 --- a/jets/e/blake.c +++ b/jets/e/blake.c @@ -29,7 +29,9 @@ static void pretty_print_hex(char * headline, u3_noun u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) { - /* msg + c3_assert(_(u3a_is_cat(out))); + + /* msg */ u3_noun men; /* msg length */ u3_noun mod; /* msg body */ @@ -80,7 +82,7 @@ u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) int ret; c3_y out_y[64]; ret = blake2b(out_y, // OUT: output - (size_t) 64, // IN: max output size + out, // IN: max output size mod_y, // IN: msg body men_w, // IN: msg len kod_y, // IN: key body @@ -95,9 +97,7 @@ u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) return u3m_bail(c3__exit); } - u3_noun sig = u3i_bytes(64, out_y); - - return(sig); + return(u3kc_rev(3, out, u3i_bytes(out, out_y))); } From ce8779c929739b868d30c755c711bb3a938bc4f7 Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 4 Nov 2018 11:40:14 -0800 Subject: [PATCH 017/157] Clean up argon2 jet config params unpacking --- jets/e/argon2.c | 53 ++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/jets/e/argon2.c b/jets/e/argon2.c index 896b1f5d5..9b436924b 100644 --- a/jets/e/argon2.c +++ b/jets/e/argon2.c @@ -95,44 +95,29 @@ threads, mem_cost, time_cost, wik, key, wix, extra, // input params - wid, dat, wis, sat; + wid, dat, wis, sat, + // for use during unpacking + wmsg, wsat, arg, brg, wkey, wext; // the hoon code for argon2 takes configuration parameters, // and then produces a gate. we jet that inner gate. // this does mean that the config params have gotten buried - // pretty deep in the subject, so we have to use large - // tree addresses to get at them. - if ( (c3n == u3r_mean(cor, u3x_sam_4, &wid, - u3x_sam_5, &dat, - u3x_sam_6, &wis, - u3x_sam_7, &sat, - // - 1020, &out, - 2042, &type, - 4086, &version, - // - 8174, &threads, - 16350, &mem_cost, - 32702, &time_cost, - // - 130812, &wik, - 130813, &key, - 130814, &wix, - 130815, &extra, 0)) || - (c3n == u3ud(out)) || - (c3n == u3ud(type)) || - (c3n == u3ud(version)) || - (c3n == u3ud(threads)) || - (c3n == u3ud(mem_cost)) || - (c3n == u3ud(time_cost)) || - (c3n == u3ud(wik)) || - (c3n == u3ud(key)) || - (c3n == u3ud(wix)) || - (c3n == u3ud(extra)) || - (c3n == u3ud(wid)) || - (c3n == u3ud(dat)) || - (c3n == u3ud(wis)) || - (c3n == u3ud(sat)) + // pretty deep in the subject, hence the +510. + if ( c3n == u3r_mean(cor, u3x_sam_2, &wmsg, + u3x_sam_3, &wsat, + 510, &arg, 0) || + u3r_cell(wmsg, &wid, &dat) || u3ud(wid) || u3ud(dat) || + u3r_cell(wsat, &wis, &sat) || u3ud(wis) || u3ud(sat) || + // + u3r_qual(arg, &out, &type, &version, &brg) || + u3ud(out) || u3ud(type) || u3ud(version) || + // + u3r_qual(brg, &threads, &mem_cost, &time_cost, &arg) || + u3ud(threads) || u3ud(mem_cost) || u3ud(time_cost) || + // + u3r_cell(arg, &wkey, &wext) || + u3r_cell(wkey, &wik, &key) || u3ud(wik) || u3ud(key) || + u3r_cell(wext, &wix, &extra) || u3ud(wix) || u3ud(extra) ) { return u3m_bail(c3__exit); From a74ea050fa9d46c38070dd1709db880c4371623f Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 4 Nov 2018 11:41:24 -0800 Subject: [PATCH 018/157] Clean up style in argon2 jet --- include/c/motes.h | 1 + jets/e/argon2.c | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index 652cfa073..91392ed2b 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -559,6 +559,7 @@ # define c3__ic c3_s2('i','c') # define c3__ice c3_s3('i','c','e') # define c3__iced c3_s4('i','c','e','d') +# define c3__id c3_s2('i','d') # define c3__if c3_s2('i','f') # define c3__ifix c3_s4('i','f','i','x') # define c3__in c3_s2('i','n') diff --git a/jets/e/argon2.c b/jets/e/argon2.c index 9b436924b..fec9185ab 100644 --- a/jets/e/argon2.c +++ b/jets/e/argon2.c @@ -57,28 +57,29 @@ int argon_res; switch(type) { - case 100: // %d - argon_res = argon2d_ctx(&context); - break; + case c3__d: + argon_res = argon2d_ctx(&context); + break; // - case 105: // %i - argon_res = argon2i_ctx(&context); - break; + case c3__i: + argon_res = argon2i_ctx(&context); + break; // - case 117: // %u - argon_res = argon2u_ctx(&context); - break; + case c3__id: + argon_res = argon2id_ctx(&context); + break; // - case 25705: // %id - argon_res = argon2id_ctx(&context); - break; + case c3__u: + argon_res = argon2u_ctx(&context); + break; // - default: - fprintf(stderr, "\nunjetted argon2 variant %i\n", type); - u3m_bail(c3__exit); + default: + fprintf(stderr, "\nunjetted argon2 variant %i\n", type); + u3m_bail(c3__exit); } - if(ARGON2_OK != argon_res) { + if(ARGON2_OK != argon_res) + { fprintf(stderr, "\nargon2 error: %s\n", argon2_error_message(argon_res)); u3m_bail(c3__exit); } From 449cd080b0791fda4ee06867a859fe07c34a7171 Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 4 Nov 2018 11:42:33 -0800 Subject: [PATCH 019/157] Clean up style in blake2 jet --- jets/e/blake.c | 88 +++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/jets/e/blake.c b/jets/e/blake.c index 4bdc67e87..75efb4dea 100644 --- a/jets/e/blake.c +++ b/jets/e/blake.c @@ -6,7 +6,6 @@ #include #include "../src/blake2/blake2.h" -// `@ux`(blake2b:blake:crypto 1^0xaa 2^0xbbcc 32) #if 0 static void pretty_print_hex(char * headline, c3_y * ptr, @@ -31,68 +30,71 @@ u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) { c3_assert(_(u3a_is_cat(out))); - /* msg - */ - u3_noun men; /* msg length */ - u3_noun mod; /* msg body */ + // msg + u3_noun men; // length + u3_noun mod; // body u3r_mean(msg, - 2, &men, - 3, &mod, + 2, &men, + 3, &mod, 0); - c3_w met_w = u3r_met(3, men); /* meta length: length of the length */ + // meta length: length of the length + c3_w met_w = u3r_met(3, men); - if (met_w > 4){ + if (met_w > 4) + { fprintf(stderr, "\rblake jet: msg size size too big\n"); return u3m_bail(c3__exit); } c3_w men_w; - men_w = u3r_word(0, men); - - c3_y * mod_y = (c3_y * ) u3a_malloc(men_w); - u3r_bytes(0, men, (void *) mod_y, mod); + men_w = u3r_word(0, men); - /* key - */ + c3_y* mod_y = (c3_y*)u3a_malloc(men_w); + u3r_bytes(0, men, (void*)mod_y, mod); - u3_noun ken; /* key length */ - u3_noun kod; /* key body */ + // key + u3_noun ken; // length + u3_noun kod; // body u3r_mean(key, - 2, &ken, - 3, &kod, + 2, &ken, + 3, &kod, 0); - c3_w mek_w = u3r_met(3, ken); /* meta length: length of the length */ + // meta length: length of the length + c3_w mek_w = u3r_met(3, ken); - if (mek_w > 4){ + if (mek_w > 4) + { fprintf(stderr, "\rblake jet: key size size too big\n"); return u3m_bail(c3__exit); } c3_w ken_w; ken_w = u3r_word(0, ken); - - c3_y * kod_y = (c3_y * ) u3a_malloc(ken_w); - u3r_bytes(0, ken, (void *) kod_y, kod); - + c3_y* kod_y = (c3_y*)u3a_malloc(ken_w); + u3r_bytes(0, ken, (void*)kod_y, kod); + int ret; c3_y out_y[64]; - ret = blake2b(out_y, // OUT: output - out, // IN: max output size - mod_y, // IN: msg body - men_w, // IN: msg len - kod_y, // IN: key body - ken_w); // IN: key len + ret = blake2b(out_y, // OUT: output + out, // IN: max output size + mod_y, // IN: msg body + men_w, // IN: msg len + kod_y, // IN: key body + ken_w); // IN: key len - /* free() BEFORE checking error code; we don't want to leak memory if we return early */ - u3a_free(mod_y ); - u3a_free(kod_y ); + /* free() BEFORE checking error code; + we don't want to leak memory if we return early + */ + u3a_free(mod_y); + u3a_free(kod_y); - if (ret != 0){ + if (ret != 0) + { fprintf(stderr, "\rblake jet: cryto lib error\n"); return u3m_bail(c3__exit); } @@ -108,19 +110,17 @@ u3we_blake(u3_noun cor) u3_noun msg, byt, out; if ( (c3n == u3r_mean(cor, - u3x_sam_2, &msg, - u3x_sam_6, &byt, - u3x_sam_7, &out, + u3x_sam_2, &msg, + u3x_sam_6, &byt, + u3x_sam_7, &out, 0)) || (c3n == u3du(msg)) || (c3n == u3du(byt)) || (c3n == u3ud(out)) ) - { - fprintf(stderr, "\rblake jet: arguments error\n\r\n\r"); - return u3m_bail(c3__exit); - } else { + { + fprintf(stderr, "\rblake jet: arguments error\n"); + return u3m_bail(c3__exit); + } else { return u3qe_blake(msg, byt, out); } - - return(99); } From 1978fc9b0560b3048e2e111d4df1793873c18414 Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 4 Nov 2018 12:23:24 -0800 Subject: [PATCH 020/157] Fix ripe jet, treat input as byts rather than bits Unpack input in u3we version, assume byts, don't check for multiple of eight bits. --- include/jets/q.h | 2 +- jets/e/ripe.c | 66 +++++++++++++----------------------------------- 2 files changed, 18 insertions(+), 50 deletions(-) diff --git a/include/jets/q.h b/include/jets/q.h index e0bc6028d..779234578 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -147,7 +147,7 @@ u3_noun u3qe_blake(u3_atom msg, u3_atom key, u3_atom out); - u3_noun u3qe_ripe(u3_atom byts); + u3_noun u3qe_ripe(u3_atom wid, u3_atom dat); u3_noun u3qe_make(u3_atom has, u3_atom prv); u3_noun u3qe_reco(u3_atom has, u3_atom sig_v, u3_atom sig_r, u3_atom sig_s); diff --git a/jets/e/ripe.c b/jets/e/ripe.c index 43090d4ef..dec5306f9 100644 --- a/jets/e/ripe.c +++ b/jets/e/ripe.c @@ -21,47 +21,13 @@ static void byte_reverse_in_place(c3_y *c_y, /* in */ u3_noun -u3qe_ripe(u3_atom msg) +u3qe_ripe(u3_atom wid, u3_atom dat) { + c3_assert(_(u3a_is_cat(wid))); + dat = u3qc_rev(3, wid, dat); - /* decompose - input - */ - - u3_noun men; /* msg length */ - u3_noun mod; /* msg body */ - - u3r_mean(msg, - 2, & men, - 3, & mod, - 0); - - c3_w met_w = u3r_met(3, men); /* meta length: length of the length */ - - if (met_w > 4){ - fprintf(stderr, "\rripe jet: msg meta-size too big\n"); - return u3m_bail(c3__exit); - } - - c3_w men_w; /* msg length in bits */ - men_w = u3r_word(0, men); - - if (0 != men_w % 8) { - fprintf(stderr, "\rripe jet: input size was not an even number of bytesn"); - return u3m_bail(c3__exit); - } - men_w = men_w / 8; - - - c3_y * mod_y = (c3_y * ) u3a_malloc(men_w); /* msg body */ - u3r_bytes(0, men, (void *) mod_y, mod); - - /* endian - convert - input - */ - - byte_reverse_in_place(mod_y, men_w); + c3_y * dat_y = (c3_y * ) u3a_malloc(wid); /* msg body */ + u3r_bytes(0, wid, (void *) dat_y, dat); const EVP_MD *rip_u = EVP_ripemd160(); /* ripem algorithm */ EVP_MD_CTX * con_u = NULL; /* context */ @@ -82,15 +48,15 @@ u3qe_ripe(u3_atom msg) ret_w = EVP_DigestInit_ex (con_u, rip_u, NULL); if (ret_w != 1) { - u3a_free(mod_y ); + u3a_free(dat_y ); fprintf(stderr, "\rripe jet: crypto library fail 1\n"); return u3m_bail(c3__exit); } - - ret_w = EVP_DigestUpdate (con_u, (void *) mod_y, men_w); - u3a_free(mod_y ); - + ret_w = EVP_DigestUpdate (con_u, (void *) dat_y, wid); + + u3a_free(dat_y ); + if (ret_w != 1) { fprintf(stderr, "\rripe jet: crypto library fail 2\n"); return u3m_bail(c3__exit); @@ -115,18 +81,20 @@ u3qe_ripe(u3_atom msg) u3_noun u3we_ripe(u3_noun cor) { - u3_noun msg; /* hash */ + u3_noun wid, dat; fprintf(stderr, "HERE\n\r"); if ( (c3n == u3r_mean(cor, - u3x_sam_1, &msg, - 0)) || - (c3n == u3du(msg)) ) + u3x_sam_2, &wid, + u3x_sam_3, &dat, + 0) || + u3ud(wid) || u3ud(dat)) + ) { fprintf(stderr, "\rripe jet: argument error\n"); return u3m_bail(c3__exit); } else { - return u3qe_ripe(msg); + return u3qe_ripe(wid, dat); } } From ee02677cf27e5d1b221826ce1519b940c93f0a61 Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 4 Nov 2018 12:51:49 -0800 Subject: [PATCH 021/157] Clean up style in ripe jet --- jets/e/ripe.c | 92 ++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 56 deletions(-) diff --git a/jets/e/ripe.c b/jets/e/ripe.c index dec5306f9..6b666f06a 100644 --- a/jets/e/ripe.c +++ b/jets/e/ripe.c @@ -4,77 +4,61 @@ #include "all.h" #include -static void byte_reverse_in_place(c3_y *c_y, /* in */ - c3_w n_w) /* size */ -{ - c3_w i_w; - - for (i_w = 0; i_w < (n_w / 2) ; i_w++) { - c3_y lo = c_y[i_w]; - c3_y hi = c_y[n_w - i_w - 1]; - c_y[i_w] = hi; - c_y[n_w - i_w - 1] = lo; - } - -} - - - u3_noun u3qe_ripe(u3_atom wid, u3_atom dat) { c3_assert(_(u3a_is_cat(wid))); dat = u3qc_rev(3, wid, dat); - c3_y * dat_y = (c3_y * ) u3a_malloc(wid); /* msg body */ - u3r_bytes(0, wid, (void *) dat_y, dat); + c3_y* dat_y = (c3_y*)u3a_malloc(wid); // msg body + u3r_bytes(0, wid, (void*)dat_y, dat); - const EVP_MD *rip_u = EVP_ripemd160(); /* ripem algorithm */ - EVP_MD_CTX * con_u = NULL; /* context */ + const EVP_MD* rip_u = EVP_ripemd160(); // ripem algorithm + EVP_MD_CTX* con_u = NULL; // context /* build library context object - once (and only once) + we do this once (and only once) */ - if (NULL == con_u) { - con_u = EVP_MD_CTX_create(); - } - /* perform - signature + if (NULL == con_u) + { + con_u = EVP_MD_CTX_create(); + } + + /* perform signature */ - c3_y sib_y[20]; /* signature body */ - c3_w sil_w; /* signature length */ - c3_w ret_w; /* return code */ - - ret_w = EVP_DigestInit_ex (con_u, rip_u, NULL); - if (ret_w != 1) { - u3a_free(dat_y ); + + c3_y sib_y[20]; // signature body + c3_w sil_w; // signature length + c3_w ret_w; // return code + + ret_w = EVP_DigestInit_ex(con_u, rip_u, NULL); + if (ret_w != 1) + { + u3a_free(dat_y); fprintf(stderr, "\rripe jet: crypto library fail 1\n"); return u3m_bail(c3__exit); } - ret_w = EVP_DigestUpdate (con_u, (void *) dat_y, wid); - - u3a_free(dat_y ); - - if (ret_w != 1) { + ret_w = EVP_DigestUpdate(con_u, (void*)dat_y, wid); + u3a_free(dat_y); + if (ret_w != 1) + { fprintf(stderr, "\rripe jet: crypto library fail 2\n"); return u3m_bail(c3__exit); } - ret_w = EVP_DigestFinal_ex (con_u, sib_y, &sil_w); - if (ret_w != 1) { + + ret_w = EVP_DigestFinal_ex(con_u, sib_y, &sil_w); + if (ret_w != 1) + { fprintf(stderr, "\rripe jet: crypto library fail 3\n"); return u3m_bail(c3__exit); } - /* endian conversion ; + /* endian conversion; turn into noun for return */ - - byte_reverse_in_place(sib_y, 20); - u3_noun sig = u3i_bytes(sil_w, sib_y); - - return(sig); + return(u3kc_rev(3, sil_w, u3i_bytes(sil_w, sib_y))); } @@ -83,18 +67,14 @@ u3we_ripe(u3_noun cor) { u3_noun wid, dat; - fprintf(stderr, "HERE\n\r"); - - if ( (c3n == u3r_mean(cor, - u3x_sam_2, &wid, - u3x_sam_3, &dat, - 0) || + if ( (c3n == u3r_mean(cor, u3x_sam_2, &wid, + u3x_sam_3, &dat, 0) || u3ud(wid) || u3ud(dat)) ) - { - fprintf(stderr, "\rripe jet: argument error\n"); - return u3m_bail(c3__exit); - } else { + { + fprintf(stderr, "\rripe jet: argument error\n"); + return u3m_bail(c3__exit); + } else { return u3qe_ripe(wid, dat); } } From b11b8c1460b8d3ef5261e280477acc2d1e52c2d6 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 6 Nov 2018 14:50:46 -0800 Subject: [PATCH 022/157] Make pointer to ripe context static --- jets/e/ripe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jets/e/ripe.c b/jets/e/ripe.c index 6b666f06a..0423e3434 100644 --- a/jets/e/ripe.c +++ b/jets/e/ripe.c @@ -14,7 +14,7 @@ u3qe_ripe(u3_atom wid, u3_atom dat) u3r_bytes(0, wid, (void*)dat_y, dat); const EVP_MD* rip_u = EVP_ripemd160(); // ripem algorithm - EVP_MD_CTX* con_u = NULL; // context + static EVP_MD_CTX* con_u = NULL; // context /* build library context object we do this once (and only once) From 32bbb0214068ef606d0fa2f8f4a7b3b14637e929 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 6 Nov 2018 15:32:56 -0800 Subject: [PATCH 023/157] Unpack blake jet arguments earlier, make sure to flip endianness --- include/jets/q.h | 3 +- jets/e/blake.c | 90 +++++++++++++++--------------------------------- 2 files changed, 29 insertions(+), 64 deletions(-) diff --git a/include/jets/q.h b/include/jets/q.h index 779234578..3214e8533 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -145,7 +145,8 @@ u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom, u3_atom); - u3_noun u3qe_blake(u3_atom msg, u3_atom key, u3_atom out); + u3_noun u3qe_blake(u3_atom wid, u3_atom dat, + u3_atom wik, u3_atom dak, u3_atom out); u3_noun u3qe_ripe(u3_atom wid, u3_atom dat); diff --git a/jets/e/blake.c b/jets/e/blake.c index 75efb4dea..b0f6ed436 100644 --- a/jets/e/blake.c +++ b/jets/e/blake.c @@ -26,72 +26,36 @@ static void pretty_print_hex(char * headline, #endif u3_noun -u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) +u3qe_blake(u3_atom wid, u3_atom dat, + u3_atom wik, u3_atom dak, + u3_atom out) { - c3_assert(_(u3a_is_cat(out))); + c3_assert(_(u3a_is_cat(wid)) && _(u3a_is_cat(wik)) && _(u3a_is_cat(out))); - // msg - u3_noun men; // length - u3_noun mod; // body + // flip endianness for the internal blake2b function + dat = u3qc_rev(3, wid, dat); + dak = u3qc_rev(3, wik, dak); - u3r_mean(msg, - 2, &men, - 3, &mod, - 0); + c3_y* dat_y = (c3_y*)u3a_malloc(wid); + u3r_bytes(0, wid, (void*)dat_y, dat); - // meta length: length of the length - c3_w met_w = u3r_met(3, men); - - if (met_w > 4) - { - fprintf(stderr, "\rblake jet: msg size size too big\n"); - return u3m_bail(c3__exit); - } - - c3_w men_w; - men_w = u3r_word(0, men); - - c3_y* mod_y = (c3_y*)u3a_malloc(men_w); - u3r_bytes(0, men, (void*)mod_y, mod); - - // key - u3_noun ken; // length - u3_noun kod; // body - - u3r_mean(key, - 2, &ken, - 3, &kod, - 0); - - // meta length: length of the length - c3_w mek_w = u3r_met(3, ken); - - if (mek_w > 4) - { - fprintf(stderr, "\rblake jet: key size size too big\n"); - return u3m_bail(c3__exit); - } - - c3_w ken_w; - ken_w = u3r_word(0, ken); - - c3_y* kod_y = (c3_y*)u3a_malloc(ken_w); - u3r_bytes(0, ken, (void*)kod_y, kod); + c3_y* dak_y = (c3_y*)u3a_malloc(wik); + u3r_bytes(0, wik, (void*)dak_y, dak); int ret; c3_y out_y[64]; ret = blake2b(out_y, // OUT: output out, // IN: max output size - mod_y, // IN: msg body - men_w, // IN: msg len - kod_y, // IN: key body - ken_w); // IN: key len + dat_y, // IN: msg body + wid, // IN: msg len + dak_y, // IN: key body + wik); // IN: key len /* free() BEFORE checking error code; we don't want to leak memory if we return early */ - u3a_free(mod_y); - u3a_free(kod_y); + u3a_free(dat_y); + u3a_free(dak_y); if (ret != 0) { @@ -107,20 +71,20 @@ u3qe_blake(u3_atom msg, u3_atom key, u3_atom out) u3_noun u3we_blake(u3_noun cor) { - u3_noun msg, byt, out; + u3_noun msg, key, out, // arguments + wid, dat, // destructured msg + wik, dak; // destructured key - if ( (c3n == u3r_mean(cor, - u3x_sam_2, &msg, - u3x_sam_6, &byt, - u3x_sam_7, &out, - 0)) || - (c3n == u3du(msg)) || - (c3n == u3du(byt)) || - (c3n == u3ud(out)) ) + if ( c3n == u3r_mean(cor, u3x_sam_2, &msg, + u3x_sam_6, &key, + u3x_sam_7, &out, 0) || + u3r_cell(msg, &wid, &dat) || u3ud(wid) || u3ud(dat) || + u3r_cell(key, &wik, &dak) || u3ud(wik) || u3ud(dak) || + u3ud(out) ) { fprintf(stderr, "\rblake jet: arguments error\n"); return u3m_bail(c3__exit); } else { - return u3qe_blake(msg, byt, out); + return u3qe_blake(wid, dat, wik, dak, out); } } From 84e610fb0a68946b94f95765a86538a501e1e7bc Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 6 Nov 2018 16:52:16 -0800 Subject: [PATCH 024/157] Pin arvo commit with crypto tests --- .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 0f6ede735..36a690f13 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -6deeb7dee9f3d47e4458fac3a0518dcde429ef73 \ No newline at end of file +6298a94729de53dfe4d0336e24df86f122325b4a \ No newline at end of file From 068bf90e01d86110421a9cc23c918a04a10d1905 Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Tue, 6 Nov 2018 19:56:48 -0800 Subject: [PATCH 025/157] Build with nix on OSX and Linux --- scripts/bootstrap | 2 +- scripts/build | 2 +- scripts/nixbuild | 3 +++ shell.nix | 16 ++++++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100755 scripts/nixbuild create mode 100644 shell.nix diff --git a/scripts/bootstrap b/scripts/bootstrap index 4ac72fa7b..3a8a74e56 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash git submodule init git submodule update diff --git a/scripts/build b/scripts/build index bf5353f54..ccc472cb7 100755 --- a/scripts/build +++ b/scripts/build @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash mkdir ./build &> /dev/null meson . ./build --buildtype=release diff --git a/scripts/nixbuild b/scripts/nixbuild new file mode 100755 index 000000000..20ec10055 --- /dev/null +++ b/scripts/nixbuild @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +nix-shell --pure --run ./scripts/build diff --git a/shell.nix b/shell.nix new file mode 100644 index 000000000..817082edc --- /dev/null +++ b/shell.nix @@ -0,0 +1,16 @@ +with (import {}); + +let + + osxdeps = lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ + Cocoa + CoreServices + ]); + + deps = [ cmark curl gcc gmp libsigsegv meson ncurses ninja pkgconfig zlib re2c ]; + +in stdenv.mkDerivation { + name = "urbit"; + buildInputs = osxdeps ++ deps; + NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-framework CoreServices"; +} From 856f854a5e6007ed6414377ebdd3b84d9f72b9ea Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Wed, 7 Nov 2018 08:23:50 -0800 Subject: [PATCH 026/157] Disable hardcoding of brew's openssl paths for nix builds. --- meson.build | 2 +- meson_options.txt | 2 ++ scripts/build | 2 +- scripts/nixbuild | 2 +- shell.nix | 2 +- subprojects/libh2o | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 4cefeff2f..65aabcbcb 100644 --- a/meson.build +++ b/meson.build @@ -323,7 +323,7 @@ configure_file(input : 'include/config.h.in', # We expect these libs to supplied with the distribution curl_dep = dependency('libcurl', version: '>=7.35.0') -if osdet == 'darwin' +if osdet == 'darwin' and not get_option('nix') libcrypto = meson.get_compiler('c').find_library('crypto', dirs: [ '/usr/local/opt/openssl/lib/' ]) libssl = meson.get_compiler('c').find_library('ssl', dirs: [ '/usr/local/opt/openssl/lib/' ]) openssl_dep = declare_dependency(dependencies: [libcrypto, libssl], include_directories: include_directories('/usr/local/opt/openssl/include')) diff --git a/meson_options.txt b/meson_options.txt index a4dd84385..0785290ba 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,3 +2,5 @@ option('gc', type : 'boolean', value : false, description : 'Add debugging information to heap. Run with -g. Breaks image.') option('prof', type : 'boolean', value : false, description : 'Activate profiling. Run with -P.') +option('nix', type: 'boolean', value: false, + description: 'Build using nix.') diff --git a/scripts/build b/scripts/build index ccc472cb7..879618f28 100755 --- a/scripts/build +++ b/scripts/build @@ -1,5 +1,5 @@ #!/usr/bin/env bash mkdir ./build &> /dev/null -meson . ./build --buildtype=release +meson . ./build --buildtype=release "$@" ninja -C build diff --git a/scripts/nixbuild b/scripts/nixbuild index 20ec10055..61308f346 100755 --- a/scripts/nixbuild +++ b/scripts/nixbuild @@ -1,3 +1,3 @@ #!/usr/bin/env bash -nix-shell --pure --run ./scripts/build +nix-shell --pure --run './scripts/build -Dnix=true' diff --git a/shell.nix b/shell.nix index 817082edc..4b00a889f 100644 --- a/shell.nix +++ b/shell.nix @@ -7,7 +7,7 @@ let CoreServices ]); - deps = [ cmark curl gcc gmp libsigsegv meson ncurses ninja pkgconfig zlib re2c ]; + deps = [ cmark curl gcc gmp libsigsegv meson ncurses ninja pkgconfig zlib re2c openssl ]; in stdenv.mkDerivation { name = "urbit"; diff --git a/subprojects/libh2o b/subprojects/libh2o index 41958a8ae..23192118e 160000 --- a/subprojects/libh2o +++ b/subprojects/libh2o @@ -1 +1 @@ -Subproject commit 41958a8aedb3aa2a85332bc8ac0ac389aa725a09 +Subproject commit 23192118e5ae1a4ebb4e1078f83cc0527b4eb080 From c8e59c8d925445b3ebe49b044676ed396b68ce49 Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Wed, 7 Nov 2018 11:12:28 -0800 Subject: [PATCH 027/157] Pin nixpkgs to a specific git commit to prevent future breakage. --- .gitmodules | 3 +++ nixpkgs | 1 + shell.nix | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 160000 nixpkgs diff --git a/.gitmodules b/.gitmodules index baaaf9ff3..1843a5f08 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule "subprojects/libsni"] path = subprojects/libsni url = https://github.com/urbit/sniproxy +[submodule "nixpkgs"] + path = nixpkgs + url = https://github.com/NixOS/nixpkgs.git diff --git a/nixpkgs b/nixpkgs new file mode 160000 index 000000000..865cbd380 --- /dev/null +++ b/nixpkgs @@ -0,0 +1 @@ +Subproject commit 865cbd380d2568806c6e46c9a4bc746af7ec13c9 diff --git a/shell.nix b/shell.nix index 4b00a889f..559a73108 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,4 @@ -with (import {}); +with (import ./nixpkgs {}); let From 42c1be0fd10ef548d4adf6c72538fe10361537f9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 7 Nov 2018 14:38:59 -0500 Subject: [PATCH 028/157] [CI] fix deploy phase, move coredump backtrace to a script --- .travis.yml | 24 ++++++++++-------------- .travis/print-core-backtrace.sh | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 .travis/print-core-backtrace.sh diff --git a/.travis.yml b/.travis.yml index cc27f8f22..a21184c22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,20 +2,6 @@ language: node_js node_js: - 4 -script: - - meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true - - cd ./build - - ninja - - sudo ninja install - - cd ../.travis - - ulimit -c unlimited -S - - npm install - # || true so we continue - - npm run -s test || RESULT=$? - - if [[ ${RESULT} -eq 0 ]]; then exit 0; else for i in $(find ./ -maxdepth 1 -name 'core*' -print); do gdb urbit core* -ex "thread apply all bt" -ex "set pagination 0" -batch; done; fi; - - echo "build failed with status code $RESULT" - - exit $RESULT - # Uncomment me if this gets annoying # # notifications: @@ -34,6 +20,16 @@ install: - git checkout $(cat ../.travis/pin-arvo-commit.txt) - cd .. +script: + - meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true + - cd ./build + - ninja + - sudo ninja install + - cd ../.travis + - npm install + - ulimit -c unlimited -S + - npm run -s test; bash print-core-backtrace.sh $? + addons: apt: packages: diff --git a/.travis/print-core-backtrace.sh b/.travis/print-core-backtrace.sh new file mode 100644 index 000000000..52b421525 --- /dev/null +++ b/.travis/print-core-backtrace.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -euo pipefail +set -x + +RESULT=$1 + +if [[ ${RESULT} -eq 0 ]]; then + exit 0 +else + for i in $(find ./ -maxdepth 1 -name 'core*' -print) + do + gdb urbit core* -ex "thread apply all bt" -ex "set pagination 0" -batch + done +fi + +echo "build failed with status code $RESULT" +exit $RESULT From e715eb66aae5ff5d4fa6bc0ed9ae98ccc73af2b9 Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Thu, 8 Nov 2018 11:00:00 -0800 Subject: [PATCH 029/157] Upgrade meson to 0.46.1 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cc27f8f22..f9bdc0b69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ before_install: install: # pwd: ~/urbit - - pip3 install --user -I meson==0.44.1 + - pip3 install --user -I meson==0.46.1 - git clone https://github.com/urbit/arvo - cd ./arvo - git checkout $(cat ../.travis/pin-arvo-commit.txt) From 0925e1533577322d57e6ed1d122981ff15edcca7 Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Thu, 8 Nov 2018 11:10:00 -0800 Subject: [PATCH 030/157] Use python 3.5 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f9bdc0b69..6758ed9e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: node_js node_js: - 4 +python: "3.5" script: - meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true From 088156c197e8f7aa2cd8f5a05a3e36ca54e251df Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Thu, 8 Nov 2018 11:28:54 -0800 Subject: [PATCH 031/157] Do the build on CI using nix. --- .travis.yml | 46 +++------------------------------------------- scripts/cibuild | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 43 deletions(-) create mode 100755 scripts/cibuild diff --git a/.travis.yml b/.travis.yml index 6758ed9e9..a901f00ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,60 +1,20 @@ -language: node_js -node_js: -- 4 -python: "3.5" +language: nix +nix: 2.1.3 script: - - meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true - - cd ./build - - ninja - - sudo ninja install - - cd ../.travis - - ulimit -c unlimited -S - - npm install - # || true so we continue - - npm run -s test || RESULT=$? - - if [[ ${RESULT} -eq 0 ]]; then exit 0; else for i in $(find ./ -maxdepth 1 -name 'core*' -print); do gdb urbit core* -ex "thread apply all bt" -ex "set pagination 0" -batch; done; fi; - - echo "build failed with status code $RESULT" - - exit $RESULT + - nix-shell --pure --run './scripts/cibuild -Dnix=true' # Uncomment me if this gets annoying # # notifications: # email: false -before_install: - - wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip - - unzip ninja-linux.zip - - sudo mv ninja /usr/bin/ - install: - # pwd: ~/urbit - - pip3 install --user -I meson==0.46.1 - git clone https://github.com/urbit/arvo - cd ./arvo - git checkout $(cat ../.travis/pin-arvo-commit.txt) - cd .. -addons: - apt: - packages: - - python3 - - python3-pip - - libgmp3-dev - - libsigsegv-dev - - openssl - - libssl-dev - - libncurses5-dev - - automake - - autoconf - - make - - libtool - - g++ - - re2c - - libcurl4-gnutls-dev - - unzip - - gdb -# before_deploy: "make deb" # TODO deploy: skip_cleanup: true provider: releases diff --git a/scripts/cibuild b/scripts/cibuild new file mode 100755 index 000000000..7ec2adc77 --- /dev/null +++ b/scripts/cibuild @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -ex + +meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true "$@" + +cd ./build + +ninja || true + +sudo ninja install + +cd ../.travis + +ulimit -c unlimited -S + +npm install + +npm run -s test || RESULT=$? + +[[ ${RESULT} -eq 0 ]] && exit 0 + +for i in $(find ./ -maxdepth 1 -name 'core*' -print) +do gdb urbit core* -ex "thread apply all bt" -ex "set pagination 0" -batch +done + +echo "build failed with status code $RESULT" + +exit $RESULT From f632fbc5cb04816c8b60f643fab958cc6f259835 Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Thu, 8 Nov 2018 13:11:43 -0800 Subject: [PATCH 032/157] Do not use nixpkgs as a submodule. --- .gitmodules | 3 --- default.nix | 38 ++++++++++++++++++++++++++++++++++++++ nixpkgs | 1 - shell.nix | 16 ---------------- 4 files changed, 38 insertions(+), 20 deletions(-) create mode 100644 default.nix delete mode 160000 nixpkgs delete mode 100644 shell.nix diff --git a/.gitmodules b/.gitmodules index 1843a5f08..baaaf9ff3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,6 +22,3 @@ [submodule "subprojects/libsni"] path = subprojects/libsni url = https://github.com/urbit/sniproxy -[submodule "nixpkgs"] - path = nixpkgs - url = https://github.com/NixOS/nixpkgs.git diff --git a/default.nix b/default.nix new file mode 100644 index 000000000..bbfa72776 --- /dev/null +++ b/default.nix @@ -0,0 +1,38 @@ +let + + # In order to get the hash of another tarball, run: `nix-prefetch-url --unpack ` + pkgs = + builtins.fetchTarball { + name = "nixpkgs-2018-10-07"; + url = https://github.com/nixos/nixpkgs/archive/865cbd380d2568806c6e46c9a4bc746af7ec13c9.tar.gz; + sha256 = "0r3gj1rci2ag6k8g5wcz1m4l6brvzgbfz92kpl74mrh7kjdy1m3p"; + }; + +in + + with (import pkgs {}); + +let + + osxdeps = lib.optionals stdenv.isDarwin ( + with darwin.apple_sdk.frameworks; + [ Cocoa CoreServices ]); + + deps = [ cmark curl gcc gmp libsigsegv meson ncurses ninja pkgconfig zlib + re2c openssl ]; + + isGitDir = (path: type: type != "directory" || baseNameOf path != ".git"); + +in + + stdenv.mkDerivation { + name = "urbit"; + + src = builtins.filterSource isGitDir ./.; + + buildInputs = osxdeps ++ deps; + + mesonFlags = "-Dnix=true"; + + NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-framework CoreServices"; + } diff --git a/nixpkgs b/nixpkgs deleted file mode 160000 index 865cbd380..000000000 --- a/nixpkgs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 865cbd380d2568806c6e46c9a4bc746af7ec13c9 diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 559a73108..000000000 --- a/shell.nix +++ /dev/null @@ -1,16 +0,0 @@ -with (import ./nixpkgs {}); - -let - - osxdeps = lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ - Cocoa - CoreServices - ]); - - deps = [ cmark curl gcc gmp libsigsegv meson ncurses ninja pkgconfig zlib re2c openssl ]; - -in stdenv.mkDerivation { - name = "urbit"; - buildInputs = osxdeps ++ deps; - NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-framework CoreServices"; -} From 129ef276317964733ff48e4dc80eab0281c61b0c Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Thu, 8 Nov 2018 15:37:54 -0800 Subject: [PATCH 033/157] Disable attempt at using nix for CI builds. --- .travis.yml | 45 +++++++++++++++++++-- nix-experiment/.travis-nix.yml | 27 +++++++++++++ {scripts => nix-experiment/scripts}/cibuild | 0 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 nix-experiment/.travis-nix.yml rename {scripts => nix-experiment/scripts}/cibuild (100%) diff --git a/.travis.yml b/.travis.yml index a901f00ea..f9bdc0b69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,59 @@ -language: nix -nix: 2.1.3 +language: node_js +node_js: +- 4 script: - - nix-shell --pure --run './scripts/cibuild -Dnix=true' + - meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true + - cd ./build + - ninja + - sudo ninja install + - cd ../.travis + - ulimit -c unlimited -S + - npm install + # || true so we continue + - npm run -s test || RESULT=$? + - if [[ ${RESULT} -eq 0 ]]; then exit 0; else for i in $(find ./ -maxdepth 1 -name 'core*' -print); do gdb urbit core* -ex "thread apply all bt" -ex "set pagination 0" -batch; done; fi; + - echo "build failed with status code $RESULT" + - exit $RESULT # Uncomment me if this gets annoying # # notifications: # email: false +before_install: + - wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip + - unzip ninja-linux.zip + - sudo mv ninja /usr/bin/ + install: + # pwd: ~/urbit + - pip3 install --user -I meson==0.46.1 - git clone https://github.com/urbit/arvo - cd ./arvo - git checkout $(cat ../.travis/pin-arvo-commit.txt) - cd .. +addons: + apt: + packages: + - python3 + - python3-pip + - libgmp3-dev + - libsigsegv-dev + - openssl + - libssl-dev + - libncurses5-dev + - automake + - autoconf + - make + - libtool + - g++ + - re2c + - libcurl4-gnutls-dev + - unzip + - gdb +# before_deploy: "make deb" # TODO deploy: skip_cleanup: true provider: releases diff --git a/nix-experiment/.travis-nix.yml b/nix-experiment/.travis-nix.yml new file mode 100644 index 000000000..a901f00ea --- /dev/null +++ b/nix-experiment/.travis-nix.yml @@ -0,0 +1,27 @@ +language: nix +nix: 2.1.3 + +script: + - nix-shell --pure --run './scripts/cibuild -Dnix=true' + +# Uncomment me if this gets annoying +# +# notifications: +# email: false + +install: + - git clone https://github.com/urbit/arvo + - cd ./arvo + - git checkout $(cat ../.travis/pin-arvo-commit.txt) + - cd .. + +deploy: + skip_cleanup: true + provider: releases + prerelease: true # turn this off for official releases + api_key: + secure: V4E7784ECSS3MO6ZIRtang9XwibDyvDYGb0MoSaP2CTlmzIAhdokr4KJFM0qM4KRaaajCdQuqi0lojgOjwdxs7e0GkAwScb33LFxQ7Chj/QkFOY7V1AnSRLR5OsXnazB0nur5aSwvcvnggQ2XW3OeF7zIvGfs9aR97SEz/xCrVE= + file: ./build/urbit # TODO upload package from before_deploy + on: + repo: urbit/urbit + tags: true diff --git a/scripts/cibuild b/nix-experiment/scripts/cibuild similarity index 100% rename from scripts/cibuild rename to nix-experiment/scripts/cibuild From 112dd96f1de4f10eda19e4eaf9d5a0b8b0691210 Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Thu, 8 Nov 2018 15:56:10 -0800 Subject: [PATCH 034/157] Removed the nix-experiment directory. --- nix-experiment/.travis-nix.yml | 27 --------------------------- nix-experiment/scripts/cibuild | 29 ----------------------------- 2 files changed, 56 deletions(-) delete mode 100644 nix-experiment/.travis-nix.yml delete mode 100755 nix-experiment/scripts/cibuild diff --git a/nix-experiment/.travis-nix.yml b/nix-experiment/.travis-nix.yml deleted file mode 100644 index a901f00ea..000000000 --- a/nix-experiment/.travis-nix.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: nix -nix: 2.1.3 - -script: - - nix-shell --pure --run './scripts/cibuild -Dnix=true' - -# Uncomment me if this gets annoying -# -# notifications: -# email: false - -install: - - git clone https://github.com/urbit/arvo - - cd ./arvo - - git checkout $(cat ../.travis/pin-arvo-commit.txt) - - cd .. - -deploy: - skip_cleanup: true - provider: releases - prerelease: true # turn this off for official releases - api_key: - secure: V4E7784ECSS3MO6ZIRtang9XwibDyvDYGb0MoSaP2CTlmzIAhdokr4KJFM0qM4KRaaajCdQuqi0lojgOjwdxs7e0GkAwScb33LFxQ7Chj/QkFOY7V1AnSRLR5OsXnazB0nur5aSwvcvnggQ2XW3OeF7zIvGfs9aR97SEz/xCrVE= - file: ./build/urbit # TODO upload package from before_deploy - on: - repo: urbit/urbit - tags: true diff --git a/nix-experiment/scripts/cibuild b/nix-experiment/scripts/cibuild deleted file mode 100755 index 7ec2adc77..000000000 --- a/nix-experiment/scripts/cibuild +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true "$@" - -cd ./build - -ninja || true - -sudo ninja install - -cd ../.travis - -ulimit -c unlimited -S - -npm install - -npm run -s test || RESULT=$? - -[[ ${RESULT} -eq 0 ]] && exit 0 - -for i in $(find ./ -maxdepth 1 -name 'core*' -print) -do gdb urbit core* -ex "thread apply all bt" -ex "set pagination 0" -batch -done - -echo "build failed with status code $RESULT" - -exit $RESULT From c0726057929dc09a27c70947288b2eee7faf4793 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 8 Nov 2018 22:28:00 -0500 Subject: [PATCH 035/157] restores -H for overriding contract/snapshot ames domains --- include/vere/vere.h | 1 + vere/main.c | 11 ++++++++++- vere/sist.c | 41 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index dc5912dce..05506b86c 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -580,6 +580,7 @@ */ typedef struct _u3_opts { c3_c* arv_c; // -A, initial sync from + c3_c* dns_c; // -H, ames bootstrap domain c3_c* gen_c; // -G, czar generator c3_c* nam_c; // -n, unix hostname c3_c* pil_c; // -B, bootstrap from diff --git a/vere/main.c b/vere/main.c index 17017fe7c..c96cf8fcf 100644 --- a/vere/main.c +++ b/vere/main.c @@ -92,7 +92,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:w:u:e:E:f:F:k:l:n:p:r:NabcdgqstvxMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:w:u:e:E:f:F:k:l:n:p:r:NabcdgqstvxMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -110,6 +110,10 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.arv_c = strdup(optarg); break; } + case 'H': { + u3_Host.ops_u.dns_c = strdup(optarg); + break; + } case 'e': { u3_Host.ops_u.eth_c = strdup(optarg); break; @@ -264,6 +268,11 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.nuu = c3y; } + if ( u3_Host.ops_u.nuu != c3y && u3_Host.ops_u.dns_c != 0) { + fprintf(stderr, "-H only makes sense when bootstrapping a new instance\n"); + return c3n; + } + if ( u3_Host.ops_u.nuu != c3y && u3_Host.ops_u.pil_c != 0) { fprintf(stderr, "-B only makes sense when bootstrapping a new instance\n"); return c3n; diff --git a/vere/sist.c b/vere/sist.c index 91891a36c..9163dcd49 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1296,6 +1296,34 @@ _sist_dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) u3_lo_bail(); } +/* _sist_dawn_turf(): override contract domains with -H +*/ +static u3_noun +_sist_dawn_turf(c3_c* dns_c) +{ + u3_noun tuf; + + u3_noun par = u3v_wish("thos:de-purl:html"); + u3_noun dns = u3i_string(dns_c); + u3_noun rul = u3dc("rush", u3k(dns), u3k(par)); + + if ( (u3_nul == rul) || (c3n == u3h(u3t(rul))) ) { + fprintf(stderr, "boot: invalid domain specified with -H %s\r\n", dns_c); + // bails, won't return + u3_lo_bail(); + return u3_none; + } + else { + fprintf(stderr, "boot: overriding network domains with %s\r\n", dns_c); + u3_noun dom = u3t(u3t(rul)); + tuf = u3nc(u3k(dom), u3_nul); + } + + u3z(par); u3z(dns); u3z(rul); + + return tuf; +} + /* _sist_dawn(): produce %dawn boot card - validate keys and query contract */ static u3_noun @@ -1440,7 +1468,13 @@ _sist_dawn(u3_noun sed) { if ( c3y == u3_Host.ops_u.etn ) { zar = u3do("czar:snap:dawn", u3k(u3t(sap))); - tuf = u3do("turf:snap:dawn", u3k(u3t(sap))); + + if ( 0 != u3_Host.ops_u.dns_c ) { + tuf = _sist_dawn_turf(u3_Host.ops_u.dns_c); + } + else { + tuf = u3do("turf:snap:dawn", u3k(u3t(sap))); + } } else { { @@ -1454,7 +1488,10 @@ _sist_dawn(u3_noun sed) u3z(oct); u3z(raz); } - { + if ( 0 != u3_Host.ops_u.dns_c ) { + tuf = _sist_dawn_turf(u3_Host.ops_u.dns_c); + } + else { fprintf(stderr, "boot: retrieving network domains\r\n"); // (list turf): ames domains From 55f94d681812274eebe656319bddb8d50f00c6af Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 9 Nov 2018 10:40:02 -0800 Subject: [PATCH 036/157] fix reference handling error in _n_reap() --- noun/nock.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index adc1cf015..a0affa029 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -2457,23 +2457,27 @@ _n_prog_free(u3n_prog* pog_u) static void _n_reap(u3_noun kev) { - u3_noun fol = u3h(kev); - u3_noun got = u3t(kev); - u3_noun lof = u3a_take(fol); - u3_noun tog; - u3_weak con = u3h_get(u3R->byc.har_p, lof); - u3n_prog* pog_u = u3to(u3n_prog, got); - - if ( u3_none == con ) { - tog = u3a_outa(_n_prog_take(pog_u)); - u3h_put(u3R->byc.har_p, lof, tog); + u3_post val; + u3n_prog* pog_u = u3to(u3n_prog, u3t(kev)); + + // we must always take + u3_noun key = u3a_take(u3h(kev)); + // because u3h_git will gain the key + u3_weak got = u3h_git(u3R->byc.har_p, key); + + if ( u3_none == got ) { + val = u3a_outa(_n_prog_take(pog_u)); } else { - u3n_prog* sep_u = u3to(u3n_prog, con); + u3n_prog* sep_u = u3to(u3n_prog, got); _n_prog_take_dat(sep_u, pog_u, c3y); - tog = u3a_outa(sep_u); + val = u3a_outa(sep_u); } - u3z(lof); + // we must always put, because we have taken. + // we must always keep what we have taken, + // or we can break relocation pointers. + u3h_put(u3R->byc.har_p, key, val); + u3z(key); } /* u3n_reap(): promote bytecode state. From cfda566bf28c854ad9052ae47813a562ba342322 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 9 Nov 2018 15:54:33 -0800 Subject: [PATCH 037/157] Use latest urbit/Argon2 --- subprojects/argon2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/argon2 b/subprojects/argon2 index a936ac9e1..32497fc70 160000 --- a/subprojects/argon2 +++ b/subprojects/argon2 @@ -1 +1 @@ -Subproject commit a936ac9e132cfe1c21bcc5d851382ed5b7d60b66 +Subproject commit 32497fc70bab485b50a0f28cef51b35082ded247 From fa576b00d7112717062b58c38000c512e9566919 Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Mon, 12 Nov 2018 12:20:32 -0800 Subject: [PATCH 038/157] Implemented u3t_boff for Linux. --- noun/trace.c | 88 +++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 53 deletions(-) diff --git a/noun/trace.c b/noun/trace.c index a482b2e10..0fbe83324 100644 --- a/noun/trace.c +++ b/noun/trace.c @@ -388,58 +388,34 @@ u3t_boot(void) { if ( u3C.wag_w & u3o_debug_cpu ) { _ct_lop_o = c3n; -#if defined(U3_OS_osx) -#if 1 +#if defined(U3_OS_osx) || defined(U3_OS_linux) + // Register _ct_sigaction to be called on `SIGPROF`. { - struct itimerval itm_v; - struct sigaction sig_s; - sigset_t set; - - sig_s.__sigaction_u.__sa_handler = _ct_sigaction; - sig_s.sa_mask = 0; - sig_s.sa_flags = 0; - sigaction(SIGPROF, &sig_s, 0); - - sigemptyset(&set); - sigaddset(&set, SIGPROF); - if ( 0 != pthread_sigmask(SIG_UNBLOCK, &set, NULL) ) { - perror("pthread_sigmask"); - } - - itm_v.it_interval.tv_sec = 0; - itm_v.it_interval.tv_usec = 10000; - // itm_v.it_interval.tv_usec = 100000; - itm_v.it_value = itm_v.it_interval; - - setitimer(ITIMER_PROF, &itm_v, 0); - } -#endif -#elif defined(U3_OS_linux) - { - struct itimerval itm_v; - struct sigaction sig_s; - sigset_t set; - + struct sigaction sig_s = {0}; sig_s.sa_handler = _ct_sigaction; sigemptyset(&(sig_s.sa_mask)); - sig_s.sa_flags = 0; sigaction(SIGPROF, &sig_s, 0); + } + // Unblock `SIGPROF` for this thread (we will block it again when `u3t_boff` is called). + { + sigset_t set; sigemptyset(&set); sigaddset(&set, SIGPROF); if ( 0 != pthread_sigmask(SIG_UNBLOCK, &set, NULL) ) { perror("pthread_sigmask"); } + } - itm_v.it_interval.tv_sec = 0; + // Ask for SIGPROF to be sent every 10ms. + { + struct itimerval itm_v = {0}; itm_v.it_interval.tv_usec = 10000; - // itm_v.it_interval.tv_usec = 100000; itm_v.it_value = itm_v.it_interval; - setitimer(ITIMER_PROF, &itm_v, 0); } #elif defined(U3_OS_bsd) - // TODO: support profiling on bsd +# error "Profiling isn't yet supported on BSD" #else # error "port: profiling" #endif @@ -452,28 +428,34 @@ void u3t_boff(void) { if ( u3C.wag_w & u3o_debug_cpu ) { -#if defined(U3_OS_osx) - struct sigaction sig_s; - struct itimerval itm_v; - sigset_t set; - - sigemptyset(&set); - sigaddset(&set, SIGPROF); - if ( 0 != pthread_sigmask(SIG_BLOCK, &set, NULL) ) { - perror("pthread_sigmask"); +#if defined(U3_OS_osx) || defined(U3_OS_linux) + // Mask SIGPROF signals in this thread (and this is the only + // thread that unblocked them). + { + sigset_t set; + sigemptyset(&set); + sigaddset(&set, SIGPROF); + if ( 0 != pthread_sigmask(SIG_BLOCK, &set, NULL) ) { + perror("pthread_sigmask"); + } } - itm_v.it_interval.tv_sec = 0; - itm_v.it_interval.tv_usec = 0; - itm_v.it_value = itm_v.it_interval; + // Disable the SIGPROF timer. + { + struct itimerval itm_v = {0}; + setitimer(ITIMER_PROF, &itm_v, 0); + } - setitimer(ITIMER_PROF, &itm_v, 0); - sigaction(SIGPROF, &sig_s, 0); + // Ignore SIGPROF signals. + { + struct sigaction sig_s = {0}; + sigemptyset(&(sig_s.sa_mask)); + sig_s.sa_handler = SIG_IGN; + sigaction(SIGPROF, &sig_s, 0); + } -#elif defined(U3_OS_linux) - // TODO: support profiling on linux #elif defined(U3_OS_bsd) - // TODO: support profiling on bsd +# error "Profiling isn't yet supported on BSD" #else # error "port: profiling" #endif From f5a1b3343f0fdfc7d0bce48a8412fac7582080d0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 9 Nov 2018 16:57:43 -0500 Subject: [PATCH 039/157] removes .d --- .d/.gitignore | 1 - .d/jets/a/.gitignore | 0 .d/jets/b/.gitignore | 0 .d/jets/c/.gitignore | 0 .d/jets/d/.gitignore | 0 .d/jets/e/.gitignore | 0 .d/jets/f/.gitignore | 0 .d/jets/g/.gitignore | 0 .d/noun/.gitignore | 0 .d/outside/jhttp/.gitignore | 0 .d/outside/murmur3/.gitignore | 0 .d/tests/.gitignore | 0 .d/vere/.gitignore | 0 13 files changed, 1 deletion(-) delete mode 100644 .d/.gitignore delete mode 100644 .d/jets/a/.gitignore delete mode 100644 .d/jets/b/.gitignore delete mode 100644 .d/jets/c/.gitignore delete mode 100644 .d/jets/d/.gitignore delete mode 100644 .d/jets/e/.gitignore delete mode 100644 .d/jets/f/.gitignore delete mode 100644 .d/jets/g/.gitignore delete mode 100644 .d/noun/.gitignore delete mode 100644 .d/outside/jhttp/.gitignore delete mode 100644 .d/outside/murmur3/.gitignore delete mode 100644 .d/tests/.gitignore delete mode 100644 .d/vere/.gitignore diff --git a/.d/.gitignore b/.d/.gitignore deleted file mode 100644 index 21af5d669..000000000 --- a/.d/.gitignore +++ /dev/null @@ -1 +0,0 @@ -**.d diff --git a/.d/jets/a/.gitignore b/.d/jets/a/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/.d/jets/b/.gitignore b/.d/jets/b/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/.d/jets/c/.gitignore b/.d/jets/c/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/.d/jets/d/.gitignore b/.d/jets/d/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/.d/jets/e/.gitignore b/.d/jets/e/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/.d/jets/f/.gitignore b/.d/jets/f/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/.d/jets/g/.gitignore b/.d/jets/g/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/.d/noun/.gitignore b/.d/noun/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/.d/outside/jhttp/.gitignore b/.d/outside/jhttp/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/.d/outside/murmur3/.gitignore b/.d/outside/murmur3/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/.d/tests/.gitignore b/.d/tests/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/.d/vere/.gitignore b/.d/vere/.gitignore deleted file mode 100644 index e69de29bb..000000000 From 5c4ccdef413c3fcbf2fcb4a0621133a7ef9c10af Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Nov 2018 13:12:49 -0500 Subject: [PATCH 040/157] configures/builds/activates hashtable tests --- meson.build | 56 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 4cefeff2f..4f8ffd0b8 100644 --- a/meson.build +++ b/meson.build @@ -218,6 +218,15 @@ jets_g_src = [ jets_src = [ 'jets/tree.c' ] + +jets_all_src = [ + jets_a_src, jets_b_src, + jets_c_src, jets_d_src, + jets_e_src, jets_e_ed_src, + jets_f_src, jets_f_ut_src, + jets_z_src, jets_z_ut_src, + jets_g_src, jets_src] + noun_src = ['noun/allocate.c', 'noun/events.c', 'noun/hashtable.c', @@ -246,14 +255,7 @@ vere_src = ['vere/ames.c', 'vere/unix.c', 'vere/walk.c'] -src_list = [ -vere_src, noun_src, -jets_a_src, jets_b_src, -jets_c_src, jets_d_src, -jets_e_src, jets_e_ed_src, -jets_f_src, jets_f_ut_src, -jets_z_src, jets_z_ut_src, -jets_g_src, jets_src] +src_list = [vere_src, noun_src, jets_all_src] sources = [] foreach s : src_list @@ -369,3 +371,41 @@ dependencies: [openssl_dep, softfloat3_dep, libsni_dep] + os_deps, install: true) + +vere_sans_main = ['vere/ames.c', + 'vere/behn.c', + 'vere/cttp.c', + 'vere/http.c', + 'vere/loop.c', + 'vere/raft.c', + 'vere/reck.c', + 'vere/save.c', + 'vere/sist.c', + 'vere/term.c', + 'vere/time.c', + 'vere/unix.c', + 'vere/walk.c'] + +# XX shrink this list +test_sources = noun_src + jets_all_src + vere_sans_main + +test_hashtable = executable('test-hashtable', +sources : test_sources + ['tests/hashtable_tests.c'], +include_directories : incdir, +c_args : os_c_flags, +link_args: os_link_flags, +dependencies: [openssl_dep, + curl_dep, + libuv_dep, + libh2o_dep, + cmark_dep, + gmp_dep, + sigsegv_dep, + urbitscrypt_dep, + ed25519_dep, + murmur3_dep, + softfloat3_dep, + libsni_dep] + os_deps, +install: false) + +test('test-hashtable', test_hashtable) From fc665dce04103148e7985441c366b3d9700183da Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Nov 2018 13:42:15 -0500 Subject: [PATCH 041/157] configures/builds/activates (failing) memory tests --- meson.build | 23 ++++++++++++ tests/test.c | 99 ++++++++++++++++++++++++++-------------------------- 2 files changed, 73 insertions(+), 49 deletions(-) diff --git a/meson.build b/meson.build index 4f8ffd0b8..566798b88 100644 --- a/meson.build +++ b/meson.build @@ -409,3 +409,26 @@ dependencies: [openssl_dep, install: false) test('test-hashtable', test_hashtable) + +test_mem_sources = noun_src + jets_all_src + vere_sans_main + ['tests/test.c'] + +test_mem = executable('test-mem', +sources : test_sources + ['tests/test.c'], +include_directories : incdir, +c_args : os_c_flags, +link_args: os_link_flags, +dependencies: [openssl_dep, + curl_dep, + libuv_dep, + libh2o_dep, + cmark_dep, + gmp_dep, + sigsegv_dep, + urbitscrypt_dep, + ed25519_dep, + murmur3_dep, + softfloat3_dep, + libsni_dep] + os_deps, +install: false) + +test('test-mem', test_mem, should_fail: true) diff --git a/tests/test.c b/tests/test.c index 48a78b18e..4a7eb12ab 100644 --- a/tests/test.c +++ b/tests/test.c @@ -34,7 +34,7 @@ u3_walk_load(c3_c* pas_c) if ( (fid_i < 0) || (fstat(fid_i, &buf_b) < 0) ) { fprintf(stderr, "%s: %s\r\n", pas_c, strerror(errno)); - return u3_cm_bail(c3__fail); + return u3m_bail(c3__fail); } fln_w = buf_b.st_size; pad_y = c3_malloc(buf_b.st_size); @@ -44,10 +44,10 @@ u3_walk_load(c3_c* pas_c) if ( fln_w != red_w ) { free(pad_y); - return u3_cm_bail(c3__fail); + return u3m_bail(c3__fail); } else { - u3_noun pad = u3_ci_bytes(fln_w, (c3_y *)pad_y); + u3_noun pad = u3i_bytes(fln_w, (c3_y *)pad_y); free(pad_y); return pad; @@ -59,14 +59,14 @@ u3_walk_load(c3_c* pas_c) static c3_w* _test_walloc(c3_w siz_w) { - c3_w *ptr_w = u3_ca_walloc(siz_w); + c3_w *ptr_w = u3a_walloc(siz_w); c3_w i_w; c3_assert(siz_w >= 1); *ptr_w = siz_w; for ( i_w = 1; i_w < siz_w; i_w++ ) { - ptr_w[i_w] = u3_cr_mug((0xffff & (c3_p)(ptr_w)) + i_w); + ptr_w[i_w] = u3r_mug((0xffff & (c3_p)(ptr_w)) + i_w); } return ptr_w; } @@ -77,9 +77,9 @@ _test_free(c3_w* ptr_w) c3_w i_w, siz_w = *ptr_w; for ( i_w = 1; i_w < siz_w; i_w++ ) { - c3_assert(ptr_w[i_w] == u3_cr_mug((0xffff & (c3_p)(ptr_w)) + i_w)); + c3_assert(ptr_w[i_w] == u3r_mug((0xffff & (c3_p)(ptr_w)) + i_w)); } - u3_ca_free(ptr_w); + u3a_free(ptr_w); } #define NUM 16384 @@ -94,7 +94,7 @@ test(void) c3_w i_w; for ( i_w = 0; i_w < NUM; i_w++ ) { - c3_w siz_w = c3_max(1, u3_cr_mug(i_w) & 0xff); + c3_w siz_w = c3_max(1, u3r_mug(i_w) & 0xff); one_w[i_w] = _test_walloc(siz_w); two_w[i_w] = _test_walloc(siz_w); @@ -106,7 +106,7 @@ test(void) _road_sane(); } for ( i_w = 0; i_w < NUM; i_w++ ) { - c3_w siz_w = c3_max(1, u3_cr_mug(i_w + 1) & 0xff); + c3_w siz_w = c3_max(1, u3r_mug(i_w + 1) & 0xff); two_w[i_w] = _test_walloc(siz_w); _road_sane(); @@ -117,7 +117,7 @@ test(void) _road_sane(); } for ( i_w = 0; i_w < NUM; i_w++ ) { - c3_w siz_w = c3_max(1, u3_cr_mug(i_w + 2) & 0xff); + c3_w siz_w = c3_max(1, u3r_mug(i_w + 2) & 0xff); one_w[i_w] = _test_walloc(siz_w); _road_sane(); @@ -140,21 +140,21 @@ test(void) static void _test_hash(void) { - u3_cm_dump(); + // u3m_dump(); { - u3_ch_root* har_u = u3_ch_new(); + u3h_root* har_u = u3h_new(); c3_w i_w; c3_w max_w = (1 << 20); for ( i_w = 0; i_w < max_w; i_w++ ) { u3_noun key = u3nc(0, i_w); - u3_ch_put(har_u, key, (i_w + 1)); + u3h_put(har_u, key, (i_w + 1)); u3z(key); } for ( i_w = 0; i_w < max_w; i_w++ ) { u3_noun key = u3nc(0, i_w); - u3_noun val = u3_ch_get(har_u, key); + u3_noun val = u3h_get(har_u, key); if ( val != (i_w + 1) ) { if ( u3_none == val ) { @@ -165,9 +165,9 @@ _test_hash(void) } u3z(key); } - u3_ch_free(har_u); + u3h_free(har_u); } - u3_cm_dump(); + // u3m_dump(); } #endif @@ -175,25 +175,25 @@ _test_hash(void) static void _test_jam(void) { - u3_cm_dump(); + // u3m_dump(); { u3_noun pil = u3_walk_load("urb/urbit.pill"); u3_noun cue, jam; - printf("cueing pill - %d bytes\n", u3_cr_met(3, pil)); - cue = u3_cke_cue(pil); - printf("cued - mug %x\n", u3_cr_mug(cue)); + printf("cueing pill - %d bytes\n", u3r_met(3, pil)); + cue = u3ke_cue(pil); + printf("cued - mug %x\n", u3r_mug(cue)); #if 1 - jam = u3_cke_jam(cue); - printf("jammed - %d bytes\n", u3_cr_met(3, jam)); - cue = u3_cke_cue(jam); - printf("cued - mug %x\n", u3_cr_mug(cue)); + jam = u3ke_jam(cue); + printf("jammed - %d bytes\n", u3r_met(3, jam)); + cue = u3ke_cue(jam); + printf("cued - mug %x\n", u3r_mug(cue)); #endif u3z(cue); } - u3_cm_dump(); + // u3m_dump(); } #endif @@ -201,45 +201,45 @@ static void _test_leap(void) { #if 1 - u3_cm_dump(); + // u3m_dump(); { u3_noun pil; u3_noun cue, jam; - c3_w gof_w = u3_cm_golf(); + c3_w gof_w = u3m_golf(); pil = u3_walk_load("urb/urbit.pill"); - u3_cm_leap(0); - printf("cueing pill - %d bytes\n", u3_cr_met(3, pil)); - cue = u3_cke_cue(pil); - printf("cued - %p, mug %x\n", u3_co_to_ptr(cue), u3_cr_mug(cue)); - u3_cm_fall(); + u3m_leap(0); + printf("cueing pill - %d bytes\n", u3r_met(3, pil)); + cue = u3ke_cue(pil); + printf("cued - %p, mug %x\n", u3a_to_ptr(cue), u3r_mug(cue)); + u3m_fall(); - cue = u3_ca_take(cue); - printf("taken - %p, mug %x\n", u3_co_to_ptr(cue), u3_cr_mug(cue)); - u3_cm_flog(gof_w); + cue = u3a_take(cue); + printf("taken - %p, mug %x\n", u3a_to_ptr(cue), u3r_mug(cue)); + u3m_flog(gof_w); u3z(pil); #if 1 - jam = u3_cke_jam(cue); - printf("jammed - %d bytes\n", u3_cr_met(3, jam)); - cue = u3_cke_cue(jam); - printf("cued - mug %x\n", u3_cr_mug(cue)); + jam = u3ke_jam(cue); + printf("jammed - %d bytes\n", u3r_met(3, jam)); + cue = u3ke_cue(jam); + printf("cued - mug %x\n", u3r_mug(cue)); #endif u3z(cue); } - u3_cm_dump(); + // u3m_dump(); #endif } static void _test_test(void) { - u3_noun fol = u3_cke_cue(u3_walk_load("pill/west.pill")); + u3_noun fol = u3ke_cue(u3_walk_load("pill/west.pill")); u3_noun val; - printf("test_test: formula mug %x\n", u3_cr_mug(fol)); - val = u3_cn_nock_on(u3nc(42, 17), fol); + printf("test_test: formula mug %x\n", u3r_mug(fol)); + val = u3n_nock_on(u3nc(42, 17), fol); printf("val %d\n", val); u3z(val); } @@ -254,11 +254,11 @@ main(int argc, char *argv[]) printf("hello, world: len %dMB\n", (1 << U3_OS_LoomBits) >> 18); // _test_words(); - u3_ce_init(u3_no); - u3_cm_boot(u3_yes); - // u3_cj_boot(); + u3m_init(c3n); + u3m_pave(c3y, c3n); + // u3j_boot(); - // u3_cm_dump(); + // u3m_dump(); printf("booted.\n"); @@ -267,6 +267,7 @@ main(int argc, char *argv[]) // _test_hash(); // _test_jam(); } - u3_cm_clear(); - // u3_cm_dump(); + // u3m_clear(); + + // u3m_dump(); } From 19e588e503d80c9042cd0fae8923be5caedbcc42 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Nov 2018 13:43:15 -0500 Subject: [PATCH 042/157] removes old kjet implementation file --- tests/kjet.c | 67 ---------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 tests/kjet.c diff --git a/tests/kjet.c b/tests/kjet.c deleted file mode 100644 index 8803ad5b8..000000000 --- a/tests/kjet.c +++ /dev/null @@ -1,67 +0,0 @@ -/* f/meme.c -** -*/ -#include "f/meme.h" - - /* u3_cka_sub(): a + b. - */ - /* u3_cka_gth(): a + b. - */ - - /* u3_cka_mul(): a * b. - */ - /* u3_cka_lte(): a * b. - */ - - /* u3_ckb_lent(): length of list `a`. - */ - /* u3_ckb_flop(): reverse list `a`. - */ - /* u3_ckb_weld(): concatenate lists `a` before `b`. - */ - /* u3_ckc_lsh(): left shift. - */ - /* u3_ckc_rsh(): right shift. - */ - /* u3_ckdb_get(): map get for key `b` in map `a` with u3_none. - */ - u3_weak - u3_ckdb_get(u3_noun a, u3_noun b) - { - u3_noun c = u3_cqdb_get(a, b); - - u3z(a); u3z(b); - if ( u3_no == u3_cr_du(c) ) { - u3z(c); - return u3_none; - } else { - u3_noun pro = u3k(u3t(c)); - - u3z(c); - return pro; - } - } - - /* u3_ckdb_got(): map get for key `b` in map `a` with fail. - */ - /* u3_ckdb_put(): map put for key `b`, value `c` in map `a`. - */ - /* u3_ckdb_gas(): list to map. - */ - /* u3_ckdi_gas(): list to map. - */ - - /* u3_ckdb_has(): test for presence. - */ - /* u3_ckdi_has(): test for presence. - */ - /* u3_ckdi_tap(): map/set convert to list. (solves by_tap also.) - */ - - /* u3_cke_cue(): expand saved pill. - */ - - /* u3_cke_jam(): pack noun as atom. - */ - /* u3_cke_trip(): atom to tape. - */ From c9e22d93053b5f82b05aa7887521d7b20c30fb36 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 13 Nov 2018 13:44:21 -0500 Subject: [PATCH 043/157] [CI] run tests --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a21184c22..d3170289d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ script: - meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true - cd ./build - ninja + - ninja test - sudo ninja install - cd ../.travis - npm install From 965c43c57a464057439624caf3e8dcf127dbff49 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 9 Nov 2018 00:13:08 -0500 Subject: [PATCH 044/157] fixes race in _proxy_ward_close by unlinking early --- vere/http.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vere/http.c b/vere/http.c index 3f3ff83d1..3cd0a4c3a 100644 --- a/vere/http.c +++ b/vere/http.c @@ -2140,7 +2140,6 @@ _proxy_ward_free(uv_handle_t* han_u) u3_ward* rev_u = han_u->data; u3z(rev_u->sip); - _proxy_ward_unlink(rev_u); free(rev_u->non_u.base); free(rev_u); } @@ -2160,6 +2159,8 @@ _proxy_ward_close_timer(uv_handle_t* han_u) static void _proxy_ward_close(u3_ward* rev_u) { + _proxy_ward_unlink(rev_u); + while ( 0 != rev_u->won_u ) { _proxy_wcon_close(rev_u->won_u); rev_u->won_u = rev_u->won_u->nex_u; From 8a2521416753a504b37ebb92e41c5e13d912543d Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 13 Nov 2018 11:11:48 -0800 Subject: [PATCH 045/157] Use custom memory allocation functions for Argon2 --- jets/e/argon2.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/jets/e/argon2.c b/jets/e/argon2.c index fec9185ab..48455f7b9 100644 --- a/jets/e/argon2.c +++ b/jets/e/argon2.c @@ -5,6 +5,20 @@ #include +/* helpers +*/ + + int argon2_alloc(uint8_t** output, size_t bytes) + { + *output = u3a_malloc(bytes); + return (NULL != output); + } + + void argon2_dealloc(uint8_t* memory, size_t bytes) + { + u3a_free(memory); + } + /* functions */ @@ -50,7 +64,8 @@ bytes_extra, wix, // optional associated data time_cost, mem_cost, threads, threads, // performance cost configuration version, // algorithm version - NULL, NULL, // custom memory allocation / deallocation functions + argon2_alloc, // custom memory allocation function + argon2_dealloc, // custom memory deallocation function ARGON2_DEFAULT_FLAGS // by default only internal memory is cleared }; From 5304a7f255fc972a9a4049c0e070dadd53d7ae8b Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Tue, 13 Nov 2018 16:22:49 -0800 Subject: [PATCH 046/157] Fix bail_fail on `&33:~` --- noun/retrieve.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/noun/retrieve.c b/noun/retrieve.c index a94ac6d83..1b796f59c 100644 --- a/noun/retrieve.c +++ b/noun/retrieve.c @@ -82,6 +82,11 @@ u3r_at(u3_atom a, u3_noun b) b = _frag_word(a_u->buf_w[len_w - 1], b); len_w -= 1; + if ( u3_none == b ) { + u3t_off(far_o); + return b; + } + while ( len_w ) { b = _frag_deep(a_u->buf_w[len_w - 1], b); From e1571b5f3673c07b457567ad7d8f2c3ce3cc8061 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 13 Nov 2018 14:28:30 -0800 Subject: [PATCH 047/157] Use latest urbit/argon2 --- subprojects/argon2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/argon2 b/subprojects/argon2 index 32497fc70..6e7d7e3a9 160000 --- a/subprojects/argon2 +++ b/subprojects/argon2 @@ -1 +1 @@ -Subproject commit 32497fc70bab485b50a0f28cef51b35082ded247 +Subproject commit 6e7d7e3a92361f11942f0c743d154ab426d1530e From 10a706009120f3c48f36af5190253dd78531f776 Mon Sep 17 00:00:00 2001 From: benjamin-tlon <42358674+benjamin-tlon@users.noreply.github.com> Date: Wed, 14 Nov 2018 09:30:26 -0800 Subject: [PATCH 048/157] Make list indentation consistent in Meson file. --- meson.build | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 566798b88..ae1ac487b 100644 --- a/meson.build +++ b/meson.build @@ -227,7 +227,8 @@ jets_all_src = [ jets_z_src, jets_z_ut_src, jets_g_src, jets_src] -noun_src = ['noun/allocate.c', +noun_src = [ + 'noun/allocate.c', 'noun/events.c', 'noun/hashtable.c', 'noun/imprison.c', @@ -240,7 +241,8 @@ noun_src = ['noun/allocate.c', 'noun/xtract.c', 'noun/zave.c'] -vere_src = ['vere/ames.c', +vere_src = [ + 'vere/ames.c', 'vere/behn.c', 'vere/cttp.c', 'vere/http.c', @@ -372,7 +374,8 @@ dependencies: [openssl_dep, libsni_dep] + os_deps, install: true) -vere_sans_main = ['vere/ames.c', +vere_sans_main = [ + 'vere/ames.c', 'vere/behn.c', 'vere/cttp.c', 'vere/http.c', From e4b259138c98c3706ad16702e9442a0db26b68ef Mon Sep 17 00:00:00 2001 From: benjamin-tlon <42358674+benjamin-tlon@users.noreply.github.com> Date: Wed, 14 Nov 2018 09:34:25 -0800 Subject: [PATCH 049/157] Minor Cleanup --- meson.build | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/meson.build b/meson.build index ae1ac487b..220769f31 100644 --- a/meson.build +++ b/meson.build @@ -239,15 +239,15 @@ noun_src = [ 'noun/trace.c', 'noun/vortex.c', 'noun/xtract.c', - 'noun/zave.c'] + 'noun/zave.c' +] -vere_src = [ +vere_sans_main = [ 'vere/ames.c', 'vere/behn.c', 'vere/cttp.c', 'vere/http.c', 'vere/loop.c', - 'vere/main.c', 'vere/raft.c', 'vere/reck.c', 'vere/save.c', @@ -255,7 +255,10 @@ vere_src = [ 'vere/term.c', 'vere/time.c', 'vere/unix.c', - 'vere/walk.c'] + 'vere/walk.c' +] + +vere_src = vere_sans_main + [ 'vere/main.c' ] src_list = [vere_src, noun_src, jets_all_src] @@ -374,21 +377,6 @@ dependencies: [openssl_dep, libsni_dep] + os_deps, install: true) -vere_sans_main = [ - 'vere/ames.c', - 'vere/behn.c', - 'vere/cttp.c', - 'vere/http.c', - 'vere/loop.c', - 'vere/raft.c', - 'vere/reck.c', - 'vere/save.c', - 'vere/sist.c', - 'vere/term.c', - 'vere/time.c', - 'vere/unix.c', - 'vere/walk.c'] - # XX shrink this list test_sources = noun_src + jets_all_src + vere_sans_main From f2fa04d98a416f2b54c18aa496e7e71f56519faa Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Wed, 14 Nov 2018 09:46:08 -0800 Subject: [PATCH 050/157] Revert change to libh2o for now -- Breaks the nix build, but unbreaks the normal build. --- subprojects/libh2o | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/libh2o b/subprojects/libh2o index 23192118e..41958a8ae 160000 --- a/subprojects/libh2o +++ b/subprojects/libh2o @@ -1 +1 @@ -Subproject commit 23192118e5ae1a4ebb4e1078f83cc0527b4eb080 +Subproject commit 41958a8aedb3aa2a85332bc8ac0ac389aa725a09 From c042ccc2ea53398da6056b0ffec7f5d4f39e649e Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Wed, 14 Nov 2018 09:47:28 -0800 Subject: [PATCH 051/157] Use fetchGit instead of fetchTarball to get nixpkgs. --- default.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/default.nix b/default.nix index bbfa72776..b21daad11 100644 --- a/default.nix +++ b/default.nix @@ -1,11 +1,10 @@ let - # In order to get the hash of another tarball, run: `nix-prefetch-url --unpack ` pkgs = - builtins.fetchTarball { - name = "nixpkgs-2018-10-07"; - url = https://github.com/nixos/nixpkgs/archive/865cbd380d2568806c6e46c9a4bc746af7ec13c9.tar.gz; - sha256 = "0r3gj1rci2ag6k8g5wcz1m4l6brvzgbfz92kpl74mrh7kjdy1m3p"; + builtins.fetchGit { + name = "nixpkgs-2018-11-13"; + url = https://github.com/nixos/nixpkgs/; + rev = "695a3d4254545968fc3015142c5299c0da5ca0a9"; }; in From 33da16ca06f50dd4a70e175756fd5a71afd8d881 Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Wed, 14 Nov 2018 09:52:21 -0800 Subject: [PATCH 052/157] meson v0.44.1 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 23f534edf..a21184c22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ before_install: install: # pwd: ~/urbit - - pip3 install --user -I meson==0.46.1 + - pip3 install --user -I meson==0.44.1 - git clone https://github.com/urbit/arvo - cd ./arvo - git checkout $(cat ../.travis/pin-arvo-commit.txt) From aa129666fc9bd8dca104827889978e93e2f745b5 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 14 Nov 2018 13:38:34 -0800 Subject: [PATCH 053/157] Make small stylistic improvements to crypto jets --- jets/e/argon2.c | 44 +++++++-------- jets/e/blake.c | 140 +++++++++++++++++++++--------------------------- jets/e/hmac.c | 5 +- jets/e/ripe.c | 128 +++++++++++++++++++++---------------------- jets/e/sha1.c | 7 ++- 5 files changed, 153 insertions(+), 171 deletions(-) diff --git a/jets/e/argon2.c b/jets/e/argon2.c index 48455f7b9..cc439014b 100644 --- a/jets/e/argon2.c +++ b/jets/e/argon2.c @@ -14,7 +14,7 @@ return (NULL != output); } - void argon2_dealloc(uint8_t* memory, size_t bytes) + void argon2_free(uint8_t* memory, size_t bytes) { u3a_free(memory); } @@ -23,18 +23,18 @@ */ u3_noun - u3qe_argon2(// configuration params, - u3_atom out, u3_atom type, u3_atom version, - u3_atom threads, u3_atom mem_cost, u3_atom time_cost, - u3_atom wik, u3_atom key, u3_atom wix, u3_atom extra, - // input params - u3_atom wid, u3_atom dat, u3_atom wis, u3_atom sat) + u3qe_argon2( // configuration params, + u3_atom out, u3_atom type, u3_atom version, + u3_atom threads, u3_atom mem_cost, u3_atom time_cost, + u3_atom wik, u3_atom key, u3_atom wix, u3_atom extra, + // input params + u3_atom wid, u3_atom dat, u3_atom wis, u3_atom sat ) { - c3_assert(_(u3a_is_cat(out)) && _(u3a_is_cat(type)) && - _(u3a_is_cat(version)) && _(u3a_is_cat(threads)) && - _(u3a_is_cat(mem_cost)) && _(u3a_is_cat(time_cost)) && - _(u3a_is_cat(wik)) && _(u3a_is_cat(wix)) && - _(u3a_is_cat(wid)) && _(u3a_is_cat(wis))); + c3_assert( _(u3a_is_cat(out)) && _(u3a_is_cat(type)) && + _(u3a_is_cat(version)) && _(u3a_is_cat(threads)) && + _(u3a_is_cat(mem_cost)) && _(u3a_is_cat(time_cost)) && + _(u3a_is_cat(wik)) && _(u3a_is_cat(wix)) && + _(u3a_is_cat(wid)) && _(u3a_is_cat(wis)) ); // flip endianness for argon2 key = u3qc_rev(3, wik, key); @@ -65,13 +65,17 @@ time_cost, mem_cost, threads, threads, // performance cost configuration version, // algorithm version argon2_alloc, // custom memory allocation function - argon2_dealloc, // custom memory deallocation function + argon2_free, // custom memory deallocation function ARGON2_DEFAULT_FLAGS // by default only internal memory is cleared }; int argon_res; - switch(type) - { + switch ( type ) { + default: + fprintf(stderr, "\nunjetted argon2 variant %i\n", type); + u3m_bail(c3__exit); + break; + // case c3__d: argon_res = argon2d_ctx(&context); break; @@ -87,14 +91,9 @@ case c3__u: argon_res = argon2u_ctx(&context); break; - // - default: - fprintf(stderr, "\nunjetted argon2 variant %i\n", type); - u3m_bail(c3__exit); } - if(ARGON2_OK != argon_res) - { + if ( ARGON2_OK != argon_res ) { fprintf(stderr, "\nargon2 error: %s\n", argon2_error_message(argon_res)); u3m_bail(c3__exit); } @@ -137,7 +136,8 @@ ) { return u3m_bail(c3__exit); - } else { + } + else { return u3qe_argon2(out, type, version, threads, mem_cost, time_cost, wik, key, wix, extra, diff --git a/jets/e/blake.c b/jets/e/blake.c index b0f6ed436..8a703a4ca 100644 --- a/jets/e/blake.c +++ b/jets/e/blake.c @@ -6,85 +6,67 @@ #include #include "../src/blake2/blake2.h" -#if 0 -static void pretty_print_hex(char * headline, - c3_y * ptr, - c3_w num_bytes) -{ - fprintf(stderr, "\r%s:\n\r ", headline); - for (c3_ws ii=0 ; ii < num_bytes; ii++) { - fprintf(stderr, "%02x", ptr[ii]); - if (0 == (ii + 1) % 16){ - fprintf(stderr, "\n\r "); +/* functions +*/ + + u3_noun + u3qe_blake(u3_atom wid, u3_atom dat, + u3_atom wik, u3_atom dak, + u3_atom out) + { + c3_assert(_(u3a_is_cat(wid)) && _(u3a_is_cat(wik)) && _(u3a_is_cat(out))); + + // flip endianness for the internal blake2b function + dat = u3qc_rev(3, wid, dat); + dak = u3qc_rev(3, wik, dak); + + c3_y* dat_y = (c3_y*)u3a_malloc(wid); + u3r_bytes(0, wid, (void*)dat_y, dat); + + c3_y* dak_y = (c3_y*)u3a_malloc(wik); + u3r_bytes(0, wik, (void*)dak_y, dak); + + int ret; + c3_y out_y[64]; + ret = blake2b(out_y, // OUT: output + out, // IN: max output size + dat_y, // IN: msg body + wid, // IN: msg len + dak_y, // IN: key body + wik); // IN: key len + + /* free() BEFORE checking error code; + we don't want to leak memory if we return early + */ + u3a_free(dat_y); + u3a_free(dak_y); + + if ( 0 != ret ) + { + fprintf(stderr, "\rblake jet: cryto lib error\n"); + return u3m_bail(c3__exit); + } + + return u3kc_rev(3, out, u3i_bytes(out, out_y)); + } + + u3_noun + u3we_blake(u3_noun cor) + { + u3_noun msg, key, out, // arguments + wid, dat, // destructured msg + wik, dak; // destructured key + + if ( c3n == u3r_mean(cor, u3x_sam_2, &msg, + u3x_sam_6, &key, + u3x_sam_7, &out, 0) || + u3r_cell(msg, &wid, &dat) || u3ud(wid) || u3ud(dat) || + u3r_cell(key, &wik, &dak) || u3ud(wik) || u3ud(dak) || + u3ud(out) ) + { + fprintf(stderr, "\rblake jet: arguments error\n"); + return u3m_bail(c3__exit); } else { - fprintf(stderr, ", "); + return u3qe_blake(wid, dat, wik, dak, out); } } - fprintf(stderr, "\n\r"); - -} -#endif - -u3_noun -u3qe_blake(u3_atom wid, u3_atom dat, - u3_atom wik, u3_atom dak, - u3_atom out) -{ - c3_assert(_(u3a_is_cat(wid)) && _(u3a_is_cat(wik)) && _(u3a_is_cat(out))); - - // flip endianness for the internal blake2b function - dat = u3qc_rev(3, wid, dat); - dak = u3qc_rev(3, wik, dak); - - c3_y* dat_y = (c3_y*)u3a_malloc(wid); - u3r_bytes(0, wid, (void*)dat_y, dat); - - c3_y* dak_y = (c3_y*)u3a_malloc(wik); - u3r_bytes(0, wik, (void*)dak_y, dak); - - int ret; - c3_y out_y[64]; - ret = blake2b(out_y, // OUT: output - out, // IN: max output size - dat_y, // IN: msg body - wid, // IN: msg len - dak_y, // IN: key body - wik); // IN: key len - - /* free() BEFORE checking error code; - we don't want to leak memory if we return early - */ - u3a_free(dat_y); - u3a_free(dak_y); - - if (ret != 0) - { - fprintf(stderr, "\rblake jet: cryto lib error\n"); - return u3m_bail(c3__exit); - } - - return(u3kc_rev(3, out, u3i_bytes(out, out_y))); -} - - - -u3_noun -u3we_blake(u3_noun cor) -{ - u3_noun msg, key, out, // arguments - wid, dat, // destructured msg - wik, dak; // destructured key - - if ( c3n == u3r_mean(cor, u3x_sam_2, &msg, - u3x_sam_6, &key, - u3x_sam_7, &out, 0) || - u3r_cell(msg, &wid, &dat) || u3ud(wid) || u3ud(dat) || - u3r_cell(key, &wik, &dak) || u3ud(wik) || u3ud(dak) || - u3ud(out) ) - { - fprintf(stderr, "\rblake jet: arguments error\n"); - return u3m_bail(c3__exit); - } else { - return u3qe_blake(wid, dat, wik, dak, out); - } -} diff --git a/jets/e/hmac.c b/jets/e/hmac.c index 753011823..4a0237c6c 100644 --- a/jets/e/hmac.c +++ b/jets/e/hmac.c @@ -38,7 +38,7 @@ c3_w innpad[padwords], outpad[padwords]; memset(innpad, 0x36, padwords * 4); memset(outpad, 0x5c, padwords * 4); - if (trail > 0) { + if ( trail > 0 ) { innpad[padwords-1] = 0x36363636 >> (8 * (4 - trail)); outpad[padwords-1] = 0x5c5c5c5c >> (8 * (4 - trail)); } @@ -81,7 +81,8 @@ (c3n == u3ud(dat)) ) { return u3m_bail(c3__exit); - } else { + } + else { return u3qe_hmac(haj, boq, out, wik, key, wid, dat); } } diff --git a/jets/e/ripe.c b/jets/e/ripe.c index 0423e3434..05276a5fa 100644 --- a/jets/e/ripe.c +++ b/jets/e/ripe.c @@ -4,77 +4,77 @@ #include "all.h" #include -u3_noun -u3qe_ripe(u3_atom wid, u3_atom dat) -{ - c3_assert(_(u3a_is_cat(wid))); - dat = u3qc_rev(3, wid, dat); +/* functions +*/ - c3_y* dat_y = (c3_y*)u3a_malloc(wid); // msg body - u3r_bytes(0, wid, (void*)dat_y, dat); - - const EVP_MD* rip_u = EVP_ripemd160(); // ripem algorithm - static EVP_MD_CTX* con_u = NULL; // context - - /* build library context object - we do this once (and only once) - */ - - if (NULL == con_u) + u3_noun + u3qe_ripe(u3_atom wid, u3_atom dat) { - con_u = EVP_MD_CTX_create(); - } + c3_assert(_(u3a_is_cat(wid))); + dat = u3qc_rev(3, wid, dat); - /* perform signature - */ + c3_y* dat_y = (c3_y*)u3a_malloc(wid); // msg body + u3r_bytes(0, wid, (void*)dat_y, dat); - c3_y sib_y[20]; // signature body - c3_w sil_w; // signature length - c3_w ret_w; // return code + const EVP_MD* rip_u = EVP_ripemd160(); // ripem algorithm + static EVP_MD_CTX* con_u = NULL; // context - ret_w = EVP_DigestInit_ex(con_u, rip_u, NULL); - if (ret_w != 1) - { + /* build library context object + we do this once (and only once) + */ + + if (NULL == con_u) { + con_u = EVP_MD_CTX_create(); + } + + /* perform signature + */ + + c3_y sib_y[20]; // signature body + c3_w sil_w; // signature length + c3_w ret_w; // return code + + ret_w = EVP_DigestInit_ex(con_u, rip_u, NULL); + if ( 1 != ret_w ) { + u3a_free(dat_y); + fprintf(stderr, "\rripe jet: crypto library fail 1\n"); + return u3m_bail(c3__exit); + } + + ret_w = EVP_DigestUpdate(con_u, (void*)dat_y, wid); u3a_free(dat_y); - fprintf(stderr, "\rripe jet: crypto library fail 1\n"); - return u3m_bail(c3__exit); + if (1 != ret_w) { + fprintf(stderr, "\rripe jet: crypto library fail 2\n"); + return u3m_bail(c3__exit); + } + + ret_w = EVP_DigestFinal_ex(con_u, sib_y, &sil_w); + if ( 1 != ret_w ) { + fprintf(stderr, "\rripe jet: crypto library fail 3\n"); + return u3m_bail(c3__exit); + } + + /* endian conversion; + turn into noun for return + */ + return u3kc_rev(3, sil_w, u3i_bytes(sil_w, sib_y)); } - ret_w = EVP_DigestUpdate(con_u, (void*)dat_y, wid); - u3a_free(dat_y); - if (ret_w != 1) + + u3_noun + u3we_ripe(u3_noun cor) { - fprintf(stderr, "\rripe jet: crypto library fail 2\n"); - return u3m_bail(c3__exit); + u3_noun wid, dat; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &wid, + u3x_sam_3, &dat, 0) || + u3ud(wid) || u3ud(dat)) + ) + { + fprintf(stderr, "\rripe jet: argument error\n"); + return u3m_bail(c3__exit); + } + else { + return u3qe_ripe(wid, dat); + } } - - ret_w = EVP_DigestFinal_ex(con_u, sib_y, &sil_w); - if (ret_w != 1) - { - fprintf(stderr, "\rripe jet: crypto library fail 3\n"); - return u3m_bail(c3__exit); - } - - /* endian conversion; - turn into noun for return - */ - return(u3kc_rev(3, sil_w, u3i_bytes(sil_w, sib_y))); -} - - -u3_noun -u3we_ripe(u3_noun cor) -{ - u3_noun wid, dat; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &wid, - u3x_sam_3, &dat, 0) || - u3ud(wid) || u3ud(dat)) - ) - { - fprintf(stderr, "\rripe jet: argument error\n"); - return u3m_bail(c3__exit); - } else { - return u3qe_ripe(wid, dat); - } -} diff --git a/jets/e/sha1.c b/jets/e/sha1.c index 231968ee8..049ab0da1 100644 --- a/jets/e/sha1.c +++ b/jets/e/sha1.c @@ -3,7 +3,6 @@ */ #include "all.h" - #if defined(U3_OS_osx) #include #else @@ -14,8 +13,7 @@ */ u3_noun - u3qe_sha1(u3_atom wid, - u3_atom dat) + u3qe_sha1(u3_atom wid, u3_atom dat) { c3_assert(_(u3a_is_cat(wid))); dat = u3qc_rev(3, wid, dat); @@ -54,7 +52,8 @@ (c3n == u3ud(dat)) ) { return u3m_bail(c3__exit); - } else { + } + else { return u3qe_sha1(wid, dat); } } From 6c7811a45c6a39368650d664b6bd32b2cecaa89e Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 14 Nov 2018 14:59:57 -0800 Subject: [PATCH 054/157] De-duplicate dependency list --- meson.build | 56 +++++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/meson.build b/meson.build index 667cffbca..1bb9c05f9 100644 --- a/meson.build +++ b/meson.build @@ -368,25 +368,27 @@ secp256k1_dep = dependency('libsecp256k1', version: '>=0.1.0', fallback: ['secp2 libsni_dep = dependency('libsni', version: '>=0.5.0', fallback: ['libsni', 'libsni_dep']) +deps = [openssl_dep, + curl_dep, + libuv_dep, + libh2o_dep, + cmark_dep, + secp256k1_dep, + gmp_dep, + sigsegv_dep, + urbitscrypt_dep, + ed25519_dep, + murmur3_dep, + argon2_dep, + softfloat3_dep, + libsni_dep] + executable('urbit', sources : sources, include_directories : incdir, c_args : os_c_flags, link_args: os_link_flags, -dependencies: [openssl_dep, - curl_dep, - libuv_dep, - libh2o_dep, - cmark_dep, - secp256k1_dep, - gmp_dep, - sigsegv_dep, - urbitscrypt_dep, - ed25519_dep, - murmur3_dep, - argon2_dep, - softfloat3_dep, - libsni_dep] + os_deps, +dependencies: deps + os_deps, install: true) # XX shrink this list @@ -397,18 +399,7 @@ sources : test_sources + ['tests/hashtable_tests.c'], include_directories : incdir, c_args : os_c_flags, link_args: os_link_flags, -dependencies: [openssl_dep, - curl_dep, - libuv_dep, - libh2o_dep, - cmark_dep, - gmp_dep, - sigsegv_dep, - urbitscrypt_dep, - ed25519_dep, - murmur3_dep, - softfloat3_dep, - libsni_dep] + os_deps, +dependencies: deps + os_deps, install: false) test('test-hashtable', test_hashtable) @@ -420,18 +411,7 @@ sources : test_sources + ['tests/test.c'], include_directories : incdir, c_args : os_c_flags, link_args: os_link_flags, -dependencies: [openssl_dep, - curl_dep, - libuv_dep, - libh2o_dep, - cmark_dep, - gmp_dep, - sigsegv_dep, - urbitscrypt_dep, - ed25519_dep, - murmur3_dep, - softfloat3_dep, - libsni_dep] + os_deps, +dependencies: deps + os_deps, install: false) test('test-mem', test_mem, should_fail: true) From 2ac4bd6aa8fa4840f3eccc719b8dcb2611e75b39 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 14 Nov 2018 16:41:37 -0800 Subject: [PATCH 055/157] [CI] Point to latest release-candidate 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 36a690f13..af9da13e8 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -6298a94729de53dfe4d0336e24df86f122325b4a \ No newline at end of file +97b340675934ce196878a569d4fa1b78e26a0d33 From 4ec7ddb61b41793ada6702bd835e83281ddbc8cc Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 26 Oct 2018 12:35:40 -0400 Subject: [PATCH 056/157] removes second staging copy of compiler jets --- include/jets/g.h | 78 ---- include/jets/q.h | 81 ---- include/jets/w.h | 55 --- jets/z/ap.c | 1054 ---------------------------------------------- jets/z/cell.c | 29 -- jets/z/comb.c | 70 --- jets/z/cons.c | 52 --- jets/z/core.c | 42 -- jets/z/face.c | 31 -- jets/z/fine.c | 35 -- jets/z/fitz.c | 67 --- jets/z/flan.c | 44 -- jets/z/flip.c | 39 -- jets/z/flor.c | 44 -- jets/z/fork.c | 78 ---- jets/z/hike.c | 136 ------ jets/z/hint.c | 32 -- jets/z/look.c | 134 ------ jets/z/loot.c | 133 ------ jets/z/slot.c | 55 --- jets/z/type.c | 42 -- jets/z/ut.c | 100 ----- jets/z/ut_buss.c | 93 ---- jets/z/ut_conk.c | 88 ---- jets/z/ut_crop.c | 271 ------------ jets/z/ut_find.c | 915 ---------------------------------------- jets/z/ut_fire.c | 195 --------- jets/z/ut_fish.c | 180 -------- jets/z/ut_fuse.c | 215 ---------- jets/z/ut_gain.c | 16 - jets/z/ut_lose.c | 16 - jets/z/ut_mint.c | 830 ------------------------------------ jets/z/ut_mull.c | 757 --------------------------------- jets/z/ut_nest.c | 566 ------------------------- jets/z/ut_peek.c | 216 ---------- jets/z/ut_peel.c | 55 --- jets/z/ut_play.c | 592 -------------------------- jets/z/ut_repo.c | 70 --- jets/z/ut_rest.c | 114 ----- jets/z/ut_tack.c | 21 - jets/z/ut_toss.c | 97 ----- jets/z/ut_wrap.c | 96 ----- meson.build | 42 -- 43 files changed, 7876 deletions(-) delete mode 100644 jets/z/ap.c delete mode 100644 jets/z/cell.c delete mode 100644 jets/z/comb.c delete mode 100644 jets/z/cons.c delete mode 100644 jets/z/core.c delete mode 100644 jets/z/face.c delete mode 100644 jets/z/fine.c delete mode 100644 jets/z/fitz.c delete mode 100644 jets/z/flan.c delete mode 100644 jets/z/flip.c delete mode 100644 jets/z/flor.c delete mode 100644 jets/z/fork.c delete mode 100644 jets/z/hike.c delete mode 100644 jets/z/hint.c delete mode 100644 jets/z/look.c delete mode 100644 jets/z/loot.c delete mode 100644 jets/z/slot.c delete mode 100644 jets/z/type.c delete mode 100644 jets/z/ut.c delete mode 100644 jets/z/ut_buss.c delete mode 100644 jets/z/ut_conk.c delete mode 100644 jets/z/ut_crop.c delete mode 100644 jets/z/ut_find.c delete mode 100644 jets/z/ut_fire.c delete mode 100644 jets/z/ut_fish.c delete mode 100644 jets/z/ut_fuse.c delete mode 100644 jets/z/ut_gain.c delete mode 100644 jets/z/ut_lose.c delete mode 100644 jets/z/ut_mint.c delete mode 100644 jets/z/ut_mull.c delete mode 100644 jets/z/ut_nest.c delete mode 100644 jets/z/ut_peek.c delete mode 100644 jets/z/ut_peel.c delete mode 100644 jets/z/ut_play.c delete mode 100644 jets/z/ut_repo.c delete mode 100644 jets/z/ut_rest.c delete mode 100644 jets/z/ut_tack.c delete mode 100644 jets/z/ut_toss.c delete mode 100644 jets/z/ut_wrap.c diff --git a/include/jets/g.h b/include/jets/g.h index 19967505f..b452ca419 100644 --- a/include/jets/g.h +++ b/include/jets/g.h @@ -263,81 +263,3 @@ u3_noun u3gfu_tack(u3_noun, u3_noun, u3_noun, u3_noun); u3_noun u3gfu_toss(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); u3_noun u3gfu_wrap(u3_noun, u3_noun, u3_noun); - - - u3_noun u3qz_bull(u3_noun, u3_noun); - u3_noun u3qz_cell(u3_noun, u3_noun); - u3_noun u3qz_comb(u3_noun, u3_noun); - u3_noun u3qz_cons(u3_noun, u3_noun); - u3_noun u3qz_core(u3_noun, u3_noun); - u3_noun u3qz_cube(u3_noun, u3_noun); - u3_noun u3qz_face(u3_noun, u3_noun); - u3_noun u3qz_fine(u3_noun, u3_noun, u3_noun); - u3_noun u3qz_fitz(u3_noun, u3_noun); - u3_noun u3qz_flan(u3_noun, u3_noun); - u3_noun u3qz_flay(u3_noun); - u3_noun u3qz_flip(u3_noun); - u3_noun u3qz_flor(u3_noun, u3_noun); - u3_noun u3qz_forq(u3_noun, u3_noun); - u3_noun u3qz_fork(u3_noun); - u3_noun u3qz_grof(u3_noun); - u3_noun u3qz_help(u3_noun, u3_noun); - u3_noun u3qz_hike(u3_noun, u3_noun); - u3_noun u3qz_look(u3_noun, u3_noun); - u3_noun u3qz_loot(u3_noun, u3_noun); - u3_noun u3qz_slot(u3_atom, u3_noun); - u3_noun u3qz_type(u3_noun); - - u3_noun u3qzl_bunt(u3_noun, u3_noun); - u3_noun u3qzl_whip(u3_noun, u3_noun, u3_noun); - - u3_noun u3qzp_hack(u3_noun, u3_noun); - u3_noun u3qzp_late(u3_noun); - u3_noun u3qzp_open(u3_noun, u3_noun); - u3_noun u3qzp_rake(u3_noun); - -# define u3qzu_van_fan 28 -# define u3qzu_van_rib 58 -# define u3qzu_van_vrf 59 -# define u3qzu_van_vet 118 -# define u3qzu_van_fab 119 - - u3_noun u3qzu_burn(u3_noun, u3_noun); - u3_noun u3qzu_busk(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_buss(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_bust(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_conk(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_crop(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_cull(u3_noun, u3_noun, u3_noun, u3_atom, u3_noun); - u3_noun u3qzu_duck(u3_noun, u3_noun); - u3_noun u3qzu_dung(u3_noun, u3_noun cap, u3_noun); - u3_noun u3qzu_dunq(u3_noun, const c3_c*, u3_noun); - void u3qzu_dump(u3_noun, const c3_c*, u3_noun); - u3_noun u3qzu_fond(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_finc(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_fink(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_fire(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_firm(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_fish(u3_noun, u3_noun, u3_atom); - u3_noun u3qzu_fuse(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_gain(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_heal(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_lose(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_mint(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_mull(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_nest(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_nost(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_orth(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_peek(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_peel(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_play(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_repo(u3_noun, u3_noun); - u3_noun u3qzu_rest(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_shep(u3_noun, const c3_c*, u3_noun, u3_noun); - u3_noun u3qzu_shew(u3_noun, u3_noun); - u3_noun u3qzu_sift(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_snub(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_tack(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_toss(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_wrap(u3_noun, u3_noun, u3_noun); - diff --git a/include/jets/q.h b/include/jets/q.h index 3214e8533..f6c101d53 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -289,85 +289,4 @@ u3_noun u3qfu_toss(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); u3_noun u3qfu_wrap(u3_noun, u3_noun, u3_noun); - - u3_noun u3qz_bull(u3_noun, u3_noun); - u3_noun u3qz_cell(u3_noun, u3_noun); - u3_noun u3qz_comb(u3_noun, u3_noun); - u3_noun u3qz_cons(u3_noun, u3_noun); - u3_noun u3qz_core(u3_noun, u3_noun); - u3_noun u3qz_cube(u3_noun, u3_noun); - u3_noun u3qz_face(u3_noun, u3_noun); - u3_noun u3qz_fine(u3_noun, u3_noun, u3_noun); - u3_noun u3qz_fitz(u3_noun, u3_noun); - u3_noun u3qz_flan(u3_noun, u3_noun); - u3_noun u3qz_flay(u3_noun); - u3_noun u3qz_flip(u3_noun); - u3_noun u3qz_flor(u3_noun, u3_noun); - u3_noun u3qz_forq(u3_noun, u3_noun); - u3_noun u3qz_fork(u3_noun); - u3_noun u3qz_grof(u3_noun); - u3_noun u3qz_hint(u3_noun, u3_noun); - u3_noun u3qz_hike(u3_noun, u3_noun); - u3_noun u3qz_look(u3_noun, u3_noun); - u3_noun u3qz_loot(u3_noun, u3_noun); - u3_noun u3qz_slot(u3_atom, u3_noun); - u3_noun u3qz_type(u3_noun); - - u3_noun u3qzl_bunt(u3_noun, u3_noun); - u3_noun u3qzl_whip(u3_noun, u3_noun, u3_noun); - - u3_noun u3qzr_fish(u3_noun, u3_noun, u3_noun, u3_noun); - - u3_noun u3qzp_hack(u3_noun, u3_noun); - u3_noun u3qzp_late(u3_noun); - u3_noun u3qzp_open(u3_noun, u3_noun, u3_noun); - u3_noun u3qzp_rake(u3_noun); - void u3qf_test(const c3_c*, u3_noun); - -# define u3qzu_van_fan 28 -# define u3qzu_van_rib 58 -# define u3qzu_van_vrf 59 -# define u3qzu_van_vet 118 -# define u3qzu_van_fab 119 - - u3_noun u3qzu_burn(u3_noun, u3_noun); - u3_noun u3qzu_busk(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_buss(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_bust(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_conk(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_crop(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_cull(u3_noun, u3_noun, u3_noun, u3_atom, u3_noun); - u3_noun u3qzu_duck(u3_noun, u3_noun); - u3_noun u3qzu_dung(u3_noun, u3_noun cap, u3_noun); - u3_noun u3qzu_dunq(u3_noun, const c3_c*, u3_noun); - void u3qzu_dump(u3_noun, const c3_c*, u3_noun); - u3_noun u3qzu_fond(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_find(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_finc(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_fink(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_fire(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_firm(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_fish(u3_noun, u3_noun, u3_atom); - u3_noun u3qzu_fuse(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_gain(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_heal(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_lose(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_mint(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_mull(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_nest(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_nost(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_orth(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_peek(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_peel(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_play(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_repo(u3_noun, u3_noun); - u3_noun u3qzu_rest(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_shep(u3_noun, const c3_c*, u3_noun, u3_noun); - u3_noun u3qzu_shew(u3_noun, u3_noun); - u3_noun u3qzu_sift(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_snub(u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_tack(u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_toss(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - u3_noun u3qzu_wrap(u3_noun, u3_noun, u3_noun); - diff --git a/include/jets/w.h b/include/jets/w.h index 30612bcd4..578934703 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -289,61 +289,6 @@ u3_noun u3wfu_toss(u3_noun); u3_noun u3wfu_wrap(u3_noun); - u3_noun u3wz_bull(u3_noun); - u3_noun u3wz_cell(u3_noun); - u3_noun u3wz_comb(u3_noun); - u3_noun u3wz_cons(u3_noun); - u3_noun u3wz_core(u3_noun); - u3_noun u3wz_cube(u3_noun); - u3_noun u3wz_face(u3_noun); - u3_noun u3wz_fine(u3_noun); - u3_noun u3wz_fitz(u3_noun); - u3_noun u3wz_flan(u3_noun); - u3_noun u3wz_flay(u3_noun); - u3_noun u3wz_flip(u3_noun); - u3_noun u3wz_flor(u3_noun); - u3_noun u3wz_forq(u3_noun); - u3_noun u3wz_fork(u3_noun); - u3_noun u3wz_help(u3_noun); - u3_noun u3wz_hike(u3_noun); - u3_noun u3wz_look(u3_noun); - u3_noun u3wz_loot(u3_noun); - - u3_noun u3wzl_bunt(u3_noun); - u3_noun u3wzl_whip(u3_noun); - - u3_noun u3wzp_hack(u3_noun); - u3_noun u3wzp_late(u3_noun); - u3_noun u3wzp_open(u3_noun); - u3_noun u3wzp_rake(u3_noun); - - u3_noun u3wzu_burn(u3_noun); - u3_noun u3wzu_busk(u3_noun); - u3_noun u3wzu_bust(u3_noun); - u3_noun u3wzu_conk(u3_noun); - u3_noun u3wzu_crop(u3_noun); - u3_noun u3wzu_cull(u3_noun); - u3_noun u3wzu_duck(u3_noun); - u3_noun u3wzu_find(u3_noun); - u3_noun u3wzu_fond(u3_noun); - u3_noun u3wzu_fink(u3_noun); - u3_noun u3wzu_fire(u3_noun); - u3_noun u3wzu_firm(u3_noun); - u3_noun u3wzu_fish(u3_noun); - u3_noun u3wzu_fuse(u3_noun); - u3_noun u3wzu_heal(u3_noun); - u3_noun u3wzu_mint(u3_noun); - u3_noun u3wzu_mull(u3_noun); - u3_noun u3wzu_nest(u3_noun); - u3_noun u3wzu_peek(u3_noun); - u3_noun u3wzu_peel(u3_noun); - u3_noun u3wzu_play(u3_noun); - u3_noun u3wzu_repo(u3_noun); - u3_noun u3wzu_rest(u3_noun); - u3_noun u3wzu_snub(u3_noun); - u3_noun u3wzu_toss(u3_noun); - u3_noun u3wzu_wrap(u3_noun); - /** Tier 7. **/ u3_noun u3wg_down(u3_noun); diff --git a/jets/z/ap.c b/jets/z/ap.c deleted file mode 100644 index 64b4faf6b..000000000 --- a/jets/z/ap.c +++ /dev/null @@ -1,1054 +0,0 @@ -/* j/6/ap.c -** -*/ -#include "all.h" - - -/** forward declares -**/ - u3_noun u3wzp_rake(u3_noun); - u3_noun u3wzp_open(u3_noun); - u3_noun u3wzp_hack(u3_noun); - - static u3_noun - _ap_open_l(u3_noun, u3_noun, u3_noun); - - // make sure these match the array below! - // -# define _ap_jet_open 0 -# define _ap_jet_rake 1 -# define _ap_jet_hack 2 - -#if 0 - static u3_noun - _open_in(u3_noun ter, u3_noun gen); - /* ~(. al gen) - */ - static u3_noun - _al_bore(u3_noun ter, - u3_noun gen) - { - u3_noun gat = u3j_hook(u3k(ter), "al"); - - return u3i_molt(gat, u3x_sam, u3nc(c3__herb, u3k(gen)), 0); - } - /* ~(. al gen) - */ - static u3_noun - _al_core(u3_noun ter, - u3_noun gen) - { - u3_noun gat = u3j_hook(u3k(ter), "al"); - - return u3i_molt(gat, u3x_sam, u3k(gen), 0); - } - - /* van is transferred, gen is retained - */ - static u3_noun - _ap_bunt(u3_noun van, - u3_noun gen) - { - u3_noun pro = u3qzl_bunt(van, gen); - - u3z(van); - return pro; - } - -/** open cases -**/ - -#define _open_do_p(stem) \ - static u3_noun _open_in_##stem \ - ( u3_noun ter, u3_noun p_gen) - -#define _open_do_pq(stem) \ - static u3_noun _open_in_##stem \ - ( u3_noun ter, u3_noun p_gen, u3_noun q_gen) - -#define _open_do_pqr(stem) \ - static u3_noun _open_in_##stem \ - ( u3_noun ter, u3_noun p_gen, u3_noun q_gen, u3_noun r_gen) - -#define _open_do_pqrs(stem) \ - static u3_noun _open_in_##stem \ - ( u3_noun ter, u3_noun p_gen, u3_noun q_gen, u3_noun r_gen, \ - u3_noun s_gen) - -/*** -**** -***/ - _open_do_pq(tsbr) // =: - { - return u3nt(c3__tsls, - _ap_bunt(_al_core(ter, p_gen), p_gen), - u3k(q_gen)); - } - _open_do_pq(tscl) // =: - { - return u3nt(c3__tsgr, - u3nt(c3__cncb, - u3nc(u3nc(u3_nul, 1), - u3_nul), - u3k(p_gen)), - u3k(q_gen)); - } - _open_do_pqr(tsdt) // =. - { - return u3nt(c3__tsgr, - u3nt(c3__cncb, - u3nc(u3nc(u3_nul, 1), - u3_nul), - u3nc(u3nc(u3k(p_gen), - u3k(q_gen)), - u3_nul)), - u3k(r_gen)); - } - _open_do_pq(tsgl) // =< - { - return u3nt(c3__tsgr, - u3k(q_gen), - u3k(p_gen)); - } - _open_do_pq(tshp) // =- - { - return u3nt(c3__tsls, - u3k(q_gen), - u3k(p_gen)); - } - _open_do_pq(tsls) // =+ - { - return u3nt(c3__tsgr, - u3nc(u3k(p_gen), - u3nc(u3_nul, 1)), - u3k(q_gen)); - } - _open_do_p(tssg) // =~ - { - if ( !_(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)); - } - } - } -/*** -**** -***/ - _open_do_p(bccb) // $_ - { - return _ap_bunt(_al_core(ter, p_gen), p_gen); - } - _open_do_p(bctr) // $* - { - return - u3nc(c3__ktsg, - _ap_bunt(_al_core(ter, p_gen), - p_gen)); - } - _open_do_p(bczp) // $! - { - return u3nt(c3__bccb, - c3__axil, - u3k(p_gen)); - } -/*** -**** -***/ - _open_do_p(brhp) // |- - { - return u3nt(c3__tsgl, - u3nc(c3__cnzy, u3_blip), - u3nc(c3__brdt, u3k(p_gen))); - } - _open_do_p(brdt) // |. - { - return u3nc(c3__brcn, - u3nt(u3nt(u3_blip, c3__ash, u3k(p_gen)), - u3_nul, - u3_nul)); - } - -/*** -**** -***/ - _open_do_p(wtbr) // ?| - { - if ( (u3_nul == p_gen) ) { - return u3nt(c3__dtzz, 'f', c3n); - } - else { - u3_noun ip_gen = u3h(p_gen); - u3_noun tp_gen = u3t(p_gen); - - return u3nq(c3__wtcl, - u3k(ip_gen), - u3nt(c3__dtzz, 'f', c3y), - _open_in_wtbr(ter, tp_gen)); - } - } - _open_do_pqr(wtkt) // ?^ - { - return u3nq(c3__wtcl, - u3nt(c3__wtts, - u3nt(c3__axil, c3__atom, u3_blip), - u3k(p_gen)), - u3k(r_gen), - u3k(q_gen)); - } - _open_do_pq(wtgl) // ?< - { - return u3nq(c3__wtcl, - u3k(p_gen), - u3nc(c3__zpzp, u3_nul), - u3k(q_gen)); - } - _open_do_pqr(wtdt) // ?. - { - return u3nq(c3__wtcl, - u3k(p_gen), - u3k(r_gen), - u3k(q_gen)); - } - _open_do_pq(wtgr) // ?> - { - return u3nq(c3__wtcl, - u3k(p_gen), - u3k(q_gen), - u3nc(c3__zpzp, u3_nul)); - } - _open_do_pq(wthp) // ?- - { - if ( (u3_nul == q_gen) ) { - return u3nc(c3__zpfs, - u3nc(c3__cnzz, - u3k(p_gen))); - } - else { - u3_noun iq_gen = u3h(q_gen); - u3_noun tq_gen = u3t(q_gen); - u3_noun piq_gen = u3h(iq_gen); - u3_noun qiq_gen = u3t(iq_gen); - - return u3nq(c3__wtcl, - u3nt(c3__wtts, - u3k(piq_gen), - u3k(p_gen)), - u3k(qiq_gen), - _open_in_wthp(ter, p_gen, tq_gen)); - } - } - _open_do_p(wtpm) // ?& - { - if ( (u3_nul == p_gen) ) { - return u3nt(c3__dtzz, 'f', c3y); - } - else { - u3_noun ip_gen = u3h(p_gen); - u3_noun tp_gen = u3t(p_gen); - - return u3nq(c3__wtcl, - u3k(ip_gen), - _open_in_wtpm(ter, tp_gen), - u3nt(c3__dtzz, 'f', c3n)); - } - } - _open_do_pqr(wtls) // ?+ - { u3_noun tul = u3nc(u3nc(u3nc(c3__axil, c3__noun), - u3k(q_gen)), - u3_nul); - u3_noun zal = u3qb_weld(r_gen, tul); - u3_noun ret = u3nt(c3__wthp, u3k(p_gen), zal); - - u3z(tul); - return ret; - - } - _open_do_pqr(wtpt) // ?@ - { - return u3nq(c3__wtcl, - u3nt(c3__wtts, - u3nt(c3__axil, - c3__atom, - u3_blip), - u3k(p_gen)), - u3k(q_gen), - u3k(r_gen)); - } - _open_do_pqr(wtsg) // ?~ - { - return u3nq(c3__wtcl, - u3nt(c3__wtts, - u3nc(c3__axil, c3__null), - u3k(p_gen)), - u3k(q_gen), - u3k(r_gen)); - } - _open_do_p(wtzp) // ?! - { - return u3nq(c3__wtcl, - u3k(p_gen), - u3nt(c3__dtzz, 'f', c3n), - u3nt(c3__dtzz, 'f', c3y)); - } -/*** -**** -***/ - _open_do_pq(zpcb) // !_ - { - return u3k(q_gen); - } - _open_do_p(zpgr) // !> - { - return u3nq(c3__cnhp, - u3nc(c3__cnzy, c3__onan), - u3nt(c3__zpsm, - u3nc(c3__bctr, - u3nc(c3__herb, - u3nc(c3__cnzy, - c3__abel))), - u3k(p_gen)), - u3_nul); - } -/*** -**** -***/ - _open_do_pq(clhp) // :- - { - return u3nc(u3k(p_gen), - u3k(q_gen)); - } - _open_do_pq(clcb) // :_ - { - return u3nc(u3k(q_gen), - u3k(p_gen)); - } - _open_do_p(clcn) // :% - { - return u3nc(u3nc(c3__clsg, - u3k(p_gen)), - u3nc(c3__bczp, c3__null)); - } - _open_do_pqrs(clkt) // :^ - { - return u3nq(u3k(p_gen), - u3k(q_gen), - u3k(r_gen), - u3k(s_gen)); - } - _open_do_pqr(clls) // :+ - { - return u3nt(u3k(p_gen), - u3k(q_gen), - u3k(r_gen)); - } - _open_do_p(clsg) // :~ - { - if ( (u3_nul == p_gen) ) { - return u3nt(c3__dtzz, 'n', u3_nul); - } - else { - u3_noun ip_gen = u3h(p_gen); - u3_noun tp_gen = u3t(p_gen); - - return u3nc(u3k(ip_gen), - _open_in_clsg(ter, tp_gen)); - } - } - _open_do_p(cltr) // :* - { - if ( (u3_nul == p_gen) ) { - return u3nc(c3__zpzp, u3_nul); - } - else { - u3_noun ip_gen = u3h(p_gen); - u3_noun tp_gen = u3t(p_gen); - - if ( (u3_nul == tp_gen) ) { - return u3k(ip_gen); - } else { - return u3nc(u3k(ip_gen), - _open_in_cltr(ter, tp_gen)); - } - } - } -/*** -**** -***/ - _open_do_pq(cncb) // %_ - { - return u3nc(c3__ktls, - u3nq(u3nc(c3__cnzz, u3k(p_gen)), - c3__cnts, - u3k(p_gen), - u3k(q_gen))); - } -#if 0 - _open_do_pq(cncl) // %: - { - return u3nq - (c3__cnsg, - u3nc(u3_blip, u3_nul), - u3k(p_gen), - u3k(q_gen)); - } -#endif - _open_do_pq(cndt) // %. - { - return u3nt(c3__cnhp, - u3k(q_gen), - u3nc(u3k(p_gen), u3_nul)); - } - _open_do_pqrs(cnkt) // %^ - { - return u3nq(c3__cnhp, - u3k(p_gen), - u3k(q_gen), - u3nt(u3k(r_gen), - u3k(s_gen), - u3_nul)); - } - _open_do_pq(cnhp) // %- - { - if ( (u3_nul == q_gen) ) { - return u3nt(c3__tsgr, - u3k(p_gen), - u3nc(c3__cnzy, u3_blip)); - } else { - return u3nq(c3__cncl, - u3k(p_gen), - c3__cltr, - u3k(q_gen)); - } - } - _open_do_pqr(cnls) // %+ - { - return u3nc(c3__cnhp, - u3nq(u3k(p_gen), - u3k(q_gen), - u3k(r_gen), - u3_nul)); - } - _open_do_pqr(cnsg) // %~ - { - return u3nq(c3__cntr, - u3k(p_gen), - u3k(q_gen), - u3nc(u3nc(u3nc(u3nc(u3_nul, 6), 0), u3k(r_gen)), 0)); - } - _open_do_p(cnzy) // %cnzy - { - return u3nt(c3__cnts, - u3nc(u3k(p_gen), u3_nul), - u3_nul); - } - _open_do_p(cnzz) // %cnzz - { - return u3nt(c3__cnts, u3k(p_gen), u3_nul); - } -/*** -**** -***/ - _open_do_p(hxgl) // #< - { - return u3nq(c3__cnhp, - u3nc(c3__cnzy, c3__noah), - u3nc(c3__zpgr, - u3nc(c3__cltr, u3k(p_gen))), - u3_nul); - } - _open_do_p(hxgr) // #> - { - return u3nq(c3__cnhp, - u3nc(c3__cnzy, c3__cain), - u3nc(c3__zpgr, - u3nc(c3__cltr, u3k(p_gen))), - u3_nul); - } -/*** -**** -***/ - _open_do_pq(ktdt) // ^. - { - return u3nt(c3__ktls, - u3nq(c3__cnhp, u3k(p_gen), u3k(q_gen), u3_nul), - u3k(q_gen)); - } -#if 0 - _open_do_pq(kthp) // ^- - { - return u3nt(c3__ktls, - _ap_bunt(_al_bore(ter, p_gen), p_gen), - u3k(q_gen)); - } -#endif -/*** -**** -***/ - _open_do_pq(brcb) // |_ - { - return u3nt(c3__tsls, - u3nc(c3__bctr, u3k(p_gen)), - u3nc(c3__brcn, u3k(q_gen))); - } - _open_do_pq(brkt) // |^ - { - u3_noun diz = u3nc(c3__ash, u3k(p_gen)); - u3_noun ret = u3nt(c3__tsgr, - u3nc(c3__brcn, - u3qdb_put(q_gen, u3_blip, diz)), - u3nc(c3__cnzy, u3_blip)); - - u3z(diz); - return ret; - } - _open_do_pq(brls) // |+ - { - return u3nc(c3__ktbr, - u3nt(c3__brts, - u3k(p_gen), - u3k(q_gen))); - } - _open_do_p(brwt) // |? - { - return u3nt(c3__ktwt, - c3__brdt, - u3k(p_gen)); - } -/*** -**** -***/ - _open_do_pq(sgts) // ~= - { - return u3nt(c3__sggr, - u3nc(c3__germ, u3k(p_gen)), - u3k(q_gen)); - } -#if 0 - _open_do_pq(sgbr) // ~| - { - return u3nt - (c3__sggr, - u3nc(c3__mean, u3k(p_gen)), - u3k(q_gen)); - } -#endif - _open_do_pq(sggl) // ~> - { - return u3nt(c3__tsgl, - u3nq(c3__sggr, u3k(p_gen), u3_nul, 1), - u3k(q_gen)); - } - _open_do_pq(sgbc) // ~$ - { - return u3nt(c3__sggr, - u3nq(c3__live, - c3__dtzz, - u3_blip, - u3k(p_gen)), - u3k(q_gen)); - } - _open_do_pq(sgcb) // ~_ - { - return u3nt(c3__sggr, - u3nc(c3__mean, - u3nc(c3__brdt, - u3k(p_gen))), - u3k(q_gen)); - } - static u3_noun - _sgcn_a(u3_noun r_gen, - u3_noun nob) - { - if ( c3n == u3du(r_gen) ) { - return u3k(nob); - } else { - u3_noun ir_gen = u3h(r_gen); - u3_noun tr_gen = u3t(r_gen); - u3_noun pir_gen, qir_gen; - - u3x_cell(ir_gen, &pir_gen, &qir_gen); - - return u3nc(u3nc(u3nt(c3__dtzz, u3_blip, u3k(pir_gen)), - u3nc(c3__zpts, u3k(qir_gen))), - _sgcn_a(tr_gen, nob)); - } - } - _open_do_pqrs(sgcn) // ~% - { - return u3nt(c3__sggl, - u3nq(c3__sgcn, - c3__clls, - u3nt(c3__dtzz, u3_blip, u3k(p_gen)), - u3nt(u3nc(c3__zpts, u3k(q_gen)), - c3__clsg, - _sgcn_a(r_gen, u3_nul))), - u3k(s_gen)); - } - _open_do_pq(sgfs) // ~/ - { - return u3nc(c3__sgcn, - u3nq(u3k(p_gen), - u3nc(u3_nul, 7), - u3_nul, - u3k(q_gen))); - } - _open_do_pq(sgls) // ~+ - { - return u3nt(c3__sggr, - u3nq(c3__sgls, c3__dtzz, u3_blip, u3k(p_gen)), - u3k(q_gen)); - } - _open_do_pqr(sgpm) // ~& - { - return u3nt(c3__sggr, - u3nt(c3__slog, - u3nt(c3__dtzy, u3_blip, u3k(p_gen)), - u3nq(c3__cnhp, u3nc(c3__cnzy, c3__cain), - u3nc(c3__zpgr, u3k(q_gen)), u3_nul)), - u3k(r_gen)); - } - _open_do_pqrs(sgwt) // ~? - { - return u3nt(c3__tsls, - u3nq(c3__wtdt, - u3k(q_gen), - u3nc(c3__bczp, c3__null), - u3nc(u3nc(c3__bczp, c3__null), u3k(r_gen))), - u3nq(c3__wtsg, - u3nc(u3nc(u3_nul, 2),u3_nul), - u3nt(c3__tsgr, - u3nc(u3_nul, 3), - u3k(s_gen)), - u3nq(c3__sgpm, - u3k(p_gen), - u3nc(u3_nul, 5), - u3nt(c3__tsgr, - u3nc(u3_nul, 3), - u3k(s_gen))))); - } -/*** -**** -***/ - static u3_noun - _smcl_in(u3_noun q_gen) - { - u3_noun hq_gen = u3h(q_gen); - u3_noun tq_gen = u3t(q_gen); - - if ( c3n == u3du(tq_gen) ) { - return u3nt(c3__tsgr, - u3nc(u3_nul, 3), - u3k(hq_gen)); - } else { - return u3nc(c3__cnhp, - u3nq(u3nc(u3_nul, 2), - u3nt(c3__tsgr, - u3nc(u3_nul, 3), - u3k(hq_gen)), - _smcl_in(tq_gen), - u3_nul)); - } - } - _open_do_pq(smcl) - { - if ( c3n == u3du(q_gen) ) { - return u3nc(c3__zpzp, u3_nul); - } - else if ( u3_nul == u3t(q_gen) ) { - return u3k(u3h(q_gen)); - } - else { - return u3nt(c3__tsls, - u3k(p_gen), - _smcl_in(q_gen)); - } - } -#if 0 - _open_do_pq(smsm) - { - return - u3nt(c3__tsgr, u3nq(c3__ktts, c3__v, u3_nul, 1), - u3nt(c3__tsls, - u3nt(c3__ktts, c3__a, - u3nt(c3__tsgr, u3nc(c3__cnzy, c3__v), - u3k(p_gen))), - u3nt(c3__tsls, - u3nt(c3__ktts, c3__b, - u3nt(c3__tsgr, - u3nc(c3__cnzy, c3__v), - u3k(q_gen))), - u3nt(c3__tsls, - u3nt(c3__ktts, c3__c, - u3nq(c3__cnhp, - u3nc(c3__cnzy, c3__a), - u3nc(c3__cnzy, c3__b), - u3_nul)), - u3nt(c3__wtgr, - u3nt(c3__dtts, - u3nc(c3__cnzy, c3__c), - u3nc(c3__cnzy, c3__b)), - u3nc(c3__cnzy, c3__c)))))); - } -#endif - -/* functions -*/ - /** open - **/ - static u3_noun - _open_in(u3_noun ter, - u3_noun gen) - { - u3_noun p_gen, q_gen, r_gen, s_gen; - - return u3_none; - - if ( c3y == u3ud(gen) ) { - // printf("studly\n"); - // u3_err("stud m", gen); - return u3m_bail(c3__exit); - - return u3nt(c3__cnts, - u3nc(u3k(gen), u3_nul), - u3_nul); - } - else switch ( u3h(gen) ) { - default: return u3_none; - - case u3_nul: { - return u3nt(c3__cnts, - u3nc(u3k(gen), u3_nul), - u3_nul); - } - -# define _open_p(stem) \ - case c3__##stem: \ - return _open_in_##stem(ter, u3t(gen)); \ - -# define _open_pq(stem) \ - case c3__##stem: \ - if ( c3n == u3r_cell(u3t(gen), &p_gen, &q_gen) ) { \ - return u3m_bail(c3__fail); \ - } else return _open_in_##stem(ter, p_gen, q_gen); - -# define _open_pqr(stem) \ - case c3__##stem: \ - if ( c3n == u3r_trel(u3t(gen), &p_gen, &q_gen, &r_gen) ) { \ - return u3m_bail(c3__fail); \ - } else return _open_in_##stem(ter, p_gen, q_gen, r_gen); - -# define _open_pqrs(stem) \ - case c3__##stem: \ - if ( c3n == u3r_qual\ - (u3t(gen), &p_gen, &q_gen, &r_gen, &s_gen) )\ - { \ - return u3m_bail(c3__fail); \ - } else return _open_in_##stem(ter, p_gen, q_gen, r_gen, s_gen); - - _open_p (bccb); - _open_p (bctr); - _open_p (bczp); - - _open_p (brdt); - _open_pq (brcb); - _open_p (brhp); - _open_pq (brkt); - _open_pq (brls); - _open_p (brwt); - - _open_pq (clcb); - _open_p (clcn); - _open_pq (clhp); - _open_pqrs(clkt); - _open_pqr (clls); - _open_p (cltr); - _open_p (clsg); - _open_pq (cncb); - // _open_pq (cncl); - _open_pq (cndt); - _open_pqrs(cnkt); - _open_pq (cnhp); - _open_pqr (cnls); - _open_pqr (cnsg); - _open_p (cnzy); - _open_p (cnzz); - - _open_p (hxgl); - _open_p (hxgr); - - _open_pq (ktdt); -// _open_pq (kthp); - - _open_pq (sgts); -// _open_pq (sgbr); - _open_pq (sggl); - _open_pq (sgbc); - _open_pq (sgcb); - _open_pqrs(sgcn); - _open_pq (sgfs); - _open_pq (sgls); - _open_pqr (sgpm); - _open_pqrs(sgwt); - - _open_pq (smcl); - // _open_pq (smsm); - - _open_pq (tsbr); - _open_pq (tscl); - _open_pqr (tsdt); - _open_pq (tsgl); - _open_pq (tshp); - _open_pq (tsls); - _open_p (tssg); - - _open_pqr (wtdt); - _open_pq (wtgl); - _open_pqr (wtpt); - _open_pqr (wtsg); - _open_p (wtzp); - _open_p (wtbr); - _open_pq (wthp); - _open_pq (wtgr); - _open_pqr (wtls); - _open_pqr (wtkt); - _open_p (wtpm); - - _open_pq (zpcb); - _open_p (zpgr); - } - } - - /** rake - **/ - u3_noun - u3qzp_rake(u3_noun gen) - { - u3_noun p_gen, q_gen; - - if ( c3y == u3ud(gen) ) { - return u3nc(u3k(gen), u3_nul); - } - else switch ( u3h(gen) ) { - default: return u3m_error("rake-twig"); - - case u3_nul: return u3nc(u3k(gen), u3_nul); - - case c3__cnzy: { - return u3nc(u3k(u3t(gen)), u3_nul); - } - case c3__cnzz: { - return u3k(u3t(gen)); - } - case c3__cnts: { - if ( c3n == u3r_cell(u3t(gen), &p_gen, &q_gen) ) { - return u3m_bail(c3__fail); - } - else { - if ( u3_nul != q_gen ) { - return u3m_bail(c3__fail); - } - else { - return u3k(p_gen); - } - } - } - case c3__zpcb: { - if ( c3n == u3r_cell(u3t(gen), &p_gen, &q_gen) ) { - return u3m_bail(c3__fail); - } - else return u3qzp_rake(q_gen); - } - } - } - u3_noun - u3wzp_rake(u3_noun cor) - { - u3_noun gen; - - if ( u3_none == (gen = u3r_at(u3x_sam, cor)) ) { - return u3m_bail(c3__fail); - } else { - return u3qzp_rake(gen); - } - } - - /** hack - **/ - u3_noun - u3qzp_hack(u3_noun ter, - u3_noun gen) - { - u3_noun p_gen, q_gen; - u3_noun ret; - - if ( c3y == u3du(u3h(gen)) ) { - return u3nt(c3y, - u3k(u3h(gen)), - u3k(u3t(gen))); - } - else switch ( u3h(gen) ) { - case c3__tsgr: u3x_cell(u3t(gen), &p_gen, &q_gen); - { - if ( (c3n == u3du(p_gen)) || (u3_nul != u3h(p_gen)) ) { - return u3nc(c3n, u3k(gen)); - } - else { - u3_noun pyr = u3qzp_hack(ter, q_gen); - - if ( c3y == u3h(pyr) ) { - ret = u3nt(c3y, - u3nt(c3__tsgr, - u3k(p_gen), - u3k(u3h(u3t(pyr)))), - u3nt(c3__tsgr, - u3k(p_gen), - u3k(u3t(u3t(pyr))))); - } - else { - ret = u3nc(c3n, - u3nt(c3__tsgr, - u3k(p_gen), - u3k(u3t(pyr)))); - } - u3z(pyr); - return ret; - } - } - case c3__zpcb: u3x_cell(u3t(gen), &p_gen, &q_gen); - { - u3_noun pyr = u3qzp_hack(ter, q_gen); - - if ( c3y == u3h(pyr) ) { - ret = u3nt(c3y, - u3nt(c3__zpcb, - u3k(p_gen), - u3k(u3h(u3t(pyr)))), - u3nt(c3__zpcb, - u3k(p_gen), - u3k(u3t(u3t(pyr))))); - } - else { - ret = u3nc(c3n, - u3nt(c3__zpcb, - u3k(p_gen), - u3k(u3t(pyr)))); - } - u3z(pyr); - return ret; - } - default: break; - } - - { - u3_noun voq = _ap_open_l(ter, gen); - - if ( u3_none == voq ) { - return u3nc(c3n, u3k(gen)); - } - else if ( c3y == u3r_sing(voq, gen) ) { - return u3nc(c3n, voq); - } - else { - ret = u3qzp_hack(ter, voq); - - u3z(voq); - return ret; - } - } - } - - u3_noun - u3wzp_hack(u3_noun cor) - { - u3_noun gen; - - if ( u3_none == (gen = u3r_at(u3x_sam, cor)) ) { - return u3m_bail(c3__fail); - } else { - u3_noun ter = u3r_at(u3x_con, cor); - - return u3qzp_hack(ter, gen); - } - } -#endif - -/* boilerplate -*/ - static u3_noun - _ap_core(u3_noun ter, - u3_noun gen) - { - u3_noun gat = u3j_hook(u3k(ter), "ap"); - - return u3i_molt(gat, u3x_sam, u3k(gen), 0); - } - -/* open -*/ - static u3_noun - _ap_open_n(u3_noun ter, - u3_noun fab, - u3_noun gen) - { - u3_noun cor = _ap_core(ter, gen); - -#if 1 - if ( c3n == fab ) { - cor = u3i_molt(cor, 14, c3n, 0); - } -#endif - return u3j_soft(cor, "open"); - } - static u3_noun - _ap_open_l(u3_noun ter, - u3_noun fab, - u3_noun gen) - { -#if 0 - u3_noun pro = _open_in(ter, gen); - - if ( u3_none != pro ) { - return pro; - } else { - return _ap_open_n(ter, gen); - } -#else - return _ap_open_n(ter, fab, gen); -#endif - } - - u3_noun - u3qzp_open(u3_noun ter, - u3_noun fab, - u3_noun gen) - { - return _ap_open_l(ter, fab, gen); - } - - u3_noun - u3wzp_open(u3_noun cor) - { - u3_noun gen; - - if ( u3_none == (gen = u3r_at(u3x_sam, cor)) ) { - return u3m_bail(c3__fail); - } else { - u3_noun ter = u3r_at(u3x_con, cor); - - return u3qzp_open(ter, c3y, gen); - } - } - diff --git a/jets/z/cell.c b/jets/z/cell.c deleted file mode 100644 index a260565af..000000000 --- a/jets/z/cell.c +++ /dev/null @@ -1,29 +0,0 @@ -/* j/6/cell.c -** -*/ -#include "all.h" - - -/* functions -*/ - u3_noun - u3qz_cell(u3_noun hed, - u3_noun tal) - { - if ( (c3__void == hed) || (c3__void == tal) ) { - return c3__void; - } else { - return u3nt(c3__cell, u3k(hed), u3k(tal)); - } - } - u3_noun - u3wz_cell(u3_noun cor) - { - u3_noun hed, tal; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &hed, u3x_sam_3, &tal, 0) ) { - return u3m_bail(c3__fail); - } else { - return u3qz_cell(hed, tal); - } - } diff --git a/jets/z/comb.c b/jets/z/comb.c deleted file mode 100644 index ba2669a25..000000000 --- a/jets/z/comb.c +++ /dev/null @@ -1,70 +0,0 @@ -/* j/6/comb.c -** -*/ -#include "all.h" - - -/* functions -*/ - u3_noun - u3qz_comb(u3_noun mal, - u3_noun buz) - { - if ( (u3_none == mal) || (u3_none == buz) ) { - return u3_none; - } - else { - u3_noun p_mal, q_mal, p_buz, q_buz, pp_buz, pq_buz; - - if ( (c3y == u3r_p(mal, 0, &p_mal)) && (0 != p_mal) ) { - if ( (c3y == u3r_p(buz, 0, &p_buz)) && (0 != p_buz) ) { - return u3nc(0, - u3qc_peg(p_mal, p_buz)); - } - else if ( c3y == u3r_pq(buz, 2, &p_buz, &q_buz) && - c3y == u3r_p(p_buz, 0, &pp_buz) && - c3y == u3r_p(q_buz, 0, &pq_buz) ) - { - return u3nt(2, - u3nc(0, - u3qc_peg(p_mal, pp_buz)), - u3nc(0, - u3qc_peg(p_mal, pq_buz))); - } - else return u3nt(7, - u3k(mal), - u3k(buz)); - } -#if 1 - else if ( (c3y == u3r_bush(mal, &p_mal, &q_mal)) && - (c3y == u3du(p_mal)) && - (c3y == u3du(q_mal)) && - (0 == u3h(q_mal)) && - (1 == u3t(q_mal)) ) - { - return u3nt(8, - u3k(p_mal), - u3k(buz)); - } -#endif - else if ( (c3y == u3r_p(buz, 0, &p_buz)) && - (c3y == u3r_sing(1, p_buz)) ) - { - return u3k(mal); - } - else return u3nt(7, - u3k(mal), - u3k(buz)); - } - } - u3_noun - u3wz_comb(u3_noun cor) - { - u3_noun mal, buz; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &mal, u3x_sam_3, &buz, 0) ) { - return u3_none; - } else { - return u3qz_comb(mal, buz); - } - } diff --git a/jets/z/cons.c b/jets/z/cons.c deleted file mode 100644 index 09a2c541e..000000000 --- a/jets/z/cons.c +++ /dev/null @@ -1,52 +0,0 @@ -/* j/6/cons.c -** -*/ -#include "all.h" - - -/* functions -*/ - u3_noun - u3qz_cons(u3_noun vur, - u3_noun sed) - { - u3_noun p_vur, p_sed; - - if ( c3y == u3r_p(vur, 1, &p_vur) && - c3y == u3r_p(sed, 1, &p_sed) ) { - return u3nt(1, - u3k(p_vur), - u3k(p_sed)); - } - else if ( c3y == u3r_p(vur, 0, &p_vur) && - c3y == u3r_p(sed, 0, &p_sed) && - !(c3y == u3r_sing(1, p_vur)) && - !(c3y == u3r_sing(p_vur, p_sed)) && - (0 == u3r_nord(p_vur, p_sed)) ) - { - u3_atom fub = u3qa_div(p_vur, 2); - u3_atom nof = u3qa_div(p_sed, 2); - - if ( c3y == u3r_sing(fub, nof) ) { - u3z(nof); - - return u3nc(0, fub); - } - else { - u3z(fub); - u3z(nof); - } - } - return u3nc(u3k(vur), u3k(sed)); - } - u3_noun - u3wz_cons(u3_noun cor) - { - u3_noun vur, sed; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &vur, u3x_sam_3, &sed, 0) ) { - return u3m_bail(c3__fail); - } else { - return u3qz_cons(vur, sed); - } - } diff --git a/jets/z/core.c b/jets/z/core.c deleted file mode 100644 index 8a4092172..000000000 --- a/jets/z/core.c +++ /dev/null @@ -1,42 +0,0 @@ -/* j/6/core.c -** -*/ -#include "all.h" - - -/* functions -*/ - u3_noun - u3qz_core(u3_noun pac, - u3_noun con) - { - if ( (c3__void == pac) ) { - return c3__void; - } else { - { - u3_noun p_con, q_con, r_con, hr_con, tr_con; - - u3r_trel(con, &p_con, &q_con, &r_con); - u3r_cell(r_con, &hr_con, &tr_con); - if ( (c3y == u3du(hr_con)) && - (u3_nul == u3h(hr_con)) && - (u3_nul == u3t(hr_con)) ) - { - fprintf(stderr, "old core\r\n"); - abort(); - } - } - return u3nt(c3__core, u3k(pac), u3k(con)); - } - } - u3_noun - u3wz_core(u3_noun cor) - { - u3_noun pac, con; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &pac, u3x_sam_3, &con, 0) ) { - return u3m_bail(c3__fail); - } else { - return u3qz_core(pac, con); - } - } diff --git a/jets/z/face.c b/jets/z/face.c deleted file mode 100644 index d06f7b555..000000000 --- a/jets/z/face.c +++ /dev/null @@ -1,31 +0,0 @@ -/* j/6/face.c -** -*/ -#include "all.h" - - -/* functions -*/ - u3_noun - u3qz_face(u3_noun sag, - u3_noun tip) - { - if ( c3__void == tip ) { - return c3__void; - } - else return u3nt(c3__face, - u3k(sag), - u3k(tip)); - } - u3_noun - u3wz_face(u3_noun cor) - { - u3_noun sag, tip; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &sag, u3x_sam_3, &tip, 0) ) { - return u3m_bail(c3__fail); - } else { - return u3qz_face(sag, tip); - } - } - diff --git a/jets/z/fine.c b/jets/z/fine.c deleted file mode 100644 index 0647084ad..000000000 --- a/jets/z/fine.c +++ /dev/null @@ -1,35 +0,0 @@ -/* j/6/fine.c -** -*/ -#include "all.h" - - -/* functions -*/ - u3_noun - u3qz_fine(u3_noun fuv, - u3_noun lup, - u3_noun mar) - { - if ( (c3__void == lup) || (c3__void == mar) ) { - return c3__void; - } else { - return u3nq(c3__fine, - u3k(fuv), - u3k(lup), - u3k(mar)); - } - } - u3_noun - u3wz_fine(u3_noun cor) - { - u3_noun fuv, lup, mar; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &fuv, - u3x_sam_6, &lup, - u3x_sam_7, &mar, 0) ) { - return u3m_bail(c3__fail); - } else { - return u3qz_fine(fuv, lup, mar); - } - } diff --git a/jets/z/fitz.c b/jets/z/fitz.c deleted file mode 100644 index 722d5b73f..000000000 --- a/jets/z/fitz.c +++ /dev/null @@ -1,67 +0,0 @@ -/* j/6/fitz.c -** -*/ -#include "all.h" - - -/* functions -*/ - static u3_noun - _fitz_fiz(u3_noun yaz, - u3_noun wix) - { - c3_w yaz_w = u3r_met(3, yaz); - c3_w wix_w = u3r_met(3, wix); - c3_y yaz_y, wix_y; - - yaz_y = (0 == yaz_w) ? 0 : u3r_byte((yaz_w - 1), yaz); - if ( (yaz_y < 'A') || (yaz_y > 'Z') ) yaz_y = 0; - - wix_y = (0 == wix_w) ? 0 : u3r_byte((wix_w - 1), wix); - if ( (wix_y < 'A') || (wix_y > 'Z') ) wix_y = 0; - - if ( yaz_y && wix_y ) { - if ( !wix_y || (wix_y > yaz_y) ) { - return c3n; - } - } - return c3y; - } - - u3_noun - u3qz_fitz(u3_noun yaz, - u3_noun wix) - { - c3_w i_w, met_w = c3_min(u3r_met(3, yaz), u3r_met(3, wix)); - - if ( c3n == _fitz_fiz(yaz, wix) ) { - return c3n; - } - for ( i_w = 0; i_w < met_w; i_w++ ) { - c3_y yaz_y = u3r_byte(i_w, yaz); - c3_y wix_y = u3r_byte(i_w, wix); - - if ( (yaz_y >= 'A') && (yaz_y <= 'Z') ) yaz_y = 0; - if ( (wix_y >= 'A') && (wix_y <= 'Z') ) wix_y = 0; - - if ( yaz_y && wix_y && (yaz_y != wix_y) ) { - return c3n; - } - } - return c3y; - } - - u3_noun - u3wz_fitz(u3_noun cor) - { - u3_noun yaz, wix; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &yaz, u3x_sam_3, &wix, 0)) || - (c3n == u3ud(yaz)) || - (c3n == u3ud(wix)) ) - { - return u3m_bail(c3__fail); - } else { - return u3qz_fitz(yaz, wix); - } - } diff --git a/jets/z/flan.c b/jets/z/flan.c deleted file mode 100644 index 2d6dcf445..000000000 --- a/jets/z/flan.c +++ /dev/null @@ -1,44 +0,0 @@ -/* j/6/flan.c -** -*/ -#include "all.h" - - -/* functions -*/ - u3_noun - u3qz_flan(u3_noun bos, - u3_noun nif) - { - if ( c3y == u3r_sing(1, u3h(bos)) ) { - if ( (u3_nul == u3t(bos)) ) { - return u3k(nif); - } - else return u3k(bos); - } - else { - if ( c3y == u3r_sing(1, u3h(nif)) ) { - if ( (u3_nul == u3t(nif)) ) { - return u3k(bos); - } - else return u3k(nif); - } - else { - return u3nq(6, - u3k(bos), - u3k(nif), - u3nc(1, c3n)); - } - } - } - u3_noun - u3wz_flan(u3_noun cor) - { - u3_noun bos, nif; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &bos, u3x_sam_3, &nif, 0) ) { - return u3m_bail(c3__fail); - } else { - return u3qz_flan(bos, nif); - } - } diff --git a/jets/z/flip.c b/jets/z/flip.c deleted file mode 100644 index 3a7fef614..000000000 --- a/jets/z/flip.c +++ /dev/null @@ -1,39 +0,0 @@ -/* j/6/flip.c -** -*/ -#include "all.h" - - -/* functions -*/ - u3_noun - u3qz_flip(u3_noun hel) - { - if ( c3y == u3r_sing(1, u3h(hel)) ) { - if ( (c3y == u3t(hel)) ) { - return u3nc(1, c3n); - } - else { - c3_assert((c3n == u3t(hel))); - - return u3nc(1, c3y); - } - } - else { - return u3nq(6, - u3k(hel), - u3nc(1, c3n), - u3nc(1, c3y)); - } - } - u3_noun - u3wz_flip(u3_noun cor) - { - u3_noun hel; - - if ( u3_none == (hel = u3r_at(u3x_sam, cor)) ) { - return u3m_bail(c3__fail); - } else { - return u3qz_flip(hel); - } - } diff --git a/jets/z/flor.c b/jets/z/flor.c deleted file mode 100644 index 1cc77b064..000000000 --- a/jets/z/flor.c +++ /dev/null @@ -1,44 +0,0 @@ -/* j/6/flor.c -** -*/ -#include "all.h" - - -/* functions -*/ - u3_noun - u3qz_flor(u3_noun bos, - u3_noun nif) - { - if ( c3y == u3r_sing(1, u3h(bos)) ) { - if ( (u3_nul == u3t(bos)) ) { - return u3k(bos); - } - else return u3k(nif); - } - else { - if ( c3y == u3r_sing(1, u3h(nif)) ) { - if ( (u3_nul == u3t(nif)) ) { - return u3k(nif); - } - else return u3k(bos); - } - else { - return u3nq(6, - u3k(bos), - u3nc(1, c3y), - u3k(nif)); - } - } - } - u3_noun - u3wz_flor(u3_noun cor) - { - u3_noun bos, nif; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &bos, u3x_sam_3, &nif, 0) ) { - return u3m_bail(c3__fail); - } else { - return u3qz_flor(bos, nif); - } - } diff --git a/jets/z/fork.c b/jets/z/fork.c deleted file mode 100644 index 6cae22331..000000000 --- a/jets/z/fork.c +++ /dev/null @@ -1,78 +0,0 @@ -/* j/6/fork.c -** -*/ -#include "all.h" - - -/* functions -*/ - u3_noun - u3qz_forq(u3_noun hoz, - u3_noun bur) - { - if ( c3y == u3r_sing(hoz, bur) ) { - return u3k(hoz); - } - else if ( c3__void == bur ) { - return u3k(hoz); - } - else if ( c3__void == hoz ) { - return u3k(bur); - } - else return u3kz_fork(u3nt(u3k(hoz), u3k(bur), u3_nul)); - } - - u3_noun - u3qz_fork(u3_noun yed) - { - u3_noun lez = u3_nul; - - while ( u3_nul != yed ) { - u3_noun i_yed = u3h(yed); - - if ( c3__void != i_yed ) { - if ( (c3y == u3du(i_yed)) && (c3__fork == u3h(i_yed)) ) { - lez = u3kdi_uni(lez, u3k(u3t(i_yed))); - } - else { - lez = u3kdi_put(lez, u3k(i_yed)); - } - } - - yed = u3t(yed); - } - - if ( u3_nul == lez ) { - return c3__void; - } - else if ( (u3_nul == u3h(u3t(lez))) && (u3_nul == u3t(u3t(lez))) ) { - u3_noun ret = u3k(u3h(lez)); - - u3z(lez); - return ret; - } - else { - return u3nc(c3__fork, lez); - } - } - - u3_noun - u3wz_fork(u3_noun cor) - { - u3_noun yed; - - if ( c3n == u3r_mean(cor, u3x_sam, &yed, 0) ) { - return u3m_bail(c3__fail); - } else { - return u3qz_fork(yed); - } - } - - u3_noun - u3kz_fork(u3_noun yed) - { - u3_noun ret = u3qz_fork(yed); - - u3z(yed); - return ret; - } diff --git a/jets/z/hike.c b/jets/z/hike.c deleted file mode 100644 index 54b13306e..000000000 --- a/jets/z/hike.c +++ /dev/null @@ -1,136 +0,0 @@ -/* j/6/hike.c -** -*/ -#include "all.h" - - -/* internal tools -*/ - /* _lily_hike_belt_root(): convert (pac) to a list of root tools. - */ - static u3_noun - _lily_hike_belt_root(u3_noun pac) - { - if ( (u3_nul == pac) ) { - return u3_nul; - } - else { - u3_atom axis = u3h(u3h(pac)); - u3_noun tool = u3t(u3h(pac)); - u3_noun list_tool = _lily_hike_belt_root(u3t(pac)); - - if ( c3y == u3r_sing(1, axis) ) { - return u3nc(u3k(tool), - list_tool); - } - else return list_tool; - } - } - - /* _lily_hike_belt_l(): factor (pac) left. - */ - static u3_noun - _lily_hike_belt_l(u3_noun pac) - { - if ( (u3_nul == pac) ) { - return u3_nul; - } - else { - u3_atom axis = u3h(u3h(pac)); - u3_noun tool = u3t(u3h(pac)); - u3_noun belt_l = _lily_hike_belt_l(u3t(pac)); - - { - if ( (1 != axis) && - (c3y == u3r_sing(2, u3qc_cap(axis))) ) - { - u3_atom axis_tap = u3qc_mas(axis); - - return u3nc(u3nc(u3k(axis_tap), - u3k(tool)), - belt_l); - } - else return belt_l; - } - } - } - - /* _lily_hike_belt_r(): factor (pac) right. - */ - static u3_noun - _lily_hike_belt_r(u3_noun pac) - { - if ( (u3_nul == pac) ) { - return u3_nul; - } - else { - u3_atom axis = u3h(u3h(pac)); - u3_noun tool = u3t(u3h(pac)); - u3_noun belt_r = _lily_hike_belt_r(u3t(pac)); - - { - if ( (1 != axis) && - (c3y == u3r_sing(3, u3qc_cap(axis))) ) - { - u3_atom axis_tap = u3qc_mas(axis); - - return u3nc(u3nc(u3k(axis_tap), - u3k(tool)), - belt_r); - } - else return belt_r; - } - } - } - -/* functions -*/ - u3_noun - u3qz_hike(u3_noun axe, - u3_noun pac) - { - if ( (u3_nul == pac) ) { - return u3nc(0, u3k(axe)); - } - else { - u3_noun zet = _lily_hike_belt_root(pac); - - if ( u3_nul != zet ) { - u3_noun fol = u3k(u3h(zet)); - - u3z(zet); - return fol; - } - else { - u3_noun tum = _lily_hike_belt_l(pac); - u3_noun gam = _lily_hike_belt_r(pac); - u3_noun hax = u3qc_peg(axe, 2); - u3_noun moz = u3qc_peg(axe, 3); - u3_noun zip = u3qz_hike(hax, tum); - u3_noun dof = u3qz_hike(moz, gam); - u3_noun fol = u3qz_cons(zip, dof); - - u3z(tum); - u3z(gam); - u3z(hax); - u3z(moz); - u3z(zip); - u3z(dof); - - return fol; - } - } - } - u3_noun - u3wz_hike(u3_noun cor) - { - u3_noun axe, pac; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &axe, u3x_sam_3, &pac, 0)) || - (c3n == u3ud(axe)) ) - { - return u3m_bail(c3__fail); - } else { - return u3qz_hike(axe, pac); - } - } diff --git a/jets/z/hint.c b/jets/z/hint.c deleted file mode 100644 index 50acbf0cd..000000000 --- a/jets/z/hint.c +++ /dev/null @@ -1,32 +0,0 @@ -/* j/6/help.c -** -*/ -#include "all.h" - - -/* functions -*/ - u3_noun - u3qz_hint(u3_noun sag, - u3_noun tip) - { - if ( c3__void == tip ) { - return c3__void; - } - if ( c3__noun == tip ) { - return c3__noun; - } - else return u3nt(c3__hint, u3k(sag), u3k(tip)); - } - u3_noun - u3wz_hint(u3_noun cor) - { - u3_noun sag, tip; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &sag, u3x_sam_3, &tip, 0) ) { - return u3m_bail(c3__fail); - } else { - return u3qz_hint(sag, tip); - } - } - diff --git a/jets/z/look.c b/jets/z/look.c deleted file mode 100644 index 372c1f5ca..000000000 --- a/jets/z/look.c +++ /dev/null @@ -1,134 +0,0 @@ -/* j/6/look.c -** -*/ -#include "all.h" - - -/* internals -*/ - static u3_noun - _look_in(u3_noun cog, - u3_noun dab, - u3_atom axe) - { - if ( u3_nul == dab ) { - return u3_nul; - } - else { - u3_noun n_dab, l_dab, r_dab; - - u3r_trel(dab, &n_dab, &l_dab, &r_dab); - if ( c3n == u3du(n_dab) ) { - // return u3m_bail(c3__fail); - fprintf(stderr, "bad look\r\n"); - return u3m_bail(c3__exit) ; - } - else { - u3_noun pn_dab = u3h(n_dab); - u3_noun qn_dab = u3t(n_dab); - - if ( (u3_nul == l_dab) && (u3_nul == r_dab) ) { - if ( (c3y == u3du(qn_dab)) && - (c3y == u3r_sing(cog, pn_dab)) ) { - return u3nt(u3_nul, - u3k(axe), - u3k(qn_dab)); - } - else { - return u3_nul; - } - } - else if ( (u3_nul == l_dab) ) { - if ( (c3y == u3du(qn_dab)) && - (c3y == u3r_sing(cog, pn_dab)) ) { - return u3nt(u3_nul, - u3qc_peg(axe, 2), - u3k(qn_dab)); - } - else { - if ( c3y == u3qc_gor(cog, pn_dab) ) { - return u3_nul; - } - else { - u3_noun pro; - - axe = u3qc_peg(axe, 3); - pro = _look_in(cog, r_dab, axe); - u3z(axe); - return pro; - } - } - } - else if ( (u3_nul == r_dab) ) { - if ( (c3y == u3du(qn_dab)) && - (c3y == u3r_sing(cog, pn_dab)) ) { - return u3nt(u3_nul, - u3qc_peg(axe, 2), - u3k(qn_dab)); - } - else { - if ( c3y == u3qc_gor(cog, pn_dab) ) { - u3_noun pro; - - axe = u3qc_peg(axe, 3); - pro = _look_in(cog, l_dab, axe); - u3z(axe); - return pro; - } - else { - return u3_nul; - } - } - } - else { - if ( (c3y == u3du(qn_dab)) && - (c3y == u3r_sing(cog, pn_dab)) ) { - return u3nt(u3_nul, - u3qc_peg(axe, 2), - u3k(qn_dab)); - } - else { - if ( c3y == u3qc_gor(cog, pn_dab) ) { - u3_noun pro; - - axe = u3qc_peg(axe, 6); - pro = _look_in(cog, l_dab, axe); - u3z(axe); - return pro; - } - else { - u3_noun pro; - - axe = u3qc_peg(axe, 7); - pro = _look_in(cog, r_dab, axe); - u3z(axe); - return pro; - } - } - } - } - } - } - - - - -/* functions -*/ - u3_noun - u3qz_look(u3_noun cog, - u3_noun dab) - { - return _look_in(cog, dab, 1); - } - u3_noun - u3wz_look(u3_noun cor) - { - u3_noun cog, dab; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &cog, u3x_sam_3, &dab, 0) ) { - return u3m_bail(c3__fail); - } else { - return u3qz_look(cog, dab); - } - } diff --git a/jets/z/loot.c b/jets/z/loot.c deleted file mode 100644 index 8381535e7..000000000 --- a/jets/z/loot.c +++ /dev/null @@ -1,133 +0,0 @@ -/* j/6/loot.c -** -*/ -#include "all.h" - - -/* internals -*/ - static u3_noun - _loot_in(u3_noun cog, - u3_noun dom, - u3_atom axe) - { - if ( u3_nul == dom ) { - return u3_nul; - } - else { - u3_noun n_dom, l_dom, r_dom; - - u3r_trel(dom, &n_dom, &l_dom, &r_dom); - if ( c3n == u3du(n_dom) ) { - return u3m_bail(c3__fail); - } - else { - u3_noun qn_dom = u3t(n_dom); - u3_noun yep = u3qz_look(cog, qn_dom); - - if ( (u3_nul == l_dom) && (u3_nul == r_dom) ) { - if ( u3_nul == yep ) { - return u3_nul; - } else { - u3_noun u_yep = u3t(yep); - u3_noun pro; - - pro = u3nt(u3_nul, u3qc_peg(axe, u3h(u_yep)), u3k(u3t(u_yep))); - u3z(yep); - return pro; - } - } - else if ( (u3_nul == l_dom) ) { - if ( u3_nul == yep ) { - u3_noun nax = u3qc_peg(axe, 3); - u3_noun pro; - - pro = _loot_in(cog, r_dom, nax); - u3z(nax); - return pro; - } - else { - u3_noun u_yep = u3t(yep); - u3_noun nax = u3qc_peg(axe, 2); - u3_noun pro; - - pro = u3nt(u3_nul, u3qc_peg(nax, u3h(u_yep)), u3k(u3t(u_yep))); - u3z(nax); - u3z(yep); - return pro; - } - } - else if ( (u3_nul == r_dom) ) { - if ( u3_nul == yep ) { - u3_noun nax = u3qc_peg(axe, 3); - u3_noun pro; - - pro = _loot_in(cog, l_dom, nax); - u3z(nax); - return pro; - } - else { - u3_noun u_yep = u3t(yep); - u3_noun nax = u3qc_peg(axe, 2); - u3_noun pro; - - pro = u3nt(u3_nul, u3qc_peg(nax, u3h(u_yep)), u3k(u3t(u_yep))); - u3z(nax); - u3z(yep); - return pro; - } - } - else { - if ( u3_nul == yep ) { - u3_noun nax = u3qc_peg(axe, 6); - u3_noun pey; - - pey = _loot_in(cog, l_dom, nax); - u3z(nax); - - if ( u3_nul != pey ) { - return pey; - } - else { - u3_noun nax = u3qc_peg(axe, 7); - u3_noun pro; - - pro = _loot_in(cog, r_dom, nax); - u3z(nax); - return pro; - } - } - else { - u3_noun u_yep = u3t(yep); - u3_noun nax = u3qc_peg(axe, 2); - u3_noun pro; - - pro = u3nt(u3_nul, u3qc_peg(nax, u3h(u_yep)), u3k(u3t(u_yep))); - u3z(nax); - u3z(yep); - return pro; - } - } - } - } - } - -/* functions -*/ - u3_noun - u3qz_loot(u3_noun cog, - u3_noun dom) - { - return _loot_in(cog, dom, 1); - } - u3_noun - u3wz_loot(u3_noun cor) - { - u3_noun cog, dom; - - if ( c3n == u3r_mean(cor, u3x_sam_2, &cog, u3x_sam_3, &dom, 0) ) { - return u3m_bail(c3__fail); - } else { - return u3qz_loot(cog, dom); - } - } diff --git a/jets/z/slot.c b/jets/z/slot.c deleted file mode 100644 index 0f6781a92..000000000 --- a/jets/z/slot.c +++ /dev/null @@ -1,55 +0,0 @@ -/* j/6/slot.c -** -*/ -#include "all.h" - - -/* functions -*/ - u3_noun - u3qz_slot(u3_atom axe, - u3_noun vax) - { - u3_noun fag = u3r_at(axe, u3t(vax)); - - fprintf(stderr, "slot axe %d\r\n", axe); - - if ( u3_none == fag ) { - return u3m_bail(c3__exit); - } - else { - u3_noun typ = u3qzu_peek( - } - c3_w i_w, met_w = c3_min(u3r_met(3, axe), u3r_met(3, vax)); - - if ( c3n == _slot_fiz(axe, vax) ) { - return c3n; - } - for ( i_w = 0; i_w < met_w; i_w++ ) { - c3_y axe_y = u3r_byte(i_w, axe); - c3_y vax_y = u3r_byte(i_w, vax); - - if ( (axe_y >= 'A') && (axe_y <= 'Z') ) axe_y = 0; - if ( (vax_y >= 'A') && (vax_y <= 'Z') ) vax_y = 0; - - if ( axe_y && vax_y && (axe_y != vax_y) ) { - return c3n; - } - } - return c3y; - } - - u3_noun - u3we_slot(u3_noun cor) - { - u3_noun axe, vax; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &axe, u3x_sam_3, &vax, 0)) || - (c3n == u3ud(axe)) || - (c3n == u3du(vax)) ) - { - return u3m_bail(c3__fail); - } else { - return u3qz_slot(axe, vax); - } - } diff --git a/jets/z/type.c b/jets/z/type.c deleted file mode 100644 index d8eaa518e..000000000 --- a/jets/z/type.c +++ /dev/null @@ -1,42 +0,0 @@ -/* j/6/type.c -** -*/ - -/* new template for type switching -*/ -{ - u3_noun p_sut, q_sut, r_sut; - - if ( c3n == u3du(sut) ) switch ( sut ) { - default: return u3m_bail(c3__fail); - - case c3__noun: - { - } - case c3__void: - { - } - } - else switch ( u3h(sut) ) { - default: return u3m_bail(c3__fail); - - case c3__atom: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - } - case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - } - case c3__core: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - } - case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - } - case c3__fork: p_sut = u3t(sut); - { - } - case c3__hold: p_sut = u3t(sut); - { - } - } -} diff --git a/jets/z/ut.c b/jets/z/ut.c deleted file mode 100644 index 980bdb198..000000000 --- a/jets/z/ut.c +++ /dev/null @@ -1,100 +0,0 @@ -/* j/6/ut.c -** -*/ -#include "all.h" - - extern void - u3_pier_tank(c3_l tab_l, u3_noun tac); - - - // duck: create a duck core for mean. - // - u3_noun - u3qzu_duck(u3_noun van, - u3_noun typ) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(typ), 0); - u3_noun ret = u3j_hook(u3k(von), "dune"); - - u3z(von); - return ret; - } - - // dung: create a dunk core for mean (noun caption) - // - u3_noun - u3qzu_dung(u3_noun van, - u3_noun paz, - u3_noun typ) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(typ), 0); - u3_noun duq = u3j_hook(u3k(von), "dunk"); - u3_noun ret = u3i_molt(u3k(duq), u3x_sam, u3k(paz), 0); - - u3z(duq); - u3z(von); - return ret; - } - - // dunq: create a dunk core for mean - // - u3_noun - u3qzu_dunq(u3_noun van, - const c3_c* paz_c, - u3_noun typ) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(typ), 0); - u3_noun duq = u3j_hook(u3k(von), "dunk"); - u3_noun paz = u3i_string(paz_c); - u3_noun ret = u3i_molt(u3k(duq), u3x_sam, u3k(paz), 0); - - u3z(paz); - u3z(duq); - u3z(von); - return ret; - } - - // dump: dump a type. - // - void - u3qzu_dump(u3_noun van, - const c3_c* paz_c, - u3_noun typ) - { - c3_c* pfix_c = u3r_string((c3y == u3du(typ)) ? u3h(typ) : typ); - c3_c ugh_c[1024]; - - sprintf(ugh_c, "%s: %s: 0x%8x:", - paz_c, pfix_c, u3r_mug(typ)); -#if 0 - u3_pier_tank(0, u3n_kick_on(u3qzu_dunq(van, ugh_c, typ))); -#endif - } - - // shew: create a show core for mean - // - u3_noun - u3qzu_shew(u3_noun van, - u3_noun mol) - { - u3_noun sho = u3j_hook(u3k(van), "show"); - u3_noun ret = u3i_molt(u3k(sho), u3x_sam, u3k(mol), 0); - - u3z(sho); - u3z(mol); - return ret; - } - - // shep: show with caption and style - // - u3_noun - u3qzu_shep(u3_noun van, - const c3_c* paz_c, - u3_noun sty, - u3_noun mol) - { - return u3qzu_shew(van, - u3nc(u3nc('c', u3i_string(paz_c)), - u3nc(u3k(sty), mol))); - } - diff --git a/jets/z/ut_buss.c b/jets/z/ut_buss.c deleted file mode 100644 index 494d030c1..000000000 --- a/jets/z/ut_buss.c +++ /dev/null @@ -1,93 +0,0 @@ -/* j/6/ut_buss.c -** -*/ -#include "all.h" - - -/* logic -*/ - static u3_noun - _cqzu_buss(u3_noun van, - u3_noun sut, - u3_noun cog, - u3_noun gen) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "buss"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam_2, - u3k(cog), - u3x_sam_3, - u3k(gen), - 0)); - } - - static u3_noun - _cqzu_busk(u3_noun van, - u3_noun sut, - u3_noun gen) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "busk"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam, - u3k(gen), - 0)); - } - -/* boilerplate -*/ - u3_noun - u3wzu_buss(u3_noun cor) - { - u3_noun sut, cog, gen, van; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &cog, - u3x_sam_3, &gen, - u3x_con, &van, - 0)) || - (c3n == u3ud(cog)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_buss(van, sut, cog, gen); - } - } - - u3_noun - u3qzu_buss(u3_noun van, - u3_noun sut, - u3_noun cog, - u3_noun gen) - { - return _cqzu_buss(van, sut, cog, gen); - } - - - u3_noun - u3wzu_busk(u3_noun cor) - { - u3_noun sut, gen, van; - - if ( (c3n == u3r_mean(cor, u3x_sam, &gen, - u3x_con, &van, - 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_busk(van, sut, gen); - } - } - - u3_noun - u3qzu_busk(u3_noun van, - u3_noun sut, - u3_noun gen) - { - return _cqzu_busk(van, sut, gen); - } - diff --git a/jets/z/ut_conk.c b/jets/z/ut_conk.c deleted file mode 100644 index 1bee8e974..000000000 --- a/jets/z/ut_conk.c +++ /dev/null @@ -1,88 +0,0 @@ -/* j/6/ut_conk.c -** -*/ -#include "all.h" - - -/* logic -*/ - static u3_noun - _cqzu_conk(u3_noun van, - u3_noun sut, - u3_noun got) - { - if ( c3y == u3ud(got) ) { - u3_noun ret = u3qz_face(u3k(got), sut); - - return ret; - } - else switch ( u3h(got) ) { - default: return u3m_bail(c3__fail); - - case 0: { - return u3k(sut); - } - case 1: { - u3_noun cok = _cqzu_conk(van, sut, u3t(u3t(got))); - u3_noun nux = u3k(u3h(u3t(got))); - u3_noun ret = u3qz_face(nux, cok); - - u3z(nux); - u3z(cok); - return ret; - } - case 2: { - u3_noun vet = u3r_at(u3qzu_van_vet, van); - u3_noun hed, tal, deh, lat, ret; - - if ( c3y == vet ) { - u3_noun cel = u3nt(c3__cell, c3__noun, c3__noun); - - if ( c3n == u3qzu_nest(van, cel, c3y, sut) ) { - return u3m_bail(c3__fail); - } - u3z(cel); - } - hed = u3qzu_peek(van, sut, c3__both, 2); - tal = u3qzu_peek(van, sut, c3__both, 3); - deh = _cqzu_conk(van, hed, u3h(u3t(got))); - lat = _cqzu_conk(van, tal, u3t(u3t(got))); - - ret = u3qz_cell(deh, lat); - - u3z(lat); - u3z(deh); - u3z(tal); - u3z(hed); - - return ret; - } - } - } - -/* boilerplate -*/ - u3_noun - u3wzu_conk(u3_noun cor) - { - u3_noun sut, got, van; - - if ( (c3n == u3r_mean(cor, u3x_sam, &got, - u3x_con, &van, - 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_conk(van, sut, got); - } - } - - u3_noun - u3qzu_conk(u3_noun van, - u3_noun sut, - u3_noun got) - { - return _cqzu_conk(van, sut, got); - } - diff --git a/jets/z/ut_crop.c b/jets/z/ut_crop.c deleted file mode 100644 index cc81f203e..000000000 --- a/jets/z/ut_crop.c +++ /dev/null @@ -1,271 +0,0 @@ -/* j/6/crop.c -** -*/ -#include "all.h" - -/* logic -*/ - static u3_noun - _crop_dext(u3_noun, u3_noun, u3_noun, u3_noun); - static u3_noun - _crop_sint(u3_noun, u3_noun, u3_noun, u3_noun); - - static u3_noun - _crop_repo(u3_noun van, - u3_noun sut, - u3_noun ref, - u3_noun bix) - { - u3_noun rep = u3qzu_repo(van, sut); - u3_noun ret = _crop_dext(van, rep, ref, bix); - - if ( c3y == u3r_sing(ret, rep) ) { - if ( c3__void == rep ) { - return c3__void; - } else { - u3z(rep); - u3z(ret); - return u3k(sut); - } - } else { - u3z(rep); - return ret; - } - } - - static u3_noun - _crop_dext_fork(u3_noun van, u3_noun p_sut, u3_noun ref, u3_noun bix) - { - if ( u3_nul == p_sut ) { - return u3_nul; - } - else { - return u3nc(_crop_dext(van, u3h(p_sut), ref, bix), - _crop_dext_fork(van, u3t(p_sut), ref, bix)); - } - } - static u3_noun - _crop_sint_fork(u3_noun van, u3_noun sut, u3_noun p_ref, u3_noun bix) - { - if ( u3_nul == p_ref ) { - return u3k(sut); - } - else { - u3_noun tuz = _crop_dext(van, sut, u3h(p_ref), bix); - u3_noun zat = _crop_sint_fork(van, tuz, u3t(p_ref), bix); - - u3z(tuz); - return zat; - } - } - - static u3_noun - _crop_dext(u3_noun van, - u3_noun sut, - u3_noun ref, - u3_noun bix) - { - u3_noun p_sut, q_sut, p_ref, q_ref; - - if ( c3n == u3du(ref) ) { - switch ( ref ) { - case c3__void: return u3k(sut); - case c3__noun: return c3__void; - default: return u3m_bail(c3__fail); - } - } - if ( c3y == u3r_sing(sut, ref) ) { - return c3__void; - } - if ( c3n == u3du(sut) ) switch ( sut ) { - default: return u3m_bail(c3__fail); - - case c3__noun: return _crop_repo(van, sut, ref, bix); - case c3__void: return c3__void; - } - else switch ( u3h(sut) ) { - default: return u3m_bail(c3__fail); - - case c3__atom: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - if ( c3__atom == u3h(ref) ) { - u3x_cell(u3t(ref), &p_ref, &q_ref); - - if ( c3y == u3du(q_sut) ) { - if ( c3y == u3du(q_ref) ) { - if ( c3y == u3r_sing(q_sut, q_ref) ) { - return c3__void; - } else { - return u3k(sut); - } - } else { - return c3__void; - } - } - else { - if ( c3y == u3du(q_ref) ) { - return u3k(sut); - } - else return c3__void; - } - } - else if ( c3__cell == u3h(ref) ) { - return u3k(sut); - } - else return _crop_sint(van, sut, ref, bix); - } - case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - if ( c3__atom == u3h(ref) ) { - return u3k(sut); - } - else if ( c3__cell == u3h(ref) ) { - u3x_cell(u3t(ref), &p_ref, &q_ref); - - if ( c3y == u3qzu_nest(van, p_ref, c3n, p_sut) ) - { - u3_noun foz = _crop_dext(van, q_sut, q_ref, bix); - u3_noun ret = u3qz_cell(p_sut, foz); - - u3z(foz); - return ret; - } - else return u3k(sut); - } - else return _crop_sint(van, sut, ref, bix); - } - case c3__core: - { - if ( (c3__atom == u3h(ref)) || - (c3__cell == u3h(ref)) ) { - return u3k(sut); - } - else return _crop_sint(van, sut, ref, bix); - } - case c3__hint: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - u3_noun foz = _crop_dext(van, q_sut, ref, bix); - u3_noun ret = u3qz_hint(p_sut, foz); - - u3z(foz); - return ret; - } - case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - u3_noun foz = _crop_dext(van, q_sut, ref, bix); - u3_noun ret = u3qz_face(p_sut, foz); - - u3z(foz); - return ret; - } - case c3__fork: p_sut = u3t(sut); - { - u3_noun yed = u3qdi_tap(p_sut); - u3_noun ret = u3kf_fork(_crop_dext_fork(van, yed, ref, bix)); - - u3z(yed); - return ret; - } - case c3__hold: - { - u3_noun hud = u3nc(u3k(sut), u3k(ref)); - - if ( c3y == u3qdi_has(bix, hud) ) { -# if 0 - u3_noun dun = u3qzu_dunq(van, "type", sut); - u3_noun niz = u3qzu_dunq(van, "over", ref); - - u3t_push(u3nc(c3__mean, dun)); - u3t_push(u3nc(c3__mean, niz)); -# endif - - return u3m_error("crop-loop"); - } else { - u3_noun bux = u3qdi_put(bix, hud); - u3_noun ret = _crop_repo(van, sut, ref, bux); - - u3z(hud); - u3z(bux); - return ret; - } - } - } - } - - static u3_noun - _crop_sint(u3_noun van, - u3_noun sut, - u3_noun ref, - u3_noun bix) - { - u3_noun p_ref, q_ref; - - switch ( u3h(ref) ) { - default: return u3m_bail(c3__fail); - - case c3__core: - case c3__hint: - case c3__face: u3x_cell(u3t(ref), &p_ref, &q_ref); - { - return _crop_dext(van, sut, q_ref, bix); - } - case c3__fork: p_ref = u3t(ref); - { - u3_noun yed = u3qdi_tap(p_ref); - u3_noun ret = _crop_sint_fork(van, sut, yed, bix); - - u3z(yed); - return ret; - } - case c3__hold: - { - u3_noun rep = u3qzu_repo(van, ref); - u3_noun ret = _crop_dext(van, sut, rep, bix); - - u3z(rep); - return ret; - } - } - } - - static u3_noun - _cqzu_crop(u3_noun van, - u3_noun sut, - u3_noun ref) - { - return _crop_dext(van, sut, ref, u3_nul); - } - -/* boilerplate -*/ - u3_noun - u3wzu_crop(u3_noun cor) - { - u3_noun sut, ref, van; - - if ( (c3n == u3r_mean(cor, u3x_sam, &ref, u3x_con, &van, 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_crop(van, sut, ref); - } - } - - u3_noun - u3qzu_crop(u3_noun van, - u3_noun sut, - u3_noun ref) - { - c3_m fun_m = 144 + c3__crop + ((!!u3r_at(u3qzu_van_vet, van)) << 8); - u3_noun pro = u3z_find_2(fun_m, sut, ref); - - if ( u3_none != pro ) { - return pro; - } - else { - pro = _cqzu_crop(van, sut, ref); - - return u3z_save_2(fun_m, sut, ref, pro); - } - } diff --git a/jets/z/ut_find.c b/jets/z/ut_find.c deleted file mode 100644 index 139105a95..000000000 --- a/jets/z/ut_find.c +++ /dev/null @@ -1,915 +0,0 @@ -/* j/6/find.c -** -*/ -#include "all.h" - - static u3_noun - _find_buck(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun p_heg, - u3_noun q_heg, - u3_noun axe, - u3_noun lon, - u3_noun gil); - - static u3_noun - _opal_sane(u3_noun ope) - { - if ( (0 == u3h(ope)) && (0 == u3t(ope)) ) { - fprintf(stderr, "insane opal\r\n"); - c3_assert(0); - } - else return ope; - } - - static u3_noun - _pony_sane(u3_noun poy) - { - if ( 0 == poy ) { - return poy; - } - else if ( c3n == u3h(poy) ) { - if ( c3n == u3h(u3t(poy)) ) { - // abnormal - u3_noun type = u3h(u3t(u3t(u3t(poy)))); - if ( 0 == type ) { - u3m_p("insane type", 0); - c3_assert(0); - } - } - return poy; - } - else { - u3_noun tt_poy = u3t(u3t(poy)); // opal - - _opal_sane(tt_poy); - return poy; - } - } - - static u3_noun - u3qzu_felt(u3_noun van, - u3_noun sut, - u3_noun lap) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "felt"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam, - u3k(lap), - 0)); - } - - static u3_noun - u3qzu_fund(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun gen) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "fund"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam_2, - u3k(way), - u3x_sam_3, - u3k(gen), - 0)); - } - - static u3_noun - u3qzu_fine(u3_noun van, - u3_noun sut, - u3_noun tor) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "fine"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam, - u3k(tor), - 0)); - } - - static u3_noun - _find_buck_here(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun p_heg, - u3_noun q_heg, - u3_noun axe, - u3_noun lon, - u3_noun gil) - { - if ( 0 == p_heg ) { - return u3nt - (c3y, - u3nt(u3_nul, - u3nc(u3_nul, u3k(axe)), - u3k(lon)), - u3nc(c3y, u3k(sut))); - } - else { - return u3nt - (c3n, c3y, u3qa_dec(p_heg)); - } - } - - static u3_noun - _find_buck_lose(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun p_heg, - u3_noun q_heg, - u3_noun axe, - u3_noun lon, - u3_noun gil) - { - return u3nt(c3n, c3y, u3k(p_heg)); - } - static u3_noun - _find_buck_stop(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun p_heg, - u3_noun q_heg, - u3_noun axe, - u3_noun lon, - u3_noun gil) - { - if ( u3_nul == q_heg ) { - return _find_buck_here(van, sut, way, p_heg, q_heg, axe, lon, gil); - } - else { - return _find_buck_lose(van, sut, way, p_heg, q_heg, axe, lon, gil); - } - } - - static u3_noun - _find_buck_cell(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun p_heg, - u3_noun q_heg, - u3_noun axe, - u3_noun lon, - u3_noun gil) - { - u3_noun p_sut, q_sut; - - u3x_cell(u3t(sut), &p_sut, &q_sut); - { - if ( u3_nul == q_heg ) { - return _find_buck_here(van, sut, way, p_heg, q_heg, axe, lon, gil); - } - else { - u3_noun exa = u3qc_peg(axe, 2); - u3_noun hed = _find_buck(van, p_sut, way, p_heg, q_heg, exa, lon, gil); - - u3z(exa); - if ( (u3_nul == hed) || (c3y == u3h(hed)) || (c3n == u3h(u3t(hed))) ) { - return hed; - } - else { - u3_noun exa = u3qc_peg(axe, 3); - u3_noun tal = _find_buck - (van, q_sut, way, u3t(u3t(hed)), q_heg, exa, lon, gil); - - u3z(exa); - u3z(hed); - - return tal; - } - } - } - } - - static u3_noun - _find_buck_core(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun p_heg, - u3_noun q_heg, - u3_noun axe, - u3_noun lon, - u3_noun gil) - { - u3_noun p_sut, q_sut, pq_sut, qq_sut, rq_sut, prq_sut, qrq_sut; - u3_noun ppq_sut, qpq_sut, rpq_sut; - - u3x_cell(u3t(sut), &p_sut, &q_sut); - u3x_trel(q_sut, &pq_sut, &qq_sut, &rq_sut); - u3x_trel(pq_sut, &ppq_sut, &qpq_sut, &rpq_sut); - u3x_cell(rq_sut, &prq_sut, &qrq_sut); - { - if ( u3_nul == q_heg ) { - return _find_buck_here(van, sut, way, p_heg, q_heg, axe, lon, gil); - } - else { - u3_noun zem = u3qz_loot(u3t(q_heg), qrq_sut); - - if ( (u3_nul != zem) && (0 != p_heg) ) { - u3_noun ped; - - ped = u3qa_dec(p_heg); - u3z(p_heg); p_heg = ped; - - u3z(zem); - zem = u3_nul; - } - - if ( u3_nul != zem ) { - u3_noun u_zem = u3t(zem); - u3_noun pu_zem = u3h(u_zem); - u3_noun qu_zem = u3t(u_zem); - u3_noun qqu_zem = u3t(qu_zem); - u3_noun mut; - u3_noun pro; - - mut = u3nt(c3__core, - u3k(p_sut), - u3nt(u3nt(u3k(ppq_sut), u3k(qpq_sut), c3__gold), - u3k(qq_sut), - u3k(rq_sut))); - - pro = u3nt - (c3y, - u3nc(u3nc(u3_nul, u3k(axe)), u3k(lon)), - u3nt(c3n, - u3qc_peg(2, pu_zem), - u3nt(u3nc(mut, u3k(qqu_zem)), u3_nul, u3_nul))); - - u3z(zem); - return pro; - } - else { - u3_noun pec = u3qzu_peel(van, sut, way, rpq_sut); - u3_noun pro; - - if ( c3n == u3h(pec) ) { - pro = _find_buck_lose(van, sut, way, p_heg, q_heg, axe, lon, gil); - } - else if ( c3y == u3t(pec) ) { - u3_noun exa = u3qc_peg(axe, 3); - - pro = _find_buck(van, p_sut, way, p_heg, q_heg, exa, lon, gil); - u3z(exa); - } - else { - u3_noun sam = u3qzu_peek(van, p_sut, way, 2); - u3_noun exa = u3qc_peg(axe, 6); - - pro = _find_buck(van, sam, way, p_heg, q_heg, exa, lon, gil); - u3z(exa); - u3z(sam); - } - u3z(pec); - return pro; - } - } - } - } - - static u3_noun - _find_twin(u3_noun van, - u3_noun hax, - u3_noun yor) - { - if ( c3y == u3r_sing(hax, yor) ) { - return u3k(hax); - } - else if ( u3_nul == hax ) { - return u3k(yor); - } - else if ( u3_nul == yor ) { - return u3k(hax); - } - else if ( c3n == u3h(hax) ) { - if ( (c3n != u3h(yor)) ) { - return u3m_error("find-fork-a"); - } - else { - u3_noun p_hax = u3t(hax); // (each @ud {span nock}) - u3_noun p_yor = u3t(yor); // (each @ud {span nock}) - - if ( (c3n != u3h(p_hax)) || (c3n != u3h(p_yor)) ) { - return u3m_error("find-fork-b"); - } - else { - u3_noun pp_hax = u3t(p_hax); // {span nock} - u3_noun pp_yor = u3t(p_yor); // {span nock} - u3_noun ppp_hax = u3h(pp_hax); // span - u3_noun ppp_yor = u3h(pp_yor); // span - u3_noun qpp_hax = u3t(pp_hax); // nock - u3_noun qpp_yor = u3t(pp_yor); // nock - - if ( c3n == u3r_sing(qpp_hax, qpp_yor) ) { - return u3m_error("find-fork-c"); - } - return u3nt(c3n, - c3n, - u3nc( - u3kf_fork(u3nt(u3k(ppp_hax), u3k(ppp_yor), u3_nul)), - u3k(qpp_hax))); - } - } - } - else { - if ( c3n == u3h(yor) ) { - return u3m_error("find-fork-d"); - } - else { - u3_noun p_hax = u3t(hax); // {vein opal} - u3_noun p_yor = u3t(yor); // {vein opal} - u3_noun pp_hax = u3h(p_hax); // vein - u3_noun pp_yor = u3h(p_yor); // vein - u3_noun qp_hax = u3t(p_hax); // opal - u3_noun qp_yor = u3t(p_yor); // opal - - if ( c3n == u3r_sing(pp_hax, pp_yor) ) { - return u3m_error("find-fork-e"); - } - else { - if ( c3y == u3h(qp_hax) ) { - if ( c3y != u3h(qp_yor) ) { - return u3m_error("find-fork-f"); - } else { - u3_noun pqp_hax = u3t(qp_hax); // type - u3_noun pqp_yor = u3t(qp_yor); // type - - return - u3nt(c3y, - u3k(pp_hax), - u3nc(c3y, u3kf_fork - (u3nt(u3k(pqp_hax), u3k(pqp_yor), u3_nul)))); - } - } - else if ( c3n != u3h(qp_yor) ) { - return u3m_error("find-fork-g"); - } else { - u3_noun pqp_hax = u3h(u3t(qp_hax)); // axis - u3_noun pqp_yor = u3h(u3t(qp_yor)); // axis - u3_noun qqp_hax = u3t(u3t(qp_hax)); // (set {type foot}) - u3_noun qqp_yor = u3t(u3t(qp_yor)); // (set {type foot}) - - if ( c3n == u3r_sing(pqp_hax, pqp_yor) ) { - return u3m_error("find-fork-h"); - } else { - return - u3nt(c3y, - u3k(pp_hax), - u3nt(c3n, u3k(pqp_hax), u3qdi_uni(qqp_hax, qqp_yor))); - } - } - } - } - } - // error: { return u3m_error("find-fork"); } - } - - static u3_noun - _find_buck_fork_twin(u3_noun van, u3_noun wiz) - { - if ( u3_nul == wiz ) { - return u3_nul; - } - else if ( u3_nul == u3t(wiz) ) { - return u3k(u3h(wiz)); - } - else { - u3_noun hax = u3k(u3h(wiz)); - u3_noun yor = _find_buck_fork_twin(van, u3t(wiz)); - u3_noun fid = _find_twin(van, hax, yor); - - u3z(hax); - u3z(yor); - - return fid; - } - } - - static u3_noun - _find_buck_fork_turn(u3_noun van, - u3_noun yed, - u3_noun way, - u3_noun p_heg, - u3_noun q_heg, - u3_noun axe, - u3_noun lon, - u3_noun gil) - { - if ( u3_nul == yed ) { - return u3_nul; - } - else { - u3_noun fid = _find_buck(van, u3h(yed), way, p_heg, q_heg, axe, lon, gil); - - return u3nc - (fid, - _find_buck_fork_turn - (van, u3t(yed), way, p_heg, q_heg, axe, lon, gil)); - } - } - - static u3_noun - _find_buck_fork(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun p_heg, - u3_noun q_heg, - u3_noun axe, - u3_noun lon, - u3_noun gil) - { - u3_noun p_sut = u3t(sut); - u3_noun yed = u3qdi_tap(p_sut); - u3_noun wiz; - u3_noun ret; - - wiz = _find_buck_fork_turn(van, yed, way, p_heg, q_heg, axe, lon, gil); - u3z(yed); - - ret = _find_buck_fork_twin(van, wiz); - u3z(wiz); - - return ret; - } - - static u3_noun - _find_buck_face_next(u3_noun van, - u3_noun sut, - u3_noun q_sut, - u3_noun qp_sut, - u3_noun way, - u3_noun p_heg, - u3_noun q_heg, - u3_noun axe, - u3_noun lon, - u3_noun gil) - { - if ( u3_nul == qp_sut ) { - u3_noun nol = u3nc(u3_nul, u3k(lon)); - u3_noun ret = _find_buck(van, q_sut, way, p_heg, q_heg, axe, nol, gil); - u3z(nol); - return ret; - } - else { - u3_noun iqp_sut = u3h(qp_sut); // twig - u3_noun tiv = u3qzu_mint // (pair type nock) - (van, q_sut, c3__noun, iqp_sut); - u3_noun tqp_sut = u3t(qp_sut); // (list twig) - u3_noun p_tiv = u3h(tiv); // type - u3_noun q_tiv = u3t(tiv); // nock - u3_noun fid = _find_buck // pony - (van, p_tiv, way, p_heg, q_heg, 1, u3_nul, u3_nul); - - if ( u3_nul == fid ) { - u3z(tiv); - return u3_nul; - } - else if ( (c3n == u3h(fid)) && (c3y == u3h(u3t(fid))) ) { - u3_noun ret; - - ret = _find_buck_face_next - (van, sut, q_sut, tqp_sut, way, u3t(u3t(fid)), q_heg, axe, lon, gil); - u3z(fid); - u3z(tiv); - return ret; - } - else { - u3_noun tor; // port - u3_noun vat; // (pair type nock) - u3_noun ret; - u3_noun dog = u3nc(0, u3k(axe)); // nock - u3_noun cob = u3qz_comb(dog, q_tiv); - - if ( c3y == u3h(fid) ) { - tor = u3nc(c3y, u3k(u3t(fid))); - } else { - tor = u3nc(c3n, u3k(u3t(u3t(fid)))); - } - u3z(fid); - - vat = u3qzu_fine(van, sut, tor); - u3z(tor); - - ret = u3nt - (c3n, - c3n, - u3nc(u3k(u3h(vat)), u3qz_comb(cob, u3t(vat)))); - - u3z(vat); - u3z(dog); - u3z(cob); - u3z(tiv); - - return ret; - } - } - } - - static u3_noun - _find_buck_face(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun p_heg, - u3_noun q_heg, - u3_noun axe, - u3_noun lon, - u3_noun gil) - { - u3_noun p_sut, q_sut; - - u3x_cell(u3t(sut), &p_sut, &q_sut); - - if ( u3_nul == q_heg ) { - return _find_buck_here(van, q_sut, way, p_heg, q_heg, axe, lon, gil); - } - else { - u3_noun uq_heg = u3t(q_heg); // term - - if ( c3y == u3ud(p_sut) ) { - if ( c3y == u3r_sing(p_sut, uq_heg) ) { - return _find_buck_here(van, q_sut, way, p_heg, q_heg, axe, lon, gil); - } - else { - return _find_buck_lose(van, sut, way, p_heg, q_heg, axe, lon, gil); - } - } - else { - u3_noun pp_sut = u3h(p_sut); // (map term {wain (unit twig)}) - u3_noun qp_sut = u3t(p_sut); // (list (pair type nock)) - u3_noun tyr = u3qdb_get(pp_sut, uq_heg); // (unit {wain (unit twig)}) - - if ( u3_nul == tyr ) { - return _find_buck_face_next - (van, sut, q_sut, qp_sut, way, p_heg, q_heg, axe, lon, gil); - } - else { - u3_noun u_tyr = u3t(tyr); // (pair wain (unit twig)) - u3_noun qu_tyr = u3t(u_tyr); - - if ( u3_nul == qu_tyr ) { - u3_noun nol = u3nc(u3_nul, u3k(lon)); - u3_noun dep = u3qa_inc(p_heg); - u3_noun ret = _find_buck - (van, q_sut, way, dep, q_heg, axe, nol, gil); - - u3z(dep); - u3z(nol); - u3z(tyr); - return ret; - } - else { - u3_noun uqu_tyr = u3t(qu_tyr); - u3_noun tor = u3qzu_fund(van, sut, way, uqu_tyr); - - if ( c3y == u3h(tor) ) { - u3_noun p_tor = u3t(tor); // (pair vein opal) - u3_noun pp_tor = u3h(p_tor); // vein - u3_noun qp_tor = u3t(p_tor); // opal - u3_noun nol = // vein - u3nt(u3_nul, u3nc(u3_nul, u3k(axe)), u3k(lon)); - u3_noun ret; - - ret = u3nt(c3y, u3qb_weld(pp_tor, nol), u3k(qp_tor)); - u3z(nol); - u3z(tor); - u3z(tyr); - return ret; - } - else { - u3_noun p_tor = u3t(tor); // (pair type nock) - u3_noun pp_tor = u3h(p_tor); // type - u3_noun qp_tor = u3t(p_tor); // nock - u3_noun dog = u3nc(0, u3k(axe)); // nock - u3_noun ret; - - ret = u3nt(c3n, - c3n, - u3nc(u3k(pp_tor), u3qz_comb(dog, qp_tor))); - u3z(dog); - u3z(tor); - u3z(tyr); - - return ret; - } - } - } - } - } - } - - static u3_noun - _find_bucx(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun p_heg, - u3_noun q_heg, - u3_noun axe, - u3_noun lon, - u3_noun gil) - { - if ( c3n == u3du(sut) ) switch ( sut ) { - default: return u3m_bail(c3__fail); - - case c3__noun: { - // fprintf(stderr, "noun\r\n"); - return _find_buck_stop(van, sut, way, p_heg, q_heg, axe, lon, gil); - } - case c3__void: { - // fprintf(stderr, "void\r\n"); - // return _find_buck_stop(van, sut, way, p_heg, q_heg, axe, lon, gil); - return u3_nul; - } - } - else switch ( u3h(sut) ) { - default: return u3m_bail(c3__fail); - - case c3__atom: - { - // fprintf(stderr, "atom\r\n"); - return _find_buck_stop(van, sut, way, p_heg, q_heg, axe, lon, gil); - } - case c3__cell: - { - // fprintf(stderr, "cell\r\n"); - return _find_buck_cell(van, sut, way, p_heg, q_heg, axe, lon, gil); - } - case c3__core: - { - // fprintf(stderr, "core\r\n"); - return _find_buck_core(van, sut, way, p_heg, q_heg, axe, lon, gil); - } - case c3__hint: - { - u3_noun fop = u3qzu_repo(van, sut); - u3_noun pro = _find_bucx(van, fop, way, p_heg, q_heg, axe, lon, gil); - u3z(fop); - return pro; - } - case c3__face: - { - // fprintf(stderr, "face\r\n"); - return _find_buck_face(van, sut, way, p_heg, q_heg, axe, lon, gil); - } - case c3__fork: - { - // fprintf(stderr, "fork\r\n"); - return _find_buck_fork(van, sut, way, p_heg, q_heg, axe, lon, gil); - } - case c3__hold: - { - // fprintf(stderr, "hold\r\n"); - if ( (c3y == u3qdi_has(gil, sut)) ) { - return u3_nul; - } - else { - u3_noun zoc = u3qdi_put(gil, sut); - u3_noun fop = u3qzu_repo(van, sut); - u3_noun pro = _find_buck(van, fop, way, p_heg, q_heg, axe, lon, zoc); - - u3z(fop); - u3z(zoc); - - return pro; - } - } - } - } - - static u3_noun - _find_buck(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun p_heg, - u3_noun q_heg, - u3_noun axe, - u3_noun lon, - u3_noun gil) - { - u3_noun ret = _find_bucx(van, sut, way, p_heg, q_heg, axe, lon, gil); - - return _pony_sane(ret); - } - - static u3_noun - _find_limb(u3_noun van, - u3_noun sut, // type - u3_noun way, // ?(%read %rite %free %both) - u3_noun i_hyp, // limb - u3_noun p_mor) // palo - { - u3_noun pp_mor = u3h(p_mor); // vein - u3_noun qp_mor = u3t(p_mor); // opal - - qp_mor = _opal_sane(qp_mor); - { - u3_noun ref = u3qzu_felt(van, sut, qp_mor); - u3_noun lon = u3k(pp_mor); - u3_noun heg = (c3y == u3du(i_hyp)) - ? u3k(i_hyp) - : u3nq(c3n, 0, u3_nul, u3k(i_hyp)); - u3_noun ret; - - if ( c3y == u3h(heg) ) { - u3_noun p_heg = u3t(heg); // axis - - ret = u3nt - (c3y, - u3nc(u3nc(u3_nul, u3k(p_heg)), u3k(lon)), - u3nc(c3y, u3qzu_peek(van, ref, way, p_heg))); - - ret = _pony_sane(ret); - } - else { - u3_noun p_heg = u3h(u3t(heg)); // @ud - u3_noun q_heg = u3t(u3t(heg)); // (unit term) - - ret = _find_buck - (van, ref, way, p_heg, q_heg, 1, lon, u3_nul); - } - u3z(heg); - u3z(lon); - u3z(ref); - - return _pony_sane(ret); - } - } - - static u3_noun - _find_pony(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun hyp) - { - if ( u3_nul == hyp ) { - return _pony_sane(u3nt(c3y, u3_nul, u3nc(c3y, u3k(sut)))); - } - else { - u3_noun i_hyp = u3h(hyp); - u3_noun t_hyp = u3t(hyp); - u3_noun mor = _find_pony(van, sut, way, t_hyp); - - mor = _pony_sane(mor); - - if ( c3n == u3h(mor) ) { - u3_noun p_mor = u3t(mor); - - if ( c3y == u3h(p_mor) ) { - return mor; - } - else { - u3_noun pp_mor = u3t(p_mor); // {span nock} - u3_noun ppp_mor = u3h(pp_mor); // span - u3_noun qpp_mor = u3t(pp_mor); // nock - u3_noun gen = u3nt(c3__wing, u3k(i_hyp), u3_nul); - u3_noun fex = u3qfu_mint(van, ppp_mor, c3__noun, gen); - u3_noun ret = u3nt(c3n, - c3n, - u3nc(u3k(u3h(fex)), - u3qf_comb(qpp_mor, u3t(fex)))); - u3z(fex); - u3z(gen); - u3z(mor); - - return _pony_sane(ret); - } - } - else { - u3_noun p_mor = u3t(mor); - u3_noun ret = _find_limb(van, sut, way, i_hyp, p_mor); - - u3z(mor); - return _pony_sane(ret); - } - } - } - - static u3_noun - _cqzu_fond(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun hyp) - { - u3_noun taf; - - taf = _find_pony(van, sut, way, hyp); - - return taf; - } - - static u3_noun - _cqzu_find(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun hyp) - { - u3_noun taf = _find_pony(van, sut, way, hyp); - - if ( u3_nul == taf ) { - goto error; - } - else { - if ( c3y == u3h(taf) ) { - u3_noun fat = u3nc(c3y, u3k(u3t(taf))); - - u3z(taf); - return fat; - } - else { - if ( c3n == u3h(u3t(taf)) ) { - u3_noun fat = u3nc(c3n, u3k(u3t(u3t(u3t(taf))))); - - u3z(taf); - return fat; - } - else { - goto error; - } - } - } - error: { - u3m_p("wing", hyp); - - return u3m_error("find"); - } - } - -/* boilerplate -*/ - u3_noun - u3wzu_find(u3_noun cor) - { - u3_noun sut, way, hyp, van; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &way, - u3x_sam_3, &hyp, - u3x_con, &van, - 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_find(van, sut, way, hyp); - } - } - - u3_noun - u3qzu_find(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun hyp) - { - c3_m fun_m = 144 + c3__find + ((!!u3r_at(u3qzu_van_vet, van)) << 8); - u3_noun pro = u3z_find_3(fun_m, sut, way, hyp); - - if ( u3_none != pro ) { - return pro; - } - else { - pro = _cqzu_find(van, sut, way, hyp); - - return u3z_save_3(fun_m, sut, way, hyp, pro); - } - } - -/* boilerplate -*/ - u3_noun - u3wzu_fond(u3_noun cor) - { - u3_noun sut, way, hyp, van; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &way, - u3x_sam_3, &hyp, - u3x_con, &van, - 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_fond(van, sut, way, hyp); - } - } - - u3_noun - u3qzu_fond(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun hyp) - { - c3_m fun_m = 144 + c3__fond + ((!!u3r_at(u3qzu_van_vet, van)) << 8); - u3_noun pro = u3z_find_3(fun_m, sut, way, hyp); - - if ( u3_none != pro ) { - return pro; - } - else { - pro = _cqzu_fond(van, sut, way, hyp); - - return u3z_save_3(fun_m, sut, way, hyp, pro); - } - } diff --git a/jets/z/ut_fire.c b/jets/z/ut_fire.c deleted file mode 100644 index a4d8c0934..000000000 --- a/jets/z/ut_fire.c +++ /dev/null @@ -1,195 +0,0 @@ -/* j/6/fire.c -** -*/ -#include "all.h" - - -/* logic -*/ - static u3_noun - _fire_vet(u3_noun van) - { - // u3_noun vet = u3j_hook(u3k(van), "vet"); - u3_noun vet = u3r_at(u3qzu_van_vet, van); - - switch ( vet ) { - case c3n: - case c3y: return vet; - default: return u3m_bail(c3__fail); - } - } - - static u3_noun - _fire_mull(u3_noun van, - u3_noun sut, - u3_noun dox, - u3_noun gen) - { - u3_noun rib = u3r_at(u3qzu_van_rib, van); - u3_noun key = u3nt(u3k(sut), - u3k(dox), - u3k(gen)); - u3_noun ret; - - if ( c3n == _fire_vet(van) ) { - ret = c3y; - } - if ( c3y == u3qdi_has(rib, key) ) { - ret = c3y; - } - else { - u3_noun rob = u3qdi_put(rib, key); - u3_noun von = u3i_molt(u3k(van), - u3qzu_van_rib, - u3k(rob), - 0); - u3_noun mul = u3qzu_mull(von, sut, c3__noun, dox, gen); - - ret = c3y; - - u3z(mul); - u3z(von); - u3z(rob); - } - u3z(key); - return ret; - } - - static u3_noun - _fire_each(u3_noun van, - u3_noun vet, - u3_noun typ, - u3_noun gat) - { - u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ; - u3_noun h_gat, t_gat; - - if ( (c3n == u3du(typ)) || (c3__core != u3h(typ)) ) { - return u3m_error("fire-core"); - } else if - ( (c3n == u3r_cell(u3t(typ), &p_typ, &q_typ)) || - (c3n == u3r_trel(q_typ, &pq_typ, &qq_typ, &rq_typ)) || - (c3n == u3r_cell(gat, &h_gat, &t_gat)) ) - { - return u3m_bail(c3__fail); - } else { - u3_noun dox = u3nt - (c3__core, u3k(qq_typ), u3k(q_typ)); - - if ( c3__ash == u3h(gat) ) { - if ( (c3y == vet) && - (c3n == u3qzu_nest(van, qq_typ, c3y, p_typ)) ) - { -#if 0 - u3_noun dun = u3qzu_dunq(van, "need", qq_typ); - u3_noun niz = u3qzu_dunq(van, "have", p_typ); - - u3t_push(u3nc(c3__mean, niz)); - u3t_push(u3nc(c3__mean, dun)); -#endif - return u3m_error("fire-dry"); - } - else { - return u3nc(dox, u3k(t_gat)); - } - } - else { - c3_assert(c3__elm == u3h(gat)); -#if 0 - u3_noun dun = u3qzu_dunq(van, "wild", typ); - u3_noun niz = u3qzu_dunq(van, "tame", dox); - - u3t_push(u3nc(c3__mean, dun)); - u3t_push(u3nc(c3__mean, niz)); -#endif - if ( (c3y == vet) && - (c3n == _fire_mull(van, typ, dox, t_gat)) ) - { - return u3m_error("fire-wet"); - } - else { - u3z(dox); -#if 0 - u3t_drop(); - u3t_drop(); -#endif - return u3nc(u3k(typ), u3k(t_gat)); - } - } - } - } - - static u3_noun - _fire_in(u3_noun van, - u3_noun vet, - u3_noun hag) - { - if ( u3_nul == hag ) { - return u3_nul; - } - else { - u3_noun i_hag = u3h(hag); - u3_noun t_hag = u3t(hag); - - if ( c3n == u3du(i_hag) ) { - return u3m_bail(c3__fail); - } else { - return u3nc - (_fire_each(van, vet, u3h(i_hag), u3t(i_hag)), - _fire_in(van, vet, t_hag)); - } - } - } - - static u3_noun - _cqzu_fire(u3_noun van, - u3_noun sut, - u3_noun hag) - { - u3_noun vet = u3r_at(u3qzu_van_vet, van); - - c3_assert(!"not live"); - { - if ( (c3y == u3du(hag)) && (u3_nul == u3t(hag)) ) { - u3_noun i_hag = u3h(hag); - u3_noun pi_hag = u3h(i_hag); - u3_noun qi_hag = u3t(i_hag); - - if ( c3__elm == u3h(qi_hag) ) { - u3_noun qqi_hag = u3t(qi_hag); - - if ( c3y == u3du(qqi_hag) && - (u3_nul == u3h(qqi_hag)) && - (1 == u3t(qqi_hag)) ) - { - return u3k(pi_hag); - } - } - } - } - return u3nc(c3__hold, _fire_in(van, vet, hag)); - } - -/* boilerplate -*/ - u3_noun - u3wzu_fire(u3_noun cor) - { - u3_noun sut, hag, van; - - if ( (c3n == u3r_mean(cor, u3x_sam, &hag, u3x_con, &van, 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_fire(van, sut, hag); - } - } - - u3_noun - u3qzu_fire(u3_noun van, - u3_noun sut, - u3_noun hag) - { - return _cqzu_fire(van, sut, hag); - } diff --git a/jets/z/ut_fish.c b/jets/z/ut_fish.c deleted file mode 100644 index 30adb880a..000000000 --- a/jets/z/ut_fish.c +++ /dev/null @@ -1,180 +0,0 @@ -/* j/6/fish.c -** -*/ -#include "all.h" - -/* functions -*/ - static u3_noun - _fish_in(u3_noun, u3_noun, u3_atom, u3_noun); - - static u3_noun - _fish_fork(u3_noun van, - u3_noun p_sut, - u3_atom axe, - u3_noun vit) - { - if ( u3_nul == p_sut ) { - return u3nc(1, 1); - } - else { - u3_noun hed = _fish_in(van, u3h(p_sut), axe, vit); - u3_noun tal = _fish_fork(van, u3t(p_sut), axe, vit); - u3_noun pro = u3qz_flor(hed, tal); - - u3z(hed); - u3z(tal); - - return pro; - } - } - - static u3_noun - _fish_in(u3_noun van, - u3_noun sut, - u3_atom axe, - u3_noun vit) - { - u3_noun p_sut, q_sut; - - if ( c3y == u3ud(sut) ) switch ( sut ) { - default: return u3m_bail(c3__fail); - - case c3__noun: { - return u3nc(1, 0); - } - case c3__void: { - return u3nc(1, 1); - } - } - else switch ( u3h(sut) ) { - default: return u3m_bail(c3__fail); - - case c3__atom: { - if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { - return u3m_bail(c3__fail); - } else { - if ( c3n == u3du(q_sut) ) { - u3_noun ton = u3nt(3, 0, u3k(axe)); - u3_noun pro = u3qz_flip(ton); - - u3z(ton); - return pro; - } else { - return u3nt(5, - u3nc(1, u3k(u3t(q_sut))), - u3nc(0, u3k(axe))); - } - } - } - case c3__cell: { - if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { - return u3m_bail(c3__fail); - } else { - u3_noun hut = u3nt(3, 0, u3k(axe)); - u3_noun lef = u3qc_peg(axe, 2); - u3_noun rit = u3qc_peg(axe, 3); - u3_noun hed = _fish_in(van, p_sut, lef, vit); - u3_noun tal = _fish_in(van, q_sut, rit, vit); - u3_noun hob = u3qz_flan(hed, tal); - u3_noun vug = u3qz_flan(hut, hob); - - u3z(hob); - u3z(tal); - u3z(hed); - u3z(rit); - u3z(lef); - u3z(hut); - - return vug; - } - } - case c3__core: { - return u3m_error("fish-core"); - } - case c3__hint: - case c3__face: { - if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { - return u3m_bail(c3__fail); - } else { - return _fish_in(van, q_sut, axe, vit); - } - } - case c3__fork: p_sut = u3t(sut); - { - u3_noun yed = u3qdi_tap(p_sut); - u3_noun ret = _fish_fork(van, yed, axe, vit); - - u3z(yed); - return ret; - } - case c3__hold: { - p_sut = u3t(sut); - { - if ( (c3y == u3qdi_has(vit, sut)) ) { - // u3_noun dun = u3qzu_dunq(van, "type", sut); - u3_noun niz = u3qzu_shep - (van, "axis", 'd', u3k(axe)); - - // u3t_push(u3nc(c3__mean, dun)); - u3t_push(u3nc(c3__mean, niz)); - - return u3m_error("fish-loop"); - } else { - u3_noun zoc = u3qdi_put(vit, sut); - u3_noun fop = u3qzu_repo(van, sut); - u3_noun pro = _fish_in(van, fop, axe, zoc); - - u3z(fop); - u3z(zoc); - - return pro; - } - } - } - } - } - - static u3_noun - _cqzu_fish(u3_noun van, - u3_noun sut, - u3_atom axe) - { - return _fish_in(van, sut, axe, u3_nul); - } - - -/* boilerplate -*/ - u3_noun - u3wzu_fish(u3_noun cor) - { - u3_noun sut, axe, van; - - if ( (c3n == u3r_mean(cor, u3x_sam, &axe, u3x_con, &van, 0)) || - (c3n == u3ud(axe)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_fish(van, sut, axe); - } - } - - u3_noun - u3qzu_fish(u3_noun van, - u3_noun sut, - u3_noun axe) - { - c3_m fun_m = 144 + c3__fish + ((!!u3r_at(u3qzu_van_vet, van)) << 8); - u3_noun pro = u3z_find_2(fun_m, sut, axe); - - if ( u3_none != pro ) { - return pro; - } - else { - pro = _cqzu_fish(van, sut, axe); - - return u3z_save_2(fun_m, sut, axe, pro); - } - } diff --git a/jets/z/ut_fuse.c b/jets/z/ut_fuse.c deleted file mode 100644 index bb2e64b74..000000000 --- a/jets/z/ut_fuse.c +++ /dev/null @@ -1,215 +0,0 @@ -/* j/6/fuse.c -** -*/ -#include "all.h" - -/* logic -*/ - static u3_noun - _fuse_in(u3_noun, u3_noun, u3_noun, u3_noun); - - static u3_noun - _fuse_repo(u3_noun van, - u3_noun sut, - u3_noun ref, - u3_noun bix) - { - u3_noun rep = u3qzu_repo(van, sut); - u3_noun ret = _fuse_in(van, rep, ref, bix); - - if ( c3y == u3r_sing(ret, rep) ) { - if ( c3__void == rep ) { - return c3__void; - } else { - u3z(rep); - u3z(ret); - return u3k(sut); - } - } else { - u3z(rep); - return ret; - } - } - - static u3_noun - _fuse_in_fork(u3_noun van, u3_noun p_sut, u3_noun ref, u3_noun bix) - { - if ( u3_nul == p_sut ) { - return u3_nul; - } - else { - return u3nc(_fuse_in(van, u3h(p_sut), ref, bix), - _fuse_in_fork(van, u3t(p_sut), ref, bix)); - } - } - - static u3_noun - _fuse_in(u3_noun van, - u3_noun sut, - u3_noun ref, - u3_noun bix) - { - u3_noun p_sut, q_sut; - - if ( c3y == u3r_sing(sut, ref) || (c3__noun == ref) ) { - return u3k(sut); - } - if ( c3n == u3du(sut) ) switch ( sut ) { - default: return u3m_bail(c3__fail); - - case c3__noun: - { - return u3k(ref); - } - case c3__void: - { - return c3__void; - } - } - else switch ( u3h(sut) ) { - default: return u3m_bail(c3__fail); - - case c3__atom: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - if ( c3y == u3du(ref) ) { - if ( c3__atom == u3h(ref) ) { - u3_noun p_ref, q_ref; - - u3x_cell(u3t(ref), &p_ref, &q_ref); - { - u3_noun foc = (c3y == u3qz_fitz(p_ref, p_sut)) - ? u3k(p_sut) - : u3k(p_ref); - - if ( c3y == u3du(q_sut) ) { - if ( c3y == u3du(q_ref) ) { - if ( c3y == u3r_sing(q_ref, q_sut) ) { - return u3nt(c3__atom, foc, u3k(q_sut)); - } - else { - u3z(foc); - return c3__void; - } - } - else { - return u3nt(c3__atom, foc, u3k(q_sut)); - } - } else { - return u3nt(c3__atom, foc, u3k(q_ref)); - } - } - } - else if ( c3__cell == u3h(ref) ) { - return c3__void; - } - } - return _fuse_in(van, ref, sut, bix); - } - case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - u3_noun p_ref, q_ref; - - if ( c3y == u3r_pq(ref, c3__cell, &p_ref, &q_ref) ) { - u3_noun hed = _fuse_in(van, p_sut, p_ref, bix); - u3_noun tal = _fuse_in(van, q_sut, q_ref, bix); - u3_noun ret = u3qz_cell(hed, tal); - - u3z(hed); - u3z(tal); - return ret; - } - else return _fuse_in(van, ref, sut, bix); - } - case c3__core: - { - return _fuse_repo(van, sut, ref, bix); - } - case c3__hint: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - u3_noun vot = _fuse_in(van, q_sut, ref, bix); - u3_noun ret = u3qz_hint(p_sut, vot); - - u3z(vot); - return ret; - } - case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - u3_noun vot = _fuse_in(van, q_sut, ref, bix); - u3_noun ret = u3qz_face(p_sut, vot); - - u3z(vot); - return ret; - } - case c3__fork: p_sut = u3t(sut); - { - u3_noun yed = u3qdi_tap(p_sut); - u3_noun ret = u3kf_fork(_fuse_in_fork(van, yed, ref, bix)); - - u3z(yed); - return ret; - } - case c3__hold: - { - u3_noun hud = u3nc(u3k(sut), u3k(ref)); - - if ( c3y == u3qdi_has(bix, hud) ) { - // u3_noun dun = u3qzu_dunq(van, "type", sut); - // u3_noun niz = u3qzu_dunq(van, "over", ref); - - // u3t_push(u3nc(c3__mean, dun)); - // u3t_push(u3nc(c3__mean, niz)); - - return u3m_error("fuse-loop"); - } else { - u3_noun bux = u3qdi_put(bix, hud); - u3_noun ret = _fuse_repo(van, sut, ref, bux); - - u3z(hud); - u3z(bux); - return ret; - } - } - } - } - - static u3_noun - _cqzu_fuse(u3_noun van, - u3_noun sut, - u3_noun ref) - { - return _fuse_in(van, sut, ref, u3_nul); - } - -/* boilerplate -*/ - u3_noun - u3wzu_fuse(u3_noun cor) - { - u3_noun sut, ref, van; - - if ( (c3n == u3r_mean(cor, u3x_sam, &ref, u3x_con, &van, 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_fuse(van, sut, ref); - } - } - - u3_noun - u3qzu_fuse(u3_noun van, - u3_noun sut, - u3_noun ref) - { - c3_m fun_m = 144 + c3__fuse + ((!!u3r_at(u3qzu_van_vet, van)) << 8); - u3_noun pro = u3z_find_2(fun_m, sut, ref); - - if ( u3_none != pro ) { - return pro; - } - else { - pro = _cqzu_fuse(van, sut, ref); - - return u3z_save_2(fun_m, sut, ref, pro); - } - } diff --git a/jets/z/ut_gain.c b/jets/z/ut_gain.c deleted file mode 100644 index 925aa9948..000000000 --- a/jets/z/ut_gain.c +++ /dev/null @@ -1,16 +0,0 @@ -/* j/6/gain.c -** -*/ -#include "all.h" - - - u3_noun - u3qzu_gain(u3_noun van, - u3_noun sut, - u3_noun gen) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "gain"); - - return u3n_kick_on(u3i_molt(gat, u3x_sam, u3k(gen), 0)); - } diff --git a/jets/z/ut_lose.c b/jets/z/ut_lose.c deleted file mode 100644 index 2ab35a0bb..000000000 --- a/jets/z/ut_lose.c +++ /dev/null @@ -1,16 +0,0 @@ -/* j/6/lose.c -** -*/ -#include "all.h" - - - u3_noun - u3qzu_lose(u3_noun van, - u3_noun sut, - u3_noun gen) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "lose"); - - return u3n_kick_on(u3i_molt(gat, u3x_sam, u3k(gen), 0)); - } diff --git a/jets/z/ut_mint.c b/jets/z/ut_mint.c deleted file mode 100644 index 821e7f551..000000000 --- a/jets/z/ut_mint.c +++ /dev/null @@ -1,830 +0,0 @@ -/* j/6/mint.c -** -*/ -#include "all.h" - -/* logic -*/ - static u3_noun - _mint_in(u3_noun, u3_noun, u3_noun, u3_noun); - - static u3_noun - _mint_bean() - { - return u3kf_fork(u3nt(u3nq(c3__atom, 'f', u3_nul, 0), - u3nq(c3__atom, 'f', u3_nul, 1), - u3_nul)); - } - - static u3_noun - _mint_vet(u3_noun van) - { - // u3_noun vet = u3j_hook(u3k(van), "vet"); - u3_noun vet = u3r_at(u3qzu_van_vet, van); - - switch ( vet ) { - case c3n: - case c3y: return vet; - default: return u3m_bail(c3__fail); - } - } - - static u3_noun - _mint_feel(u3_noun van, - u3_noun sut, - u3_noun rot) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "feel"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam, - u3k(rot), - 0)); - } - - static u3_noun - _mint_mine(u3_noun van, - u3_noun sut, - u3_noun mel, - u3_noun dom) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "mine"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam_2, - u3k(mel), - u3x_sam_3, - u3k(dom), - 0)); - } - - static u3_noun - _mint_burp(u3_noun van, - u3_noun sut) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - - return u3j_hook(von, "burp"); - } - - static u3_noun - _mint_cond(u3_noun pex, - u3_noun yom, - u3_noun woq) - { - if ( 1 == u3h(pex) ) { - if ( 0 == u3t(pex) ) { - u3z(pex); - u3z(woq); - - return yom; - } - else if ( 1 == u3t(pex) ) { - u3z(pex); - u3z(yom); - - return woq; - } - } - return u3nq(6, pex, yom, woq); - } - - static u3_noun - _mint_corn(u3_noun van, - u3_noun sut, - u3_noun gen) - { - u3_noun mil = _mint_in(van, sut, c3__noun, gen); - u3_noun fol = u3k(u3t(mil)); - - u3z(mil); - return fol; - } - - static u3_noun - _mint_nice(u3_noun van, - u3_noun gol, - u3_noun typ) - { - if ( (c3y == _mint_vet(van)) && - (c3n == u3qzu_nest(van, gol, c3y, typ)) ) - { - // u3_noun dun = u3qzu_dunq(van, "need", gol); - // u3_noun niz = u3qzu_dunq(van, "have", typ); - - // u3t_push(u3nc(c3__mean, dun)); - // u3t_push(u3nc(c3__mean, niz)); - - return u3m_error("mint-nice"); - } - else return typ; - } - - static u3_noun - _mint_coke(u3_noun nug) - { - if ( 0 == u3h(nug) ) { - return u3k(u3t(nug)); - } - else if ( 10 == u3h(nug) ) { - return _mint_coke(u3t(u3t(nug))); - } - else { - return u3m_error("mint-coke"); - } - } - - static u3_noun - _mint_grow(u3_noun van, - u3_noun sut, - u3_noun gol, - u3_atom mel, - u3_noun ruf, - u3_noun dom) - { - u3_noun dan = _mint_in(van, sut, c3__noun, ruf); - u3_noun p_dan = u3h(dan); - u3_noun q_dan = u3t(dan); - u3_noun pul = _mint_mine(van, p_dan, mel, dom); - u3_noun ret = u3nc(_mint_nice(van, gol, u3k(u3h(pul))), - u3qz_cons(u3t(pul), q_dan)); - - u3z(pul); - u3z(dan); - return ret; - } - - static u3_noun - _mint_loc(u3_noun van, - u3_noun loc) - { - u3_noun mol = u3nc('o', u3k(loc)); - u3_noun sho = u3j_hook(u3k(van), "show"); - u3_noun ret = u3i_molt(u3k(sho), u3x_sam, u3k(mol), 0); - - u3z(mol); - u3z(sho); - - return ret; - } - -#if 1 - static u3_noun - _mint_cnts(u3_noun van, - u3_noun sut, - u3_noun gol, - u3_noun hyp, - u3_noun rig) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "emin"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam_2, - u3k(gol), - u3x_sam_6, - u3k(hyp), - u3x_sam_7, - u3k(rig), - 0)); - } -#else - static u3_noun - _mint_edit(u3_noun van, - u3_noun sut, - u3_noun mew, - u3_noun p_lar, - u3_noun rag, - u3_noun hej) - { - while ( 1 ) { - if ( c3n == u3du(mew) ) { - u3_noun gim = u3qzu_fire(van, sut, rag); - u3_noun fol = u3qz_hike(p_lar, hej); - - u3z(rag); - u3z(hej); - - return u3nc(gim, fol); - } else { - u3_noun i_mew = u3h(mew); - u3_noun t_mew = u3t(mew); - u3_noun pi_mew = u3h(i_mew); - u3_noun qi_mew = u3t(i_mew); - u3_noun zil = u3qzu_mint(van, sut, c3__noun, qi_mew); - u3_noun p_zil = u3h(zil); - u3_noun q_zil = u3t(zil); - u3_noun wip = u3qzu_toss(van, sut, pi_mew, p_zil, rag); - - u3z(rag); - rag = u3k(u3t(wip)); - - hej = u3nc(u3nc(u3k(u3h(wip)), - u3k(q_zil)), - hej); - - u3z(zil); - u3z(wip); - - mew = t_mew; - } - } - } - static u3_noun - _mint_cnts_old(u3_noun van, - u3_noun sut, - u3_noun gol, - u3_noun hyp, - u3_noun rig) - { - u3_noun lar = u3qzu_seek(van, sut, c3__read, hyp); - u3_noun p_lar = u3h(lar); - u3_noun q_lar = u3t(lar); - u3_noun pq_lar = u3h(q_lar); - u3_noun qq_lar = u3t(q_lar); - u3_noun mew = rig; - u3_noun yom = _mint_edit(van, sut, mew, p_lar, u3k(qq_lar), u3_nul); - u3_noun p_yom = u3h(yom); - u3_noun q_yom = u3t(yom); - u3_noun ret = u3nc(_mint_nice(van, gol, u3k(p_yom)), - (0 == pq_lar) ? u3k(q_yom) - : u3nt(9, u3k(pq_lar), u3k(q_yom))); - - u3z(yom); - u3z(lar); - - return ret; - } -#endif - -# define _mint_used() - - static u3_noun - _mint_in(u3_noun van, - u3_noun sut, - u3_noun gol, - u3_noun gen) - { - u3_noun p_gen, q_gen, r_gen; - u3_noun ret; - - if ( (c3__void == sut) && - !((c3y == u3du(gen)) && (c3__dbug == u3h(gen))) ) - { - if ( (c3n == _mint_vet(van)) - || ((c3y == u3du(gen)) && - ((c3__zpfs == u3h(gen)) || - (c3__zpsk == u3h(gen)) || - (c3__lost == u3h(gen)) || - (c3__fail == u3h(gen)) || - (c3__zpzp == u3h(gen)))) ) - { - return u3nt(c3__void, 0, 0); - } - else { - return u3m_error("mint-vain"); - } - } - - if ( c3n == u3du(gen) ) { - u3_noun ter = u3r_at(u3x_con_3, van); - u3_noun fab = u3r_at(u3qzu_van_fab, van); - u3_noun rex = u3qzp_open(ter, fab, gen); - - ret = _mint_in(van, sut, gol, rex); - u3z(rex); - - return ret; - } - else if ( c3y == u3du(u3h(gen)) ) { - _mint_used(); - { - u3_noun hed = _mint_in(van, sut, c3__noun, u3h(gen)); - u3_noun tal = _mint_in(van, sut, c3__noun, u3t(gen)); - u3_noun typ = u3qz_cell(u3h(hed), u3h(tal)); - - ret = u3nc(_mint_nice(van, gol, typ), - u3qz_cons(u3t(hed), - u3t(tal))); - - u3z(hed); - u3z(tal); - - return ret; - } - } else switch ( u3h(gen) ) { - default: { - u3_noun ter = u3r_at(u3x_con_3, van); - u3_noun fab = u3r_at(u3qzu_van_fab, van); - u3_noun rex = u3qzp_open(ter, fab, gen); - - if ( c3y == u3r_sing(rex, gen) ) { -#if 1 - u3_noun zix = u3qzu_shep(van, "gene", 'q', u3k(gen)); - - u3t_push(u3nc(c3__mean, zix)); - return u3m_error("mint-open"); -#else - u3_err("h", u3h(gen)); - return u3m_bail(c3__fail); -#endif - } - ret = _mint_in(van, sut, gol, rex); - u3z(rex); - - return ret; - } - - case c3__fits: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun wam = u3qzu_play(van, sut, p_gen); - u3_noun dok = u3nc(c3__wing, u3k(q_gen)); - u3_noun vol = _mint_corn(van, sut, dok); - u3_noun axe = _mint_coke(vol); - - ret = u3nc(_mint_nice(van, gol, _mint_bean()), - u3qzu_fish(van, wam, axe)); - - u3z(axe); - u3z(vol); - u3z(wam); - u3z(dok); - - return ret; - } - - case c3__wtcl: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen); - _mint_used(); - { - u3_noun bol = _mint_bean(); - u3_noun nor = _mint_in(van, sut, bol, p_gen); - u3_noun fex = u3qzu_gain(van, sut, p_gen); - u3_noun wux = u3qzu_lose(van, sut, p_gen); - u3_noun duy = (c3__void == fex) - ? ( (c3__void == wux) - ? u3nc(0, 0) - : u3nc(1, 1) ) - : ( (c3__void == wux) - ? u3nc(1, 0) - : u3k(u3t(nor)) ); - u3_noun hiq = _mint_in(van, fex, gol, q_gen); - u3_noun ran = _mint_in(van, wux, gol, r_gen); - - ret = u3nc(u3qz_forq(u3h(hiq), - u3h(ran)), - _mint_cond(duy, - u3k(u3t(hiq)), - u3k(u3t(ran)))); - - u3z(ran); - u3z(hiq); - u3z(nor); - u3z(wux); - u3z(fex); - u3z(bol); - - return ret; - } - - case c3__clhp: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun hed = _mint_in(van, sut, c3__noun, p_gen); - u3_noun tal = _mint_in(van, sut, c3__noun, q_gen); - u3_noun typ = u3qz_cell(u3h(hed), u3h(tal)); - - ret = u3nc(_mint_nice(van, gol, typ), - u3qz_cons(u3t(hed), - u3t(tal))); - - u3z(hed); - u3z(tal); - - return ret; - } - - case c3__dtts: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun typ = _mint_nice(van, gol, _mint_bean()); - u3_noun one = _mint_in(van, sut, c3__noun, p_gen); - u3_noun two = _mint_in(van, sut, c3__noun, q_gen); - u3_noun ret; - - if ( (c3y == _mint_vet(van)) && - (c3n == u3qzu_nest(van, u3h(one), c3n, u3h(two))) && - (c3n == u3qzu_nest(van, u3h(two), c3y, u3h(one))) ) - { - return u3m_error("nest"); - } - ret = u3nc(typ, u3nt(5, u3k(u3t(one)), u3k(u3t(two)))); - u3z(one); - u3z(two); - - return ret; - } - - case c3__dtwt: p_gen = u3t(gen); - _mint_used(); - { - u3_noun typ = _mint_nice(van, gol, _mint_bean()); - - return u3nc(typ, - u3nc(3, _mint_corn(van, sut, p_gen))); - } - - case c3__dtkt: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun nog = u3nc(c3__bcdt, u3k(p_gen)); - u3_noun nef = _mint_in(van, sut, gol, nog); - u3_noun viz = _mint_in(van, sut, c3__noun, q_gen); - - ret = u3nc(u3k(u3h(nef)), - u3nt(11, u3nc(1, u3nc(151, u3k(u3h(nef)))), u3k(u3t(viz)))); - - u3z(viz); - u3z(nef); - u3z(nog); - return ret; - } - - case c3__dtls: p_gen = u3t(gen); - _mint_used(); - { - u3_noun tom = u3nt(c3__atom, u3_blip, u3_nul); - u3_noun sam = _mint_in(van, sut, tom, p_gen); - - ret = u3nc(_mint_nice(van, gol, tom), - u3nc(4, u3k(u3t(sam)))); - - u3z(sam); - return ret; - } - - case c3__rock: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun typ = u3qzu_play(van, sut, gen); - u3_noun ret = u3nc(_mint_nice(van, gol, typ), - u3nc(1, u3k(q_gen))); - - return ret; - } - - case c3__dttr: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun one = _mint_corn(van, sut, p_gen); - u3_noun two = _mint_corn(van, sut, q_gen); - - return u3nc(_mint_nice(van, gol, c3__noun), - u3nt(2, one, two)); - } - - case c3__sand: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun typ = u3qzu_play(van, sut, gen); - u3_noun ret = u3nc(_mint_nice(van, gol, typ), - u3nc(1, u3k(q_gen))); - - return ret; - } - - case c3__hand: - _mint_used(); - { - return u3k(u3t(gen)); - } - - case c3__ktbr: p_gen = u3t(gen); - _mint_used(); - { - u3_noun ryd = _mint_in(van, sut, gol, p_gen); - u3_noun tyf = u3qzu_wrap(van, u3h(ryd), c3__iron); - u3_noun pro = u3nc(tyf, u3k(u3t(ryd))); - - u3z(ryd); - return pro; - } - - case c3__ktpd: - case c3__ktpm: p_gen = u3t(gen); - _mint_used(); - { - u3_noun ryd = _mint_in(van, sut, gol, p_gen); - u3_noun tyf = u3qzu_wrap(van, u3h(ryd), c3__zinc); - u3_noun pro = u3nc(tyf, u3k(u3t(ryd))); - - u3z(ryd); - return pro; - } - - case c3__ktwt: p_gen = u3t(gen); - _mint_used(); - { - u3_noun ryd = _mint_in(van, sut, gol, p_gen); - u3_noun tyf = u3qzu_wrap(van, u3h(ryd), c3__lead); - u3_noun pro = u3nc(tyf, u3k(u3t(ryd))); - - u3z(ryd); - return pro; - } - - case c3__note: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun hit = u3nc(u3k(sut), u3k(p_gen)); - u3_noun hum = _mint_in(van, sut, gol, q_gen); - - u3_noun ret = u3nc(u3qz_hint(hit, u3h(hum)), - u3k(u3t(hum))); - u3z(hum); - u3z(hit); - return ret; - } - - case c3__tune: p_gen = u3t(gen); - _mint_used(); - { - return u3nc(u3qz_face(p_gen, sut), u3nc(0, 1)); - } - - case c3__ktls: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun huz = u3qzu_play(van, sut, p_gen); - u3_noun hif = _mint_nice(van, gol, huz); - u3_noun zel = _mint_in(van, sut, hif, q_gen); - u3_noun ret = u3nc(hif, u3k(u3t(zel))); - - u3z(zel); - return ret; - } - - case c3__tsgr: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun fid = _mint_in(van, sut, c3__noun, p_gen); - u3_noun p_fid = u3h(fid); - u3_noun q_fid = u3t(fid); - - if ( 0 == p_fid ) { - u3m_p("bad subject: p_gen", p_gen); - c3_assert(0); - } - u3_noun dov = _mint_in(van, p_fid, gol, q_gen); - u3_noun p_dov = u3h(dov); - u3_noun q_dov = u3t(dov); - - ret = u3nc(u3k(p_dov), - u3qz_comb(q_fid, q_dov)); - - u3z(fid); - u3z(dov); - return ret; - } - - case c3__tscm: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun boc = u3qzu_busk(van, sut, p_gen); - u3_noun ret = _mint_in(van, boc, gol, q_gen); - - u3z(boc); - return ret; - } - - case c3__cnts: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - return _mint_cnts(van, sut, gol, p_gen, q_gen); - } - - case c3__brcn: p_gen = u3t(gen); - _mint_used(); - { - u3_noun ruf = u3nc(u3_nul, 1); - - ret = _mint_grow(van, sut, gol, c3__gold, ruf, p_gen); - u3z(ruf); - - return ret; - } - - case c3__sgzp: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun typ = u3qzu_play(van, sut, p_gen); - u3_noun dug = u3qzu_duck(van, typ); - - u3t_push(u3nc(c3__mean, dug)); - { - ret = _mint_in(van, sut, gol, q_gen); - } - u3t_drop(); - - u3z(typ); - return ret; - } - - case c3__sggr: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun hum = _mint_in(van, sut, gol, q_gen); - u3_noun bez; - - if ( c3y == u3ud(p_gen) ) { - bez = u3k(p_gen); - } else { - bez = u3nc(u3k(u3h(p_gen)), - _mint_corn(van, sut, u3t(p_gen))); - } - ret = u3nc(u3k(u3h(hum)), - u3nt(10, bez, u3k(u3t(hum)))); - - u3z(hum); - return ret; - } - - case c3__zpts: p_gen = u3t(gen); - _mint_used(); - { - u3_noun von = u3i_molt(u3k(van), u3qzu_van_vet, c3n, 0); - u3_noun sev = _mint_corn(von, sut, p_gen); - - u3z(von); - return u3nc(c3__noun, u3nc(1, sev)); - } - - case c3__ktcn: p_gen = u3t(gen); - _mint_used(); - { - u3_noun von = u3i_molt(u3k(van), u3qzu_van_fab, c3n, 0); - u3_noun ret = _mint_in(von, sut, gol, p_gen); - - u3z(von); - return ret; - } - - case c3__cold: - case c3__ktsg: p_gen = u3t(gen); - _mint_used(); - { - - c3_m fun_m = 144 + c3__blow; - u3_noun vrf = u3r_at(u3qzu_van_vrf, van); - u3_noun pro = u3z_find_4(fun_m, vrf, sut, gol, p_gen); - - if ( u3_none != pro ) { - return pro; - } - else { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "blow"); - u3_noun pro; - - pro = u3n_kick_on(u3i_molt(gat, - u3x_sam_2, - u3k(gol), - u3x_sam_3, - u3k(p_gen), - 0)); - - return u3z_save_4(fun_m, vrf, sut, gol, p_gen, pro); - } - } - - case c3__zpcm: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - return u3nc(_mint_nice(van, - gol, - u3qzu_play(van, sut, p_gen)), - u3nc(1, u3k(q_gen))); - } - - case c3__dbug: u3x_cell(u3t(gen), &p_gen, &q_gen); - { - u3t_push(u3nc(c3__mean, _mint_loc(van, p_gen))); - { - u3_noun hum = _mint_in(van, sut, gol, q_gen); - u3_noun bez = u3nt(c3__spot, 1, u3k(p_gen)); - - ret = u3nc(u3k(u3h(hum)), u3nt(10, bez, u3k(u3t(hum)))); - u3z(hum); - } - u3t_drop(); - return ret; - } - - case c3__zpmc: - case c3__zpsm: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mint_used(); - { - u3_noun vos = _mint_in(van, sut, c3__noun, q_gen); - u3_noun zur = u3qzu_play(van, sut, p_gen); - u3_noun p_vos = u3h(vos); - u3_noun q_vos = u3t(vos); - u3_noun waz = u3nc(1, _mint_burp(van, p_vos)); - // u3_noun waz = u3nc(1, u3k(p_vos)); - u3_noun sif = u3k(zur); - u3_noun cig = u3qz_cell(sif, p_vos); - u3_noun ret; - - ret = u3nc(_mint_nice(van, gol, cig), - u3qz_cons(waz, q_vos)); - - u3z(waz); - u3z(zur); - u3z(sif); - u3z(vos); - - return ret; - } - - case c3__zpvt: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen); - _mint_used(); - { - if ( c3y == _mint_feel(van, sut, p_gen) ) { - return _mint_in(van, sut, gol, q_gen); - } else { - return _mint_in(van, sut, gol, r_gen); - } - } - - case c3__lost: p_gen = u3t(gen); - _mint_used(); - { - if ( c3y == _mint_vet(van) ) { - u3_noun zur = u3qzu_play(van, sut, p_gen); - u3_noun dun = u3qzu_dunq(van, "lost", zur); - - u3t_push(u3nc(c3__mean, dun)); - return u3m_error("mint-lost"); - } - else { - return u3nt(c3__void, 0, 0); - } - } - - case c3__fail: - case c3__zpzp: - _mint_used(); - { - return u3nt(c3__void, 0, 0); - } - } - } - - static u3_noun - _cqzu_mint(u3_noun van, - u3_noun sut, - u3_noun gol, - u3_noun gen) - { - return _mint_in(van, sut, gol, gen); - } - -/* boilerplate -*/ - u3_noun - u3wzu_mint(u3_noun cor) - { - u3_noun sut, gol, gen, van; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &gol, - u3x_sam_3, &gen, - u3x_con, &van, - 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_mint(van, sut, gol, gen); - } - } - - u3_noun - u3qzu_mint(u3_noun van, - u3_noun sut, - u3_noun gol, - u3_noun gen) - { - c3_m fun_m = 144 + c3__mint; - u3_noun vrf = u3r_at(u3qzu_van_vrf, van); - u3_noun pro = u3z_find_4(fun_m, vrf, sut, gol, gen); - - if ( u3_none != pro ) { - return pro; - } - else { - pro = _cqzu_mint(van, sut, gol, gen); - - return u3z_save_4(fun_m, vrf, sut, gol, gen, pro); - } - } diff --git a/jets/z/ut_mull.c b/jets/z/ut_mull.c deleted file mode 100644 index b99901b2b..000000000 --- a/jets/z/ut_mull.c +++ /dev/null @@ -1,757 +0,0 @@ -/* j/6/mull.c -** -*/ -#include "all.h" - -/* functions -*/ - static u3_noun - _mull_in(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - - static u3_noun - _mull_bean() - { - return u3kf_fork(u3nt(u3nq(c3__atom, 'f', u3_nul, 0), - u3nq(c3__atom, 'f', u3_nul, 1), - u3_nul)); - } - - static u3_noun - _mull_loc(u3_noun van, - u3_noun loc) - { - u3_noun mol = u3nc('o', u3k(loc)); - u3_noun sho = u3j_hook(u3k(van), "show"); - u3_noun ret = u3i_molt(u3k(sho), u3x_sam, u3k(mol), 0); - - u3z(mol); - u3z(sho); - - return ret; - } - - static u3_noun - _mull_feel(u3_noun van, - u3_noun sut, - u3_noun rot) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "feel"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam, - u3k(rot), - 0)); - } - - static u3_noun - _mull_coke(u3_noun nug) - { - if ( 0 == u3h(nug) ) { - return u3k(u3t(nug)); - } - else if ( 10 == u3h(nug) ) { - return _mull_coke(u3t(u3t(nug))); - } - else { - return u3m_error("mull-coke"); - } - } - - static u3_noun - _mull_mile(u3_noun van, - u3_noun sut, - u3_noun dox, - u3_noun mel, - u3_noun dom) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "mile"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam_2, - u3k(dox), - u3x_sam_6, - u3k(mel), - u3x_sam_7, - u3k(dom), - 0)); - } - - static u3_noun - _mull_doke(u3_noun van, - u3_noun sut, - u3_noun gen) - { - u3_noun fug = u3qzu_mint(van, sut, c3__noun, gen); - u3_noun axe = _mull_coke(u3t(fug)); - - u3z(fug); - return axe; - } - - static u3_noun - _mull_nice(u3_noun van, - u3_noun gol, - u3_noun typ) - { - if ( c3n == u3qzu_nest(van, gol, c3y, typ) ) { - // u3_noun dun = u3qzu_dunq(van, "need", gol); - // u3_noun niz = u3qzu_dunq(van, "have", typ); - - // u3t_push(u3nc(c3__mean, dun)); - // u3t_push(u3nc(c3__mean, niz)); - - return u3m_error("mull-nice"); - } - else return typ; - } - - static u3_noun - _mull_grow(u3_noun van, - u3_noun sut, - u3_noun gol, - u3_noun dox, - u3_atom mel, - u3_noun ruf, - u3_noun dom) - { - u3_noun dan = _mull_in(van, sut, c3__noun, dox, ruf); - u3_noun p_dan = u3h(dan); - u3_noun q_dan = u3t(dan); - u3_noun yaz = _mull_mile(van, p_dan, q_dan, mel, dom); - u3_noun p_yaz = u3h(yaz); - u3_noun q_yaz = u3t(yaz); - u3_noun ret = u3nc(_mull_nice(van, gol, u3k(p_yaz)), u3k(q_yaz)); - - u3z(yaz); - u3z(dan); - - return ret; - } - - static u3_noun - _mull_both(u3_noun van, - u3_noun gol, - u3_noun typ) - { - return u3nc(_mull_nice(van, gol, u3k(typ)), - typ); - } - -#if 1 - static u3_noun - _mull_cnts(u3_noun van, - u3_noun sut, - u3_noun gol, - u3_noun dox, - u3_noun hyp, - u3_noun rig) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "emul"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam_2, - u3k(gol), - u3x_sam_6, - u3k(dox), - u3x_sam_14, - u3k(hyp), - u3x_sam_15, - u3k(rig), - 0)); - } -#else - static u3_noun - _mull_edit(u3_noun van, - u3_noun sut, - u3_noun dox, - u3_noun mew, - u3_noun p_yom, - u3_noun q_yom) - { - while ( 1 ) { - if ( c3n == u3du(mew) ) { - return u3nc(p_yom, q_yom); - } else { - u3_noun i_mew = u3h(mew); - u3_noun t_mew = u3t(mew); - u3_noun pi_mew = u3h(i_mew); - u3_noun qi_mew = u3t(i_mew); - u3_noun zil = _mull_in(van, sut, c3__noun, dox, qi_mew); - u3_noun p_zil = u3h(zil); - u3_noun q_zil = u3t(zil); - u3_noun cuf = u3qzu_toss(van, sut, pi_mew, p_zil, p_yom); - u3_noun dof = u3qzu_toss(van, sut, pi_mew, q_zil, q_yom); - - if ( u3r_sing(u3h(cuf), u3h(dof)) ) { - u3m_error("mull-bonk-a"); - } - - u3z(p_yom); - p_yom = u3k(u3t(cuf)); - - u3z(q_yom); - q_yom = u3k(u3t(dof)); - - u3z(dof); - u3z(cuf); - u3z(zil); - - mew = t_mew; - } - } - } - - static u3_noun - _mull_cnts_old(u3_noun van, - u3_noun sut, - u3_noun gol, - u3_noun dox, - u3_noun hyp, - u3_noun rig) - { - u3_noun lar = u3qzu_seek(van, sut, c3__read, hyp); - u3_noun vug = u3qzu_seek(van, dox, c3__read, hyp); - u3_noun p_lar = u3h(lar); - u3_noun q_lar = u3t(lar); - u3_noun pq_lar = u3h(q_lar); - u3_noun qq_lar = u3t(q_lar); - u3_noun p_vug = u3h(vug); - u3_noun q_vug = u3t(vug); - u3_noun pq_vug = u3h(q_vug); - u3_noun qq_vug = u3t(q_vug); - - if ( c3a(u3r_sing(p_lar, p_vug), u3r_sing(pq_lar, pq_vug)) ) { - u3m_error("mull-bonk-e"); - } - { - u3_noun mew = rig; - u3_noun yom = _mull_edit - (van, sut, dox, mew, u3k(qq_lar), - u3k(qq_vug)); - u3_noun von = u3i_molt(u3k(van), u3qzu_van_vet, c3n, 0); - u3_noun p_ret = u3qzu_fire(van, sut, u3h(yom)); - u3_noun q_ret = u3qzu_fire(von, sut, u3t(yom)); - - u3z(von); - u3z(yom); - u3z(vug); - u3z(lar); - - return u3nc(_mull_nice(van, gol, p_ret), q_ret); - } - } -#endif - -# define _mull_used() - - static u3_noun - _mull_in(u3_noun van, - u3_noun sut, - u3_noun gol, - u3_noun dox, - u3_noun gen) - { - u3_noun p_gen, q_gen, r_gen; - u3_noun ret; - - if ( c3n == u3du(gen) ) { - u3_noun ter = u3r_at(u3x_con_3, van); - u3_noun fab = u3r_at(u3qzu_van_fab, van); - u3_noun rex = u3qzp_open(ter, fab, gen); - - ret = _mull_in(van, sut, gol, dox, rex); - u3z(rex); - - return ret; - } - else if ( c3y == u3du(u3h(gen)) ) { - _mull_used(); - { - u3_noun hed = _mull_in(van, sut, c3__noun, dox, u3h(gen)); - u3_noun tal = _mull_in(van, sut, c3__noun, dox, u3t(gen)); - u3_noun dis = u3qz_cell(u3h(hed), u3h(tal)); - u3_noun dat = u3qz_cell(u3t(hed), u3t(tal)); - u3_noun ret = u3nc(_mull_nice(van, gol, dis), dat); - - u3z(tal); - u3z(hed); - - return ret; - } - } - else switch ( u3h(gen) ) { - default: { - u3_noun ter = u3r_at(u3x_con_3, van); - u3_noun fab = u3r_at(u3qzu_van_fab, van); - u3_noun rex = u3qzp_open(ter, fab, gen); - - if ( c3y == u3r_sing(rex, gen) ) { -#if 1 - u3_noun zix = u3qzu_shep(van, "gene", 'q', u3k(gen)); - - u3t_push(u3nc(c3__mean, zix)); - return u3m_error("mull-open"); -#else - u3_err("h", u3h(gen)); - return u3m_bail(c3__fail); -#endif - } - ret = _mull_in(van, sut, gol, dox, rex); - u3z(rex); - - return ret; - } - - case c3__fits: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun p_waz = u3qzu_play(van, sut, p_gen); - u3_noun q_waz = u3qzu_play(van, dox, p_gen); - u3_noun dok = u3nc(c3__wing, u3k(q_gen)); - u3_noun p_syx = _mull_doke(van, sut, dok); - u3_noun q_syx = _mull_doke(van, dox, dok); - u3_noun p_pov = u3qzu_fish(van, p_waz, p_syx); - u3_noun q_pov = u3qzu_fish(van, q_waz, q_syx); - - if ( (c3n == u3r_sing(p_syx, q_syx)) || - (c3n == u3r_sing(p_pov, q_pov)) ) - { - return u3m_error("mull-bonk-b"); - } - u3z(p_waz); u3z(q_waz); - u3z(p_syx); u3z(q_syx); - u3z(p_pov); u3z(q_pov); - u3z(dok); - - return _mull_both(van, gol, _mull_bean()); - } - - case c3__wtcl: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen); - _mull_used(); - { - u3_noun bol = _mull_bean(); - u3_noun nor = _mull_in(van, sut, bol, dox, p_gen); - u3_noun p_fex = u3qzu_gain(van, sut, p_gen); - u3_noun q_fex = u3qzu_gain(van, dox, p_gen); - u3_noun p_wux = u3qzu_lose(van, sut, p_gen); - u3_noun q_wux = u3qzu_lose(van, dox, p_gen); - u3_noun hiq, ran; - u3_noun dis, dat; - u3_noun ret; - - if ( c3__void == p_fex ) { - hiq = u3nc(c3__void, - (c3__void == q_fex) - ? c3__void - : u3qzu_play(van, q_fex, q_gen)); - } else if ( c3__void == q_fex ) { - hiq = u3m_error("mull-bonk-c"); - } - else hiq = _mull_in(van, p_fex, gol, q_fex, q_gen); - - if ( c3__void == p_wux ) { - ran = u3nc(c3__void, - (c3__void == q_wux) - ? c3__void - : u3qzu_play(van, q_wux, r_gen)); - } else if ( c3__void == q_wux ) { - ran = u3m_error("mull-bonk-d"); - } - else ran = _mull_in(van, p_wux, gol, q_wux, r_gen); - - dis = u3qz_forq(u3h(hiq), u3h(ran)); - dat = u3qz_forq(u3t(hiq), u3t(ran)); - - ret = u3nc(_mull_nice(van, gol, dis), dat); - - u3z(ran); - u3z(hiq); - u3z(q_wux); - u3z(p_wux); - u3z(q_fex); - u3z(p_fex); - u3z(nor); - u3z(bol); - - return ret; - } - - case c3__clhp: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun hed = _mull_in(van, sut, c3__noun, dox, p_gen); - u3_noun tal = _mull_in(van, sut, c3__noun, dox, q_gen); - u3_noun dis = u3qz_cell(u3h(hed), u3h(tal)); - u3_noun dat = u3qz_cell(u3t(hed), u3t(tal)); - u3_noun ret = u3nc(_mull_nice(van, gol, dis), dat); - - u3z(tal); - u3z(hed); - - return ret; - } - - case c3__dtts: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun hed = _mull_in(van, sut, c3__noun, dox, p_gen); - u3_noun tal = _mull_in(van, sut, c3__noun, dox, q_gen); - - u3z(hed); - u3z(tal); - - return _mull_both(van, gol, _mull_bean()); - } - - case c3__dtwt: p_gen = u3t(gen); - _mull_used(); - { - u3_noun vay = _mull_in(van, sut, c3__noun, dox, p_gen); - - u3z(vay); - return _mull_both(van, gol, _mull_bean()); - } - - case c3__dtkt: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun nog = u3nc(c3__bcdt, u3k(p_gen)); - u3_noun vay = _mull_in(van, sut, c3__noun, dox, q_gen); - u3_noun ret; - - u3z(vay); - ret = _mull_in(van, sut, gol, dox, nog); - u3z(nog); - return ret; - } - - case c3__dtls: p_gen = u3t(gen); - _mull_used(); - { - u3_noun wuq = u3nt(c3__atom, u3_blip, u3_nul); - u3_noun vay = _mull_in(van, sut, wuq, dox, p_gen); - - u3z(vay); - return _mull_both(van, gol, wuq); - } - - case c3__rock: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun typ = u3qzu_play(van, sut, gen); - - return _mull_both(van, gol, typ); - } - - case c3__dttr: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun hed = _mull_in(van, sut, c3__noun, dox, p_gen); - u3_noun tal = _mull_in(van, sut, c3__noun, dox, q_gen); - - u3z(hed); - u3z(tal); - - return _mull_both(van, gol, c3__noun); - } - - case c3__sand: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun typ = u3qzu_play(van, sut, gen); - return _mull_both(van, gol, typ); - } - - case c3__hand: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - return u3nc(u3k(p_gen), u3k(p_gen)); - } - - case c3__ktbr: p_gen = u3t(gen); - _mull_used(); - { - u3_noun vat = _mull_in(van, sut, gol, dox, p_gen); - u3_noun pro = u3nc(u3qzu_wrap(van, - u3h(vat), - c3__iron), - u3qzu_wrap(van, - u3t(vat), - c3__iron)); - - u3z(vat); - return pro; - } - - case c3__ktpd: - case c3__ktpm: p_gen = u3t(gen); - _mull_used(); - { - u3_noun vat = _mull_in(van, sut, gol, dox, p_gen); - u3_noun pro = u3nc(u3qzu_wrap(van, - u3h(vat), - c3__zinc), - u3qzu_wrap(van, - u3t(vat), - c3__zinc)); - - u3z(vat); - return pro; - } - - case c3__ktwt: p_gen = u3t(gen); - _mull_used(); - { - u3_noun vat = _mull_in(van, sut, gol, dox, p_gen); - u3_noun pro = u3nc(u3qzu_wrap(van, - u3h(vat), - c3__lead), - u3qzu_wrap(van, - u3t(vat), - c3__lead)); - - u3z(vat); - return pro; - } - - case c3__note: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun vat = _mull_in(van, sut, gol, dox, q_gen); - u3_noun hit = u3nc(u3k(sut), u3k(p_gen)); - u3_noun hix = u3nc(u3k(dox), u3k(p_gen)); - u3_noun ret = u3nc(u3qz_hint(hit, u3h(vat)), - u3qz_hint(hix, u3t(vat))); - - u3z(hix); - u3z(hit); - u3z(vat); - return ret; - } - - case c3__tune: p_gen = u3t(gen); - _mull_used(); - { - return u3nc(u3qz_face(p_gen, sut), - u3qz_face(p_gen, dox)); - } - - case c3__ktsg: p_gen = u3t(gen); - _mull_used(); - { - return _mull_in(van, sut, gol, dox, p_gen); - } - - case c3__ktls: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun p_hif = _mull_nice(van, gol, u3qzu_play(van, sut, p_gen)); - u3_noun q_hif = u3qzu_play(van, dox, p_gen); - u3_noun zel = _mull_in(van, sut, p_hif, dox, q_gen); - u3_noun ret = u3nc(p_hif, q_hif); - - u3z(zel); - return ret; - } - - case c3__tsgr: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun lem = _mull_in(van, sut, c3__noun, dox, p_gen); - u3_noun p_lem = u3h(lem); - u3_noun q_lem = u3t(lem); - u3_noun ret = _mull_in(van, p_lem, gol, q_lem, q_gen); - - u3z(lem); - return ret; - } - - case c3__tscm: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun boc = u3qzu_busk(van, sut, p_gen); - u3_noun nuf = u3qzu_busk(van, dox, p_gen); - u3_noun ret = _mull_in(van, boc, gol, nuf, q_gen); - - u3z(boc); - u3z(nuf); - - return ret; - } - - case c3__cnts: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - return _mull_cnts(van, sut, gol, dox, p_gen, q_gen); - } - - case c3__brcn: p_gen = u3t(gen); - _mull_used(); - { - u3_noun ruf = u3nc(u3_nul, 1); - - ret = _mull_grow(van, sut, gol, dox, c3__gold, ruf, p_gen); - u3z(ruf); - - return ret; - } - - case c3__sgzp: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun typ = u3qzu_play(van, sut, p_gen); - u3_noun dug = u3qzu_duck(van, typ); - u3_noun ret; - - u3t_push(u3nc(c3__mean, dug)); - { - ret = _mull_in(van, sut, gol, dox, q_gen); - } - u3t_drop(); - - u3z(typ); - return ret; - } - - case c3__sggr: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - return _mull_in(van, sut, gol, dox, q_gen); - } - - case c3__zpcm: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun p_ret = u3qzu_play(van, sut, p_gen); - u3_noun q_ret = u3qzu_play(van, sut, q_gen); - - return u3nc(_mull_nice(van, gol, p_ret), - q_ret); - } - - case c3__dbug: u3x_cell(u3t(gen), &p_gen, &q_gen); - { - u3_noun ret; - - u3t_push(u3nc(c3__mean, _mull_loc(van, p_gen))); - { - ret = _mull_in(van, sut, gol, dox, q_gen); - } - u3t_drop(); - return ret; - } - - case c3__zpts: p_gen = u3t(gen); - _mull_used(); - { - return _mull_both(van, gol, c3__noun); - } - - case c3__ktcn: p_gen = u3t(gen); - _mull_used(); - { - u3_noun von = u3i_molt(u3k(van), u3qzu_van_fab, c3n, 0); - u3_noun ret = _mull_in(von, sut, gol, dox, p_gen); - - u3z(von); - return ret; - } - - case c3__zpmc: - case c3__zpsm: u3x_cell(u3t(gen), &p_gen, &q_gen); - _mull_used(); - { - u3_noun p_zur = u3qzu_play(van, sut, p_gen); - u3_noun q_zur = u3qzu_play (van, dox, p_gen); - u3_noun vos = _mull_in(van, sut, c3__noun, dox, q_gen); - u3_noun p_ret = u3qz_cell(p_zur, u3h(vos)); - u3_noun q_ret = u3qz_cell(q_zur, u3t(vos)); - - u3z(vos); - u3z(q_zur); - u3z(p_zur); - - return u3nc - (_mull_nice(van, gol, p_ret), q_ret); - } - case c3__zpvt: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen); - _mull_used(); - { - c3_o fes = _mull_feel(van, sut, p_gen); - c3_o fed = _mull_feel(van, dox, p_gen); - - if ( fes != fed ) { - return u3m_error("mull-bonk-f"); - } - else { - if ( c3y == fes ) { - return _mull_in(van, sut, gol, dox, q_gen); - } else { - return _mull_in(van, sut, gol, dox, r_gen); - } - } - } - - case c3__lost: - case c3__fail: - case c3__zpzp: - _mull_used(); - { - return u3nc(c3__void, c3__void); - } - } - } - - static u3_noun - _cqzu_mull(u3_noun van, - u3_noun sut, - u3_noun gol, - u3_noun dox, - u3_noun gen) - { - return _mull_in(van, sut, gol, dox, gen); - } - -/* boilerplate -*/ - u3_noun - u3wzu_mull(u3_noun cor) - { - u3_noun sut, gol, dox, gen, van; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &gol, - u3x_sam_6, &dox, - u3x_sam_7, &gen, - u3x_con, &van, - 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_mull(van, sut, gol, dox, gen); - } - } - - u3_noun - u3qzu_mull(u3_noun van, - u3_noun sut, - u3_noun gol, - u3_noun dox, - u3_noun gen) - { - c3_m fun_m = 144 + c3__mull + ((!!u3r_at(u3qzu_van_vet, van)) << 8); - u3_noun pro = u3z_find_4(fun_m, sut, gol, dox, gen); - - if ( u3_none != pro ) { - return pro; - } - else { - pro = _cqzu_mull(van, sut, gol, dox, gen); - - return u3z_save_4(fun_m, sut, gol, dox, gen, pro); - } - } - diff --git a/jets/z/ut_nest.c b/jets/z/ut_nest.c deleted file mode 100644 index 152e0756a..000000000 --- a/jets/z/ut_nest.c +++ /dev/null @@ -1,566 +0,0 @@ -/* j/6/ut_nest.c -** -*/ -#include "all.h" - -/* logic -*/ - /* forward - */ - static u3_noun - _nest_sint(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - static u3_noun - _nest_dext(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun); - - static u3_noun - _nest_deep(u3_noun van, - u3_noun sut, - u3_noun tel, - u3_noun ref, - u3_noun dab, - u3_noun hem, - u3_noun gil) - { - if ( u3_nul == dab ) { - return u3r_sing(u3_nul, hem); - } else if ( u3_nul == hem ) { - return c3n; - } else { - u3_noun n_dab, l_dab, r_dab; - u3_noun n_hem, l_hem, r_hem; - u3_noun pn_hem, pqn_hem, qqn_hem, pn_dab, pqn_dab, qqn_dab; - - u3x_trel(dab, &n_dab, &l_dab, &r_dab); - u3x_trel(hem, &n_hem, &l_hem, &r_hem); - - if ( (c3n == _nest_deep(van, sut, tel, ref, l_dab, l_hem, gil)) || - (c3n == _nest_deep(van, sut, tel, ref, r_dab, r_hem, gil)) ) - { - return c3n; - } - u3x_trel(n_dab, &pn_dab, &pqn_dab, &qqn_dab); - u3x_trel(n_hem, &pn_hem, &pqn_hem, &qqn_hem); - - if ( c3n == u3r_sing(pn_dab, pn_hem) ) { - return c3n; - } else { - if ( (c3n == u3du(qqn_dab)) || (c3n == u3du(qqn_hem)) ) { - return u3m_bail(c3__fail); - } - else switch ( u3h(qqn_dab) ) { - default: return u3m_bail(c3__exit); - case c3__ash: { - if ( c3__ash != u3h(qqn_hem) ) { - return c3n; - } else { - u3_noun qqqn_dab = u3t(qqn_dab); - u3_noun qqqn_hem = u3t(qqn_hem); - u3_noun vis = u3qzu_play(van, sut, qqqn_dab); - u3_noun lon = u3qzu_play(van, ref, qqqn_hem); - - u3_noun ret = _nest_dext(van, vis, tel, lon, u3_nul, u3_nul, gil); - - u3z(vis); - u3z(lon); - return ret; - } - } - case c3__elm: { - return u3r_sing(qqn_dab, qqn_hem); - } - } - } - } - } - - static u3_noun - _nest_dope(u3_noun van, - u3_noun sut, - u3_noun tel, - u3_noun ref, - u3_noun dom, - u3_noun vim, - u3_noun gil) - { - if ( u3_nul == dom ) { - return u3r_sing(u3_nul, vim); - } else if ( u3_nul == vim ) { - return c3n; - } else { - u3_noun n_dom, l_dom, r_dom; - u3_noun n_vim, l_vim, r_vim; - u3_noun pn_vim, qn_vim, pn_dom, qn_dom; - - u3x_trel(dom, &n_dom, &l_dom, &r_dom); - u3x_trel(vim, &n_vim, &l_vim, &r_vim); - - if ( (c3n == _nest_dope(van, sut, tel, ref, l_dom, l_vim, gil)) || - (c3n == _nest_dope(van, sut, tel, ref, r_dom, r_vim, gil)) ) - { - return c3n; - } - u3x_cell(n_dom, &pn_dom, &qn_dom); - u3x_cell(n_vim, &pn_vim, &qn_vim); - - if ( c3n == u3r_sing(pn_dom, pn_vim) ) { - return c3n; - } else { - return _nest_deep(van, sut, tel, ref, qn_dom, qn_vim, gil); - } - } - } - - static u3_noun - _nest_cong(u3_noun van, - u3_noun sut, - u3_noun tel, - u3_noun ref, - u3_noun gil) - { - u3_noun p_sut, q_sut, p_ref, q_ref; - u3_noun pq_sut, qq_sut, rq_sut; - u3_noun pq_ref, qq_ref, rq_ref; - u3_noun prq_sut, qrq_sut, prq_ref, qrq_ref; - u3_noun ppq_sut, qpq_sut, rpq_sut; - u3_noun ppq_ref, qpq_ref, rpq_ref; - u3_noun ret; - - u3x_trel(sut, 0, &p_sut, &q_sut); - u3x_trel(ref, 0, &p_ref, &q_ref); - - u3x_trel(q_sut, &pq_sut, &qq_sut, &rq_sut); - u3x_trel(q_ref, &pq_ref, &qq_ref, &rq_ref); - - u3x_trel(pq_sut, &ppq_sut, &qpq_sut, &rpq_sut); - u3x_trel(pq_ref, &ppq_ref, &qpq_ref, &rpq_ref); - - u3x_cell(rq_sut, &prq_sut, &qrq_sut); - u3x_cell(rq_ref, &prq_ref, &qrq_ref); - - if ( c3y == u3r_sing(q_sut, q_ref) ) { - return _nest_dext(van, p_sut, tel, p_ref, u3_nul, u3_nul, gil); - } - else if ( (c3n == _nest_dext - (van, qq_sut, tel, p_sut, u3_nul, u3_nul, gil)) || - (c3n == _nest_dext - (van, p_sut, tel, qq_sut, u3_nul, u3_nul, gil)) || - (c3n == _nest_dext - (van, qq_ref, tel, p_ref, u3_nul, u3_nul, gil)) ) - { - return c3n; - } - else { - if ( (rpq_sut != rpq_ref) && - (c3__lead != rpq_sut) && - (c3__gold != rpq_ref) ) - { - return c3n; - } - else { - u3_noun hud = u3nc(u3k(sut), u3k(ref)); - - if ( (c3y == u3qdi_has(gil, hud)) ) { - u3z(hud); - - return c3y; - } - else { - u3_noun zoc = u3qdi_put(gil, hud); - u3_noun tus = u3nt(c3__core, - u3k(qq_sut), - u3nc(u3nt(u3k(ppq_sut), u3k(qpq_sut), c3__gold), - u3k(u3t(q_sut)))); - - u3_noun fer = u3nt(c3__core, - u3k(qq_ref), - u3nc(u3nt(u3k(ppq_ref), u3k(qpq_ref), c3__gold), - u3k(u3t(q_ref)))); - - ret = _nest_dope(van, tus, tel, fer, qrq_sut, qrq_ref, zoc); - u3z(fer); - u3z(tus); - u3z(zoc); - u3z(hud); - - if ( c3n == ret ) { - return c3n; - } - else { - switch ( rpq_sut ) { - default: return u3m_bail(c3__fail); - - case c3__gold: { - return - c3a(_nest_dext(van, qq_sut, tel, qq_ref, u3_nul, u3_nul, gil), - _nest_dext(van, qq_ref, tel, qq_sut, u3_nul, u3_nul, gil)); - } - case c3__iron: { - u3_noun s_sam = u3qzu_peek(van, qq_sut, c3__rite, 2); - u3_noun r_sam = u3qzu_peek(van, qq_ref, c3__rite, 2); - u3_noun ret = _nest_dext - (van, r_sam, tel, s_sam, u3_nul, u3_nul, gil); - - u3z(r_sam); - u3z(s_sam); - return ret; - } - case c3__lead: { - return c3y; - } - case c3__zinc: { - u3_noun s_pal = u3qzu_peek(van, qq_sut, c3__read, 2); - u3_noun r_pal = u3qzu_peek(van, qq_ref, c3__read, 2); - u3_noun ret = _nest_dext - (van, s_pal, tel, r_pal, u3_nul, u3_nul, gil); - - u3z(r_pal); - u3z(s_pal); - - return ret; - } - } - } - } - } - } - } - - static u3_noun - _nest_dext_in(u3_noun van, - u3_noun sut, - u3_noun tel, - u3_noun ref, - u3_noun seg, - u3_noun reg, - u3_noun gil) - { - u3_noun p_sut, q_sut, p_ref, q_ref; - - if ( (c3n == u3du(sut)) ) switch ( sut ) { - default: return u3m_bail(c3__fail); - - case c3__noun: { - return c3y; - } - case c3__void: { - return _nest_sint(van, sut, tel, ref, seg, reg, gil); - } - } - else switch ( u3h(sut) ) { - default: return u3m_bail(c3__fail); - - case c3__atom: { - if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { - return u3m_bail(c3__fail); - } - else { - if ( c3y == u3r_pq(ref, c3__atom, &p_ref, &q_ref) ) { - if ( (c3n == u3qz_fitz(p_sut, p_ref)) || - ( (c3y == u3du(q_sut)) && - ( (c3n == u3du(q_ref)) || - (c3n == u3r_sing(q_sut, q_ref)))) ) - { - return c3n; - } - return c3y; - } - return _nest_sint(van, sut, tel, ref, seg, reg, gil); - } - } - case c3__cell: { - if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { - return u3m_bail(c3__fail); - } else { - if ( c3y == u3r_pq(ref, c3__cell, &p_ref, &q_ref) ) { - return c3a(_nest_dext(van, p_sut, tel, p_ref, u3_nul, u3_nul, gil), - _nest_dext(van, q_sut, tel, q_ref, u3_nul, u3_nul, gil)); - } - else return _nest_sint(van, sut, tel, ref, seg, reg, gil); - } - } - case c3__core: { - if ( c3n == u3r_trel(sut, 0, &p_sut, &q_sut) ) { - return u3m_bail(c3__fail); - } else { - if ( (c3y == u3r_pq(ref, c3__core, &p_ref, &q_ref)) ) { - return _nest_cong(van, sut, tel, ref, gil); - } - else return _nest_sint(van, sut, tel, ref, seg, reg, gil); - } - } - case c3__hint: - case c3__face: { - if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { - return u3m_bail(c3__fail); - } else { - return _nest_dext(van, q_sut, tel, ref, seg, reg, gil); - } - } - case c3__fork: p_sut = u3t(sut); - { - if ( c3n == u3du(ref) ) switch ( ref ) { - default: return _nest_sint(van, sut, tel, ref, seg, reg, gil); - - case c3__noun: - break; - } - else switch ( u3h(ref) ) { - default: return _nest_sint(van, sut, tel, ref, seg, reg, gil); - - case c3__atom: - case c3__cell: - case c3__core: - break; - } - - { - u3_noun dey = u3qdi_tap(p_sut); - u3_noun yed = dey; - - while ( u3_nul != yed ) { - if ( c3y == _nest_dext(van, u3h(yed), c3n, ref, seg, reg, gil) ) { - u3z(dey); - return c3y; - } else { - yed = u3t(yed); - } - } - u3z(dey); - return c3n; - } - } - case c3__hold: - { - if ( c3y == u3qdi_has(seg, sut) ) { - return c3n; - } - else { - u3_noun hud = u3nc(u3k(sut), u3k(ref)); - - if ( (c3y == u3qdi_has(gil, hud)) ) { - u3z(hud); - - return c3y; - } - else { - u3_noun gus = u3qdi_put(seg, sut); - u3_noun zoc = u3qdi_put(gil, hud); - u3_noun fop = u3qzu_repo(van, sut); - u3_noun hiv = _nest_dext(van, fop, tel, ref, gus, reg, zoc); - - u3z(hud); - u3z(fop); - u3z(zoc); - u3z(gus); - - return hiv; - } - } - } - } - } - - static u3_noun - _nest_dext_to(u3_noun van, - u3_noun sut, - u3_noun tel, - u3_noun ref, - u3_noun seg, - u3_noun reg, - u3_noun gil) - { - u3_noun tyn = _nest_dext_in(van, sut, tel, ref, seg, reg, gil); - - if ( (c3y == tyn) || (c3n == tel) ) { - return tyn; - } else { -#if 0 - u3_noun dun = u3qzu_dunq(van, "need", sut); - u3_noun niz = u3qzu_dunq(van, "have", ref); - - u3t_push(u3nc(c3__mean, dun)); - u3t_push(u3nc(c3__mean, niz)); -#endif - return u3m_error("nest-fail"); - } - } - - static u3_noun - _nest_dext(u3_noun van, - u3_noun sut, - u3_noun tel, - u3_noun ref, - u3_noun seg, - u3_noun reg, - u3_noun gil) - { - - if ( (c3y == u3r_sing(sut, ref)) ) { - return c3y; - } - - { - c3_m fun_m = 144 + c3__nest + ((!!u3r_at(u3qzu_van_vet, van)) << 8); - u3_noun pro = u3z_find_2(fun_m, sut, ref); - - if ( u3_none != pro ) { - return pro; - } - else { - pro = _nest_dext_to(van, sut, tel, ref, seg, reg, gil); - - if ( ((c3y == pro) && (u3_nul == reg)) || - ((c3n == pro) && (u3_nul == seg)) ) - { - return u3z_save_2(fun_m, sut, ref, pro); - } - else return pro; - } - } - } - - static u3_noun - _nest_sint(u3_noun van, - u3_noun sut, - u3_noun tel, - u3_noun ref, - u3_noun seg, - u3_noun reg, - u3_noun gil) - { - u3_noun p_ref, q_ref; - - if ( (c3n == u3du(ref)) ) { - switch ( ref ) { - default: return u3m_bail(c3__fail); - - case c3__noun: return c3n; - case c3__void: return c3y; - } - } - else { - switch ( u3h(ref) ) { - default: { - return u3m_bail(c3__fail); - } - case c3__atom: return c3n; - case c3__cell: return c3n; - case c3__core: { - u3_noun gam = u3qzu_repo(van, ref); - u3_noun hiv = _nest_dext(van, sut, tel, gam, seg, reg, gil); - - u3z(gam); - return hiv; - } - case c3__hint: - case c3__face: { - if ( c3n == u3r_trel(ref, 0, &p_ref, &q_ref) ) { - return u3m_bail(c3__fail); - } else { - return _nest_dext(van, sut, tel, q_ref, seg, reg, gil); - } - } - case c3__fork: p_ref = u3t(ref); - { - u3_noun dey = u3qdi_tap(p_ref); - u3_noun yed = dey; - - while ( u3_nul != yed ) { - if ( c3n == _nest_dext(van, sut, c3n, u3h(yed), seg, reg, gil) ) { - u3z(dey); - return c3n; - } else { - yed = u3t(yed); - } - } - u3z(dey); - return c3y; - } - case c3__hold: { - if ( c3y == u3qdi_has(reg, ref) ) { - return c3y; - } - { - u3_noun hud = u3nc(u3k(sut), u3k(ref)); - - if ( (c3y == u3qdi_has(gil, hud)) ) { - u3z(hud); - - return c3y; - } else { - u3_noun gur = u3qdi_put(reg, ref); - u3_noun zoc = u3qdi_put(gil, hud); - u3_noun gam = u3qzu_repo(van, ref); - - { - u3_noun hiv = _nest_dext(van, sut, tel, gam, seg, gur, zoc); - - u3z(hud); - u3z(gam); - u3z(zoc); - u3z(gur); - - return hiv; - } - } - } - } - } - } - } - - static u3_noun - _cqzu_nest(u3_noun van, - u3_noun sut, - u3_noun tel, - u3_noun ref) - { - return _nest_dext(van, sut, tel, ref, u3_nul, u3_nul, u3_nul); - } - -/* boilerplate -*/ - u3_noun - u3wzu_nest(u3_noun cor) - { - u3_noun sut, tel, ref, van; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &tel, - u3x_sam_3, &ref, - u3x_con, &van, - 0)) || - (c3n == u3ud(tel)) || (tel > 1) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_nest(van, sut, tel, ref); - } - } - - u3_noun - u3qzu_nest(u3_noun van, - u3_noun sut, - u3_noun tel, - u3_noun ref) - { -#if 1 - c3_m fun_m = 144 + c3__nest; - u3_noun vrf = u3r_at(u3qzu_van_vrf, van); - u3_noun pro = u3z_find_4(fun_m, vrf, sut, tel, ref); - - if ( u3_none != pro ) { - // u3t_heck(c3__good); - return pro; - } - else { - pro = _cqzu_nest(van, sut, tel, ref); - - // u3t_heck(c3__nest); - return u3z_save_4(fun_m, vrf, sut, tel, ref, pro); - } -#else - return _cqzu_nest(van, sut, tel, ref); -#endif - } - diff --git a/jets/z/ut_peek.c b/jets/z/ut_peek.c deleted file mode 100644 index 75db4fb37..000000000 --- a/jets/z/ut_peek.c +++ /dev/null @@ -1,216 +0,0 @@ -/* j/6/peek.c -** -*/ -#include "all.h" - - -/* logic -*/ - static u3_noun - _cqzu_peek(u3_noun, u3_noun, u3_noun, u3_atom); - - static u3_noun - _peek_in(u3_noun, u3_noun, u3_noun, u3_atom, u3_noun); - - static u3_noun - _peek_fork(u3_noun van, u3_noun p_sut, u3_noun way, u3_noun axe, u3_noun gil) - { - if ( u3_nul == p_sut ) { - return u3_nul; - } - else { - return u3nc(_peek_in(van, u3h(p_sut), way, axe, gil), - _peek_fork(van, u3t(p_sut), way, axe, gil)); - } - } - - static u3_noun - _peek_in(u3_noun van, - u3_noun sut, - u3_noun way, - u3_atom axe, - u3_noun gil) - { - u3_noun p_sut, q_sut; - u3_noun pro; - - if ( (c3n == u3du(sut)) ) switch ( sut ) { - default: return u3m_bail(c3__fail); - - case c3__noun: { - return c3__noun; - } - case c3__void: { - return c3__void; - } - } - else switch ( u3h(sut) ) { - default: return u3m_bail(c3__fail); - - case c3__atom: { - return c3__void; - } - case c3__cell: { - if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { - return u3m_bail(c3__fail); - } else { - u3_atom tip = u3qc_cap(axe); - u3_atom tap = u3qc_mas(axe); - - if ( 2 == tip ) { - pro = _cqzu_peek(van, p_sut, way, tap); - } - else { - pro = _cqzu_peek(van, q_sut, way, tap); - } - u3z(tap); - u3z(tip); - - return pro; - } - } - case c3__core: { - u3_noun pq_sut, qq_sut, rq_sut; - u3_noun ppq_sut, qpq_sut, rpq_sut; - u3_noun prq_sut, qrq_sut; - - if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) || - (c3n == u3r_trel(q_sut, &pq_sut, &qq_sut, &rq_sut)) || - (c3n == u3r_trel(pq_sut, &ppq_sut, &qpq_sut, &rpq_sut)) || - (c3n == u3r_cell(rq_sut, &prq_sut, &qrq_sut)) ) - { - return u3m_bail(c3__fail); - } else { - u3_atom now = u3qc_cap(axe); - u3_atom lat = u3qc_mas(axe); - - if ( 3 == now ) { - u3_noun pec = u3qzu_peel(van, sut, way, rpq_sut); - u3_noun sam = u3h(pec); - u3_noun con = u3t(pec); - - if ( c3y == c3a(sam, con) ) { - pro = _cqzu_peek(van, p_sut, way, lat); - } - else { - u3_noun typ; - - { - u3_noun hed, tal; - - if ( c3n == sam ) { - hed = c3__noun; - } else { - hed = _cqzu_peek(van, p_sut, way, 2); - } - - if ( c3n == con ) { - tal = c3__noun; - } else { - tal = _cqzu_peek(van, p_sut, way, 3); - } - - typ = u3qz_cell(hed, tal); - u3z(hed); - u3z(tal); - } - - pro = _cqzu_peek(van, typ, way, lat); - u3z(typ); - } - - u3z(pec); - } - else { - pro = c3__noun; - } - u3z(lat); - u3z(now); - - return pro; - } - } - case c3__hint: - case c3__face: { - if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { - return u3m_bail(c3__fail); - } else { - return _peek_in(van, q_sut, way, axe, gil); - } - } - case c3__fork: p_sut = u3t(sut); - { - u3_noun yed = u3qdi_tap(p_sut); - u3_noun ret = u3kf_fork(_peek_fork(van, yed, way, axe, gil)); - - u3z(yed); - return ret; - } - case c3__hold: { - if ( (c3y == u3qdi_has(gil, sut)) ) { - return c3__void; - } - else { - u3_noun zoc = u3qdi_put(gil, sut); - u3_noun fop = u3qzu_repo(van, sut); - u3_noun pro = _peek_in(van, fop, way, axe, zoc); - - u3z(fop); - u3z(zoc); - - return pro; - } - } - } - } - - static u3_noun - _cqzu_peek(u3_noun van, - u3_noun sut, - u3_noun way, - u3_atom axe) - { - if ( 1 == axe ) { - return u3k(sut); - } - else return _peek_in(van, sut, way, axe, u3_nul); - } - -/* boilerplate -*/ - u3_noun - u3wzu_peek(u3_noun cor) - { - u3_noun sut, way, axe, van; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &way, - u3x_sam_3, &axe, - u3x_con, &van, - 0)) || - (c3n == u3ud(axe)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_peek(van, sut, way, axe); - } - } - - u3_noun - u3qzu_peek(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun axe) - { - c3_m fun_m = 144 + c3__peek + ((!!u3r_at(u3qzu_van_vet, van)) << 8); - u3_noun pro = u3z_find_3(fun_m, sut, way, axe); - - if ( u3_none != pro ) { - return pro; - } - else { - pro = _cqzu_peek(van, sut, way, axe); - - return u3z_save_3(fun_m, sut, way, axe, pro); - } - } diff --git a/jets/z/ut_peel.c b/jets/z/ut_peel.c deleted file mode 100644 index 16cbad89c..000000000 --- a/jets/z/ut_peel.c +++ /dev/null @@ -1,55 +0,0 @@ -/* j/6/ut_peel.c -** -*/ -#include "all.h" - - -/* logic -*/ - u3_noun - _cqzu_peel(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun met) - { - if ( c3__gold == met ) { - return u3nc(c3y, c3y); - } - else switch ( way ) { - default: return u3m_bail(c3__fail); - - case c3__both: return u3nc(c3n, c3n); - case c3__free: return u3nc(c3y, c3y); - case c3__read: return u3nc(((met == c3__zinc) ? c3y : c3n), c3n); - case c3__rite: return u3nc(((met == c3__iron) ? c3y : c3n), c3n); - } - } - -/* boilerplate -*/ - u3_noun - u3wzu_peel(u3_noun cor) - { - u3_noun sut, way, met, van; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &way, - u3x_sam_3, &met, - u3x_con, &van, - 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_peel(van, sut, way, met); - } - } - - u3_noun - u3qzu_peel(u3_noun van, - u3_noun sut, - u3_noun way, - u3_noun met) - { - return _cqzu_peel(van, sut, way, met); - } - diff --git a/jets/z/ut_play.c b/jets/z/ut_play.c deleted file mode 100644 index 1b910cdb5..000000000 --- a/jets/z/ut_play.c +++ /dev/null @@ -1,592 +0,0 @@ -/* j/6/play.c -** -*/ -#include "all.h" - -/* logic -*/ -# define _play_used() - - static u3_noun - _play_in(u3_noun, u3_noun, u3_noun); - - static u3_noun - _play_bean() - { - return u3kf_fork(u3nt(u3nq(c3__atom, 'f', u3_nul, 0), - u3nq(c3__atom, 'f', u3_nul, 1), - u3_nul)); - } - - static u3_noun - _play_rock(u3_noun odo, u3_noun bob) - { - if ( c3y == u3ud(bob) ) { - return u3nq(c3__atom, u3k(odo), u3_nul, u3k(bob)); - } - else return u3nt(c3__cell, _play_rock(odo, u3h(bob)), - _play_rock(odo, u3t(bob))); - } - - static u3_noun - _play_sand(u3_noun odo, u3_noun bob) - { - if ( c3y == u3ud(bob) ) { - if ( 'n' == odo ) { - if ( (bob != 0) ) { - return u3m_bail(c3__exit); - } else { - return u3nq(c3__atom, odo, u3_nul, bob); - } - } - if ( 'f' == odo ) { - if ( (bob > 1) ) { - return u3m_bail(c3__exit); - } else { - return _play_bean(); - } - } - return u3nt(c3__atom, u3k(odo), u3_nul); - } - else return u3nt(c3__cell, _play_rock(odo, u3h(bob)), - _play_rock(odo, u3t(bob))); - } - - static u3_noun - _play_core(u3_noun pac, - u3_noun con) - { - if ( (c3__void == pac) ) { - u3z(con); - - return c3__void; - } else { - return u3nt(c3__core, pac, con); - } - } - - static u3_noun - _play_loc(u3_noun van, - u3_noun loc) - { - u3_noun mol = u3nc('o', u3k(loc)); - u3_noun sho = u3j_hook(u3k(van), "show"); - u3_noun ret = u3i_molt(u3k(sho), u3x_sam, u3k(mol), 0); - - u3z(mol); - u3z(sho); - - return ret; - } - - static u3_noun - _play_feel(u3_noun van, - u3_noun sut, - u3_noun rot) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "feel"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam, - u3k(rot), - 0)); - } - -#if 0 - static u3_noun - _play_loc_term(u3_noun van, - u3_noun loc) - { - u3_noun fop = u3kb_flop(u3k(u3h(loc))); - u3_noun nam = ((0 == fop) ? c3__none : u3k(u3h(fop))); - u3_noun lys = u3nt(u3k(u3h(u3t(loc))), u3k(u3t(u3t(loc))), u3_nul); - u3_noun rup = u3nc(nam, lys); - c3_c* pre_c = u3m_pretty(rup); - u3_noun pro = u3i_string(pre_c); - - u3z(fop); - u3z(rup); - free(pre_c); - - return pro; - } -#endif - -#if 1 - static u3_noun - _play_cnts(u3_noun van, - u3_noun sut, - u3_noun hyp, - u3_noun rig) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "epla"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam_2, - u3k(hyp), - u3x_sam_3, - u3k(rig), - 0)); - } -#else - static u3_noun - _play_edit(u3_noun van, - u3_noun sut, - u3_noun mew, - u3_noun rag) - { - while ( 1 ) { - if ( c3n == u3du(mew) ) { - return rag; - } else { - u3_noun i_mew = u3h(mew); - u3_noun t_mew = u3t(mew); - u3_noun pi_mew = u3h(i_mew); - u3_noun qi_mew = u3t(i_mew); - u3_noun laf = _play_in(van, sut, qi_mew); - u3_noun ruz = u3qzu_toss(van, sut, pi_mew, laf, rag); - - u3z(laf); - u3z(rag); - rag = u3k(u3t(ruz)); - u3z(ruz); - - mew = t_mew; - } - } - } - static u3_noun - _play_cnts_old(u3_noun van, - u3_noun sut, - u3_noun hyp, - u3_noun rig) - { - u3_noun lar = u3qzu_seek(van, sut, c3__read, hyp); - u3_noun q_lar = u3t(lar); - u3_noun qq_lar = u3t(q_lar); - u3_noun mew = rig; - u3_noun rag = _play_edit(van, sut, mew, u3k(qq_lar)); - u3_noun ret = u3qzu_fire(van, sut, rag); - - u3z(rag); - u3z(lar); - - return ret; - } -#endif - - static u3_noun - _play_grow(u3_noun van, - u3_noun sut, - u3_atom mel, - u3_noun ruf, - u3_noun dom) - { - u3_noun dan = _play_in(van, sut, ruf); - - return _play_core(dan, - u3nt(u3nt(u3_nul, c3__dry, u3k(mel)), - u3k(dan), - u3nc(u3nc(u3nc(c3__full, u3_nul), u3_nul), - u3k(dom)))); - } - - static u3_noun - _play_in(u3_noun van, - u3_noun sut, - u3_noun gen); - - static u3_noun - _play_x(u3_noun van, - u3_noun sut, - u3_noun gen) - { -#if 1 - return _play_in(van, sut, gen); -#else - u3_noun zix = u3qzu_shep - (van, "gene", 'q', u3k(gen)); - u3_noun ret; - - u3t_push(u3nc(c3__mean, zix)); - - ret = _play_in(van, sut, gen); - - u3t_drop(); - return ret; -#endif - } - - static u3_noun - _play_in(u3_noun van, - u3_noun sut, - u3_noun gen) - { - u3_noun p_gen, q_gen, r_gen; - - if ( c3n == u3du(gen) ) { - open: { - u3_noun ter = u3r_at(u3x_con_3, van); - u3_noun fab = u3r_at(u3qzu_van_fab, van); - u3_noun rex = u3qzp_open(ter, fab, gen); - u3_noun ret; - - if ( c3y == u3r_sing(rex, gen) ) { - u3_noun zix = u3qzu_shep(van, "gene", 'q', u3k(gen)); - - u3t_push(u3nc(c3__mean, zix)); - return u3m_error("play-open-z"); - } - ret = _play_x(van, sut, rex); - u3z(rex); - - return ret; - } - } - else if ( c3y == u3du(u3h(gen)) ) { - _play_used(); - { - u3_noun dis = _play_x(van, sut, u3h(gen)); - u3_noun dat = _play_x(van, sut, u3t(gen)); - u3_noun ret = u3qz_cell(dis, dat); - - u3z(dis); - u3z(dat); - return ret; - } - } - else switch ( u3h(gen) ) { - default: goto open; - - case c3__fits: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - return _play_bean(); - } - - case c3__wtcl: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen); - _play_used(); - { - u3_noun fex = u3qzu_gain(van, sut, p_gen); - u3_noun wux = u3qzu_lose(van, sut, p_gen); - u3_noun dez = (fex == c3__void) ? c3__void - : _play_x(van, fex, q_gen); - u3_noun doz = (wux == c3__void) ? c3__void - : _play_x(van, wux, r_gen); - u3_noun ret = u3qz_forq(dez, doz); - - u3z(dez); u3z(doz); - u3z(fex); u3z(wux); - return ret; - } - - case c3__clhp: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - u3_noun dis = _play_x(van, sut, p_gen); - u3_noun dat = _play_x(van, sut, q_gen); - u3_noun ret = u3qz_cell(dis, dat); - - u3z(dis); - u3z(dat); - return ret; - } - - case c3__dtkt: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - u3_noun nog = u3nc(c3__bcdt, u3k(p_gen)); - u3_noun ret = _play_x(van, sut, nog); - - u3z(nog); - return ret; - } - - case c3__dtwt: p_gen = u3t(gen); - _play_used(); - { - return _play_bean(); - } - - case c3__dtts: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - return _play_bean(); - } - - case c3__dtls: p_gen = u3t(gen); - _play_used(); - { - return u3nt(c3__atom, u3_blip, u3_nul); - } - - case c3__rock: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - return _play_rock(p_gen, q_gen); - } - - case c3__dttr: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - return c3__noun; - } - - case c3__sand: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - return _play_sand(p_gen, q_gen); - } - - case c3__hand: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - return u3k(p_gen); - } - - case c3__ktbr: p_gen = u3t(gen); - _play_used(); - { - u3_noun boc = _play_x(van, sut, p_gen); - u3_noun pro = u3qzu_wrap(van, boc, c3__iron); - - u3z(boc); - return pro; - } - - case c3__ktpm: p_gen = u3t(gen); - _play_used(); - { - u3_noun boc = _play_x(van, sut, p_gen); - u3_noun pro = u3qzu_wrap(van, boc, c3__zinc); - - u3z(boc); - return pro; - } - - case c3__ktwt: p_gen = u3t(gen); - _play_used(); - { - u3_noun boc = _play_x(van, sut, p_gen); - u3_noun pro = u3qzu_wrap(van, boc, c3__lead); - - u3z(boc); - return pro; - } - - case c3__note: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - u3_noun boc = _play_x(van, sut, q_gen); - u3_noun hit = u3nc(u3k(sut), u3k(p_gen)); - u3_noun ret = u3qz_hint(hit, boc); - - u3z(hit); - u3z(boc); - return ret; - } - - case c3__tune: p_gen = u3t(gen); - _play_used(); - { - return u3qz_face(p_gen, sut); - } - - case c3__ktsg: p_gen = u3t(gen); - _play_used(); - { - return _play_x(van, sut, p_gen); - } - - case c3__ktls: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - return _play_x(van, sut, p_gen); - } - - case c3__tsgr: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - u3_noun boc = _play_x(van, sut, p_gen); - u3_noun ret = _play_x(van, boc, q_gen); - - u3z(boc); - return ret; - } - - case c3__tscm: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - u3_noun boc = u3qzu_busk(van, sut, p_gen); - u3_noun ret = _play_x(van, boc, q_gen); - - u3z(boc); - return ret; - } - - case c3__cnts: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - return _play_cnts(van, sut, p_gen, q_gen); - } - - case c3__brcn: p_gen = u3t(gen); - _play_used(); - { - u3_noun ruf = u3nc(u3_nul, 1); - u3_noun ret = _play_grow(van, sut, c3__gold, ruf, p_gen); - - u3z(ruf); - return ret; - } - - case c3__sgzp: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - u3_noun typ = u3qzu_play(van, sut, p_gen); - u3_noun dug = u3qzu_duck(van, typ); - u3_noun ret; - - u3t_push(u3nc(c3__mean, dug)); - { - ret = _play_x(van, sut, q_gen); - } - u3t_drop(); - - u3z(typ); - return ret; - } - - case c3__sggr: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - return _play_x(van, sut, q_gen); - } - - case c3__zpts: p_gen = u3t(gen); - _play_used(); - { - return c3__noun; - } - - case c3__ktcn: p_gen = u3t(gen); - { - u3_noun von = u3i_molt(u3k(van), u3qzu_van_fab, c3n, 0); - u3_noun ret = _play_x(von, sut, p_gen); - - u3z(von); - return ret; - } - - case c3__zpcm: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - return _play_x(van, sut, p_gen); - } - - case c3__dbug: u3x_cell(u3t(gen), &p_gen, &q_gen); - { - u3_noun ret; - -#if 0 - { - u3_noun cog = _play_loc_term(van, p_gen); - - u3t_heck(cog); - u3z(cog); - } -#endif - u3t_push(u3nc(c3__mean, _play_loc(van, p_gen))); - { - ret = _play_x(van, sut, q_gen); - } - u3t_drop(); - return ret; - } - - case c3__zpmc: - case c3__zpsm: u3x_cell(u3t(gen), &p_gen, &q_gen); - _play_used(); - { - u3_noun zur = _play_x(van, sut, p_gen); - u3_noun vos = _play_x(van, sut, q_gen); - u3_noun ret = u3qz_cell(zur, vos); - - u3z(zur); - u3z(vos); - - return ret; - } - - case c3__zpvt: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen); - _play_used(); - { - if ( c3y == _play_feel(van, sut, p_gen) ) { - return _play_x(van, sut, q_gen); - } else { - return _play_x(van, sut, r_gen); - } - } - - case c3__lost: - case c3__fail: - case c3__zpzp: - _play_used(); - { - return c3__void; - } - } - } - - static u3_noun - _cqzu_play(u3_noun van, - u3_noun sut, - u3_noun gen) - { - u3_noun von = u3i_molt(u3k(van), u3qzu_van_vet, c3n, 0); - u3_noun ret = _play_x(von, sut, gen); - - u3z(von); - return ret; - } - -/* boilerplate -*/ - u3_noun - u3wzu_play(u3_noun cor) - { - u3_noun sut, gen, van; - - if ( (c3n == u3r_mean(cor, u3x_sam, &gen, u3x_con, &van, 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_play(van, sut, gen); - } - } - - u3_noun - u3qzu_play(u3_noun van, - u3_noun sut, - u3_noun gen) - { -#if 1 - c3_m fun_m = 144 + c3__play; - u3_noun vrf = u3r_at(u3qzu_van_vrf, van); - u3_noun pro = u3z_find_3(fun_m, vrf, sut, gen); - - if ( u3_none != pro ) { - return pro; - } - else { - pro = _cqzu_play(van, sut, gen); - - return u3z_save_3(fun_m, vrf, sut, gen, pro); - } -#else - return _cqzu_play(van, sut, gen); -#endif - } diff --git a/jets/z/ut_repo.c b/jets/z/ut_repo.c deleted file mode 100644 index 5b6f5faac..000000000 --- a/jets/z/ut_repo.c +++ /dev/null @@ -1,70 +0,0 @@ -/* j/6/ut_repo.c -** -*/ -#include "all.h" - - -/* logic -*/ - u3_noun - u3qzu_repo(u3_noun van, - u3_noun sut) - { - u3_noun p_sut, q_sut; - - if ( c3n == u3du(sut) ) switch ( sut ) { - default: return u3k(sut); - - case c3__noun: { - return u3kf_fork(u3nt(u3nt(c3__atom, u3_blip, u3_nul), - u3nt(c3__cell, c3__noun, c3__noun), - u3_nul)); - } - } - else switch ( u3h(sut) ) { - default: { - u3m_p("head", u3h(sut)); - return u3m_error("repo-flat"); - } - - case c3__core: { - if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut) ) { - return u3m_bail(c3__fail); - } else { - return u3nt(c3__cell, c3__noun, u3k(p_sut)); - } - } - case c3__hint: - case c3__face: { - if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut)) { - return u3m_bail(c3__fail); - } else { - return u3k(q_sut); - } - } - case c3__hold: { - if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut)) { - return u3m_bail(c3__fail); - } else { - u3_noun old = u3nc(u3nc(u3k(p_sut), u3k(q_sut)), u3_nul); - u3_noun ret; - - ret = u3qzu_rest(van, sut, old); - u3z(old); - return ret; - } - } - } - } - - u3_noun - u3wzu_repo(u3_noun cor) - { - u3_noun sut; - - if ( u3_none == (sut = u3r_at(u3x_sam, cor)) ) { - return u3m_bail(c3__fail); - } else { - return u3qzu_repo(cor, sut); - } - } diff --git a/jets/z/ut_rest.c b/jets/z/ut_rest.c deleted file mode 100644 index fc6dedbae..000000000 --- a/jets/z/ut_rest.c +++ /dev/null @@ -1,114 +0,0 @@ -/* j/6/ut_rest.c -** -*/ -#include "all.h" - - -/* logic -*/ - static u3_noun - _rest_in_list(u3_noun van, - u3_noun leg) - { - if ( u3_nul == leg ) { - return u3_nul; - } else { - u3_noun i_leg = u3h(leg); - u3_noun t_leg = u3t(leg); - - return u3nc(u3qzu_play(van, u3h(i_leg), u3t(i_leg)), - _rest_in_list(van, t_leg)); - } - } - - static u3_noun - _rest_in_stil(u3_noun van, - u3_noun gar) - { - u3_noun gun = u3qdi_gas(u3_nul, gar); - u3_noun yed = u3qdi_tap(gun); - - u3z(gun); - return yed; - } - - static u3_noun - _rest_in(u3_noun van, - u3_noun leg) - { - u3_noun gar = _rest_in_list(van, leg); - u3_noun yed = _rest_in_stil(van, gar); - u3_noun fub = u3qz_fork(yed); - - u3z(gar); - u3z(yed); - - return fub; - } - - static u3_noun - _rest_hit_fan(u3_noun fan, - u3_noun leg) - { - if ( u3_nul == leg ) { - return c3n; - } else { - return c3o(u3qdi_has(fan, u3h(leg)), - _rest_hit_fan(fan, u3t(leg))); - } - } - - static u3_noun - _cqzu_rest(u3_noun van, - u3_noun sut, - u3_noun leg) - { - u3_noun fan = u3r_at(u3qzu_van_fan, van); - - if ( c3y == _rest_hit_fan(fan, leg) ) { - return u3m_error("rest-loop"); - } - else { - u3_noun naf = u3qdi_gas(fan, leg); - u3_noun nav = u3i_molt(u3k(van), u3qzu_van_fan, u3k(naf), 0); - u3_noun mez = _rest_in(nav, leg); - - u3z(naf); - u3z(nav); - return mez; - } - } - -/* boilerplate -*/ - u3_noun - u3wzu_rest(u3_noun cor) - { - u3_noun sut, leg, van; - - if ( (c3n == u3r_mean(cor, u3x_sam, &leg, u3x_con, &van, 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_rest(van, sut, leg); - } - } - - u3_noun - u3qzu_rest(u3_noun van, - u3_noun sut, - u3_noun leg) - { - c3_m fun_m = 144 + c3__rest + ((!!u3r_at(u3qzu_van_vet, van)) << 8); - u3_noun pro = u3z_find_2(fun_m, sut, leg); - - if ( u3_none != pro ) { - return pro; - } - else { - pro = _cqzu_rest(van, sut, leg); - - return u3z_save_2(fun_m, sut, leg, pro); - } - } diff --git a/jets/z/ut_tack.c b/jets/z/ut_tack.c deleted file mode 100644 index dea0c04b5..000000000 --- a/jets/z/ut_tack.c +++ /dev/null @@ -1,21 +0,0 @@ -/* j/6/tack.c -** -*/ -#include "all.h" - - u3_noun - u3qzu_tack(u3_noun van, - u3_noun sut, - u3_noun hyp, - u3_noun mur) - { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "tack"); - - return u3n_kick_on(u3i_molt(gat, - u3x_sam_2, - u3k(hyp), - u3x_sam_3, - u3k(mur), - 0)); - } diff --git a/jets/z/ut_toss.c b/jets/z/ut_toss.c deleted file mode 100644 index bd4273da5..000000000 --- a/jets/z/ut_toss.c +++ /dev/null @@ -1,97 +0,0 @@ -/* j/6/toss.c -** -*/ -#include "all.h" - - -/* internals -*/ - static u3_noun - _toss_in(u3_noun van, - u3_noun sut, - u3_noun peh, - u3_noun mur, - u3_noun men) - { - if ( c3n == u3du(men) ) { - return u3nc(u3_nul, u3_nul); - } - else { - u3_noun i_men = u3h(men); - u3_noun pi_men = u3h(i_men); - u3_noun qi_men = u3t(i_men); - u3_noun t_men = u3t(men); - u3_noun geq = u3qzu_tack(van, pi_men, peh, mur); - u3_noun p_geq = u3h(geq); - u3_noun q_geq = u3t(geq); - u3_noun mox = _toss_in(van, sut, peh, mur, t_men); - u3_noun p_mox = u3h(mox); - u3_noun q_mox = u3t(mox); - u3_noun ret; - - ret = u3nc( - ( (u3_nul == p_mox) - ? u3nc(u3_nul, u3k(p_geq)) - : (c3n == u3r_sing(p_geq, u3t(p_mox))) - ? u3m_bail(c3__exit) - : u3k(p_mox) ), - u3nc(u3nc(u3k(q_geq), u3k(qi_men)), u3k(q_mox))); - - u3z(mox); - u3z(geq); - return ret; - } - } - -/* functions -*/ - u3_noun - _cqzu_toss(u3_noun van, - u3_noun sut, - u3_noun peh, - u3_noun mur, - u3_noun men) - { - u3_noun wib = _toss_in(van, sut, peh, mur, men); - u3_noun p_wib = u3h(wib); - u3_noun q_wib = u3t(wib); - - if ( u3_nul == p_wib ) { - return u3m_bail(c3__exit); - } else { - u3_noun ret = u3nc(u3k(u3t(p_wib)), u3k(q_wib)); - - u3z(wib); - return ret; - } - } - -/* boilerplate -*/ - u3_noun - u3wzu_toss(u3_noun cor) - { - u3_noun van, sut, peh, mur, men; - - if ( (c3n == u3r_mean(cor, u3x_sam_2, &peh, - u3x_sam_6, &mur, - u3x_sam_7, &men, - u3x_con, &van, - 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_toss(van, sut, peh, mur, men); - } - } - - u3_noun - u3qzu_toss(u3_noun van, - u3_noun sut, - u3_noun peh, - u3_noun mur, - u3_noun men) - { - return _cqzu_toss(van, sut, peh, mur, men); - } diff --git a/jets/z/ut_wrap.c b/jets/z/ut_wrap.c deleted file mode 100644 index 73c41f3e1..000000000 --- a/jets/z/ut_wrap.c +++ /dev/null @@ -1,96 +0,0 @@ -/* j/6/wrap.c -** -*/ -#include "all.h" - - static u3_noun _cqzu_wrap(u3_noun, u3_noun, u3_noun); - - static u3_noun - _wrap_fork(u3_noun van, u3_noun p_sut, u3_noun yoz) - { - if ( u3_nul == p_sut ) { - return u3_nul; - } - else { - return u3nc(_cqzu_wrap(van, u3h(p_sut), yoz), - _wrap_fork(van, u3t(p_sut), yoz)); - } - } - - static u3_noun - _cqzu_wrap(u3_noun van, - u3_noun sut, - u3_noun yoz) - { - u3_noun p_sut, q_sut; - - if ( c3n == u3du(sut) ) { - return u3m_error("wrap-type"); - } - else switch ( u3h(sut) ) { - default: return u3m_error("wrap-type"); - - case c3__core: u3x_cell(u3t(sut), &p_sut, &q_sut); - { - u3_noun pq_sut, qq_sut, rq_sut; - u3_noun ppq_sut, qpq_sut, rpq_sut; - - if ( c3n == u3r_trel(q_sut, &pq_sut, &qq_sut, &rq_sut) ) { - return u3m_bail(c3__fail); - } - if ( c3n == u3r_trel(pq_sut, &ppq_sut, &qpq_sut, &rpq_sut) ) { - return u3m_bail(c3__fail); - } - else if ( c3__gold != rpq_sut ) { - return u3m_error("wrap-gold"); - } - else { - return u3nt(c3__core, - u3k(p_sut), - u3nt(u3nt(u3k(ppq_sut), u3k(qpq_sut), u3k(yoz)), - u3k(qq_sut), - u3k(rq_sut))); - } - } - case c3__fork: p_sut = u3t(sut); - { - u3_noun yed = u3qdi_tap(p_sut); - u3_noun ret = u3kf_fork(_wrap_fork(van, yed, yoz)); - - u3z(yed); - return ret; - } - case c3__hold: - { - u3_noun fop = u3qzu_repo(van, sut); - u3_noun pro = _cqzu_wrap(van, fop, yoz); - - u3z(fop); - return pro; - } - } - } - -/* boilerplate -*/ - u3_noun - u3wzu_wrap(u3_noun cor) - { - u3_noun sut, yoz, van; - - if ( (c3n == u3r_mean(cor, u3x_sam, &yoz, u3x_con, &van, 0)) || - (u3_none == (sut = u3r_at(u3x_sam, van))) ) - { - return u3m_bail(c3__fail); - } else { - return _cqzu_wrap(van, sut, yoz); - } - } - - u3_noun - u3qzu_wrap(u3_noun van, - u3_noun sut, - u3_noun yoz) - { - return _cqzu_wrap(van, sut, yoz); - } diff --git a/meson.build b/meson.build index 1bb9c05f9..5a1ac36c1 100644 --- a/meson.build +++ b/meson.build @@ -178,47 +178,6 @@ jets_f_ut_src = [ 'jets/f/ut_wrap.c' ] -jets_z_src = [ -'jets/z/ap.c', -'jets/z/cell.c', -'jets/z/comb.c', -'jets/z/cons.c', -'jets/z/core.c', -'jets/z/face.c', -'jets/z/fitz.c', -'jets/z/flan.c', -'jets/z/flip.c', -'jets/z/flor.c', -'jets/z/fork.c', -'jets/z/hint.c', -'jets/z/hike.c', -'jets/z/look.c', -'jets/z/loot.c' -] - -jets_z_ut_src = [ -'jets/z/ut.c', -'jets/z/ut_buss.c', -'jets/z/ut_crop.c', -'jets/z/ut_find.c', -'jets/z/ut_fire.c', -'jets/z/ut_fish.c', -'jets/z/ut_fuse.c', -'jets/z/ut_gain.c', -'jets/z/ut_lose.c', -'jets/z/ut_mint.c', -'jets/z/ut_mull.c', -'jets/z/ut_nest.c', -'jets/z/ut_peek.c', -'jets/z/ut_peel.c', -'jets/z/ut_play.c', -'jets/z/ut_repo.c', -'jets/z/ut_rest.c', -'jets/z/ut_tack.c', -'jets/z/ut_toss.c', -'jets/z/ut_wrap.c' -] - jets_g_src = [ 'jets/g/down.c' ] @@ -232,7 +191,6 @@ jets_all_src = [ jets_c_src, jets_d_src, jets_e_src, jets_e_ed_src, jets_f_src, jets_f_ut_src, - jets_z_src, jets_z_ut_src, jets_g_src, jets_src] noun_src = [ From 2ea9cb52fe527a7622dc56ccebdc881ed35596e1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 15 Nov 2018 19:33:30 -0500 Subject: [PATCH 057/157] properly zero-initialize u3_wcon linked-list pointer --- vere/http.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vere/http.c b/vere/http.c index 3cd0a4c3a..d8a035f9d 100644 --- a/vere/http.c +++ b/vere/http.c @@ -2082,8 +2082,9 @@ static u3_wcon* _proxy_wcon_new(u3_ward* rev_u) { u3_wcon* won_u = c3_malloc(sizeof(*won_u)); - won_u->rev_u = rev_u; won_u->upt_u.data = won_u; + won_u->rev_u = rev_u; + won_u->nex_u = 0; _proxy_wcon_link(won_u, rev_u); From 3eccfae00a6df95699e763ebb09a0c08fcc9c682 Mon Sep 17 00:00:00 2001 From: Curtis Yarvin Date: Mon, 22 Oct 2018 12:46:27 -0700 Subject: [PATCH 058/157] Fix README build instructions --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 13a59fb09..2ea009481 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,12 @@ are included as git submodules. To build urbit from source, perform the followin 4. The executable should appear in `./build` directory. ### Using meson & ninja -To configure project, enter the build directory and enter -`meson configure`. Without any arguments this command will display available -options. For example, to compile debug build of urbit, use + +To configure the project, enter the build directory and enter +`meson configure -Dbuildtype=release`. To compile a debug build of urbit, use `meson configure -Dbuildtype=debug`. -To set the prefix for installation use -`meson configure -Dprefix=/usr`, and so on. +To set a prefix for installation use +`meson configure -Dprefix=/usr`. ## Configuration & compilation for legacy meson From 2cb3ad1a7a069eec7245fc746bd2fe06c036e246 Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Fri, 16 Nov 2018 11:56:58 -0800 Subject: [PATCH 059/157] Use Ed25519 u3a_malloc in the ed25519 jet. --- jets/e/ed_sign.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jets/e/ed_sign.c b/jets/e/ed_sign.c index 5724c6bb3..b87527666 100644 --- a/jets/e/ed_sign.c +++ b/jets/e/ed_sign.c @@ -27,14 +27,14 @@ memset(pub_y, 0, 64); memset(sec_y, 0, 64); - mes_y = malloc(mesm_w); + mes_y = u3a_malloc(mesm_w); u3r_bytes(0, mesm_w, mes_y, a); u3r_bytes(0, mess_w, sed_y, b); ed25519_create_keypair(pub_y, sec_y, sed_y); ed25519_sign(sig_y, mes_y, mesm_w, pub_y, sec_y); - free(mes_y); + u3a_free(mes_y); return u3i_bytes(64, sig_y); } From f87120095ab6b6b68aedb6f2a8e90c5b07863baf Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 15 Nov 2018 20:24:38 -0500 Subject: [PATCH 060/157] removes -M ("memory madness") --- include/vere/vere.h | 1 - vere/main.c | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 05506b86c..7518e7523 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -600,7 +600,6 @@ c3_o gab; // -g, run with garbage collector c3_o has; // -S, Skip battery hashes c3_o git; // -s, pill url from arvo git hash - c3_o mem; // -M, memory madness c3_o net; // -N, remote networking in -F mode c3_o nuu; // -c, new pier c3_o pro; // -P, profile diff --git a/vere/main.c b/vere/main.c index c96cf8fcf..9b9e05fe6 100644 --- a/vere/main.c +++ b/vere/main.c @@ -83,7 +83,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.git = c3n; u3_Host.ops_u.has = c3n; u3_Host.ops_u.net = c3n; - u3_Host.ops_u.mem = c3n; u3_Host.ops_u.nuu = c3n; u3_Host.ops_u.pro = c3n; u3_Host.ops_u.qui = c3n; @@ -92,12 +91,8 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:w:u:e:E:f:F:k:l:n:p:r:NabcdgqstvxMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:w:u:e:E:f:F:k:l:n:p:r:NabcdgqstvxPDXRS")) != -1 ) { switch ( ch_i ) { - case 'M': { - u3_Host.ops_u.mem = c3y; - break; - } case 'B': { u3_Host.ops_u.pil_c = strdup(optarg); break; @@ -377,7 +372,6 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-K stage Start at Hoon kernel version stage\n", "-k keys Private key file\n", "-l port Initial peer port\n", - "-M Memory madness\n", "-n host Set unix hostname\n", "-N Enable networking in fake mode (-F)\n", "-p ames_port Set the ames port to bind to\n", From 0148b101e7d9f0c48422c4c419629c441027a427 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 15 Nov 2018 20:27:15 -0500 Subject: [PATCH 061/157] removes -X ("skip last event") --- include/vere/vere.h | 1 - vere/main.c | 8 +------- vere/sist.c | 4 ---- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 7518e7523..3bba22eb6 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -596,7 +596,6 @@ c3_o etn; // -t, use snapshot exclusively to boot c3_c* ets_c; // -E, eth snapshot c3_c* fak_c; // -F, fake ship - c3_o fog; // -X, skip last event c3_o gab; // -g, run with garbage collector c3_o has; // -S, Skip battery hashes c3_o git; // -s, pill url from arvo git hash diff --git a/vere/main.c b/vere/main.c index 9b9e05fe6..c885151b1 100644 --- a/vere/main.c +++ b/vere/main.c @@ -78,7 +78,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.dem = c3n; u3_Host.ops_u.dry = c3n; u3_Host.ops_u.etn = c3n; - u3_Host.ops_u.fog = c3n; u3_Host.ops_u.gab = c3n; u3_Host.ops_u.git = c3n; u3_Host.ops_u.has = c3n; @@ -91,7 +90,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:w:u:e:E:f:F:k:l:n:p:r:NabcdgqstvxPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:w:u:e:E:f:F:k:l:n:p:r:NabcdgqstvxPDRS")) != -1 ) { switch ( ch_i ) { case 'B': { u3_Host.ops_u.pil_c = strdup(optarg); @@ -134,10 +133,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.tex = c3y; break; } - case 'X': { - u3_Host.ops_u.fog = c3y; - break; - } case 'f': { if ( c3n == _main_readw(optarg, 100, &u3_Host.ops_u.fuz_w) ) { return c3n; @@ -385,7 +380,6 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-v Verbose\n", "-w name Boot as ~name\n", "-x Exit immediately\n", - "-Xwtf Skip last event\n", "\n", "Development Usage:\n", " To create a development ship, use a fakezod:\n", diff --git a/vere/sist.c b/vere/sist.c index 9163dcd49..6116f5151 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1026,10 +1026,6 @@ _sist_rest() { fprintf(stderr, "replay: skipped veer\n"); } - else if ( c3y == u3_Host.ops_u.fog && - u3_nul == t_roe ) { - fprintf(stderr, "replay: -Xwtf, skipped last event\n"); - } else { _sist_sing(u3k(ovo)); fputc('.', stderr); From 3edcd47b7c4be25a0f505ef61cc4491b0adedbf5 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 15 Nov 2018 20:33:08 -0500 Subject: [PATCH 062/157] removes the option to set -l, -n, and -r (raft options) --- vere/main.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/vere/main.c b/vere/main.c index c885151b1..1a0a50719 100644 --- a/vere/main.c +++ b/vere/main.c @@ -90,7 +90,11 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:w:u:e:E:f:F:k:l:n:p:r:NabcdgqstvxPDRS")) != -1 ) { + u3_Host.ops_u.rop_s = 0; + u3_Host.ops_u.raf_c = 0; + u3_Host.ops_u.nam_c = 0; + + while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:w:u:e:E:f:F:k:p:NabcdgqstvxPDRS")) != -1 ) { switch ( ch_i ) { case 'B': { u3_Host.ops_u.pil_c = strdup(optarg); @@ -149,26 +153,12 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.key_c = strdup(optarg); break; } - case 'l': { - if ( c3n == _main_readw(optarg, 65536, &arg_w) ) { - return c3n; - } else u3_Host.ops_u.rop_s = arg_w; - break; - } - case 'n': { - u3_Host.ops_u.nam_c = strdup(optarg); - break; - } case 'p': { if ( c3n == _main_readw(optarg, 65536, &arg_w) ) { return c3n; } else u3_Host.ops_u.por_s = arg_w; break; } - case 'r': { - u3_Host.ops_u.raf_c = strdup(optarg); - break; - } case 'R': { u3_Host.ops_u.rep = c3y; return c3y; @@ -248,11 +238,6 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } - if ( u3_Host.ops_u.rop_s == 0 && u3_Host.ops_u.raf_c != 0 ) { - fprintf(stderr, "The -r flag requires -l.\n"); - return c3n; - } - if ( c3y == u3_Host.ops_u.bat ) { u3_Host.ops_u.dem = c3y; u3_Host.ops_u.nuu = c3y; @@ -366,13 +351,10 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-g Set GC flag\n", "-K stage Start at Hoon kernel version stage\n", "-k keys Private key file\n", - "-l port Initial peer port\n", - "-n host Set unix hostname\n", "-N Enable networking in fake mode (-F)\n", "-p ames_port Set the ames port to bind to\n", "-P Profiling\n", "-q Quiet\n", - "-r host Initial peer address\n", "-R Report urbit build info\n", "-s Pill URL from arvo git hash\n", "-S Disable battery hashing\n", From eaab7dda8f76ba55209257c9e57da7b4b505f5cf Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 16 Nov 2018 11:49:55 -0500 Subject: [PATCH 063/157] replaces -N (enable fake networking) with -L (disable networking) --- include/vere/vere.h | 2 +- vere/main.c | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 3bba22eb6..1bbf75ba3 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -599,7 +599,7 @@ c3_o gab; // -g, run with garbage collector c3_o has; // -S, Skip battery hashes c3_o git; // -s, pill url from arvo git hash - c3_o net; // -N, remote networking in -F mode + c3_o net; // -L, local networking only c3_o nuu; // -c, new pier c3_o pro; // -P, profile c3_o qui; // -q, quiet diff --git a/vere/main.c b/vere/main.c index 1a0a50719..0b2d7113e 100644 --- a/vere/main.c +++ b/vere/main.c @@ -81,7 +81,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.gab = c3n; u3_Host.ops_u.git = c3n; u3_Host.ops_u.has = c3n; - u3_Host.ops_u.net = c3n; + u3_Host.ops_u.net = c3y; u3_Host.ops_u.nuu = c3n; u3_Host.ops_u.pro = c3n; u3_Host.ops_u.qui = c3n; @@ -94,7 +94,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.raf_c = 0; u3_Host.ops_u.nam_c = 0; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:w:u:e:E:f:F:k:p:NabcdgqstvxPDRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:w:u:e:E:f:F:k:p:LabcdgqstvxPDRS")) != -1 ) { switch ( ch_i ) { case 'B': { u3_Host.ops_u.pil_c = strdup(optarg); @@ -163,7 +163,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.rep = c3y; return c3y; } - case 'N': { u3_Host.ops_u.net = c3y; break; } + case 'L': { u3_Host.ops_u.net = c3n; break; } case 'a': { u3_Host.ops_u.abo = c3y; break; } case 'b': { u3_Host.ops_u.bat = c3y; break; } case 'c': { u3_Host.ops_u.nuu = c3y; break; } @@ -198,16 +198,9 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } - // XX revisit - if ( (0 == u3_Host.ops_u.fak_c) && (c3y == u3_Host.ops_u.net) ) { - // fprintf(stderr, "-N only makes sense with -F\n"); - u3_Host.ops_u.net = c3n; - } else if ( (0 == u3_Host.ops_u.fak_c) && (c3n == u3_Host.ops_u.net) ) { - u3_Host.ops_u.net = c3y; /* remote networking is always on in real mode. */ - } - if ( 0 != u3_Host.ops_u.fak_c ) { u3_Host.ops_u.has = c3y; /* no battery hashing on fake ships. */ + u3_Host.ops_u.net = c3n; /* no networking on fake ships. */ } if ( u3_Host.ops_u.arv_c != 0 && !imp_t ) { @@ -351,7 +344,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-g Set GC flag\n", "-K stage Start at Hoon kernel version stage\n", "-k keys Private key file\n", - "-N Enable networking in fake mode (-F)\n", + "-L local networking only\n", "-p ames_port Set the ames port to bind to\n", "-P Profiling\n", "-q Quiet\n", From 80b1d34aa633683bf86a0009b3c92e32a602cd0e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 16 Nov 2018 12:03:08 -0500 Subject: [PATCH 064/157] alphabetizes u3_opts and usage instructions --- include/vere/vere.h | 48 ++++++++++++++++++++++----------------------- vere/main.c | 8 ++++---- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 1bbf75ba3..b9bb5f533 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -580,37 +580,37 @@ */ typedef struct _u3_opts { c3_c* arv_c; // -A, initial sync from - c3_c* dns_c; // -H, ames bootstrap domain - c3_c* gen_c; // -G, czar generator - c3_c* nam_c; // -n, unix hostname + c3_o abo; // -a, abort aggressively c3_c* pil_c; // -B, bootstrap from - c3_c* raf_c; // -r, raft flotilla - c3_c* url_c; // -u, pill url - c3_c* who_c; // -w, begin with ticket - c3_c* key_c; // -K, private key file - c3_o abo; // -a c3_o bat; // -b, batch create - c3_o dem; // -d, daemon - c3_o dry; // -D, dry compute - c3_c* eth_c; // -e, ethereum node url - c3_o etn; // -t, use snapshot exclusively to boot - c3_c* ets_c; // -E, eth snapshot - c3_c* fak_c; // -F, fake ship - c3_o gab; // -g, run with garbage collector - c3_o has; // -S, Skip battery hashes - c3_o git; // -s, pill url from arvo git hash - c3_o net; // -L, local networking only c3_o nuu; // -c, new pier + c3_o dry; // -D, dry compute, no checkpoint + c3_o dem; // -d, daemon + c3_c* ets_c; // -E, eth snapshot + c3_c* eth_c; // -e, ethereum node url + c3_c* fak_c; // -F, fake ship + c3_w fuz_w; // -f, fuzz testing + c3_c* gen_c; // -G, czar generator + c3_o gab; // -g, test garbage collection + c3_c* dns_c; // -H, ames bootstrap domain + c3_w kno_w; // -K, kernel version + c3_c* key_c; // -k, private key file + c3_o net; // -L, local-only networking + c3_s rop_s; // -l, raft port + c3_c* nam_c; // -n, unix hostname c3_o pro; // -P, profile + c3_s por_s; // -p, ames port c3_o qui; // -q, quiet c3_o rep; // -R, report build info - c3_o tex; // -x, exit after loading - c3_o veb; // -v, verbose (inverse of -q) + c3_c* raf_c; // -r, raft flotilla + c3_o has; // -S, Skip battery hashes + c3_o git; // -s, pill url from arvo git hash + c3_o etn; // -t, use snapshot exclusively to boot + c3_c* url_c; // -u, pill url c3_o vno; // -V, replay without reboots - c3_s por_s; // -p, ames port - c3_s rop_s; // -l, raft port - c3_w fuz_w; // -f, fuzz testing - c3_w kno_w; // -k, kernel version + c3_o veb; // -v, verbose (inverse of -q) + c3_c* who_c; // -w, begin with ticket + c3_o tex; // -x, exit after loading } u3_opts; /* u3_host: entire host. diff --git a/vere/main.c b/vere/main.c index 0b2d7113e..2c6fd9bad 100644 --- a/vere/main.c +++ b/vere/main.c @@ -333,11 +333,11 @@ u3_ve_usage(c3_i argc, c3_c** argv) "without the leading '~', and options is some subset of the following:\n", "\n", "-A dir Use dir for initial galaxy sync\n", - "-b Batch create\n", "-B pill Bootstrap from this pill\n", + "-b Batch create\n", "-c pier Create a new urbit in pier/\n", - "-d Daemon mode\n", "-D Recompute from events\n", + "-d Daemon mode\n", "-e url Ethereum gateway\n", "-F ship Fake keys; also disables networking\n", "-f Fuzz testing\n", @@ -345,12 +345,12 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-K stage Start at Hoon kernel version stage\n", "-k keys Private key file\n", "-L local networking only\n", - "-p ames_port Set the ames port to bind to\n", "-P Profiling\n", + "-p ames_port Set the ames port to bind to\n", "-q Quiet\n", "-R Report urbit build info\n", - "-s Pill URL from arvo git hash\n", "-S Disable battery hashing\n", + "-s Pill URL from arvo git hash\n", "-u url URL from which to download pill\n", "-v Verbose\n", "-w name Boot as ~name\n", From 42c61039a49049333419a9a0fa28dfe7bceb3b19 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 16 Nov 2018 19:44:47 -0500 Subject: [PATCH 065/157] refines -F argument handling --- vere/main.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/vere/main.c b/vere/main.c index 2c6fd9bad..0ae11fca2 100644 --- a/vere/main.c +++ b/vere/main.c @@ -189,20 +189,13 @@ _main_getopt(c3_i argc, c3_c** argv) } u3_Host.ops_u.who_c = strdup(u3_Host.ops_u.fak_c); + u3_Host.ops_u.has = c3y; /* no battery hashing on fake ships. */ + u3_Host.ops_u.net = c3n; /* no networking on fake ships. */ + u3_Host.ops_u.nuu = c3y; } c3_t imp_t = ( (0 != u3_Host.ops_u.who_c) && (4 == strlen(u3_Host.ops_u.who_c)) ); - if ( (0 != u3_Host.ops_u.fak_c) && (c3n == u3_Host.ops_u.nuu) ) { - fprintf(stderr, "-F only makes sense on initial boot\n"); - return c3n; - } - - if ( 0 != u3_Host.ops_u.fak_c ) { - u3_Host.ops_u.has = c3y; /* no battery hashing on fake ships. */ - u3_Host.ops_u.net = c3n; /* no networking on fake ships. */ - } - if ( u3_Host.ops_u.arv_c != 0 && !imp_t ) { fprintf(stderr, "-A only makes sense when creating a new galaxy\n"); return c3n; From 9104ad2acb1306e683c0ff790fa21cb6b530ab0f Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 20 Nov 2018 11:40:11 -0800 Subject: [PATCH 066/157] reap call sites before reaping the warm dashboard if the warm dashboard is reaped before call sites, the activation (and thus the label inside the activation) can be freed (during u3h_put) while a call site in the junior still points to the label (but doesn't hold a reference to it, since it is on a senior road). trying to take that label during call site reap then results in a bail: foul. the solution is to always reap call sites before reaping the warm dashboard. --- noun/jets.c | 5 ++++- noun/manage.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index e17cf6006..8e37f8d4e 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1996,8 +1996,11 @@ void u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p, u3p(u3h_root) han_p, u3p(u3h_root) bas_p) { u3h_walk(cod_p, _cj_cold_reap); - u3h_walk(war_p, _cj_warm_reap); + + // call sites must be reaped before the warm dashboard, because they may + // contain references to labels on this road u3h_walk(han_p, _cj_hank_reap); + u3h_walk(war_p, _cj_warm_reap); u3h_walk(bas_p, _cj_bash_reap); } diff --git a/noun/manage.c b/noun/manage.c index 5f6d4dabd..3e30b75be 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -830,8 +830,9 @@ u3m_love(u3_noun pro) pro = u3a_take(pro); - u3j_reap(cod_p, war_p, han_p, bas_p); + // call sites first: see u3j_reap(). u3n_reap(byc_p); + u3j_reap(cod_p, war_p, han_p, bas_p); u3R->cap_p = u3R->ear_p; u3R->ear_p = 0; From 356f9fc9ac24f3b93db8d73a35e763f800aa9d2a Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 23 Nov 2018 13:05:39 -0800 Subject: [PATCH 067/157] Shrink preallocation of cells from 262.144 cells to 4.096 Everytime a new road is constructed, a new bank of cells is allocated and initialized. This lead to over three megabytes of memory being allocated and accessed on each road change. This takes more than 1ms to complete. Road changes occur on each virtualization call. Each +soft happens virtualized; so each +soft call incurs a 1ms delay. The metavase machinery does at least two (and usually three) softs per card move meaning sending a card move through arvo usually incurs a 3ms delay. Before this patch, the following line took six seconds to execute. Now it is imperceivable: ``` ~:(turn (gulf 0 10.000) |=(a=@ud (mule |.(a)))) ``` --- noun/allocate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noun/allocate.c b/noun/allocate.c index 80182910b..7f2272439 100644 --- a/noun/allocate.c +++ b/noun/allocate.c @@ -772,7 +772,7 @@ u3a_celloc(void) return u3a_walloc(c3_wiseof(u3a_cell)); } else { - if ( c3n == u3a_cellblock(256 << 10) ) { + if ( c3n == u3a_cellblock(4096) ) { return u3a_walloc(c3_wiseof(u3a_cell)); } cel_p = u3R->all.cel_p; From a9c8615674665ca431954510d42837df843f1ef2 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 26 Nov 2018 03:07:40 -0500 Subject: [PATCH 068/157] removes %ames timer and disables u3v_keep polling --- include/vere/vere.h | 1 - vere/ames.c | 54 --------------------------------------------- 2 files changed, 55 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index b9bb5f533..70a22d5e6 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -253,7 +253,6 @@ uv_udp_t wax_u; uv_handle_t had_u; }; - uv_timer_t tim_u; // network timer c3_o liv; // listener on c3_o alm; // alarm on c3_w law_w; // last wakeup, unix time diff --git a/vere/ames.c b/vere/ames.c index 72063ecde..72e069755 100644 --- a/vere/ames.c +++ b/vere/ames.c @@ -324,30 +324,6 @@ u3_ames_ef_send(u3_noun lan, u3_noun pac) u3z(lan); u3z(pac); } -/* _ames_time_cb(): timer callback. -*/ -static void -_ames_time_cb(uv_timer_t* tim_uo) -{ - u3_ames* sam_u = &u3_Host.sam_u; - - // defer until started via u3_ames_ef_turf() - if ( c3n == sam_u->liv ) { - uv_timer_start(&sam_u->tim_u, _ames_time_cb, 1000, 0); - } - else { - u3_lo_open(); - - sam_u->law_w = time(0); - { - u3v_plan - (u3nt(u3_blip, c3__ames, u3_nul), - u3nc(c3__wake, u3_nul)); - } - u3_lo_shut(c3n); - } -} - /* _ames_recv_cb(): receive callback. */ static void @@ -545,7 +521,6 @@ u3_ames_io_init() { u3_ames* sam_u = &u3_Host.sam_u; sam_u->liv = c3n; - uv_timer_init(u3L, &sam_u->tim_u); } /* u3_ames_io_talk(): start receiving ames traffic. @@ -562,8 +537,6 @@ u3_ames_io_exit() { u3_ames* sam_u = &u3_Host.sam_u; - uv_close((uv_handle_t*)&sam_u->tim_u, 0); - if ( c3y == sam_u->liv ) { // XX remove had_u/wax_u union, cast and close wax_u uv_close(&sam_u->had_u, 0); @@ -575,31 +548,4 @@ u3_ames_io_exit() void u3_ames_io_poll() { - u3_ames* sam_u = &u3_Host.sam_u; - u3_noun wen = u3v_keep(u3nt(u3_blip, c3__ames, u3_nul)); - - if ( (u3_nul != wen) && - (c3y == u3du(wen)) && - (c3y == u3ud(u3t(wen))) ) - { - c3_d gap_d = u3_time_gap_ms(u3k(u3A->now), u3k(u3t(wen))); - c3_w lem_w = (time(0) - sam_u->law_w); - c3_w lef_w = (lem_w > 32) ? 0 : (32 - lem_w); - - gap_d = c3_min(gap_d, (c3_d)(1000 * lef_w)); - - if ( c3y == sam_u->alm ) { - uv_timer_stop(&sam_u->tim_u); - } - else sam_u->alm = c3y; - - uv_timer_start(&sam_u->tim_u, _ames_time_cb, gap_d, 0); - } - else { - if ( c3y == sam_u->alm ) { - uv_timer_stop(&sam_u->tim_u); - } - sam_u->alm = c3n; - } - u3z(wen); } From a77f6401a7c0baed78c84bd1b606ab394dd3f4a2 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 26 Nov 2018 02:52:53 -0500 Subject: [PATCH 069/157] updates %behn to use effects instead of u3v_keep polling --- include/c/motes.h | 1 + include/vere/vere.h | 9 +++++++++ vere/behn.c | 45 ++++++++++++++++++++++++++++----------------- vere/loop.c | 1 + vere/reck.c | 20 ++++++++++++++++++++ vere/sist.c | 3 +++ 6 files changed, 62 insertions(+), 17 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index d8866557d..f05f716ba 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -325,6 +325,7 @@ # define c3__dorn c3_s4('d','o','r','n') # define c3__dost c3_s4('d','o','s','t') # define c3__dot c3_s3('d','o','t') +# define c3__doze c3_s4('d','o','z','e') # define c3__drag c3_s4('d','r','a','g') # define c3__draz c3_s4('d','r','a','z') # define c3__drib c3_s4('d','r','i','b') diff --git a/include/vere/vere.h b/include/vere/vere.h index 70a22d5e6..83fc4a83c 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -1061,6 +1061,15 @@ void u2_behn_io_poll(void); + /* u3_behn_ef_bake(): notify %behn that we're live + */ + void + u3_behn_ef_bake(void); + + /* u3_behn_ef_doze(): set or cancel timer + */ + void + u3_behn_ef_doze(u3_noun wen); /** HTTP server. **/ diff --git a/vere/behn.c b/vere/behn.c index 04d1989a2..9c6ec613d 100644 --- a/vere/behn.c +++ b/vere/behn.c @@ -45,6 +45,9 @@ static void _behn_time_cb(uv_timer_t* tim_u) { u3_behn* teh_u = &u3_Host.teh_u; + + // XX remove timer backoff + // if(teh_u->run_w < 1024) { teh_u->run_w++; } @@ -62,34 +65,42 @@ _behn_time_cb(uv_timer_t* tim_u) */ void u3_behn_io_poll(void) +{ +} + +/* u3_behn_ef_doze(): set or cancel timer +*/ +void +u3_behn_ef_doze(u3_noun wen) { u3_behn* teh_u = &u3_Host.teh_u; - u3_noun wen = u3v_keep(u3nt(u3_blip, c3__behn, u3_nul)); + + if ( c3y == teh_u->alm ) { + uv_timer_stop(&teh_u->tim_u); + teh_u->alm = c3n; + } if ( (u3_nul != wen) && (c3y == u3du(wen)) && (c3y == u3ud(u3t(wen))) ) { c3_d gap_d = u3_time_gap_ms(u3k(u3A->now), u3k(u3t(wen))); - -#if 0 - fprintf(stderr, "gap_d %llu, plus %llu\r\n", - gap_d, gap_d + (c3_d)teh_u->run_w); -#endif + // XX remove timer backoff + // gap_d += teh_u->run_w; - if ( c3y == teh_u->alm ) { - uv_timer_stop(&teh_u->tim_u); - } - else teh_u->alm = c3y; - uv_timer_start(&teh_u->tim_u, _behn_time_cb, gap_d, 0); } - else { - if ( c3y == teh_u->alm ) { - uv_timer_stop(&teh_u->tim_u); - } - teh_u->alm = c3n; - } + u3z(wen); } + +/* u3_behn_ef_bake(): notify %behn that we're live +*/ +void +u3_behn_ef_bake(void) +{ + u3_noun pax = u3nq(u3_blip, c3__behn, u3k(u3A->sen), u3_nul); + + u3v_plan(pax, u3nc(c3__born, u3_nul)); +} diff --git a/vere/loop.c b/vere/loop.c index 130ee87fa..8f6435d20 100644 --- a/vere/loop.c +++ b/vere/loop.c @@ -669,6 +669,7 @@ u3_lo_lead(void) { if ( c3n == u3_Host.ops_u.nuu ) { u3_ames_ef_bake(); + u3_behn_ef_bake(); } u3_http_ef_bake(); diff --git a/vere/reck.c b/vere/reck.c index 28dba1988..4a4727081 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -166,6 +166,22 @@ _reck_kick_http(u3_noun pox, c3_assert(!"not reached"); return c3n; } +/* _reck_kick_behn(): apply packet network outputs. +*/ +static u3_noun +_reck_kick_behn(u3_noun pox, u3_noun fav) +{ + switch ( u3h(fav) ) { + default: break; + + case c3__doze: { + u3_behn_ef_doze(u3k(u3t(fav))); + u3z(pox); u3z(fav); return c3y; + } break; + } + u3z(pox); u3z(fav); return c3n; +} + /* _reck_kick_sync(): apply sync outputs. */ static u3_noun @@ -277,6 +293,10 @@ _reck_kick_spec(u3_noun pox, u3_noun fav) return _reck_kick_http(pox, sev_l, coq_l, seq_l, fav); } break; + case c3__behn: { + return _reck_kick_behn(pox, fav); + } break; + case c3__clay: case c3__boat: case c3__sync: { diff --git a/vere/sist.c b/vere/sist.c index 6116f5151..a03fdcfa3 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1687,6 +1687,9 @@ u3_sist_boot(void) u3_ames_ef_bake(); } + // initialize %behn + u3_behn_ef_bake(); + // Authenticate and initialize terminal. u3_term_ef_bake(pig); From c3555c25a920727306f885fe616a51cb37c4adc1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 26 Nov 2018 03:03:03 -0500 Subject: [PATCH 070/157] increases %behn timer accuracy --- vere/behn.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vere/behn.c b/vere/behn.c index 9c6ec613d..e249fcfc0 100644 --- a/vere/behn.c +++ b/vere/behn.c @@ -84,7 +84,11 @@ u3_behn_ef_doze(u3_noun wen) (c3y == u3du(wen)) && (c3y == u3ud(u3t(wen))) ) { - c3_d gap_d = u3_time_gap_ms(u3k(u3A->now), u3k(u3t(wen))); + struct timeval tim_tv; + gettimeofday(&tim_tv, 0); + + u3_noun now = u3_time_in_tv(&tim_tv); + c3_d gap_d = u3_time_gap_ms(now, u3k(u3t(wen))); // XX remove timer backoff // gap_d += teh_u->run_w; From 0c33960a66a4109c5d4022daa2a16df12dfd972c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 26 Nov 2018 12:06:11 -0500 Subject: [PATCH 071/157] [CI] updates pinned arvo commit --- .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 af9da13e8..9d43e70d0 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -97b340675934ce196878a569d4fa1b78e26a0d33 +e661d55e491bbb28a2f7272bd1ab244f34a8ee17 From 9121e108abd9419511e92bd1fb8ffd6d2f7dd25b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 26 Nov 2018 12:22:13 -0500 Subject: [PATCH 072/157] removes %behn timer backoff --- include/vere/vere.h | 1 - vere/behn.c | 10 +--------- vere/raft.c | 6 ------ 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 83fc4a83c..38056d12f 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -433,7 +433,6 @@ */ typedef struct _u3_behn { uv_timer_t tim_u; // behn timer - c3_w run_w; // run of consecutive alarms c3_o alm; // alarm } u3_behn; diff --git a/vere/behn.c b/vere/behn.c index e249fcfc0..605d2347e 100644 --- a/vere/behn.c +++ b/vere/behn.c @@ -45,12 +45,7 @@ static void _behn_time_cb(uv_timer_t* tim_u) { u3_behn* teh_u = &u3_Host.teh_u; - - // XX remove timer backoff - // - if(teh_u->run_w < 1024) { - teh_u->run_w++; - } + teh_u->alm = c3n; u3_lo_open(); { @@ -89,9 +84,6 @@ 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))); - // XX remove timer backoff - // - gap_d += teh_u->run_w; uv_timer_start(&teh_u->tim_u, _behn_time_cb, gap_d, 0); } diff --git a/vere/raft.c b/vere/raft.c index 6f66b31b0..8452102a8 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1559,12 +1559,6 @@ _raft_punk(u3_noun ovo) sec_w = 0; } else sec_w = 600; - // Control alarm loops. - // - if ( c3__wake != u3h(u3t(ovo)) ) { - u3_Host.teh_u.run_w = 0; - } - #ifdef GHETTO struct timeval b4, f2, d0; gettimeofday(&b4, 0); From 1774725e4c51bc6b0bd8300fd5c0af5574c82130 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 26 Nov 2018 16:29:38 -0500 Subject: [PATCH 073/157] removes i/o polling --- include/vere/vere.h | 54 --------------------------------------------- vere/ames.c | 7 ------ vere/behn.c | 7 ------ vere/cttp.c | 7 ------ vere/http.c | 7 ------ vere/loop.c | 38 ------------------------------- vere/save.c | 7 ------ vere/term.c | 5 ----- vere/unix.c | 7 ------ 9 files changed, 139 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 38056d12f..4e59a01e8 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -902,11 +902,6 @@ void u3_term_io_exit(void); - /* u3_term_io_poll(): update terminal IO state. - */ - void - u3_term_io_poll(void); - /* u3_term_io_hija(): hijack console for cooked print. */ FILE* @@ -958,11 +953,6 @@ void u3_ames_io_exit(void); - /* u3_ames_io_poll(): update ames IO state. - */ - void - u3_ames_io_poll(void); - /** Autosave. **/ /* u3_save_ef_chld(): report SIGCHLD. @@ -980,11 +970,6 @@ void u3_save_io_exit(void); - /* u3_save_io_poll(): update autosave state. - */ - void - u3_save_io_poll(void); - /** Storage, new school. **/ /* u3_unix_ef_hold(): @@ -1037,12 +1022,6 @@ void u3_unix_io_exit(void); - /* u3_unix_io_poll(): update storage state. - */ - void - u3_unix_io_poll(void); - - /** behn, just a timer. **/ /* u2_behn_io_init(): initialize behn timer. @@ -1055,11 +1034,6 @@ void u2_behn_io_exit(void); - /* u2_behn_io_poll(): update behn IO state. - */ - void - u2_behn_io_poll(void); - /* u3_behn_ef_bake(): notify %behn that we're live */ void @@ -1116,11 +1090,6 @@ void u3_http_io_exit(void); - /* u3_http_io_poll(): update http IO state. - */ - void - u3_http_io_poll(void); - /** Raft log syncing. **/ /* u3_raft_readopt(): parse command line options. @@ -1209,24 +1178,6 @@ void u3_sist_rand(c3_w* rad_w); - /** New timer system. - **/ - /* u3_behn_io_init(): initialize time timer. - */ - void - u3_behn_io_init(void); - - /* u3_behn_io_exit(): terminate timer. - */ - void - u3_behn_io_exit(void); - - /* u3_behn_io_poll(): update behn IO state. - */ - void - u3_behn_io_poll(void); - - /** HTTP client. **/ /* u3_cttp_ef_thus(): send %thus effect to cttp. @@ -1244,8 +1195,3 @@ */ void u3_cttp_io_exit(void); - - /* u3_cttp_io_poll(): update cttp IO state. - */ - void - u3_cttp_io_poll(void); diff --git a/vere/ames.c b/vere/ames.c index 72e069755..a28e21e19 100644 --- a/vere/ames.c +++ b/vere/ames.c @@ -542,10 +542,3 @@ u3_ames_io_exit() uv_close(&sam_u->had_u, 0); } } - -/* u3_ames_io_poll(): update ames IO state. -*/ -void -u3_ames_io_poll() -{ -} diff --git a/vere/behn.c b/vere/behn.c index 605d2347e..e934d2620 100644 --- a/vere/behn.c +++ b/vere/behn.c @@ -56,13 +56,6 @@ _behn_time_cb(uv_timer_t* tim_u) u3_lo_shut(c3n); } -/* u3_behn_io_poll(): update behn IO state. -*/ -void -u3_behn_io_poll(void) -{ -} - /* u3_behn_ef_doze(): set or cancel timer */ void diff --git a/vere/cttp.c b/vere/cttp.c index 0d131e775..b37101688 100644 --- a/vere/cttp.c +++ b/vere/cttp.c @@ -976,13 +976,6 @@ u3_cttp_io_init() u3_Host.ctp_u.ceq_u = 0; } -/* u3_cttp_io_poll(): poll kernel for cttp I/O. -*/ -void -u3_cttp_io_poll(void) -{ -} - /* u3_cttp_io_exit(): shut down cttp. */ void diff --git a/vere/http.c b/vere/http.c index d8a035f9d..4b56f0a8e 100644 --- a/vere/http.c +++ b/vere/http.c @@ -1561,13 +1561,6 @@ u3_http_io_talk(void) { } -/* u3_http_io_poll(): poll kernel for http I/O. -*/ -void -u3_http_io_poll(void) -{ -} - /* u3_http_io_exit(): shut down http. */ void diff --git a/vere/loop.c b/vere/loop.c index 8f6435d20..84b582edc 100644 --- a/vere/loop.c +++ b/vere/loop.c @@ -254,38 +254,6 @@ u3_lo_exit(void) u3a_lop(cod_l); } -/* _lo_poll(): reset event flags across the process. -*/ -static void -_lo_poll(void) -{ - c3_l cod_l; - - cod_l = u3a_lush(c3__ames); - u3_ames_io_poll(); - u3a_lop(cod_l); - - cod_l = u3a_lush(c3__http); - u3_http_io_poll(); - u3a_lop(cod_l); - - cod_l = u3a_lush(c3__term); - u3_term_io_poll(); - u3a_lop(cod_l); - - cod_l = u3a_lush(c3__save); - u3_save_io_poll(); - u3a_lop(cod_l); - - cod_l = u3a_lush(c3__unix); - u3_unix_io_poll(); - u3a_lop(cod_l); - - cod_l = u3a_lush(c3__behn); - u3_behn_io_poll(); - u3a_lop(cod_l); -} - #if 0 /* _lo_how(): print how. */ @@ -479,11 +447,6 @@ u3_lo_shut(c3_o inn) u3e_save(); exit(u3_Host.xit_i); } - else { - // poll arvo to generate any event binding changes - // - _lo_poll(); - } } #if 0 @@ -681,7 +644,6 @@ u3_lo_lead(void) u3v_plan(u3nt(u3_blip, c3__ames, u3_nul), u3nc(c3__kick, u3k(u3A->now))); } - _lo_poll(); #if 0 u3_loom_save(u3A->ent_d); diff --git a/vere/save.c b/vere/save.c index 68c56c33e..e4d25fa3e 100644 --- a/vere/save.c +++ b/vere/save.c @@ -80,10 +80,3 @@ void u3_save_io_exit(void) { } - -/* u3_save_io_poll(): poll kernel for save I/O. -*/ -void -u3_save_io_poll(void) -{ -} diff --git a/vere/term.c b/vere/term.c index 4782e34bf..e57143d10 100644 --- a/vere/term.c +++ b/vere/term.c @@ -303,11 +303,6 @@ u3_term_io_exit(void) } } -void -u3_term_io_poll(void) -{ -} - /* _term_it_buf(): create a data buffer. */ static u3_ubuf* diff --git a/vere/unix.c b/vere/unix.c index e6c0065e7..22ccf7fa2 100644 --- a/vere/unix.c +++ b/vere/unix.c @@ -1486,10 +1486,3 @@ u3_unix_io_exit(void) uv_check_stop(&u3_Host.unx_u.syn_u); u3_unix_release(u3_Host.dir_c); } - -/* u3_unix_io_poll(): update unix IO state. -*/ -void -u3_unix_io_poll(void) -{ -} From bc30fb282b7eadf5e0c6777f21e0d6ffce8eddaa Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 26 Nov 2018 16:31:55 -0500 Subject: [PATCH 074/157] automatically process events on restart --- vere/sist.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vere/sist.c b/vere/sist.c index a03fdcfa3..4644ea551 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1624,6 +1624,9 @@ u3_sist_boot(void) u3_Host.ops_u.has = c3y; u3C.wag_w |= u3o_hashless; } + + // process pending events + u3_raft_work(); } else { u3_noun pig, who; From 4b9ea4cabca0ce2c52697037f4f56b514264bfbb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 26 Nov 2018 16:40:43 -0500 Subject: [PATCH 075/157] [build] builds just the urbit binary by default --- scripts/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build b/scripts/build index 879618f28..8a83841ed 100755 --- a/scripts/build +++ b/scripts/build @@ -2,4 +2,4 @@ mkdir ./build &> /dev/null meson . ./build --buildtype=release "$@" -ninja -C build +ninja -C build urbit From 941f2f72bd18c12e30d42d64cd4fa249f1119b85 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 26 Nov 2018 17:57:01 -0500 Subject: [PATCH 076/157] removes u3v_keep, updates arvo axes --- include/noun/vortex.h | 5 ----- noun/vortex.c | 31 ++++++++----------------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/include/noun/vortex.h b/include/noun/vortex.h index b36cd8f25..345f312e5 100644 --- a/include/noun/vortex.h +++ b/include/noun/vortex.h @@ -120,11 +120,6 @@ u3_noun u3v_peek(u3_noun hap); - /* u3v_keep(): measure timer. - */ - u3_noun - u3v_keep(u3_noun hap); - /* u3v_poke(): insert and apply an input ovum (protected). */ u3_noun diff --git a/noun/vortex.c b/noun/vortex.c index faec49d42..46538a5d3 100644 --- a/noun/vortex.c +++ b/noun/vortex.c @@ -4,6 +4,10 @@ #include #include "all.h" +#define _CVX_WISH 4 +#define _CVX_POKE 10 +#define _CVX_PEEK 47 + int WISH; /* _cv_nock_wish(): call wish through hardcoded interface. */ @@ -13,7 +17,7 @@ _cv_nock_wish(u3_noun txt) u3_noun fun, pro; WISH = 1; - fun = u3n_nock_on(u3k(u3A->roc), u3k(u3x_at(20, u3A->roc))); + fun = u3n_nock_on(u3k(u3A->roc), u3k(u3x_at(_CVX_WISH, u3A->roc))); pro = u3n_slam_on(fun, txt); WISH = 0; @@ -129,7 +133,7 @@ _cv_mung(c3_w sec_w, u3_noun gat, u3_noun sam) u3_noun u3v_pike(u3_noun ovo, u3_noun cor) { - u3_noun fun = u3n_nock_on(cor, u3k(u3x_at(42, cor))); + u3_noun fun = u3n_nock_on(cor, u3k(u3x_at(_CVX_POKE, cor))); u3_noun sam = u3nc(u3k(u3A->now), ovo); return _cv_mung(0, fun, sam); @@ -198,7 +202,7 @@ u3v_nick(u3_noun vir, u3_noun cor) static u3_noun _cv_nock_poke(u3_noun ovo) { - u3_noun fun = u3n_nock_on(u3k(u3A->roc), u3k(u3x_at(42, u3A->roc))); + u3_noun fun = u3n_nock_on(u3k(u3A->roc), u3k(u3x_at(_CVX_POKE, u3A->roc))); u3_noun sam, pro; u3_noun cod_w; @@ -236,18 +240,7 @@ _cv_nock_poke(u3_noun ovo) static u3_noun _cv_nock_peek(u3_noun hap) { - u3_noun fun = u3n_nock_on(u3k(u3A->roc), u3k(u3x_at(87, u3A->roc))); - u3_noun sam = u3nc(u3k(u3A->now), hap); - - return u3n_slam_on(fun, sam); -} - -/* _cv_nock_keep(): call wait through hardcoded interface. -*/ -static u3_noun -_cv_nock_keep(u3_noun hap) -{ - u3_noun fun = u3n_nock_on(u3k(u3A->roc), u3k(u3x_at(4, u3A->roc))); + u3_noun fun = u3n_nock_on(u3k(u3A->roc), u3k(u3x_at(_CVX_PEEK, u3A->roc))); u3_noun sam = u3nc(u3k(u3A->now), hap); return u3n_slam_on(fun, sam); @@ -325,14 +318,6 @@ u3v_peek(u3_noun hap) return u3m_soft_sure(_cv_nock_peek, hap); } -/* u3v_keep(): measure timer. -*/ -u3_noun -u3v_keep(u3_noun hap) -{ - return u3m_soft_sure(_cv_nock_keep, hap); -} - #if 0 /* _cv_mole(): parse simple atomic mole. */ From 819967dd621820ce09bd7009d69c2abe4615551b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 26 Nov 2018 17:59:41 -0500 Subject: [PATCH 077/157] [CI] updates pinned arvo commit --- .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 9d43e70d0..4e689c4c5 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -e661d55e491bbb28a2f7272bd1ab244f34a8ee17 +806c604c2f0f9ee7eea2999e6bb15ed5a8abaa99 From 98c581f95a71b06b6c83bc6e0dbfcdeb25e81864 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 26 Nov 2018 16:18:53 -0800 Subject: [PATCH 078/157] Jet +jab:by, which is used extensively in ford. --- include/jets/w.h | 1 + jets/d/by_jab.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ jets/tree.c | 3 +++ meson.build | 1 + 4 files changed, 61 insertions(+) create mode 100644 jets/d/by_jab.c diff --git a/include/jets/w.h b/include/jets/w.h index 578934703..d8b5d8017 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -84,6 +84,7 @@ u3_noun u3wdb_get(u3_noun); u3_noun u3wdb_has(u3_noun); u3_noun u3wdb_int(u3_noun); + u3_noun u3wdb_jab(u3_noun); u3_noun u3wdb_put(u3_noun); # define u3wdb_tap u3wdi_tap u3_noun u3wdb_uni(u3_noun); diff --git a/jets/d/by_jab.c b/jets/d/by_jab.c new file mode 100644 index 000000000..f147232a2 --- /dev/null +++ b/jets/d/by_jab.c @@ -0,0 +1,56 @@ +/* j/4/by_jab.c +** +*/ +#include "all.h" + + +/* functions +*/ + u3_noun + u3qdb_jab(u3_noun a, + u3_noun key, + u3_noun fun) + { + if ( u3_nul == a ) { + return u3m_bail(c3__exit); + } + else { + u3_noun l_a, n_a, r_a; + u3_noun 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 ( (c3y == u3r_sing(key, pn_a)) ) { + u3_noun value = u3n_slam_on(u3k(fun), u3k(qn_a)); + return u3nc(u3nc(u3k(pn_a), value), u3k(u3t(a))); + } + else { + if ( c3y == u3qc_gor(key, pn_a) ) { + return u3nt(u3k(n_a), u3qdb_jab(l_a, key, fun), u3k(r_a)); + } + else { + return u3nt(u3k(n_a), u3k(l_a), u3qdb_jab(r_a, key, fun)); + } + } + } + } + } + + u3_noun + u3wdb_jab(u3_noun cor) + { + u3_noun a, key, fun; + + if ( c3n == u3r_mean(cor, u3x_sam_2, &key, + u3x_sam_3, &fun, + u3x_con_sam, &a, 0) ) { + return u3m_bail(c3__exit); + } else { + u3_noun n = u3qdb_jab(a, key, fun); + return n; + } + } diff --git a/jets/tree.c b/jets/tree.c index 57f21979b..4facf4fa0 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -922,6 +922,8 @@ static c3_c* _141_two__in_ha[] = {0}; // static u3j_harm _141_two__by_int_a[] = {{".2", u3wdb_int, c3y}, {}}; // static c3_c* _141_two__by_int_ha[] = {0}; + static u3j_harm _141_two__by_jab_a[] = {{".2", u3wdb_jab, c3y}, {}}; + static c3_c* _141_two__by_jab_ha[] = {0}; static u3j_harm _141_two__by_put_a[] = {{".2", u3wdb_put, c3y}, {}}; static c3_c* _141_two__by_put_ha[] = {0}; static u3j_harm _141_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; @@ -938,6 +940,7 @@ static u3j_core _141_two__by_d[] = { "get", 7, _141_two__by_get_a, 0, _141_two__by_get_ha }, { "has", 7, _141_two__by_has_a, 0, _141_two__by_has_ha }, // { "int", 7, _141_two__by_int_a, 0, _141_two__by_int_ha }, + { "jab", 7, _141_two__by_jab_a, 0, _141_two__by_jab_ha }, { "put", 7, _141_two__by_put_a, 0, _141_two__by_put_ha }, { "tap", 7, _141_two__by_tap_a, 0, _141_two__by_tap_ha }, // { "uni", 7, _141_two__by_uni_a, 0, _141_two__by_uni_ha }, diff --git a/meson.build b/meson.build index 5a1ac36c1..405bd0d50 100644 --- a/meson.build +++ b/meson.build @@ -94,6 +94,7 @@ jets_d_src = [ 'jets/d/by_get.c', 'jets/d/by_has.c', 'jets/d/by_int.c', +'jets/d/by_jab.c', 'jets/d/by_put.c', 'jets/d/by_uni.c', 'jets/d/by_bif.c', From ab455736e93b610371c96a014162a55fc08f039a Mon Sep 17 00:00:00 2001 From: joshuareagan Date: Thu, 29 Nov 2018 12:42:47 -0600 Subject: [PATCH 079/157] variance fix: calling lead, zinc gates --- jets/f/ut_find.c | 9 +-------- jets/f/ut_fire.c | 9 +++++++-- jets/f/ut_peek.c | 22 +++++++++++++++++++++- jets/tree.c | 9 +++------ 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/jets/f/ut_find.c b/jets/f/ut_find.c index 610e4a46f..7de284836 100644 --- a/jets/f/ut_find.c +++ b/jets/f/ut_find.c @@ -190,15 +190,8 @@ u3_noun pu_zem = u3h(u_zem); u3_noun qu_zem = u3t(u_zem); u3_noun zut; - u3_noun mut; u3_noun pro; - mut = u3nt(c3__core, - u3k(p_sut), - u3nt(u3nt(u3k(ppq_sut), u3k(qpq_sut), c3__gold), - u3k(qq_sut), - u3k(rq_sut))); - #if 1 if ( qpq_sut == c3__wet ) { zut = u3nc(c3__wet, u3k(qu_zem)); @@ -214,7 +207,7 @@ u3nc(u3nc(u3_nul, u3k(axe)), u3k(lon)), u3nt(c3n, u3qc_peg(2, pu_zem), - u3nt(u3nc(mut, zut), u3_nul, u3_nul))); + u3nt(u3nc(u3k(sut), zut), u3_nul, u3_nul))); u3z(zem); return pro; diff --git a/jets/f/ut_fire.c b/jets/f/ut_fire.c index 7ca02bccb..873d4524b 100644 --- a/jets/f/ut_fire.c +++ b/jets/f/ut_fire.c @@ -62,6 +62,7 @@ u3_noun gat) { u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ; + u3_noun ppq_typ, qpq_typ, rpq_typ; u3_noun h_gat, t_gat; if ( (c3n == u3du(typ)) || (c3__core != u3h(typ)) ) { @@ -69,12 +70,16 @@ } else if ( (c3n == u3r_cell(u3t(typ), &p_typ, &q_typ)) || (c3n == u3r_trel(q_typ, &pq_typ, &qq_typ, &rq_typ)) || + (c3n == u3r_trel(pq_typ, &ppq_typ, &qpq_typ, &rpq_typ)) || (c3n == u3r_cell(gat, &h_gat, &t_gat)) ) { return u3m_bail(c3__fail); } else { - u3_noun dox = u3nt - (c3__core, u3k(qq_typ), u3k(q_typ)); + u3_noun dox = u3nt(c3__core, + u3k(qq_typ), + u3nt(u3nt(u3k(ppq_typ), u3k(qpq_typ), c3__gold), + u3k(qq_typ), + u3k(rq_typ))); if ( (c3__ash == u3h(gat)) || (c3__dry == u3h(gat)) ) { if ( (c3y == vet) && diff --git a/jets/f/ut_peek.c b/jets/f/ut_peek.c index 96c99414c..8b59d8f88 100644 --- a/jets/f/ut_peek.c +++ b/jets/f/ut_peek.c @@ -88,11 +88,30 @@ u3_noun pec = u3qfu_peel(van, sut, way, rpq_sut); u3_noun sam = u3h(pec); u3_noun con = u3t(pec); + u3_atom tow; - if ( c3y == c3a(sam, con) ) { + if ( 1 == lat ) { + tow = 1; + } else { + tow = u3qc_cap(lat); + } + + if ( (c3y == c3a(sam, con)) || + ((c3y == sam) && (tow == 2)) || + ((c3y == con) && (tow == 3)) ) + { pro = _cqfu_peek(van, p_sut, way, lat); } else { + + if ( way != c3__read ) { + u3z(lat); + u3z(now); + u3z(pec); + u3z(tow); + return u3m_error("payload-block"); + } + u3_noun typ; { @@ -120,6 +139,7 @@ } u3z(pec); + u3z(tow); } else { pro = c3__noun; diff --git a/jets/tree.c b/jets/tree.c index 4facf4fa0..a96baaded 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -233,11 +233,8 @@ static c3_c* _141_pen_loot_ha[] = {0}; static u3j_harm _141_pen__ut_crop_a[] = {{".2", u3wfu_crop}, {}}; static c3_c* _141_pen__ut_crop_ha[] = {0}; - - // XX figure out why this is disabled - // static u3j_harm _141_pen__ut_fire_a[] = {{".2", u3wfu_fire}, {}}; - // static c3_c* _141_pen__ut_fire_ha[] = {0}; - + static u3j_harm _141_pen__ut_fire_a[] = {{".2", u3wfu_fire}, {}}; + static c3_c* _141_pen__ut_fire_ha[] = {0}; static u3j_harm _141_pen__ut_fond_a[] = {{".2", u3wfu_fond}, {}}; static c3_c* _141_pen__ut_fond_ha[] = {0}; static u3j_harm _141_pen__ut_fish_a[] = {{".2", u3wfu_fish}, {}}; @@ -265,7 +262,7 @@ static u3j_core _141_pen__ut_d[] = { { "crop", 7, _141_pen__ut_crop_a, 0, _141_pen__ut_crop_ha }, { "fond", 7, _141_pen__ut_fond_a, 0, _141_pen__ut_fond_ha }, - // { "fire", 7, _141_pen__ut_fire_a, 0, _141_pen__ut_fire_ha }, + { "fire", 7, _141_pen__ut_fire_a, 0, _141_pen__ut_fire_ha }, { "fish", 7, _141_pen__ut_fish_a, 0, _141_pen__ut_fish_ha }, { "fuse", 7, _141_pen__ut_fuse_a, 0, _141_pen__ut_fuse_ha }, { "mint", 7, _141_pen__ut_mint_a, 0, _141_pen__ut_mint_ha }, From cb96aed4c7f25c011296d9dda41aad32bbb91067 Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Thu, 29 Nov 2018 13:05:15 -0600 Subject: [PATCH 080/157] arvo commit hash --- .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 4e689c4c5..372a31df7 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -806c604c2f0f9ee7eea2999e6bb15ed5a8abaa99 +f583936e8e092a133644d184387e8bb7d30c9299 From 1e2a8bdb12befd193b4e5a62412e18bcc3395008 Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Thu, 29 Nov 2018 14:10:45 -0600 Subject: [PATCH 081/157] Update pin-arvo-commit.txt --- .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 372a31df7..92c82b8d0 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -f583936e8e092a133644d184387e8bb7d30c9299 +e71c57b4455c84062230b4277f95eb7047a26146 From e62acfa1bcca372872bc835872a77d638ca3cfea Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Thu, 29 Nov 2018 18:52:47 -0600 Subject: [PATCH 082/157] remove superfluous reference decrements --- jets/f/ut_peek.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/jets/f/ut_peek.c b/jets/f/ut_peek.c index 8b59d8f88..dc9a5887c 100644 --- a/jets/f/ut_peek.c +++ b/jets/f/ut_peek.c @@ -105,10 +105,6 @@ else { if ( way != c3__read ) { - u3z(lat); - u3z(now); - u3z(pec); - u3z(tow); return u3m_error("payload-block"); } From 2f8d0d6d34963ea00284c4cd69a5ae8bbc33b061 Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Fri, 30 Nov 2018 22:11:08 -0600 Subject: [PATCH 083/157] fix core nest mismatch There is a variance bug such that the following cast is allowed to go through: ``` > =a 12 > =core1 ^? |=(b=@ a) > =a "hello" > =core2 ^? |=(b=@ a) > ^+(core1 core2) ``` This should not be! The code in `hoon.hoon` is correct -- it turns out that the jet is wrong however. It falsely returns "yes" for a nest in which two cores have identical code. Obviously that's not enough to guarantee sameness of type. So I've removed the offending lines. --- jets/f/ut_nest.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/jets/f/ut_nest.c b/jets/f/ut_nest.c index a6bd87deb..f36c1385c 100644 --- a/jets/f/ut_nest.c +++ b/jets/f/ut_nest.c @@ -150,9 +150,6 @@ else if ( c3__wet == qpq_sut ) { return u3r_sing(qrq_sut, qrq_ref); } - else if ( c3y == u3r_sing(qrq_sut, qrq_ref) ) { - return c3y; - } else { u3_noun hud = u3nc(u3k(sut), u3k(ref)); From 8b9680072a6c2e38be5ae1f87e531c222cdc4b81 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 28 Nov 2018 16:34:32 -0800 Subject: [PATCH 084/157] Add support for trace_event files. This adds a -j parameter which writes traces of your Urbit's function call stack to a json file, readable by Chrome's about://tracing or the standalone trace-viewer webapp. --- include/noun/allocate.h | 1 + include/noun/options.h | 3 +- include/noun/trace.h | 21 +++++ include/vere/vere.h | 2 + noun/jets.c | 55 +++++++++--- noun/manage.c | 3 + noun/trace.c | 181 +++++++++++++++++++++++++++++++++++++++- noun/vortex.c | 3 + vere/main.c | 14 +++- vere/raft.c | 5 ++ vere/reck.c | 2 + 11 files changed, 275 insertions(+), 15 deletions(-) diff --git a/include/noun/allocate.h b/include/noun/allocate.h index 11199014d..32a8e8d37 100644 --- a/include/noun/allocate.h +++ b/include/noun/allocate.h @@ -146,6 +146,7 @@ c3_d nox_d; // nock steps c3_d cel_d; // cell allocations u3_noun don; // (list batt) + u3_noun trace; // (list trace) u3_noun day; // doss, only in u3H (moveme) } pro; diff --git a/include/noun/options.h b/include/noun/options.h index 7eb5d540b..9ac90512e 100644 --- a/include/noun/options.h +++ b/include/noun/options.h @@ -25,7 +25,8 @@ u3o_verbose = 0x10, // be remarkably wordy u3o_dryrun = 0x20, // don't touch checkpoint u3o_quiet = 0x40, // disable ~& - u3o_hashless = 0x80 // disable hashboard + u3o_hashless = 0x80, // disable hashboard + u3o_trace = 0x100 // enables trace dumping }; /** Globals. diff --git a/include/noun/trace.h b/include/noun/trace.h index 838ce835f..049c55218 100644 --- a/include/noun/trace.h +++ b/include/noun/trace.h @@ -83,6 +83,27 @@ void u3t_flee(void); + /* u3t_trace_open(): opens the path for writing tracing information. + */ + void + u3t_trace_open(c3_c*); + + /* u3t_nock_trace_push(): pushes a frame ont o the trace stack; + * return yes if active push. + */ + c3_o + u3t_nock_trace_push(u3_noun lab); + + /* u3t_nock_trace_pop(): pop off trace stack. + */ + void + u3t_nock_trace_pop(); + + /* u3t_even_trace(): record a lifecycle event. + */ + void + u3t_event_trace(const char* name, char type); + /* u3t_damp(): print and clear profile data. */ void diff --git a/include/vere/vere.h b/include/vere/vere.h index 4e59a01e8..79cc76b7e 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -591,6 +591,7 @@ c3_c* gen_c; // -G, czar generator c3_o gab; // -g, test garbage collection c3_c* dns_c; // -H, ames bootstrap domain + c3_c* json_file_c; // -j, json trace c3_w kno_w; // -K, kernel version c3_c* key_c; // -k, private key file c3_o net; // -L, local-only networking @@ -631,6 +632,7 @@ c3_o liv; // if u3_no, shut down c3_i xit_i; // exit code for shutdown void* tls_u; // server SSL_CTX* + FILE* trace_file; // trace file to write to } u3_host; // host == computer == process # define u3L u3_Host.lup_u // global event loop diff --git a/noun/jets.c b/noun/jets.c index 8e37f8d4e..3fb353f70 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1243,18 +1243,27 @@ u3j_kick(u3_noun cor, u3_noun axe) u3x_qual(act, &jax_l, &hap, &bal, &jit); if ( u3_none == (inx = u3kdb_get(u3k(hap), u3k(axe))) ) { - u3t_off(glu_o); + u3t_off(glu_o); { c3_o pof_o = __(u3C.wag_w & u3o_debug_cpu); + c3_o trc_o = __(u3C.wag_w & u3o_trace); if ( _(pof_o) ) { pof_o = u3t_come(bal); } + if ( _(trc_o) ) { + trc_o = u3t_nock_trace_push(bal); + } u3z(act); - if ( _(pof_o) ) { + if ( _(pof_o) || _(trc_o) ) { u3_noun pro = _cj_sink(cor, u3k(axe)); - u3t_flee(); + if (_(pof_o)) { + u3t_flee(); + } + if ( _(trc_o) ) { + u3t_nock_trace_pop(); + } return pro; } else { @@ -1267,28 +1276,39 @@ u3j_kick(u3_noun cor, u3_noun axe) c3_l inx_l = inx; u3j_harm* ham_u = &cop_u->arm_u[inx_l]; c3_o pof_o = __(u3C.wag_w & u3o_debug_cpu); + c3_o trc_o = __(u3C.wag_w & u3o_trace); u3_noun pro; if ( _(pof_o) ) { pof_o = u3t_come(bal); } + if ( _(trc_o) ) { + trc_o = u3t_nock_trace_push(bal); + } u3z(act); u3t_off(glu_o); pro = _cj_kick_z(cor, cop_u, ham_u, axe); - + if ( u3_none == pro ) { - if ( _(pof_o) ) { + if ( _(pof_o) || _(trc_o) ) { pro = _cj_sink(cor, u3k(axe)); - u3t_flee(); - return pro; - } - else return u3_none; + if (_(pof_o)) { + u3t_flee(); + } + if ( _(trc_o) ) { + u3t_nock_trace_pop(); + } + } + return pro; } else { if ( _(pof_o) ) { u3t_flee(); } + if ( _(trc_o) ) { + u3t_nock_trace_pop(); + } return pro; } } @@ -1470,7 +1490,9 @@ _cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u, c3_o lok_o) u3_weak pro = u3_none; c3_o jet_o = sit_u->jet_o; c3_o pof_o = __(u3C.wag_w & u3o_debug_cpu); - if ( c3n == pof_o ) { + c3_o trc_o = __(u3C.wag_w & u3o_trace); + + if ( c3n == pof_o && c3n == trc_o ) { if ( c3y == jet_o ) { u3t_off(glu_o); pro = _cj_kick_z(cor, sit_u->cop_u, sit_u->ham_u, sit_u->axe); @@ -1483,7 +1505,13 @@ _cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u, c3_o lok_o) } } else { - pof_o = u3t_come(sit_u->lab); + if ( _(pof_o) ) { + pof_o = u3t_come(sit_u->lab); + } + if ( _(trc_o) ) { + trc_o = u3t_nock_trace_push(sit_u->lab); + } + if ( c3y == jet_o ) { u3t_off(glu_o); pro = _cj_kick_z(cor, sit_u->cop_u, sit_u->ham_u, sit_u->axe); @@ -1495,10 +1523,15 @@ _cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u, c3_o lok_o) } pro = _cj_burn(sit_u->pog_p, cor); } + if ( c3y == pof_o ) { u3t_flee(); } + if ( c3y == trc_o ) { + u3t_nock_trace_pop(); + } } + return pro; } diff --git a/noun/manage.c b/noun/manage.c index 3e30b75be..efe295e12 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -500,6 +500,7 @@ u3m_mark(void) tot_w += u3a_mark_noun(u3R->bug.tax); tot_w += u3a_mark_noun(u3R->bug.mer); tot_w += u3a_mark_noun(u3R->pro.don); + tot_w += u3a_mark_noun(u3R->pro.trace); tot_w += u3a_mark_noun(u3R->pro.day); tot_w += u3h_mark(u3R->cax.har_p); return tot_w; @@ -1014,6 +1015,7 @@ u3m_soft_run(u3_noun gul, { u3R->ski.gul = u3nc(gul, u3to(u3_road, u3R->par_p)->ski.gul); u3R->pro.don = u3to(u3_road, u3R->par_p)->pro.don; + u3R->pro.trace = u3to(u3_road, u3R->par_p)->pro.trace; u3R->bug.tax = 0; } u3t_on(coy_o); @@ -1107,6 +1109,7 @@ u3m_soft_esc(u3_noun ref, u3_noun sam) { u3R->ski.gul = u3t(u3to(u3_road, u3R->par_p)->ski.gul); u3R->pro.don = u3to(u3_road, u3R->par_p)->pro.don; + u3R->pro.trace = u3to(u3_road, u3R->par_p)->pro.trace; u3R->bug.tax = 0; } diff --git a/noun/trace.c b/noun/trace.c index 0fbe83324..6d4d2f4a7 100644 --- a/noun/trace.c +++ b/noun/trace.c @@ -210,7 +210,10 @@ u3t_samp(void) // it can cause memory errors. return; } + + c3_w old_wag = u3C.wag_w; u3C.wag_w &= ~u3o_debug_cpu; + u3C.wag_w &= ~u3o_trace; static int home = 0; static int away = 0; @@ -265,7 +268,7 @@ u3t_samp(void) away++; // fprintf(stderr,"home: %06d away: %06d\r\n", home, away); } - u3C.wag_w |= u3o_debug_cpu; + u3C.wag_w = old_wag; } /* u3t_come(): push on profile stack; return yes if active push. RETAIN. @@ -279,7 +282,7 @@ u3t_come(u3_noun lab) u3R->pro.don = u3nc(lab, u3R->pro.don); _ct_lop_o = c3n; return c3y; - } + } else return c3n; } @@ -295,6 +298,180 @@ u3t_flee(void) u3z(don); } +static FILE* trace_file = NULL; +static int nock_pid = 0; + +/* u3t_trace_open(): opens a trace file and writes the preamble. +*/ +void +u3t_trace_open(c3_c* trace_file_name) +{ + printf("trace: tracing to %s\n", trace_file_name); + trace_file = fopen(trace_file_name, "w"); + nock_pid = (int)getpid(); + fprintf(trace_file, "[ "); + + // We have two "threads", the event processing and the nock stuff. + // tid 1 = event processing + // tid 2 = nock processing + fprintf( + trace_file, + "{\"name\": \"process_name\", \"ph\": \"M\", \"pid\": %d, \"args\": " + "{\"name\": \"urbit\"}},\n", + nock_pid); + fprintf(trace_file, + "{\"name\": \"thread_name\", \"ph\": \"M\", \"pid\": %d, \"tid\": 1, " + "\"args\": {\"name\": \"Event Processing\"}},\n", + nock_pid); + fprintf(trace_file, + "{\"name\": \"thread_sort_index\", \"ph\": \"M\", \"pid\": %d, " + "\"tid\": 1, \"args\": {\"sort_index\": 1}},\n", + nock_pid); + fprintf(trace_file, + "{\"name\": \"thread_name\", \"ph\": \"M\", \"pid\": %d, \"tid\": 2, " + "\"args\": {\"name\": \"Nock\"}},\n", + nock_pid); + fprintf(trace_file, + "{\"name\": \"thread_sort_index\", \"ph\": \"M\", \"pid\": %d, " + "\"tid\": 2, \"args\": {\"sort_index\": 2}},\n", + nock_pid); +} + +/* u3t_trace_time(): microsecond clock +*/ +uint64_t u3t_trace_time() +{ + struct timeval tim_tv; + gettimeofday(&tim_tv, 0); + return 1000000ULL * tim_tv.tv_sec + tim_tv.tv_usec; +} + +/* u3t_nock_trace_push(): push a trace onto the trace stack; returns yes if pushed. + * + * The trace stack is a stack of [path time-entered]. + */ +c3_o +u3t_nock_trace_push(u3_noun lab) +{ + if (!trace_file) + return c3n; + + if ( (u3_nul == u3R->pro.trace) || + !_(u3r_sing(lab, u3h(u3h(u3R->pro.trace)))) ) { + u3a_gain(lab); + c3_d time = u3t_trace_time(); + u3R->pro.trace = u3nc(u3nc(lab, u3i_chubs(1, &time)), u3R->pro.trace); + return c3y; + } + else { + return c3n; + } +} + +/* _in_trace_pretty: measure/cut prettyprint. + * + * Modeled after _cm_in_pretty(), the backend to u3m_p(), but with the + * assumption that we're always displaying a path. + */ +static c3_w +_in_trace_pretty(u3_noun som, c3_c* str_c) +{ + if ( _(u3du(som)) ) { + c3_w sel_w, one_w, two_w; + if ( str_c ) { + *(str_c++) = '/'; + } + sel_w = 1; + + one_w = _in_trace_pretty(u3h(som), str_c); + if ( str_c ) { + str_c += one_w; + } + + two_w = _in_trace_pretty(u3t(som), str_c); + if ( str_c ) { + str_c += two_w; + } + + return sel_w + one_w + two_w; + } + else { + c3_w len_w = u3r_met(3, som); + if ( str_c && len_w ) { + u3r_bytes(0, len_w, (c3_y *)str_c, som); + str_c += len_w; + } + return len_w; + } +} + +static c3_c* +trace_pretty(u3_noun som) +{ + c3_w len_w = _in_trace_pretty(som, NULL); + c3_c* pre_c = malloc(len_w + 1); + + _in_trace_pretty(som, pre_c); + pre_c[len_w] = 0; + return pre_c; +} + +/* u3t_nock_trace_pop(): pops a trace from the trace stack. + * + * When we remove the trace from the stack, we check to see if the sample is + * large enough to process, as we'll otherwise keep track of individual +add + * calls. If it is, we write it out to the tracefile. + */ +void +u3t_nock_trace_pop() +{ + if (!trace_file) + return; + + u3_noun trace = u3R->pro.trace; + u3R->pro.trace = u3k(u3t(trace)); + + u3_noun item = u3h(trace); + u3_noun lab = u3h(item); + c3_d start_time = u3r_chub(0, u3t(item)); + + // 33microseconds (a 30th of a millisecond). + uint64_t duration = u3t_trace_time() - start_time; + if (duration > 33) { + c3_c* name = trace_pretty(lab); + + fprintf(trace_file, + "{\"cat\": \"nock\", \"name\": \"%s\", \"ph\":\"%c\", \"pid\": %d, " + "\"tid\": 2, \"ts\": %" PRIu64 ", \"dur\": %" PRIu64 "}, \n", + name, + 'X', + nock_pid, + start_time, + duration); + + free(name); + } + + u3z(trace); +} + +/* u3t_event_trace(): dumps a simple event from outside nock. +*/ +void +u3t_event_trace(const char* name, char type) +{ + if (!trace_file) + return; + + fprintf(trace_file, + "{\"cat\": \"event\", \"name\": \"%s\", \"ph\":\"%c\", \"pid\": %d, " + "\"tid\": 1, \"ts\": %" PRIu64 ", \"id\": \"0x100\"}, \n", + name, + type, + nock_pid, + u3t_trace_time()); +} + extern FILE* u3_term_io_hija(void); diff --git a/noun/vortex.c b/noun/vortex.c index 46538a5d3..bcbaf3d4f 100644 --- a/noun/vortex.c +++ b/noun/vortex.c @@ -93,6 +93,7 @@ u3v_start(u3_noun now) u3_noun u3v_wish(const c3_c* str_c) { + u3t_event_trace("u3v_wish", 'b'); u3_noun txt = u3i_string(str_c); u3_weak exp = u3kdb_get(u3k(u3A->yot), u3k(txt)); @@ -107,6 +108,8 @@ u3v_wish(const c3_c* str_c) } } + u3t_event_trace("u3v_wish", 'e'); + u3z(txt); return exp; } diff --git a/vere/main.c b/vere/main.c index 0ae11fca2..1768136ae 100644 --- a/vere/main.c +++ b/vere/main.c @@ -94,7 +94,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.raf_c = 0; u3_Host.ops_u.nam_c = 0; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:w:u:e:E:f:F:k:p:LabcdgqstvxPDRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:w:u:j:e:E:f:F:k:p:LabcdgqstvxPDRS")) != -1 ) { switch ( ch_i ) { case 'B': { u3_Host.ops_u.pil_c = strdup(optarg); @@ -133,6 +133,10 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.url_c = strdup(optarg); break; } + case 'j': { + u3_Host.ops_u.json_file_c = strdup(optarg); + break; + } case 'x': { u3_Host.ops_u.tex = c3y; break; @@ -335,6 +339,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-F ship Fake keys; also disables networking\n", "-f Fuzz testing\n", "-g Set GC flag\n", + "-j file Create json trace file\n", "-K stage Start at Hoon kernel version stage\n", "-k keys Private key file\n", "-L local networking only\n", @@ -598,6 +603,13 @@ main(c3_i argc, if ( _(u3_Host.ops_u.has) ) { u3C.wag_w |= u3o_hashless; } + + /* Set tracing flag + */ + if ( u3_Host.ops_u.json_file_c ) { + u3C.wag_w |= u3o_trace; + u3t_trace_open(u3_Host.ops_u.json_file_c); + } } u3m_boot(u3_Host.ops_u.nuu, u3_Host.ops_u.gab, diff --git a/vere/raft.c b/vere/raft.c index 8452102a8..e14e06523 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1567,7 +1567,10 @@ _raft_punk(u3_noun ovo) } #endif + // TODO: Embed event number here? + u3t_event_trace("Running", 'b'); gon = u3m_soft(sec_w, u3v_poke, u3k(ovo)); + u3t_event_trace("Running", 'e'); #ifdef GHETTO c3_w ms_w; @@ -1656,7 +1659,9 @@ _raft_push(u3_raft* raf_u, c3_w* bob_w, c3_w len_w) if ( 1 == raf_u->pop_w ) { c3_assert(u3_raty_lead == raf_u->typ_e); + u3t_event_trace("Recording", 'b'); raf_u->ent_d = u3_sist_pack(raf_u->tem_w, c3__ov, bob_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) ) { diff --git a/vere/reck.c b/vere/reck.c index 4a4727081..0a98887f8 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -365,6 +365,7 @@ _reck_kick_norm(u3_noun pox, u3_noun fav) void u3_reck_kick(u3_noun ovo) { + u3t_event_trace("Effect", 'b'); if ( (c3n == _reck_kick_spec(u3k(u3h(ovo)), u3k(u3t(ovo)))) && (c3n == _reck_kick_norm(u3k(u3h(ovo)), u3k(u3t(ovo)))) ) { @@ -399,4 +400,5 @@ u3_reck_kick(u3_noun ovo) #endif } u3z(ovo); + u3t_event_trace("Effect", 'e'); } From 46dc173bf6877e2f7ffaaf77c14f645b5ba02e7f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 3 Dec 2018 17:09:56 -0500 Subject: [PATCH 085/157] update old %behn declarations in vere.h --- include/vere/vere.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 4e59a01e8..b0b54bb06 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -1024,15 +1024,15 @@ /** behn, just a timer. **/ - /* u2_behn_io_init(): initialize behn timer. + /* u3_behn_io_init(): initialize behn timer. */ void - u2_behn_io_init(void); + u3_behn_io_init(void); /* u2_behn_io_exit(): terminate timer. */ void - u2_behn_io_exit(void); + u3_behn_io_exit(void); /* u3_behn_ef_bake(): notify %behn that we're live */ From 7b475e7caa76fd8e8f5dd655ec7ea217e855afc8 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 3 Dec 2018 16:10:07 -0800 Subject: [PATCH 086/157] Remove 30ms per dill-blit. --- vere/reck.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/vere/reck.c b/vere/reck.c index 4a4727081..8c29c5f94 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -66,6 +66,27 @@ _reck_lily(u3_noun fot, u3_noun txt, c3_l* tid_l) } } +/* _reck_orchid(): parses only a number as text + * + * Parses a text string which contains a decimal number. In practice, this + * number is always '1'. + */ +static u3_noun +_reck_orchid(u3_noun fot, u3_noun txt, c3_l* tid_l) +{ + c3_c* str = u3r_string(txt); + c3_d ato_d = strtol(str, NULL, 10); + free(str); + + if ( ato_d >= 0x80000000ULL ) { + return c3n; + } else { + *tid_l = (c3_l) ato_d; + + return c3y; + } +} + /* _reck_kick_term(): apply terminal outputs. */ static u3_noun @@ -314,7 +335,7 @@ _reck_kick_spec(u3_noun pox, u3_noun fav) if ( (c3n == u3r_cell(pud, &p_pud, &q_pud)) || (u3_nul != q_pud) || - (c3n == _reck_lily(c3__ud, u3k(p_pud), &tid_l)) ) + (c3n == _reck_orchid(c3__ud, u3k(p_pud), &tid_l)) ) { uL(fprintf(uH, "term: bad tire\n")); u3z(pox); u3z(fav); return c3n; From 2ed422e11f4399287d5af701fcd35aac31e69cd9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 4 Dec 2018 00:53:56 -0500 Subject: [PATCH 087/157] boots with lifecycle formula, without persistent kernel formula removes now-unused vortex functions --- include/noun/vortex.h | 15 ++------------ noun/manage.c | 12 ++++++++--- noun/trace.c | 2 +- noun/vortex.c | 48 +++++++++++++------------------------------ 4 files changed, 26 insertions(+), 51 deletions(-) diff --git a/include/noun/vortex.h b/include/noun/vortex.h index 345f312e5..d84dbf2c6 100644 --- a/include/noun/vortex.h +++ b/include/noun/vortex.h @@ -33,7 +33,6 @@ u3_noun roe; // temporary unsaved events u3_noun key; // log key, or 0 - u3_noun ken; // kernel formula u3_noun roc; // kernel core struct { // ova waiting to process @@ -65,15 +64,10 @@ u3_noun u3v_do(const c3_c* txt_c, u3_noun arg); - /* u3v_make(): make a new pier by loading a pill. + /* u3v_boot(): evaluate boot sequence, making a kernel */ void - u3v_make(c3_c* pas_c); - - /* u3v_jack(): execute kernel formula to bind jets. - */ - void - u3v_jack(void); + u3v_boot(u3_noun eve); /* u3v_start(): start time. */ @@ -160,11 +154,6 @@ void u3v_hose(void); - /* u3v_louse(): last-minute deviltry upon a bail. - */ - void - u3v_louse(c3_m how_m); - /* u3v_mark(): mark arvo kernel. */ c3_w diff --git a/noun/manage.c b/noun/manage.c index 3e30b75be..94579b1db 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -1707,11 +1707,17 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, _boot_home(dir_c, pil_c, url_c, arv_c); snprintf(ful_c, 2048, "%s/.urb/urbit.pill", dir_c); - printf("boot: loading %s\r\n", ful_c); - u3v_make(ful_c); - u3v_jack(); + { + u3_noun sys = u3ke_cue(u3m_file(ful_c)); + u3_noun bot; + + u3x_trel(sys, &bot, 0, 0); + u3v_boot(u3k(bot)); + + u3z(sys); + } } else { u3v_hose(); diff --git a/noun/trace.c b/noun/trace.c index 0fbe83324..bb3a22848 100644 --- a/noun/trace.c +++ b/noun/trace.c @@ -66,7 +66,7 @@ u3t_slog(u3_noun hod) old = 1; #endif - if ( c3y == u3du(hod) ) { + if ( (0 != u3A->roc) && (c3y == u3du(hod)) ) { u3_noun pri = u3h(hod); switch ( pri ) { diff --git a/noun/vortex.c b/noun/vortex.c index 46538a5d3..7ca632efb 100644 --- a/noun/vortex.c +++ b/noun/vortex.c @@ -24,29 +24,26 @@ _cv_nock_wish(u3_noun txt) return pro; } -/* u3v_make(): make a new pier and instantiate pill. +/* u3v_boot(): evaluate boot sequence, making a kernel */ void -u3v_make(c3_c* pas_c) +u3v_boot(u3_noun eve) { - u3_noun sys = u3ke_cue(u3m_file(pas_c)); + // ensure zero-initialized kernel + // + // So that u3t_slog won't try to print tanks. + // + u3A->roc = 0; - u3A->ken = u3k(u3h(sys)); - u3A->roc = u3k(u3t(sys)); + // lifecycle formula + // + u3_noun lyf = u3nt(2, u3nc(0, 3), u3nc(0, 2)); + u3_noun cor = u3n_nock_on(eve, lyf); - u3z(sys); -} + // save the Arvo core (at +7 of the Arvo gate) + // + u3A->roc = u3k(u3x_at(7, cor)); -/* u3v_jack(): execute kernel formula to bind jets. -*/ -void -u3v_jack(void) -{ - u3_noun cor; - - fprintf(stderr, "jack: kernel %x\r\n", u3r_mug(u3A->ken)); - cor = u3n_nock_on(0, u3k(u3A->ken)); - fprintf(stderr, "jacked\r\n"); u3z(cor); } @@ -450,22 +447,6 @@ u3v_plow(u3_noun ova) u3z(ova); } -/* u3v_louse(): last-minute deviltry upon a bail. -*/ -void -u3v_louse(c3_m how_m) -{ -#if 0 - if ( c3__exit == how_m ) { - printf("louse: nocks: %d\n", NOX); - printf("louse: washing kernel %x %d\n", u3A->ken, u3a_is_dog(u3A->ken)); - u3m_wash(u3A->ken); - - printf("kernel %x; washed mug %x\n", u3A->ken, u3r_mug(u3A->ken)); - } -#endif -} - /* _cv_mark_ova(): mark ova queue. */ c3_w @@ -503,7 +484,6 @@ u3v_mark(void) tot_w += u3a_mark_noun(arv_u->roe); tot_w += u3a_mark_noun(arv_u->key); - tot_w += u3a_mark_noun(arv_u->ken); tot_w += u3a_mark_noun(arv_u->roc); tot_w += _cv_mark_ova(arv_u->ova.egg_p); From bf4e7910dcdaf1cd2314848477f03dea15a70829 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 4 Dec 2018 00:54:56 -0500 Subject: [PATCH 088/157] loads initial filesystem from pill, -A optional for all ships --- vere/main.c | 11 ----------- vere/sist.c | 26 +++++++++++++++++++------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/vere/main.c b/vere/main.c index 0ae11fca2..ebcd0c2a2 100644 --- a/vere/main.c +++ b/vere/main.c @@ -196,11 +196,6 @@ _main_getopt(c3_i argc, c3_c** argv) c3_t imp_t = ( (0 != u3_Host.ops_u.who_c) && (4 == strlen(u3_Host.ops_u.who_c)) ); - if ( u3_Host.ops_u.arv_c != 0 && !imp_t ) { - fprintf(stderr, "-A only makes sense when creating a new galaxy\n"); - return c3n; - } - if ( u3_Host.ops_u.ets_c == 0 && c3y == u3_Host.ops_u.etn ) { fprintf(stderr, "can't trust Ethereum snapshot without specifying " "snapshot with -E\n"); @@ -213,12 +208,6 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } - if ( u3_Host.ops_u.arv_c == 0 && imp_t ) { - fprintf(stderr, "can't create a new galaxy without specifying " - "the initial sync path with -A\n"); - return c3n; - } - if ( u3_Host.ops_u.gen_c != 0 && u3_Host.ops_u.nuu == c3n ) { fprintf(stderr, "-G only makes sense when bootstrapping a new instance\n"); return c3n; diff --git a/vere/sist.c b/vere/sist.c index 4644ea551..620ead285 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1696,15 +1696,27 @@ u3_sist_boot(void) // Authenticate and initialize terminal. u3_term_ef_bake(pig); - // queue initial galaxy sync - { - u3_noun rac = u3do("clan:title", u3k(u3A->own)); + // queue initial filesystem sync + // + // from the Arvo directory if specified + if ( 0 != u3_Host.ops_u.arv_c ) { + u3_unix_ef_initial_into(); + } + // otherwise from the pill + else { + c3_c ful_c[2048]; - if ( c3__czar == rac ) { - u3_unix_ef_initial_into(); + snprintf(ful_c, 2048, "%s/.urb/urbit.pill", u3_Host.dir_c); + + { + u3_noun sys = u3ke_cue(u3m_file(ful_c)); + u3_noun fil; + + u3x_trel(sys, 0, 0, &fil); + u3v_plow(u3k(fil)); + + u3z(sys); } - - u3z(rac); } // Create the event log From 6b3956dda0b2fa78553289170e16c2c393ede55f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 4 Dec 2018 02:27:17 -0500 Subject: [PATCH 089/157] [CI] updates pinned arvo commit --- .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 92c82b8d0..dfd8a1c12 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -e71c57b4455c84062230b4277f95eb7047a26146 +cae4b03c5c95722fb0e5f1947ba988f72703816d From 6ea1248f9424a919c6157e68046e7d0f2382fcfe Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 4 Dec 2018 03:12:05 -0500 Subject: [PATCH 090/157] [CI] skip arvo download, retrieve pill directly --- .travis.yml | 4 ---- .travis/test.js | 6 +++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index d3170289d..a957eb315 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,10 +15,6 @@ before_install: install: # pwd: ~/urbit - pip3 install --user -I meson==0.44.1 - - git clone https://github.com/urbit/arvo - - cd ./arvo - - git checkout $(cat ../.travis/pin-arvo-commit.txt) - - cd .. script: - meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true diff --git a/.travis/test.js b/.travis/test.js index 4afc09417..4efa96008 100644 --- a/.travis/test.js +++ b/.travis/test.js @@ -1,11 +1,15 @@ 'use strict'; +var fs = require('fs') var runner = require('urbit-runner') var Urbit = runner.Urbit; var ERROR = runner.ERROR; var actions = runner.actions -var args = ['-A', '../arvo', '-csgPSF', 'zod', 'zod']; +var hash = fs.readFileSync('./pin-arvo-commit.txt', 'utf-8').slice(0, 10) +var pill = 'https://bootstrap.urbit.org/git-' + hash + '.pill' + +var args = ['-u', pill, '-cgPSF', 'zod', 'zod']; var urbit = new Urbit(args); // vere hangs (always?) with run in travis-ci with -P From 4a53ebc6c5bdf3026dac93b99a33f393649a5b14 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 4 Dec 2018 14:46:25 -0800 Subject: [PATCH 091/157] Cleanup --- include/noun/trace.h | 9 +++++-- include/vere/vere.h | 2 +- noun/trace.c | 56 +++++++++++++++++++++++++++----------------- vere/loop.c | 5 ++++ 4 files changed, 47 insertions(+), 25 deletions(-) diff --git a/include/noun/trace.h b/include/noun/trace.h index 049c55218..e8ba7348a 100644 --- a/include/noun/trace.h +++ b/include/noun/trace.h @@ -88,7 +88,12 @@ void u3t_trace_open(c3_c*); - /* u3t_nock_trace_push(): pushes a frame ont o the trace stack; + /* u3t_trace_close(): closes the trace file. optional. + */ + void + u3t_trace_close(); + + /* u3t_nock_trace_push(): pushes a frame onto the trace stack; * return yes if active push. */ c3_o @@ -99,7 +104,7 @@ void u3t_nock_trace_pop(); - /* u3t_even_trace(): record a lifecycle event. + /* u3t_event_trace(): record a lifecycle event. */ void u3t_event_trace(const char* name, char type); diff --git a/include/vere/vere.h b/include/vere/vere.h index 79cc76b7e..972f0aedf 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -632,7 +632,7 @@ c3_o liv; // if u3_no, shut down c3_i xit_i; // exit code for shutdown void* tls_u; // server SSL_CTX* - FILE* trace_file; // trace file to write to + FILE* trace_file_u; // trace file to write to } u3_host; // host == computer == process # define u3L u3_Host.lup_u // global event loop diff --git a/noun/trace.c b/noun/trace.c index 6d4d2f4a7..51dfd0f66 100644 --- a/noun/trace.c +++ b/noun/trace.c @@ -298,8 +298,8 @@ u3t_flee(void) u3z(don); } -static FILE* trace_file = NULL; -static int nock_pid = 0; +static FILE* trace_file_u = NULL; +static int nock_pid_i = 0; /* u3t_trace_open(): opens a trace file and writes the preamble. */ @@ -307,34 +307,46 @@ void u3t_trace_open(c3_c* trace_file_name) { printf("trace: tracing to %s\n", trace_file_name); - trace_file = fopen(trace_file_name, "w"); - nock_pid = (int)getpid(); - fprintf(trace_file, "[ "); + trace_file_u = fopen(trace_file_name, "w"); + nock_pid_i = (int)getpid(); + fprintf(trace_file_u, "[ "); // We have two "threads", the event processing and the nock stuff. // tid 1 = event processing // tid 2 = nock processing fprintf( - trace_file, + trace_file_u, "{\"name\": \"process_name\", \"ph\": \"M\", \"pid\": %d, \"args\": " "{\"name\": \"urbit\"}},\n", - nock_pid); - fprintf(trace_file, + nock_pid_i); + fprintf(trace_file_u, "{\"name\": \"thread_name\", \"ph\": \"M\", \"pid\": %d, \"tid\": 1, " "\"args\": {\"name\": \"Event Processing\"}},\n", - nock_pid); - fprintf(trace_file, + nock_pid_i); + fprintf(trace_file_u, "{\"name\": \"thread_sort_index\", \"ph\": \"M\", \"pid\": %d, " "\"tid\": 1, \"args\": {\"sort_index\": 1}},\n", - nock_pid); - fprintf(trace_file, + nock_pid_i); + fprintf(trace_file_u, "{\"name\": \"thread_name\", \"ph\": \"M\", \"pid\": %d, \"tid\": 2, " "\"args\": {\"name\": \"Nock\"}},\n", - nock_pid); - fprintf(trace_file, + nock_pid_i); + fprintf(trace_file_u, "{\"name\": \"thread_sort_index\", \"ph\": \"M\", \"pid\": %d, " "\"tid\": 2, \"args\": {\"sort_index\": 2}},\n", - nock_pid); + nock_pid_i); +} + +/* u3t_trace_close(): closes a trace file. optional. +*/ +void +u3t_trace_close() +{ + if (!trace_file_u) + return; + + // We don't terminate the JSON because of the file format. + fclose(trace_file_u); } /* u3t_trace_time(): microsecond clock @@ -353,7 +365,7 @@ uint64_t u3t_trace_time() c3_o u3t_nock_trace_push(u3_noun lab) { - if (!trace_file) + if (!trace_file_u) return c3n; if ( (u3_nul == u3R->pro.trace) || @@ -425,7 +437,7 @@ trace_pretty(u3_noun som) void u3t_nock_trace_pop() { - if (!trace_file) + if (!trace_file_u) return; u3_noun trace = u3R->pro.trace; @@ -440,12 +452,12 @@ u3t_nock_trace_pop() if (duration > 33) { c3_c* name = trace_pretty(lab); - fprintf(trace_file, + fprintf(trace_file_u, "{\"cat\": \"nock\", \"name\": \"%s\", \"ph\":\"%c\", \"pid\": %d, " "\"tid\": 2, \"ts\": %" PRIu64 ", \"dur\": %" PRIu64 "}, \n", name, 'X', - nock_pid, + nock_pid_i, start_time, duration); @@ -460,15 +472,15 @@ u3t_nock_trace_pop() void u3t_event_trace(const char* name, char type) { - if (!trace_file) + if (!trace_file_u) return; - fprintf(trace_file, + fprintf(trace_file_u, "{\"cat\": \"event\", \"name\": \"%s\", \"ph\":\"%c\", \"pid\": %d, " "\"tid\": 1, \"ts\": %" PRIu64 ", \"id\": \"0x100\"}, \n", name, type, - nock_pid, + nock_pid_i, u3t_trace_time()); } diff --git a/vere/loop.c b/vere/loop.c index 84b582edc..59cc76f70 100644 --- a/vere/loop.c +++ b/vere/loop.c @@ -252,6 +252,11 @@ u3_lo_exit(void) cod_l = u3a_lush(c3__behn); u3_behn_io_exit(); u3a_lop(cod_l); + + if ( c3y == __(u3C.wag_w & u3o_trace) ) { + printf("saving trace file.\r\n"); + u3t_trace_close(); + } } #if 0 From ee38b881887b4238b21c1859f308fc92ef2654d9 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 4 Dec 2018 15:59:33 -0800 Subject: [PATCH 092/157] Cleanup --- noun/trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noun/trace.c b/noun/trace.c index 51dfd0f66..4ef31bb5e 100644 --- a/noun/trace.c +++ b/noun/trace.c @@ -351,7 +351,7 @@ u3t_trace_close() /* u3t_trace_time(): microsecond clock */ -uint64_t u3t_trace_time() +c3_d u3t_trace_time() { struct timeval tim_tv; gettimeofday(&tim_tv, 0); @@ -448,7 +448,7 @@ u3t_nock_trace_pop() c3_d start_time = u3r_chub(0, u3t(item)); // 33microseconds (a 30th of a millisecond). - uint64_t duration = u3t_trace_time() - start_time; + c3_d duration = u3t_trace_time() - start_time; if (duration > 33) { c3_c* name = trace_pretty(lab); From 36f2152e614d415edb771767556095ac993a957e Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 4 Dec 2018 16:20:22 -0800 Subject: [PATCH 093/157] Move more chars. --- include/noun/trace.h | 2 +- noun/trace.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/noun/trace.h b/include/noun/trace.h index e8ba7348a..0654862d0 100644 --- a/include/noun/trace.h +++ b/include/noun/trace.h @@ -107,7 +107,7 @@ /* u3t_event_trace(): record a lifecycle event. */ void - u3t_event_trace(const char* name, char type); + u3t_event_trace(const c3_c* name, c3_c type); /* u3t_damp(): print and clear profile data. */ diff --git a/noun/trace.c b/noun/trace.c index 4ef31bb5e..30c3a31a9 100644 --- a/noun/trace.c +++ b/noun/trace.c @@ -470,7 +470,7 @@ u3t_nock_trace_pop() /* u3t_event_trace(): dumps a simple event from outside nock. */ void -u3t_event_trace(const char* name, char type) +u3t_event_trace(const c3_c* name, c3_c type) { if (!trace_file_u) return; From e611cc34c46923f2b612ac496bc7e2fac40658a1 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 4 Dec 2018 15:58:52 -0800 Subject: [PATCH 094/157] Use +slaw instead of +slay. --- vere/reck.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/vere/reck.c b/vere/reck.c index 8c29c5f94..2df328488 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -27,20 +27,18 @@ _reck_mole(u3_noun fot, u3_noun san, c3_d* ato_d) { - u3_noun uco = u3do("slay", san); - u3_noun p_uco, q_uco, r_uco, s_uco; + u3_noun uco = u3dc("slaw", fot, san); + u3_noun p_uco, q_uco; - if ( (c3n == u3r_qual(uco, &p_uco, &q_uco, &r_uco, &s_uco)) || - (0 != p_uco) || - (0 != q_uco) || - (c3n == u3r_sing(fot, r_uco)) ) + if ( (c3n == u3r_cell(uco, &p_uco, &q_uco)) || + (0 != p_uco) ) { uL(fprintf(uH, "strange mole %s\n", u3r_string(san))); u3z(fot); u3z(uco); return c3n; } else { - *ato_d = u3r_chub(0, s_uco); + *ato_d = u3r_chub(0, q_uco); u3z(fot); u3z(uco); return c3y; } From 39eb89d66b5ee60f15179652c91c28622a862b26 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 4 Dec 2018 16:40:19 -0800 Subject: [PATCH 095/157] Use u3_nul --- vere/reck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vere/reck.c b/vere/reck.c index 2df328488..d8bb694c1 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -31,7 +31,7 @@ _reck_mole(u3_noun fot, u3_noun p_uco, q_uco; if ( (c3n == u3r_cell(uco, &p_uco, &q_uco)) || - (0 != p_uco) ) + (u3_nul != p_uco) ) { uL(fprintf(uH, "strange mole %s\n", u3r_string(san))); From 384a2a15550e972418beeda4be85b509b01feba3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 3 Dec 2018 14:18:41 -0500 Subject: [PATCH 096/157] moves ethereum-integrated pre-boot validation to vere/dawn --- include/vere/vere.h | 11 ++ meson.build | 1 + vere/dawn.c | 444 ++++++++++++++++++++++++++++++++++++++++++++ vere/sist.c | 423 +---------------------------------------- 4 files changed, 458 insertions(+), 421 deletions(-) create mode 100644 vere/dawn.c diff --git a/include/vere/vere.h b/include/vere/vere.h index c1f6935e9..9d81e4e83 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -1197,3 +1197,14 @@ */ void u3_cttp_io_exit(void); + + + /* u3_dawn_come(): mine a comet under star (unit) + */ + u3_noun + u3_dawn_come(u3_noun star); + + /* u3_dawn_vent(): validatated boot event + */ + u3_noun + u3_dawn_vent(u3_noun seed); diff --git a/meson.build b/meson.build index 405bd0d50..a4925d434 100644 --- a/meson.build +++ b/meson.build @@ -213,6 +213,7 @@ vere_sans_main = [ 'vere/ames.c', 'vere/behn.c', 'vere/cttp.c', + 'vere/dawn.c', 'vere/http.c', 'vere/loop.c', 'vere/raft.c', diff --git a/vere/dawn.c b/vere/dawn.c new file mode 100644 index 000000000..45252861b --- /dev/null +++ b/vere/dawn.c @@ -0,0 +1,444 @@ +/* vere/dawn.c +** +** ethereum-integrated pre-boot validation +*/ +#include +#include +#include +#include "all.h" +#include "vere/vere.h" + +/* _dawn_curl_alloc(): allocate a response buffer for curl +*/ +static size_t +_dawn_curl_alloc(void* dat_v, size_t uni_t, size_t mem_t, uv_buf_t* buf_u) +{ + size_t siz_t = uni_t * mem_t; + buf_u->base = realloc(buf_u->base, 1 + siz_t + buf_u->len); + + if ( 0 == buf_u->base ) { + fprintf(stderr, "out of memory\n"); + u3_lo_bail(); + } + + memcpy(buf_u->base + buf_u->len, dat_v, siz_t); + buf_u->len += siz_t; + buf_u->base[buf_u->len] = 0; + + return siz_t; +} + +/* _dawn_post_json(): POST JSON to url_c +*/ +static uv_buf_t +_dawn_post_json(c3_c* url_c, uv_buf_t lod_u) +{ + CURL *curl; + CURLcode result; + long cod_l; + struct curl_slist* hed_u = 0; + + uv_buf_t buf_u = uv_buf_init(c3_malloc(1), 0); + + if ( !(curl = curl_easy_init()) ) { + fprintf(stderr, "failed to initialize libcurl\n"); + u3_lo_bail(); + } + + hed_u = curl_slist_append(hed_u, "Accept: application/json"); + hed_u = curl_slist_append(hed_u, "Content-Type: application/json"); + hed_u = curl_slist_append(hed_u, "charsets: utf-8"); + + // XX require TLS, pin default cert? + + curl_easy_setopt(curl, CURLOPT_URL, url_c); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _dawn_curl_alloc); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&buf_u); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, hed_u); + + // note: must be terminated! + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, lod_u.base); + + result = curl_easy_perform(curl); + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &cod_l); + + // XX retry? + if ( CURLE_OK != result ) { + fprintf(stderr, "failed to fetch %s: %s\n", + url_c, curl_easy_strerror(result)); + u3_lo_bail(); + } + if ( 300 <= cod_l ) { + fprintf(stderr, "error fetching %s: HTTP %ld\n", url_c, cod_l); + u3_lo_bail(); + } + + curl_easy_cleanup(curl); + curl_slist_free_all(hed_u); + + return buf_u; +} + +/* _dawn_oct_to_buf(): +octs to uv_buf_t +*/ +static uv_buf_t +_dawn_oct_to_buf(u3_noun oct) +{ + if ( c3n == u3a_is_cat(u3h(oct)) ) { + u3_lo_bail(); + } + + c3_w len_w = u3h(oct); + c3_y* buf_y = c3_malloc(1 + len_w); + buf_y[len_w] = 0; + + u3r_bytes(0, len_w, buf_y, u3t(oct)); + + u3z(oct); + return uv_buf_init((void*)buf_y, len_w); +} + +/* _dawn_buf_to_oct(): uv_buf_t to +octs +*/ +static u3_noun +_dawn_buf_to_oct(uv_buf_t buf_u) +{ + u3_noun len = u3i_words(1, (c3_w*)&buf_u.len); + + if ( c3n == u3a_is_cat(len) ) { + u3_lo_bail(); + } + + return u3nc(len, u3i_bytes(buf_u.len, (const c3_y*)buf_u.base)); +} + +/* _dawn_eth_rpc(): ethereum JSON RPC with request/response as +octs +*/ +static u3_noun +_dawn_eth_rpc(c3_c* url_c, u3_noun oct) +{ + return _dawn_buf_to_oct(_dawn_post_json(url_c, _dawn_oct_to_buf(oct))); +} + +/* _dawn_fail(): pre-boot validation failed +*/ +static void +_dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) +{ + u3_noun how = u3dc("scot", 'p', u3k(who)); + c3_c* how_c = u3r_string(u3k(how)); + + c3_c* rac_c; + + switch (rac) { + default: c3_assert(0); + case c3__czar: { + rac_c = "galaxy"; + break; + } + case c3__king: { + rac_c = "star"; + break; + } + case c3__duke: { + rac_c = "planet"; + break; + } + case c3__earl: { + rac_c = "moon"; + break; + } + case c3__pawn: { + rac_c = "comet"; + break; + } + } + + fprintf(stderr, "dawn: invalid keys for %s '%s'\r\n", rac_c, how_c); + + // XX deconstruct sas, print helpful error messages + u3m_p("pre-boot error", u3t(sas)); + + u3z(how); + free(how_c); + u3_lo_bail(); +} + +/* _dawn_purl(): ethereum gateway url as (unit purl) +*/ +static u3_noun +_dawn_purl(u3_noun rac) +{ + u3_noun url; + + if ( 0 == u3_Host.ops_u.eth_c ) { + if ( c3__czar == rac ) { + fprintf(stderr, "boot: galaxy requires ethereum gateway via -e\r\n"); + u3_lo_bail(); + } + + url = u3_nul; + } + else { + // XX call de-purl directly + // + u3_noun par = u3v_wish("auru:de-purl:html"); + u3_noun lur = u3i_string(u3_Host.ops_u.eth_c); + u3_noun rul = u3dc("rush", u3k(lur), u3k(par)); + + if ( u3_nul == rul ) { + if ( c3__czar == rac ) { + fprintf(stderr, "boot: galaxy requires ethereum gateway via -e\r\n"); + u3_lo_bail(); + } + + url = u3_nul; + } + else { + // XX revise for de-purl + // auru:de-purl:html parses to (pair user purl) + // we need (unit purl) + // + url = u3nc(u3_nul, u3k(u3t(u3t(rul)))); + } + + u3z(par); u3z(lur); u3z(rul); + } + + return url; +} + +/* _dawn_turf(): override contract domains with -H +*/ +static u3_noun +_dawn_turf(c3_c* dns_c) +{ + u3_noun tuf; + + u3_noun par = u3v_wish("thos:de-purl:html"); + u3_noun dns = u3i_string(dns_c); + u3_noun rul = u3dc("rush", u3k(dns), u3k(par)); + + if ( (u3_nul == rul) || (c3n == u3h(u3t(rul))) ) { + fprintf(stderr, "boot: invalid domain specified with -H %s\r\n", dns_c); + // bails, won't return + u3_lo_bail(); + return u3_none; + } + else { + fprintf(stderr, "boot: overriding network domains with %s\r\n", dns_c); + u3_noun dom = u3t(u3t(rul)); + tuf = u3nc(u3k(dom), u3_nul); + } + + u3z(par); u3z(dns); u3z(rul); + + return tuf; +} + +/* u3_dawn_vent(): validatated boot event +*/ +u3_noun +u3_dawn_vent(u3_noun seed) +{ + u3_noun url, bok, pon, zar, tuf, sap; + + u3_noun ship = u3h(seed); + u3_noun rank = u3do("clan:title", u3k(ship)); + + // load snapshot if exists + // + if ( 0 != u3_Host.ops_u.ets_c ) { + fprintf(stderr, "boot: loading ethereum snapshot\r\n"); + u3_noun raw_snap = u3ke_cue(u3m_file(u3_Host.ops_u.ets_c)); + sap = u3nc(u3_nul, raw_snap); + } + else { + sap = u3_nul; + } + + url = _dawn_purl(rank); + + // XX require https? + // + c3_c* url_c = ( 0 != u3_Host.ops_u.eth_c ) ? + u3_Host.ops_u.eth_c : + "https://ropsten.infura.io/v3/196a7f37c7d54211b4a07904ec73ad87"; + + // pin block number + // + if ( c3y == u3_Host.ops_u.etn ) { + fprintf(stderr, "boot: extracting block from snapshot\r\n"); + bok = u3do("bloq:snap:dawn", u3k(u3t(sap))); + } + else { + fprintf(stderr, "boot: retrieving latest block\r\n"); + + u3_noun oct = u3v_wish("bloq:give:dawn"); + u3_noun kob = _dawn_eth_rpc(url_c, u3k(oct)); + bok = u3do("bloq:take:dawn", u3k(kob)); + + u3z(oct); u3z(kob); + } + + { + // +hull:constitution:ethe: on-chain state + // + u3_noun hul; + + if ( c3y == u3_Host.ops_u.etn ) { + hul = u3dc("hull:snap:dawn", u3k(ship), u3k(u3t(sap))); + } + else if ( c3__pawn == rank ) { + // irrelevant, just bunt +hull + // + hul = u3v_wish("*hull:constitution:ethe"); + } + else { + u3_noun oct; + + if ( c3__earl == rank ) { + u3_noun seg = u3do("^sein:title", u3k(ship)); + u3_noun ges = u3dc("scot", 'p', u3k(seg)); + c3_c* seg_c = u3r_string(ges); + + fprintf(stderr, "boot: retrieving %s's public keys (for %s)\r\n", + seg_c, u3_Host.ops_u.who_c); + oct = u3dc("hull:give:dawn", u3k(bok), u3k(seg)); + + free(seg_c); + u3z(seg); u3z(ges); + } + else { + fprintf(stderr, "boot: retrieving %s's public keys\r\n", + u3_Host.ops_u.who_c); + oct = u3dc("hull:give:dawn", u3k(bok), u3k(ship)); + } + + u3_noun luh = _dawn_eth_rpc(url_c, u3k(oct)); + hul = u3dc("hull:take:dawn", u3k(ship), u3k(luh)); + + u3z(oct); u3z(luh); + } + + // +live:dawn: network state + // XX actually make request + // + u3_noun liv = u3_nul; + // u3_noun liv = _dawn_get_json(parent, /some/url) + + fprintf(stderr, "boot: verifying keys\r\n"); + + // (each sponsor=(unit ship) error=@tas) + // + u3_noun sas = u3dt("veri:dawn", u3k(seed), u3k(hul), u3k(liv)); + + if ( c3n == u3h(sas) ) { + // bails, won't return + _dawn_fail(ship, rank, sas); + return u3_none; + } + + // (unit ship): sponsor + // produced by +veri:dawn to avoid coupling to +hull structure + // XX reconsider + // + pon = u3k(u3t(sas)); + + u3z(hul); u3z(liv); u3z(sas); + } + + // (map ship [=life =pass]): galaxy table + // + if ( c3y == u3_Host.ops_u.etn ) { + zar = u3do("czar:snap:dawn", u3k(u3t(sap))); + } + else { + fprintf(stderr, "boot: retrieving galaxy table\r\n"); + + u3_noun oct = u3do("czar:give:dawn", u3k(bok)); + u3_noun raz = _dawn_eth_rpc(url_c, u3k(oct)); + zar = u3do("czar:take:dawn", u3k(raz)); + + u3z(oct); u3z(raz); + } + + // (list turf): ames domains + // + if ( 0 != u3_Host.ops_u.dns_c ) { + tuf = _dawn_turf(u3_Host.ops_u.dns_c); + } + else if ( c3y == u3_Host.ops_u.etn ) { + tuf = u3do("turf:snap:dawn", u3k(u3t(sap))); + } + else { + fprintf(stderr, "boot: retrieving network domains\r\n"); + + u3_noun oct = u3do("turf:give:dawn", u3k(bok)); + u3_noun fut = _dawn_eth_rpc(url_c, u3k(oct)); + tuf = u3do("turf:take:dawn", u3k(fut)); + + u3z(oct); u3z(fut); + } + + u3z(rank); + + // [%dawn seed sponsor galaxies domains block eth-url snap] + // + return u3nc(c3__dawn, u3nq(seed, pon, zar, u3nq(tuf, bok, url, sap))); +} + +/* u3_dawn_come(): mine a comet under star (unit) +*/ +u3_noun +u3_dawn_come(u3_noun star) +{ + u3_noun seed; + + if ( u3_nul == star ) { + // XX ~marzod hardcoded + // choose from list, at random, &c + // + star = 256; + } + else { + // XX parse and validate + // + u3_noun tar = u3k(u3t(star)); + u3z(star); + star = tar; + } + + { + u3_noun sar = u3dc("scot", 'p', u3k(star)); + c3_c* tar_c = u3r_string(sar); + + fprintf(stderr, "boot: mining a comet under %s\r\n", tar_c); + free(tar_c); + u3z(sar); + } + + { + c3_w eny_w[16]; + u3_noun eny; + + c3_rand(eny_w); + eny = u3i_words(16, eny_w); + + seed = u3dc("come:dawn", u3k(star), u3k(eny)); + u3z(eny); + } + + { + u3_noun who = u3dc("scot", 'p', u3k(u3h(seed))); + c3_c* who_c = u3r_string(who); + + fprintf(stderr, "boot: found comet %s\r\n", who_c); + free(who_c); + u3z(who); + } + + u3z(star); + + return seed; +} diff --git a/vere/sist.c b/vere/sist.c index 4644ea551..965c6e402 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include "all.h" @@ -21,7 +20,6 @@ #define DEVRANDOM "/dev/random" #endif - /* u3_sist_pack(): write a blob to disk, transferring. */ c3_d @@ -1136,423 +1134,6 @@ _sist_rest() } } -/* _sist_curl_alloc(): allocate a response buffer for curl -*/ -static size_t -_sist_curl_alloc(void* dat_v, size_t uni_t, size_t mem_t, uv_buf_t* buf_u) -{ - size_t siz_t = uni_t * mem_t; - buf_u->base = realloc(buf_u->base, 1 + siz_t + buf_u->len); - - if ( 0 == buf_u->base ) { - fprintf(stderr, "out of memory\n"); - u3_lo_bail(); - } - - memcpy(buf_u->base + buf_u->len, dat_v, siz_t); - buf_u->len += siz_t; - buf_u->base[buf_u->len] = 0; - - return siz_t; -} - -/* _sist_post_json(): POST JSON to url_c -*/ -static uv_buf_t -_sist_post_json(c3_c* url_c, uv_buf_t lod_u) -{ - CURL *curl; - CURLcode result; - long cod_l; - struct curl_slist* hed_u = 0; - - uv_buf_t buf_u = uv_buf_init(c3_malloc(1), 0); - - if ( !(curl = curl_easy_init()) ) { - fprintf(stderr, "failed to initialize libcurl\n"); - u3_lo_bail(); - } - - hed_u = curl_slist_append(hed_u, "Accept: application/json"); - hed_u = curl_slist_append(hed_u, "Content-Type: application/json"); - hed_u = curl_slist_append(hed_u, "charsets: utf-8"); - - // XX require TLS, pin default cert? - - curl_easy_setopt(curl, CURLOPT_URL, url_c); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _sist_curl_alloc); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&buf_u); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, hed_u); - - // note: must be terminated! - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, lod_u.base); - - result = curl_easy_perform(curl); - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &cod_l); - - // XX retry? - if ( CURLE_OK != result ) { - fprintf(stderr, "failed to fetch %s: %s\n", - url_c, curl_easy_strerror(result)); - u3_lo_bail(); - } - if ( 300 <= cod_l ) { - fprintf(stderr, "error fetching %s: HTTP %ld\n", url_c, cod_l); - u3_lo_bail(); - } - - curl_easy_cleanup(curl); - curl_slist_free_all(hed_u); - - return buf_u; -} - -/* _sist_oct_to_buf(): +octs to uv_buf_t -*/ -static uv_buf_t -_sist_oct_to_buf(u3_noun oct) -{ - if ( c3n == u3a_is_cat(u3h(oct)) ) { - u3_lo_bail(); - } - - c3_w len_w = u3h(oct); - c3_y* buf_y = c3_malloc(1 + len_w); - buf_y[len_w] = 0; - - u3r_bytes(0, len_w, buf_y, u3t(oct)); - - u3z(oct); - return uv_buf_init((void*)buf_y, len_w); -} - -/* _sist_buf_to_oct(): uv_buf_t to +octs -*/ -static u3_noun -_sist_buf_to_oct(uv_buf_t buf_u) -{ - u3_noun len = u3i_words(1, (c3_w*)&buf_u.len); - - if ( c3n == u3a_is_cat(len) ) { - u3_lo_bail(); - } - - return u3nc(len, u3i_bytes(buf_u.len, (const c3_y*)buf_u.base)); -} - -/* _sist_eth_rpc(): ethereum JSON RPC with request/response as +octs -*/ -static u3_noun -_sist_eth_rpc(c3_c* url_c, u3_noun oct) -{ - return _sist_buf_to_oct(_sist_post_json(url_c, _sist_oct_to_buf(oct))); -} - -/* _sist_dawn_fail(): pre-boot validation failed -*/ -static void -_sist_dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) -{ - u3_noun how = u3dc("scot", 'p', u3k(who)); - c3_c* how_c = u3r_string(u3k(how)); - - c3_c* rac_c; - - switch (rac) { - default: c3_assert(0); - case c3__czar: { - rac_c = "galaxy"; - break; - } - case c3__king: { - rac_c = "star"; - break; - } - case c3__duke: { - rac_c = "planet"; - break; - } - case c3__earl: { - rac_c = "moon"; - break; - } - case c3__pawn: { - rac_c = "comet"; - break; - } - } - - fprintf(stderr, "dawn: invalid keys for %s '%s'\r\n", rac_c, how_c); - - // XX deconstruct sas, print helpful error messages - u3m_p("pre-boot error", u3t(sas)); - - u3z(how); - free(how_c); - u3_lo_bail(); -} - -/* _sist_dawn_turf(): override contract domains with -H -*/ -static u3_noun -_sist_dawn_turf(c3_c* dns_c) -{ - u3_noun tuf; - - u3_noun par = u3v_wish("thos:de-purl:html"); - u3_noun dns = u3i_string(dns_c); - u3_noun rul = u3dc("rush", u3k(dns), u3k(par)); - - if ( (u3_nul == rul) || (c3n == u3h(u3t(rul))) ) { - fprintf(stderr, "boot: invalid domain specified with -H %s\r\n", dns_c); - // bails, won't return - u3_lo_bail(); - return u3_none; - } - else { - fprintf(stderr, "boot: overriding network domains with %s\r\n", dns_c); - u3_noun dom = u3t(u3t(rul)); - tuf = u3nc(u3k(dom), u3_nul); - } - - u3z(par); u3z(dns); u3z(rul); - - return tuf; -} - -/* _sist_dawn(): produce %dawn boot card - validate keys and query contract -*/ -static u3_noun -_sist_dawn(u3_noun sed) -{ - u3_noun url, bok, pon, zar, tuf, sap; - - u3_noun who = u3h(sed); - u3_noun rac = u3do("clan:title", u3k(who)); - - // load snapshot if exists - if ( 0 != u3_Host.ops_u.ets_c ) { - fprintf(stderr, "boot: loading ethereum snapshot\r\n"); - u3_noun raw_snap = u3ke_cue(u3m_file(u3_Host.ops_u.ets_c)); - sap = u3nc(u3_nul, raw_snap); - } - else { - sap = u3_nul; - } - - // ethereum gateway as (unit purl) - if ( 0 == u3_Host.ops_u.eth_c ) { - if ( c3__czar == rac ) { - fprintf(stderr, "boot: galaxy requires ethereum gateway via -e\r\n"); - // bails, won't return - u3_lo_bail(); - return u3_none; - } - - url = u3_nul; - } - else { - u3_noun par = u3v_wish("auru:de-purl:html"); - u3_noun lur = u3i_string(u3_Host.ops_u.eth_c); - u3_noun rul = u3dc("rush", u3k(lur), u3k(par)); - - if ( u3_nul == rul ) { - if ( c3__czar == rac ) { - fprintf(stderr, "boot: galaxy requires ethereum gateway via -e\r\n"); - // bails, won't return - u3_lo_bail(); - return u3_none; - } - - url = u3_nul; - } - else { - // auru:de-purl:html parses to (pair user purl) - // we need (unit purl) - // (we're using it to avoid the +hoke weirdness) - // XX revisit upon merging with release-candidate - url = u3nc(u3_nul, u3k(u3t(u3t(rul)))); - } - - u3z(par); u3z(lur); u3z(rul); - } - - // XX require https? - c3_c* url_c = ( 0 != u3_Host.ops_u.eth_c ) ? - u3_Host.ops_u.eth_c : - "https://ropsten.infura.io/v3/196a7f37c7d54211b4a07904ec73ad87"; - - { - fprintf(stderr, "boot: retrieving latest block\r\n"); - - if ( c3y == u3_Host.ops_u.etn ) { - bok = u3do("bloq:snap:dawn", u3k(u3t(sap))); - } - else { - // @ud: block number - u3_noun oct = u3v_wish("bloq:give:dawn"); - u3_noun kob = _sist_eth_rpc(url_c, u3k(oct)); - bok = u3do("bloq:take:dawn", u3k(kob)); - - u3z(oct); u3z(kob); - } - } - - { - // +hull:constitution:ethe: on-chain state - u3_noun hul; - - if ( c3y == u3_Host.ops_u.etn ) { - hul = u3dc("hull:snap:dawn", u3k(who), u3k(u3t(sap))); - } - else { - if ( c3__pawn == rac ) { - // irrelevant, just bunt +hull - hul = u3v_wish("*hull:constitution:ethe"); - } - else { - u3_noun oct; - - if ( c3__earl == rac ) { - u3_noun seg = u3do("^sein:title", u3k(who)); - u3_noun ges = u3dc("scot", 'p', u3k(seg)); - c3_c* seg_c = u3r_string(ges); - - fprintf(stderr, "boot: retrieving %s's public keys (for %s)\r\n", - seg_c, u3_Host.ops_u.who_c); - oct = u3dc("hull:give:dawn", u3k(bok), u3k(seg)); - - free(seg_c); - u3z(seg); u3z(ges); - } - else { - fprintf(stderr, "boot: retrieving %s's public keys\r\n", - u3_Host.ops_u.who_c); - oct = u3dc("hull:give:dawn", u3k(bok), u3k(who)); - } - - u3_noun luh = _sist_eth_rpc(url_c, u3k(oct)); - hul = u3dc("hull:take:dawn", u3k(who), u3k(luh)); - - u3z(oct); u3z(luh); - } - } - - // +live:dawn: network state - // XX actually make request - // u3_noun liv = _sist_get_json(parent, /some/url) - u3_noun liv = u3_nul; - - fprintf(stderr, "boot: verifying keys\r\n"); - - // (each sponsor=(unit ship) error=@tas) - u3_noun sas = u3dt("veri:dawn", u3k(sed), u3k(hul), u3k(liv)); - - if ( c3n == u3h(sas) ) { - // bails, won't return - _sist_dawn_fail(who, rac, sas); - return u3_none; - } - - // (unit ship): sponsor - // produced by +veri:dawn to avoid coupling to +hull structure - pon = u3k(u3t(sas)); - - u3z(hul); u3z(liv); u3z(sas); - } - - { - if ( c3y == u3_Host.ops_u.etn ) { - zar = u3do("czar:snap:dawn", u3k(u3t(sap))); - - if ( 0 != u3_Host.ops_u.dns_c ) { - tuf = _sist_dawn_turf(u3_Host.ops_u.dns_c); - } - else { - tuf = u3do("turf:snap:dawn", u3k(u3t(sap))); - } - } - else { - { - fprintf(stderr, "boot: retrieving galaxy table\r\n"); - - // (map ship [=life =pass]): galaxy table - u3_noun oct = u3do("czar:give:dawn", u3k(bok)); - u3_noun raz = _sist_eth_rpc(url_c, u3k(oct)); - zar = u3do("czar:take:dawn", u3k(raz)); - - u3z(oct); u3z(raz); - } - - if ( 0 != u3_Host.ops_u.dns_c ) { - tuf = _sist_dawn_turf(u3_Host.ops_u.dns_c); - } - else { - fprintf(stderr, "boot: retrieving network domains\r\n"); - - // (list turf): ames domains - u3_noun oct = u3do("turf:give:dawn", u3k(bok)); - u3_noun fut = _sist_eth_rpc(url_c, u3k(oct)); - tuf = u3do("turf:take:dawn", u3k(fut)); - - u3z(oct); u3z(fut); - } - } - } - - u3z(rac); - - // [%dawn seed sponsor galaxies domains block eth-url snap] - return u3nc(c3__dawn, u3nq(sed, pon, zar, u3nq(tuf, bok, url, sap))); -} - -/* _sist_zen(): get OS entropy. -*/ -static u3_noun -_sist_zen(void) -{ - c3_w rad_w[16]; - - c3_rand(rad_w); - return u3i_words(16, rad_w); -} - -/* _sist_come(): mine a comet. -*/ -static u3_noun -_sist_come(void) -{ - u3_noun tar, eny, sed; - - // XX choose from list, at random, &c - tar = u3dc("slav", 'p', u3i_string("~marzod")); - eny = _sist_zen(); - - { - u3_noun sar = u3dc("scot", 'p', u3k(tar)); - c3_c* tar_c = u3r_string(sar); - - fprintf(stderr, "boot: mining a comet under %s\r\n", tar_c); - free(tar_c); - u3z(sar); - } - - sed = u3dc("come:dawn", u3k(tar), u3k(eny)); - - { - u3_noun who = u3dc("scot", 'p', u3k(u3h(sed))); - c3_c* who_c = u3r_string(who); - - fprintf(stderr, "boot: found comet %s\r\n", who_c); - free(who_c); - u3z(who); - } - - u3z(tar); u3z(eny); - - return sed; -} - /* sist_key(): parse a private key-file. */ static u3_noun @@ -1669,11 +1250,11 @@ u3_sist_boot(void) sed = sist_key(des); } else { - sed = _sist_come(); + sed = u3_dawn_come(u3_nul); } u3A->fak = c3n; - pig = _sist_dawn(u3k(sed)); + pig = u3_dawn_vent(u3k(sed)); who = u3k(u3h(u3h(u3t(pig)))); u3z(sed); From 511ff89f808dc04a15367185047a984fb67a34db Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 5 Dec 2018 15:52:16 -0500 Subject: [PATCH 097/157] add entropy to arvo with %wack --- include/c/motes.h | 1 + vere/sist.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/c/motes.h b/include/c/motes.h index f05f716ba..d833c94ea 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -1187,6 +1187,7 @@ # define c3__void c3_s4('v','o','i','d') # define c3__vorp c3_s4('v','o','r','p') # define c3__way c3_s3('w','a','y') +# define c3__wack c3_s4('w','a','c','k') # define c3__wail c3_s4('w','a','i','l') # define c3__wake c3_s4('w','a','k','e') # define c3__wamp c3_s4('w','a','m','p') diff --git a/vere/sist.c b/vere/sist.c index 620ead285..8bafa3d8f 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1608,6 +1608,19 @@ sist_key(u3_noun des) void u3_sist_boot(void) { + // iterate entropy + // + { + c3_w eny_w[16]; + u3_noun eny; + + c3_rand(eny_w); + eny = u3i_words(16, eny_w); + + u3v_plan(u3nt(u3_blip, c3__arvo, u3_nul), u3nc(c3__wack, u3k(eny))); + u3z(eny); + } + if ( c3n == u3_Host.ops_u.nuu ) { _sist_rest(); From 591995934a8dd45735ee759142910bc966614224 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 5 Dec 2018 16:02:43 -0500 Subject: [PATCH 098/157] single-home arvo with %whom --- include/c/motes.h | 1 + vere/sist.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/c/motes.h b/include/c/motes.h index d833c94ea..78bd52e38 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -1202,6 +1202,7 @@ # define c3__werp c3_s4('w','e','r','p') # define c3__west c3_s4('w','e','s','t') # define c3__what c3_s4('w','h','a','t') +# define c3__whom c3_s4('w','h','o','m') # define c3__wing c3_s4('w','i','n','g') # define c3__wild c3_s4('w','i','l','d') # define c3__win c3_s3('w','i','n') diff --git a/vere/sist.c b/vere/sist.c index 8bafa3d8f..f78c39543 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1694,6 +1694,10 @@ u3_sist_boot(void) u3A->own = who; + // set single-home + // + u3v_plan(u3nt(u3_blip, c3__arvo, u3_nul), u3nc(c3__whom, u3k(who))); + // initialize ames { u3_noun tuf = (c3y == u3A->fak) ? u3_nul : u3h(u3t(u3t(u3t(u3t(pig))))); From cfca39542f64c9dbdd45468a4ae96e602d6be989 Mon Sep 17 00:00:00 2001 From: joshuareagan Date: Wed, 5 Dec 2018 22:24:44 -0600 Subject: [PATCH 099/157] type variance bug fix --- jets/f/ut_find.c | 76 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 10 deletions(-) diff --git a/jets/f/ut_find.c b/jets/f/ut_find.c index 7de284836..10a81529f 100644 --- a/jets/f/ut_find.c +++ b/jets/f/ut_find.c @@ -13,18 +13,74 @@ u3_noun lon, u3_noun gil); +/* `u3qfu_felt_arm` is a helper function for + * u3qfu_felt. It handles the case in which the + * opal is for an arm, and hence which needs a + * list of `hold`s. These will be converted to + * a `fork` type. +*/ static u3_noun - u3qfu_felt(u3_noun van, - u3_noun sut, - u3_noun lap) + u3qfu_felt_arm(u3_noun lis) { - u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_cook("u3qfu_felt-felt", von, "felt"); + if ( lis == u3_nul ) { + return u3_nul; + } else { + + u3_noun i_lis = u3h(lis); + u3_noun t_lis = u3t(lis); + u3_noun typ = u3h(i_lis); - return u3n_kick_on(u3i_molt(gat, - u3x_sam, - u3k(lap), - 0)); + u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ; + + if ( (c3n == u3du(typ)) || + (u3h(typ) != c3__core) ) { + return u3m_error("felt-core"); + } else if + ( (c3n == u3r_cell(u3t(typ), &p_typ, &q_typ)) || + (c3n == u3r_trel(q_typ, &pq_typ, &qq_typ, &rq_typ)) ) + { + return u3m_bail(c3__fail); + } else { + + u3_noun dox = u3nt(c3__core, u3k(qq_typ), u3k(q_typ)); + u3_noun par = u3nt(c3__hold, dox, u3nc(u3_nul, 1)); + u3_noun pro = u3nc(par, u3qfu_felt_arm(t_lis)); + + return pro; + } + } + } + +/* `u3qfu_felt` takes an opal, lap, and converts + * it to a type. The opal comes from the last + * limb of the wing processed by `+fond`. The + * type is used in +fond as the subject type of + * the next limb in the wing. +*/ + static u3_noun + u3qfu_felt(u3_noun lap) + { + u3_noun pro; + u3_noun lim = u3h(lap); + + if ( lim == c3y ) { + + u3_noun p_lap = u3t(lap); + pro = u3k(p_lap); + + } else if ( lim == c3n ) { + + u3_noun q_lap = u3t(u3t(lap)); + u3_noun lis = u3qdi_tap(q_lap); + u3_noun hos = u3qfu_felt_arm(lis); + + pro = u3kf_fork(hos); + u3z(lis); + + } else u3m_bail(c3__fail); + + u3z(lim); + return pro; } static u3_noun @@ -658,7 +714,7 @@ u3_noun qp_mor = u3t(p_mor); // opal { - u3_noun ref = u3qfu_felt(van, sut, qp_mor); + u3_noun ref = u3qfu_felt(qp_mor); u3_noun lon = u3k(pp_mor); u3_noun heg = (c3y == u3du(i_hyp)) ? u3k(i_hyp) From 4e244b92a843f0f6cd06230fc8b4996db8cb75f7 Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Wed, 5 Dec 2018 22:32:22 -0600 Subject: [PATCH 100/157] Update pin-arvo-commit.txt --- .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 dfd8a1c12..1214a0f18 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -cae4b03c5c95722fb0e5f1947ba988f72703816d +37de11cb061409968e587e96e28cbbe9067da236 From ec84e0abc2302dabd674d9712ed43e72cdac2296 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 5 Dec 2018 23:32:45 -0500 Subject: [PATCH 101/157] [CI] updates pinned arvo commit --- .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 dfd8a1c12..9f80a20e2 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -cae4b03c5c95722fb0e5f1947ba988f72703816d +1a4462123804e168d11e278f44af03cd2e0b8d7d From 56d26f486a53f82e4e69fd43bbe841c847e15c41 Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Wed, 5 Dec 2018 22:51:01 -0600 Subject: [PATCH 102/157] Update pin-arvo-commit.txt --- .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 1214a0f18..3c8e052bd 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -37de11cb061409968e587e96e28cbbe9067da236 +b8a4ab3f10c1039970901e56f5abe24301f38406 From 3c4e85fcee37b9765c3aaff4c98bb6933b007c7b Mon Sep 17 00:00:00 2001 From: joshuareagan Date: Wed, 5 Dec 2018 23:37:23 -0600 Subject: [PATCH 103/157] added shape checks --- jets/f/ut_find.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/jets/f/ut_find.c b/jets/f/ut_find.c index 10a81529f..209d1503b 100644 --- a/jets/f/ut_find.c +++ b/jets/f/ut_find.c @@ -24,10 +24,18 @@ { if ( lis == u3_nul ) { return u3_nul; - } else { + } + else if ( u3du(lis) != c3y ) { + return u3m_bail(c3__exit); + } + else + { u3_noun i_lis = u3h(lis); u3_noun t_lis = u3t(lis); + + if (u3du(i_lis) != c3y) u3m_bail(c3__exit); + u3_noun typ = u3h(i_lis); u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ; @@ -39,8 +47,9 @@ ( (c3n == u3r_cell(u3t(typ), &p_typ, &q_typ)) || (c3n == u3r_trel(q_typ, &pq_typ, &qq_typ, &rq_typ)) ) { - return u3m_bail(c3__fail); - } else { + return u3m_bail(c3__exit); + } else + { u3_noun dox = u3nt(c3__core, u3k(qq_typ), u3k(q_typ)); u3_noun par = u3nt(c3__hold, dox, u3nc(u3_nul, 1)); @@ -61,6 +70,9 @@ u3qfu_felt(u3_noun lap) { u3_noun pro; + + if (u3du(lap) != c3y) u3m_bail(c3__exit); + u3_noun lim = u3h(lap); if ( lim == c3y ) { @@ -70,16 +82,19 @@ } else if ( lim == c3n ) { - u3_noun q_lap = u3t(u3t(lap)); + u3_noun tal_lap = u3t(lap); + + if (u3du(tal_lap) != c3y) u3m_bail(c3__exit); + + u3_noun q_lap = u3t(tal_lap); u3_noun lis = u3qdi_tap(q_lap); u3_noun hos = u3qfu_felt_arm(lis); pro = u3kf_fork(hos); u3z(lis); - } else u3m_bail(c3__fail); + } else u3m_bail(c3__exit); - u3z(lim); return pro; } From def6538c08d4828fd2c6a8c7d8c503c86eec030c Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Wed, 5 Dec 2018 23:48:09 -0600 Subject: [PATCH 104/157] braces constants --- jets/f/ut_find.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/jets/f/ut_find.c b/jets/f/ut_find.c index 209d1503b..5f3c9a65a 100644 --- a/jets/f/ut_find.c +++ b/jets/f/ut_find.c @@ -22,10 +22,10 @@ static u3_noun u3qfu_felt_arm(u3_noun lis) { - if ( lis == u3_nul ) { + if ( u3_nul == lis ) { return u3_nul; } - else if ( u3du(lis) != c3y ) { + else if ( c3y != u3du(lis) ) { return u3m_bail(c3__exit); } else @@ -34,21 +34,23 @@ u3_noun i_lis = u3h(lis); u3_noun t_lis = u3t(lis); - if (u3du(i_lis) != c3y) u3m_bail(c3__exit); + if (c3y != u3du(i_lis)) { u3m_bail(c3__exit); } u3_noun typ = u3h(i_lis); u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ; if ( (c3n == u3du(typ)) || - (u3h(typ) != c3__core) ) { + (c3__core != u3h(typ)) ) { return u3m_error("felt-core"); - } else if + } + else if ( (c3n == u3r_cell(u3t(typ), &p_typ, &q_typ)) || (c3n == u3r_trel(q_typ, &pq_typ, &qq_typ, &rq_typ)) ) { return u3m_bail(c3__exit); - } else + } + else { u3_noun dox = u3nt(c3__core, u3k(qq_typ), u3k(q_typ)); @@ -71,20 +73,21 @@ { u3_noun pro; - if (u3du(lap) != c3y) u3m_bail(c3__exit); + if (c3y != u3du(lap)) { u3m_bail(c3__exit); } u3_noun lim = u3h(lap); - if ( lim == c3y ) { + if ( c3y == lim ) { u3_noun p_lap = u3t(lap); pro = u3k(p_lap); - } else if ( lim == c3n ) { + } + else if ( c3n == lim ) { u3_noun tal_lap = u3t(lap); - if (u3du(tal_lap) != c3y) u3m_bail(c3__exit); + if (u3du(tal_lap) != c3y) { u3m_bail(c3__exit); } u3_noun q_lap = u3t(tal_lap); u3_noun lis = u3qdi_tap(q_lap); @@ -93,7 +96,8 @@ pro = u3kf_fork(hos); u3z(lis); - } else u3m_bail(c3__exit); + } + else { u3m_bail(c3__exit); } return pro; } From 2769cb2ac9f9e5976fe1d58b72d378a2ed99f2da Mon Sep 17 00:00:00 2001 From: joshuareagan Date: Thu, 6 Dec 2018 01:01:27 -0600 Subject: [PATCH 105/157] using u3x functions --- jets/f/ut_find.c | 104 +++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 62 deletions(-) diff --git a/jets/f/ut_find.c b/jets/f/ut_find.c index 5f3c9a65a..f86b399d8 100644 --- a/jets/f/ut_find.c +++ b/jets/f/ut_find.c @@ -22,44 +22,34 @@ static u3_noun u3qfu_felt_arm(u3_noun lis) { - if ( u3_nul == lis ) { - return u3_nul; + if ( u3_nul == lis ) { + return u3_nul; + } + else if ( c3y != u3du(lis) ) { + return u3m_bail(c3__exit); + } + else + { + u3_noun i_lis, t_lis, fot, typ; + u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ; + + u3x_cell(lis, &i_lis, &t_lis); + u3x_cell(i_lis, &typ, &fot); + + if ( (c3n == u3du(typ)) || + (c3__core != u3h(typ)) ) { + return u3m_error("felt-core"); } - else if ( c3y != u3du(lis) ) { - return u3m_bail(c3__exit); - } - else - { - - u3_noun i_lis = u3h(lis); - u3_noun t_lis = u3t(lis); - - if (c3y != u3du(i_lis)) { u3m_bail(c3__exit); } - - u3_noun typ = u3h(i_lis); - - u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ; - - if ( (c3n == u3du(typ)) || - (c3__core != u3h(typ)) ) { - return u3m_error("felt-core"); - } - else if - ( (c3n == u3r_cell(u3t(typ), &p_typ, &q_typ)) || - (c3n == u3r_trel(q_typ, &pq_typ, &qq_typ, &rq_typ)) ) - { - return u3m_bail(c3__exit); - } - else - { - - u3_noun dox = u3nt(c3__core, u3k(qq_typ), u3k(q_typ)); - u3_noun par = u3nt(c3__hold, dox, u3nc(u3_nul, 1)); - u3_noun pro = u3nc(par, u3qfu_felt_arm(t_lis)); - - return pro; - } + else { + u3x_cell(u3t(typ), &p_typ, &q_typ); + u3x_trel(q_typ, &pq_typ, &qq_typ, &rq_typ); + + u3_noun dox = u3nt(c3__core, u3k(qq_typ), u3k(q_typ)); + u3_noun par = u3nt(c3__hold, dox, u3nc(u3_nul, 1)); + u3_noun pro = u3nc(par, u3qfu_felt_arm(t_lis)); + return pro; } + } } /* `u3qfu_felt` takes an opal, lap, and converts @@ -71,35 +61,25 @@ static u3_noun u3qfu_felt(u3_noun lap) { - u3_noun pro; + u3_noun pro, lim, mil; + u3x_cell(lap, &lim, &mil); - if (c3y != u3du(lap)) { u3m_bail(c3__exit); } - - u3_noun lim = u3h(lap); - - if ( c3y == lim ) { - - u3_noun p_lap = u3t(lap); - pro = u3k(p_lap); + if ( c3y == lim ) { + pro = u3k(mil); + } + else if ( c3n == lim ) { + u3_noun p_lap, q_lap; + u3x_cell(mil, &p_lap, &q_lap); + u3_noun lis = u3qdi_tap(q_lap); + u3_noun hos = u3qfu_felt_arm(lis); + pro = u3kf_fork(hos); + u3z(lis); } - else if ( c3n == lim ) { - - u3_noun tal_lap = u3t(lap); - - if (u3du(tal_lap) != c3y) { u3m_bail(c3__exit); } - - u3_noun q_lap = u3t(tal_lap); - u3_noun lis = u3qdi_tap(q_lap); - u3_noun hos = u3qfu_felt_arm(lis); - - pro = u3kf_fork(hos); - u3z(lis); - - } - else { u3m_bail(c3__exit); } - - return pro; + else { + u3m_bail(c3__exit); + } + return pro; } static u3_noun From 85ed15775b6fc10993001929d20c0a3ecbb36acb Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Thu, 6 Dec 2018 01:11:14 -0600 Subject: [PATCH 106/157] moving one brace --- jets/f/ut_find.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jets/f/ut_find.c b/jets/f/ut_find.c index f86b399d8..916fbf998 100644 --- a/jets/f/ut_find.c +++ b/jets/f/ut_find.c @@ -75,7 +75,7 @@ pro = u3kf_fork(hos); u3z(lis); - } + } else { u3m_bail(c3__exit); } From a9e760edb5e33cdfc0addd5781419968c11b3552 Mon Sep 17 00:00:00 2001 From: joshuareagan Date: Thu, 6 Dec 2018 02:00:35 -0600 Subject: [PATCH 107/157] removed superfluous lines --- jets/f/ut_find.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/jets/f/ut_find.c b/jets/f/ut_find.c index f86b399d8..e5300d861 100644 --- a/jets/f/ut_find.c +++ b/jets/f/ut_find.c @@ -25,11 +25,7 @@ if ( u3_nul == lis ) { return u3_nul; } - else if ( c3y != u3du(lis) ) { - return u3m_bail(c3__exit); - } - else - { + else { u3_noun i_lis, t_lis, fot, typ; u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ; @@ -38,7 +34,7 @@ if ( (c3n == u3du(typ)) || (c3__core != u3h(typ)) ) { - return u3m_error("felt-core"); + return u3m_error("felt-core"); } else { u3x_cell(u3t(typ), &p_typ, &q_typ); @@ -46,8 +42,7 @@ u3_noun dox = u3nt(c3__core, u3k(qq_typ), u3k(q_typ)); u3_noun par = u3nt(c3__hold, dox, u3nc(u3_nul, 1)); - u3_noun pro = u3nc(par, u3qfu_felt_arm(t_lis)); - return pro; + return u3nc(par, u3qfu_felt_arm(t_lis)); } } } @@ -75,7 +70,7 @@ pro = u3kf_fork(hos); u3z(lis); - } + } else { u3m_bail(c3__exit); } From ee483875bc37f5c9167d2c1e02dd030d23bca466 Mon Sep 17 00:00:00 2001 From: joshuareagan Date: Thu, 6 Dec 2018 02:15:18 -0600 Subject: [PATCH 108/157] removed more superfluous lines --- jets/f/ut_find.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/jets/f/ut_find.c b/jets/f/ut_find.c index e5300d861..a5312ef8c 100644 --- a/jets/f/ut_find.c +++ b/jets/f/ut_find.c @@ -56,11 +56,11 @@ static u3_noun u3qfu_felt(u3_noun lap) { - u3_noun pro, lim, mil; + u3_noun lim, mil; u3x_cell(lap, &lim, &mil); if ( c3y == lim ) { - pro = u3k(mil); + return u3k(mil); } else if ( c3n == lim ) { u3_noun p_lap, q_lap; @@ -68,13 +68,12 @@ u3_noun lis = u3qdi_tap(q_lap); u3_noun hos = u3qfu_felt_arm(lis); - pro = u3kf_fork(hos); u3z(lis); + return u3kf_fork(hos); } else { u3m_bail(c3__exit); } - return pro; } static u3_noun From a36b2a010e68d58f4f7d56dff9eab1c5ad48c276 Mon Sep 17 00:00:00 2001 From: joshuareagan Date: Thu, 6 Dec 2018 13:38:33 -0600 Subject: [PATCH 109/157] remove hold --- jets/f/ut_find.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/jets/f/ut_find.c b/jets/f/ut_find.c index a5312ef8c..bde859ee9 100644 --- a/jets/f/ut_find.c +++ b/jets/f/ut_find.c @@ -15,9 +15,9 @@ /* `u3qfu_felt_arm` is a helper function for * u3qfu_felt. It handles the case in which the - * opal is for an arm, and hence which needs a - * list of `hold`s. These will be converted to - * a `fork` type. + * opal is for an arm, by creating a list of + * parent core types. These will be converted to + * a single `fork` type. */ static u3_noun u3qfu_felt_arm(u3_noun lis) @@ -27,8 +27,6 @@ } else { u3_noun i_lis, t_lis, fot, typ; - u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ; - u3x_cell(lis, &i_lis, &t_lis); u3x_cell(i_lis, &typ, &fot); @@ -37,12 +35,12 @@ return u3m_error("felt-core"); } else { + u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ; u3x_cell(u3t(typ), &p_typ, &q_typ); u3x_trel(q_typ, &pq_typ, &qq_typ, &rq_typ); u3_noun dox = u3nt(c3__core, u3k(qq_typ), u3k(q_typ)); - u3_noun par = u3nt(c3__hold, dox, u3nc(u3_nul, 1)); - return u3nc(par, u3qfu_felt_arm(t_lis)); + return u3nc(dox, u3qfu_felt_arm(t_lis)); } } } @@ -63,10 +61,10 @@ return u3k(mil); } else if ( c3n == lim ) { - u3_noun p_lap, q_lap; + u3_noun p_lap, q_lap, lis, hos; u3x_cell(mil, &p_lap, &q_lap); - u3_noun lis = u3qdi_tap(q_lap); - u3_noun hos = u3qfu_felt_arm(lis); + lis = u3qdi_tap(q_lap); + hos = u3qfu_felt_arm(lis); u3z(lis); return u3kf_fork(hos); From 3fc14073e0ea99f2f3931ac4201357b53eb29b5e Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 5 Dec 2018 16:36:03 -0800 Subject: [PATCH 110/157] Write a jet for +sort Closes #387 --- jets/b/sort.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++--- jets/tree.c | 9 +++---- 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/jets/b/sort.c b/jets/b/sort.c index df08279e8..51d02c05a 100644 --- a/jets/b/sort.c +++ b/jets/b/sort.c @@ -6,13 +6,73 @@ /* functions */ + // like skid, except its callback is $-([* *] ?) and it takes the second + // argument so that it calls its callback with [i.list, second] + // + // all args are RETAINED + static u3_noun + _split_in(u3j_site* sit_u, + u3_noun a, + u3_noun second) + { + if ( 0 == a ) { + return u3nc(u3_nul, u3_nul); + } + else if ( c3n == u3du(a) ) { + return u3m_bail(c3__exit); + } else { + u3_noun acc = _split_in(sit_u, u3t(a), second); + u3_noun hoz = u3j_gate_slam(sit_u, u3nc(u3k(u3h(a)), u3k(second))); + u3_noun nex; + + if ( c3y == hoz ) { + nex = u3nc(u3nc(u3k(u3h(a)), u3k(u3h(acc))), u3k(u3t(acc))); + } + else { + nex = u3nc(u3k(u3h(acc)), u3nc(u3k(u3h(a)), u3k(u3t(acc)))); + } + u3z(hoz); + u3z(acc); + + return nex; + } + } + + static u3_noun + _sort_in(u3j_site* sit_u, u3_noun list) + { + if ( 0 == list ) { + return u3_nul; + } + else if ( c3n == u3du(list) ) { + return u3m_bail(c3__exit); + } else { + u3_noun hed, tal; + u3x_cell(list, &hed, &tal); + + u3_noun split = _split_in(sit_u, tal, hed); + u3_noun lhs = _sort_in(sit_u, u3h(split)); + u3_noun rhs = u3nc(u3k(hed), _sort_in(sit_u, u3t(split))); + + u3_noun ret = u3qb_weld(lhs, rhs); + u3z(lhs); + u3z(rhs); + u3z(split); + + return ret; + } + } + u3_noun u3qb_sort(u3_noun a, u3_noun b) { - // must think about - // - return u3m_bail(c3__fail); + u3_noun pro; + u3j_site sit_u; + u3j_gate_prep(&sit_u, u3k(b)); + pro = _sort_in(&sit_u, a); + u3j_gate_lose(&sit_u); + return pro; } u3_noun u3wb_sort(u3_noun cor) diff --git a/jets/tree.c b/jets/tree.c index a96baaded..254a7b465 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -797,11 +797,8 @@ static u3j_harm _141_two_slag_a[] = {{".2", u3wb_slag, c3y}, {}}; static c3_c* _141_two_slag_ha[] = {0}; static u3j_harm _141_two_snag_a[] = {{".2", u3wb_snag, c3y}, {}}; static c3_c* _141_two_snag_ha[] = {0}; - -// https://github.com/urbit/urbit/issues/387 -// static u3j_harm _141_two_sort_a[] = {{".2", u3wb_sort, c3y}, {}}; -// static c3_c* _141_two_sort_ha[] = {0}; - +static u3j_harm _141_two_sort_a[] = {{".2", u3wb_sort, c3y}, {}}; +static c3_c* _141_two_sort_ha[] = {0}; static u3j_harm _141_two_turn_a[] = {{".2", u3wb_turn, c3y}, {}}; static c3_c* _141_two_turn_ha[] = {0}; static u3j_harm _141_two_weld_a[] = {{".2", u3wb_weld, c3y}, {}}; @@ -972,7 +969,7 @@ static u3j_core _141_two_d[] = { "scag", 7, _141_two_scag_a, 0, _141_two_scag_ha }, { "slag", 7, _141_two_slag_a, 0, _141_two_slag_ha }, { "snag", 7, _141_two_snag_a, 0, _141_two_snag_ha }, - // { "sort", 7, _141_two_sort_a, 0, _141_two_sort_ha }, + { "sort", 7, _141_two_sort_a, 0, _141_two_sort_ha }, { "turn", 7, _141_two_turn_a, 0, _141_two_turn_ha }, { "weld", 7, _141_two_weld_a, 0, _141_two_weld_ha }, From 33b52c77c2549aff3576385d133e0466b3751c2c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 6 Dec 2018 19:08:08 -0500 Subject: [PATCH 111/157] [CI] updates pinned arvo commit --- .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 9f80a20e2..9d21e4199 100644 --- a/.travis/pin-arvo-commit.txt +++ b/.travis/pin-arvo-commit.txt @@ -1 +1 @@ -1a4462123804e168d11e278f44af03cd2e0b8d7d +6a1f32bb1984fa9329c072de09ba67b212c8dbed From 6a4fc7c9aed8384936a7cb0289fcf78ea4d6a864 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 7 Dec 2018 00:27:50 -0500 Subject: [PATCH 112/157] updates calls to the |take:dawn gates to handle units and bail on ~ --- vere/dawn.c | 84 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 19 deletions(-) diff --git a/vere/dawn.c b/vere/dawn.c index 45252861b..858a45f67 100644 --- a/vere/dawn.c +++ b/vere/dawn.c @@ -276,9 +276,19 @@ u3_dawn_vent(u3_noun seed) u3_noun oct = u3v_wish("bloq:give:dawn"); u3_noun kob = _dawn_eth_rpc(url_c, u3k(oct)); - bok = u3do("bloq:take:dawn", u3k(kob)); + u3_noun nit = u3do("bloq:take:dawn", u3k(kob)); - u3z(oct); u3z(kob); + if ( u3_nul == nit ) { + fprintf(stderr, "boot: block retrieval failed\r\n"); + // bails, won't return + u3_lo_bail(); + return u3_none; + } + else { + bok = u3k(u3t(nit)); + } + + u3z(oct); u3z(kob); u3z(nit); } { @@ -295,30 +305,46 @@ u3_dawn_vent(u3_noun seed) hul = u3v_wish("*hull:constitution:ethe"); } else { - u3_noun oct; + u3_noun who; if ( c3__earl == rank ) { - u3_noun seg = u3do("^sein:title", u3k(ship)); - u3_noun ges = u3dc("scot", 'p', u3k(seg)); - c3_c* seg_c = u3r_string(ges); + who = u3do("^sein:title", u3k(ship)); - fprintf(stderr, "boot: retrieving %s's public keys (for %s)\r\n", - seg_c, u3_Host.ops_u.who_c); - oct = u3dc("hull:give:dawn", u3k(bok), u3k(seg)); + { + u3_noun seg = u3dc("scot", 'p', u3k(who)); + c3_c* seg_c = u3r_string(seg); - free(seg_c); - u3z(seg); u3z(ges); + fprintf(stderr, "boot: retrieving %s's public keys (for %s)\r\n", + seg_c, u3_Host.ops_u.who_c); + + free(seg_c); + u3z(seg); + } } else { + who = u3k(ship); fprintf(stderr, "boot: retrieving %s's public keys\r\n", u3_Host.ops_u.who_c); - oct = u3dc("hull:give:dawn", u3k(bok), u3k(ship)); } - u3_noun luh = _dawn_eth_rpc(url_c, u3k(oct)); - hul = u3dc("hull:take:dawn", u3k(ship), u3k(luh)); + { + u3_noun oct = u3dc("hull:give:dawn", u3k(bok), u3k(who)); + u3_noun luh = _dawn_eth_rpc(url_c, u3k(oct)); + u3_noun nit = u3dc("hull:take:dawn", u3k(ship), u3k(luh)); - u3z(oct); u3z(luh); + if ( u3_nul == nit ) { + fprintf(stderr, "boot: public key retrieval failed\r\n"); + // bails, won't return + u3_lo_bail(); + return u3_none; + } + else { + hul = u3k(u3t(nit)); + } + + u3z(oct); u3z(luh); u3z(nit); + } + u3z(who); } // +live:dawn: network state @@ -358,9 +384,19 @@ u3_dawn_vent(u3_noun seed) u3_noun oct = u3do("czar:give:dawn", u3k(bok)); u3_noun raz = _dawn_eth_rpc(url_c, u3k(oct)); - zar = u3do("czar:take:dawn", u3k(raz)); + u3_noun nit = u3do("czar:take:dawn", u3k(raz)); - u3z(oct); u3z(raz); + if ( u3_nul == nit ) { + fprintf(stderr, "boot: galaxy table retrieval failed\r\n"); + // bails, won't return + u3_lo_bail(); + return u3_none; + } + else { + zar = u3k(u3t(nit)); + } + + u3z(oct); u3z(raz); u3z(nit); } // (list turf): ames domains @@ -376,9 +412,19 @@ u3_dawn_vent(u3_noun seed) u3_noun oct = u3do("turf:give:dawn", u3k(bok)); u3_noun fut = _dawn_eth_rpc(url_c, u3k(oct)); - tuf = u3do("turf:take:dawn", u3k(fut)); + u3_noun nit = u3do("turf:take:dawn", u3k(fut)); - u3z(oct); u3z(fut); + if ( u3_nul == nit ) { + fprintf(stderr, "boot: network domains retrieval failed\r\n"); + // bails, won't return + u3_lo_bail(); + return u3_none; + } + else { + tuf = u3k(u3t(nit)); + } + + u3z(oct); u3z(fut); u3z(nit); } u3z(rank); From 611d72d9579a3d2d3050b15753bb60f8c104a994 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 7 Dec 2018 01:51:10 -0500 Subject: [PATCH 113/157] refactors |take:dawn unit promotion --- vere/dawn.c | 80 +++++++++++++++++++++-------------------------------- 1 file changed, 31 insertions(+), 49 deletions(-) diff --git a/vere/dawn.c b/vere/dawn.c index 858a45f67..697ec2b0d 100644 --- a/vere/dawn.c +++ b/vere/dawn.c @@ -164,6 +164,24 @@ _dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) u3_lo_bail(); } +/* _dawn_need_unit(): produce a value or pail +*/ +static u3_noun +_dawn_need_unit(u3_noun nit, c3_c* msg_c) +{ + if ( u3_nul == nit ) { + fprintf(stderr, "%s\r\n", msg_c); + // bails, won't return + u3_lo_bail(); + return u3_none; + } + else { + u3_noun pro = u3k(u3t(nit)); + u3z(nit); + return pro; + } +} + /* _dawn_purl(): ethereum gateway url as (unit purl) */ static u3_noun @@ -276,19 +294,10 @@ u3_dawn_vent(u3_noun seed) u3_noun oct = u3v_wish("bloq:give:dawn"); u3_noun kob = _dawn_eth_rpc(url_c, u3k(oct)); - u3_noun nit = u3do("bloq:take:dawn", u3k(kob)); - if ( u3_nul == nit ) { - fprintf(stderr, "boot: block retrieval failed\r\n"); - // bails, won't return - u3_lo_bail(); - return u3_none; - } - else { - bok = u3k(u3t(nit)); - } - - u3z(oct); u3z(kob); u3z(nit); + bok = _dawn_need_unit(u3do("bloq:take:dawn", u3k(kob)), + "boot: block retrieval failed"); + u3z(oct); u3z(kob); } { @@ -316,7 +325,6 @@ u3_dawn_vent(u3_noun seed) fprintf(stderr, "boot: retrieving %s's public keys (for %s)\r\n", seg_c, u3_Host.ops_u.who_c); - free(seg_c); u3z(seg); } @@ -330,20 +338,12 @@ u3_dawn_vent(u3_noun seed) { u3_noun oct = u3dc("hull:give:dawn", u3k(bok), u3k(who)); u3_noun luh = _dawn_eth_rpc(url_c, u3k(oct)); - u3_noun nit = u3dc("hull:take:dawn", u3k(ship), u3k(luh)); - if ( u3_nul == nit ) { - fprintf(stderr, "boot: public key retrieval failed\r\n"); - // bails, won't return - u3_lo_bail(); - return u3_none; - } - else { - hul = u3k(u3t(nit)); - } - - u3z(oct); u3z(luh); u3z(nit); + hul = _dawn_need_unit(u3dc("hull:take:dawn", u3k(ship), u3k(luh)), + "boot: failed to retrieve public keys"); + u3z(oct); u3z(luh); } + u3z(who); } @@ -384,19 +384,10 @@ u3_dawn_vent(u3_noun seed) u3_noun oct = u3do("czar:give:dawn", u3k(bok)); u3_noun raz = _dawn_eth_rpc(url_c, u3k(oct)); - u3_noun nit = u3do("czar:take:dawn", u3k(raz)); - if ( u3_nul == nit ) { - fprintf(stderr, "boot: galaxy table retrieval failed\r\n"); - // bails, won't return - u3_lo_bail(); - return u3_none; - } - else { - zar = u3k(u3t(nit)); - } - - u3z(oct); u3z(raz); u3z(nit); + zar = _dawn_need_unit(u3do("czar:take:dawn", u3k(raz)), + "boot: failed to retrieve galaxy table"); + u3z(oct); u3z(raz); } // (list turf): ames domains @@ -412,19 +403,10 @@ u3_dawn_vent(u3_noun seed) u3_noun oct = u3do("turf:give:dawn", u3k(bok)); u3_noun fut = _dawn_eth_rpc(url_c, u3k(oct)); - u3_noun nit = u3do("turf:take:dawn", u3k(fut)); - if ( u3_nul == nit ) { - fprintf(stderr, "boot: network domains retrieval failed\r\n"); - // bails, won't return - u3_lo_bail(); - return u3_none; - } - else { - tuf = u3k(u3t(nit)); - } - - u3z(oct); u3z(fut); u3z(nit); + tuf = _dawn_need_unit(u3do("turf:take:dawn", u3k(fut)), + "boot: failed to retrieve network domains"); + u3z(oct); u3z(fut); } u3z(rank); From 55f792e8ab9d728379d7542cacd0feadd03cf69a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 7 Dec 2018 02:08:02 -0500 Subject: [PATCH 114/157] updates calls to the |snap:dawn gates to handle units --- vere/dawn.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/vere/dawn.c b/vere/dawn.c index 697ec2b0d..f4a2c31c6 100644 --- a/vere/dawn.c +++ b/vere/dawn.c @@ -287,7 +287,10 @@ u3_dawn_vent(u3_noun seed) // if ( c3y == u3_Host.ops_u.etn ) { fprintf(stderr, "boot: extracting block from snapshot\r\n"); - bok = u3do("bloq:snap:dawn", u3k(u3t(sap))); + + bok = _dawn_need_unit(u3do("bloq:snap:dawn", u3k(u3t(sap))), + "boot: failed to extract " + "block from snapshot"); } else { fprintf(stderr, "boot: retrieving latest block\r\n"); @@ -306,7 +309,11 @@ u3_dawn_vent(u3_noun seed) u3_noun hul; if ( c3y == u3_Host.ops_u.etn ) { - hul = u3dc("hull:snap:dawn", u3k(ship), u3k(u3t(sap))); + fprintf(stderr, "boot: extracting public keys from snapshot\r\n"); + + hul = _dawn_need_unit(u3dc("hull:snap:dawn", u3k(ship), u3k(u3t(sap))), + "boot: failed to extract " + "public keys from snapshot"); } else if ( c3__pawn == rank ) { // irrelevant, just bunt +hull @@ -377,7 +384,11 @@ u3_dawn_vent(u3_noun seed) // (map ship [=life =pass]): galaxy table // if ( c3y == u3_Host.ops_u.etn ) { - zar = u3do("czar:snap:dawn", u3k(u3t(sap))); + fprintf(stderr, "boot: extracting galaxy table from snapshot\r\n"); + + zar = _dawn_need_unit(u3do("czar:snap:dawn", u3k(u3t(sap))), + "boot: failed to extract " + "galaxy table from snapshot"); } else { fprintf(stderr, "boot: retrieving galaxy table\r\n"); @@ -396,7 +407,11 @@ u3_dawn_vent(u3_noun seed) tuf = _dawn_turf(u3_Host.ops_u.dns_c); } else if ( c3y == u3_Host.ops_u.etn ) { - tuf = u3do("turf:snap:dawn", u3k(u3t(sap))); + fprintf(stderr, "boot: extracting network domains from snapshot\r\n"); + + tuf = _dawn_need_unit(u3do("turf:snap:dawn", u3k(u3t(sap))), + "boot: failed to extract " + "network domains from snapshot"); } else { fprintf(stderr, "boot: retrieving network domains\r\n"); From eabeb4a200efd74a023197e6e6e15636dd0dda47 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 7 Dec 2018 14:15:35 -0500 Subject: [PATCH 115/157] corrects typo in comment --- vere/dawn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vere/dawn.c b/vere/dawn.c index f4a2c31c6..e18676372 100644 --- a/vere/dawn.c +++ b/vere/dawn.c @@ -164,7 +164,7 @@ _dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) u3_lo_bail(); } -/* _dawn_need_unit(): produce a value or pail +/* _dawn_need_unit(): produce a value or print error and exit */ static u3_noun _dawn_need_unit(u3_noun nit, c3_c* msg_c) From d6f02165a0cc4d75507ec5d87dfecb3b439c1fd6 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 8 Dec 2018 16:26:25 -0500 Subject: [PATCH 116/157] fixes use-after-free in _http_serv_start() --- vere/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vere/http.c b/vere/http.c index 4b56f0a8e..01ffc9b50 100644 --- a/vere/http.c +++ b/vere/http.c @@ -1017,11 +1017,11 @@ _http_serv_start(u3_http* htp_u) } uL(fprintf(uH, "http: listen: %s\n", uv_strerror(sas_i))); - _http_serv_free(htp_u); if ( 0 != htp_u->rox_u ) { _proxy_serv_free(htp_u->rox_u); } + _http_serv_free(htp_u); return; } From 295affdaad5c149bffb5ce311456474daf27589a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 8 Dec 2018 16:28:29 -0500 Subject: [PATCH 117/157] fixes memory leak in _sist_cask() --- vere/sist.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vere/sist.c b/vere/sist.c index 275eedb2c..aed41cd08 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -322,6 +322,8 @@ _sist_cask(c3_c* dir_c, u3_noun nun) strncat(say_c, paw_c, strlen(paw_c) - 1); say = u3do("slay", u3i_string(say_c)); + free(say_c); + if ( (u3_nul == say) || (u3_blip != u3h(u3t(say))) || ('p' != u3h(u3t(u3t(say)))) ) From 21224cc35933a7aefe7ca2e27a6949210bb985f2 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 8 Dec 2018 16:30:05 -0500 Subject: [PATCH 118/157] fixes memory leak in _cj_je_fsck() --- noun/jets.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/noun/jets.c b/noun/jets.c index 3fb353f70..67b15dccb 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -469,7 +469,12 @@ _cj_je_fsck(u3_noun clu) } } u3z(clu); - return u3nt(u3i_string(nam_c), axe_l, huk); + + { + u3_noun pro = u3nt(u3i_string(nam_c), axe_l, huk); + free(nam_c); + return pro; + } } /* _cj_find_cold(): search cold state for `bat`s [bash registry]. From 0d5beaf774cbe21d8f32241a1d568a32cd319429 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 8 Dec 2018 16:32:37 -0500 Subject: [PATCH 119/157] fixes duplicate assignment in u3v_nick() --- noun/vortex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noun/vortex.c b/noun/vortex.c index 7f1b90c82..a23f95f30 100644 --- a/noun/vortex.c +++ b/noun/vortex.c @@ -152,7 +152,7 @@ u3v_nick(u3_noun vir, u3_noun cor) u3_noun pi_vir, qi_vir; u3_noun vix; - if ( (c3y == u3r_cell((i_vir=u3h(vir)), &pi_vir, &qi_vir)) && + if ( (c3y == u3r_cell(i_vir, &pi_vir, &qi_vir)) && (c3y == u3du(qi_vir)) && (c3__hear == u3h(qi_vir)) ) { From b60668f1d8bfe6153f12cf0e05c4e7cb0a00e9e8 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 8 Dec 2018 16:35:40 -0500 Subject: [PATCH 120/157] fixes 0-byte allocation in _cttp_bods_to_vec() --- vere/cttp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vere/cttp.c b/vere/cttp.c index b37101688..98b463fa4 100644 --- a/vere/cttp.c +++ b/vere/cttp.c @@ -152,6 +152,11 @@ _cttp_bods_to_vec(u3_hbod* bod_u, c3_w* tot_w) } } + if ( 0 == len_w ) { + *tot_w = len_w; + return 0; + } + vec_u = c3_malloc(sizeof(h2o_iovec_t) * len_w); len_w = 0; From a3bef0f23a8e98ff8e3de6351925ea438f75c2fb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 8 Dec 2018 16:36:51 -0500 Subject: [PATCH 121/157] prevents 0-byte allocations in u3i_molt() and u3r_mean() --- noun/imprison.c | 2 ++ noun/retrieve.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/noun/imprison.c b/noun/imprison.c index daf59a1d3..13ba89cc5 100644 --- a/noun/imprison.c +++ b/noun/imprison.c @@ -527,6 +527,8 @@ u3i_molt(u3_noun som, ...) } va_end(ap); } + + c3_assert( 0 != len_w ); pms_m = alloca(len_w * sizeof(struct _molt_pair)); /* Install. diff --git a/noun/retrieve.c b/noun/retrieve.c index 1b796f59c..63287154b 100644 --- a/noun/retrieve.c +++ b/noun/retrieve.c @@ -185,6 +185,8 @@ u3r_mean(u3_noun som, } va_end(ap); } + + c3_assert( 0 != len_w ); prs_m = alloca(len_w * sizeof(struct _mean_pair)); /* Install. From 76fbb1d9181370b1310c63ebc895c69af291c1fe Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 8 Dec 2018 16:54:49 -0500 Subject: [PATCH 122/157] adds and uses c3_realloc() --- include/c/defs.h | 9 +++++++++ vere/dawn.c | 7 +------ vere/http.c | 4 +--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/c/defs.h b/include/c/defs.h index 5332d42a1..c0eb6e570 100644 --- a/include/c/defs.h +++ b/include/c/defs.h @@ -97,3 +97,12 @@ void* rut = c3_malloc(s); \ memset(rut, 0, s); \ rut;}) + +/* c3_realloc(): asserting realloc + */ +#define c3_realloc(a, b) ({ \ + void* rut = realloc(a, b); \ + if ( 0 == rut ) { \ + c3_assert(!"memory lost"); \ + } \ + rut;}) diff --git a/vere/dawn.c b/vere/dawn.c index e18676372..2611b28d4 100644 --- a/vere/dawn.c +++ b/vere/dawn.c @@ -14,12 +14,7 @@ static size_t _dawn_curl_alloc(void* dat_v, size_t uni_t, size_t mem_t, uv_buf_t* buf_u) { size_t siz_t = uni_t * mem_t; - buf_u->base = realloc(buf_u->base, 1 + siz_t + buf_u->len); - - if ( 0 == buf_u->base ) { - fprintf(stderr, "out of memory\n"); - u3_lo_bail(); - } + buf_u->base = c3_realloc(buf_u->base, 1 + siz_t + buf_u->len); memcpy(buf_u->base + buf_u->len, dat_v, siz_t); buf_u->len += siz_t; diff --git a/vere/http.c b/vere/http.c index 01ffc9b50..e0ee698ca 100644 --- a/vere/http.c +++ b/vere/http.c @@ -2687,9 +2687,7 @@ _proxy_peek_read_cb(uv_stream_t* don_u, } else { c3_w len_w = siz_w + con_u->buf_u.len; - // XX c3_realloc - void* ptr_v = realloc(con_u->buf_u.base, len_w); - c3_assert( 0 != ptr_v ); + void* ptr_v = c3_realloc(con_u->buf_u.base, len_w); memcpy(ptr_v + con_u->buf_u.len, buf_u->base, siz_w); con_u->buf_u = uv_buf_init(ptr_v, len_w); From bdc7179a28adc6a1b44b396c9f8690ea5a6f3c8f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 8 Dec 2018 19:48:08 -0500 Subject: [PATCH 123/157] prevents ub in u3x_cap and u3x_mas --- include/noun/xtract.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/noun/xtract.h b/include/noun/xtract.h index 7db51a0d0..d7a355ffb 100644 --- a/include/noun/xtract.h +++ b/include/noun/xtract.h @@ -38,12 +38,15 @@ /* u3x_cap(): root axis, 2 or 3. */ -# define u3x_cap(a_w) (0x2 | (a_w >> (u3x_dep(a_w) - 1))) +# define u3x_cap(a_w) ({ \ + c3_assert( 1 < a_w ); \ + (0x2 | (a_w >> (u3x_dep(a_w) - 1))); }) /* u3x_mas(): remainder after cap. */ -# define u3x_mas(a_w) \ - ( (a_w & ~(1 << u3x_dep(a_w))) | (1 << (u3x_dep(a_w) - 1)) ) +# define u3x_mas(a_w) ({ \ + c3_assert( 1 < a_w ); \ + ( (a_w & ~(1 << u3x_dep(a_w))) | (1 << (u3x_dep(a_w) - 1)) ); }) /* u3x_peg(): connect two axes. */ From 435596b485b07f1a43e004658a176015f8ed9c19 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 8 Dec 2018 20:07:41 -0500 Subject: [PATCH 124/157] fixes memory leak in _unix_update_dir() --- vere/unix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vere/unix.c b/vere/unix.c index 22ccf7fa2..5903d2200 100644 --- a/vere/unix.c +++ b/vere/unix.c @@ -915,6 +915,8 @@ _unix_update_dir(u3_udir* dir_u) } } } + + free(pax_c); } } From 413b53ea16012b2bc3a857cbd8ec4f42e5d48052 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 8 Dec 2018 20:08:23 -0500 Subject: [PATCH 125/157] prevents 0-byte allocation in u3qe_lore() --- jets/e/lore.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jets/e/lore.c b/jets/e/lore.c index 13fa3c1d3..9d62644d0 100644 --- a/jets/e/lore.c +++ b/jets/e/lore.c @@ -35,8 +35,12 @@ } { - c3_y* byts_y = alloca(meg_w); - u3r_bytes(pos_w, meg_w, byts_y, lub); + c3_y* byts_y = 0; + + if ( 0 != meg_w ) { + byts_y = alloca(meg_w); + u3r_bytes(pos_w, meg_w, byts_y, lub); + } if ( _(end_y) ) { return u3kb_flop(u3nc(u3i_bytes(meg_w, byts_y), tez)); From 606650ab3fdf207a955f5782a53b6ec3389e1058 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Dec 2018 12:00:22 -0500 Subject: [PATCH 126/157] disables unused _term_close_cb() --- vere/term.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vere/term.c b/vere/term.c index e57143d10..3e2acef45 100644 --- a/vere/term.c +++ b/vere/term.c @@ -52,6 +52,10 @@ _term_alloc(uv_handle_t* had_u, } +// XX unused, but %hook is in %zuse. +// implement or remove +// +#if 0 /* _term_close_cb(): free terminal. */ static void @@ -79,6 +83,7 @@ _term_close_cb(uv_handle_t* han_t) } free(tty_u); } +#endif /* u3_term_io_init(): initialize terminal. */ From 675fd016077be4375c7976c079d5a64195457ded Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Dec 2018 12:00:45 -0500 Subject: [PATCH 127/157] disables unused _sist_text() --- vere/sist.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vere/sist.c b/vere/sist.c index aed41cd08..75acb393a 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -345,6 +345,9 @@ _sist_cask(c3_c* dir_c, u3_noun nun) return key; } +// XX unused, but may be needed for brainwallet +// +#if 0 /* _sist_text(): ask for a name string. */ static u3_noun @@ -378,7 +381,6 @@ _sist_text(c3_c* pom_c) return say; } -#if 0 /* _sist_bask(): ask a yes or no question. */ static u3_noun From 2bb7b6edd31a074c269f57253236363b4d573b60 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Dec 2018 12:01:03 -0500 Subject: [PATCH 128/157] removes unused variable in _reck_kick_spec() --- vere/reck.c | 1 - 1 file changed, 1 deletion(-) diff --git a/vere/reck.c b/vere/reck.c index 5d977466a..6766b5355 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -259,7 +259,6 @@ static u3_noun _reck_kick_spec(u3_noun pox, u3_noun fav) { u3_noun i_pox, t_pox; - u3_noun p_fav; if ( (c3n == u3r_cell(pox, &i_pox, &t_pox)) || ((i_pox != u3_blip) && From b60e10f1494bfe8242436f5049df0f45701fe167 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Dec 2018 12:02:16 -0500 Subject: [PATCH 129/157] corrects profiling struct initializations --- noun/trace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/noun/trace.c b/noun/trace.c index fc09be9d9..af3b1a23d 100644 --- a/noun/trace.c +++ b/noun/trace.c @@ -580,7 +580,7 @@ u3t_boot(void) #if defined(U3_OS_osx) || defined(U3_OS_linux) // Register _ct_sigaction to be called on `SIGPROF`. { - struct sigaction sig_s = {0}; + struct sigaction sig_s = {{0}}; sig_s.sa_handler = _ct_sigaction; sigemptyset(&(sig_s.sa_mask)); sigaction(SIGPROF, &sig_s, 0); @@ -598,7 +598,7 @@ u3t_boot(void) // Ask for SIGPROF to be sent every 10ms. { - struct itimerval itm_v = {0}; + struct itimerval itm_v = {{0}}; itm_v.it_interval.tv_usec = 10000; itm_v.it_value = itm_v.it_interval; setitimer(ITIMER_PROF, &itm_v, 0); @@ -631,13 +631,13 @@ u3t_boff(void) // Disable the SIGPROF timer. { - struct itimerval itm_v = {0}; + struct itimerval itm_v = {{0}}; setitimer(ITIMER_PROF, &itm_v, 0); } // Ignore SIGPROF signals. { - struct sigaction sig_s = {0}; + struct sigaction sig_s = {{0}}; sigemptyset(&(sig_s.sa_mask)); sig_s.sa_handler = SIG_IGN; sigaction(SIGPROF, &sig_s, 0); From 3ae323e43e4be43ff1bd4c8852b49dae6f4f32d2 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 10 Dec 2018 13:39:32 -0500 Subject: [PATCH 130/157] 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 6e7d7e3a9..4da94a611 160000 --- a/subprojects/argon2 +++ b/subprojects/argon2 @@ -1 +1 @@ -Subproject commit 6e7d7e3a92361f11942f0c743d154ab426d1530e +Subproject commit 4da94a611ee62bad87ab2b131ffda3bcc0723d9c diff --git a/subprojects/ed25519 b/subprojects/ed25519 index ba4777aca..76385f2eb 160000 --- a/subprojects/ed25519 +++ b/subprojects/ed25519 @@ -1 +1 @@ -Subproject commit ba4777acac5694925ab78f38577b059cd4a3e8e6 +Subproject commit 76385f2ebbbc9580a9c236952d68d11d73a6135c diff --git a/subprojects/libh2o b/subprojects/libh2o index 41958a8ae..3b1f53c86 160000 --- a/subprojects/libh2o +++ b/subprojects/libh2o @@ -1 +1 @@ -Subproject commit 41958a8aedb3aa2a85332bc8ac0ac389aa725a09 +Subproject commit 3b1f53c86b71f6fdc099b3b378de6f379b4b8412 diff --git a/subprojects/libscrypt b/subprojects/libscrypt index 4ebe362f3..029693ff1 160000 --- a/subprojects/libscrypt +++ b/subprojects/libscrypt @@ -1 +1 @@ -Subproject commit 4ebe362f390025e5448e9fcf777c1f38630bc011 +Subproject commit 029693ff1cbe4f69d3a2da87d0f4f034f92cc0c2 diff --git a/subprojects/libsni b/subprojects/libsni index a59901c38..173beb88e 160000 --- a/subprojects/libsni +++ b/subprojects/libsni @@ -1 +1 @@ -Subproject commit a59901c38a67660039ee93a6170a338634d76ec0 +Subproject commit 173beb88ee62bddd13874ca04ab338cdec704928 diff --git a/subprojects/libuv b/subprojects/libuv index 9e3aece81..0c3a346a6 160000 --- a/subprojects/libuv +++ b/subprojects/libuv @@ -1 +1 @@ -Subproject commit 9e3aece8147d28246c57b84731dad26130c7d1c1 +Subproject commit 0c3a346a60f0b3bb42445b2c63198a6e0f94c89b diff --git a/subprojects/murmur3 b/subprojects/murmur3 index 001378cbe..71a75d57c 160000 --- a/subprojects/murmur3 +++ b/subprojects/murmur3 @@ -1 +1 @@ -Subproject commit 001378cbe3681af1137553ed7220c79273850d6a +Subproject commit 71a75d57ca4e7ca0f7fc2fd84abd93595b0624ca diff --git a/subprojects/secp256k1 b/subprojects/secp256k1 index 9989e23ce..66a72cf20 160000 --- a/subprojects/secp256k1 +++ b/subprojects/secp256k1 @@ -1 +1 @@ -Subproject commit 9989e23ce8a02a51a1f90a2d5e391ba7d16bef39 +Subproject commit 66a72cf2084799d0799874d4fa3c530a73713d81 diff --git a/subprojects/softfloat3 b/subprojects/softfloat3 index 9d4342099..ec4c7e31b 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 131/157] 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 54f523511..83769058b 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 d8b5d8017..dae4c80ee 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 f106e2b3d..58b259551 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 5f80290fb..000000000 --- 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 254a7b465..0bfe6cf7e 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 a4925d434..d023d4ada 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 8555ef14c..000000000 --- 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 132/157] 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 c0eb6e570..74dfeeb33 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 133/157] 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 5903d2200..7ee2f3918 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 134/157] 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 7ee2f3918..0b5f9002f 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 135/157] 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 af3b1a23d..d2a9e9a0c 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 136/157] 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 e14e06523..5e5de9ea2 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 137/157] 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 5e5de9ea2..d86ec9104 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 138/157] 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 d86ec9104..fc7be85ed 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 139/157] 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 fc7be85ed..5c20653d5 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 140/157] 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 5c20653d5..7e89aeeb9 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 141/157] 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 7e89aeeb9..3b4a00505 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 142/157] 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 9d81e4e83..fe54c6f3a 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 59cc76f70..a8f9a0bdd 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 3b4a00505..3149a2273 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 75acb393a..e14b5bdb1 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 143/157] 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 e934d2620..bb1021dbb 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 144/157] 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 a28e21e19..ad9094a79 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 145/157] 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 3e2acef45..2c768002b 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 146/157] 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 3149a2273..6c2778a21 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 147/157] 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 6c2778a21..e4134c29a 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 148/157] trailing whitespace --- vere/behn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vere/behn.c b/vere/behn.c index bb1021dbb..9d7bd8b2d 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 149/157] 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 e4134c29a..508dddb6d 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 150/157] 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 e14b5bdb1..f20b1d4b2 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 151/157] 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 d84dbf2c6..dfb7e8bae 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 a23f95f30..c40fd3fcf 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 152/157] 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 e4134c29a..5c0ec25e5 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 153/157] 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 2c768002b..54cb0a222 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 154/157] 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 dae4c80ee..65a7cef8d 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 000000000..ea87c1862 --- /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 0bfe6cf7e..c0da86ffd 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 d023d4ada..71b902999 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 155/157] [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 9d21e4199..a59368215 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 156/157] 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 ea87c1862..90e11b37c 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; } From e25c8388a4658aea5a143b705c58d342ef1f2adb Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 13 Dec 2018 14:39:53 -0800 Subject: [PATCH 157/157] Add jet for +del:in --- include/jets/w.h | 1 + jets/d/in_del.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++ jets/tree.c | 3 ++ meson.build | 1 + 4 files changed, 110 insertions(+) create mode 100644 jets/d/in_del.c diff --git a/include/jets/w.h b/include/jets/w.h index 65a7cef8d..0dd3d7f42 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -91,6 +91,7 @@ u3_noun u3wdb_uni(u3_noun); u3_noun u3wdi_bif(u3_noun); + u3_noun u3wdi_del(u3_noun); u3_noun u3wdi_dif(u3_noun); u3_noun u3wdi_gas(u3_noun); u3_noun u3wdi_has(u3_noun); diff --git a/jets/d/in_del.c b/jets/d/in_del.c new file mode 100644 index 000000000..02390ccce --- /dev/null +++ b/jets/d/in_del.c @@ -0,0 +1,105 @@ +/* j/4/in_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) ) ) { + return u3m_bail(c3__exit); + } + else { + if ( c3y == u3qc_vor(n_l_a, 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 + u3qdi_del(u3_noun a, + u3_noun b) + { + if ( u3_nul == a ) { + return u3_nul; + } + else { + 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 ( c3n == u3r_sing(n_a, b) ) { + if ( c3y == u3qc_hor(b, n_a) ) { + return u3nt(u3k(n_a), + u3qdi_del(l_a, b), + u3k(r_a)); + } + else { + return u3nt(u3k(n_a), + u3k(l_a), + u3qdi_del(r_a, b)); + } + } + else { + return _rebalance(a); + } + } + } + + u3_noun + u3wdi_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 = u3qdi_del(a, b); + return n; + } + } diff --git a/jets/tree.c b/jets/tree.c index c0da86ffd..b73f0110a 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -854,6 +854,8 @@ static c3_c* _141_two_xeb_ha[] = {0}; static u3j_harm _141_two__in_bif_a[] = {{".2", u3wdi_bif}, {}}; static c3_c* _141_two__in_bif_ha[] = {0}; + static u3j_harm _141_two__in_del_a[] = {{".2", u3wdi_del}, {}}; + static c3_c* _141_two__in_del_ha[] = {0}; static u3j_harm _141_two__in_dif_a[] = {{".2", u3wdi_dif}, {}}; static c3_c* _141_two__in_dif_ha[] = {0}; static u3j_harm _141_two__in_gas_a[] = {{".2", u3wdi_gas}, {}}; @@ -877,6 +879,7 @@ static c3_c* _141_two_xeb_ha[] = {0}; static c3_c* _141_two__in_uni_ha[] = {0}; static u3j_core _141_two__in_d[] = { { "bif", 7, _141_two__in_bif_a, 0, _141_two__in_bif_ha }, + { "del", 7, _141_two__in_del_a, 0, _141_two__in_del_ha }, { "dif", 7, _141_two__in_dif_a, 0, _141_two__in_dif_ha }, { "gas", 7, _141_two__in_gas_a, 0, _141_two__in_gas_ha }, { "has", 7, _141_two__in_has_a, 0, _141_two__in_has_ha }, diff --git a/meson.build b/meson.build index 71b902999..03c1b613c 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/in_del.c', 'jets/d/by_del.c', 'jets/d/by_gas.c', 'jets/d/by_get.c',