import "@ffi/c" import "@std/io" assert proc(ok bool) void { if (!ok) unreachable } print proc($format []u8, $Args type, args Args) void { writer :: io.Writer{ context = null, handle = io.Handle{ file_desc = c_int(io.Stream.stderr) }, write = write, } io.print(writer, format, Args, args) catch |_| {} } hide write proc(_ ?@mut anyopaque, handle io.Handle, bytes []u8) usize ! io.WriteError { request := bytes.len maximum :: usize(maxval!(c_long)) if request > maximum { request = maximum } while true { count :: c.write(handle.file_desc, bytes.ptr, c_ulong(request)) if count >= 0 { return usize(count) } if c.__error()?^ != c.EINTR { return .write_failed } } }