Before gmp malloc changeover.

This commit is contained in:
C. Guy Yarvin 2014-11-07 14:54:59 -08:00
parent 9ad1e215bb
commit 4815cbcfa6
22 changed files with 772 additions and 559 deletions

View File

@ -59,7 +59,7 @@ INCLUDE=i
MDEFINES=-DU3_OS_$(OS) -DU3_OS_ENDIAN_$(ENDIAN) -D U3_LIB=\"$(LIB)\"
# NOTFORCHECKIN - restore -O3
CFLAGS= $(COSFLAGS) -O3 -msse3 -ffast-math \
CFLAGS= $(COSFLAGS) -g -msse3 -ffast-math \
-funsigned-char \
-I/usr/local/include \
-I/opt/local/include \

View File

@ -17,7 +17,7 @@ arithmetic operation in Nock is increment. So it's nontrivial
to compute both efficiently and correctly.
Two: `u3` is designed to support "permanent computing," ie, a
single-level store which is transparently checkpointed. This
single-level store which is transparently snapshotted. This
implies a specialized memory-management model, etc, etc.
(Does `u3` depend on the higher levels of Urbit, Arvo and Hoon?
@ -164,6 +164,41 @@ They're defined in `i/n/u.h`. Finally, `i/all.h` includes all
these headers (fast compilers, yay) and is all you need to
program in `u3`.
### u3: noun internals
A noun is a `u3_noun` - currently defined as a 32-bit `c3_w`.
If your `u3_noun` is less than `(1 << 31)`, it's a direct atom.
Every unsigned integer between `0` and `0x7fffffff` inclusive is
its own noun.
If bit `31` is set in a `u3_noun`, bit `30` is always set - this
bit is reserved. Bit `29` is `1` if the noun is a cell, `0` if
it's an atom. Bits `28` through `0` are a word pointer into the
loom - see below. The structures are:
typedef struct {
c3_w mug_w;
c3_w len_w;
c3_w buf_w[0]; // actually [len_w]
} u3a_atom;
typedef struct {
c3_w mug_w;
u3_noun hed;
u3_noun tel;
} u3a_cell;
The only thing that should be mysterious here is `mug_w`, which
is a 31-bit lazily computed nonzero short hash (FNV currently,
soon Murmur3). If `mug_w` is 0, the hash is not yet computed.
We also hijack this field for various hacks, such as saving the
new address of a noun when copying over.
Also, the value `0xffffffff` is `u3_none`, which is never a valid
noun. Use the type `u3_weak` to express that a noun variable may
be `u3_none`.
### u3: reference counts
The only really essential thing you need to know about `u3` is
@ -174,9 +209,10 @@ u3 deals with reference-counted, immutable, acyclic nouns.
Unfortunately, we are not Apple and can't build reference
counting into your C compiler, so you need to count by hand.
Every allocated noun contains a counter which counts the number
of references to it - typically variables with type `u3_noun`.
When this counter goes to 0, the noun is freed.
Every allocated noun (or any allocation object, because our
allocator is general-purpose) contains a counter which counts the
number of references to it - typically variables with type
`u3_noun`. When this counter goes to 0, the noun is freed.
To tell `u3` that you've added a reference to a noun, call the
function `u3a_gain()` or its shorthand `u3k()`. (For your
@ -191,6 +227,8 @@ Memory leaks are difficult to debug - the best way to handle
leaks is just to revert to a version that didn't have them, and
look over your code again.)
(You can gain or lose a direct atom. It does nothing.)
### u3: reference protocols
*THIS IS THE MOST CRITICAL SECTION IN THE `u3` DOCUMENTATION.*
@ -254,8 +292,8 @@ Transfer semantics are more appropriate for functions which make
nouns, which is obviously what most functions do.
In general, though, in most places it's not worth thinking about
what your function does. There is probably a convention for it.
Follow the convention.
what your function does. There is a convention for it, which
depends on where it is, not what it is. Follow the convention.
### u3: reference conventions
@ -269,7 +307,141 @@ If functions outside this set have retain semantics, they need to
be commented, both in the `.h` and `.c` file, with `RETAIN` in
all caps. Yes, it's this important.
### u3: system and memory architecture
### u3: system architecture
If you just want to tinker with some existing code, it might be
enough to understand the above. If not, it's probably worth
taking the time to look at `u3` as a whole.
`u3` is designed to work as a persistent event processor.
Logically, it computes a function of the form
f(event, old state) -> (actions, new state)
Obviously almost any computing model - including, but not limited
to, Urbit - can be defined in this form. To create the illusion
of a computer that never loses state and never fails, we:
- log every event externally before it goes into u3
- keep a single reference to a permanent state noun.
- can abort any event without damaging the permanent state.
- snapshot the permanent state periodically, and/or prune logs.
### u3: the road model
`u3` uses a memory design which I'm sure someone has invented
somewhere before, because it's not very clever, but I've never
seen it anywhere in particular.
Every allocation starts with a solid block of memory, which `u3`
calls the `loom`. How do we allocate on the loom? You're
probably familiar with the Unix heap-stack design, in which the
stack grows downward and the heap (malloc arena) grows upward:
0 brk ffff
| heap | stack |
|------------#################################+++++++++++++|
| | |
0 sp ffff
A road is a normal heap-stack system, except that the heap
and stack can point in *either direction*. Therefore, inside
a road, we can nest another road in the *opposite direction*.
When the opposite road completes, its heap is left on top of
the opposite heap's stack. It's no more than the normal
behavior of a stack machine for all subcomputations to push
their results on the stack.
The performance tradeoff of "leaping" - reversing directions in
the road - is that if the outer computation wants to preserve the
results of the inner one, not just use them for temporary
purposes, it has to *copy them*.
This is a trivial cost in some cases, a prohibitive cost in
others. The upside, of course, is that all garbage accrued
in the inner computation is discarded at zero cost.
The goal of the road system is the ability to *layer* memory
models. If you are allocating on a road, you have no idea
how deep within a nested road system you are - in other words,
you have no idea exactly how durable your result may be.
But free space is never fragmented within a road.
Roads do not reduce the generality or performance of a memory
system, since even the most complex GC system can be nested
within a road at no particular loss of performance - a road
is just a block of memory.
Each road (`u3a_road` to be exact) uses four pointers: `rut` is
the bottom of the arena, `hat` the top of the arena, `mat` the
bottom of the stack, `cap` the top of the stack. (Bear in mind
that the road "stack" is not actually used as the C function-call
stack, though it probably should be.)
A "north" road has the stack high and the heap low:
0 rut hat ffff
| | | |
|~~~~~~~~~~~~-------##########################+++++++$~~~~~|
| | | |
0 cap mat ffff
A "south" road is the other way around:
0 mat cap ffff
| | | |
|~~~~~~~~~~~~$++++++##########################--------~~~~~|
| | | |
0 hat rut ffff
Legend: `-` is durable storage (heap); `+` is temporary storage
(stack); `~` is deep storage (immutable); `$` is the allocation
frame `#` is free memory.
Pointer restrictions: pointers stored in `+` can point anywhere.
Pointers in `-` can only point to `-` or `~`; pointers in `~`
only point to `~`.
To "leap" is to create a new inner road in the `###` free space.
but in the reverse direction, so that when the inner road
"falls" (terminates), its durable storage is left on the
temporary storage of the outer road.
`u3` keeps a global variable, `u3_Road` or its alias `u3R`, which
points to the current road. (If we ever run threads in inner
roads - see below - this will become a thread-local variable.)
Relative to `u3R`, `+` memory is called `junior` memory; `-`
memory is `normal` memory; `~` is `senior` memory.
### u3: persistence, events, and the road model
We're now ready to understand why this system works so logically
with the event and persistence model.
The key is that *we don't update refcounts in senior memory.*
A pointer from an inner road to an outer road is not counted.
Also, the outmost, or `surface` road, is the only part of the
image that gets checkpointed.
So the surface road contains the entire durable state of `u3`.
When we process an event, or perform any kind of complicated or
interesting calculation, we process it in an inner road.
Since processing in an inner road does not touch surface memory,
(a) we can leave the surface road in a read-only state and not
mark its pages dirty; (b) we can abort an inner calculation
without screwing up the surface; and (c) because inner results
are copied onto the surface, the surface doesn't get fragmented.
All of (a), (b) and (c) are needed for checkpointing to be easy.
It might be tractable otherwise, but easy is even better.
Moreover, while the surface is most definitely single-threaded,
we could easily run multiple threads in multiple inner roads
(as long as the threads don't have pointers into each others'
memory, which they obviously shouldn't).
### u3: rules for C programming
Describing

365
i/n/a.h
View File

@ -1,23 +1,46 @@
/* include/g/a.h
/* i/n/a.h
**
** This file is in the public domain.
*/
/** Tunables.
/** Options.
**/
# undef U3_MEMORY_DEBUG
# ifdef U3_MEMORY_DEBUG
# define u3a_leak_on(x) (u3_Code = x)
# define u3a_leak_off (u3_Code = 0)
# endif
# define u3a_bits U3_OS_LoomBits // 28, max 29
# define u3a_page 12 // 16Kbyte pages
# define u3a_pages (1 << (u3a_bits - u3a_page)) // 2^16 pages
# define u3a_words (1 << u3a_bits)
# define u3a_bytes (c3_w)((1 << (2 + u3a_bits)))
/* U3_MEMORY_DEBUG: add debugging information to heap. Breaks image.
*/
# undef U3_MEMORY_DEBUG
/** Data structures.
/** Constants.
**/
/* u3a_bits: number of bits in word-addressed pointer. 29 == 2GB.
*/
# define u3a_bits 29
/* u3a_page: number of bits in word-addressed page. 12 == 16Kbyte page.
*/
# define u3a_page 12
/* u3a_pages: number of pages in memory.
*/
# define u3a_pages (1 << (u3a_bits - u3a_page))
/* u3a_words: number of words in memory.
*/
# define u3a_words (1 << u3a_bits)
/* u3a_bytes: number of bytes in memory.
*/
# define u3a_bytes (c3_w)((1 << (2 + u3a_bits)))
/* u3a_minimum: minimum number of words in a box.
*/
# define u3a_minimum 6
/* u3a_fbox_no: number of free lists per size.
*/
# define u3a_fbox_no 28
/** Structures.
**/
/* u3_atom, u3_cell: logical atom and cell structures.
*/
@ -37,6 +60,118 @@
u3_noun tel;
} u3a_cell;
/* u3a_box: classic allocation box.
**
** The box size is also stored at the end of the box in classic
** bad ass malloc style. Hence a box is:
**
** ---
** siz_w
** use_w
** user data
** siz_w
** ---
**
** Do not attempt to adjust this structure!
*/
typedef struct _u3a_box {
c3_w siz_w; // size of this box
c3_w use_w; // reference count; free if 0
# ifdef U3_MEMORY_DEBUG
c3_w eus_w; // recomputed refcount
c3_w cod_w; // tracing code
# endif
} u3a_box;
/* u3a_fbox: free node in heap. Sets minimum node size.
*/
typedef struct _u3a_fbox {
u3a_box box_u;
u3p(struct _u3a_fbox) pre_p;
u3p(struct _u3a_fbox) nex_p;
} u3a_fbox;
/* u3a_road: contiguous allocation and execution context.
*/
typedef struct _u3a_road {
struct _u3a_road* par_u; // parent road
struct _u3a_road* kid_u; // child road list
struct _u3a_road* nex_u; // sibling road
struct _u3a_road* now_u; // current road pointer
u3p(c3_w) cap_p; // top of transient region
u3p(c3_w) hat_p; // top of durable region
u3p(c3_w) mat_p; // bottom of transient region
u3p(c3_w) rut_p; // bottom of durable region
u3p(c3_w) ear_p; // original cap if kid is live
c3_w fut_w[32]; // futureproof buffer
struct { // escape buffer
union {
jmp_buf buf;
c3_w buf_w[256]; // futureproofing
};
} esc;
struct { // miscellaneous config
c3_w fag_w; // flag bits
} how; //
struct { // allocation pools
u3p(u3a_fbox) fre_p[u3a_fbox_no]; // heap by node size log
c3_w fre_w; // number of free words
} all;
struct { // jet dashboard
u3p(u3h_root) har_p; // jet index (old style)
u3_noun das; // dashboard (new style)
} jed;
struct { // namespace
u3_noun flu; // (list $+(* (unit))), inward
} ski;
struct { // trace stack
u3_noun tax; // (list ,*)
u3_noun mer; // emergency buffer to release
} bug;
struct { // profile stack
c3_d nox_d; // nock steps
u3_noun don; // ++path
u3_noun day; // profile data, ++doss
} pro;
struct { // memoization
u3p(u3h_root) har_p; // (map (pair term noun) noun)
} cax;
} u3a_road;
typedef u3a_road u3_road;
/* u3a_flag: flags for how.fag_w.
*/
enum u3a_flag {
u3a_flag_debug = 0x1, // debug memory
u3a_flag_gc = 0x2, // garbage collect once
u3a_flag_sand = 0x4, // sand mode, bump allocation
u3a_flag_die = 0x8 // process was asked to exit
};
/** Macros. Should be better commented.
**/
/* In and out of the box.
*/
# define u3a_boxed(len_w) (len_w + c3_wiseof(u3a_box) + 1)
# define u3a_boxto(box_v) ( (void *) \
( ((c3_w *)(void*)(box_v)) + \
c3_wiseof(u3a_box) ) )
# define u3a_botox(tox_v) ( (struct _u3a_box *) \
(void *) \
( ((c3_w *)(void*)(tox_v)) - \
c3_wiseof(u3a_box) ) )
/* Inside a noun.
*/
# define u3a_is_cat(som) (((som) >> 31) ? c3n : c3y)
@ -65,190 +200,6 @@
? ( ((u3a_cell *)u3a_to_ptr(som))->tel )\
: u3m_bail(c3__exit) )
/* u3a_box: classic allocation box.
**
** The box size is also stored at the end of the box in classic
** bad ass malloc style. Hence a box is:
**
** ---
** siz_w
** use_w
** if(debug) cod_w
** user data
** siz_w
** ---
**
** Do not attempt to adjust this structure!
*/
typedef struct _u3a_box {
c3_w siz_w; // size of this box
c3_w use_w; // reference count; free if 0
# ifdef U3_MEMORY_DEBUG
c3_w eus_w; // recomputed refcount
c3_w cod_w; // tracing code
# endif
} u3a_box;
# define u3a_boxed(len_w) (len_w + c3_wiseof(u3a_box) + 1)
# define u3a_boxto(box_v) ( (void *) \
( ((c3_w *)(void*)(box_v)) + \
c3_wiseof(u3a_box) ) )
# define u3a_botox(tox_v) ( (struct _u3a_box *) \
(void *) \
( ((c3_w *)(void*)(tox_v)) - \
c3_wiseof(u3a_box) ) )
/* u3a_fbox: free node in heap. Sets minimum node size.
**
*/
typedef struct _u3a_fbox {
u3a_box box_u;
u3p(struct _u3a_fbox) pre_p;
u3p(struct _u3a_fbox) nex_p;
} u3a_fbox;
# define u3_cc_minimum 6
# define u3_cc_fbox_no 28
/* u3a_road: contiguous allocation and execution context.
**
** A road is a normal heap-stack system, except that the heap
** and stack can point in either direction. Therefore, inside
** a road, we can nest another road in the opposite direction.
**
** When the opposite road completes, its heap is left on top of
** the opposite heap's stack. It's no more than the normal
** behavior of a stack machine for all subcomputations to push
** their results, internally durable, on the stack.
**
** The performance tradeoff of "leaping" - reversing directions
** in the road - is that if the outer computation wants to
** preserve the results of the inner one, not just use them for
** temporary purposes, it has to copy them.
**
** This is a trivial cost in some cases, a prohibitive cost in
** others. The upside, of course, is that all garbage accrued
** in the inner computation is discarded at zero cost.
**
** The goal of the road system is the ability to *layer* memory
** models. If you are allocating on a road, you have no idea
** how deep within a nested road system you are - in other words,
** you have no idea exactly how durable your result may be.
** But free space is never fragmented within a road.
**
** Roads do not reduce the generality or performance of a memory
** system, since even the most complex GC system can be nested
** within a road at no particular loss of performance - a road
** is just a block of memory. The cost of road allocation is,
** at least in theory, the branch prediction hits when we try to
** decide which side of the road we're allocating on. The road
** system imposes no pointer read or write barriers, of course.
**
** The road can point in either direction. If cap > hat, it
** looks like this ("north"):
**
** 0 rut hat ffff
** | | | |
** |~~~~~~~~~~~~-------##########################+++++++$~~~~~|
** | | | |
** 0 cap mat ffff
**
** Otherwise, it looks like this ("south"):
**
** 0 mat cap ffff
** | | | |
** |~~~~~~~~~~~~$++++++##########################--------~~~~~|
** | | | |
** 0 hat rut ffff
**
** Legend: - is durable storage (heap); + is temporary storage
** (stack); ~ is deep storage (immutable); $ is the allocation block;
** # is free memory.
**
** Pointer restrictions: pointers stored in + can point anywhere,
** except to more central pointers in +. (Ie, all pointers from
** stack to stack must point downward on the stack.) Pointers in
** - can only point to - or ~; pointers in ~ only point to ~.
**
** To "leap" is to create a new inner road in the ### free space.
** but in the reverse direction, so that when the inner road
** "falls" (terminates), its durable storage is left on the
** temporary storage of the outer road.
**
** In all cases, the pointer in a u3_noun is a word offset into
** u3H, the top-level road.
*/
typedef struct _u3a_road {
struct _u3a_road* par_u; // parent road
struct _u3a_road* kid_u; // child road list
struct _u3a_road* nex_u; // sibling road
struct _u3a_road* now_u; // current road pointer
u3p(c3_w) cap_p; // top of transient region
u3p(c3_w) hat_p; // top of durable region
u3p(c3_w) mat_p; // bottom of transient region
u3p(c3_w) rut_p; // bottom of durable region
u3p(c3_w) ear_p; // original cap if kid is live
c3_w fut_w[32]; // futureproof buffer
struct { // escape buffer
union {
jmp_buf buf;
c3_w buf_w[256]; // futureproofing
};
} esc;
struct { // miscellaneous config
c3_w fag_w; // flag bits
} how; //
struct { // allocation pools
u3p(u3a_fbox) fre_p[u3_cc_fbox_no]; // heap by node size log
c3_w fre_w; // number of free words
} all;
struct { // jet dashboard
u3p(u3h_root) har_p; // jet index (old style)
u3_noun das; // dashboard (new style)
} jed;
struct { // namespace
u3_noun flu; // (list $+(* (unit))), inward
} ski;
struct { // trace stack
u3_noun tax; // (list ,*)
u3_noun mer; // emergency buffer to release
} bug;
struct { // profile stack
c3_d nox_d; // nock steps
u3_noun don; // ++path
u3_noun day; // profile data, ++doss
} pro;
struct { // memoization
u3p(u3h_root) har_p; // (map (pair term noun) noun)
} cax;
} u3a_road;
typedef u3a_road u3_road;
/** Flags.
**/
enum u3a_flag {
u3a_flag_debug = 0x1, // debug memory
u3a_flag_gc = 0x2, // garbage collect once
u3a_flag_sand = 0x4, // sand mode, bump allocation
u3a_flag_die = 0x8 // process was asked to exit
};
/** Macros.
**/
# define u3a_into(x) ((void *)(u3_Loom + (x)))
# define u3a_outa(p) (((c3_w*)(void*)(p)) - u3_Loom)
@ -345,8 +296,8 @@
**/
/* u3_Road / u3R: current road (thread-local).
*/
c3_global u3_road* u3_Road;
# define u3R u3_Road
c3_global u3_road* u3a_Road;
# define u3R u3a_Road
/* u3_Code: memory code.
*/
@ -370,7 +321,7 @@
/* u3a_malloc(): allocate storage measured in bytes.
*/
void*
u3a_malloc(c3_w len_w);
u3a_malloc(size_t len_i);
/* u3a_free(): free storage.
*/
@ -385,7 +336,17 @@
/* u3a_realloc(): byte realloc.
*/
void*
u3a_realloc(void* lag_v, c3_w len_w);
u3a_realloc(void* lag_v, size_t len_i);
/* u3a_realloc2(): gmp-shaped realloc.
*/
void*
u3a_realloc2(void* lag_v, size_t old_i, size_t new_i);
/* u3a_free2(): gmp-shaped free.
*/
void
u3a_free2(void* tox_v, size_t siz_i);
/* Reference and arena control.

View File

@ -1,4 +1,4 @@
/* include/g/e.h
/* i/n/e.h
**
** This file is in the public domain.
*/
@ -27,7 +27,7 @@
c3_i ctl_i;
c3_i mem_i;
u3e_control* con_u;
} u3_cs_patch;
} u3_ce_patch;
/* u3e_image: memory segment, open file.
*/
@ -52,8 +52,8 @@
**/
/* u3_Pool / u3P: global memory control.
*/
c3_global u3e_pool u3_Pool;
# define u3P u3_Pool
c3_global u3e_pool u3e_Pool;
# define u3P u3e_Pool
/** Functions.

View File

@ -1,4 +1,4 @@
/* include/g/h.h
/* include/n/h.h
**
** This file is in the public domain.
*/

