Publish VCC Plus OSS source distribution for 3.6.2 build 60

This commit is contained in:
Brian Holman committed 2026-11-13 00:14:03 -07:00
commit c652a5276d
1192 files changed
+272368

No files matched your search

@@ -0,0 +1,44 @@
# SPDX-License-Identifier: GPL-3.0-or-later
"""Check signed and unsigned base conversion under both guest CPUs and CMOC optimizations."""
import argparse
import os
from pathlib import Path
import subprocess
import tempfile
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("runtime", type=Path, help="staged toolchain with base-aware vcccompat")
parser.add_argument("core", type=Path, help="current libVCCCore.a")
parser.add_argument("rom", type=Path, help="private CoCo 3 ROM")
args = parser.parse_args()
runtime, core, rom = [p.resolve(strict=True) for p in (args.runtime, args.core, args.rom)]
fixture = Path(__file__).resolve().parent
root = fixture.parents[2]
env = dict(os.environ, VCC_CMOC_COMPAT="1")
with tempfile.TemporaryDirectory(prefix="vcc-number-conversion-") as work:
runner = Path(work) / "run-compiled"
subprocess.run(["xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
fixture.parent / "run-compiled.cpp", core, "-o", runner], cwd=work, check=True)
compiler = [runtime / "bin/cmoc", "--coco", "-Werror"]
for opt in ("-O0", "-O2"):
caller = [*compiler, opt, "--org=2800", "-o", "TEST.BIN"]
if opt == "-O2":
caller.append("-DCMOC_HEADER_FIRST")
caller.append(fixture / "qualification.c")
# The installed library is optimized. Check it with both app
# settings, then exercise the conversion code itself unoptimized.
subprocess.run([*caller, "-lvcccompat"], cwd=work, env=env, check=True)
print(f"{opt} caller, staged archive", flush=True)
subprocess.run([runner, rom, "TEST.BIN", "NUMBER CONVERSIONS PASSED", "450"], cwd=work, check=True)
if opt == "-O0":
subprocess.run([*compiler, opt, "-c", "-o", "strto.o", root / "sdk/cmoc/compat/strto.c"],
cwd=work, env=env, check=True)
subprocess.run([*caller, "strto.o"], cwd=work, env=env, check=True)
print("-O0 caller and conversion implementation", flush=True)
subprocess.run([runner, rom, "TEST.BIN", "NUMBER CONVERSIONS PASSED", "450"], cwd=work, check=True)
if __name__ == "__main__":
main()
@@ -0,0 +1,113 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#ifdef CMOC_HEADER_FIRST
#include <cmoc.h>
#include <stdlib.h>
#else
#include <stdlib.h>
#include <cmoc.h>
#endif
#include <errno.h>
#include <limits.h>
// The upstream cmoc.h has decimal-only macros. Both include orders must
// expose the base-aware calls and their addresses when compatibility is on.
static long (*signedParser)(const char *, char **, int) = strtol;
static unsigned long (*unsignedParser)(const char *, char **, int) = strtoul;
#define UNCHANGED 73
struct Conversion {
const char *text;
int base;
unsigned consumed;
long signedValue;
unsigned long unsignedValue;
int signedError;
int unsignedError;
};
static const struct Conversion cases[] = {
{ "", 10, 0, 0, 0, UNCHANGED, UNCHANGED },
{ " ", 0, 0, 0, 0, UNCHANGED, UNCHANGED },
{ " +!", 10, 0, 0, 0, UNCHANGED, UNCHANGED },
{ "-", 10, 0, 0, 0, UNCHANGED, UNCHANGED },
{ "MARS", 10, 0, 0, 0, UNCHANGED, UNCHANGED },
{ "0", 0, 1, 0, 0, UNCHANGED, UNCHANGED },
{ " -0", 0, 4, 0, 0, UNCHANGED, UNCHANGED },
{ "+0779", 0, 4, 63, 63, UNCHANGED, UNCHANGED },
{ "09", 10, 2, 9, 9, UNCHANGED, UNCHANGED },
{ "0x", 0, 1, 0, 0, UNCHANGED, UNCHANGED },
{ "0XG", 16, 1, 0, 0, UNCHANGED, UNCHANGED },
{ "0x12", 10, 1, 0, 0, UNCHANGED, UNCHANGED },
{ "0b11", 0, 1, 0, 0, UNCHANGED, UNCHANGED },
{ "0X010f!", 0, 6, 271, 271, UNCHANGED, UNCHANGED },
{ "2X", 0, 1, 2, 2, UNCHANGED, UNCHANGED },
{ "\t\n\v\f\r +1012", 2, 10, 5, 5, UNCHANGED, UNCHANGED },
{ " -aB", 16, 4, -171, 4294967125UL, UNCHANGED, UNCHANGED },
{ "zZ.", 36, 2, 1295, 1295, UNCHANGED, UNCHANGED },
{ "2147483647", 10, 10, LONG_MAX, 2147483647UL, UNCHANGED, UNCHANGED },
{ "2147483648", 10, 10, LONG_MAX, 2147483648UL, ERANGE, UNCHANGED },
{ "-2147483648", 10, 11, -2147483648L, 2147483648UL, UNCHANGED, UNCHANGED },
{ "-2147483649", 10, 11, -2147483648L, 2147483647UL, ERANGE, UNCHANGED },
{ "4294967295!", 10, 10, LONG_MAX, ULONG_MAX, ERANGE, UNCHANGED },
{ "4294967296", 10, 10, LONG_MAX, ULONG_MAX, ERANGE, ERANGE },
{ "-4294967295", 10, 11, -2147483648L, 1, ERANGE, UNCHANGED },
{ "-4294967296", 10, 11, -2147483648L, ULONG_MAX, ERANGE, ERANGE },
{ "0xffffffff!", 0, 10, LONG_MAX, ULONG_MAX, ERANGE, UNCHANGED },
{ "-0x80000000", 0, 11, -2147483648L, 2147483648UL, UNCHANGED, UNCHANGED },
{ "100000000000000000000000000000!", 16, 30, LONG_MAX, ULONG_MAX, ERANGE, ERANGE },
{ "37777777777!", 8, 11, LONG_MAX, ULONG_MAX, ERANGE, UNCHANGED },
{ "40000000000!", 8, 11, LONG_MAX, ULONG_MAX, ERANGE, ERANGE },
{ " +42", -2, 0, 0, 0, EINVAL, EINVAL },
{ " +42", 1, 0, 0, 0, EINVAL, EINVAL },
{ " +42", 37, 0, 0, 0, EINVAL, EINVAL }
};
static int check(void)
{
unsigned i;
for (i = 0; i < sizeof(cases) / sizeof(cases[0]); ++i) {
const struct Conversion *c = &cases[i];
char *end = NULL;
errno = UNCHANGED;
long s = signedParser(c->text, &end, c->base);
if (s != c->signedValue || errno != c->signedError || end != c->text + c->consumed) {
printf("SIGNED CASE %u\n", i);
return __LINE__;
}
end = NULL;
errno = UNCHANGED;
unsigned long u = unsignedParser(c->text, &end, c->base);
if (u != c->unsignedValue || errno != c->unsignedError || end != c->text + c->consumed) {
printf("UNSIGNED CASE %u\n", i);
return __LINE__;
}
}
// One more than the highest digit is a terminator in each radix.
const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz!";
for (i = 2; i <= 36; ++i) {
char text[4], *end;
text[0] = '1';
text[1] = digits[i - 1];
text[2] = digits[i];
text[3] = 0;
if (strtol(text, &end, i) != (long)(2 * i - 1) || end != text + 2)
return __LINE__;
if (strtoul(text, &end, i) != (unsigned long)(2 * i - 1) || end != text + 2)
return __LINE__;
}
if (strtoul("ff", NULL, 16) != 255 || strtol("-10", NULL, 2) != -2)
return __LINE__;
char highByte[] = { (char) 0xff, '3', 0 };
char *end;
if (strtol(highByte, &end, 10) != 0 || end != highByte)
return __LINE__;
return 0;
}
int main(void)
{
int line = check();
if (line) printf("FAIL LINE %d\n", line);
else printf("NUMBER CONVERSIONS PASSED\n");
return line != 0;
}