Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions boot-fake-ship.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
set -xeuo pipefail

urbit_binary=$GITHUB_WORKSPACE/$URBIT_BINARY
solid_pill=$GITHUB_WORKSPACE/solid.pill
brass_pill=$GITHUB_WORKSPACE/brass.pill

curl -LJ -o $solid_pill https://github.com/urbit/urbit/raw/84ebb321314b3fbc08253de5213f19450ffbfb3e/bin/solid.pill
curl -LJ -o urbit.tar.gz https://github.com/urbit/urbit/archive/84ebb321314b3fbc08253de5213f19450ffbfb3e.tar.gz
curl -LJ -o $brass_pill https://github.com/urbit/urbit/raw/592b957a30b302cb7ae7fea78c6804c9d63d97ef/bin/brass.pill
curl -LJ -o urbit.tar.gz https://github.com/urbit/urbit/archive/592b957a30b302cb7ae7fea78c6804c9d63d97ef.tar.gz

mkdir ./urbit
tar xfz urbit.tar.gz -C ./urbit --strip-components=1
cp -RL ./urbit/tests ./urbit/pkg/arvo/tests

$urbit_binary --lite-boot --daemon --fake bus \
--bootstrap $solid_pill \
--bootstrap $brass_pill \
--arvo ./urbit/pkg/arvo \
--pier ./pier

Expand Down
1 change: 1 addition & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ fn buildBinary(
"-DU3_GUARD_PAGE", // pkg_noun
"-DU3_OS_ENDIAN_little=1", // pkg_c3
"-DU3_OS_PROF=1", // pkg_c3
"-DVERE64",
});

if (cfg.cpu_dbg)
Expand Down
8 changes: 4 additions & 4 deletions pkg/c3/defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

c3_s
c3_sift_short(c3_y buf_y[2]);
c3_w
c3_sift_word(c3_y buf_y[4]);
c3_w_tmp
c3_sift_word_new(c3_y buf_y[4]);
c3_d
c3_sift_chub(c3_y byt_y[8]);

void
c3_etch_short(c3_y buf_y[2], c3_s sot_s);
void
c3_etch_word(c3_y buf_y[4], c3_w wod_w);
c3_etch_word_new(c3_y buf_y[4], c3_w_tmp wod_w);
void
c3_etch_chub(c3_y byt_y[8], c3_d num_d);

c3_w c3_align_w(c3_w x, c3_w al, align_dir hilo);
c3_w_tmp c3_align_w(c3_w_tmp x, c3_w_tmp al, align_dir hilo);
c3_d c3_align_d(c3_d x, c3_d al, align_dir hilo);
void *c3_align_p(void const * p, size_t al, align_dir hilo);
68 changes: 58 additions & 10 deletions pkg/c3/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@

/* Size in words.
*/
// XX: 64 square with allocate.h
// (probably some of that belongs here)
#ifndef VERE64
# define c3_wiseof(x) (((sizeof (x)) + 3) >> 2)
#else
# define c3_wiseof(x) (((sizeof (x)) + 7) >> 3)
#endif

/* Bit counting.
*/
Expand All @@ -64,7 +70,29 @@
# error "port me"
#endif

# define c3_bits_word(w) ((w) ? (32 - c3_lz_w(w)) : 0)
#if (64 == (CHAR_BIT * __SIZEOF_LONG_LONG__))
# define c3_lz_d __builtin_clzll
# define c3_tz_d __builtin_ctzll
# define c3_pc_d __builtin_popcountll
#else
# error "port me"
#endif

# define c3_bits_word_tmp(w) ((w) ? (32 - c3_lz_w(w)) : 0)
# define c3_bits_word_new(w) ((w) ? (32 - c3_lz_w(w)) : 0)
# define c3_bits_chub(d) ((d) ? (64 - c3_lz_d(d)) : 0)

