| ... | @@ -19,10 +19,10 @@ fn _errno(rc: usize) enum(c_ushort) { ok, _ } { | ... | @@ -19,10 +19,10 @@ fn _errno(rc: usize) enum(c_ushort) { ok, _ } { |
| 19 | // ssize_t read(int fd, void buf[.count], size_t count); | 19 | // ssize_t read(int fd, void buf[.count], size_t count); |
| 20 | // asmlinkage long sys_read(unsigned int fd, char __user *buf, size_t count); | 20 | // asmlinkage long sys_read(unsigned int fd, char __user *buf, size_t count); |
| 21 | pub fn read(fd: c_int, buf: []u8) errno.Error!usize { | 21 | pub fn read(fd: c_int, buf: []u8) errno.Error!usize { |
| 22 | const r = syscall3(.read, fd, buf.ptr, buf.len); | 22 | const r = syscall3(.read, @intCast(fd), @intFromPtr(buf.ptr), buf.len); |
| 23 | return switch (_errno(r)) { | 23 | return switch (_errno(r)) { |
| 24 | .ok => @intCast(r), | 24 | .ok => @intCast(r), |
| 25 | _ => |c| errno.errorFromInt(c), | 25 | _ => |c| errno.errorFromInt(@intFromEnum(c)), |
| 26 | }; | 26 | }; |
| 27 | } | 27 | } |
| 28 | | 28 | |
| ... | @@ -30,10 +30,10 @@ pub fn read(fd: c_int, buf: []u8) errno.Error!usize { | ... | @@ -30,10 +30,10 @@ pub fn read(fd: c_int, buf: []u8) errno.Error!usize { |
| 30 | // ssize_t write(int fd, const void buf[.count], size_t count); | 30 | // ssize_t write(int fd, const void buf[.count], size_t count); |
| 31 | // asmlinkage long sys_write(unsigned int fd, const char __user *buf, size_t count); | 31 | // asmlinkage long sys_write(unsigned int fd, const char __user *buf, size_t count); |
| 32 | pub fn write(fd: c_int, buf: []const u8) errno.Error!usize { | 32 | pub fn write(fd: c_int, buf: []const u8) errno.Error!usize { |
| 33 | const r = syscall3(.write, fd, buf.ptr, buf.len); | 33 | const r = syscall3(.write, @intCast(fd), @intFromPtr(buf.ptr), buf.len); |
| 34 | return switch (_errno(r)) { | 34 | return switch (_errno(r)) { |
| 35 | .ok => @intCast(r), | 35 | .ok => @intCast(r), |
| 36 | _ => |c| errno.errorFromInt(c), | 36 | _ => |c| errno.errorFromInt(@intFromEnum(c)), |
| 37 | }; | 37 | }; |
| 38 | } | 38 | } |
| 39 | | 39 | |