View File

@ -1,4 +1,4 @@
/* include/g/i.h
/* include/n/i.h
**
** This file is in the public domain.
*/

32
i/n/j.h
View File

@ -1,4 +1,4 @@
/* include/g/j.h
/* include/n/j.h
**
** This file is in the public domain.
*/
@ -62,9 +62,9 @@
***
*** All of these are transient structures allocated with malloc.
**/
/* u3e_harm: jet arm.
/* u3j_harm: jet arm.
*/
typedef struct _u3e_harm {
typedef struct _u3j_harm {
c3_c* fcs_c; // `.axe` or name
u3_noun (*fun_f)(u3_noun); // compute or 0 / semitransfer
// c3_o (*val_f)(u3_noun); // validate or 0 / retain
@ -72,35 +72,35 @@
c3_o tot; // total (never punts)
c3_o liv; // live (enabled)
c3_l axe_l; // computed/discovered axis
struct _u3e_core* cop_u; // containing core
} u3e_harm;
struct _u3j_core* cop_u; // containing core
} u3j_harm;
/* u3e_core: driver definition.
/* u3j_core: driver definition.
*/
typedef struct _u3e_core {
typedef struct _u3j_core {
c3_c* cos_c; // control string
struct _u3e_harm* arm_u; // blank-terminated static list
struct _u3e_core* dev_u; // blank-terminated static list
struct _u3e_core* par_u; // dynamic parent pointer
struct _u3j_harm* arm_u; // blank-terminated static list
struct _u3j_core* dev_u; // blank-terminated static list
struct _u3j_core* par_u; // dynamic parent pointer
c3_l axe_l; // axis to parent
c3_l jax_l; // index in global dashboard
} u3e_core;
} u3j_core;
/* u3e_dash, u3_Dash, u3D: jet dashboard singleton
*/
typedef struct _u3e_dash {
u3e_core* dev_u; // null-terminated static list
u3j_core* dev_u; // null-terminated static list
c3_l len_l; // dynamic array length
c3_l all_l; // allocated length
u3e_core* ray_u; // dynamic array by axis
} u3e_dash;
u3j_core* ray_u; // dynamic array by axis
} u3j_dash;
/** Globals.
**/
/* u3_Dash: jet dashboard.
*/
extern u3e_dash u3_Dash;
# define u3D u3_Dash
extern u3j_dash u3j_Dash;
# define u3D u3j_Dash
/** Functions.

View File

@ -1,4 +1,4 @@
/* include/g/m.h
/* i/n/m.h
**
** This file is in the public domain.
*/
@ -120,9 +120,9 @@
*/
u3_noun
u3m_soft_top(c3_w sec_w, // timer seconds
c3_w pad_w, // base memory pad
u3_funk fun_f,
u3_noun arg);
c3_w pad_w, // base memory pad
u3_funk fun_f,
u3_noun arg);
/* u3m_soft_slam: top-level call.
*/

