Files
Brian Holman 5534005799 Sync VCC Plus 3.7.1 build 67 source
Refresh reviewed MCP output export, four-drive owned playtests, bounded BASIC readiness, and pinned CMOC 0.1.101 source/patches. Preserve independent source-edition identity, empty libraries, notices and privacy boundaries.

Validated 74 export/privacy checks, pinned dependency sources, and an independent unsigned universal Release build. A subsequent documentation-only correction removes an excluded qualification link; all build inputs remain identical.
2026-11-17 08:42:27 -07:00

64 lines
1.7 KiB
C

// SPDX-License-Identifier: GPL-3.0-or-later
#include <cmoc.h>
// The runtime must report the exact assembler label after each LBSR. Subtracting
// an assumed instruction width gives the pre-0.1.101 address and fails this test.
static void *expectedNullReturn;
static void *observedNullReturn;
static void *expectedStackReturn;
static void *expectedStackRegister;
static void nullHandler(void *addressPastFailedCheck)
{
observedNullReturn = addressPastFailedCheck;
}
asm void nullProbe(void)
{
asm {
import check_null_ptr_x
leax null_probe_after,pcr
stx :expectedNullReturn
ldx #0
lbsr check_null_ptr_x
null_probe_after:
}
}
static void stackHandler(void *addressPastFailedCheck, void *stackRegister)
{
printf("HANDLERS N%u S%u P%u END\n",
observedNullReturn == expectedNullReturn,
addressPastFailedCheck == expectedStackReturn,
stackRegister == expectedStackRegister);
exit(0); // The stack handler contract forbids returning.
}
asm void stackProbe(void)
{
asm {
import check_stack_overflow
import end_of_sbrk_mem
leax stack_probe_after,pcr
stx :expectedStackReturn
tfr s,d
std :expectedStackRegister
// Trigger the lower-bound check without corrupting or exhausting the
// actual stack. This is a disposable guest and no allocation follows.
ldd #$ffff
std end_of_sbrk_mem,pcr
lbsr check_stack_overflow
stack_probe_after:
}
}
int main(void)
{
set_null_ptr_handler(nullHandler);
nullProbe();
set_stack_overflow_handler(stackHandler);
stackProbe();
printf("FAIL STACK CHECK RETURNED\n");
return 1;
}