Skip to content

Commit

Permalink
#ifdef gate
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-levan committed Aug 23, 2024
1 parent 6583ca2 commit 19dd84b
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 9 deletions.
14 changes: 14 additions & 0 deletions pkg/c3/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@

/* Size in words.
*/
#ifdef VERE_64
# define c3_wiseof(x) (((sizeof (x)) + 7) >> 3)
#else
# define c3_wiseof(x) (((sizeof (x)) + 3) >> 2)
#endif


/* Bit counting.
*/
Expand Down Expand Up @@ -224,11 +229,20 @@
unless effective type of x is c3_w or c3_d, assumes x is a pointer.
*/
#ifdef VERE_64
#define c3_align(x, al, hilo) \
_Generic((x), \
c3_d : c3_align_d, \
default : c3_align_p) \
(x, al, hilo)
#else
#define c3_align(x, al, hilo) \
_Generic((x), \
c3_w : c3_align_w, \
c3_d : c3_align_d, \
default : c3_align_p) \
(x, al, hilo)
#endif
typedef enum { C3_ALGHI=1, C3_ALGLO=0 } align_dir;
inline c3_w
c3_align_w(c3_w x, c3_w al, align_dir hilo) {
Expand Down
9 changes: 7 additions & 2 deletions pkg/c3/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
typedef ssize_t c3_zs;
typedef uint64_t c3_d;
typedef int64_t c3_ds;
#ifdef VERE_64
typedef uint64_t c3_w;
typedef int64_t c3_ws;
#else
typedef uint32_t c3_w;
typedef int32_t c3_ws;
#endif
typedef uint16_t c3_s;
typedef int16_t c3_ss;
typedef uint8_t c3_y; // byte
Expand All @@ -24,8 +29,8 @@
typedef uint8_t c3_t; // boolean
typedef uint8_t c3_o; // loobean
typedef uint8_t c3_g; // 32-bit log - 0-31 bits
typedef uint64_t c3_l; // little; 31-bit unsigned integer
typedef uint64_t c3_m; // mote; also c3_l; LSB first a-z 4-char string.
typedef uint32_t c3_l; // little; 31-bit unsigned integer
typedef uint32_t c3_m; // mote; also c3_l; LSB first a-z 4-char string.

/* Deprecated integers.
*/
Expand Down
6 changes: 5 additions & 1 deletion pkg/noun/allocate.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

/* u3a_walign: references into the loom are guaranteed to be word-aligned to:
*/
#ifdef VERE_64
# define u3a_walign (4 << u3a_vits)
#else
# define u3a_walign (1 << u3a_vits)
#endif

/* u3a_balign: u3a_walign in bytes
*/
Expand All @@ -28,7 +32,7 @@

/* u3a_page: number of bits in word-addressed page. 12 == 16K page
*/
# define u3a_page 12ULL
# define u3a_page 13ULL

/* u3a_pages: maximum number of pages in memory.
*/
Expand Down
1 change: 1 addition & 0 deletions pkg/noun/jets.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ u3j_boot(c3_o nuu_o)
u3h_free(u3R->jed.hot_p);
}
u3R->jed.hot_p = u3h_new();
fprintf(stderr, "jets: hot state init done\r\n");

return _cj_install(u3D.ray_u, 1,
(c3_l) (long long) u3D.dev_u[0].par_u,
Expand Down
5 changes: 5 additions & 0 deletions pkg/noun/jets/b/find.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@

#include "noun.h"

#ifdef VERE_64
STATIC_ASSERT( (UINT64_MAX > u3a_cells),
"list index precision" );
#else
STATIC_ASSERT( (UINT32_MAX > u3a_cells),
"list index precision" );
#endif

u3_noun
u3qb_find(u3_noun nedl, u3_noun hstk)
Expand Down
7 changes: 6 additions & 1 deletion pkg/noun/jets/b/lent.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@

#include "noun.h"

#ifdef VERE_64
STATIC_ASSERT( (UINT64_MAX > u3a_cells),
"length precision" );
"list index precision" );
#else
STATIC_ASSERT( (UINT32_MAX > u3a_cells),
"list index precision" );
#endif

u3_noun
u3qb_lent(u3_noun a)
Expand Down
5 changes: 5 additions & 0 deletions pkg/noun/jets/d/in_wyt.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@

#include "noun.h"

#ifdef VERE_64
STATIC_ASSERT( (UINT64_MAX > u3a_cells),
"width precision" );
#else
STATIC_ASSERT( (UINT32_MAX > u3a_cells),
"width precision" );
#endif

