| ... | ... | @@ -141,7 +141,7 @@ pub fn io(el: *EventLoop) Io { |
| 141 | 141 | .@"async" = @"async", |
| 142 | 142 | .@"await" = @"await", |
| 143 | 143 | .go = go, |
| 144 | | |
| 144 | .select = select, |
| 145 | 145 | .cancel = cancel, |
| 146 | 146 | .cancelRequested = cancelRequested, |
| 147 | 147 | |
| ... | ... | @@ -728,6 +728,13 @@ fn @"async"( |
| 728 | 728 | return @ptrCast(fiber); |
| 729 | 729 | } |
| 730 | 730 | |
| 731 | fn select(userdata: ?*anyopaque, futures: []const *Io.AnyFuture) usize { |
| 732 | const el: *EventLoop = @alignCast(@ptrCast(userdata)); |
| 733 | _ = el; |
| 734 | _ = futures; |
| 735 | @panic("TODO"); |
| 736 | } |
| 737 | |
| 731 | 738 | const DetachedClosure = struct { |
| 732 | 739 | event_loop: *EventLoop, |
| 733 | 740 | fiber: *Fiber, |
| ... | ... | @@ -870,10 +877,10 @@ fn cancelRequested(userdata: ?*anyopaque) bool { |
| 870 | 877 | |
| 871 | 878 | fn createFile( |
| 872 | 879 | userdata: ?*anyopaque, |
| 873 | | dir: std.fs.Dir, |
| 880 | dir: Io.Dir, |
| 874 | 881 | sub_path: []const u8, |
| 875 | | flags: Io.CreateFlags, |
| 876 | | ) Io.FileOpenError!std.fs.File { |
| 882 | flags: Io.File.CreateFlags, |
| 883 | ) Io.File.OpenError!Io.File { |
| 877 | 884 | const el: *EventLoop = @alignCast(@ptrCast(userdata)); |
| 878 | 885 | const thread: *Thread = .current(); |
| 879 | 886 | const iou = &thread.io_uring; |
| ... | ... | @@ -921,7 +928,7 @@ fn createFile( |
| 921 | 928 | .opcode = .OPENAT, |
| 922 | 929 | .flags = 0, |
| 923 | 930 | .ioprio = 0, |
| 924 | | .fd = dir.fd, |
| 931 | .fd = dir.handle, |
| 925 | 932 | .off = 0, |
| 926 | 933 | .addr = @intFromPtr(&sub_path_c), |
| 927 | 934 | .len = @intCast(flags.mode), |
| ... | ... | @@ -972,10 +979,10 @@ fn createFile( |
| 972 | 979 | |
| 973 | 980 | fn openFile( |
| 974 | 981 | userdata: ?*anyopaque, |
| 975 | | dir: std.fs.Dir, |
| 982 | dir: Io.Dir, |
| 976 | 983 | sub_path: []const u8, |
| 977 | | flags: Io.OpenFlags, |
| 978 | | ) Io.FileOpenError!std.fs.File { |
| 984 | flags: Io.File.OpenFlags, |
| 985 | ) Io.File.OpenError!Io.File { |
| 979 | 986 | const el: *EventLoop = @alignCast(@ptrCast(userdata)); |
| 980 | 987 | const thread: *Thread = .current(); |
| 981 | 988 | const iou = &thread.io_uring; |
| ... | ... | @@ -1029,7 +1036,7 @@ fn openFile( |
| 1029 | 1036 | .opcode = .OPENAT, |
| 1030 | 1037 | .flags = 0, |
| 1031 | 1038 | .ioprio = 0, |
| 1032 | | .fd = dir.fd, |
| 1039 | .fd = dir.handle, |
| 1033 | 1040 | .off = 0, |
| 1034 | 1041 | .addr = @intFromPtr(&sub_path_c), |
| 1035 | 1042 | .len = 0, |
| ... | ... | @@ -1078,7 +1085,7 @@ fn openFile( |
| 1078 | 1085 | } |
| 1079 | 1086 | } |
| 1080 | 1087 | |
| 1081 | | fn closeFile(userdata: ?*anyopaque, file: std.fs.File) void { |
| 1088 | fn closeFile(userdata: ?*anyopaque, file: Io.File) void { |
| 1082 | 1089 | const el: *EventLoop = @alignCast(@ptrCast(userdata)); |
| 1083 | 1090 | const thread: *Thread = .current(); |
| 1084 | 1091 | const iou = &thread.io_uring; |
| ... | ... | @@ -1114,7 +1121,7 @@ fn closeFile(userdata: ?*anyopaque, file: std.fs.File) void { |
| 1114 | 1121 | } |
| 1115 | 1122 | } |
| 1116 | 1123 | |
| 1117 | | fn pread(userdata: ?*anyopaque, file: std.fs.File, buffer: []u8, offset: std.posix.off_t) Io.FilePReadError!usize { |
| 1124 | fn pread(userdata: ?*anyopaque, file: Io.File, buffer: []u8, offset: std.posix.off_t) Io.File.PReadError!usize { |
| 1118 | 1125 | const el: *EventLoop = @alignCast(@ptrCast(userdata)); |
| 1119 | 1126 | const thread: *Thread = .current(); |
| 1120 | 1127 | const iou = &thread.io_uring; |
| ... | ... | @@ -1166,7 +1173,7 @@ fn pread(userdata: ?*anyopaque, file: std.fs.File, buffer: []u8, offset: std.pos |
| 1166 | 1173 | } |
| 1167 | 1174 | } |
| 1168 | 1175 | |
| 1169 | | fn pwrite(userdata: ?*anyopaque, file: std.fs.File, buffer: []const u8, offset: std.posix.off_t) Io.FilePWriteError!usize { |
| 1176 | fn pwrite(userdata: ?*anyopaque, file: Io.File, buffer: []const u8, offset: std.posix.off_t) Io.File.PWriteError!usize { |
| 1170 | 1177 | const el: *EventLoop = @alignCast(@ptrCast(userdata)); |
| 1171 | 1178 | const thread: *Thread = .current(); |
| 1172 | 1179 | const iou = &thread.io_uring; |
| ... | ... | @@ -1236,7 +1243,7 @@ fn sleep(userdata: ?*anyopaque, clockid: std.posix.clockid_t, deadline: Io.Deadl |
| 1236 | 1243 | try fiber.enterCancelRegion(thread); |
| 1237 | 1244 | |
| 1238 | 1245 | const deadline_nanoseconds: i96 = switch (deadline) { |
| 1239 | | .nanoseconds => |nanoseconds| nanoseconds, |
| 1246 | .duration => |duration| duration.nanoseconds, |
| 1240 | 1247 | .timestamp => |timestamp| @intFromEnum(timestamp), |
| 1241 | 1248 | }; |
| 1242 | 1249 | const timespec: std.os.linux.kernel_timespec = .{ |
| ... | ... | @@ -1252,7 +1259,7 @@ fn sleep(userdata: ?*anyopaque, clockid: std.posix.clockid_t, deadline: Io.Deadl |
| 1252 | 1259 | .addr = @intFromPtr(&timespec), |
| 1253 | 1260 | .len = 1, |
| 1254 | 1261 | .rw_flags = @as(u32, switch (deadline) { |
| 1255 | | .nanoseconds => 0, |
| 1262 | .duration => 0, |
| 1256 | 1263 | .timestamp => std.os.linux.IORING_TIMEOUT_ABS, |
| 1257 | 1264 | }) | @as(u32, switch (clockid) { |
| 1258 | 1265 | .REALTIME => std.os.linux.IORING_TIMEOUT_REALTIME, |