| ... | ... | @@ -88,11 +88,29 @@ pub const FUTEX_PRIVATE_FLAG = 128; |
| 88 | 88 | |
| 89 | 89 | pub const FUTEX_CLOCK_REALTIME = 256; |
| 90 | 90 | |
| 91 | | pub const PROT_NONE = 0; |
| 92 | | pub const PROT_READ = 1; |
| 93 | | pub const PROT_WRITE = 2; |
| 94 | | pub const PROT_EXEC = 4; |
| 91 | /// page can not be accessed |
| 92 | pub const PROT_NONE = 0x0; |
| 93 | |
| 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 | 111 | pub const PROT_GROWSDOWN = 0x01000000; |
| 112 | |
| 113 | /// mprotect flag: extend change to end of growsup vma |
| 96 | 114 | pub const PROT_GROWSUP = 0x02000000; |
| 97 | 115 | |
| 98 | 116 | /// Share changes |
| ... | ... | @@ -617,6 +635,11 @@ pub const CLONE_IO = 0x80000000; |
| 617 | 635 | /// Clear any signal handler and reset to SIG_DFL. |
| 618 | 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 | 643 | pub const EFD_SEMAPHORE = 1; |
| 621 | 644 | pub const EFD_CLOEXEC = O_CLOEXEC; |
| 622 | 645 | pub const EFD_NONBLOCK = O_NONBLOCK; |
| ... | ... | @@ -1125,7 +1148,8 @@ pub const io_uring_params = extern struct { |
| 1125 | 1148 | sq_thread_cpu: u32, |
| 1126 | 1149 | sq_thread_idle: u32, |
| 1127 | 1150 | features: u32, |
| 1128 | | resv: [4]u32, |
| 1151 | wq_fd: u32, |
| 1152 | resv: [3]u32, |
| 1129 | 1153 | sq_off: io_sqring_offsets, |
| 1130 | 1154 | cq_off: io_cqring_offsets, |
| 1131 | 1155 | }; |
| ... | ... | @@ -1135,6 +1159,8 @@ pub const io_uring_params = extern struct { |
| 1135 | 1159 | pub const IORING_FEAT_SINGLE_MMAP = 1 << 0; |
| 1136 | 1160 | pub const IORING_FEAT_NODROP = 1 << 1; |
| 1137 | 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 | 1165 | // io_uring_params.flags |
| 1140 | 1166 | |
| ... | ... | @@ -1150,6 +1176,12 @@ pub const IORING_SETUP_SQ_AFF = 1 << 2; |
| 1150 | 1176 | /// app defines CQ size |
| 1151 | 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 | 1185 | pub const io_sqring_offsets = extern struct { |
| 1154 | 1186 | /// offset of ring head |
| 1155 | 1187 | head: u32, |
| ... | ... | @@ -1192,7 +1224,7 @@ pub const io_cqring_offsets = extern struct { |
| 1192 | 1224 | }; |
| 1193 | 1225 | |
| 1194 | 1226 | pub const io_uring_sqe = extern struct { |
| 1195 | | opcode: u8, |
| 1227 | opcode: IORING_OP, |
| 1196 | 1228 | flags: u8, |
| 1197 | 1229 | ioprio: u16, |
| 1198 | 1230 | fd: i32, |
| ... | ... | @@ -1212,31 +1244,53 @@ pub const io_uring_sqe = extern struct { |
| 1212 | 1244 | timeout_flags: u32, |
| 1213 | 1245 | accept_flags: u32, |
| 1214 | 1246 | cancel_flags: u32, |
| 1247 | open_flags: u32, |
| 1248 | statx_flags: u32, |
| 1249 | fadvise_flags: u32, |
| 1215 | 1250 | }; |
| 1216 | 1251 | union2: union2, |
| 1217 | 1252 | user_data: u64, |
| 1218 | 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 | 1261 | __pad2: [3]u64, |
| 1221 | 1262 | }; |
| 1222 | 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 | 1276 | // io_uring_sqe.flags |
| 1226 | 1277 | |
| 1227 | 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 | 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 | 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 | 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 | 1294 | NOP, |
| 1241 | 1295 | READV, |
| 1242 | 1296 | WRITEV, |
| ... | ... | @@ -1254,6 +1308,19 @@ pub const IORING_OP = extern enum { |
| 1254 | 1308 | ASYNC_CANCEL, |
| 1255 | 1309 | LINK_TIMEOUT, |
| 1256 | 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 | 1350 | pub const IORING_ENTER_SQ_WAKEUP = 1 << 1; |
| 1284 | 1351 | |
| 1285 | 1352 | // io_uring_register opcodes and arguments |
| 1286 | | pub const IORING_REGISTER_BUFFERS = 0; |
| 1287 | | pub const IORING_UNREGISTER_BUFFERS = 1; |
| 1288 | | pub const IORING_REGISTER_FILES = 2; |
| 1289 | | pub const IORING_UNREGISTER_FILES = 3; |
| 1290 | | pub const IORING_REGISTER_EVENTFD = 4; |
| 1291 | | pub const IORING_UNREGISTER_EVENTFD = 5; |
| 1292 | | pub const IORING_REGISTER_FILES_UPDATE = 6; |
| 1353 | pub const IORING_REGISTER = extern enum(u32) { |
| 1354 | REGISTER_BUFFERS, |
| 1355 | UNREGISTER_BUFFERS, |
| 1356 | REGISTER_FILES, |
| 1357 | UNREGISTER_FILES, |
| 1358 | REGISTER_EVENTFD, |
| 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 | 1369 | pub const io_uring_files_update = struct { |
| 1295 | 1370 | offset: u32, |
| ... | ... | @@ -1297,6 +1372,32 @@ pub const io_uring_files_update = struct { |
| 1297 | 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 | 1401 | pub const utsname = extern struct { |
| 1301 | 1402 | sysname: [64:0]u8, |
| 1302 | 1403 | nodename: [64:0]u8, |