static c3_w
_wyt_in(u3_noun a)
Expand Down
23 changes: 21 additions & 2 deletions pkg/noun/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,11 @@ _pave_north(c3_w* mem_w, c3_w siz_w, c3_w len_w, c3_o kid_o)
//
c3_w* mat_w = c3_align(mem_w + len_w - siz_w, u3a_balign, C3_ALGLO);
c3_w* rut_w = c3_align(mem_w, u3a_balign, C3_ALGHI);
c3_w* end_w = mat_w + siz_w;
c3_w* cap_w = mat_w;
fprintf(stderr, "mat_w: %p, rut_w: %p, cap_w: %p, siz_w: %llu\r\n",
mat_w, rut_w, cap_w, siz_w);
fprintf(stderr, "loom: mat_w: %p, rut_w: %p\r\n"
" cap_w: %p, end_w: %p\r\n",
mat_w, rut_w, cap_w, end_w);

if ( c3y == kid_o ) {
u3e_ward(u3of(c3_w, rut_w) - 1, u3of(c3_w, cap_w));
Expand Down Expand Up @@ -588,8 +590,13 @@ _pave_home(void)
_pave_parts();
}

#ifdef VERE_64
STATIC_ASSERT( ((c3_wiseof(u3v_home) * 8) == sizeof(u3v_home)),
"home road alignment" );
#else
STATIC_ASSERT( ((c3_wiseof(u3v_home) * 4) == sizeof(u3v_home)),
"home road alignment" );
#endif

/* _find_home(): in restored image, point to home road.
*/
Expand Down Expand Up @@ -2076,7 +2083,11 @@ u3m_init(size_t len_i)
exit(1);
}

#ifdef VERE_64
u3C.wor_i = len_i >> 3;
#else
u3C.wor_i = len_i >> 2;
#endif
u3l_log("loom: mapped %zuMB", len_i >> 20);
}
}
Expand Down Expand Up @@ -2140,6 +2151,7 @@ u3m_boot(c3_c* dir_c, size_t len_i)
/* Activate the loom.
*/
u3m_init(len_i);
fprintf(stderr, "loom: init done\n");

/* Activate the storage system.
*/
Expand All @@ -2155,6 +2167,7 @@ u3m_boot(c3_c* dir_c, size_t len_i)
/* Construct or activate the allocator.
*/
u3m_pave(nuu_o);
fprintf(stderr, "loom: pave done\n");

/* GC immediately if requested
*/
Expand Down Expand Up @@ -2195,29 +2208,35 @@ u3m_boot_lite(size_t len_i)
/* Activate the loom.
*/
u3m_init(len_i);
fprintf(stderr, "lite: loom init done\r\n");

/* Activate tracing.
*/
u3C.slog_f = 0;
u3C.sign_hold_f = 0;
u3C.sign_move_f = 0;
u3t_init();
fprintf(stderr, "lite: tracing init done\r\n");

/* Construct or activate the allocator.
*/
u3m_pave(c3y);
fprintf(stderr, "lite: pave done\r\n");

/* Place the guard page.
*/
u3e_init();
fprintf(stderr, "lite: guard done\r\n");

/* Initialize the jet system.
*/
u3j_boot(c3y);
fprintf(stderr, "lite: jets done\r\n");

/* Basic initialization.
*/
memset(u3A, 0, sizeof(*u3A));
fprintf(stderr, "lite: memset done\r\n");
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/noun/manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
** %oops :: assertion failure
*/
c3_i
u3m_bail(c3_m how_m) __attribute__((noreturn));
u3m_bail(c3_w how_m) __attribute__((noreturn));

/* u3m_fault(): handle a memory event with libsigsegv protocol.
*/
Expand Down
2 changes: 1 addition & 1 deletion pkg/noun/retrieve.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
/* u3r_mug_both(): Join two mugs.
*/
c3_l
u3r_mug_both(c3_w lef_w, c3_w rit_w);
u3r_mug_both(c3_l lef_w, c3_l rit_w);

/* u3r_mug_bytes(): Compute the mug of `buf`, `len`, LSW first.
*/
Expand Down
3 changes: 2 additions & 1 deletion pkg/vere/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static c3_i
_main_readw_loom(const c3_c* arg_c, c3_y* out_y)
{
c3_w lom_w;
c3_o res_o = _main_readw(optarg, u3a_bits_max, &lom_w);
c3_o res_o = _main_readw(optarg, u3a_bits_max + 1, &lom_w);
if ( res_o == c3n || (lom_w < 20) ) {
fprintf(stderr, "error: --%s must be >= 20 and <= %zu\r\n", arg_c, u3a_bits_max);
return -1;
Expand Down Expand Up @@ -3345,6 +3345,7 @@ main(c3_i argc,
SSL_library_init();
SSL_load_error_strings();
}
fprintf(stderr, "boot: openssl initialized\n");

// initialize curl
//
Expand Down

0 comments on commit 19dd84b

Please sign in to comment.