v / vlib / builtin / builtin_nix.c.v
47 lines · 40 sloc · 1.21 KB · 81a5657604ec6da99c25e26546870c6888d6fdde
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
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.
41fn write_buf_to_fd_kernel32(fd int, buf &u8, buf_len int) bool {
42 return false
43}
44
45fn write_buf_to_fd_kernel32_or_exit(fd int, buf &u8, buf_len int) {}
46
47fn write_buf_to_fd_windows_non_minimal(fd int, buf &u8, buf_len int) {}
48