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