16 lines
651 B
Nim
16 lines
651 B
Nim
|
|
# Forward declarations for C symbols
|
|
proc console_write(p: pointer, len: csize_t) {.importc, cdecl.}
|
|
proc ion_vfs_write(fd: int32, buf: pointer, count: uint64): int64 {.importc, cdecl.}
|
|
proc kprint(s: cstring) {.importc, cdecl.}
|
|
proc kprint_hex(n: uint64) {.importc, cdecl.}
|
|
proc kprintln(s: cstring) {.importc, cdecl.}
|
|
|
|
# Wrapper for VFS write to handle stdout/stderr
|
|
proc wrapper_vfs_write(fd: int32, buf: pointer, count: uint64): int64 {.cdecl.} =
|
|
# kprint("[WRAPPER] write fd="); kprint_hex(uint64(fd)); kprintln("")
|
|
if fd == 1 or fd == 2:
|
|
console_write(buf, csize_t(count))
|
|
return int64(count)
|
|
return ion_vfs_write(fd, buf, count)
|