Merge remote-tracking branch 'urbit/master' into master

Conflicts:
	v/loop.c
This commit is contained in:
Steve Dee 2014-02-24 10:45:10 -08:00
commit 9b992ae438
12 changed files with 66 additions and 523 deletions

View File

@ -242,6 +242,18 @@ _ds_chip(u2_wire wir_r,
}
}
/* u2_ds_wipe():
**
** Clear dashboard.
*/
void
u2_ds_wipe(u2_wire wir_r)
{
u2_noun bas_r = u2_wire_bas_r(wir_r);
u2_cs_lose(bas_r, u2_wire_des_r(wir_r));
}
/* u2_ds_mine():
**
** Register and/or save core.

View File

@ -38,7 +38,7 @@ u2_wr_init(c3_m hip_m,
u2_wire_lan(wir_r) = u2_yes;
}
/* Permanent basket = 1/16 of address space.
/* Permanent basket = 1/8 of address space.
*/
{
u2_ray bas_r;

View File

@ -21,7 +21,6 @@
u2_noun bid = u2_bt(wir_r, u2k(cog), u2k(hyp), sep);
u2_noun ret = j2_mby(Pt6, bull)(wir_r, bid, sut);
u2z(sep);
u2z(bid);
return ret;

View File

@ -32,14 +32,19 @@
}
case c3__bull: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
{
u2_noun sub = _heal_by(wir_r, van, q_sut, qog, ref);
u2_noun ret;
if ( u2_yes == u2_sing(u2h(p_sut), u2_t(qog)) ) {
return u2_rx(wir_r, ref);
}
else {
u2_noun sub = _heal_by(wir_r, van, q_sut, qog, ref);
u2_noun ret;
ret = j2_mcy(Pt6, ut, busk)
(wir_r, van, sub, u2h(p_sut), u2h(u2t(p_sut)));
ret = j2_mcy(Pt6, ut, busk)
(wir_r, van, sub, u2h(p_sut), u2h(u2t(p_sut)));
u2z(sub);
return ret;
u2z(sub);
return ret;
}
}
case c3__face: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
{
@ -90,7 +95,7 @@
case c3__bull: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
{
u2_noun sub = _heal_by(wir_r, van, q_sut, qog, ref);
u2_noun sub = _heal_to(wir_r, van, q_sut, gil, qog, ref, now, lat);
u2_noun ret;
ret = j2_mcy(Pt6, ut, busk)

View File

@ -37,6 +37,13 @@
case c3__atom: {
return c3__void;
}
case c3__bull: {
if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ) {
return u2_bl_bail(wir_r, c3__fail);
} else {
return _peek_in(wir_r, van, q_sut, way, axe, gil);
}
}
case c3__cell: {
if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ) {
return u2_bl_bail(wir_r, c3__fail);

View File

@ -1054,6 +1054,7 @@
# define c3__veb c3_s3('v','e','b')
# define c3__veck c3_s4('v','e','c','k')
# define c3__veer c3_s4('v','e','e','r')
# define c3__vega c3_s4('v','e','g','a')
# define c3__velt c3_s4('v','e','l','t')
# define c3__vern c3_s4('v','e','r','n')
# define c3__very c3_s4('v','e','r','y')

View File

@ -56,6 +56,13 @@
u2_noun cor, // retain
const c3_c* tam_c); // retain
/* u2_ds_wipe():
**
** Clear dashboard.
*/
void
u2_ds_wipe(u2_wire wir_r);
/* u2_ds_fire():
**
** Fire formula from core.

View File

@ -1,501 +0,0 @@
/* include/v/tube.h
**
** This file is in the public domain.
*/
/** Tubes - event-driven I/O with type specific queues.
**/
typedef struct _u2_tube {
struct ev_io wax_u; // event handler state
c3_w tid_w; // tube index
struct
/** Data types.
**/
struct _u2_http;
/* u2_hhed: http header.
*/
typedef struct _u2_hhed {
struct _u2_hhed* nex_u;
c3_c* nam_c;
c3_c* val_c;
} u2_hhed;
/* u2_hbod: http body block. Also used for responses.
*/
typedef struct _u2_hbod {
struct _u2_hbod* nex_u;
c3_w len_w;
c3_y hun_y[0];
} u2_hbod;
/* u2_hrat: http parser state.
*/
typedef enum {
u2_hreq_non,
u2_hreq_nam,
u2_hreq_val
} u2_hrat;
/* u2_hmet: http method. Matches jhttp encoding.
*/
typedef enum {
u2_hmet_delete,
u2_hmet_get,
u2_hmet_head,
u2_hmet_post,
u2_hmet_put,
u2_hmet_other // ie, unsupported
} u2_hmet;
/* u2_hreq: http request.
*/
typedef struct _u2_hreq {
u2_hmet met_e; // method
u2_hrat rat_e; // request state
u2_bean liv; // keepalive
c3_c* url_c; // url
u2_hhed* hed_u; // headers
u2_hbod* bod_u; // body parts
} u2_hreq;
/* u2_hrep: simple http response.
*/
typedef struct _u2_hrep {
c3_w sat_w; // status
c3_c* msg_c; // status-message or null
c3_c* typ_c; // content-type
struct _u2_hbod* bod_u; // body (one part)
} u2_hrep;
/* u2_hcon: http connection.
*/
typedef struct _u2_hcon {
struct ev_io wax_u; // event handler state
void* par_u; // struct http_parser *
struct _u2_http* srv_u; // server below
struct _u2_hcon* nex_u; // next in server list
struct _u2_hreq* req_u; // request in process if any
struct _u2_hbod* rep_u; // head of response queue
struct _u2_hbod* per_u; // tail of response queue
} u2_hcon;
/* u2_http: http server.
*/
typedef struct _u2_http {
struct ev_io wax_u; // event handler state
c3_w por_w; // running port
struct _u2_hcon* hon_u; // connection list
struct _u2_http* nex_u; // next in list
} u2_http;
/* u2_steg: kernel stage.
*/
typedef struct {
c3_m mod_m; // stage mode, or 0 for none
u2_noun ken; // stable kernel, or 0 for none
u2_noun ras; // transition kernel, or 0
u2_noun tip; // broken sub-kernel, or 0
u2_noun tul; // toolkit map - [term vase]
struct {
u2_noun seed; // kernel vase
u2_noun what; // platform vase
u2_noun ream; // text to gene
u2_noun rain; // text, path to gene
u2_noun sell; // vase to tank
u2_noun skol; // type to tank
u2_noun slot; // vase fragment
u2_noun slam; // nock vase call - [vase vase]
u2_noun slap; // nock vase pipe - [vase gene]
u2_noun slop; // nock vase pair - [vase vase]
u2_noun scot; // coin printer
} toy;
struct {
u2_noun old; // legacy app (gunn) - pre 221
} dev;
struct {
u2_noun vax; // reck vase
c3_c* who_c; // name prefix
} rec;
struct {
struct { // packet pile
u2_noun log; // packets
u2_noun len; // (lent log)
u2_noun sol; // vase of cato core
} pyl;
} has;
} u2_steg;
/* u2_reck: modern reck structure.
*/
struct _u2_host;
typedef struct {
c3_w kno_w; // kernel stage
c3_w rno_w; // rotor index (always 0)
struct { // function gates, use mung
u2_noun duel; // compare resource trees
u2_noun rain; // parse path, text -> gene
u2_noun ream; // parse text -> gene
u2_noun sham; // SHA-256
u2_noun slam; // call ([vase vase] -> vase)
u2_noun slap; // layer ([vase gene] -> vase)
u2_noun slop; // cell ([vase vase] -> vase)
} toy;
u2_noun now; // current time, as noun
u2_noun wen; // current time, as text
u2_noun ken; // kernel formula
u2_noun syd; // kernel seed
u2_noun rec; // rotor core
} u2_reck;
/* u2_host: entire host.
*/
typedef struct _u2_host {
u2_wire wir_r; // noun system, 1 per thread
c3_c* fel_c; // readline filename
u2_noun pet; // petname of self, atomic
u2_noun pat; // unix path to self, atomic
u2_noun map; // unix arguments as map
u2_steg ver_e[257]; // stages improving downward
c3_w kno_w; // current executing stage
c3_d now_d; // event tick
struct ev_loop *lup_u; // libev event loop
u2_http *htp_u; // http servers, if any
u2_reck rec_u[1]; // rotors (hardcoded to 1)
} u2_host; // host == computer == process
/** Global variables.
**/
c3_global u2_host u2_Host;
c3_global u2_wire u2_Wire;
c3_global c3_c* u2_Local;
c3_global c3_c* u2_System;
c3_global u2_bean u2_Flag_Abort;
c3_global u2_bean u2_Flag_Garbage;
c3_global u2_bean u2_Flag_Profile;
c3_global u2_bean u2_Flag_Verbose;
# define u2_ve_at() ( &u2_Host.ver_e[u2_Host.kno_w] )
/** Functions.
**/
/* Urbit time: 128 bits, leap-free.
**
** High 64 bits: 0x8000.000c.cea3.5380 + Unix time at leap 25 (Jul 2012)
** Low 64 bits: 1/2^64 of a second.
**
** Seconds per Gregorian 400-block: 12.622.780.800
** 400-blocks from 0 to 0AD: 730.692.561
** Years from 0 to 0AD: 292.277.024.400
** Seconds from 0 to 0AD: 9.223.372.029.693.628.800
** Seconds between 0A and Unix epoch: 62.167.219.200
** Seconds before Unix epoch: 9.223.372.091.860.848.000
** The same, in C hex notation: 0x8000000cce9e0d80ULL
**
** New leap seconds after July 2012 (leap second 25) are ignored. The
** platform OS will not ignore them, of course, so they must be detected
** and counteracted. Perhaps this phenomenon will soon find an endpoint.
*/
/* u2_time_sec_in(): urbit seconds from unix time.
**
** Adjust (externally) for future leap secs!
*/
c3_d
u2_time_sec_in(c3_w unx_w);
/* u2_time_sec_out(): unix time from urbit seconds.
**
** Adjust (externally) for future leap secs!
*/
c3_w
u2_time_sec_out(c3_d urs_d);
/* u2_time_fsc_in(): urbit fracto-seconds from unix microseconds.
*/
c3_d
u2_time_fsc_in(c3_w usc_w);
/* u2_time_fsc_out: unix microseconds from urbit fracto-seconds.
*/
c3_w
u2_time_fsc_out(c3_d ufc_d);
/* u2_time_in_tv(): urbit time from struct timeval.
*/
u2_atom
u2_time_in_tv(struct timeval* tim_tv);
/* u2_time_out_tv(): struct timeval from urbit time.
*/
void
u2_time_out_tv(struct timeval* tim_tv, u2_noun now);
/* u2_time_in_ts(): urbit time from struct timespec.
*/
u2_atom
u2_time_in_ts(struct timespec* tim_ts);
/* u2_time_out_ts(): struct timespec from urbit time.
*/
void
u2_time_out_ts(struct timespec* tim_ts, u2_noun now);
/** Filesystem (new api).
**/
/* u2_walk_load(): load file or bail.
*/
u2_noun
u2_walk_load(c3_c* pas_c);
/* u2_walk_save(): save file or bail.
*/
void
u2_walk_save(c3_c* pas_c, u2_noun tim, u2_atom pad);
/* u2_sync_reck(): traverse filesystem for changes -> lamb
*/
u2_noun
u2_sync_reck(u2_reck* rec_u);
/* u2_walk(): traverse `dir_c` to produce an arch, updating `old`.
*/
u2_noun
u2_walk(u2_reck* rec_u, const c3_c* dir_c, u2_noun old);
/** Filesystem (old api).
**/
/* u2_ve_file(): load internal file as atom from local or system.
*/
u2_weak
u2_ve_file(c3_c* ext_c, u2_noun tah);
/* u2_ve_frep(): load [.~ %rep myp {now} tah].
**
** File is either ~ or [nbytes mdate atom].
*/
u2_noun
u2_ve_frep(u2_noun myp, u2_noun tah);
/* u2_ve_date(): date internal file.
*/
c3_d
u2_ve_date(c3_c* ext_c, u2_noun tah);
/* u2_ve_save(): save internal file as atom.
*/
u2_bean
u2_ve_save(c3_c* ext_c, u2_noun tah, u2_noun dat);
/* u2_ve_zeus(): prayer to internal file path. Return unit.
*/
u2_noun
u2_ve_zeus(u2_noun hap);
/** Output.
**/
/* u2_ve_tank(): print a tank at `tab`.
*/
void
u2_ve_tank(c3_l tab_l, u2_noun tac);
/** Kernel control.
**/
/* u2_reck_line(): apply a reck line (protected).
*/
void
u2_reck_line(u2_reck* rec_u, u2_noun lin);
/* u2_reck_boot(): boot the reck engine (unprotected).
*/
void
u2_reck_boot(u2_reck* rec_u);
/* u2_reck_peek(): query the reck namespace.
*/
u2_noun
u2_reck_peek(u2_reck* rec_u, u2_noun hap);
/** Execution system.
**/
/* u2_ve_tag: simple string from stage number.
*/
u2_noun
u2_ve_tag(c3_w a_w);
/* u2_ve_bone(): direct execution from kernel, using ":!%".
*/
u2_noun
u2_ve_bone(c3_c *bon_c);
/* u2_ve_seed(): return kernel seed.
*/
u2_noun
u2_ve_seed();
/* u2_ve_slap(): use slap gate.
*/
u2_noun
u2_ve_slap(u2_noun vax, u2_noun gen);
/* u2_ve_slam(): use slam gate.
*/
u2_noun
u2_ve_slam(u2_noun gat, u2_noun sam);
/* u2_ve_slop(): use slop gate.
*/
u2_noun
u2_ve_slop(u2_noun hed, u2_noun tal);
/* u2_ve_scot(): use scot (atom printer).
*/
u2_noun
u2_ve_scot(u2_noun fom, u2_noun dat);
/* u2_ve_sell(): use sell gate.
*/
u2_noun
u2_ve_sell(u2_noun vax);
/* u2_ve_skol(): use skol gate.
*/
u2_noun
u2_ve_skol(u2_noun typ);
/* u2_ve_ream(): use ream gate.
*/
u2_noun
u2_ve_ream(u2_noun txt);
/* u2_ve_rain(): use rain gate.
*/
u2_noun
u2_ve_rain(u2_noun bon, u2_noun txt);
/* u2_ve_slac(): slap with C string as feature.
*/
u2_noun
u2_ve_slac(u2_noun vax, const c3_c* sam_c);
/* u2_ve_slan(): slap with C string as gene.
*/
u2_noun
u2_ve_slan(u2_noun vax, const c3_c* sam_c);
/* u2_ve_use(): use specified tool.
*/
u2_noun
u2_ve_use(const c3_c* wit_c);
/* u2_ve_set(): set specified tool.
*/
void
u2_ve_set(const c3_c* wit_c, u2_noun zam);
/* u2_ve_step(): replace standard tool gate with new core.
*/
void
u2_ve_step(const c3_c* wit_c, u2_noun wip);
/* u2_ve_hard(): use standard tool gate without type check.
*/
u2_noun
u2_ve_hard(const c3_c* wit_c, c3_c* fun_c, u2_noun arg);
/* u2_ve_soft(): use standard tool gate against vase.
*/
u2_noun
u2_ve_soft(const c3_c* wit_c, c3_c* fun_c, u2_noun vos);
/* u2_ve_meat(): return noun of vase.
*/
u2_noun
u2_ve_meat(u2_noun vos);
/* u2_ve_here(): overlay path search.
*/
u2_noun
u2_ve_here(u2_noun wis);
/** Boot logic.
**/
/* u2_ve_grab(): garbage-collect the world, plus roots.
*/
void
u2_ve_grab(u2_noun som, ...);
/* u2_ve_gunn(): produce a gunn, of any vintage.
*/
u2_noun
u2_ve_gunn();
/* u2_ve_init(): boot the kernel at `kno`.
*/
void
u2_ve_init(c3_w kno_w);
/** Console and command line.
**/
/* u2_ve_dump_columns(): return screen column width from OS.
*/
c3_l
u2_ve_dump_columns(void);
/* u2_ve_dump_tape(): print a tape of text.
*/
void
u2_ve_dump_tape(u2_noun tep);
/* u2_ve_dump_wall(): print a wall of text.
*/
void
u2_ve_dump_wall(u2_noun wol);
/* u2_ve_sway(): print trace stack.
*/
void
u2_ve_sway(c3_l tab_l, u2_noun tax);
/* u2_ve_wine(): analyze and express error result.
*/
void
u2_ve_wine(u2_noun how);
/* u2_ve_line(): execute a command line, fully protected.
*/
void
u2_ve_line(c3_c* lin_c);
/* u2_ve_line_boot(): boot the command-line shell.
*/
void
u2_ve_line_boot(void);
/** HTTP.
**/
/* u2_ve_http_start():
*/
u2_bean
u2_ve_http_start(c3_w por_w);
/* u2_ve_http_sync(): simple synchronous http.
*/
u2_hrep*
u2_ve_http_sync(u2_hreq* req_u);

View File

@ -717,30 +717,30 @@ _lo_mark()
return siz_w;
}
/* _lo_word(): print a word to stderr.
/* _lo_word(): print a word to the passed stream.
*/
static void
_lo_word(c3_w wod_w)
_lo_word(FILE* fil_u, c3_w wod_w)
{
u2_bean top = u2_yes;
if ( wod_w / (1000 * 1000 * 1000) ) {
uL(fprintf(uH, "%u.", wod_w / (1000 * 1000 * 1000)));
fprintf(fil_u, "%u.", wod_w / (1000 * 1000 * 1000));
wod_w %= (1000 * 1000 * 1000);
top = u2_no;
}
if ( wod_w / (1000 * 1000) ) {
uL(fprintf(uH, ((top == u2_yes) ? "%u." : "%03u."),
wod_w / (1000 * 1000)));
fprintf(fil_u, ((top == u2_yes) ? "%u." : "%03u."),
wod_w / (1000 * 1000));
wod_w %= (1000 * 1000);
top = u2_no;
}
if ( wod_w / 1000 ) {
uL(fprintf(uH, ((top == u2_yes) ? "%u." : "%03u."), wod_w / 1000));
fprintf(fil_u, ((top == u2_yes) ? "%u." : "%03u."), wod_w / 1000);
wod_w %= 1000;
top = u2_no;
}
uL(fprintf(uH, ((top == u2_yes) ? "%u" : "%03u"), wod_w));
fprintf(fil_u, ((top == u2_yes) ? "%u" : "%03u"), wod_w);
}
/* u2_lo_grab(): garbage-collect the world, plus roots.
@ -770,13 +770,14 @@ u2_lo_grab(c3_c* cap_c, u2_noun som, ...)
// if ( lec_w || (u2_yes == u2_Flag_Verbose) )
if ( lec_w || !strcmp("init", cap_c) ) {
uL(fprintf(uH, "%s: gc: ", cap_c));
FILE* fil_u = uH;
fprintf(fil_u, "%s: gc: ", cap_c);
if ( lec_w ) {
_lo_word(4 * lec_w);
uL(fprintf(uH, " bytes shed; "));
_lo_word(fil_u, 4 * lec_w);
fprintf(fil_u, " bytes shed; ");
}
_lo_word(4 * siz_w);
uL(fprintf(uH, " bytes live\n"));
_lo_word(fil_u, 4 * siz_w);
uL(fprintf(fil_u, " bytes live\n"));
#if 0
if ( lec_w ) {

View File

@ -827,6 +827,15 @@ _reck_kick_norm(u2_reck* rec_u, u2_noun pox, u2_noun fav)
else switch ( u2h(fav) ) {
default: u2z(pox); u2z(fav); return u2_no;
case c3__vega:
{
// uL(fprintf(uH, "reset\n"));
u2z(pox); u2z(fav);
// u2_ds_wipe(u2_Wire); // doesn't work
return u2_yes;
}
case c3__exit:
{
uL(fprintf(uH, "<<<goodbye>>>\n"));

View File

@ -738,6 +738,7 @@ _sist_rest(u2_reck* rec_u)
if ( 0 == (xno_w % 1000) ) {
uL(fprintf(uH, "{%d}\n", xno_w));
u2_lo_grab("rest", rou, u2_none);
}
}
u2z(rou);

View File

@ -491,8 +491,10 @@ _term_it_show_line(u2_utty* uty_u, c3_w* lin_w, c3_w len_w)
static void
_term_it_refresh_line(u2_utty* uty_u)
{
c3_w len_w = uty_u->tat_u.mir.len_w;
_term_it_show_clear(uty_u);
_term_it_show_wide(uty_u, uty_u->tat_u.mir.len_w, uty_u->tat_u.mir.lin_w);
_term_it_show_wide(uty_u, len_w, uty_u->tat_u.mir.lin_w);
}
/* _term_it_show_more(): new current line.