cmd/ww: drop duplicate PATH_MAX def; use os.PATH_MAX
main.ww was declaring `def PATH_MAX: u64 = 4096u64;` alongside the imported os module's `export def PATH_MAX: i32 = 4096;` (lib/os/os.ww:91). The duplicate triggered the cstage mod_map last-write-wins attribution bug (#127): cstage emitted `main.PATH_MAX` for os's DATA entry too, producing two 4096-byte slots and a wrong-module symbol. Both stages shipped working binaries because LOADs all routed to main.PATH_MAX(SB), but the divergence was real. Removing the duplicate closes the only known #127 consumer per rule-7; the defensive cstage cgen fix stays filed (task #11) until a new duplicate-def collision surfaces. PATH_MAX use-sites in main.ww cast `os.PATH_MAX: u64` at point-of-use for alloc/arithmetic, and use the bare i32 form directly for slice .len assigns (which expect i32). No cgen surface touched; byte-id-neutral on the 990-997 gates.
This commit is contained in:
@@ -2724,8 +2724,9 @@ import rt;
|
||||
import strings;
|
||||
|
||||
// All path/string scratch buffers go on the runtime page allocator.
|
||||
// One page is plenty for any path we build.
|
||||
def PATH_MAX: u64 = 4096u64;
|
||||
// One page is plenty for any path we build. PATH_MAX lives in lib/os
|
||||
// (os.PATH_MAX: i32 = 4096) — the duplicate u64 def was dropped to close
|
||||
// the cgen #127 mod-mangle attribution bug consumer per rule-7.
|
||||
def CMD_MAX: u64 = 8192u64;
|
||||
|
||||
// ---- C-string helpers --------------------------------------------------
|
||||
@@ -2845,8 +2846,8 @@ fn selfdirinto(dst: *u8, dstsz: u64, argv0: *u8) void = {
|
||||
|
||||
// Build "$dir/$name" (NUL-terminated) into a fresh page-sized buffer.
|
||||
fn joinpath(dir: *u8, name: *u8) *u8 = {
|
||||
let buf: []u8 = alloc([], PATH_MAX)!;
|
||||
buf.len = PATH_MAX: i32;
|
||||
let buf: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
buf.len = os.PATH_MAX;
|
||||
let off: u64 = cstrinto(buf.ptr, 0u64, dir);
|
||||
off = byteinto(buf.ptr, off, 47u8);
|
||||
off = cstrinto(buf.ptr, off, name);
|
||||
@@ -2856,8 +2857,8 @@ fn joinpath(dir: *u8, name: *u8) *u8 = {
|
||||
|
||||
// Same, but the second component is a ww `str` literal.
|
||||
fn joinpathlit(dir: *u8, name: str) *u8 = {
|
||||
let buf: []u8 = alloc([], PATH_MAX)!;
|
||||
buf.len = PATH_MAX: i32;
|
||||
let buf: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
buf.len = os.PATH_MAX;
|
||||
let off: u64 = cstrinto(buf.ptr, 0u64, dir);
|
||||
off = byteinto(buf.ptr, off, 47u8);
|
||||
off = strinto(buf.ptr, off, name);
|
||||
@@ -2960,7 +2961,7 @@ fn importpathform(name: *u8, namelen: u64) *u8 = {
|
||||
// `foo/foo.ha` fallback; a module IS the directory).
|
||||
fn locatein(dir: *u8, dirlen: u64,
|
||||
pathform: *u8, pflen: u64, isdir: *i32) *u8 = {
|
||||
let buf: []u8 = alloc([], PATH_MAX)!;
|
||||
let buf: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
let off: u64 = 0u64;
|
||||
let i: u64 = 0u64;
|
||||
for (i < dirlen) { buf[off + i] = dir[i]; i += 1u64; };
|
||||
@@ -2985,7 +2986,7 @@ fn locatein(dir: *u8, dirlen: u64,
|
||||
return buf.ptr;
|
||||
};
|
||||
|
||||
let buf2: []u8 = alloc([], PATH_MAX)!;
|
||||
let buf2: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
off = 0u64;
|
||||
i = 0u64;
|
||||
for (i < dirlen) { buf2[off + i] = dir[i]; i += 1u64; };
|
||||
@@ -3430,8 +3431,8 @@ fn makestem(stem: *u8, src: *u8) void = {
|
||||
|
||||
// Append a literal suffix to `stem` (which already lives in a buffer).
|
||||
fn appendlit(stem: *u8, suffix: str) *u8 = {
|
||||
let buf: []u8 = alloc([], PATH_MAX)!;
|
||||
buf.len = PATH_MAX: i32;
|
||||
let buf: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
buf.len = os.PATH_MAX;
|
||||
let off: u64 = cstrinto(buf.ptr, 0u64, stem);
|
||||
off = strinto(buf.ptr, off, suffix);
|
||||
cstrseal(buf.ptr, off);
|
||||
@@ -3467,8 +3468,8 @@ fn buildone(selfdir: *u8, src: *u8, entryisdir: i32, out: *u8, incs: *u8, lf: *l
|
||||
let l6: *u8 = joinpathlit(selfdir, "w6l_ww");
|
||||
|
||||
// Default lib search path: <selfdir>/../../lib
|
||||
let dotdotlib: []u8 = alloc([], PATH_MAX)!;
|
||||
dotdotlib.len = PATH_MAX: i32;
|
||||
let dotdotlib: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
dotdotlib.len = os.PATH_MAX;
|
||||
{
|
||||
let off: u64 = cstrinto(dotdotlib.ptr, 0u64, selfdir);
|
||||
off = strinto(dotdotlib.ptr, off, "/../../lib");
|
||||
@@ -3481,8 +3482,8 @@ fn buildone(selfdir: *u8, src: *u8, entryisdir: i32, out: *u8, incs: *u8, lf: *l
|
||||
// convention assumes you're running from the module dir; our
|
||||
// wrappers don't cd, so dirname(src) stands in as the closest
|
||||
// analog. Source-dir wins ties over the system path (cc -I.).
|
||||
let srcd: []u8 = alloc([], PATH_MAX)!;
|
||||
srcd.len = PATH_MAX: i32;
|
||||
let srcd: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
srcd.len = os.PATH_MAX;
|
||||
if (entryisdir != 0) {
|
||||
let slen: u64 = cstrlen(src);
|
||||
let k: u64 = 0u64;
|
||||
@@ -3516,8 +3517,8 @@ fn buildone(selfdir: *u8, src: *u8, entryisdir: i32, out: *u8, incs: *u8, lf: *l
|
||||
};
|
||||
|
||||
// Compose searchpath: srcd + ':' + incs + ':' + dotdotlib.
|
||||
let searchpath: []u8 = alloc([], PATH_MAX * 3u64)!;
|
||||
searchpath.len = (PATH_MAX * 3u64): i32;
|
||||
let searchpath: []u8 = alloc([], (os.PATH_MAX: u64) * 3u64)!;
|
||||
searchpath.len = ((os.PATH_MAX: u64) * 3u64): i32;
|
||||
{
|
||||
let off: u64 = cstrinto(searchpath.ptr, 0u64, srcd.ptr);
|
||||
off = byteinto(searchpath.ptr, off, 58u8); // ':'
|
||||
@@ -3531,8 +3532,8 @@ fn buildone(selfdir: *u8, src: *u8, entryisdir: i32, out: *u8, incs: *u8, lf: *l
|
||||
|
||||
// Stem for .s/.o/.combined.ww side files. Dir entry: <dir>/<base>;
|
||||
// file entry: src stripped of .ww.
|
||||
let stem: []u8 = alloc([], PATH_MAX)!;
|
||||
stem.len = PATH_MAX: i32;
|
||||
let stem: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
stem.len = os.PATH_MAX;
|
||||
if (entryisdir != 0) {
|
||||
let dlen: u64 = cstrlen(srcd.ptr);
|
||||
let bo: u64 = basenameoff(srcd.ptr, dlen);
|
||||
@@ -3549,8 +3550,8 @@ fn buildone(selfdir: *u8, src: *u8, entryisdir: i32, out: *u8, incs: *u8, lf: *l
|
||||
let combined: *u8 = appendlit(stem.ptr, ".combined.ww");
|
||||
|
||||
// libwwrt.a path: <selfdir>/../lib/libwwrt.a
|
||||
let libwwrt: []u8 = alloc([], PATH_MAX)!;
|
||||
libwwrt.len = PATH_MAX: i32;
|
||||
let libwwrt: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
libwwrt.len = os.PATH_MAX;
|
||||
{
|
||||
let off: u64 = cstrinto(libwwrt.ptr, 0u64, selfdir);
|
||||
off = strinto(libwwrt.ptr, off, "/../lib/libwwrt.a");
|
||||
@@ -3701,7 +3702,7 @@ fn arenadupcstr(src: *u8, plen: u64) *u8 = {
|
||||
// buildsearchpath — compose the colon-separated lookup path used by
|
||||
// resolvemodule's case (4). Order: "." : <incs> : <selfdir>/../../lib
|
||||
fn buildsearchpath(selfdir: *u8, incs: *u8) *u8 = {
|
||||
let buf: []u8 = alloc([], PATH_MAX * 2u64)!;
|
||||
let buf: []u8 = alloc([], (os.PATH_MAX: u64) * 2u64)!;
|
||||
let off: u64 = 0u64;
|
||||
buf[off] = 46u8; off += 1u64; // '.'
|
||||
if (incs != nil) {
|
||||
@@ -3776,8 +3777,8 @@ fn defaultoutpath(src: *u8) *u8 = {
|
||||
if (src[i] == 47u8) { start = i + 1u64; }; // '/'
|
||||
i += 1u64;
|
||||
};
|
||||
let out: []u8 = alloc([], PATH_MAX)!;
|
||||
out.len = PATH_MAX: i32;
|
||||
let out: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
out.len = os.PATH_MAX;
|
||||
let off: u64 = 0u64;
|
||||
let j: u64 = start;
|
||||
for (j < n) {
|
||||
@@ -3801,8 +3802,8 @@ fn defaultoutpath(src: *u8) *u8 = {
|
||||
|
||||
fn dobuild(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
|
||||
let src: *u8 = nil;
|
||||
let incs: []u8 = alloc([], PATH_MAX * 2u64)!;
|
||||
incs.len = (PATH_MAX * 2u64): i32;
|
||||
let incs: []u8 = alloc([], (os.PATH_MAX: u64) * 2u64)!;
|
||||
incs.len = ((os.PATH_MAX: u64) * 2u64): i32;
|
||||
let incoff: u64 = 0u64;
|
||||
cstrseal(incs.ptr, 0u64);
|
||||
|
||||
@@ -3901,8 +3902,8 @@ fn dobuild(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
|
||||
rlen -= 1u64;
|
||||
};
|
||||
let bo: u64 = basenameoff(resolved, rlen);
|
||||
let outbuf: []u8 = alloc([], PATH_MAX)!;
|
||||
outbuf.len = PATH_MAX: i32;
|
||||
let outbuf: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
outbuf.len = os.PATH_MAX;
|
||||
out = outbuf.ptr;
|
||||
let i: u64 = bo;
|
||||
let off: u64 = 0u64;
|
||||
@@ -3952,8 +3953,8 @@ fn makeruntmp(buf: *u8) void = {
|
||||
fn dorun(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
|
||||
let src: *u8 = nil;
|
||||
let passstart: i32 = -1; // first argv idx to pass through to program
|
||||
let incs: []u8 = alloc([], PATH_MAX * 2u64)!;
|
||||
incs.len = (PATH_MAX * 2u64): i32;
|
||||
let incs: []u8 = alloc([], (os.PATH_MAX: u64) * 2u64)!;
|
||||
incs.len = ((os.PATH_MAX: u64) * 2u64): i32;
|
||||
let incoff: u64 = 0u64;
|
||||
cstrseal(incs.ptr, 0u64);
|
||||
|
||||
@@ -4052,8 +4053,8 @@ fn dorun(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
|
||||
return 1;
|
||||
};
|
||||
|
||||
let tmp: []u8 = alloc([], PATH_MAX)!;
|
||||
tmp.len = PATH_MAX: i32;
|
||||
let tmp: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
tmp.len = os.PATH_MAX;
|
||||
makeruntmp(tmp.ptr);
|
||||
let lf: lflags;
|
||||
lf.libdirs = libdirs.ptr;
|
||||
@@ -4091,8 +4092,8 @@ fn dorun(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
|
||||
// report ok/FAIL per file, return 0 iff all pass.
|
||||
|
||||
fn runsingletest(selfdir: *u8, src: *u8) i32 = {
|
||||
let tmp: []u8 = alloc([], PATH_MAX)!;
|
||||
tmp.len = PATH_MAX: i32;
|
||||
let tmp: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
tmp.len = os.PATH_MAX;
|
||||
makeruntmp(tmp.ptr);
|
||||
if (buildone(selfdir, src, 0, tmp.ptr, "\0".ptr, nil) != 0) {
|
||||
os.remove(pathstr(tmp.ptr));
|
||||
@@ -4133,8 +4134,8 @@ fn rundirtests(selfdir: *u8, dir: *u8) i32 = {
|
||||
if (cstrendswithlit(name, "_test.ww")) {
|
||||
let nlen: u64 = cstrlen(name);
|
||||
// path = <dir>/<name>
|
||||
let path: []u8 = alloc([], PATH_MAX)!;
|
||||
path.len = PATH_MAX: i32;
|
||||
let path: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
path.len = os.PATH_MAX;
|
||||
let poff: u64 = cstrinto(path.ptr, 0u64, dir);
|
||||
path[poff] = 47u8; poff += 1u64;
|
||||
let i: u64 = 0u64;
|
||||
@@ -4142,12 +4143,12 @@ fn rundirtests(selfdir: *u8, dir: *u8) i32 = {
|
||||
poff += nlen;
|
||||
cstrseal(path.ptr, poff);
|
||||
// incs = <dir> so test files can `use ` siblings
|
||||
let tincs: []u8 = alloc([], PATH_MAX)!;
|
||||
tincs.len = PATH_MAX: i32;
|
||||
let tincs: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
tincs.len = os.PATH_MAX;
|
||||
let ic: u64 = cstrinto(tincs.ptr, 0u64, dir);
|
||||
cstrseal(tincs.ptr, ic);
|
||||
let tmp: []u8 = alloc([], PATH_MAX)!;
|
||||
tmp.len = PATH_MAX: i32;
|
||||
let tmp: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
tmp.len = os.PATH_MAX;
|
||||
makeruntmp(tmp.ptr);
|
||||
let bres: i32 = buildone(selfdir, path.ptr, 0, tmp.ptr, tincs.ptr, nil);
|
||||
if (bres != 0) {
|
||||
@@ -4213,9 +4214,9 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
};
|
||||
|
||||
// selfdir = dirname(argv[0])
|
||||
let selfdir: []u8 = alloc([], PATH_MAX)!;
|
||||
selfdir.len = PATH_MAX: i32;
|
||||
selfdirinto(selfdir.ptr, PATH_MAX, argv[0]);
|
||||
let selfdir: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
selfdir.len = os.PATH_MAX;
|
||||
selfdirinto(selfdir.ptr, (os.PATH_MAX: u64), argv[0]);
|
||||
|
||||
if (argc < 2) {
|
||||
writeusage(2);
|
||||
|
||||
@@ -18,8 +18,9 @@ import rt;
|
||||
import strings;
|
||||
|
||||
// All path/string scratch buffers go on the runtime page allocator.
|
||||
// One page is plenty for any path we build.
|
||||
def PATH_MAX: u64 = 4096u64;
|
||||
// One page is plenty for any path we build. PATH_MAX lives in lib/os
|
||||
// (os.PATH_MAX: i32 = 4096) — the duplicate u64 def was dropped to close
|
||||
// the cgen #127 mod-mangle attribution bug consumer per rule-7.
|
||||
def CMD_MAX: u64 = 8192u64;
|
||||
|
||||
// ---- C-string helpers --------------------------------------------------
|
||||
@@ -139,8 +140,8 @@ fn selfdirinto(dst: *u8, dstsz: u64, argv0: *u8) void = {
|
||||
|
||||
// Build "$dir/$name" (NUL-terminated) into a fresh page-sized buffer.
|
||||
fn joinpath(dir: *u8, name: *u8) *u8 = {
|
||||
let buf: []u8 = alloc([], PATH_MAX)!;
|
||||
buf.len = PATH_MAX: i32;
|
||||
let buf: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
buf.len = os.PATH_MAX;
|
||||
let off: u64 = cstrinto(buf.ptr, 0u64, dir);
|
||||
off = byteinto(buf.ptr, off, 47u8);
|
||||
off = cstrinto(buf.ptr, off, name);
|
||||
@@ -150,8 +151,8 @@ fn joinpath(dir: *u8, name: *u8) *u8 = {
|
||||
|
||||
// Same, but the second component is a ww `str` literal.
|
||||
fn joinpathlit(dir: *u8, name: str) *u8 = {
|
||||
let buf: []u8 = alloc([], PATH_MAX)!;
|
||||
buf.len = PATH_MAX: i32;
|
||||
let buf: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
buf.len = os.PATH_MAX;
|
||||
let off: u64 = cstrinto(buf.ptr, 0u64, dir);
|
||||
off = byteinto(buf.ptr, off, 47u8);
|
||||
off = strinto(buf.ptr, off, name);
|
||||
@@ -254,7 +255,7 @@ fn importpathform(name: *u8, namelen: u64) *u8 = {
|
||||
// `foo/foo.ha` fallback; a module IS the directory).
|
||||
fn locatein(dir: *u8, dirlen: u64,
|
||||
pathform: *u8, pflen: u64, isdir: *i32) *u8 = {
|
||||
let buf: []u8 = alloc([], PATH_MAX)!;
|
||||
let buf: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
let off: u64 = 0u64;
|
||||
let i: u64 = 0u64;
|
||||
for (i < dirlen) { buf[off + i] = dir[i]; i += 1u64; };
|
||||
@@ -279,7 +280,7 @@ fn locatein(dir: *u8, dirlen: u64,
|
||||
return buf.ptr;
|
||||
};
|
||||
|
||||
let buf2: []u8 = alloc([], PATH_MAX)!;
|
||||
let buf2: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
off = 0u64;
|
||||
i = 0u64;
|
||||
for (i < dirlen) { buf2[off + i] = dir[i]; i += 1u64; };
|
||||
@@ -724,8 +725,8 @@ fn makestem(stem: *u8, src: *u8) void = {
|
||||
|
||||
// Append a literal suffix to `stem` (which already lives in a buffer).
|
||||
fn appendlit(stem: *u8, suffix: str) *u8 = {
|
||||
let buf: []u8 = alloc([], PATH_MAX)!;
|
||||
buf.len = PATH_MAX: i32;
|
||||
let buf: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
buf.len = os.PATH_MAX;
|
||||
let off: u64 = cstrinto(buf.ptr, 0u64, stem);
|
||||
off = strinto(buf.ptr, off, suffix);
|
||||
cstrseal(buf.ptr, off);
|
||||
@@ -761,8 +762,8 @@ fn buildone(selfdir: *u8, src: *u8, entryisdir: i32, out: *u8, incs: *u8, lf: *l
|
||||
let l6: *u8 = joinpathlit(selfdir, "w6l_ww");
|
||||
|
||||
// Default lib search path: <selfdir>/../../lib
|
||||
let dotdotlib: []u8 = alloc([], PATH_MAX)!;
|
||||
dotdotlib.len = PATH_MAX: i32;
|
||||
let dotdotlib: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
dotdotlib.len = os.PATH_MAX;
|
||||
{
|
||||
let off: u64 = cstrinto(dotdotlib.ptr, 0u64, selfdir);
|
||||
off = strinto(dotdotlib.ptr, off, "/../../lib");
|
||||
@@ -775,8 +776,8 @@ fn buildone(selfdir: *u8, src: *u8, entryisdir: i32, out: *u8, incs: *u8, lf: *l
|
||||
// convention assumes you're running from the module dir; our
|
||||
// wrappers don't cd, so dirname(src) stands in as the closest
|
||||
// analog. Source-dir wins ties over the system path (cc -I.).
|
||||
let srcd: []u8 = alloc([], PATH_MAX)!;
|
||||
srcd.len = PATH_MAX: i32;
|
||||
let srcd: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
srcd.len = os.PATH_MAX;
|
||||
if (entryisdir != 0) {
|
||||
let slen: u64 = cstrlen(src);
|
||||
let k: u64 = 0u64;
|
||||
@@ -810,8 +811,8 @@ fn buildone(selfdir: *u8, src: *u8, entryisdir: i32, out: *u8, incs: *u8, lf: *l
|
||||
};
|
||||
|
||||
// Compose searchpath: srcd + ':' + incs + ':' + dotdotlib.
|
||||
let searchpath: []u8 = alloc([], PATH_MAX * 3u64)!;
|
||||
searchpath.len = (PATH_MAX * 3u64): i32;
|
||||
let searchpath: []u8 = alloc([], (os.PATH_MAX: u64) * 3u64)!;
|
||||
searchpath.len = ((os.PATH_MAX: u64) * 3u64): i32;
|
||||
{
|
||||
let off: u64 = cstrinto(searchpath.ptr, 0u64, srcd.ptr);
|
||||
off = byteinto(searchpath.ptr, off, 58u8); // ':'
|
||||
@@ -825,8 +826,8 @@ fn buildone(selfdir: *u8, src: *u8, entryisdir: i32, out: *u8, incs: *u8, lf: *l
|
||||
|
||||
// Stem for .s/.o/.combined.ww side files. Dir entry: <dir>/<base>;
|
||||
// file entry: src stripped of .ww.
|
||||
let stem: []u8 = alloc([], PATH_MAX)!;
|
||||
stem.len = PATH_MAX: i32;
|
||||
let stem: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
stem.len = os.PATH_MAX;
|
||||
if (entryisdir != 0) {
|
||||
let dlen: u64 = cstrlen(srcd.ptr);
|
||||
let bo: u64 = basenameoff(srcd.ptr, dlen);
|
||||
@@ -843,8 +844,8 @@ fn buildone(selfdir: *u8, src: *u8, entryisdir: i32, out: *u8, incs: *u8, lf: *l
|
||||
let combined: *u8 = appendlit(stem.ptr, ".combined.ww");
|
||||
|
||||
// libwwrt.a path: <selfdir>/../lib/libwwrt.a
|
||||
let libwwrt: []u8 = alloc([], PATH_MAX)!;
|
||||
libwwrt.len = PATH_MAX: i32;
|
||||
let libwwrt: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
libwwrt.len = os.PATH_MAX;
|
||||
{
|
||||
let off: u64 = cstrinto(libwwrt.ptr, 0u64, selfdir);
|
||||
off = strinto(libwwrt.ptr, off, "/../lib/libwwrt.a");
|
||||
@@ -995,7 +996,7 @@ fn arenadupcstr(src: *u8, plen: u64) *u8 = {
|
||||
// buildsearchpath — compose the colon-separated lookup path used by
|
||||
// resolvemodule's case (4). Order: "." : <incs> : <selfdir>/../../lib
|
||||
fn buildsearchpath(selfdir: *u8, incs: *u8) *u8 = {
|
||||
let buf: []u8 = alloc([], PATH_MAX * 2u64)!;
|
||||
let buf: []u8 = alloc([], (os.PATH_MAX: u64) * 2u64)!;
|
||||
let off: u64 = 0u64;
|
||||
buf[off] = 46u8; off += 1u64; // '.'
|
||||
if (incs != nil) {
|
||||
@@ -1070,8 +1071,8 @@ fn defaultoutpath(src: *u8) *u8 = {
|
||||
if (src[i] == 47u8) { start = i + 1u64; }; // '/'
|
||||
i += 1u64;
|
||||
};
|
||||
let out: []u8 = alloc([], PATH_MAX)!;
|
||||
out.len = PATH_MAX: i32;
|
||||
let out: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
out.len = os.PATH_MAX;
|
||||
let off: u64 = 0u64;
|
||||
let j: u64 = start;
|
||||
for (j < n) {
|
||||
@@ -1095,8 +1096,8 @@ fn defaultoutpath(src: *u8) *u8 = {
|
||||
|
||||
fn dobuild(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
|
||||
let src: *u8 = nil;
|
||||
let incs: []u8 = alloc([], PATH_MAX * 2u64)!;
|
||||
incs.len = (PATH_MAX * 2u64): i32;
|
||||
let incs: []u8 = alloc([], (os.PATH_MAX: u64) * 2u64)!;
|
||||
incs.len = ((os.PATH_MAX: u64) * 2u64): i32;
|
||||
let incoff: u64 = 0u64;
|
||||
cstrseal(incs.ptr, 0u64);
|
||||
|
||||
@@ -1195,8 +1196,8 @@ fn dobuild(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
|
||||
rlen -= 1u64;
|
||||
};
|
||||
let bo: u64 = basenameoff(resolved, rlen);
|
||||
let outbuf: []u8 = alloc([], PATH_MAX)!;
|
||||
outbuf.len = PATH_MAX: i32;
|
||||
let outbuf: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
outbuf.len = os.PATH_MAX;
|
||||
out = outbuf.ptr;
|
||||
let i: u64 = bo;
|
||||
let off: u64 = 0u64;
|
||||
@@ -1246,8 +1247,8 @@ fn makeruntmp(buf: *u8) void = {
|
||||
fn dorun(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
|
||||
let src: *u8 = nil;
|
||||
let passstart: i32 = -1; // first argv idx to pass through to program
|
||||
let incs: []u8 = alloc([], PATH_MAX * 2u64)!;
|
||||
incs.len = (PATH_MAX * 2u64): i32;
|
||||
let incs: []u8 = alloc([], (os.PATH_MAX: u64) * 2u64)!;
|
||||
incs.len = ((os.PATH_MAX: u64) * 2u64): i32;
|
||||
let incoff: u64 = 0u64;
|
||||
cstrseal(incs.ptr, 0u64);
|
||||
|
||||
@@ -1346,8 +1347,8 @@ fn dorun(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
|
||||
return 1;
|
||||
};
|
||||
|
||||
let tmp: []u8 = alloc([], PATH_MAX)!;
|
||||
tmp.len = PATH_MAX: i32;
|
||||
let tmp: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
tmp.len = os.PATH_MAX;
|
||||
makeruntmp(tmp.ptr);
|
||||
let lf: lflags;
|
||||
lf.libdirs = libdirs.ptr;
|
||||
@@ -1385,8 +1386,8 @@ fn dorun(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
|
||||
// report ok/FAIL per file, return 0 iff all pass.
|
||||
|
||||
fn runsingletest(selfdir: *u8, src: *u8) i32 = {
|
||||
let tmp: []u8 = alloc([], PATH_MAX)!;
|
||||
tmp.len = PATH_MAX: i32;
|
||||
let tmp: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
tmp.len = os.PATH_MAX;
|
||||
makeruntmp(tmp.ptr);
|
||||
if (buildone(selfdir, src, 0, tmp.ptr, "\0".ptr, nil) != 0) {
|
||||
os.remove(pathstr(tmp.ptr));
|
||||
@@ -1427,8 +1428,8 @@ fn rundirtests(selfdir: *u8, dir: *u8) i32 = {
|
||||
if (cstrendswithlit(name, "_test.ww")) {
|
||||
let nlen: u64 = cstrlen(name);
|
||||
// path = <dir>/<name>
|
||||
let path: []u8 = alloc([], PATH_MAX)!;
|
||||
path.len = PATH_MAX: i32;
|
||||
let path: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
path.len = os.PATH_MAX;
|
||||
let poff: u64 = cstrinto(path.ptr, 0u64, dir);
|
||||
path[poff] = 47u8; poff += 1u64;
|
||||
let i: u64 = 0u64;
|
||||
@@ -1436,12 +1437,12 @@ fn rundirtests(selfdir: *u8, dir: *u8) i32 = {
|
||||
poff += nlen;
|
||||
cstrseal(path.ptr, poff);
|
||||
// incs = <dir> so test files can `use ` siblings
|
||||
let tincs: []u8 = alloc([], PATH_MAX)!;
|
||||
tincs.len = PATH_MAX: i32;
|
||||
let tincs: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
tincs.len = os.PATH_MAX;
|
||||
let ic: u64 = cstrinto(tincs.ptr, 0u64, dir);
|
||||
cstrseal(tincs.ptr, ic);
|
||||
let tmp: []u8 = alloc([], PATH_MAX)!;
|
||||
tmp.len = PATH_MAX: i32;
|
||||
let tmp: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
tmp.len = os.PATH_MAX;
|
||||
makeruntmp(tmp.ptr);
|
||||
let bres: i32 = buildone(selfdir, path.ptr, 0, tmp.ptr, tincs.ptr, nil);
|
||||
if (bres != 0) {
|
||||
@@ -1507,9 +1508,9 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
};
|
||||
|
||||
// selfdir = dirname(argv[0])
|
||||
let selfdir: []u8 = alloc([], PATH_MAX)!;
|
||||
selfdir.len = PATH_MAX: i32;
|
||||
selfdirinto(selfdir.ptr, PATH_MAX, argv[0]);
|
||||
let selfdir: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||
selfdir.len = os.PATH_MAX;
|
||||
selfdirinto(selfdir.ptr, (os.PATH_MAX: u64), argv[0]);
|
||||
|
||||
if (argc < 2) {
|
||||
writeusage(2);
|
||||
|
||||
Reference in New Issue
Block a user