| ... | ... | @@ -604,6 +604,11 @@ pub const CLONE_NEWPID = 0x20000000; |
| 604 | 604 | pub const CLONE_NEWNET = 0x40000000; |
| 605 | 605 | pub const CLONE_IO = 0x80000000; |
| 606 | 606 | |
| 607 | // Flags for the clone3() syscall. |
| 608 | |
| 609 | /// Clear any signal handler and reset to SIG_DFL. |
| 610 | pub const CLONE_CLEAR_SIGHAND = 0x100000000; |
| 611 | |
| 607 | 612 | pub const EFD_SEMAPHORE = 1; |
| 608 | 613 | pub const EFD_CLOEXEC = O_CLOEXEC; |
| 609 | 614 | pub const EFD_NONBLOCK = O_NONBLOCK; |
| ... | ... | @@ -1120,17 +1125,22 @@ pub const io_uring_params = extern struct { |
| 1120 | 1125 | // io_uring_params.features flags |
| 1121 | 1126 | |
| 1122 | 1127 | pub const IORING_FEAT_SINGLE_MMAP = 1 << 0; |
| 1128 | pub const IORING_FEAT_NODROP = 1 << 1; |
| 1129 | pub const IORING_FEAT_SUBMIT_STABLE = 1 << 2; |
| 1123 | 1130 | |
| 1124 | 1131 | // io_uring_params.flags |
| 1125 | 1132 | |
| 1126 | 1133 | /// io_context is polled |
| 1127 | | pub const IORING_SETUP_IOPOLL = (1 << 0); |
| 1134 | pub const IORING_SETUP_IOPOLL = 1 << 0; |
| 1128 | 1135 | |
| 1129 | 1136 | /// SQ poll thread |
| 1130 | | pub const IORING_SETUP_SQPOLL = (1 << 1); |
| 1137 | pub const IORING_SETUP_SQPOLL = 1 << 1; |
| 1131 | 1138 | |
| 1132 | 1139 | /// sq_thread_cpu is valid |
| 1133 | | pub const IORING_SETUP_SQ_AFF = (1 << 2); |
| 1140 | pub const IORING_SETUP_SQ_AFF = 1 << 2; |
| 1141 | |
| 1142 | /// app defines CQ size |
| 1143 | pub const IORING_SETUP_CQSIZE = 1 << 3; |
| 1134 | 1144 | |
| 1135 | 1145 | pub const io_sqring_offsets = extern struct { |
| 1136 | 1146 | /// offset of ring head |
| ... | ... | @@ -1178,52 +1188,73 @@ pub const io_uring_sqe = extern struct { |
| 1178 | 1188 | flags: u8, |
| 1179 | 1189 | ioprio: u16, |
| 1180 | 1190 | fd: i32, |
| 1181 | | off: u64, |
| 1191 | pub const union1 = extern union { |
| 1192 | off: u64, |
| 1193 | addr2: u64, |
| 1194 | }; |
| 1195 | union1: union1, |
| 1182 | 1196 | addr: u64, |
| 1183 | 1197 | len: u32, |
| 1184 | | pub const union1 = extern union { |
| 1198 | pub const union2 = extern union { |
| 1185 | 1199 | rw_flags: kernel_rwf, |
| 1186 | 1200 | fsync_flags: u32, |
| 1187 | 1201 | poll_events: u16, |
| 1188 | 1202 | sync_range_flags: u32, |
| 1189 | 1203 | msg_flags: u32, |
| 1190 | 1204 | timeout_flags: u32, |
| 1205 | accept_flags: u32, |
| 1206 | cancel_flags: u32, |
| 1191 | 1207 | }; |
| 1192 | | union1: union1, |
| 1208 | union2: union2, |
| 1193 | 1209 | user_data: u64, |
| 1194 | | pub const union2 = extern union { |
| 1210 | pub const union3 = extern union { |
| 1195 | 1211 | buf_index: u16, |
| 1196 | 1212 | __pad2: [3]u64, |
| 1197 | 1213 | }; |
| 1198 | | union2: union2, |
| 1214 | union3: union3, |
| 1199 | 1215 | }; |
| 1200 | 1216 | |
| 1201 | 1217 | // io_uring_sqe.flags |
| 1202 | 1218 | |
| 1203 | 1219 | /// use fixed fileset |
| 1204 | | pub const IOSQE_FIXED_FILE = (1 << 0); |
| 1220 | pub const IOSQE_FIXED_FILE = 1 << 0; |
| 1205 | 1221 | |
| 1206 | 1222 | /// issue after inflight IO |
| 1207 | | pub const IOSQE_IO_DRAIN = (1 << 1); |
| 1223 | pub const IOSQE_IO_DRAIN = 1 << 1; |
| 1208 | 1224 | |
| 1209 | 1225 | /// links next sqe |
| 1210 | | pub const IOSQE_IO_LINK = (1 << 2); |
| 1211 | | |
| 1212 | | pub const IORING_OP_NOP = 0; |
| 1213 | | pub const IORING_OP_READV = 1; |
| 1214 | | pub const IORING_OP_WRITEV = 2; |
| 1215 | | pub const IORING_OP_FSYNC = 3; |
| 1216 | | pub const IORING_OP_READ_FIXED = 4; |
| 1217 | | pub const IORING_OP_WRITE_FIXED = 5; |
| 1218 | | pub const IORING_OP_POLL_ADD = 6; |
| 1219 | | pub const IORING_OP_POLL_REMOVE = 7; |
| 1220 | | pub const IORING_OP_SYNC_FILE_RANGE = 8; |
| 1221 | | pub const IORING_OP_SENDMSG = 9; |
| 1222 | | pub const IORING_OP_RECVMSG = 10; |
| 1223 | | pub const IORING_OP_TIMEOUT = 11; |
| 1226 | pub const IOSQE_IO_LINK = 1 << 2; |
| 1227 | |
| 1228 | /// like LINK, but stronger |
| 1229 | pub const IOSQE_IO_HARDLINK = 1 << 3; |
| 1230 | |
| 1231 | pub const IORING_OP = extern enum { |
| 1232 | NOP, |
| 1233 | READV, |
| 1234 | WRITEV, |
| 1235 | FSYNC, |
| 1236 | READ_FIXED, |
| 1237 | WRITE_FIXED, |
| 1238 | POLL_ADD, |
| 1239 | POLL_REMOVE, |
| 1240 | SYNC_FILE_RANGE, |
| 1241 | SENDMSG, |
| 1242 | RECVMSG, |
| 1243 | TIMEOUT, |
| 1244 | TIMEOUT_REMOVE, |
| 1245 | ACCEPT, |
| 1246 | ASYNC_CANCEL, |
| 1247 | LINK_TIMEOUT, |
| 1248 | CONNECT, |
| 1249 | |
| 1250 | _, |
| 1251 | }; |
| 1224 | 1252 | |
| 1225 | 1253 | // io_uring_sqe.fsync_flags |
| 1226 | | pub const IORING_FSYNC_DATASYNC = (1 << 0); |
| 1254 | pub const IORING_FSYNC_DATASYNC = 1 << 0; |
| 1255 | |
| 1256 | // io_uring_sqe.timeout_flags |
| 1257 | pub const IORING_TIMEOUT_ABS = 1 << 0; |
| 1227 | 1258 | |
| 1228 | 1259 | // IO completion data structure (Completion Queue Entry) |
| 1229 | 1260 | pub const io_uring_cqe = extern struct { |
| ... | ... | @@ -1240,8 +1271,8 @@ pub const IORING_OFF_CQ_RING = 0x8000000; |
| 1240 | 1271 | pub const IORING_OFF_SQES = 0x10000000; |
| 1241 | 1272 | |
| 1242 | 1273 | // io_uring_enter flags |
| 1243 | | pub const IORING_ENTER_GETEVENTS = (1 << 0); |
| 1244 | | pub const IORING_ENTER_SQ_WAKEUP = (1 << 1); |
| 1274 | pub const IORING_ENTER_GETEVENTS = 1 << 0; |
| 1275 | pub const IORING_ENTER_SQ_WAKEUP = 1 << 1; |
| 1245 | 1276 | |
| 1246 | 1277 | // io_uring_register opcodes and arguments |
| 1247 | 1278 | pub const IORING_REGISTER_BUFFERS = 0; |
| ... | ... | @@ -1250,6 +1281,13 @@ pub const IORING_REGISTER_FILES = 2; |
| 1250 | 1281 | pub const IORING_UNREGISTER_FILES = 3; |
| 1251 | 1282 | pub const IORING_REGISTER_EVENTFD = 4; |
| 1252 | 1283 | pub const IORING_UNREGISTER_EVENTFD = 5; |
| 1284 | pub const IORING_REGISTER_FILES_UPDATE = 6; |
| 1285 | |
| 1286 | pub const io_uring_files_update = struct { |
| 1287 | offset: u32, |
| 1288 | resv: u32, |
| 1289 | fds: u64, |
| 1290 | }; |
| 1253 | 1291 | |
| 1254 | 1292 | pub const utsname = extern struct { |
| 1255 | 1293 | sysname: [65]u8, |