C bootstrap (phases 0-9):
cmd/wwc, cmd/6c, cmd/6a, cmd/6l, cmd/ww, rt, lib/*.
ww-side self-host (phase 10):
selfhost/cmd/wwc — ww-cgen frontend; bootstrap fixed point.
selfhost/cmd/6a — assembler; byte-identical to C 6a (test 991).
selfhost/cmd/6l — linker w/ archive (.a) support; byte-identical
to C 6l (test 992).
selfhost/cmd/ww — driver (build/run/version); byte-identical to
C ww (test 993).
make test: 15/15. make bootstrap: ww2.s == ww3.s, ww2.o == ww3.o,
ww2 == ww3 byte-identical, with the full ww-tooled chain.
49 lines
1.0 KiB
Plaintext
49 lines
1.0 KiB
Plaintext
// types — integer limits and helpers, the seed module that the
|
|
// rest of the stdlib depends on. Plan 9-flavoured: the names are
|
|
// short and the constants are platform-fixed (we are amd64 only).
|
|
|
|
def I8_MAX: i8 = 127;
|
|
def I16_MAX: i16 = 32767;
|
|
def I32_MAX: i32 = 2147483647;
|
|
def I64_MAX: i64 = 9223372036854775807;
|
|
|
|
def I8_MIN: i8 = -128;
|
|
def I16_MIN: i16 = -32768;
|
|
def I32_MIN: i32 = -2147483648;
|
|
def I64_MIN: i64 = -9223372036854775808;
|
|
|
|
def U8_MAX: u8 = 255;
|
|
def U16_MAX: u16 = 65535;
|
|
def U32_MAX: u32 = 4294967295;
|
|
def U64_MAX: u64 = 18446744073709551615;
|
|
|
|
export fn min_i32(a: i32, b: i32) i32 = {
|
|
if (a < b) { return a; };
|
|
return b;
|
|
};
|
|
|
|
export fn max_i32(a: i32, b: i32) i32 = {
|
|
if (a > b) { return a; };
|
|
return b;
|
|
};
|
|
|
|
export fn min_i64(a: i64, b: i64) i64 = {
|
|
if (a < b) { return a; };
|
|
return b;
|
|
};
|
|
|
|
export fn max_i64(a: i64, b: i64) i64 = {
|
|
if (a > b) { return a; };
|
|
return b;
|
|
};
|
|
|
|
export fn abs_i32(x: i32) i32 = {
|
|
if (x < 0) { return -x; };
|
|
return x;
|
|
};
|
|
|
|
export fn abs_i64(x: i64) i64 = {
|
|
if (x < 0) { return -x; };
|
|
return x;
|
|
};
|