| ... | @@ -88,11 +88,29 @@ pub const FUTEX_PRIVATE_FLAG = 128; | ... | @@ -88,11 +88,29 @@ pub const FUTEX_PRIVATE_FLAG = 128; |
| 88 | | 88 | |
| 89 | pub const FUTEX_CLOCK_REALTIME = 256; | 89 | pub const FUTEX_CLOCK_REALTIME = 256; |
| 90 | | 90 | |
| 91 | pub const PROT_NONE = 0; | 91 | /// page can not be accessed |
| 92 | pub const PROT_READ = 1; | 92 | pub const PROT_NONE = 0x0; |
| 93 | pub const PROT_WRITE = 2; | 93 | |
| 94 | pub const PROT_EXEC = 4; | 94 | /// page can be read |
| | 95 | pub const PROT_READ = 0x1; |
| | 96 | |
| | 97 | /// page can be written |
| | 98 | pub const PROT_WRITE = 0x2; |
| | 99 | |
| | 100 | /// page can be executed |
| | 101 | pub const PROT_EXEC = 0x4; |
| | 102 | |
| | 103 | /// page may be used for atomic ops |
| | 104 | pub const PROT_SEM = switch (builtin.arch) { |
| | 105 | // TODO: also xtensa |
| | 106 | .mips, .mipsel, .mips64, .mips64el => 0x10, |
| | 107 | else => 0x8, |
| | 108 | }; |
| | 109 | |
| | 110 | /// mprotect flag: extend change to start of growsdown vma |
| 95 | pub const PROT_GROWSDOWN = 0x01000000; | 111 | pub const PROT_GROWSDOWN = 0x01000000; |
| | 112 | |
| | 113 | /// mprotect flag: extend change to end of growsup vma |
| 96 | pub const PROT_GROWSUP = 0x02000000; | 114 | pub const PROT_GROWSUP = 0x02000000; |
| 97 | | 115 | |
| 98 | /// Share changes | 116 | /// Share changes |
| ... | @@ -617,6 +635,11 @@ pub const CLONE_IO = 0x80000000; | ... | @@ -617,6 +635,11 @@ pub const CLONE_IO = 0x80000000; |
| 617 | /// Clear any signal handler and reset to SIG_DFL. | 635 | /// Clear any signal handler and reset to SIG_DFL. |
| 618 | pub const CLONE_CLEAR_SIGHAND = 0x100000000; | 636 | pub const CLONE_CLEAR_SIGHAND = 0x100000000; |
| 619 | | 637 | |
| | 638 | // cloning flags intersect with CSIGNAL so can be used with unshare and clone3 syscalls only. |
| | 639 | |
| | 640 | /// New time namespace |
| | 641 | pub const CLONE_NEWTIME = 0x00000080; |
| | 642 | |
| 620 | pub const EFD_SEMAPHORE = 1; | 643 | pub const EFD_SEMAPHORE = 1; |
| 621 | pub const EFD_CLOEXEC = O_CLOEXEC; | 644 | pub const EFD_CLOEXEC = O_CLOEXEC; |
| 622 | pub const EFD_NONBLOCK = O_NONBLOCK; | 645 | pub const EFD_NONBLOCK = O_NONBLOCK; |
| ... | @@ -1125,7 +1148,8 @@ pub const io_uring_params = extern struct { | ... | @@ -1125,7 +1148,8 @@ pub const io_uring_params = extern struct { |
| 1125 | sq_thread_cpu: u32, | 1148 | sq_thread_cpu: u32, |
| 1126 | sq_thread_idle: u32, | 1149 | sq_thread_idle: u32, |
| 1127 | features: u32, | 1150 | features: u32, |
| 1128 | resv: [4]u32, | 1151 | wq_fd: u32, |
| | 1152 | resv: [3]u32, |
| 1129 | sq_off: io_sqring_offsets, | 1153 | sq_off: io_sqring_offsets, |
| 1130 | cq_off: io_cqring_offsets, | 1154 | cq_off: io_cqring_offsets, |
| 1131 | }; | 1155 | }; |
| ... | @@ -1135,6 +1159,8 @@ pub const io_uring_params = extern struct { | ... | @@ -1135,6 +1159,8 @@ pub const io_uring_params = extern struct { |
| 1135 | pub const IORING_FEAT_SINGLE_MMAP = 1 << 0; | 1159 | pub const IORING_FEAT_SINGLE_MMAP = 1 << 0; |
| 1136 | pub const IORING_FEAT_NODROP = 1 << 1; | 1160 | pub const IORING_FEAT_NODROP = 1 << 1; |
| 1137 | pub const IORING_FEAT_SUBMIT_STABLE = 1 << 2; | 1161 | pub const IORING_FEAT_SUBMIT_STABLE = 1 << 2; |
| | 1162 | pub const IORING_FEAT_RW_CUR_POS = 1 << 3; |
| | 1163 | pub const IORING_FEAT_CUR_PERSONALITY = 1 << 4; |
| 1138 | | 1164 | |
| 1139 | // io_uring_params.flags | 1165 | // io_uring_params.flags |
| 1140 | | 1166 | |
| ... | @@ -1150,6 +1176,12 @@ pub const IORING_SETUP_SQ_AFF = 1 << 2; | ... | @@ -1150,6 +1176,12 @@ pub const IORING_SETUP_SQ_AFF = 1 << 2; |
| 1150 | /// app defines CQ size | 1176 | /// app defines CQ size |
| 1151 | pub const IORING_SETUP_CQSIZE = 1 << 3; | 1177 | pub const IORING_SETUP_CQSIZE = 1 << 3; |
| 1152 | | 1178 | |
| | 1179 | /// clamp SQ/CQ ring sizes |
| | 1180 | pub const IORING_SETUP_CLAMP = 1 << 4; |
| | 1181 | |
| | 1182 | /// attach to existing wq |
| | 1183 | pub const IORING_SETUP_ATTACH_WQ = 1 << 5; |
| | 1184 | |
| 1153 | pub const io_sqring_offsets = extern struct { | 1185 | pub const io_sqring_offsets = extern struct { |
| 1154 | /// offset of ring head | 1186 | /// offset of ring head |
| 1155 | head: u32, | 1187 | head: u32, |
| ... | @@ -1192,7 +1224,7 @@ pub const io_cqring_offsets = extern struct { | ... | @@ -1192,7 +1224,7 @@ pub const io_cqring_offsets = extern struct { |
| 1192 | }; | 1224 | }; |
| 1193 | | 1225 | |
| 1194 | pub const io_uring_sqe = extern struct { | 1226 | pub const io_uring_sqe = extern struct { |
| 1195 | opcode: u8, | 1227 | opcode: IORING_OP, |
| 1196 | flags: u8, | 1228 | flags: u8, |
| 1197 | ioprio: u16, | 1229 | ioprio: u16, |
| 1198 | fd: i32, | 1230 | fd: i32, |
| ... | @@ -1212,31 +1244,53 @@ pub const io_uring_sqe = extern struct { | ... | @@ -1212,31 +1244,53 @@ pub const io_uring_sqe = extern struct { |
| 1212 | timeout_flags: u32, | 1244 | timeout_flags: u32, |
| 1213 | accept_flags: u32, | 1245 | accept_flags: u32, |
| 1214 | cancel_flags: u32, | 1246 | cancel_flags: u32, |
| | 1247 | open_flags: u32, |
| | 1248 | statx_flags: u32, |
| | 1249 | fadvise_flags: u32, |
| 1215 | }; | 1250 | }; |
| 1216 | union2: union2, | 1251 | union2: union2, |
| 1217 | user_data: u64, | 1252 | user_data: u64, |
| 1218 | pub const union3 = extern union { | 1253 | pub const union3 = extern union { |
| 1219 | buf_index: u16, | 1254 | struct1: extern struct { |
| | 1255 | /// index into fixed buffers, if used |
| | 1256 | buf_index: u16, |
| | 1257 | |
| | 1258 | /// personality to use, if used |
| | 1259 | personality: u16, |
| | 1260 | }, |
| 1220 | __pad2: [3]u64, | 1261 | __pad2: [3]u64, |
| 1221 | }; | 1262 | }; |
| 1222 | union3: union3, | 1263 | union3: union3, |
| 1223 | }; | 1264 | }; |
| 1224 | | 1265 | |
| | 1266 | pub const IOSQE_BIT = extern enum { |
| | 1267 | FIXED_FILE, |
| | 1268 | IO_DRAIN, |
| | 1269 | IO_LINK, |
| | 1270 | IO_HARDLINK, |
| | 1271 | ASYNC, |
| | 1272 | |
| | 1273 | _, |
| | 1274 | }; |
| | 1275 | |
| 1225 | // io_uring_sqe.flags | 1276 | // io_uring_sqe.flags |
| 1226 | | 1277 | |
| 1227 | /// use fixed fileset | 1278 | /// use fixed fileset |
| 1228 | pub const IOSQE_FIXED_FILE = 1 << 0; | 1279 | pub const IOSQE_FIXED_FILE = 1 << IOSQE_BIT.FIXED_FILE; |
| 1229 | | 1280 | |
| 1230 | /// issue after inflight IO | 1281 | /// issue after inflight IO |
| 1231 | pub const IOSQE_IO_DRAIN = 1 << 1; | 1282 | pub const IOSQE_IO_DRAIN = 1 << IOSQE_BIT.IO_DRAIN; |
| 1232 | | 1283 | |
| 1233 | /// links next sqe | 1284 | /// links next sqe |
| 1234 | pub const IOSQE_IO_LINK = 1 << 2; | 1285 | pub const IOSQE_IO_LINK = 1 << IOSQE_BIT.IO_LINK; |
| 1235 | | 1286 | |
| 1236 | /// like LINK, but stronger | 1287 | /// like LINK, but stronger |
| 1237 | pub const IOSQE_IO_HARDLINK = 1 << 3; | 1288 | pub const IOSQE_IO_HARDLINK = 1 << IOSQE_BIT.IO_HARDLINK; |
| | 1289 | |
| | 1290 | /// always go async |
| | 1291 | pub const IOSQE_ASYNC = 1 << IOSQE_BIT.ASYNC; |
| 1238 | | 1292 | |
| 1239 | pub const IORING_OP = extern enum { | 1293 | pub const IORING_OP = extern enum(u8) { |
| 1240 | NOP, | 1294 | NOP, |
| 1241 | READV, | 1295 | READV, |
| 1242 | WRITEV, | 1296 | WRITEV, |
| ... | @@ -1254,6 +1308,19 @@ pub const IORING_OP = extern enum { | ... | @@ -1254,6 +1308,19 @@ pub const IORING_OP = extern enum { |
| 1254 | ASYNC_CANCEL, | 1308 | ASYNC_CANCEL, |
| 1255 | LINK_TIMEOUT, | 1309 | LINK_TIMEOUT, |
| 1256 | CONNECT, | 1310 | CONNECT, |
| | 1311 | FALLOCATE, |
| | 1312 | OPENAT, |
| | 1313 | CLOSE, |
| | 1314 | FILES_UPDATE, |
| | 1315 | STATX, |
| | 1316 | READ, |
| | 1317 | WRITE, |
| | 1318 | FADVISE, |
| | 1319 | MADVISE, |
| | 1320 | SEND, |
| | 1321 | RECV, |
| | 1322 | OPENAT2, |
| | 1323 | EPOLL_CTL, |
| 1257 | | 1324 | |
| 1258 | _, | 1325 | _, |
| 1259 | }; | 1326 | }; |
| ... | @@ -1283,13 +1350,21 @@ pub const IORING_ENTER_GETEVENTS = 1 << 0; | ... | @@ -1283,13 +1350,21 @@ pub const IORING_ENTER_GETEVENTS = 1 << 0; |
| 1283 | pub const IORING_ENTER_SQ_WAKEUP = 1 << 1; | 1350 | pub const IORING_ENTER_SQ_WAKEUP = 1 << 1; |
| 1284 | | 1351 | |
| 1285 | // io_uring_register opcodes and arguments | 1352 | // io_uring_register opcodes and arguments |
| 1286 | pub const IORING_REGISTER_BUFFERS = 0; | 1353 | pub const IORING_REGISTER = extern enum(u32) { |
| 1287 | pub const IORING_UNREGISTER_BUFFERS = 1; | 1354 | REGISTER_BUFFERS, |
| 1288 | pub const IORING_REGISTER_FILES = 2; | 1355 | UNREGISTER_BUFFERS, |
| 1289 | pub const IORING_UNREGISTER_FILES = 3; | 1356 | REGISTER_FILES, |
| 1290 | pub const IORING_REGISTER_EVENTFD = 4; | 1357 | UNREGISTER_FILES, |
| 1291 | pub const IORING_UNREGISTER_EVENTFD = 5; | 1358 | REGISTER_EVENTFD, |
| 1292 | pub const IORING_REGISTER_FILES_UPDATE = 6; | 1359 | UNREGISTER_EVENTFD, |
| | 1360 | REGISTER_FILES_UPDATE, |
| | 1361 | REGISTER_EVENTFD_ASYNC, |
| | 1362 | REGISTER_PROBE, |
| | 1363 | REGISTER_PERSONALITY, |
| | 1364 | UNREGISTER_PERSONALITY, |
| | 1365 | |
| | 1366 | _, |
| | 1367 | }; |
| 1293 | | 1368 | |
| 1294 | pub const io_uring_files_update = struct { | 1369 | pub const io_uring_files_update = struct { |
| 1295 | offset: u32, | 1370 | offset: u32, |
| ... | @@ -1297,6 +1372,32 @@ pub const io_uring_files_update = struct { | ... | @@ -1297,6 +1372,32 @@ pub const io_uring_files_update = struct { |
| 1297 | fds: u64, | 1372 | fds: u64, |
| 1298 | }; | 1373 | }; |
| 1299 | | 1374 | |
| | 1375 | pub const IO_URING_OP_SUPPORTED = 1 << 0; |
| | 1376 | |
| | 1377 | pub const io_uring_probe_op = struct { |
| | 1378 | op: IORING_OP, |
| | 1379 | |
| | 1380 | resv: u8, |
| | 1381 | |
| | 1382 | /// IO_URING_OP_* flags |
| | 1383 | flags: u16, |
| | 1384 | |
| | 1385 | resv2: u32, |
| | 1386 | }; |
| | 1387 | |
| | 1388 | pub const io_uring_probe = struct { |
| | 1389 | /// last opcode supported |
| | 1390 | last_op: IORING_OP, |
| | 1391 | |
| | 1392 | /// Number of io_uring_probe_op following |
| | 1393 | ops_len: u8, |
| | 1394 | |
| | 1395 | resv: u16, |
| | 1396 | resv2: u32[3], |
| | 1397 | |
| | 1398 | // Followed by up to `ops_len` io_uring_probe_op structures |
| | 1399 | }; |
| | 1400 | |
| 1300 | pub const utsname = extern struct { | 1401 | pub const utsname = extern struct { |
| 1301 | sysname: [64:0]u8, | 1402 | sysname: [64:0]u8, |
| 1302 | nodename: [64:0]u8, | 1403 | nodename: [64:0]u8, |