| 1 | // Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved. |
| 2 | // Use of this source code is governed by an MIT license |
| 3 | // that can be found in the LICENSE file. |
| 4 | module builtin |
| 5 | |
| 6 | @[markused] |
| 7 | fn builtin_init() { |
| 8 | $if gcboehm ? { |
| 9 | $if !gc_warn_on_stderr ? { |
| 10 | gc_set_warn_proc(internal_gc_warn_proc_none) |
| 11 | } |
| 12 | } |
| 13 | $if !vinix { |
| 14 | unbuffer_stdout() |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | fn break_if_debugger_attached() { |
| 19 | unsafe { |
| 20 | mut ptr := &voidptr(0) |
| 21 | *ptr = nil |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | @[noreturn] |
| 26 | pub fn panic_lasterr(base string) { |
| 27 | // TODO: use strerror_r and errno |
| 28 | panic(base + ' unknown') |
| 29 | } |
| 30 | |
| 31 | // write_buf_to_console is a Windows-only helper; on non-Windows platforms |
| 32 | // it is a no-op stub so that callers guarded by `$if windows { ... }` still |
| 33 | // type-check on other targets. |
| 34 | fn write_buf_to_console(fd int, buf &u8, buf_len int) bool { |
| 35 | return false |
| 36 | } |
| 37 | |
| 38 | // write_buf_to_fd_kernel32 is a Windows-only helper for the minimal V2 PE path. |
| 39 | // Keep a non-Windows stub so optional compile-time branches type-check while |
| 40 | // bootstrapping V on other hosts. |
| 41 | fn write_buf_to_fd_kernel32(fd int, buf &u8, buf_len int) bool { |
| 42 | return false |
| 43 | } |
| 44 | |
| 45 | fn write_buf_to_fd_kernel32_or_exit(fd int, buf &u8, buf_len int) {} |
| 46 | |
| 47 | fn write_buf_to_fd_windows_non_minimal(fd int, buf &u8, buf_len int) {} |
| 48 | |