const std = @import("std"); const syscall = @import("syscall.zig"); pub const BUFFER_SIZE: usize = 512; pub const Writer = struct { buffer: [BUFFER_SIZE]u8 = undefined, position: usize = 0, fn write(self: *Writer, bytes: []const u8) error{}!usize { const amount = @min(BUFFER_SIZE - self.position, bytes.len); if (amount != 0) { @memcpy(self.buffer[self.position .. self.position + amount], bytes[0..amount]); self.position += amount; } return amount; } }; pub fn println(comptime format: []const u8, args: anytype) void { const W = std.io.GenericWriter(*Writer, error{}, Writer.write); var context = Writer{}; var w = W{ .context = &context }; w.print(format, args) catch return; if (context.position != 0) { syscall.debug_write(context.buffer[0..context.position]); } }