authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-03-30 21:24:08+11:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-30 10:55:18-04:00
log356ef3840fcfc5065713fd20908eba0eb7648b66
treeb9d08c8232f8d0206930a7d80b41a59fad722929
parentde9933761c56287a27f3c348a99434ddab175094

std: update for linux 5.6 release


8 files changed, 134 insertions(+), 21 deletions(-)

lib/std/os/bits/linux.zig+120-19
......@@ -88,11 +88,29 @@ pub const FUTEX_PRIVATE_FLAG = 128;
8888
8989pub const FUTEX_CLOCK_REALTIME = 256;
9090
91pub const PROT_NONE = 0;
92pub const PROT_READ = 1;
93pub const PROT_WRITE = 2;
94pub const PROT_EXEC = 4;
91/// page can not be accessed
92pub const PROT_NONE = 0x0;
93
94/// page can be read
95pub const PROT_READ = 0x1;
96
97/// page can be written
98pub const PROT_WRITE = 0x2;
99
100/// page can be executed
101pub const PROT_EXEC = 0x4;
102
103/// page may be used for atomic ops
104pub 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
95111pub const PROT_GROWSDOWN = 0x01000000;
112
113/// mprotect flag: extend change to end of growsup vma
96114pub const PROT_GROWSUP = 0x02000000;
97115
98116/// Share changes
......@@ -617,6 +635,11 @@ pub const CLONE_IO = 0x80000000;
617635/// Clear any signal handler and reset to SIG_DFL.
618636pub const CLONE_CLEAR_SIGHAND = 0x100000000;
619637
638// cloning flags intersect with CSIGNAL so can be used with unshare and clone3 syscalls only.
639
640/// New time namespace
641pub const CLONE_NEWTIME = 0x00000080;
642
620643pub const EFD_SEMAPHORE = 1;
621644pub const EFD_CLOEXEC = O_CLOEXEC;
622645pub const EFD_NONBLOCK = O_NONBLOCK;
......@@ -1125,7 +1148,8 @@ pub const io_uring_params = extern struct {
11251148 sq_thread_cpu: u32,
11261149 sq_thread_idle: u32,
11271150 features: u32,
1128 resv: [4]u32,
1151 wq_fd: u32,
1152 resv: [3]u32,
11291153 sq_off: io_sqring_offsets,
11301154 cq_off: io_cqring_offsets,
11311155};
......@@ -1135,6 +1159,8 @@ pub const io_uring_params = extern struct {
11351159pub const IORING_FEAT_SINGLE_MMAP = 1 << 0;
11361160pub const IORING_FEAT_NODROP = 1 << 1;
11371161pub const IORING_FEAT_SUBMIT_STABLE = 1 << 2;
1162pub const IORING_FEAT_RW_CUR_POS = 1 << 3;
1163pub const IORING_FEAT_CUR_PERSONALITY = 1 << 4;
11381164
11391165// io_uring_params.flags
11401166
......@@ -1150,6 +1176,12 @@ pub const IORING_SETUP_SQ_AFF = 1 << 2;
11501176/// app defines CQ size
11511177pub const IORING_SETUP_CQSIZE = 1 << 3;
11521178
1179/// clamp SQ/CQ ring sizes
1180pub const IORING_SETUP_CLAMP = 1 << 4;
1181
1182/// attach to existing wq
1183pub const IORING_SETUP_ATTACH_WQ = 1 << 5;
1184
11531185pub const io_sqring_offsets = extern struct {
11541186 /// offset of ring head
11551187 head: u32,
......@@ -1192,7 +1224,7 @@ pub const io_cqring_offsets = extern struct {
11921224};
11931225
11941226pub const io_uring_sqe = extern struct {
1195 opcode: u8,
1227 opcode: IORING_OP,
11961228 flags: u8,
11971229 ioprio: u16,
11981230 fd: i32,
......@@ -1212,31 +1244,53 @@ pub const io_uring_sqe = extern struct {
12121244 timeout_flags: u32,
12131245 accept_flags: u32,
12141246 cancel_flags: u32,
1247 open_flags: u32,
1248 statx_flags: u32,
1249 fadvise_flags: u32,
12151250 };
12161251 union2: union2,
12171252 user_data: u64,
12181253 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 },
12201261 __pad2: [3]u64,
12211262 };
12221263 union3: union3,
12231264};
12241265
1266pub const IOSQE_BIT = extern enum {
1267 FIXED_FILE,
1268 IO_DRAIN,
1269 IO_LINK,
1270 IO_HARDLINK,
1271 ASYNC,
1272
1273 _,
1274};
1275
12251276// io_uring_sqe.flags
12261277
12271278/// use fixed fileset
1228pub const IOSQE_FIXED_FILE = 1 << 0;
1279pub const IOSQE_FIXED_FILE = 1 << IOSQE_BIT.FIXED_FILE;
12291280
12301281/// issue after inflight IO
1231pub const IOSQE_IO_DRAIN = 1 << 1;
1282pub const IOSQE_IO_DRAIN = 1 << IOSQE_BIT.IO_DRAIN;
12321283
12331284/// links next sqe
1234pub const IOSQE_IO_LINK = 1 << 2;
1285pub const IOSQE_IO_LINK = 1 << IOSQE_BIT.IO_LINK;
12351286
12361287/// like LINK, but stronger
1237pub const IOSQE_IO_HARDLINK = 1 << 3;
1288pub const IOSQE_IO_HARDLINK = 1 << IOSQE_BIT.IO_HARDLINK;
1289
1290/// always go async
1291pub const IOSQE_ASYNC = 1 << IOSQE_BIT.ASYNC;
12381292
1239pub const IORING_OP = extern enum {
1293pub const IORING_OP = extern enum(u8) {
12401294 NOP,
12411295 READV,
12421296 WRITEV,
......@@ -1254,6 +1308,19 @@ pub const IORING_OP = extern enum {
12541308 ASYNC_CANCEL,
12551309 LINK_TIMEOUT,
12561310 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,
12571324
12581325 _,
12591326};
......@@ -1283,13 +1350,21 @@ pub const IORING_ENTER_GETEVENTS = 1 << 0;
12831350pub const IORING_ENTER_SQ_WAKEUP = 1 << 1;
12841351
12851352// io_uring_register opcodes and arguments
1286pub const IORING_REGISTER_BUFFERS = 0;
1287pub const IORING_UNREGISTER_BUFFERS = 1;
1288pub const IORING_REGISTER_FILES = 2;
1289pub const IORING_UNREGISTER_FILES = 3;
1290pub const IORING_REGISTER_EVENTFD = 4;
1291pub const IORING_UNREGISTER_EVENTFD = 5;
1292pub const IORING_REGISTER_FILES_UPDATE = 6;
1353pub 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};
12931368
12941369pub const io_uring_files_update = struct {
12951370 offset: u32,
......@@ -1297,6 +1372,32 @@ pub const io_uring_files_update = struct {
12971372 fds: u64,
12981373};
12991374
1375pub const IO_URING_OP_SUPPORTED = 1 << 0;
1376
1377pub 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
1388pub 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
13001401pub const utsname = extern struct {
13011402 sysname: [64:0]u8,
13021403 nodename: [64:0]u8,
lib/std/os/bits/linux/arm-eabi.zig+2
......@@ -400,6 +400,8 @@ pub const SYS_fsmount = 432;
400400pub const SYS_fspick = 433;
401401pub const SYS_pidfd_open = 434;
402402pub const SYS_clone3 = 435;
403pub const SYS_openat2 = 437;
404pub const SYS_pidfd_getfd = 438;
403405
404406pub const SYS_breakpoint = 0x0f0001;
405407pub const SYS_cacheflush = 0x0f0002;
lib/std/os/bits/linux/arm64.zig+2
......@@ -302,6 +302,8 @@ pub const SYS_fsmount = 432;
302302pub const SYS_fspick = 433;
303303pub const SYS_pidfd_open = 434;
304304pub const SYS_clone3 = 435;
305pub const SYS_openat2 = 437;
306pub const SYS_pidfd_getfd = 438;
305307
306308pub const O_CREAT = 0o100;
307309pub const O_EXCL = 0o200;
lib/std/os/bits/linux/i386.zig+2
......@@ -434,6 +434,8 @@ pub const SYS_fsopen = 430;
434434pub const SYS_fsconfig = 431;
435435pub const SYS_fsmount = 432;
436436pub const SYS_fspick = 433;
437pub const SYS_openat2 = 437;
438pub const SYS_pidfd_getfd = 438;
437439
438440pub const O_CREAT = 0o100;
439441pub const O_EXCL = 0o200;
lib/std/os/bits/linux/mipsel.zig+2
......@@ -375,6 +375,8 @@ pub const SYS_pkey_free = (SYS_Linux + 365);
375375pub const SYS_statx = (SYS_Linux + 366);
376376pub const SYS_rseq = (SYS_Linux + 367);
377377pub const SYS_io_pgetevents = (SYS_Linux + 368);
378pub const SYS_openat2 = (SYS_Linux + 437);
379pub const SYS_pidfd_getfd = (SYS_Linux + 438);
378380
379381pub const O_CREAT = 0o0400;
380382pub const O_EXCL = 0o02000;
lib/std/os/bits/linux/riscv64.zig+2
......@@ -297,6 +297,8 @@ pub const SYS_fsmount = 432;
297297pub const SYS_fspick = 433;
298298pub const SYS_pidfd_open = 434;
299299pub const SYS_clone3 = 435;
300pub const SYS_openat2 = 437;
301pub const SYS_pidfd_getfd = 438;
300302
301303pub const O_CREAT = 0o100;
302304pub const O_EXCL = 0o200;
lib/std/os/bits/linux/x86_64.zig+2
......@@ -362,6 +362,8 @@ pub const SYS_fsmount = 432;
362362pub const SYS_fspick = 433;
363363pub const SYS_pidfd_open = 434;
364364pub const SYS_clone3 = 435;
365pub const SYS_openat2 = 437;
366pub const SYS_pidfd_getfd = 438;
365367
366368pub const O_CREAT = 0o100;
367369pub const O_EXCL = 0o200;
lib/std/os/linux.zig+2-2
......@@ -1169,8 +1169,8 @@ pub fn io_uring_enter(fd: i32, to_submit: u32, min_complete: u32, flags: u32, si
11691169 return syscall6(SYS_io_uring_enter, @bitCast(usize, @as(isize, fd)), to_submit, min_complete, flags, @ptrToInt(sig), NSIG / 8);
11701170}
11711171
1172pub fn io_uring_register(fd: i32, opcode: u32, arg: ?*const c_void, nr_args: u32) usize {
1173 return syscall4(SYS_io_uring_register, @bitCast(usize, @as(isize, fd)), opcode, @ptrToInt(arg), nr_args);
1172pub fn io_uring_register(fd: i32, opcode: IORING_REGISTER, arg: ?*const c_void, nr_args: u32) usize {
1173 return syscall4(SYS_io_uring_register, @bitCast(usize, @as(isize, fd)), @enumToInt(opcode), @ptrToInt(arg), nr_args);
11741174}
11751175
11761176pub fn memfd_create(name: [*:0]const u8, flags: u32) usize {