| 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 | |