lib: rename stdlib surface to Hare names; add endian/math

Sweeping rename so the lib/ surface mirrors Hare's stdlib spellings.
- ascii: rune-taking predicates; ishex -> isxdigit
- bufio: rinit -> init; take1/takeline -> readbyte/readline
- bytes: indexsub -> index
- encoding/utf8: runelen -> runesz
- errors: eEOF/eShortRead/... -> eof/underread/...
- fmt: errln -> errorln; println/fprintln return i64
- os: readfull/writefull -> readall/writeall; unlink -> remove
- path: isabs -> abs; drop lastindex (now strings.rbyteindex)
- strconv: u64toa/i64toa -> u64tos/i64tos; parse64/parseu64 -> stoi64/stou64
- strings: drop len/isempty; equal -> compare; indexbyte -> byteindex; +rbyteindex
- types: drop numeric helpers (moved to math)
- new lib/endian (htonu16/ntohu16), lib/math (absi32/absi64)
- net: drop htons (use endian.htonu16)

Callers in selfhost/, lib/ww/, cmd/w6c/cgen.c, and test/wcc/700_e2e.c
updated to match.
This commit is contained in:
2026-05-12 00:45:18 +09:00
parent 35421f2561
commit 1ac1d985f6
37 changed files with 597 additions and 568 deletions

View File

@@ -205,27 +205,27 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
wru16(eh.ptr, 60u64, NSECT); // e_shnum
wru16(eh.ptr, 62u64, 5u16); // e_shstrndx
if (os.writefull(fd, eh.ptr, 64u64) != 64i64) { return -1; };
if (os.writeall(fd, eh.ptr, 64u64) != 64i64) { return -1; };
if (a.textlen > 0u64) {
if (os.writefull(fd, a.text, a.textlen) != a.textlen: i64) { return -1; };
if (os.writeall(fd, a.text, a.textlen) != a.textlen: i64) { return -1; };
};
if (rela.n > 0u64) {
if (os.writefull(fd, rela.p, rela.n) != rela.n: i64) { return -1; };
if (os.writeall(fd, rela.p, rela.n) != rela.n: i64) { return -1; };
};
if (sym.n > 0u64) {
if (os.writefull(fd, sym.p, sym.n) != sym.n: i64) { return -1; };
if (os.writeall(fd, sym.p, sym.n) != sym.n: i64) { return -1; };
};
if (str_.n > 0u64) {
if (os.writefull(fd, str_.p, str_.n) != str_.n: i64) { return -1; };
if (os.writeall(fd, str_.p, str_.n) != str_.n: i64) { return -1; };
};
if (shstr.n > 0u64) {
if (os.writefull(fd, shstr.p, shstr.n) != shstr.n: i64) { return -1; };
if (os.writeall(fd, shstr.p, shstr.n) != shstr.n: i64) { return -1; };
};
// Pad to 8 before shdrs.
let written: u64 = EHDR_SZ + a.textlen + rela.n + sym.n + str_.n + shstr.n;
for ((written & 7u64) != 0u64) {
os.writefull(fd, &zero, 1u64);
os.writeall(fd, &zero, 1u64);
written += 1u64;
};
@@ -234,7 +234,7 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
// SHT_NULL
let sn: i32 = 0;
for (sn < 64) { shbuf[sn] = 0u8; sn += 1; };
os.writefull(fd, shbuf.ptr, 64u64);
os.writeall(fd, shbuf.ptr, 64u64);
// .text
sn = 0;
for (sn < 64) { shbuf[sn] = 0u8; sn += 1; };
@@ -244,7 +244,7 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
wru64(shbuf.ptr, 24u64, offtext);
wru64(shbuf.ptr, 32u64, a.textlen);
wru64(shbuf.ptr, 48u64, 1u64); // sh_addralign
os.writefull(fd, shbuf.ptr, 64u64);
os.writeall(fd, shbuf.ptr, 64u64);
// .rela.text
sn = 0;
for (sn < 64) { shbuf[sn] = 0u8; sn += 1; };
@@ -257,7 +257,7 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
wru32(shbuf.ptr, 44u64, 1u32); // sh_info = .text idx
wru64(shbuf.ptr, 48u64, 8u64);
wru64(shbuf.ptr, 56u64, RELA_SZ);
os.writefull(fd, shbuf.ptr, 64u64);
os.writeall(fd, shbuf.ptr, 64u64);
// .symtab
sn = 0;
for (sn < 64) { shbuf[sn] = 0u8; sn += 1; };
@@ -269,7 +269,7 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
wru32(shbuf.ptr, 44u64, 1u32); // sh_info = one local (STN_UNDEF)
wru64(shbuf.ptr, 48u64, 8u64);
wru64(shbuf.ptr, 56u64, SYM_SZ);
os.writefull(fd, shbuf.ptr, 64u64);
os.writeall(fd, shbuf.ptr, 64u64);
// .strtab
sn = 0;
for (sn < 64) { shbuf[sn] = 0u8; sn += 1; };
@@ -278,7 +278,7 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
wru64(shbuf.ptr, 24u64, offstr);
wru64(shbuf.ptr, 32u64, str_.n);
wru64(shbuf.ptr, 48u64, 1u64);
os.writefull(fd, shbuf.ptr, 64u64);
os.writeall(fd, shbuf.ptr, 64u64);
// .shstrtab
sn = 0;
for (sn < 64) { shbuf[sn] = 0u8; sn += 1; };
@@ -287,7 +287,7 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
wru64(shbuf.ptr, 24u64, offshstr);
wru64(shbuf.ptr, 32u64, shstr.n);
wru64(shbuf.ptr, 48u64, 1u64);
os.writefull(fd, shbuf.ptr, 64u64);
os.writeall(fd, shbuf.ptr, 64u64);
return 0;
};