View File

@ -1,4 +1,4 @@
/* include/g/n.h
/* i/n/n.h
**
** This file is in the public domain.
*/

View File

@ -1,4 +1,4 @@
/* include/g/r.h
/* i/n/r.h
**
** This file is in the public domain.
*/

94
i/n/t.h
View File

@ -1,60 +1,60 @@
/* include/g/t.h
/* i/n/t.h
**
** This file is in the public domain.
*/
/** Tracing.
**/
/* u3t_push(): push on trace stack.
*/
void
u3t_push(u3_noun mon);
/** Functions.
**/
/* u3t_push(): push on trace stack.
*/
void
u3t_push(u3_noun mon);
/* u3t_mean(): push `[%mean roc]` on trace stack.
*/
void
u3t_mean(u3_noun roc);
/* u3t_mean(): push `[%mean roc]` on trace stack.
*/
void
u3t_mean(u3_noun roc);
/* u3t_drop(): drop from meaning stack.
*/
void
u3t_drop(void);
/* u3t_drop(): drop from meaning stack.
*/
void
u3t_drop(void);
/* u3t_slog(): print directly.
*/
void
u3t_slog(u3_noun hod);
/* u3t_slog(): print directly.
*/
void
u3t_slog(u3_noun hod);
/* u3t_heck(): profile point.
*/
void
u3t_heck(u3_atom cog);
/* u3t_heck(): profile point.
*/
void
u3t_heck(u3_atom cog);
/* u3t_samp(): sample.
*/
void
u3t_samp(void);
/* u3t_samp(): sample.
*/
void
u3t_samp(void);
/* u3t_come(): push on profile stack.
*/
void
u3t_come(u3_atom cog);
/* u3t_come(): push on profile stack.
*/
void
u3t_come(u3_atom cog);
/* u3t_flee(): pop off profile stack.
*/
void
u3t_flee(void);
/* u3t_flee(): pop off profile stack.
*/
void
u3t_flee(void);
/* u3t_damp(): print and clear profile data.
*/
void
u3t_damp(void);
/* u3t_damp(): print and clear profile data.
*/
void
u3t_damp(void);
/* u3t_boff(): turn profile sampling off.
*/
void
u3t_boff(void);
/* u3t_boff(): turn profile sampling off.
*/
void
u3t_boff(void);
/* u3t_boot(): turn sampling on.
*/
void
u3t_boot(void);
/* u3t_boot(): turn sampling on.
*/
void
u3t_boot(void);

32
i/n/u.h
View File

@ -1,7 +1,22 @@
/* include/all.h
/* i/n/u.h
**
** This file is in the public domain.
*/
/** Constants.
**/
/* u3_none - u3_noun which is not a noun.
*/
# define u3_none (u3_noun)0xffffffff
/* u3_nul: 0, hoon ~.
*/
# define u3_nul 0
/* u3_blip: 0, hoon %$.
*/
# define u3_blip 0
/** Typedefs.
**/
/* u3_post: pointer offset into u3_Loom; _p suffix; declare as u3p().
@ -44,21 +59,6 @@
typedef u3_noun (*u3_funq)(u3_noun, u3_noun);
/** Constants.
**/
/* u3_none - u3_noun which is not a noun.
*/
# define u3_none (u3_noun)0xffffffff
/* u3_nul: 0, hoon ~.
*/
# define u3_nul 0
/* u3_blip: 0, hoon %$.
*/
# define u3_blip 0
/** Macros.
**/
/* u3_assure(): loobean assert, bailing with %fail.

View File

@ -51,9 +51,9 @@
**/
/* u3_Home / u3H: root of thread.
*/
c3_global u3v_home* u3_Home;
# define u3H u3_Home
# define u3A (&(u3_Home->arv_u))
c3_global u3v_home* u3v_Home;
# define u3H u3v_Home
# define u3A (&(u3v_Home->arv_u))
/** Functions.
**/

View File

@ -1,4 +1,4 @@
/* include/g/x.h
/* i/n/x.h
**
** This file is in the public domain.
*/

View File