#ifndef VERE64
# define c3_bits_note(n) c3_bits_word_new(n)
# define c3_lz_n c3_lz_w
# define c3_tz_n c3_tz_w
# define c3_pc_n c3_pc_w
#else
# define c3_bits_note(n) c3_bits_chub(n)
# define c3_lz_n c3_lz_d
# define c3_tz_n c3_tz_d
# define c3_pc_n c3_pc_d
#endif

/* Min and max.
*/
Expand All @@ -88,7 +116,7 @@
/* Fill 16 words (64 bytes) with high-quality entropy.
*/
void
c3_rand(c3_w* rad_w);
c3_rand(c3_w_tmp* rad_w);

/* Short integers.
*/
Expand Down Expand Up @@ -120,11 +148,12 @@
return ((c3_s)buf_y[1] << 8 | (c3_s)buf_y[0]);
}

inline c3_w
c3_sift_word(c3_y buf_y[4])
inline c3_w_tmp
c3_sift_word_new(c3_y buf_y[4])
{
return ((c3_w)buf_y[3] << 24 | (c3_w)buf_y[2] << 16 | (c3_w)buf_y[1] << 8 | (c3_w)buf_y[0]);
return ((c3_w_tmp)buf_y[3] << 24 | (c3_w_tmp)buf_y[2] << 16 | (c3_w_tmp)buf_y[1] << 8 | (c3_w_tmp)buf_y[0]);
}
#define c3_sift_word_tmp c3_sift_word_new

inline c3_d
c3_sift_chub(c3_y byt_y[8])
Expand All @@ -147,13 +176,14 @@
}

inline void
c3_etch_word(c3_y buf_y[4], c3_w wod_w)
c3_etch_word_new(c3_y buf_y[4], c3_w_tmp wod_w)
{
buf_y[0] = wod_w & 0xff;
buf_y[1] = (wod_w >> 8) & 0xff;
buf_y[2] = (wod_w >> 16) & 0xff;
buf_y[3] = (wod_w >> 24) & 0xff;
}
#define c3_etch_word_tmp c3_etch_word_new

inline void
c3_etch_chub(c3_y byt_y[8], c3_d num_d)
Expand Down Expand Up @@ -235,17 +265,17 @@

hi or lo align x to al

