From a3bb81f397018fbd0532b50c9cf2ea7af09bea96 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sun, 8 Feb 2015 13:22:33 -0800 Subject: [PATCH 01/14] Check in some testing stuff. --- i/c/motes.h | 1 + n/m.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- v/term.c | 15 +++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/i/c/motes.h b/i/c/motes.h index 5c86c8e81..557c7c088 100644 --- a/i/c/motes.h +++ b/i/c/motes.h @@ -886,6 +886,7 @@ # define c3__scry c3_s4('s','c','r','y') # define c3__scsg c3_s4('s','c','s','g') # define c3__seal c3_s4('s','e','a','l') +# define c3__seat c3_s4('s','e','a','t') # define c3__see c3_s3('s','e','e') # define c3__seed c3_s4('s','e','e','d') # define c3__seek c3_s4('s','e','e','k') diff --git a/n/m.c b/n/m.c index 08a09326c..891f0518c 100644 --- a/n/m.c +++ b/n/m.c @@ -188,6 +188,47 @@ _cm_signal_reset(void) u3R->kid_u = 0; } +/* _cm_stack_recover(): recover stack trace, with lacunae. +*/ +static u3_noun +_cm_stack_recover(u3a_road* rod_u) +{ + c3_w len_w; + + len_w = 0; + { + u3_noun tax = rod_u->bug.tax; + + while ( tax ) { + len_w++; + tax = u3t(tax); + } + + if ( len_w < 4096 ) { + return u3a_take(rod_u->bug.tax); + } + else { + u3_noun beg, fin; + c3_w i_w; + + tax = rod_u->bug.tax; + beg = u3_nul; + for ( i_w = 0; i_w < 2048; i_w++ ) { + beg = u3nc(u3a_take(u3h(tax)), beg); + tax = u3t(tax); + } + beg = u3kb_flop(beg); + + for ( i_w = 0; i_w < (len_w - 4096); i_w++ ) { + tax = u3t(tax); + } + fin = u3nc(u3nc(c3__lose, c3__over), u3a_take(tax)); + + return u3kb_weld(beg, fin); + } + } +} + /* _cm_signal_recover(): recover from a deep signal, after longjmp. Free arg. */ static u3_noun @@ -235,9 +276,13 @@ _cm_signal_recover(c3_l sig_l, u3_noun arg) u3R = &(u3H->rod_u); rod_u = u3R; - + while ( rod_u->kid_u ) { - tax = u3kb_weld(u3a_take(rod_u->kid_u->bug.tax), tax); +#if 0 + fprintf(stderr, "collecting %d frames\r\n", + u3kb_lent(rod_u->kid_u->bug.tax)); +#endif + tax = u3kb_weld(_cm_stack_recover(rod_u->kid_u), tax); rod_u = rod_u->kid_u; } } diff --git a/v/term.c b/v/term.c index 8114e165c..83abf0cc1 100644 --- a/v/term.c +++ b/v/term.c @@ -306,6 +306,7 @@ _term_listen_cb(uv_stream_t *wax_u, int sas_i) u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); u3v_plan(u3k(pax), u3nc(c3__blew, u3nc(80, 25))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); + u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); u3z(pax); } @@ -668,6 +669,17 @@ _term_it_save(u3_noun pax, u3_noun pad) free(pax_c); } +/* _term_io_flow(): send flow. +*/ +static void +_term_io_flow(u3_utty* uty_u) +{ + u3_noun tid = u3dc("scot", c3__ud, uty_u->tid_l); + u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); + + u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); +} + /* _term_io_belt(): send belt. */ static void @@ -818,6 +830,9 @@ _term_io_suck_char(u3_utty* uty_u, c3_y cay_y) else if ( 13 == cay_y ) { _term_io_belt(uty_u, u3nc(c3__ret, u3_nul)); } + else if ( 6 == cay_y ) { + _term_io_flow(uty_u); // XX hack + } else if ( cay_y <= 26 ) { _term_io_belt(uty_u, u3nc(c3__ctl, ('a' + (cay_y - 1)))); } From 045f862a84002942558da5da0e6dc1204e7fe0cc Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Mon, 9 Feb 2015 12:40:44 -0800 Subject: [PATCH 02/14] Full test pathway. --- v/term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v/term.c b/v/term.c index 83abf0cc1..c4faee708 100644 --- a/v/term.c +++ b/v/term.c @@ -677,7 +677,7 @@ _term_io_flow(u3_utty* uty_u) u3_noun tid = u3dc("scot", c3__ud, uty_u->tid_l); u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); - u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); + u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__galk, u3_nul)); } /* _term_io_belt(): send belt. From 2c80dd529703f47493b774c7f6031bab705c858d Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 11 Feb 2015 18:57:33 -0800 Subject: [PATCH 03/14] Reverse i search --- i/c/motes.h | 1 + v/term.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/i/c/motes.h b/i/c/motes.h index 557c7c088..c1abcf8b6 100644 --- a/i/c/motes.h +++ b/i/c/motes.h @@ -412,6 +412,7 @@ # define c3__gab c3_s3('g','a','b') # define c3__galb c3_s4('g','a','l','b') # define c3__gald c3_s4('g','a','l','d') +# define c3__galk c3_s4('g','a','l','k') # define c3__game c3_s4('g','a','m','e') # define c3__gamp c3_s4('g','a','m','p') # define c3__gant c3_s4('g','a','n','t') diff --git a/v/term.c b/v/term.c index c4faee708..6d01d6cce 100644 --- a/v/term.c +++ b/v/term.c @@ -306,7 +306,7 @@ _term_listen_cb(uv_stream_t *wax_u, int sas_i) u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); u3v_plan(u3k(pax), u3nc(c3__blew, u3nc(80, 25))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); - u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); + u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__galk, u3_nul)); u3z(pax); } From 4f0a620972a3a317db5bcceb8ddc3c4968639f48 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Fri, 13 Feb 2015 16:37:40 -0800 Subject: [PATCH 04/14] Various fixes and improvements. --- v/term.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v/term.c b/v/term.c index 6d01d6cce..83abf0cc1 100644 --- a/v/term.c +++ b/v/term.c @@ -306,7 +306,7 @@ _term_listen_cb(uv_stream_t *wax_u, int sas_i) u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); u3v_plan(u3k(pax), u3nc(c3__blew, u3nc(80, 25))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); - u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__galk, u3_nul)); + u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); u3z(pax); } @@ -677,7 +677,7 @@ _term_io_flow(u3_utty* uty_u) u3_noun tid = u3dc("scot", c3__ud, uty_u->tid_l); u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); - u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__galk, u3_nul)); + u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); } /* _term_io_belt(): send belt. From 95fbf2915bd3a6b805c16a300151fe1c1343abb2 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 17 Feb 2015 19:30:53 -0800 Subject: [PATCH 05/14] Before experiment in reversing arvo moves. --- i/c/motes.h | 1 + v/term.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/i/c/motes.h b/i/c/motes.h index c1abcf8b6..9339fe5f4 100644 --- a/i/c/motes.h +++ b/i/c/motes.h @@ -300,6 +300,7 @@ # define c3__do c3_s2('d','o') # define c3__doc c3_s3('d','o','c') # define c3__dogo c3_s4('d','o','g','o') +# define c3__dojo c3_s4('d','o','j','o') # define c3__dome c3_s4('d','o','m','e') # define c3__done c3_s4('d','o','n','e') # define c3__door c3_s4('d','o','o','r') diff --git a/v/term.c b/v/term.c index 83abf0cc1..7bf1f4c19 100644 --- a/v/term.c +++ b/v/term.c @@ -677,7 +677,9 @@ _term_io_flow(u3_utty* uty_u) u3_noun tid = u3dc("scot", c3__ud, uty_u->tid_l); u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); - u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); + // u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); + // u3v_plan(pax, u3nt(c3__flow, c3__seat, u3_nul)); + u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); } /* _term_io_belt(): send belt. From 597cfd11caa2b48cce473abd77be05294b2b0368 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 24 Feb 2015 14:53:31 -0800 Subject: [PATCH 06/14] Barnaby, almost working. --- i/c/motes.h | 1 + v/term.c | 1 + 2 files changed, 2 insertions(+) diff --git a/i/c/motes.h b/i/c/motes.h index 9339fe5f4..49c0c22c9 100644 --- a/i/c/motes.h +++ b/i/c/motes.h @@ -479,6 +479,7 @@ # define c3__head c3_s4('h','e','a','d') # define c3__heal c3_s4('h','e','a','l') # define c3__hear c3_s4('h','e','a','r') +# define c3__helm c3_s4('h','e','l','m') # define c3__helo c3_s4('h','e','l','o') # define c3__hep c3_s3('h','e','p') # define c3__hept c3_s4('h','e','p','t') diff --git a/v/term.c b/v/term.c index 056740ec8..9eb4b9c88 100644 --- a/v/term.c +++ b/v/term.c @@ -679,6 +679,7 @@ _term_io_flow(u3_utty* uty_u) // u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); // u3v_plan(pax, u3nt(c3__flow, c3__seat, u3_nul)); u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); + // u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__helm, u3_nul)); } /* _term_io_belt(): send belt. From 21e3a0aee88bcf04b94a64b1cb6389d5280b9031 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 24 Feb 2015 15:31:58 -0800 Subject: [PATCH 07/14] Recover a BUNCH of old stuff from a stash. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e1e95c43c..813d76c17 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ INCLUDE=i MDEFINES=-DU3_OS_$(OS) -DU3_OS_ENDIAN_$(ENDIAN) -D U3_LIB=\"$(LIB)\" # NOTFORCHECKIN - restore -O3 -CFLAGS= $(COSFLAGS) -O3 -msse3 -ffast-math \ +CFLAGS= $(COSFLAGS) -O3 -msse3 -ffast-math -DGHETTO \ -funsigned-char \ -I/usr/local/include \ -I/opt/local/include \ From a3a2ec226097ca92c54297ea759c460c25b24a83 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 25 Feb 2015 08:57:43 -0800 Subject: [PATCH 08/14] Basic dialog workings. --- Makefile | 2 +- v/term.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 813d76c17..e1e95c43c 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ INCLUDE=i MDEFINES=-DU3_OS_$(OS) -DU3_OS_ENDIAN_$(ENDIAN) -D U3_LIB=\"$(LIB)\" # NOTFORCHECKIN - restore -O3 -CFLAGS= $(COSFLAGS) -O3 -msse3 -ffast-math -DGHETTO \ +CFLAGS= $(COSFLAGS) -O3 -msse3 -ffast-math \ -funsigned-char \ -I/usr/local/include \ -I/opt/local/include \ diff --git a/v/term.c b/v/term.c index 9eb4b9c88..e15e8d26e 100644 --- a/v/term.c +++ b/v/term.c @@ -678,8 +678,8 @@ _term_io_flow(u3_utty* uty_u) // u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); // u3v_plan(pax, u3nt(c3__flow, c3__seat, u3_nul)); - u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); - // u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__helm, u3_nul)); + // u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); + u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__helm, u3_nul)); } /* _term_io_belt(): send belt. From 4eefaeb9539f9197f8ff38f1bc78bb564c7e40d2 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Thu, 5 Mar 2015 13:25:08 -0800 Subject: [PATCH 09/14] Start dojo. --- v/term.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v/term.c b/v/term.c index e15e8d26e..9eb4b9c88 100644 --- a/v/term.c +++ b/v/term.c @@ -678,8 +678,8 @@ _term_io_flow(u3_utty* uty_u) // u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); // u3v_plan(pax, u3nt(c3__flow, c3__seat, u3_nul)); - // u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); - u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__helm, u3_nul)); + u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); + // u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__helm, u3_nul)); } /* _term_io_belt(): send belt. From a1a6cc8ad310f53925b33488a2ff4512c869c2c0 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 17 Mar 2015 10:56:54 -0700 Subject: [PATCH 10/14] Right before pill switch from dull to dill. --- v/term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v/term.c b/v/term.c index 21b28bd6a..fc99e0c11 100644 --- a/v/term.c +++ b/v/term.c @@ -305,7 +305,7 @@ _term_listen_cb(uv_stream_t *wax_u, int sas_i) u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); u3v_plan(u3k(pax), u3nc(c3__blew, u3nc(80, 25))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); - u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); + u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); u3z(pax); } From f98eeda22854822426cb79d941390d5a3a8897f0 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 17 Mar 2015 13:53:38 -0700 Subject: [PATCH 11/14] Adjust dill for forward compatibility. --- v/term.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/v/term.c b/v/term.c index fc99e0c11..bed9c1c43 100644 --- a/v/term.c +++ b/v/term.c @@ -303,9 +303,9 @@ _term_listen_cb(uv_stream_t *wax_u, int sas_i) { u3_noun tid = u3dc("scot", c3__ud, tty_u->tid_l); u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); + u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); u3v_plan(u3k(pax), u3nc(c3__blew, u3nc(80, 25))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); - u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); u3z(pax); } @@ -1016,6 +1016,7 @@ u3_term_ef_boil(void) u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); // u3v_plan(u3k(pax), u3nc(c3__init, u3k(u3h(u3A->own)))); + u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); u3v_plan(u3k(pax), u3nc(c3__harm, u3_nul)); u3v_plan(u3k(pax), u3nc(c3__blew, u3_term_get_blew(1))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); @@ -1032,6 +1033,7 @@ u3_term_ef_bake(u3_noun fav) u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); u3v_plan(u3k(pax), u3nc(c3__boot, fav)); + u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); u3v_plan(u3k(pax), u3nc(c3__blew, u3_term_get_blew(1))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); From 6257937fccacc51a0dc88bec23b155b64ca4e368 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 18 Mar 2015 09:40:40 -0700 Subject: [PATCH 12/14] Various fixes and improvements. --- v/reck.c | 2 +- v/term.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/v/reck.c b/v/reck.c index 32366d8a7..64289d422 100644 --- a/v/reck.c +++ b/v/reck.c @@ -104,7 +104,7 @@ _reck_kick_term(u3_noun pox, c3_l tid_l, u3_noun fav) u3_unix_ef_init(u3k(p_fav)); - // uL(fprintf(uH, "kick: init: %d\n", p_fav)); + uL(fprintf(uH, "kick: init: %d\n", p_fav)); u3z(pox); u3z(fav); return c3y; } break; } diff --git a/v/term.c b/v/term.c index bed9c1c43..f68998979 100644 --- a/v/term.c +++ b/v/term.c @@ -1016,7 +1016,6 @@ u3_term_ef_boil(void) u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); // u3v_plan(u3k(pax), u3nc(c3__init, u3k(u3h(u3A->own)))); - u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); u3v_plan(u3k(pax), u3nc(c3__harm, u3_nul)); u3v_plan(u3k(pax), u3nc(c3__blew, u3_term_get_blew(1))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); From 5732f8bd1afccdf9d5f525fbd15689fa640eb5a9 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 18 Mar 2015 15:01:47 -0700 Subject: [PATCH 13/14] :begin on cruiser works. --- v/term.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/v/term.c b/v/term.c index f68998979..387e01782 100644 --- a/v/term.c +++ b/v/term.c @@ -303,7 +303,7 @@ _term_listen_cb(uv_stream_t *wax_u, int sas_i) { u3_noun tid = u3dc("scot", c3__ud, tty_u->tid_l); u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); - u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); + // u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); u3v_plan(u3k(pax), u3nc(c3__blew, u3nc(80, 25))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); u3z(pax); @@ -673,12 +673,12 @@ _term_it_save(u3_noun pax, u3_noun pad) static void _term_io_flow(u3_utty* uty_u) { - u3_noun tid = u3dc("scot", c3__ud, uty_u->tid_l); - u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); + // u3_noun tid = u3dc("scot", c3__ud, uty_u->tid_l); + // u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul); // u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__talk, u3_nul)); // u3v_plan(pax, u3nt(c3__flow, c3__seat, u3_nul)); - u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); + // u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); // u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__helm, u3_nul)); } @@ -1032,7 +1032,7 @@ u3_term_ef_bake(u3_noun fav) u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); u3v_plan(u3k(pax), u3nc(c3__boot, fav)); - u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); + // u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__dojo, u3_nul)); u3v_plan(u3k(pax), u3nc(c3__blew, u3_term_get_blew(1))); u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul)); From 0308c9a00a40114a902a84a40fb433b2c6f91db5 Mon Sep 17 00:00:00 2001 From: Steven Dee Date: Wed, 18 Mar 2015 18:48:29 -0400 Subject: [PATCH 14/14] Use getentropy(2) on OpenBSD --- i/c/portable.h | 9 +++++++++ i/v/vere.h | 5 +++++ v/sist.c | 12 ++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/i/c/portable.h b/i/c/portable.h index 30381ced1..4cbf0a3c7 100644 --- a/i/c/portable.h +++ b/i/c/portable.h @@ -178,3 +178,12 @@ # else # error "port: timeconvert" # endif + +/* Entropy + */ +# if defined(U3_OS_bsd) && defined(__OpenBSD__) +# define c3_rand(rd) (getentropy((void*)rd, 32) == 0 ? \ + (void)0 : c3_assert(!"ent")) +# else +# define c3_rand u3_sist_rand +# endif diff --git a/i/v/vere.h b/i/v/vere.h index e4ebb4e12..6e6868031 100644 --- a/i/v/vere.h +++ b/i/v/vere.h @@ -1094,6 +1094,11 @@ void u3_sist_get(const c3_c* key_c, c3_y* val_y); + /* u3_sist_rand(): fill 8 words (32 bytes) with high-quality entropy. + */ + void + u3_sist_rand(c3_w* rad_w); + /** New timer system. **/ /* u3_temp_io_init(): initialize time timer. diff --git a/v/sist.c b/v/sist.c index b3655f5ff..7013d05b5 100644 --- a/v/sist.c +++ b/v/sist.c @@ -444,10 +444,10 @@ _sist_bask(c3_c* pop_c, u3_noun may) } #endif -/* _sist_rand(): fill a 256-bit (8-word) buffer. +/* u3_sist_rand(): fill a 256-bit (8-word) buffer. */ -static void -_sist_rand(c3_w* rad_w) +void +u3_sist_rand(c3_w* rad_w) { c3_i fid_i = open(DEVRANDOM, O_RDONLY); @@ -589,7 +589,7 @@ _sist_zest() { c3_w rad_w[8]; - _sist_rand(rad_w); + c3_rand(rad_w); sal_l = (0x7fffffff & rad_w[0]); } @@ -599,7 +599,7 @@ _sist_zest() c3_w rad_w[8]; u3_noun pas; - _sist_rand(rad_w); + c3_rand(rad_w); pas = u3i_words(2, rad_w); u3A->key = _sist_fatt(sal_l, u3k(pas)); @@ -1201,7 +1201,7 @@ _sist_zen() { c3_w rad_w[8]; - _sist_rand(rad_w); + c3_rand(rad_w); return u3i_words(8, rad_w); }