| ... | ... | @@ -13,8 +13,8 @@ sender: MailboxId, |
| 13 | 13 | payload: ?[]const u8, |
| 14 | 14 | |
| 15 | 15 | pub fn from(mailbox_id: *const MailboxId) Message { |
| 16 | | return Message{ |
| 17 | | .sender = MailboxId.Undefined, |
| 16 | return Message { |
| 17 | .sender = MailboxId.Undefined, |
| 18 | 18 | .receiver = mailbox_id.*, |
| 19 | 19 | .code = undefined, |
| 20 | 20 | .args = undefined, |
| ... | ... | @@ -80,11 +80,15 @@ pub const STDOUT_FILENO = 1; |
| 80 | 80 | pub const STDERR_FILENO = 2; |
| 81 | 81 | |
| 82 | 82 | // FIXME: let's borrow Linux's error numbers for now. |
| 83 | | pub const getErrno = @import("linux/index.zig").getErrno; |
| 84 | 83 | use @import("linux/errno.zig"); |
| 84 | // Get the errno from a syscall return value, or 0 for no error. |
| 85 | pub fn getErrno(r: usize) usize { |
| 86 | const signed_r = @bitCast(isize, r); |
| 87 | return if (signed_r > -4096 and signed_r < 0) @intCast(usize, -signed_r) else 0; |
| 88 | } |
| 85 | 89 | |
| 86 | 90 | // TODO: implement this correctly. |
| 87 | | pub fn read(fd: i32, buf: *u8, count: usize) usize { |
| 91 | pub fn read(fd: i32, buf: [*]u8, count: usize) usize { |
| 88 | 92 | switch (fd) { |
| 89 | 93 | STDIN_FILENO => { |
| 90 | 94 | var i: usize = 0; |
| ... | ... | @@ -93,9 +97,9 @@ pub fn read(fd: i32, buf: *u8, count: usize) usize { |
| 93 | 97 | |
| 94 | 98 | // FIXME: we should be certain that we are receiving from Keyboard. |
| 95 | 99 | var message = Message.from(MailboxId.This); |
| 96 | | receive(message.*); |
| 100 | receive(&message); |
| 97 | 101 | |
| 98 | | buf[i] = u8(message.args[0]); |
| 102 | buf[i] = @intCast(u8, message.args[0]); |
| 99 | 103 | } |
| 100 | 104 | }, |
| 101 | 105 | else => unreachable, |
| ... | ... | @@ -104,7 +108,7 @@ pub fn read(fd: i32, buf: *u8, count: usize) usize { |
| 104 | 108 | } |
| 105 | 109 | |
| 106 | 110 | // TODO: implement this correctly. |
| 107 | | pub fn write(fd: i32, buf: *const u8, count: usize) usize { |
| 111 | pub fn write(fd: i32, buf: [*]const u8, count: usize) usize { |
| 108 | 112 | switch (fd) { |
| 109 | 113 | STDOUT_FILENO, STDERR_FILENO => { |
| 110 | 114 | send(Message.to(Server.Terminal, 1) |