mirror of
https://github.com/urbit/shrub.git
synced 2024-12-29 15:14:17 +03:00
Fix reversing allocation.
This commit is contained in:
parent
8fa9d0b875
commit
0b885cbf3d
14
Makefile
14
Makefile
@ -271,6 +271,9 @@ V_OFILES=\
|
||||
MAIN_FILE =\
|
||||
v/main.o
|
||||
|
||||
MEME_FILE =\
|
||||
w/test.o
|
||||
|
||||
VERE_OFILES=\
|
||||
$(CRE2_OFILES) \
|
||||
$(OUT_OFILES) \
|
||||
@ -278,6 +281,12 @@ VERE_OFILES=\
|
||||
$(MAIN_FILE) \
|
||||
$(V_OFILES)
|
||||
|
||||
MEME_OFILES=\
|
||||
$(CRE2_OFILES) \
|
||||
$(OUT_OFILES) \
|
||||
$(BASE_OFILES) \
|
||||
$(MEME_FILE)
|
||||
|
||||
# This is a silly hack necessitated by the fact that libuv uses configure
|
||||
#
|
||||
# * Making 'all' obviously requires outside/libuv,
|
||||
@ -303,10 +312,11 @@ LIBED25519=outside/ed25519/ed25519.a
|
||||
|
||||
LIBANACHRONISM=outside/anachronism/build/libanachronism.a
|
||||
|
||||
all: meme
|
||||
|
||||
vere: $(BIN)/vere
|
||||
meme: $(BIN)/meme
|
||||
|
||||
all: vere
|
||||
|
||||
|
||||
$(LIBUV_MAKEFILE) $(LIBUV_MAKEFILE2):
|
||||
@ -333,7 +343,7 @@ $(BIN)/vere: $(LIBCRE) $(VERE_OFILES) $(LIBUV) $(LIBRE2) $(LIBED25519) $(LIBANAC
|
||||
mkdir -p $(BIN)
|
||||
$(CLD) $(CLDOSFLAGS) -o $(BIN)/vere $(VERE_OFILES) $(LIBUV) $(LIBCRE) $(LIBRE2) $(LIBED25519) $(LIBANACHRONISM) $(LIBS)
|
||||
|
||||
$(BIN)/meme: $(LIBCRE) $(VERE_OFILES) $(LIBUV) $(LIBRE2) $(LIBED25519) $(LIBANACHRONISM)
|
||||
$(BIN)/meme: $(LIBCRE) $(MEME_OFILES) $(LIBUV) $(LIBRE2) $(LIBED25519) $(LIBANACHRONISM)
|
||||
mkdir -p $(BIN)
|
||||
$(CLD) $(CLDOSFLAGS) -o $(BIN)/meme $(MEME_OFILES) $(LIBUV) $(LIBCRE) $(LIBRE2) $(LIBED25519) $(LIBANACHRONISM) $(LIBS)
|
||||
|
||||
|
5
g/a.c
5
g/a.c
@ -301,7 +301,6 @@ u3_ca_free(void* tox_v)
|
||||
box_u->use_w -= 1;
|
||||
if ( 0 != box_u->use_w ) return;
|
||||
|
||||
c3_assert(u3_yes == u3_co_is_north);
|
||||
#if 0
|
||||
/* Clear the contents of the block, for debugging.
|
||||
*/
|
||||
@ -354,9 +353,6 @@ u3_ca_free(void* tox_v)
|
||||
if ( 0 == nox_u->use_w ) {
|
||||
_box_detach(nox_u);
|
||||
_box_make(box_u, (box_u->siz_w + nox_u->siz_w), 0);
|
||||
|
||||
box_u = nox_u;
|
||||
box_w = (c3_w*)(void *)nox_u;
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,6 +368,7 @@ u3_ca_free(void* tox_v)
|
||||
if ( 0 == pox_u->use_w ) {
|
||||
_box_detach(pox_u);
|
||||
_box_make(pox_u, (laz_w + box_u->siz_w), 0);
|
||||
box_u = pox_u;
|
||||
}
|
||||
_box_attach(box_u);
|
||||
}
|
||||
|
27
g/e.c
27
g/e.c
@ -660,30 +660,23 @@ _ce_signals(void)
|
||||
// signal(SIGINT, _loom_stop);
|
||||
}
|
||||
|
||||
/* u3_ce_boot(): start the u3 system.
|
||||
/* u3_ce_init(): start the environment, with/without checkpointing.
|
||||
*/
|
||||
void
|
||||
u3_ce_boot(c3_o nuu_o, c3_c* cpu_c)
|
||||
u3_ce_init(c3_o chk_o)
|
||||
{
|
||||
u3P.cpu_c = cpu_c;
|
||||
u3P.nor_u.nam_c = "north";
|
||||
u3P.sou_u.nam_c = "south";
|
||||
|
||||
_ce_limits();
|
||||
_ce_signals();
|
||||
// _ce_signals();
|
||||
|
||||
/* Map at fixed address.
|
||||
*/
|
||||
#if 0
|
||||
u3_Loom = (void *)U2_OS_LoomBase;
|
||||
#endif
|
||||
{
|
||||
c3_w len_w = u3_cc_bytes;
|
||||
void* map_v;
|
||||
|
||||
map_v = mmap((void *)u3_Loom,
|
||||
len_w,
|
||||
u3_so(nuu_o) ? PROT_READ : (PROT_READ | PROT_WRITE),
|
||||
u3_so(chk_o) ? PROT_READ : (PROT_READ | PROT_WRITE),
|
||||
(MAP_ANON | MAP_FIXED | MAP_PRIVATE),
|
||||
-1, 0);
|
||||
|
||||
@ -703,6 +696,18 @@ u3_ce_boot(c3_o nuu_o, c3_c* cpu_c)
|
||||
}
|
||||
printf("loom: mapped %dMB\r\n", len_w >> 20);
|
||||
}
|
||||
}
|
||||
|
||||
/* u3_ce_boot(): start the u3 system.
|
||||
*/
|
||||
void
|
||||
u3_ce_boot(c3_o nuu_o, c3_c* cpu_c)
|
||||
{
|
||||
u3_ce_init(nuu_o);
|
||||
|
||||
u3P.cpu_c = cpu_c;
|
||||
u3P.nor_u.nam_c = "north";
|
||||
u3P.sou_u.nam_c = "south";
|
||||
|
||||
/* Open and apply any patches.
|
||||
*/
|
||||
|
26
g/m.c
26
g/m.c
@ -41,7 +41,7 @@ u3_cm_file(c3_c* pas_c)
|
||||
}
|
||||
}
|
||||
|
||||
/* _find_north(): point to a north home.
|
||||
/* _find_north(): in restored image, point to a north home.
|
||||
*/
|
||||
static u3_road*
|
||||
_find_north(c3_w* mem_w, c3_w siz_w, c3_w len_w)
|
||||
@ -49,21 +49,13 @@ _find_north(c3_w* mem_w, c3_w siz_w, c3_w len_w)
|
||||
return (void *) ((mem_w + len_w) - siz_w);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* _find_south(): install a south road.
|
||||
/* _find_south(): in restored image, point to a south home.
|
||||
*/
|
||||
static u3_road*
|
||||
_find_south(c3_w* mem_w, c3_w siz_w, c3_w len_w)
|
||||
{
|
||||
c3_w* rut_w = mem_w;
|
||||
c3_w* hat_w = rut_w;
|
||||
c3_w* mat_w = ((mem_w + len_w) - siz_w);
|
||||
c3_w* cap_w = mat_w;
|
||||
u3_road* rod_u = (void*) mat_w;
|
||||
|
||||
return rod_u;
|
||||
return (void *)(mem_w + siz_w);
|
||||
}
|
||||
#endif
|
||||
|
||||
static u3_road*
|
||||
_boot_north(c3_w* mem_w, c3_w siz_w, c3_w len_w)
|
||||
@ -90,9 +82,9 @@ _boot_north(c3_w* mem_w, c3_w siz_w, c3_w len_w)
|
||||
static u3_road*
|
||||
_boot_south(c3_w* mem_w, c3_w siz_w, c3_w len_w)
|
||||
{
|
||||
c3_w* rut_w = mem_w;
|
||||
c3_w* rut_w = (mem_w + len_w);
|
||||
c3_w* hat_w = rut_w;
|
||||
c3_w* mat_w = ((mem_w + len_w) - siz_w);
|
||||
c3_w* mat_w = mem_w + siz_w;
|
||||
c3_w* cap_w = mat_w;
|
||||
u3_road* rod_u = (void*) mat_w;
|
||||
|
||||
@ -149,7 +141,7 @@ u3_cm_dump(void)
|
||||
c3_w i_w;
|
||||
|
||||
hat_w = u3_so(u3_co_is_north) ? u3R->hat_w - u3R->rut_w
|
||||
: u3R->hat_w - u3R->rut_w;
|
||||
: u3R->rut_w - u3R->hat_w;
|
||||
|
||||
for ( i_w = 0; i_w < u3_cc_fbox_no; i_w++ ) {
|
||||
u3_cs_fbox* fre_u = u3R->all.fre_u[i_w];
|
||||
@ -163,15 +155,15 @@ u3_cm_dump(void)
|
||||
hat_w, fre_w, (hat_w - fre_w));
|
||||
|
||||
if ( 0 != (hat_w - fre_w) ) {
|
||||
c3_w* box_w = u3R->rut_w;
|
||||
c3_w* box_w = u3_so(u3_co_is_north) ? u3R->rut_w : u3R->hat_w;
|
||||
c3_w mem_w = 0;
|
||||
|
||||
while ( box_w < u3R->hat_w ) {
|
||||
while ( box_w < (u3_so(u3_co_is_north) ? u3R->hat_w : u3R->rut_w) ) {
|
||||
u3_cs_box* box_u = (void *)box_w;
|
||||
|
||||
if ( 0 != box_u->use_w ) {
|
||||
#ifdef U3_MEMORY_DEBUG
|
||||
printf("live %d words, code %x\n", box_u->siz_w, box_u->cod_w);
|
||||
// printf("live %d words, code %x\n", box_u->siz_w, box_u->cod_w);
|
||||
#endif
|
||||
mem_w += box_u->siz_w;
|
||||
}
|
||||
|
@ -18,3 +18,8 @@
|
||||
*/
|
||||
void
|
||||
u3_ce_boot(c3_o nuu_o, c3_c* cpu_c);
|
||||
|
||||
/* u3_ce_init(): start the environment, with/without checkpointing.
|
||||
*/
|
||||
void
|
||||
u3_ce_init(c3_o chk_o);
|
||||
|
@ -200,8 +200,8 @@
|
||||
u3_not(u3_co_north_is_junior(dog)))
|
||||
|
||||
# define u3_co_south_is_senior(dog) \
|
||||
u3_say((u3_co_to_wtr(dog) >= u3R->mat_w) || \
|
||||
(u3_co_to_wtr(dog) < u3R->cap_w))
|
||||
u3_say((u3_co_to_wtr(dog) < u3R->mat_w) || \
|
||||
(u3_co_to_wtr(dog) >= u3R->rut_w))
|
||||
|
||||
# define u3_co_south_is_junior(dog) \
|
||||
u3_say((u3_co_to_wtr(dog) >= u3R->cap_w) && \
|
||||
|
38
w/test.c
38
w/test.c
@ -137,11 +137,11 @@ test(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
static void
|
||||
_test_hash(void)
|
||||
{
|
||||
_road_dump();
|
||||
u3_cm_dump();
|
||||
{
|
||||
u3_ch_root* har_u = u3_ch_new();
|
||||
c3_w i_w;
|
||||
@ -168,17 +168,17 @@ _test_hash(void)
|
||||
}
|
||||
u3_ch_free(har_u);
|
||||
}
|
||||
_road_dump();
|
||||
u3_cm_dump();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
static void
|
||||
_test_jam(void)
|
||||
{
|
||||
_road_dump();
|
||||
u3_cm_dump();
|
||||
{
|
||||
u3_noun pil = u3_walk_load("pill/easy1.pill");
|
||||
u3_noun pil = u3_walk_load("urb/urbit.pill");
|
||||
u3_noun cue, jam;
|
||||
|
||||
printf("cueing pill - %d bytes\n", u3_cr_met(3, pil));
|
||||
@ -194,21 +194,10 @@ _test_jam(void)
|
||||
|
||||
u3z(cue);
|
||||
}
|
||||
_road_dump();
|
||||
u3_cm_dump();
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
_test_easy0(void)
|
||||
{
|
||||
u3_noun cor = u3_cke_cue(u3_walk_load("pill/easy0.pill"));
|
||||
u3_noun val;
|
||||
|
||||
printf("test_easy1: core mug %x\n", u3_cr_mug(cor));
|
||||
val = u3_cn_slam_on(cor, u3nc(42, 17));
|
||||
printf("val %d\n", val);
|
||||
}
|
||||
|
||||
static void
|
||||
_test_test(void)
|
||||
{
|
||||
@ -221,26 +210,27 @@ _test_test(void)
|
||||
u3z(val);
|
||||
}
|
||||
|
||||
int FOO;
|
||||
|
||||
// A simple memory tester.
|
||||
//
|
||||
int c3_cooked() { u3_cm_bail(c3__oops); return 0; }
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
printf("hello, world: len %dMB\n", (1 << U2_OS_LoomBits) >> 18);
|
||||
// _test_words();
|
||||
|
||||
u3_cm_boot(U2_OS_LoomBase, (1 << U2_OS_LoomBits));
|
||||
u3_ce_init(u3_no);
|
||||
u3_cm_boot(u3_yes);
|
||||
u3_cj_boot();
|
||||
|
||||
u3_cm_dump();
|
||||
|
||||
u3_cj_boot();
|
||||
printf("booted.\n");
|
||||
|
||||
{
|
||||
// _test_hash();
|
||||
_test_hash();
|
||||
// _test_jam();
|
||||
// _test_easy0();
|
||||
_test_test();
|
||||
}
|
||||
u3_cm_clear();
|
||||
u3_cm_dump();
|
||||
|
Loading…
Reference in New Issue
Block a user