unless effective type of x is c3_w or c3_d, assumes x is a pointer.
unless effective type of x is c3_w_tmp or c3_d, assumes x is a pointer.
*/
#define c3_align(x, al, hilo) \
_Generic((x), \
c3_w : c3_align_w, \
c3_w_tmp : c3_align_w, \
c3_d : c3_align_d, \
default : c3_align_p) \
(x, al, hilo)
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) {
inline c3_w_tmp
c3_align_w(c3_w_tmp x, c3_w_tmp al, align_dir hilo) {
c3_dessert(hilo <= C3_ALGHI && hilo >= C3_ALGLO);
x += hilo * (al - 1);
x &= ~(al - 1);
Expand All @@ -258,6 +288,15 @@ c3_align_d(c3_d x, c3_d al, align_dir hilo) {
x &= ~(al - 1);
return x;
}
inline c3_n
c3_align_n(c3_n x, c3_n al, align_dir hilo) {
#ifndef VERE64
return c3_align_w(x, al, hilo);
#else
return c3_align_d(x, al, hilo);
#endif
}

inline void*
c3_align_p(void const * p, size_t al, align_dir hilo) {
uintptr_t x = (uintptr_t)p;
Expand All @@ -267,4 +306,13 @@ c3_align_p(void const * p, size_t al, align_dir hilo) {
return (void*)x;
}

#define c3_w_max 0xffffffff
#define c3_d_max 0xffffffffffffffffULL

#ifndef VERE64
#define c3_n_max c3_w_max
#else
#define c3_n_max c3_d_max
#endif

#endif /* ifndef C3_DEFS_H */
8 changes: 5 additions & 3 deletions pkg/c3/portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
# else
# define U3_OS_LoomBase 0x36000000
# endif
# define U3_OS_LoomBits 30
# elif defined(U3_OS_osx)
# ifdef __LP64__
# ifdef ASAN_ENABLED
Expand All @@ -136,18 +135,21 @@
# else
# define U3_OS_LoomBase 0x4000000
# endif
# define U3_OS_LoomBits 30
# elif defined(U3_OS_bsd)
# ifdef __LP64__
# define U3_OS_LoomBase 0x200000000
# else
# define U3_OS_LoomBase 0x4000000
# endif
# define U3_OS_LoomBits 30
# else
# error "port: LoomBase"
# endif

#ifndef VERE64
# define U3_OS_LoomBits 30
#else
# define U3_OS_LoomBits 46
#endif

/** Private C "extensions."
***
Expand Down
67 changes: 59 additions & 8 deletions pkg/c3/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
typedef ssize_t c3_zs;
typedef uint64_t c3_d;
typedef int64_t c3_ds;
typedef uint32_t c3_w;
typedef int32_t c3_ws;
typedef uint32_t c3_w_tmp;
typedef uint32_t c3_w_new;
typedef int32_t c3_ws_tmp;
typedef int32_t c3_ws_new;
typedef uint16_t c3_s;
typedef int16_t c3_ss;
typedef uint8_t c3_y; // byte
Expand All @@ -24,8 +26,18 @@
typedef uint8_t c3_t; // boolean
typedef uint8_t c3_o; // loobean
typedef uint8_t c3_g; // 32-bit log - 0-31 bits
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.
#ifdef VERE64
typedef uint32_t c3_l_tmp; // little; 31-bit unsigned integer
typedef uint64_t c3_l; // little; 31-bit unsigned integer
typedef uint64_t c3_n; // note: noun-sized integer
typedef int64_t c3_ns;
#else
typedef uint32_t c3_l_tmp; // little; 31-bit unsigned integer
typedef uint32_t c3_l; // little; 31-bit unsigned integer
typedef uint32_t c3_n; // note: noun-sized integer
typedef int32_t c3_ns;
#endif

/* Deprecated integers.
*/
Expand All @@ -49,11 +61,11 @@
#define PRIxc3_d PRIx64
#define PRIXc3_d PRIX64

/* c3_w */
#define PRIc3_w PRIu32
#define PRIc3_ws PRIi32
#define PRIxc3_w PRIx32
#define PRIXc3_w PRIX32
/* c3_w_tmp */
#define PRIc3_w_tmp PRIu32
#define PRIc3_ws_tmp PRIi32
#define PRIxc3_w_tmp PRIx32
#define PRIXc3_w_tmp PRIX32

/* c3_s */
#define PRIc3_s PRIu16
Expand All @@ -72,4 +84,43 @@
#define PRIxc3_b PRIx8
#define PRIXc3_b PRIX8

#ifdef VERE64
#define SCNc3_n SCNu64
#define PRIc3_n PRIu64
#define PRIc3_ns PRIi64
#define PRIxc3_n PRIx64
#define PRIXc3_n PRIX64
#define PRIc3_w_new PRIu32
#define PRIc3_ws_new PRIi32
#else
#define SCNc3_n SCNu32
#define PRIc3_n PRIu32
#define PRIc3_ns PRIi32
#define PRIxc3_n PRIx32
#define PRIXc3_n PRIX32
#define PRIc3_w_new PRIu32
#define PRIc3_ws_new PRIi32
#endif

#ifdef VERE64
#define PRIc3_l PRIu64
#define PRIc3_ls PRIi64
#define PRIxc3_l PRIx64
#define PRIXc3_l PRIX64
#define PRIc3_l_tmp PRIu32
#define PRIc3_ls_tmp PRIi32
#define PRIxc3_l_tmp PRIx32
#define PRIXc3_l_tmp PRIX32
#else
#define PRIc3_l PRIu32
#define PRIc3_ls PRIi32
#define PRIxc3_l PRIx32
#define PRIXc3_l PRIX32
#endif

#define PRIc3_m PRIu32
#define PRIc3_ms PRIi32
#define PRIxc3_m PRIx32
#define PRIXc3_m PRIX32

#endif /* ifndef C3_TYPES_H */
Loading