mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 22:33:06 +03:00
Merge branch 'release-candidate' into cc-release-rc-merge
* release-candidate: (90 commits) Only bail if profiling is enabled Fixes the build on OpenBSD don't abort on bail:fail, but continue with crash handling renames event-timing, adds build option to enable Add jet for +del:in prevents profiling on *bsd removes preprocessor errors in trace.c on openbsd updates secp256k1 to include /usr/local/include for openbsd Style nits [CI] Update arvo Add a jet for +del:by fit UTF-8 tape bug calls u3_raft_work on leader promotion (for eager restart effects) enables event-log encryption removes unused u3v_nick (effect traversal) and u3v_http_request refactors event replay, removing unnecessary effect traversal refactors event poke, removing unnecessary effect traversal trailing whitespace adds and corrects some raft comments separates effects and persistence ...
This commit is contained in:
commit
042b55326f
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -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
|
||||
|
@ -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
|
||||
|
@ -1 +1 @@
|
||||
806c604c2f0f9ee7eea2999e6bb15ed5a8abaa99
|
||||
00c79de3df4ecae9f499053990471d420f0e79a0
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
*/
|
||||
@ -91,7 +100,6 @@
|
||||
} \
|
||||
rut;})
|
||||
#define c3_free(s) free(s)
|
||||
#define c3_realloc(s, l) realloc(s, l)
|
||||
|
||||
/* c3_calloc(): asserting calloc
|
||||
*/
|
||||
@ -99,3 +107,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;})
|
||||
|
@ -1198,6 +1198,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')
|
||||
@ -1212,6 +1213,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')
|
||||
|
@ -188,12 +188,8 @@
|
||||
|
||||
/* Entropy
|
||||
*/
|
||||
# if defined(U3_OS_bsd) && defined(__OpenBSD__)
|
||||
# define c3_rand(rd) (getentropy((void*)rd, 64) == 0 ? \
|
||||
(void)0 : c3_assert(!"ent"))
|
||||
# else
|
||||
# define c3_rand u3_pier_rand
|
||||
# endif
|
||||
# define c3_rand u3_pier_rand
|
||||
|
||||
# if defined(U3_OS_linux)
|
||||
# define DEVRANDOM "/dev/urandom"
|
||||
# else
|
||||
|
@ -12,5 +12,6 @@
|
||||
|
||||
#mesondefine U3_MEMORY_DEBUG
|
||||
#mesondefine U3_CPU_DEBUG
|
||||
#mesondefine U3_EVENT_TIME_DEBUG
|
||||
|
||||
#endif /*CONFIG_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);
|
||||
@ -90,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);
|
||||
@ -289,7 +291,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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
|
@ -88,6 +88,32 @@
|
||||
void
|
||||
u3t_flee(void);
|
||||
|
||||
/* u3t_trace_open(): opens the path for writing tracing information.
|
||||
*/
|
||||
void
|
||||
u3t_trace_open(c3_c*);
|
||||
|
||||
/* 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
|
||||
u3t_nock_trace_push(u3_noun lab);
|
||||
|
||||
/* u3t_nock_trace_pop(): pop off trace stack.
|
||||
*/
|
||||
void
|
||||
u3t_nock_trace_pop();
|
||||
|
||||
/* u3t_event_trace(): record a lifecycle event.
|
||||
*/
|
||||
void
|
||||
u3t_event_trace(const c3_c* name, c3_c type);
|
||||
|
||||
/* u3t_damp(): print and clear profile data.
|
||||
*/
|
||||
void
|
||||
|
@ -34,7 +34,6 @@
|
||||
u3_noun key; // log key, or 0
|
||||
u3_noun sys; // system pill
|
||||
|
||||
u3_noun ken; // kernel formula
|
||||
u3_noun roc; // kernel core
|
||||
|
||||
struct { // ova waiting to process
|
||||
@ -66,26 +65,16 @@
|
||||
u3_noun
|
||||
u3v_do(const c3_c* txt_c, u3_noun arg);
|
||||
|
||||
/* u3v_boot(): make a new pier by loading a pill.
|
||||
/* u3v_boot(): evaluate boot sequence, making a kernel
|
||||
*/
|
||||
void
|
||||
u3v_boot(c3_c* pas_c);
|
||||
u3v_boot(u3_noun eve);
|
||||
|
||||
/* u3v_boot_lite(): light bootstrap sequence, just making a kernel.
|
||||
*/
|
||||
void
|
||||
u3v_boot_lite(u3_noun lit);
|
||||
|
||||
/* u3v_make(): make a new pier by loading a pill.
|
||||
*/
|
||||
void
|
||||
u3v_make(c3_c* pas_c);
|
||||
|
||||
/* u3v_jack(): execute kernel formula to bind jets.
|
||||
*/
|
||||
void
|
||||
u3v_jack(void);
|
||||
|
||||
/* u3v_start(): start time.
|
||||
*/
|
||||
void
|
||||
@ -101,11 +90,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
|
||||
@ -136,11 +120,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
|
||||
@ -171,11 +150,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
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -554,6 +554,7 @@
|
||||
c3_o gab; // -g, test garbage collection
|
||||
c3_c* dns_c; // -H, ames bootstrap domain
|
||||
c3_c* lit_c; // -J, ivory (fastboot) kernel
|
||||
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
|
||||
@ -588,6 +589,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_u; // trace file to write to
|
||||
} u3_host; // host == computer == process
|
||||
|
||||
/** New pier system.
|
||||
@ -1107,7 +1109,7 @@
|
||||
|
||||
/** behn, just a timer.
|
||||
**/
|
||||
/* u3_behn_io_init(): initialize time timer.
|
||||
/* u3_behn_io_init(): initialize behn timer.
|
||||
*/
|
||||
void
|
||||
u3_behn_io_init(u3_pier *pir_u);
|
||||
|
@ -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)
|
||||
|
111
jets/d/by_del.c
Normal file
111
jets/d/by_del.c
Normal file
@ -0,0 +1,111 @@
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
105
jets/d/in_del.c
Normal file
105
jets/d/in_del.c
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -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));
|
||||
|
@ -13,18 +13,65 @@
|
||||
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, by creating a list of
|
||||
* parent core types. These will be converted to
|
||||
* a single `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 ( u3_nul == lis ) {
|
||||
return u3_nul;
|
||||
}
|
||||
else {
|
||||
u3_noun i_lis, t_lis, fot, typ;
|
||||
u3x_cell(lis, &i_lis, &t_lis);
|
||||
u3x_cell(i_lis, &typ, &fot);
|
||||
|
||||
return u3n_kick_on(u3i_molt(gat,
|
||||
u3x_sam,
|
||||
u3k(lap),
|
||||
0));
|
||||
if ( (c3n == u3du(typ)) ||
|
||||
(c3__core != u3h(typ)) ) {
|
||||
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));
|
||||
return u3nc(dox, u3qfu_felt_arm(t_lis));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* `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 lim, mil;
|
||||
u3x_cell(lap, &lim, &mil);
|
||||
|
||||
if ( c3y == lim ) {
|
||||
return u3k(mil);
|
||||
}
|
||||
else if ( c3n == lim ) {
|
||||
u3_noun p_lap, q_lap, lis, hos;
|
||||
u3x_cell(mil, &p_lap, &q_lap);
|
||||
lis = u3qdi_tap(q_lap);
|
||||
hos = u3qfu_felt_arm(lis);
|
||||
|
||||
u3z(lis);
|
||||
return u3kf_fork(hos);
|
||||
}
|
||||
else {
|
||||
u3m_bail(c3__exit);
|
||||
}
|
||||
}
|
||||
|
||||
static u3_noun
|
||||
@ -190,15 +237,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 +254,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;
|
||||
@ -665,7 +705,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)
|
||||
|
@ -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) &&
|
||||
|
@ -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));
|
||||
|
||||
|
@ -88,11 +88,26 @@
|
||||
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 ) {
|
||||
return u3m_error("payload-block");
|
||||
}
|
||||
|
||||
u3_noun typ;
|
||||
|
||||
{
|
||||
@ -120,6 +135,7 @@
|
||||
}
|
||||
|
||||
u3z(pec);
|
||||
u3z(tow);
|
||||
}
|
||||
else {
|
||||
pro = c3__noun;
|
||||
|
220
jets/g/down.c
220
jets/g/down.c
@ -1,220 +0,0 @@
|
||||
/* j/g/down.c
|
||||
**
|
||||
*/
|
||||
#include "all.h"
|
||||
#include <cmark.h>
|
||||
#include <node.h>
|
||||
#include <buffer.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
37
jets/tree.c
37
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 },
|
||||
|
||||
@ -233,11 +222,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 +251,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 },
|
||||
@ -800,11 +786,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}, {}};
|
||||
@ -871,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}, {}};
|
||||
@ -894,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 },
|
||||
@ -909,6 +895,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}, {}};
|
||||
@ -935,6 +923,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 },
|
||||
@ -975,7 +964,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 },
|
||||
|
||||
|
21
meson.build
21
meson.build
@ -90,6 +90,8 @@ 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',
|
||||
'jets/d/by_has.c',
|
||||
@ -179,10 +181,6 @@ jets_f_ut_src = [
|
||||
'jets/f/ut_wrap.c'
|
||||
]
|
||||
|
||||
jets_g_src = [
|
||||
'jets/g/down.c'
|
||||
]
|
||||
|
||||
jets_src = [
|
||||
'jets/tree.c'
|
||||
]
|
||||
@ -192,7 +190,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',
|
||||
@ -245,6 +244,7 @@ conf_data = configuration_data()
|
||||
conf_data.set('URBIT_VERSION', '"0.6.0"')
|
||||
conf_data.set('U3_MEMORY_DEBUG', get_option('gc'))
|
||||
conf_data.set('U3_CPU_DEBUG', get_option('prof'))
|
||||
conf_data.set('U3_EVENT_TIME_DEBUG', get_option('event-time'))
|
||||
|
||||
osdet = build_machine.system()
|
||||
os_c_flags = ['-funsigned-char','-ffast-math']
|
||||
@ -283,6 +283,13 @@ elif osdet == 'bsd' or osdet == 'freebsd'
|
||||
kvm_dep = meson.get_compiler('c').find_library('kvm')
|
||||
ncurses_dep = dependency('ncurses')
|
||||
os_deps = os_deps + [kvm_dep, pthread_dep, ncurses_dep]
|
||||
|
||||
elif osdet == 'openbsd'
|
||||
conf_data.set('U3_OS_bsd', true)
|
||||
os_link_flags = ['-L/usr/local/lib', '-lgmp', '-lsigsegv', '-lcurses']
|
||||
gmp_dep = []
|
||||
sigsegv_dep = []
|
||||
|
||||
else
|
||||
error('Unsupported OS detected:' + osdet)
|
||||
endif
|
||||
@ -313,13 +320,12 @@ endif
|
||||
if(legacy_meson)
|
||||
gmp_dep = find_library('gmp')
|
||||
sigsegv_dep = find_library('sigsegv')
|
||||
else
|
||||
elif osdet != 'openbsd'
|
||||
gmp_dep = meson.get_compiler('c').find_library('gmp')
|
||||
sigsegv_dep = meson.get_compiler('c').find_library('sigsegv')
|
||||
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'])
|
||||
@ -336,7 +342,6 @@ deps = [openssl_dep,
|
||||
curl_dep,
|
||||
libuv_dep,
|
||||
libh2o_dep,
|
||||
cmark_dep,
|
||||
secp256k1_dep,
|
||||
gmp_dep,
|
||||
sigsegv_dep,
|
||||
|
@ -2,5 +2,7 @@ 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('event-time', type : 'boolean', value : false,
|
||||
description : 'Print timing information per event.')
|
||||
option('nix', type: 'boolean', value: false,
|
||||
description: 'Build using nix.')
|
||||
|
@ -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.
|
||||
|
62
noun/jets.c
62
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].
|
||||
@ -1243,18 +1248,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 +1281,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 +1495,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 +1510,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 +1528,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;
|
||||
}
|
||||
|
||||
|
@ -497,6 +497,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;
|
||||
@ -621,14 +622,15 @@ u3m_bail(u3_noun how)
|
||||
}
|
||||
else {
|
||||
c3_assert(_(u3ud(u3h(how))));
|
||||
|
||||
fprintf(stderr, "\r\nbail: %d\r\n", u3h(how));
|
||||
u3m_p("bail", u3t(how));
|
||||
}
|
||||
}
|
||||
|
||||
switch ( how ) {
|
||||
case c3__fail:
|
||||
case c3__fail: {
|
||||
break;
|
||||
}
|
||||
|
||||
case c3__meme: {
|
||||
fprintf(stderr, "bailing out\r\n");
|
||||
abort();
|
||||
@ -1011,6 +1013,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);
|
||||
@ -1104,6 +1107,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;
|
||||
}
|
||||
|
||||
@ -1757,12 +1761,18 @@ 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);
|
||||
snprintf(ful_c, 2048, "%s/.urb/urbit.pill", dir_c);
|
||||
printf("boot: loading %s\r\n", ful_c);
|
||||
|
||||
printf("boot: loading %s\r\n", ful_c);
|
||||
u3v_boot(ful_c);
|
||||
}
|
||||
{
|
||||
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();
|
||||
|
@ -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.
|
||||
|
225
noun/trace.c
225
noun/trace.c
@ -40,11 +40,11 @@ u3t_drop(void)
|
||||
extern void
|
||||
u3_pier_tank(c3_l tab_l, u3_noun tac);
|
||||
|
||||
#ifdef GHETTO
|
||||
/* _t_ghetto(): ghetto timelapse.
|
||||
#ifdef U3_EVENT_TIME_DEBUG
|
||||
/* _t_slog_time(): slog timelapse.
|
||||
*/
|
||||
void
|
||||
_t_ghetto(void)
|
||||
_t_slog_time(void)
|
||||
{
|
||||
static int old;
|
||||
static struct timeval b4, f2, d0;
|
||||
@ -84,11 +84,11 @@ _t_ghetto(void)
|
||||
void
|
||||
u3t_slog(u3_noun hod)
|
||||
{
|
||||
#ifdef GHETTO
|
||||
_t_ghetto();
|
||||
#ifdef U3_EVENT_TIME_DEBUG
|
||||
_t_slog_time();
|
||||
#endif
|
||||
|
||||
if ( c3y == u3du(hod) ) {
|
||||
if ( (0 != u3A->roc) && (c3y == u3du(hod)) ) {
|
||||
u3_noun pri = u3h(hod);
|
||||
|
||||
switch ( pri ) {
|
||||
@ -106,8 +106,8 @@ u3t_slog(u3_noun hod)
|
||||
void
|
||||
u3t_shiv(u3_noun hod)
|
||||
{
|
||||
#ifdef GHETTO
|
||||
_t_ghetto();
|
||||
#ifdef U3_EVENT_TIME_DEBUG
|
||||
_t_slog_time();
|
||||
#endif
|
||||
|
||||
if ( c3n == u3ud(hod) ) {
|
||||
@ -250,7 +250,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;
|
||||
@ -305,7 +308,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.
|
||||
@ -319,7 +322,7 @@ u3t_come(u3_noun lab)
|
||||
u3R->pro.don = u3nc(lab, u3R->pro.don);
|
||||
_ct_lop_o = c3n;
|
||||
return c3y;
|
||||
}
|
||||
}
|
||||
else return c3n;
|
||||
}
|
||||
|
||||
@ -335,6 +338,192 @@ u3t_flee(void)
|
||||
u3z(don);
|
||||
}
|
||||
|
||||
static FILE* trace_file_u = NULL;
|
||||
static int nock_pid_i = 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_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_u,
|
||||
"{\"name\": \"process_name\", \"ph\": \"M\", \"pid\": %d, \"args\": "
|
||||
"{\"name\": \"urbit\"}},\n",
|
||||
nock_pid_i);
|
||||
fprintf(trace_file_u,
|
||||
"{\"name\": \"thread_name\", \"ph\": \"M\", \"pid\": %d, \"tid\": 1, "
|
||||
"\"args\": {\"name\": \"Event Processing\"}},\n",
|
||||
nock_pid_i);
|
||||
fprintf(trace_file_u,
|
||||
"{\"name\": \"thread_sort_index\", \"ph\": \"M\", \"pid\": %d, "
|
||||
"\"tid\": 1, \"args\": {\"sort_index\": 1}},\n",
|
||||
nock_pid_i);
|
||||
fprintf(trace_file_u,
|
||||
"{\"name\": \"thread_name\", \"ph\": \"M\", \"pid\": %d, \"tid\": 2, "
|
||||
"\"args\": {\"name\": \"Nock\"}},\n",
|
||||
nock_pid_i);
|
||||
fprintf(trace_file_u,
|
||||
"{\"name\": \"thread_sort_index\", \"ph\": \"M\", \"pid\": %d, "
|
||||
"\"tid\": 2, \"args\": {\"sort_index\": 2}},\n",
|
||||
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
|
||||
*/
|
||||
c3_d 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_u)
|
||||
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_u)
|
||||
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).
|
||||
c3_d duration = u3t_trace_time() - start_time;
|
||||
if (duration > 33) {
|
||||
c3_c* name = trace_pretty(lab);
|
||||
|
||||
fprintf(trace_file_u,
|
||||
"{\"cat\": \"nock\", \"name\": \"%s\", \"ph\":\"%c\", \"pid\": %d, "
|
||||
"\"tid\": 2, \"ts\": %" PRIu64 ", \"dur\": %" PRIu64 "}, \n",
|
||||
name,
|
||||
'X',
|
||||
nock_pid_i,
|
||||
start_time,
|
||||
duration);
|
||||
|
||||
free(name);
|
||||
}
|
||||
|
||||
u3z(trace);
|
||||
}
|
||||
|
||||
/* u3t_event_trace(): dumps a simple event from outside nock.
|
||||
*/
|
||||
void
|
||||
u3t_event_trace(const c3_c* name, c3_c type)
|
||||
{
|
||||
if (!trace_file_u)
|
||||
return;
|
||||
|
||||
fprintf(trace_file_u,
|
||||
"{\"cat\": \"event\", \"name\": \"%s\", \"ph\":\"%c\", \"pid\": %d, "
|
||||
"\"tid\": 1, \"ts\": %" PRIu64 ", \"id\": \"0x100\"}, \n",
|
||||
name,
|
||||
type,
|
||||
nock_pid_i,
|
||||
u3t_trace_time());
|
||||
}
|
||||
|
||||
extern FILE*
|
||||
u3_term_io_hija(void);
|
||||
|
||||
@ -382,10 +571,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
|
||||
@ -431,7 +620,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);
|
||||
@ -449,13 +638,13 @@ 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);
|
||||
}
|
||||
#elif defined(U3_OS_bsd)
|
||||
# error "Profiling isn't yet supported on BSD"
|
||||
// XX "Profiling isn't yet supported on BSD"
|
||||
#else
|
||||
# error "port: profiling"
|
||||
#endif
|
||||
@ -482,20 +671,20 @@ 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);
|
||||
}
|
||||
|
||||
#elif defined(U3_OS_bsd)
|
||||
# error "Profiling isn't yet supported on BSD"
|
||||
// XX "Profiling isn't yet supported on BSD"
|
||||
#else
|
||||
# error "port: profiling"
|
||||
#endif
|
||||
|
135
noun/vortex.c
135
noun/vortex.c
@ -21,17 +21,25 @@ _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));
|
||||
|
||||
u3z(sys);
|
||||
// lifecycle formula
|
||||
//
|
||||
u3_noun lyf = u3nt(2, u3nc(0, 3), u3nc(0, 2));
|
||||
u3_noun cor = u3n_nock_on(eve, lyf);
|
||||
// save the Arvo core (at +7 of the Arvo gate)
|
||||
//
|
||||
u3A->roc = u3k(u3x_at(7, cor));
|
||||
u3z(cor);
|
||||
}
|
||||
|
||||
/* u3v_fire(): execute initial lifecycle.
|
||||
@ -81,6 +89,8 @@ u3v_lite(u3_noun pil)
|
||||
return pro;
|
||||
}
|
||||
|
||||
// XX deprecated, remove
|
||||
#if 0
|
||||
/* u3v_boot(): correct bootstrap sequence.
|
||||
*/
|
||||
void
|
||||
@ -106,6 +116,7 @@ u3v_boot(c3_c* pas_c)
|
||||
|
||||
u3z(pru);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* u3v_boot_lite(): light bootstrap sequence, just making a kernel.
|
||||
*/
|
||||
@ -121,28 +132,11 @@ u3v_boot_lite(u3_atom lit)
|
||||
|
||||
fprintf(stderr, "lite: final state %x\r\n", u3r_mug(u3t(pru)));
|
||||
|
||||
u3A->ken = 0;
|
||||
u3A->roc = u3k(u3t(pru));
|
||||
|
||||
u3z(pru);
|
||||
}
|
||||
|
||||
// XX deprecated, remove
|
||||
#if 0
|
||||
/* 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);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* u3v_hose(): clear initial ovum queue.
|
||||
*/
|
||||
void
|
||||
@ -189,6 +183,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));
|
||||
|
||||
@ -203,6 +198,8 @@ u3v_wish(const c3_c* str_c)
|
||||
}
|
||||
}
|
||||
|
||||
u3t_event_trace("u3v_wish", 'e');
|
||||
|
||||
u3z(txt);
|
||||
return exp;
|
||||
}
|
||||
@ -241,67 +238,6 @@ u3v_pike(u3_noun ovo, u3_noun cor)
|
||||
}
|
||||
#endif
|
||||
|
||||
// XX deprecated, remove
|
||||
#if 0
|
||||
/* 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=u3h(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* _cv_nock_poke(): call poke through hardcoded interface.
|
||||
*/
|
||||
static u3_noun
|
||||
@ -482,18 +418,6 @@ u3v_poke(u3_noun ovo)
|
||||
return _cv_nock_poke(ovo);
|
||||
}
|
||||
|
||||
// XX deprecated, remove
|
||||
#if 0
|
||||
/* 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));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* u3v_tank(): dump single tank.
|
||||
*/
|
||||
void
|
||||
@ -567,22 +491,6 @@ u3v_plow(u3_noun ova)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
@ -621,7 +529,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);
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 6e7d7e3a92361f11942f0c743d154ab426d1530e
|
||||
Subproject commit 4da94a611ee62bad87ab2b131ffda3bcc0723d9c
|
@ -1 +0,0 @@
|
||||
Subproject commit 8555ef14c4a503f57a0d192bb120159239f4322c
|
@ -1 +1 @@
|
||||
Subproject commit ba4777acac5694925ab78f38577b059cd4a3e8e6
|
||||
Subproject commit 76385f2ebbbc9580a9c236952d68d11d73a6135c
|
@ -1 +1 @@
|
||||
Subproject commit 41958a8aedb3aa2a85332bc8ac0ac389aa725a09
|
||||
Subproject commit 3b1f53c86b71f6fdc099b3b378de6f379b4b8412
|
@ -1 +1 @@
|
||||
Subproject commit 4ebe362f390025e5448e9fcf777c1f38630bc011
|
||||
Subproject commit 029693ff1cbe4f69d3a2da87d0f4f034f92cc0c2
|
@ -1 +1 @@
|
||||
Subproject commit a59901c38a67660039ee93a6170a338634d76ec0
|
||||
Subproject commit 173beb88ee62bddd13874ca04ab338cdec704928
|
@ -1 +1 @@
|
||||
Subproject commit 9e3aece8147d28246c57b84731dad26130c7d1c1
|
||||
Subproject commit 0c3a346a60f0b3bb42445b2c63198a6e0f94c89b
|
@ -1 +1 @@
|
||||
Subproject commit 001378cbe3681af1137553ed7220c79273850d6a
|
||||
Subproject commit 71a75d57ca4e7ca0f7fc2fd84abd93595b0624ca
|
@ -1 +1 @@
|
||||
Subproject commit 9989e23ce8a02a51a1f90a2d5e391ba7d16bef39
|
||||
Subproject commit 87f73ffad3d3047baf1ed134fb7827a9dca163ee
|
@ -1 +1 @@
|
||||
Subproject commit 9d4342099a54cefc3a4117ce0d0c71cff4e48783
|
||||
Subproject commit ec4c7e31b32e07aad80e52f65ff46ac6d6aad986
|
@ -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.
|
||||
|
@ -79,6 +79,7 @@ u3_behn_ef_doze(u3_pier *pir_u, 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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
90
vere/dawn.c
90
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");
|
||||
exit(1);
|
||||
}
|
||||
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;
|
||||
@ -160,6 +155,22 @@ _dawn_fail(u3_noun who, u3_noun rac, u3_noun sas)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* _dawn_need_unit(): produce a value or print error and exit
|
||||
*/
|
||||
static u3_noun
|
||||
_dawn_need_unit(u3_noun nit, c3_c* msg_c)
|
||||
{
|
||||
if ( u3_nul == nit ) {
|
||||
fprintf(stderr, "%s\r\n", msg_c);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
u3_noun pro = u3k(u3t(nit));
|
||||
u3z(nit);
|
||||
return pro;
|
||||
}
|
||||
}
|
||||
|
||||
/* _dawn_purl(): ethereum gateway url as (unit purl)
|
||||
*/
|
||||
static u3_noun
|
||||
@ -263,15 +274,19 @@ 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");
|
||||
|
||||
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));
|
||||
|
||||
bok = _dawn_need_unit(u3do("bloq:take:dawn", u3k(kob)),
|
||||
"boot: block retrieval failed");
|
||||
u3z(oct); u3z(kob);
|
||||
}
|
||||
|
||||
@ -281,7 +296,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
|
||||
@ -289,30 +308,37 @@ 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));
|
||||
|
||||
u3z(oct); u3z(luh);
|
||||
hul = _dawn_need_unit(u3dc("hull:take:dawn", u3k(ship), u3k(luh)),
|
||||
"boot: failed to retrieve public keys");
|
||||
u3z(oct); u3z(luh);
|
||||
}
|
||||
|
||||
u3z(who);
|
||||
}
|
||||
|
||||
// +live:dawn: network state
|
||||
@ -345,15 +371,20 @@ 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");
|
||||
|
||||
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));
|
||||
|
||||
zar = _dawn_need_unit(u3do("czar:take:dawn", u3k(raz)),
|
||||
"boot: failed to retrieve galaxy table");
|
||||
u3z(oct); u3z(raz);
|
||||
}
|
||||
|
||||
@ -363,15 +394,20 @@ 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");
|
||||
|
||||
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));
|
||||
|
||||
tuf = _dawn_need_unit(u3do("turf:take:dawn", u3k(fut)),
|
||||
"boot: failed to retrieve network domains");
|
||||
u3z(oct); u3z(fut);
|
||||
}
|
||||
|
||||
@ -435,4 +471,4 @@ u3_dawn_come(u3_noun star)
|
||||
u3z(star);
|
||||
|
||||
return seed;
|
||||
}
|
||||
}
|
||||
|
@ -1013,11 +1013,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;
|
||||
}
|
||||
|
||||
@ -2682,10 +2682,7 @@ _proxy_peek_read_cb(uv_stream_t* don_u,
|
||||
}
|
||||
else {
|
||||
c3_w len_w = siz_w + con_u->buf_u.len;
|
||||
|
||||
void* ptr_v = c3_realloc(con_u->buf_u.base, len_w);
|
||||
// XX move assert into c3_realloc?
|
||||
c3_assert( 0 != ptr_v );
|
||||
|
||||
memcpy(ptr_v + con_u->buf_u.len, buf_u->base, siz_w);
|
||||
con_u->buf_u = uv_buf_init(ptr_v, len_w);
|
||||
|
21
vere/main.c
21
vere/main.c
@ -89,7 +89,7 @@ _main_getopt(c3_i argc, c3_c** argv)
|
||||
u3_Host.ops_u.kno_w = DefaultKernel;
|
||||
|
||||
// XX re-enable -s, -A
|
||||
while ( (ch_i=getopt(argc, argv,"G:J:B:K:H:w:u:e:E:f:F:k:p:LabcdgqtvxPDRS")) != -1 ) {
|
||||
while ( (ch_i=getopt(argc, argv,"G:J:B:K:H:w:u:j:e:E:f:F:k:p:LabcdgqtvxPDRS")) != -1 ) {
|
||||
switch ( ch_i ) {
|
||||
case 'J': {
|
||||
u3_Host.ops_u.lit_c = strdup(optarg);
|
||||
@ -135,6 +135,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;
|
||||
@ -185,6 +189,13 @@ _main_getopt(c3_i argc, c3_c** argv)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(U3_OS_bsd)
|
||||
if (u3_Host.ops_u.pro == c3y) {
|
||||
fprintf(stderr, "profiling isn't yet supported on BSD\r\n");
|
||||
return c3n;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( 0 != u3_Host.ops_u.fak_c ) {
|
||||
if ( 28 < strlen(u3_Host.ops_u.fak_c) ) {
|
||||
fprintf(stderr, "fake comets are disallowed\r\n");
|
||||
@ -346,6 +357,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",
|
||||
@ -610,6 +622,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);
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize OpenSSL for client and server
|
||||
|
@ -1579,12 +1579,18 @@ u3_pier_plan(u3_noun pax, u3_noun fav)
|
||||
void
|
||||
u3_pier_rand(c3_w* rad_w)
|
||||
{
|
||||
#if defined(U3_OS_bsd) && defined(__OpenBSD__)
|
||||
if (-1 == getentropy(rad_w, 64)) {
|
||||
c3_assert(!"lo_rand");
|
||||
}
|
||||
#else
|
||||
c3_i fid_i = open(DEVRANDOM, O_RDONLY);
|
||||
|
||||
if ( 64 != read(fid_i, (c3_y*) rad_w, 64) ) {
|
||||
c3_assert(!"u3_pier_rand");
|
||||
}
|
||||
close(fid_i);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
42
vere/reck.c
42
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)) ||
|
||||
(u3_nul != 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;
|
||||
}
|
||||
@ -66,6 +64,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
|
||||
@ -278,7 +297,6 @@ static u3_noun
|
||||
_reck_kick_spec(u3_pier* pir_u, 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) &&
|
||||
@ -354,9 +372,9 @@ _reck_kick_spec(u3_pier* pir_u, u3_noun pox, u3_noun fav)
|
||||
}
|
||||
} break;
|
||||
|
||||
case c3__init: p_fav = u3t(fav);
|
||||
{
|
||||
case c3__init: {
|
||||
// king ignores %init
|
||||
// p_fav = u3t(fav);
|
||||
// u3A->own = u3nc(u3k(p_fav), u3A->own);
|
||||
// uL(fprintf(uH, "kick: init: %d\n", p_fav));
|
||||
u3z(pox); u3z(fav); return c3y;
|
||||
@ -369,7 +387,7 @@ _reck_kick_spec(u3_pier* pir_u, 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;
|
||||
@ -420,6 +438,7 @@ _reck_kick_norm(u3_pier* pir_u, u3_noun pox, u3_noun fav)
|
||||
void
|
||||
u3_reck_kick(u3_pier* pir_u, u3_noun ovo)
|
||||
{
|
||||
u3t_event_trace("Effect", 'b');
|
||||
if ( (c3n == _reck_kick_spec(pir_u, u3k(u3h(ovo)), u3k(u3t(ovo)))) &&
|
||||
(c3n == _reck_kick_norm(pir_u, u3k(u3h(ovo)), u3k(u3t(ovo)))) )
|
||||
{
|
||||
@ -455,4 +474,5 @@ u3_reck_kick(u3_pier* pir_u, u3_noun ovo)
|
||||
#endif
|
||||
}
|
||||
u3z(ovo);
|
||||
u3t_event_trace("Effect", 'e');
|
||||
}
|
||||
|
@ -287,7 +287,6 @@ _serf_poke_boot(c3_d evt_d,
|
||||
|
||||
fprintf(stderr, "serf: (5)| core: %x\r\n", u3r_mug(u3t(pru)));
|
||||
|
||||
u3A->ken = 0;
|
||||
u3A->roc = u3k(u3t(pru));
|
||||
|
||||
u3z(pru);
|
||||
|
16
vere/term.c
16
vere/term.c
@ -41,17 +41,26 @@ _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);
|
||||
}
|
||||
|
||||
|
||||
// XX unused, but %hook is in %zuse.
|
||||
// implement or remove
|
||||
//
|
||||
#if 0
|
||||
/* _term_close_cb(): free terminal.
|
||||
*/
|
||||
static void
|
||||
@ -79,6 +88,7 @@ _term_close_cb(uv_handle_t* han_t)
|
||||
}
|
||||
free(tty_u);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* u3_term_io_init(): initialize terminal.
|
||||
*/
|
||||
@ -653,7 +663,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;
|
||||
|
10
vere/unix.c
10
vere/unix.c
@ -370,6 +370,8 @@ _unix_scan_mount_point(u3_pier *pir_u, u3_umon* mon_u)
|
||||
_unix_watch_file(pir_u, fil_u, &mon_u->dir_u, pax_c);
|
||||
}
|
||||
}
|
||||
|
||||
free(pax_c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -543,7 +545,8 @@ _unix_watch_file(u3_pier *pir_u, 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;
|
||||
@ -564,7 +567,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;
|
||||
@ -823,6 +827,8 @@ _unix_update_dir(u3_pier *pir_u, u3_udir* dir_u)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(pax_c);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user