mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-15 06:43:42 +00:00
Update _stderr_write for orca
This commit is contained in:
@@ -2,13 +2,26 @@
|
||||
//+private
|
||||
package runtime
|
||||
|
||||
// TODO
|
||||
// foreign import
|
||||
// fd_write :: proc "contextless" ()
|
||||
import "core:sys/wasm/wasi"
|
||||
@(private="file")
|
||||
log_level :: enum i32 {
|
||||
ERROR,
|
||||
WARNING,
|
||||
INFO,
|
||||
}
|
||||
|
||||
@(private="file", default_calling_convention="c")
|
||||
foreign {
|
||||
oc_log_ext :: proc(
|
||||
level: log_level,
|
||||
function: cstring,
|
||||
file: cstring,
|
||||
line: i32,
|
||||
fmt: cstring,
|
||||
#c_vararg args: ..any,
|
||||
) ---
|
||||
}
|
||||
|
||||
_stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
|
||||
data := (wasi.ciovec_t)(data)
|
||||
n, err := wasi.fd_write(1, {data})
|
||||
return int(n), _OS_Errno(err)
|
||||
oc_log_ext(.ERROR, "", "", 0, "%.*s", i32(len(data)), raw_data(data))
|
||||
return len(data), 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user