@ -1,4 +1,4 @@
/* include/g/z.h
/* i/n/z.h
**
** This file is in the public domain.
*/
@ -24,8 +24,7 @@
u3_noun u3z_save(c3_m, u3_noun, u3_noun);
u3_noun u3z_save_2(c3_m, u3_noun, u3_noun, u3_noun);
u3_noun u3z_save_3(c3_m, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3z_save_4
(c3_m, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3z_save_4(c3_m, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
/* u3z_uniq(): uniquify with memo cache.
*/

View File

@ -12,6 +12,13 @@
u3_atom a,
u3_atom b)
{
#if 0
if ( b == 3 && a == 2684227708 ) {
printf("dword at 0x27ff84ff8 is %llu\r\n", *(c3_d *)0x27ff84ff8);
*(c3_d *)0x27ff84ff8 = 25;
printf("see, we modified it\r\n");
}
#endif
if ( 0 == b ) {
return u3m_bail(c3__exit);
} else {

368
j/tree.c
View File

@ -4,63 +4,63 @@
*/
#include "all.h"
static u3e_harm _mood__hoon_add_a[] = {{".2", u3wa_add, c3y}, {}};
static u3e_harm _mood__hoon_dec_a[] = {{".2", u3wa_dec, c3y}, {}};
static u3e_harm _mood__hoon_div_a[] = {{".2", u3wa_div, c3y}, {}};
static u3e_harm _mood__hoon_gte_a[] = {{".2", u3wa_gte, c3y}, {}};
static u3e_harm _mood__hoon_gth_a[] = {{".2", u3wa_gth, c3y}, {}};
static u3e_harm _mood__hoon_lte_a[] = {{".2", u3wa_lte, c3y}, {}};
static u3e_harm _mood__hoon_lth_a[] = {{".2", u3wa_lth, c3y}, {}};
static u3e_harm _mood__hoon_mod_a[] = {{".2", u3wa_mod, c3y}, {}};
static u3e_harm _mood__hoon_mul_a[] = {{".2", u3wa_mul, c3y}, {}};
static u3e_harm _mood__hoon_sub_a[] = {{".2", u3wa_sub, c3y}, {}};
static u3j_harm _mood__hoon_add_a[] = {{".2", u3wa_add, c3y}, {}};
static u3j_harm _mood__hoon_dec_a[] = {{".2", u3wa_dec, c3y}, {}};
static u3j_harm _mood__hoon_div_a[] = {{".2", u3wa_div, c3y}, {}};
static u3j_harm _mood__hoon_gte_a[] = {{".2", u3wa_gte, c3y}, {}};
static u3j_harm _mood__hoon_gth_a[] = {{".2", u3wa_gth, c3y}, {}};
static u3j_harm _mood__hoon_lte_a[] = {{".2", u3wa_lte, c3y}, {}};
static u3j_harm _mood__hoon_lth_a[] = {{".2", u3wa_lth, c3y}, {}};
static u3j_harm _mood__hoon_mod_a[] = {{".2", u3wa_mod, c3y}, {}};
static u3j_harm _mood__hoon_mul_a[] = {{".2", u3wa_mul, c3y}, {}};
static u3j_harm _mood__hoon_sub_a[] = {{".2", u3wa_sub, c3y}, {}};
static u3e_harm _mood__hoon_bind_a[] = {{".2", u3wb_bind, c3y}, {}};
static u3e_harm _mood__hoon_clap_a[] = {{".2", u3wb_clap, c3y}, {}};
static u3e_harm _mood__hoon_drop_a[] = {{".2", u3wb_drop, c3y}, {}};
static u3e_harm _mood__hoon_flop_a[] = {{".2", u3wb_flop, c3y}, {}};
static u3e_harm _mood__hoon_lent_a[] = {{".2", u3wb_lent, c3y}, {}};
static u3e_harm _mood__hoon_levy_a[] = {{".2", u3wb_levy, c3y}, {}};
static u3e_harm _mood__hoon_lien_a[] = {{".2", u3wb_lien, c3y}, {}};
static u3e_harm _mood__hoon_need_a[] = {{".2", u3wb_need, c3y}, {}};
static u3e_harm _mood__hoon_reel_a[] = {{".2", u3wb_reel, c3y}, {}};
static u3e_harm _mood__hoon_roll_a[] = {{".2", u3wb_roll, c3y}, {}};
static u3e_harm _mood__hoon_skim_a[] = {{".2", u3wb_skim, c3y}, {}};
static u3e_harm _mood__hoon_skip_a[] = {{".2", u3wb_skip, c3y}, {}};
// static u3e_harm _mood__hoon_scag_a[] = {{".2", u3wb_scag, c3y}, {}};
static u3e_harm _mood__hoon_slag_a[] = {{".2", u3wb_slag, c3y}, {}};
static u3e_harm _mood__hoon_snag_a[] = {{".2", u3wb_snag, c3y}, {}};
// static u3e_harm _mood__hoon_sort_a[] = {{".2", u3wb_sort, c3y}, {}};
static u3e_harm _mood__hoon_turn_a[] = {{".2", u3wb_turn, c3y}, {}};
static u3e_harm _mood__hoon_weld_a[] = {{".2", u3wb_weld, c3y}, {}};
static u3j_harm _mood__hoon_bind_a[] = {{".2", u3wb_bind, c3y}, {}};
static u3j_harm _mood__hoon_clap_a[] = {{".2", u3wb_clap, c3y}, {}};
static u3j_harm _mood__hoon_drop_a[] = {{".2", u3wb_drop, c3y}, {}};
static u3j_harm _mood__hoon_flop_a[] = {{".2", u3wb_flop, c3y}, {}};
static u3j_harm _mood__hoon_lent_a[] = {{".2", u3wb_lent, c3y}, {}};
static u3j_harm _mood__hoon_levy_a[] = {{".2", u3wb_levy, c3y}, {}};
static u3j_harm _mood__hoon_lien_a[] = {{".2", u3wb_lien, c3y}, {}};
static u3j_harm _mood__hoon_need_a[] = {{".2", u3wb_need, c3y}, {}};
static u3j_harm _mood__hoon_reel_a[] = {{".2", u3wb_reel, c3y}, {}};
static u3j_harm _mood__hoon_roll_a[] = {{".2", u3wb_roll, c3y}, {}};
static u3j_harm _mood__hoon_skim_a[] = {{".2", u3wb_skim, c3y}, {}};
static u3j_harm _mood__hoon_skip_a[] = {{".2", u3wb_skip, c3y}, {}};
// static u3j_harm _mood__hoon_scag_a[] = {{".2", u3wb_scag, c3y}, {}};
static u3j_harm _mood__hoon_slag_a[] = {{".2", u3wb_slag, c3y}, {}};
static u3j_harm _mood__hoon_snag_a[] = {{".2", u3wb_snag, c3y}, {}};
// static u3j_harm _mood__hoon_sort_a[] = {{".2", u3wb_sort, c3y}, {}};
static u3j_harm _mood__hoon_turn_a[] = {{".2", u3wb_turn, c3y}, {}};
static u3j_harm _mood__hoon_weld_a[] = {{".2", u3wb_weld, c3y}, {}};
static u3e_harm _mood__hoon_bex_a[] = {{".2", u3wc_bex, c3y}, {}};
static u3e_harm _mood__hoon_can_a[] = {{".2", u3wc_can, c3y}, {}};
static u3e_harm _mood__hoon_cap_a[] = {{".2", u3wc_cap, c3y}, {}};
static u3e_harm _mood__hoon_cat_a[] = {{".2", u3wc_cat, c3y}, {}};
static u3e_harm _mood__hoon_con_a[] = {{".2", u3wc_con, c3y}, {}};
static u3e_harm _mood__hoon_cut_a[] = {{".2", u3wc_cut, c3y}, {}};
static u3e_harm _mood__hoon_dis_a[] = {{".2", u3wc_dis, c3y}, {}};
static u3e_harm _mood__hoon_dor_a[] = {{".2", u3wc_dor, c3y}, {}};
static u3e_harm _mood__hoon_end_a[] = {{".2", u3wc_end, c3y}, {}};
static u3e_harm _mood__hoon_gor_a[] = {{".2", u3wc_gor, c3y}, {}};
static u3e_harm _mood__hoon_hor_a[] = {{".2", u3wc_hor, c3y}, {}};
static u3e_harm _mood__hoon_lsh_a[] = {{".2", u3wc_lsh, c3y}, {}};
static u3e_harm _mood__hoon_mas_a[] = {{".2", u3wc_mas, c3y}, {}};
static u3e_harm _mood__hoon_met_a[] = {{".2", u3wc_met, c3y}, {}};
static u3e_harm _mood__hoon_mix_a[] = {{".2", u3wc_mix, c3y}, {}};
static u3e_harm _mood__hoon_mug_a[] = {{".2", u3wc_mug, c3y}, {}};
static u3e_harm _mood__hoon_peg_a[] = {{".2", u3wc_peg, c3y}, {}};
static u3e_harm _mood__hoon_rap_a[] = {{".2", u3wc_rap, c3y}, {}};
static u3e_harm _mood__hoon_rip_a[] = {{".2", u3wc_rip, c3y}, {}};
static u3e_harm _mood__hoon_rsh_a[] = {{".2", u3wc_rsh, c3y}, {}};
static u3e_harm _mood__hoon_vor_a[] = {{".2", u3wc_vor, c3y}, {}};
static u3j_harm _mood__hoon_bex_a[] = {{".2", u3wc_bex, c3y}, {}};
static u3j_harm _mood__hoon_can_a[] = {{".2", u3wc_can, c3y}, {}};
static u3j_harm _mood__hoon_cap_a[] = {{".2", u3wc_cap, c3y}, {}};
static u3j_harm _mood__hoon_cat_a[] = {{".2", u3wc_cat, c3y}, {}};
static u3j_harm _mood__hoon_con_a[] = {{".2", u3wc_con, c3y}, {}};
static u3j_harm _mood__hoon_cut_a[] = {{".2", u3wc_cut, c3y}, {}};
static u3j_harm _mood__hoon_dis_a[] = {{".2", u3wc_dis, c3y}, {}};
static u3j_harm _mood__hoon_dor_a[] = {{".2", u3wc_dor, c3y}, {}};
static u3j_harm _mood__hoon_end_a[] = {{".2", u3wc_end, c3y}, {}};
static u3j_harm _mood__hoon_gor_a[] = {{".2", u3wc_gor, c3y}, {}};
static u3j_harm _mood__hoon_hor_a[] = {{".2", u3wc_hor, c3y}, {}};
static u3j_harm _mood__hoon_lsh_a[] = {{".2", u3wc_lsh, c3y}, {}};
static u3j_harm _mood__hoon_mas_a[] = {{".2", u3wc_mas, c3y}, {}};
static u3j_harm _mood__hoon_met_a[] = {{".2", u3wc_met, c3y}, {}};
static u3j_harm _mood__hoon_mix_a[] = {{".2", u3wc_mix, c3y}, {}};
static u3j_harm _mood__hoon_mug_a[] = {{".2", u3wc_mug, c3y}, {}};
static u3j_harm _mood__hoon_peg_a[] = {{".2", u3wc_peg, c3y}, {}};
static u3j_harm _mood__hoon_rap_a[] = {{".2", u3wc_rap, c3y}, {}};
static u3j_harm _mood__hoon_rip_a[] = {{".2", u3wc_rip, c3y}, {}};
static u3j_harm _mood__hoon_rsh_a[] = {{".2", u3wc_rsh, c3y}, {}};
static u3j_harm _mood__hoon_vor_a[] = {{".2", u3wc_vor, c3y}, {}};
static u3e_harm _mood__hoon__po_ind_a[] = {{".2", u3wcp_ind}, {}};
static u3e_harm _mood__hoon__po_ins_a[] = {{".2", u3wcp_ins}, {}};
static u3e_harm _mood__hoon__po_tod_a[] = {{".2", u3wcp_tod}, {}};
static u3e_harm _mood__hoon__po_tos_a[] = {{".2", u3wcp_tos}, {}};
static u3e_core _mood__hoon__po_d[] =
static u3j_harm _mood__hoon__po_ind_a[] = {{".2", u3wcp_ind}, {}};
static u3j_harm _mood__hoon__po_ins_a[] = {{".2", u3wcp_ins}, {}};
static u3j_harm _mood__hoon__po_tod_a[] = {{".2", u3wcp_tod}, {}};
static u3j_harm _mood__hoon__po_tos_a[] = {{".2", u3wcp_tos}, {}};
static u3j_core _mood__hoon__po_d[] =
{ { "ind", _mood__hoon__po_ind_a },
{ "ins", _mood__hoon__po_ins_a },
{ "tod", _mood__hoon__po_tod_a },
@ -68,14 +68,14 @@ static u3e_core _mood__hoon__po_d[] =
{}
};
static u3e_harm _mood__hoon__by_gas_a[] = {{".2", u3wdb_gas, c3y}, {}};
static u3e_harm _mood__hoon__by_get_a[] = {{".2", u3wdb_get, c3y}, {}};
static u3e_harm _mood__hoon__by_has_a[] = {{".2", u3wdb_has, c3y}, {}};
static u3e_harm _mood__hoon__by_int_a[] = {{".2", u3wdb_int, c3y}, {}};
static u3e_harm _mood__hoon__by_put_a[] = {{".2", u3wdb_put, c3y}, {}};
static u3e_harm _mood__hoon__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}};
static u3e_harm _mood__hoon__by_uni_a[] = {{".2", u3wdb_uni, c3y}, {}};
static u3e_core _mood__hoon__by_d[] =
static u3j_harm _mood__hoon__by_gas_a[] = {{".2", u3wdb_gas, c3y}, {}};
static u3j_harm _mood__hoon__by_get_a[] = {{".2", u3wdb_get, c3y}, {}};
static u3j_harm _mood__hoon__by_has_a[] = {{".2", u3wdb_has, c3y}, {}};
static u3j_harm _mood__hoon__by_int_a[] = {{".2", u3wdb_int, c3y}, {}};
static u3j_harm _mood__hoon__by_put_a[] = {{".2", u3wdb_put, c3y}, {}};
static u3j_harm _mood__hoon__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}};
static u3j_harm _mood__hoon__by_uni_a[] = {{".2", u3wdb_uni, c3y}, {}};
static u3j_core _mood__hoon__by_d[] =
{ { "gas", _mood__hoon__by_gas_a },
{ "get", _mood__hoon__by_get_a },
{ "has", _mood__hoon__by_has_a },
@ -86,14 +86,14 @@ static u3e_core _mood__hoon__by_d[] =
{}
};
static u3e_harm _mood__hoon__in_gas_a[] = {{".2", u3wdi_gas}, {}};
static u3e_harm _mood__hoon__in_has_a[] = {{".2", u3wdi_has}, {}};
static u3e_harm _mood__hoon__in_mer_a[] = {{".2", u3wdi_mer}, {}};
static u3e_harm _mood__hoon__in_int_a[] = {{".2", u3wdi_int}, {}};
static u3e_harm _mood__hoon__in_put_a[] = {{".2", u3wdi_put}, {}};
static u3e_harm _mood__hoon__in_tap_a[] = {{".2", u3wdi_tap}, {}};
static u3e_harm _mood__hoon__in_uni_a[] = {{".2", u3wdi_uni}, {}};
static u3e_core _mood__hoon__in_d[] =
static u3j_harm _mood__hoon__in_gas_a[] = {{".2", u3wdi_gas}, {}};
static u3j_harm _mood__hoon__in_has_a[] = {{".2", u3wdi_has}, {}};
static u3j_harm _mood__hoon__in_mer_a[] = {{".2", u3wdi_mer}, {}};
static u3j_harm _mood__hoon__in_int_a[] = {{".2", u3wdi_int}, {}};
static u3j_harm _mood__hoon__in_put_a[] = {{".2", u3wdi_put}, {}};
static u3j_harm _mood__hoon__in_tap_a[] = {{".2", u3wdi_tap}, {}};
static u3j_harm _mood__hoon__in_uni_a[] = {{".2", u3wdi_uni}, {}};
static u3j_core _mood__hoon__in_d[] =
{ { "gas", _mood__hoon__in_gas_a },
{ "has", _mood__hoon__in_has_a },
{ "mer", _mood__hoon__in_mer_a },
@ -104,108 +104,108 @@ static u3e_core _mood__hoon__in_d[] =
{}
};
static u3e_harm _mood__hoon_cue_a[] = {{".2", u3we_cue}, {}};
static u3e_harm _mood__hoon_jam_a[] = {{".2", u3we_jam}, {}};
static u3e_harm _mood__hoon_mat_a[] = {{".2", u3we_mat}, {}};
static u3e_harm _mood__hoon_rub_a[] = {{".2", u3we_rub}, {}};
static u3e_harm _mood__hoon_lore_a[] = {{".2", u3we_lore}, {}};
static u3e_harm _mood__hoon_loss_a[] = {{".2", u3we_loss}, {}};
static u3e_harm _mood__hoon_mink_a[] = {{".2", u3we_mink}, {}};
static u3e_harm _mood__hoon_mule_a[] = {{".2", u3we_mule}, {}};
static u3e_harm _mood__hoon_repg_a[] = {{".2", u3we_repg}, {}};
static u3e_harm _mood__hoon_rexp_a[] = {{".2", u3we_rexp}, {}};
static u3e_harm _mood__hoon_trip_a[] = {{".2", u3we_trip}, {}};
static u3j_harm _mood__hoon_cue_a[] = {{".2", u3we_cue}, {}};
static u3j_harm _mood__hoon_jam_a[] = {{".2", u3we_jam}, {}};
static u3j_harm _mood__hoon_mat_a[] = {{".2", u3we_mat}, {}};
static u3j_harm _mood__hoon_rub_a[] = {{".2", u3we_rub}, {}};
static u3j_harm _mood__hoon_lore_a[] = {{".2", u3we_lore}, {}};
static u3j_harm _mood__hoon_loss_a[] = {{".2", u3we_loss}, {}};
static u3j_harm _mood__hoon_mink_a[] = {{".2", u3we_mink}, {}};
static u3j_harm _mood__hoon_mule_a[] = {{".2", u3we_mule}, {}};
static u3j_harm _mood__hoon_repg_a[] = {{".2", u3we_repg}, {}};
static u3j_harm _mood__hoon_rexp_a[] = {{".2", u3we_rexp}, {}};
static u3j_harm _mood__hoon_trip_a[] = {{".2", u3we_trip}, {}};
static u3e_harm _mood__hoon__aesc_en_a[] = {{".2", u3wea_en}, {}};
static u3e_harm _mood__hoon__aesc_de_a[] = {{".2", u3wea_en}, {}};
static u3e_core _mood__hoon__aesc_d[] =
static u3j_harm _mood__hoon__aesc_en_a[] = {{".2", u3wea_en}, {}};
static u3j_harm _mood__hoon__aesc_de_a[] = {{".2", u3wea_en}, {}};
static u3j_core _mood__hoon__aesc_d[] =
{ { "en", _mood__hoon__aesc_en_a },
{ "de", _mood__hoon__aesc_de_a },
{}
};
static u3e_harm _mood__hoon__bend_fun_a[] = {{".2", u3we_bend_fun}, {}};
static u3e_core _mood__hoon__bend_d[] =
static u3j_harm _mood__hoon__bend_fun_a[] = {{".2", u3we_bend_fun}, {}};
static u3j_core _mood__hoon__bend_d[] =
{ { "fun", _mood__hoon__bend_fun_a },
{}
};
static u3e_harm _mood__hoon__cold_fun_a[] = {{".2", u3we_cold_fun}, {}};
static u3e_core _mood__hoon__cold_d[] =
static u3j_harm _mood__hoon__cold_fun_a[] = {{".2", u3we_cold_fun}, {}};
static u3j_core _mood__hoon__cold_d[] =
{ { "fun", _mood__hoon__cold_fun_a },
{}
};
static u3e_harm _mood__hoon__cook_fun_a[] = {{".2", u3we_cook_fun}, {}};
static u3e_core _mood__hoon__cook_d[] =
static u3j_harm _mood__hoon__cook_fun_a[] = {{".2", u3we_cook_fun}, {}};
static u3j_core _mood__hoon__cook_d[] =
{ { "fun", _mood__hoon__cook_fun_a },
{}
};
static u3e_harm _mood__hoon__comp_fun_a[] = {{".2", u3we_comp_fun}, {}};
static u3e_core _mood__hoon__comp_d[] =
static u3j_harm _mood__hoon__comp_fun_a[] = {{".2", u3we_comp_fun}, {}};
static u3j_core _mood__hoon__comp_d[] =
{ { "fun", _mood__hoon__comp_fun_a },
{}
};
static u3e_harm _mood__hoon__easy_fun_a[] = {{".2", u3we_easy_fun}, {}};
static u3e_core _mood__hoon__easy_d[] =
static u3j_harm _mood__hoon__easy_fun_a[] = {{".2", u3we_easy_fun}, {}};
static u3j_core _mood__hoon__easy_d[] =
{ { "fun", _mood__hoon__easy_fun_a },
{}
};
static u3e_harm _mood__hoon__glue_fun_a[] = {{".2", u3we_glue_fun}, {}};
static u3e_core _mood__hoon__glue_d[] =
static u3j_harm _mood__hoon__glue_fun_a[] = {{".2", u3we_glue_fun}, {}};
static u3j_core _mood__hoon__glue_d[] =
{ { "fun", _mood__hoon__glue_fun_a },
{}
};
static u3e_harm _mood__hoon__here_fun_a[] = {{".2", u3we_here_fun}, {}};
static u3e_core _mood__hoon__here_d[] =
static u3j_harm _mood__hoon__here_fun_a[] = {{".2", u3we_here_fun}, {}};
static u3j_core _mood__hoon__here_d[] =
{ { "fun", _mood__hoon__here_fun_a },
{}
};
static u3e_harm _mood__hoon__just_fun_a[] = {{".2", u3we_just_fun}, {}};
static u3e_core _mood__hoon__just_d[] =
static u3j_harm _mood__hoon__just_fun_a[] = {{".2", u3we_just_fun}, {}};
static u3j_core _mood__hoon__just_d[] =
{ { "fun", _mood__hoon__just_fun_a },
{}
};
static u3e_harm _mood__hoon__mask_fun_a[] = {{".2", u3we_mask_fun}, {}};
static u3e_core _mood__hoon__mask_d[] =
static u3j_harm _mood__hoon__mask_fun_a[] = {{".2", u3we_mask_fun}, {}};
static u3j_core _mood__hoon__mask_d[] =
{ { "fun", _mood__hoon__mask_fun_a },
{}
};
static u3e_harm _mood__hoon__shim_fun_a[] = {{".2", u3we_shim_fun}, {}};
static u3e_core _mood__hoon__shim_d[] =
static u3j_harm _mood__hoon__shim_fun_a[] = {{".2", u3we_shim_fun}, {}};
static u3j_core _mood__hoon__shim_d[] =
{ { "fun", _mood__hoon__shim_fun_a },
{}
};
static u3e_harm _mood__hoon__stag_fun_a[] = {{".2", u3we_stag_fun}, {}};
static u3e_core _mood__hoon__stag_d[] =
static u3j_harm _mood__hoon__stag_fun_a[] = {{".2", u3we_stag_fun}, {}};
static u3j_core _mood__hoon__stag_d[] =
{ { "fun", _mood__hoon__stag_fun_a },
{}
};
static u3e_harm _mood__hoon__stew_fun_a[] = {{".2", u3we_stew_fun}, {}};
static u3e_core _mood__hoon__stew_d[] =
static u3j_harm _mood__hoon__stew_fun_a[] = {{".2", u3we_stew_fun}, {}};
static u3j_core _mood__hoon__stew_d[] =
{ { "fun", _mood__hoon__stew_fun_a },
{}
};
static u3e_harm _mood__hoon__stir_fun_a[] = {{".2", u3we_stir_fun}, {}};
static u3e_core _mood__hoon__stir_d[] =
static u3j_harm _mood__hoon__stir_fun_a[] = {{".2", u3we_stir_fun}, {}};
static u3j_core _mood__hoon__stir_d[] =
{ { "fun", _mood__hoon__stir_fun_a },
{}
};
static u3e_harm _mood__hoon__og_raw_a[] = {{".2", u3weo_raw}, {}};
static u3e_core _mood__hoon__og_d[] =
static u3j_harm _mood__hoon__og_raw_a[] = {{".2", u3weo_raw}, {}};
static u3j_core _mood__hoon__og_d[] =
{ { "raw", _mood__hoon__og_raw_a },
{}
};
static u3e_harm _mood__hoon__rd_sun_a[] = {{".2", u3wer_sun}, {}};
static u3e_harm _mood__hoon__rd_mul_a[] = {{".2", u3wer_mul}, {}};
static u3e_harm _mood__hoon__rd_div_a[] = {{".2", u3wer_div}, {}};
static u3e_harm _mood__hoon__rd_add_a[] = {{".2", u3wer_add}, {}};
static u3e_harm _mood__hoon__rd_sub_a[] = {{".2", u3wer_sub}, {}};
static u3e_harm _mood__hoon__rd_lte_a[] = {{".2", u3wer_lte}, {}};
static u3e_harm _mood__hoon__rd_lth_a[] = {{".2", u3wer_lth}, {}};
static u3e_harm _mood__hoon__rd_gte_a[] = {{".2", u3wer_gte}, {}};
static u3e_harm _mood__hoon__rd_gth_a[] = {{".2", u3wer_gth}, {}};
static u3e_core _mood__hoon__rd_d[] =
static u3j_harm _mood__hoon__rd_sun_a[] = {{".2", u3wer_sun}, {}};
static u3j_harm _mood__hoon__rd_mul_a[] = {{".2", u3wer_mul}, {}};
static u3j_harm _mood__hoon__rd_div_a[] = {{".2", u3wer_div}, {}};
static u3j_harm _mood__hoon__rd_add_a[] = {{".2", u3wer_add}, {}};
static u3j_harm _mood__hoon__rd_sub_a[] = {{".2", u3wer_sub}, {}};
static u3j_harm _mood__hoon__rd_lte_a[] = {{".2", u3wer_lte}, {}};
static u3j_harm _mood__hoon__rd_lth_a[] = {{".2", u3wer_lth}, {}};
static u3j_harm _mood__hoon__rd_gte_a[] = {{".2", u3wer_gte}, {}};
static u3j_harm _mood__hoon__rd_gth_a[] = {{".2", u3wer_gth}, {}};
static u3j_core _mood__hoon__rd_d[] =
{ { "sun", _mood__hoon__rd_sun_a },
{ "mul", _mood__hoon__rd_mul_a },
{ "div", _mood__hoon__rd_div_a },
@ -218,71 +218,71 @@ static u3e_core _mood__hoon__rd_d[] =
{}
};
static u3e_harm _mood__hoon__coed__ed_puck_a[] = {{".2", u3wee_puck}, {}};
static u3e_harm _mood__hoon__coed__ed_sign_a[] = {{".2", u3wee_sign}, {}};
static u3e_harm _mood__hoon__coed__ed_veri_a[] = {{".2", u3wee_veri}, {}};
static u3e_core _mood__hoon__coed__ed_d[] =
static u3j_harm _mood__hoon__coed__ed_puck_a[] = {{".2", u3wee_puck}, {}};
static u3j_harm _mood__hoon__coed__ed_sign_a[] = {{".2", u3wee_sign}, {}};
static u3j_harm _mood__hoon__coed__ed_veri_a[] = {{".2", u3wee_veri}, {}};
static u3j_core _mood__hoon__coed__ed_d[] =
{ { "sign", _mood__hoon__coed__ed_sign_a },
{ "puck", _mood__hoon__coed__ed_puck_a },
{ "veri", _mood__hoon__coed__ed_veri_a },
{}
};
static u3e_core _mood__hoon__coed_d[] =
static u3j_core _mood__hoon__coed_d[] =
{ { "ed", 0, _mood__hoon__coed__ed_d },
{}
};
static u3e_harm _mood__hoon_pfix_a[] = {{".2", u3we_pfix}, {}};
static u3e_harm _mood__hoon_plug_a[] = {{".2", u3we_plug}, {}};
static u3e_harm _mood__hoon_pose_a[] = {{".2", u3we_pose}, {}};
static u3e_harm _mood__hoon_sfix_a[] = {{".2", u3we_sfix}, {}};
static u3e_harm _mood__hoon_shax_a[] = {{".2", u3we_shax}, {}};
static u3e_harm _mood__hoon_shas_a[] = {{".2", u3we_shas}, {}};
static u3e_harm _mood__hoon_shal_a[] = {{".2", u3we_shal}, {}};
static u3j_harm _mood__hoon_pfix_a[] = {{".2", u3we_pfix}, {}};
static u3j_harm _mood__hoon_plug_a[] = {{".2", u3we_plug}, {}};
static u3j_harm _mood__hoon_pose_a[] = {{".2", u3we_pose}, {}};
static u3j_harm _mood__hoon_sfix_a[] = {{".2", u3we_sfix}, {}};
static u3j_harm _mood__hoon_shax_a[] = {{".2", u3we_shax}, {}};
static u3j_harm _mood__hoon_shas_a[] = {{".2", u3we_shas}, {}};
static u3j_harm _mood__hoon_shal_a[] = {{".2", u3we_shal}, {}};
static u3e_harm _mood__hoon_bull_a[] = {{".2", u3wf_bull}, {}};
static u3e_harm _mood__hoon_cell_a[] = {{".2", u3wf_cell}, {}};
static u3e_harm _mood__hoon_comb_a[] = {{".2", u3wf_comb}, {}};
static u3e_harm _mood__hoon_cons_a[] = {{".2", u3wf_cons}, {}};
static u3e_harm _mood__hoon_core_a[] = {{".2", u3wf_core}, {}};
static u3e_harm _mood__hoon_cube_a[] = {{".2", u3wf_cube}, {}};
static u3e_harm _mood__hoon_face_a[] = {{".2", u3wf_face}, {}};
static u3e_harm _mood__hoon_fitz_a[] = {{".2", u3wf_fitz}, {}};
static u3e_harm _mood__hoon_flan_a[] = {{".2", u3wf_flan}, {}};
static u3e_harm _mood__hoon_flay_a[] = {{".2", u3wf_flay}, {}};
static u3e_harm _mood__hoon_flip_a[] = {{".2", u3wf_flip}, {}};
static u3e_harm _mood__hoon_flor_a[] = {{".2", u3wf_flor}, {}};
static u3e_harm _mood__hoon_fork_a[] = {{".2", u3wf_fork}, {}};
static u3e_harm _mood__hoon_hike_a[] = {{".2", u3wf_hike}, {}};
static u3e_harm _mood__hoon_look_a[] = {{".2", u3wf_look}, {}};
static u3j_harm _mood__hoon_bull_a[] = {{".2", u3wf_bull}, {}};
static u3j_harm _mood__hoon_cell_a[] = {{".2", u3wf_cell}, {}};
static u3j_harm _mood__hoon_comb_a[] = {{".2", u3wf_comb}, {}};
static u3j_harm _mood__hoon_cons_a[] = {{".2", u3wf_cons}, {}};
static u3j_harm _mood__hoon_core_a[] = {{".2", u3wf_core}, {}};
static u3j_harm _mood__hoon_cube_a[] = {{".2", u3wf_cube}, {}};
static u3j_harm _mood__hoon_face_a[] = {{".2", u3wf_face}, {}};
static u3j_harm _mood__hoon_fitz_a[] = {{".2", u3wf_fitz}, {}};
static u3j_harm _mood__hoon_flan_a[] = {{".2", u3wf_flan}, {}};
static u3j_harm _mood__hoon_flay_a[] = {{".2", u3wf_flay}, {}};
static u3j_harm _mood__hoon_flip_a[] = {{".2", u3wf_flip}, {}};
static u3j_harm _mood__hoon_flor_a[] = {{".2", u3wf_flor}, {}};
static u3j_harm _mood__hoon_fork_a[] = {{".2", u3wf_fork}, {}};
static u3j_harm _mood__hoon_hike_a[] = {{".2", u3wf_hike}, {}};
static u3j_harm _mood__hoon_look_a[] = {{".2", u3wf_look}, {}};
static u3e_harm _mood__hoon__ut_busk_a[] = {{".2", u3wfu_busk}, {}};
static u3e_harm _mood__hoon__ut_bust_a[] = {{".2", u3wfu_bust}, {}};
static u3e_harm _mood__hoon__ut_conk_a[] = {{".2", u3wfu_conk}, {}};
static u3e_harm _mood__hoon__ut_crop_a[] = {{".2", u3wfu_crop}, {}};
static u3e_harm _mood__hoon__ut_cull_a[] = {{".2", u3wfu_cull}, {}};
static u3e_harm _mood__hoon__ut_find_a[] = {{".2", u3wfu_find}, {}};
static u3e_harm _mood__hoon__ut_fino_a[] = {{".2", u3wfu_fino}, {}};
static u3e_harm _mood__hoon__ut_fink_a[] = {{".2", u3wfu_fink}, {}};
static u3e_harm _mood__hoon__ut_fire_a[] = {{".2", u3wfu_fire}, {}};
static u3e_harm _mood__hoon__ut_firm_a[] = {{".2", u3wfu_firm}, {}};
static u3e_harm _mood__hoon__ut_fish_a[] = {{".2", u3wfu_fish}, {}};
static u3e_harm _mood__hoon__ut_fuse_a[] = {{".2", u3wfu_fuse}, {}};
static u3e_harm _mood__hoon__ut_heal_a[] = {{".2", u3wfu_heal}, {}};
static u3e_harm _mood__hoon__ut_mint_a[] = {{".2", u3wfu_mint}, {}};
static u3e_harm _mood__hoon__ut_mull_a[] = {{".2", u3wfu_mull}, {}};
static u3e_harm _mood__hoon__ut_nest_a[] = {{".2", u3wfu_nest}, {}};
static u3e_harm _mood__hoon__ut_park_a[] = {{".2", u3wfu_park}, {}};
static u3e_harm _mood__hoon__ut_peek_a[] = {{".2", u3wfu_peek}, {}};
static u3e_harm _mood__hoon__ut_play_a[] = {{".2", u3wfu_play}, {}};
static u3e_harm _mood__hoon__ut_rest_a[] = {{".2", u3wfu_rest}, {}};
static u3e_harm _mood__hoon__ut_seek_a[] = {{".2", u3wfu_seek}, {}};
static u3e_harm _mood__hoon__ut_seep_a[] = {{".2", u3wfu_seep}, {}};
static u3e_harm _mood__hoon__ut_snub_a[] = {{".2", u3wfu_snub}, {}};
static u3e_harm _mood__hoon__ut_tock_a[] = {{".2", u3wfu_tock}, {}};
static u3e_harm _mood__hoon__ut_wrap_a[] = {{".2", u3wfu_wrap}, {}};
static u3j_harm _mood__hoon__ut_busk_a[] = {{".2", u3wfu_busk}, {}};
static u3j_harm _mood__hoon__ut_bust_a[] = {{".2", u3wfu_bust}, {}};
static u3j_harm _mood__hoon__ut_conk_a[] = {{".2", u3wfu_conk}, {}};
static u3j_harm _mood__hoon__ut_crop_a[] = {{".2", u3wfu_crop}, {}};
static u3j_harm _mood__hoon__ut_cull_a[] = {{".2", u3wfu_cull}, {}};
static u3j_harm _mood__hoon__ut_find_a[] = {{".2", u3wfu_find}, {}};
static u3j_harm _mood__hoon__ut_fino_a[] = {{".2", u3wfu_fino}, {}};
static u3j_harm _mood__hoon__ut_fink_a[] = {{".2", u3wfu_fink}, {}};
static u3j_harm _mood__hoon__ut_fire_a[] = {{".2", u3wfu_fire}, {}};
static u3j_harm _mood__hoon__ut_firm_a[] = {{".2", u3wfu_firm}, {}};
static u3j_harm _mood__hoon__ut_fish_a[] = {{".2", u3wfu_fish}, {}};
static u3j_harm _mood__hoon__ut_fuse_a[] = {{".2", u3wfu_fuse}, {}};
static u3j_harm _mood__hoon__ut_heal_a[] = {{".2", u3wfu_heal}, {}};
static u3j_harm _mood__hoon__ut_mint_a[] = {{".2", u3wfu_mint}, {}};
static u3j_harm _mood__hoon__ut_mull_a[] = {{".2", u3wfu_mull}, {}};
static u3j_harm _mood__hoon__ut_nest_a[] = {{".2", u3wfu_nest}, {}};
static u3j_harm _mood__hoon__ut_park_a[] = {{".2", u3wfu_park}, {}};
static u3j_harm _mood__hoon__ut_peek_a[] = {{".2", u3wfu_peek}, {}};
static u3j_harm _mood__hoon__ut_play_a[] = {{".2", u3wfu_play}, {}};
static u3j_harm _mood__hoon__ut_rest_a[] = {{".2", u3wfu_rest}, {}};
static u3j_harm _mood__hoon__ut_seek_a[] = {{".2", u3wfu_seek}, {}};
static u3j_harm _mood__hoon__ut_seep_a[] = {{".2", u3wfu_seep}, {}};
static u3j_harm _mood__hoon__ut_snub_a[] = {{".2", u3wfu_snub}, {}};
static u3j_harm _mood__hoon__ut_tock_a[] = {{".2", u3wfu_tock}, {}};
static u3j_harm _mood__hoon__ut_wrap_a[] = {{".2", u3wfu_wrap}, {}};
static u3e_core _mood__hoon__ut_d[] =
static u3j_core _mood__hoon__ut_d[] =
{
{ "busk", _mood__hoon__ut_busk_a },
{ "bust", _mood__hoon__ut_bust_a },
@ -311,13 +311,13 @@ static u3e_core _mood__hoon__ut_d[] =
{ "wrap", _mood__hoon__ut_wrap_a },
{}
};
static u3e_harm _mood__hoon__ut_a[] =
static u3j_harm _mood__hoon__ut_a[] =
{ {"burn", u3wfu_burn},
{"repo", u3wfu_repo},
{}
};
static u3e_harm _mood__hoon__ap_a[] =
static u3j_harm _mood__hoon__ap_a[] =
{ // {"hack", u3wfp_open},
// {"late", u3wfp_open},
{"open", u3wfp_open},
@ -326,14 +326,14 @@ static u3e_harm _mood__hoon__ap_a[] =
};
#if 0
static u3e_harm _mood__hoon__al_a[] =
static u3j_harm _mood__hoon__al_a[] =
{ {"bunt", u3wfl_bunt},
{"whip", u3wfl_whip},
{}
};
#endif
static u3e_core _mood__hoon_d[] =
static u3j_core _mood__hoon_d[] =
{ { "add", _mood__hoon_add_a },
{ "dec", _mood__hoon_dec_a },
{ "div", _mood__hoon_div_a },
@ -455,23 +455,23 @@ static u3e_core _mood__hoon_d[] =
{}
};
static u3e_core _mood_d[] =
static u3j_core _mood_d[] =
{ { "hoon", 0, _mood__hoon_d },
{}
};
static u3e_core _k164_d[] =
static u3j_core _k164_d[] =
{ { "mood", 0, _mood_d },
{}
};
static u3e_core _d[] = {
static u3j_core _d[] = {
{ "k164", 0, _k164_d},
{}
};
u3e_dash
u3_Dash = {
u3j_dash
u3j_Dash = {
_d,
0,
0

70
n/a.c
View File

@ -17,7 +17,7 @@ _box_slot(c3_w siz_w)
c3_w i_w = 1;
while ( 1 ) {
if ( i_w == u3_cc_fbox_no ) {
if ( i_w == u3a_fbox_no ) {
return (i_w - 1);
}
if ( siz_w < 16 ) {
@ -37,7 +37,7 @@ _box_make(void* box_v, c3_w siz_w, c3_w use_w)
u3a_box* box_u = box_v;
c3_w* box_w = box_v;
c3_assert(siz_w >= u3_cc_minimum);
c3_assert(siz_w >= u3a_minimum);
box_w[0] = siz_w;
box_w[siz_w - 1] = siz_w;
@ -170,7 +170,7 @@ u3a_sane(void)
{
c3_w i_w;
for ( i_w = 0; i_w < u3_cc_fbox_no; i_w++ ) {
for ( i_w = 0; i_w < u3a_fbox_no; i_w++ ) {
u3a_fbox* fre_u = u3R->all.fre_u[i_w];
while ( fre_u ) {
@ -195,12 +195,12 @@ u3a_sane(void)
static void*
_ca_walloc(c3_w len_w)
{
c3_w siz_w = c3_max(u3_cc_minimum, u3a_boxed(len_w));
c3_w siz_w = c3_max(u3a_minimum, u3a_boxed(len_w));
c3_w sel_w = _box_slot(siz_w);
// XX: this logic is totally bizarre, but preserve it.
//
if ( (sel_w != 0) && (sel_w != u3_cc_fbox_no - 1) ) {
if ( (sel_w != 0) && (sel_w != u3a_fbox_no - 1) ) {
sel_w += 1;
}
@ -210,7 +210,7 @@ _ca_walloc(c3_w len_w)
while ( 1 ) {
if ( 0 == *pfr_p ) {
if ( sel_w < (u3_cc_fbox_no - 1) ) {
if ( sel_w < (u3a_fbox_no - 1) ) {
sel_w += 1;
break;
}
@ -253,7 +253,7 @@ _ca_walloc(c3_w len_w)
/* If we can chop off another block, do it.
*/
if ( (siz_w + u3_cc_minimum) <= box_u->siz_w ) {
if ( (siz_w + u3a_minimum) <= box_u->siz_w ) {
/* Split the block.
*/
c3_w* box_w = ((c3_w *)(void *)box_u);
@ -306,14 +306,6 @@ u3a_walloc(c3_w len_w)
return ptr_v;
}
/* u3a_malloc(): allocate storage measured in bytes.
*/
void*
u3a_malloc(c3_w len_w)
{
return u3a_walloc((len_w + 3) >> 2);
}
/* u3a_wealloc(): realloc in words.
*/
void*
@ -339,14 +331,6 @@ u3a_wealloc(void* lag_v, c3_w len_w)
}
}
/* u3a_realloc(): realloc in bytes.
*/
void*
u3a_realloc(void* lag_v, c3_w len_w)
{
return u3a_wealloc(lag_v, (len_w + 3) >> 2);
}
/* u3a_free(): free storage.
*/
void
@ -433,6 +417,42 @@ u3a_free(void* tox_v)
}
}
/* u3a_malloc(): allocate storage measured in bytes.
*/
void*
u3a_malloc(size_t len_i)
{
c3_w len_w = (c3_w)len_i;
return u3a_walloc((len_w + 3) >> 2);
}
/* u3a_realloc(): realloc in bytes.
*/
void*
u3a_realloc(void* lag_v, size_t len_i)
{
c3_w len_w = (c3_w)len_i;
return u3a_wealloc(lag_v, (len_w + 3) >> 2);
}
/* u3a_realloc2(): gmp-shaped realloc.
*/
void*
u3a_realloc2(void* lag_v, size_t old_i, size_t new_i)
{
return u3a_realloc(lag_v, new_i);
}
/* u3a_free2(): gmp-shaped free.
*/
void
u3a_free2(void* tox_v, size_t siz_i)
{
u3a_free(tox_v);
}
#if 1
/* _me_wash_north(): clean up mug slots after copy.
*/
@ -1159,7 +1179,7 @@ u3a_sweep(c3_c* cap_c)
? (u3R->hat_p - u3R->rut_p)
: (u3R->rut_p - u3R->hat_p);
for ( i_w = 0; i_w < u3_cc_fbox_no; i_w++ ) {
for ( i_w = 0; i_w < u3a_fbox_no; i_w++ ) {
u3p(u3a_fbox) fre_p = u3R->all.fre_p[i_w];
while ( fre_p ) {
@ -1405,7 +1425,7 @@ u3a_mint(c3_w* sal_w, c3_w len_w)
c3_w old_w = nov_u->len_w;
c3_w dif_w = (old_w - len_w);
if ( dif_w >= u3_cc_minimum ) {
if ( dif_w >= u3a_minimum ) {
c3_w* box_w = (void *)u3a_botox(nov_w);
c3_w* end_w = (nov_w + c3_wiseof(u3a_atom) + len_w + 1);
c3_w asz_w = (end_w - box_w);

98
n/e.c
View File

@ -71,6 +71,45 @@ u3e_check(c3_c* cap_c)
printf("%s: sum %x (%x, %x)\r\n", cap_c, sum_w, nor_w, sou_w);
}
}
/* _ce_maplloc(): crude off-loom allocator.
*/
static void*
_ce_maplloc(c3_w len_w)
{
void* map_v;
map_v = mmap(0,
len_w,
(PROT_READ | PROT_WRITE),
(MAP_ANON | MAP_PRIVATE),
-1, 0);
if ( -1 == (c3_ps)map_v ) {
c3_assert(0);
}
else {
c3_w* map_w = map_v;
map_w[0] = len_w;
return map_w + 1;
}
}
/* _ce_mapfree(): crude off-loom allocator.
*/
static void
_ce_mapfree(void* map_v)
{
c3_w* map_w = map_v;
c3_i res_i;
map_w -= 1;
res_i = munmap(map_w, map_w[0]);
c3_assert(0 == res_i);
}
#endif
/* u3e_fault(): handle a memory event with libsigsegv protocol.
@ -91,7 +130,21 @@ u3e_fault(void* adr_v, c3_i ser_i)
c3_w blk_w = (pag_w >> 5);
c3_w bit_w = (pag_w & 31);
// printf("dirty page %d\r\n", pag_w);
#if 0
if ( pag_w == 131041 ) {
printf("dirty page %d (at %p); unprotecting %p to %p\r\n",
pag_w,
adr_v,
(u3_Loom + (pag_w << u3a_page)),
(u3_Loom + (pag_w << u3a_page) + (1 << u3a_page)));
}
#endif
if ( 0 != (u3P.dit_w[blk_w] & (1 << bit_w)) ) {
fprintf(stderr, "strange page: %d, at %p, off %x\r\n",
pag_w, adr_w, off_w);
abort();
}
c3_assert(0 == (u3P.dit_w[blk_w] & (1 << bit_w)));
u3P.dit_w[blk_w] |= (1 << bit_w);
@ -166,7 +219,7 @@ _ce_image_open(u3e_image* img_u, c3_o nuu_o)
/* _ce_patch_write_control(): write control block file.
*/
static void
_ce_patch_write_control(u3_cs_patch* pat_u)
_ce_patch_write_control(u3_ce_patch* pat_u)
{
c3_w len_w = sizeof(u3e_control) +
(pat_u->con_u->pgs_w * sizeof(u3e_line));
@ -179,7 +232,7 @@ _ce_patch_write_control(u3_cs_patch* pat_u)
/* _ce_patch_read_control(): read control block file.
*/
static c3_o
_ce_patch_read_control(u3_cs_patch* pat_u)
_ce_patch_read_control(u3_ce_patch* pat_u)
{
c3_w len_w;
@ -209,7 +262,7 @@ _ce_patch_read_control(u3_cs_patch* pat_u)
/* _ce_patch_create(): create patch files.
*/
static void
_ce_patch_create(u3_cs_patch* pat_u)
_ce_patch_create(u3_ce_patch* pat_u)
{
c3_c ful_c[8193];
@ -247,7 +300,7 @@ _ce_patch_delete(void)
/* _ce_patch_verify(): check patch data mug.
*/
static c3_o
_ce_patch_verify(u3_cs_patch* pat_u)
_ce_patch_verify(u3_ce_patch* pat_u)
{
c3_w i_w;
@ -288,7 +341,7 @@ _ce_patch_verify(u3_cs_patch* pat_u)
/* _ce_patch_free(): free a patch.
*/
static void
_ce_patch_free(u3_cs_patch* pat_u)
_ce_patch_free(u3_ce_patch* pat_u)
{
free(pat_u->con_u);
close(pat_u->ctl_i);
@ -298,10 +351,10 @@ _ce_patch_free(u3_cs_patch* pat_u)
/* _ce_patch_open(): open patch, if any.
*/
static u3_cs_patch*
static u3_ce_patch*
_ce_patch_open(void)
{
u3_cs_patch* pat_u;
u3_ce_patch* pat_u;
c3_c ful_c[8193];
c3_i ctl_i, mem_i;
@ -323,7 +376,7 @@ _ce_patch_open(void)
_ce_patch_delete();
return 0;
}
pat_u = malloc(sizeof(u3_cs_patch));
pat_u = malloc(sizeof(u3_ce_patch));
pat_u->ctl_i = ctl_i;
pat_u->mem_i = mem_i;
pat_u->con_u = 0;
@ -347,7 +400,7 @@ _ce_patch_open(void)
/* _ce_patch_write_page(): write a page of patch memory.
*/
static void
_ce_patch_write_page(u3_cs_patch* pat_u,
_ce_patch_write_page(u3_ce_patch* pat_u,
c3_w pgc_w,
c3_w* mem_w)
{
@ -379,7 +432,7 @@ _ce_patch_count_page(c3_w pag_w,
/* _ce_patch_save_page(): save a page, producing new page counter.
*/
static c3_w
_ce_patch_save_page(u3_cs_patch* pat_u,
_ce_patch_save_page(u3_ce_patch* pat_u,
c3_w pag_w,
c3_w pgc_w)
{
@ -394,9 +447,7 @@ _ce_patch_save_page(u3_cs_patch* pat_u,
(1 << u3a_page));
#if 0
u3K.mug_w[pag_w] = pat_u->con_u->mem_u[pgc_w].mug_w;
printf("save: page %d, mug %x\r\n",
pag_w, u3r_mug_words(mem_w, (1 << u3a_page)));
printf("protect a: page %d\r\n", pag_w);
#endif
_ce_patch_write_page(pat_u, pgc_w, mem_w);
@ -416,12 +467,13 @@ _ce_patch_save_page(u3_cs_patch* pat_u,
/* _ce_patch_junk_page(): mark a page as junk.
*/
static void
_ce_patch_junk_page(u3_cs_patch* pat_u,
_ce_patch_junk_page(u3_ce_patch* pat_u,
c3_w pag_w)
{
c3_w blk_w = (pag_w >> 5);
c3_w bit_w = (pag_w & 31);
// printf("protect b: page %d\r\n", pag_w);
if ( -1 == mprotect(u3_Loom + (pag_w << u3a_page),
(1 << (u3a_page + 2)),
PROT_READ) )
@ -470,7 +522,7 @@ u3e_dirty(void)
/* _ce_patch_compose(): make and write current patch.
*/
static u3_cs_patch*
static u3_ce_patch*
_ce_patch_compose(void)
{
c3_w pgs_w = 0;
@ -508,7 +560,7 @@ _ce_patch_compose(void)
return 0;
}
else {
u3_cs_patch* pat_u = malloc(sizeof(u3_cs_patch));
u3_ce_patch* pat_u = malloc(sizeof(u3_ce_patch));
c3_w i_w, pgc_w;
_ce_patch_create(pat_u);
@ -553,7 +605,7 @@ _ce_sync(c3_i fid_i)
/* _ce_patch_sync(): make sure patch is synced to disk.
*/
static void
_ce_patch_sync(u3_cs_patch* pat_u)
_ce_patch_sync(u3_ce_patch* pat_u)
{
_ce_sync(pat_u->ctl_i);
_ce_sync(pat_u->mem_i);
@ -570,7 +622,7 @@ _ce_image_sync(u3e_image* img_u)
/* _ce_patch_apply(): apply patch to image.
*/
static void
_ce_patch_apply(u3_cs_patch* pat_u)
_ce_patch_apply(u3_ce_patch* pat_u)
{
c3_w i_w;
@ -700,7 +752,7 @@ _ce_image_fine(u3e_image* img_u,
void
u3e_save(void)
{
u3_cs_patch* pat_u;
u3_ce_patch* pat_u;
// Write all dirty pages to disk; clear protection and dirty bits.
//
@ -829,6 +881,10 @@ u3e_init(c3_o chk_o)
_ce_limits();
_ce_signals();
/* Make sure GMP uses our malloc.
*/
// mp_set_memory_functions(u3a_malloc, u3a_realloc2, u3a_free2);
/* Map at fixed address.
*/
{
@ -909,7 +965,7 @@ u3e_boot(c3_o nuu_o, c3_o bug_o, c3_c* cpu_c)
}
}
else {
u3_cs_patch* pat_u;
u3_ce_patch* pat_u;
/* Open image files.
*/

30
n/j.c
View File

@ -7,14 +7,14 @@
/* _cj_count(): count and link dashboard entries.
*/
static c3_w
_cj_count(u3e_core* par_u, u3e_core* dev_u)
_cj_count(u3j_core* par_u, u3j_core* dev_u)
{
c3_w len_l = 0;
c3_w i_w;
if ( dev_u ) {
for ( i_w = 0; 0 != dev_u[i_w].cos_c; i_w++ ) {
u3e_core* kid_u = &dev_u[i_w];
u3j_core* kid_u = &dev_u[i_w];
kid_u->par_u = par_u;
len_l += _cj_count(kid_u, kid_u->dev_u);
@ -25,13 +25,13 @@
/* _cj_install(): install dashboard entries.
*/
static c3_w
_cj_install(u3e_core* ray_u, c3_w jax_l, u3e_core* dev_u)
_cj_install(u3j_core* ray_u, c3_w jax_l, u3j_core* dev_u)
{
c3_w i_w;
if ( dev_u ) {
for ( i_w = 0; 0 != dev_u[i_w].cos_c; i_w++ ) {
u3e_core* kid_u = &dev_u[i_w];
u3j_core* kid_u = &dev_u[i_w];
kid_u->jax_l = jax_l;
ray_u[jax_l++] = *kid_u;
@ -313,12 +313,12 @@ static u3_noun
_cj_warm_hump(c3_l jax_l, u3_noun huc)
{
u3_noun hap = u3_nul;
u3e_core* cop_u;
u3j_core* cop_u;
/* Compute axes of all correctly declared arms.
*/
if ( jax_l && (cop_u = &u3D.ray_u[jax_l])->arm_u ) {
u3e_harm* jet_u;
u3j_harm* jet_u;
c3_l i_l;
for ( i_l = 0; (jet_u = &cop_u->arm_u[i_l])->fcs_c; i_l++ ) {
@ -362,8 +362,8 @@ _cj_warm_hump(c3_l jax_l, u3_noun huc)
static c3_l
_cj_boil_mean(c3_l par_l, u3_noun mop, u3_noun bat)
{
u3e_core* par_u;
u3e_core* dev_u;
u3j_core* par_u;
u3j_core* dev_u;
if ( 0 != par_l ) {
par_u = &u3D.ray_u[par_l];
@ -376,7 +376,7 @@ _cj_boil_mean(c3_l par_l, u3_noun mop, u3_noun bat)
{
c3_w i_l = 0;
u3e_core* cop_u;
u3j_core* cop_u;
while ( (cop_u = &dev_u[i_l])->cos_c ) {
if ( _(u3r_sing_c(cop_u->cos_c, u3h(mop))) ) {
@ -596,8 +596,8 @@ u3j_boot(void)
u3D.len_l =_cj_count(0, u3D.dev_u);
u3D.all_l = (2 * u3D.len_l) + 1024; // horrid heuristic
u3D.ray_u = (u3e_core*) malloc(u3D.all_l * sizeof(u3e_core));
memset(u3D.ray_u, 0, (u3D.all_l * sizeof(u3e_core)));
u3D.ray_u = (u3j_core*) malloc(u3D.all_l * sizeof(u3j_core));
memset(u3D.ray_u, 0, (u3D.all_l * sizeof(u3j_core)));
jax_l = _cj_install(u3D.ray_u, 1, u3D.dev_u);
fprintf(stderr, "boot: installed %d jets\n", jax_l);
@ -657,7 +657,7 @@ extern int SLAY;
** `axe` is RETAINED.
*/
static u3_weak
_cj_kick_z(u3_noun cor, u3e_core* cop_u, u3e_harm* ham_u, u3_atom axe)
_cj_kick_z(u3_noun cor, u3j_core* cop_u, u3j_harm* ham_u, u3_atom axe)
{
if ( 0 == ham_u->fun_f ) {
return u3_none;
@ -732,7 +732,7 @@ _cj_hook_in(u3_noun cor,
u3x_qual(cax, &jax, &pax, &hap, &huc);
{
c3_l jax_l = jax;
u3e_core* cop_u = &u3D.ray_u[jax_l];
u3j_core* cop_u = &u3D.ray_u[jax_l];
u3_noun fol = u3kdb_get(u3k(huc), u3i_string(tam_c));
if ( u3_none == fol ) {
@ -827,9 +827,9 @@ u3j_kick(u3_noun cor, u3_noun axe)
}
else {
c3_l jax_l = u3h(cax);
u3e_core* cop_u = &u3D.ray_u[jax_l];
u3j_core* cop_u = &u3D.ray_u[jax_l];
c3_l inx_l = inx;
u3e_harm* ham_u = &cop_u->arm_u[inx_l];
u3j_harm* ham_u = &cop_u->arm_u[inx_l];
u3_noun pro;
u3z(cax);

4
n/v.c
View File

@ -38,8 +38,6 @@ u3v_make(c3_c* pas_c)
u3z(sys);
}
int JACK;
/* u3v_jack(): execute kernel formula to bind jets.
*/
void
@ -47,11 +45,9 @@ u3v_jack(void)
{
u3_noun cor;
JACK = 1;
printf("cv_jack: activating kernel %x\n", u3r_mug(u3A->ken));
cor = u3n_nock_on(0, u3k(u3A->ken));
printf("cv_jack: activated\n");
JACK = 0;
u3z(cor);
}

View File

@ -39,6 +39,8 @@ _main_readw(const c3_c* str_c, c3_w max_w, c3_w* out_w)
else return c3n;
}
static c3_c hostbuf[2048]; // kill me
/* _main_getopt(): extract option map from command line.
*/
static u3_noun
@ -143,7 +145,7 @@ _main_getopt(c3_i argc, c3_c** argv)
if ( u3_Host.ops_u.nam_c == 0 ) {
c3_w len_w = sysconf(_SC_HOST_NAME_MAX) + 1;
u3_Host.ops_u.nam_c = c3_malloc(len_w);
u3_Host.ops_u.nam_c = hostbuf;
if ( 0 != gethostname(u3_Host.ops_u.nam_c, len_w) ) {
perror("gethostname");
exit(1);