lib/os+selfhost: *u8→str path migration (#23)
Path-shaped entrypoints now take str: open, tryopen, access, remove, mkdir, rmdir, mkdirs, stat, lstat, exists, execve (path arg only). Each cites its Hare source (ref/hare/os/*.ha, ref/hare/sys/+linux/ *.ha). New internal kpath(str) *u8 copies into module-level pathbuf: [4096]u8 and NUL-terminates; mirrors ref/hare/sys/+linux/syscalls.ha:25,53. Non-reentrant — graduates with thread story. mkdirs flattens to one kpath at entry then walks pathbuf invoking raw SYS_mkdir to avoid nested kpath clobber. One Hare divergence at kpath: ships *u8 with nil ENAMETOOLONG sentinel instead of (*const u8 | errno). Reason: wwstage over-allocates 1-word-payload tagged returns to 24B (cstage emits 16B); filed as follow-up. Repro at .ai/probe_tagged_return_pointer_payload.ww; graduates when fix lands. Each selfhost cmd grew a private pathstr(*u8) str (cstrlen + bs) for remaining *u8 path sites; w6l shares via obj.ww. Probe 7 in smoke updated. Tests 975/976/981 cover migrated entrypoints; 976 extended with two ENAMETOOLONG rows (-36 for stat, false for exists).
This commit is contained in:
@@ -76,7 +76,7 @@ def RELA_ADDEND: u64 = 16u64;
|
||||
// ---- file slurp --------------------------------------------------------
|
||||
|
||||
fn slurp(path: *u8) (*u8, u64) = {
|
||||
let fd: i32 = os.open(path, os.flag.RDONLY, 0i32);
|
||||
let fd: i32 = os.open(pathstr(path), os.flag.RDONLY, 0i32);
|
||||
if (fd < 0) { return nil, 0u64; };
|
||||
let szr: (i64 | os.oserror) = os.filesize(fd);
|
||||
let n: i64 = 0i64;
|
||||
@@ -153,6 +153,16 @@ fn cstrlen(p: *u8) u64 = {
|
||||
return n;
|
||||
};
|
||||
|
||||
// pathstr — view a NUL-terminated *u8 as a str. Bridges argv/arena
|
||||
// callers to lib/os entrypoints (str post-task-#23). Shared with
|
||||
// main.ww and dyn.ww via the w6l bundle.
|
||||
fn pathstr(p: *u8) str = {
|
||||
let r: str;
|
||||
r.ptr = p;
|
||||
r.len = cstrlen(p): i32;
|
||||
return r;
|
||||
};
|
||||
|
||||
fn cstreq(p: *u8, lit: str) bool = {
|
||||
let n: u64 = lit.len: u64;
|
||||
let i: u64 = 0u64;
|
||||
|
||||
Reference in New Issue
Block a user