module scheme $if !freestanding || (macos && arm64) { #include "@VMODROOT/scheme/system.h" fn C.vile_system_tai_seconds(result &f64) bool fn C.vile_system_terminate(status i64, emergency bool) } $if freestanding && macos && amd64 { @[noreturn] fn C._Exit(i32) } fn system_tai_seconds() ?f64 { $if freestanding { seconds, nanoseconds, code := bf_tai_now() if code != 0 { return none } return f64(seconds) + f64(nanoseconds) / 1_000_000_000.0 } $else { mut seconds := 0.0 if C.vile_system_tai_seconds(&seconds) { return seconds } return none } } fn system_terminate(status i64, emergency bool) { $if freestanding && (!macos || amd64) { // Scheme cleanup is performed before the host hook. The AMD64 Mac // runtime also distinguishes native finalizers from emergency termination. $if macos && amd64 { if emergency { C._Exit(i32(u64(status) & 255)) } } exit(int(u64(status) & 255)) } $else { C.vile_system_terminate(status, emergency) } }