v2 / vlib / builtin / builtin_nix.c.v
36 lines · 32 sloc · 820 bytes · 881f3b8c1b8e5fae14b2a94212d8be110cd7ca74
Raw
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.
4module builtin
5
6@[markused]
7fn 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
18fn break_if_debugger_attached() {
19 unsafe {
20 mut ptr := &voidptr(0)
21 *ptr = nil
22 }
23}
24
25@[noreturn]
26pub 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.
34fn write_buf_to_console(fd int, buf &u8, buf_len int) bool {
35 return false
36}
37