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;...@@ -88,11 +88,29 @@ pub const FUTEX_PRIVATE_FLAG = 128;
8888
89pub const FUTEX_CLOCK_REALTIME = 256;89pub const FUTEX_CLOCK_REALTIME = 256;
9090
91pub const PROT_NONE = 0;91/// page can not be accessed
92pub const PROT_READ = 1;92pub const PROT_NONE = 0x0;
93pub const PROT_WRITE = 2;93
94pub const PROT_EXEC = 4;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
95pub const PROT_GROWSDOWN = 0x01000000;111pub const PROT_GROWSDOWN = 0x01000000;
112
113/// mprotect flag: extend change to end of growsup vma
96pub const PROT_GROWSUP = 0x02000000;114pub const PROT_GROWSUP = 0x02000000;
97115
98/// Share changes116/// 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.
618pub const CLONE_CLEAR_SIGHAND = 0x100000000;636pub 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
620pub const EFD_SEMAPHORE = 1;643pub const EFD_SEMAPHORE = 1;
621pub const EFD_CLOEXEC = O_CLOEXEC;644pub const EFD_CLOEXEC = O_CLOEXEC;
622pub const EFD_NONBLOCK = O_NONBLOCK;645pub 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 {
1135pub const IORING_FEAT_SINGLE_MMAP = 1 << 0;1159pub const IORING_FEAT_SINGLE_MMAP = 1 << 0;
1136pub const IORING_FEAT_NODROP = 1 << 1;1160pub const IORING_FEAT_NODROP = 1 << 1;
1137pub const IORING_FEAT_SUBMIT_STABLE = 1 << 2;1161pub 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
1139// io_uring_params.flags1165// io_uring_params.flags
11401166
...@@ -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 size1176/// app defines CQ size
1151pub const IORING_SETUP_CQSIZE = 1 << 3;1177pub 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
1153pub const io_sqring_offsets = extern struct {1185pub const io_sqring_offsets = extern struct {
1154 /// offset of ring head1186 /// 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};
11931225
1194pub const io_uring_sqe = extern struct {1226pub 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};
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
1225// io_uring_sqe.flags1276// io_uring_sqe.flags
12261277
1227/// use fixed fileset1278/// use fixed fileset
1228pub const IOSQE_FIXED_FILE = 1 << 0;1279pub const IOSQE_FIXED_FILE = 1 << IOSQE_BIT.FIXED_FILE;
12291280
1230/// issue after inflight IO1281/// issue after inflight IO
1231pub const IOSQE_IO_DRAIN = 1 << 1;1282pub const IOSQE_IO_DRAIN = 1 << IOSQE_BIT.IO_DRAIN;
12321283
1233/// links next sqe1284/// links next sqe
1234pub const IOSQE_IO_LINK = 1 << 2;1285pub const IOSQE_IO_LINK = 1 << IOSQE_BIT.IO_LINK;
12351286
1236/// like LINK, but stronger1287/// 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) {
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,
12571324
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;
1283pub const IORING_ENTER_SQ_WAKEUP = 1 << 1;1350pub const IORING_ENTER_SQ_WAKEUP = 1 << 1;
12841351
1285// io_uring_register opcodes and arguments1352// io_uring_register opcodes and arguments
1286pub const IORING_REGISTER_BUFFERS = 0;1353pub const IORING_REGISTER = extern enum(u32) {
1287pub const IORING_UNREGISTER_BUFFERS = 1;1354 REGISTER_BUFFERS,
1288pub const IORING_REGISTER_FILES = 2;1355 UNREGISTER_BUFFERS,
1289pub const IORING_UNREGISTER_FILES = 3;1356 REGISTER_FILES,
1290pub const IORING_REGISTER_EVENTFD = 4;1357 UNREGISTER_FILES,
1291pub const IORING_UNREGISTER_EVENTFD = 5;1358 REGISTER_EVENTFD,
1292pub 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};
12931368
1294pub const io_uring_files_update = struct {1369pub 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};
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
1300pub const utsname = extern struct {1401pub const utsname = extern struct {
1301 sysname: [64:0]u8,1402 sysname: [64:0]u8,
1302 nodename: [64:0]u8,1403 nodename: [64:0]u8,
lib/std/os/bits/linux/arm-eabi.zig+2
...@@ -400,6 +400,8 @@ pub const SYS_fsmount = 432;...@@ -400,6 +400,8 @@ pub const SYS_fsmount = 432;
400pub const SYS_fspick = 433;400pub const SYS_fspick = 433;
401pub const SYS_pidfd_open = 434;401pub const SYS_pidfd_open = 434;
402pub const SYS_clone3 = 435;402pub const SYS_clone3 = 435;
403pub const SYS_openat2 = 437;
404pub const SYS_pidfd_getfd = 438;
403405
404pub const SYS_breakpoint = 0x0f0001;406pub const SYS_breakpoint = 0x0f0001;
405pub const SYS_cacheflush = 0x0f0002;407pub const SYS_cacheflush = 0x0f0002;
lib/std/os/bits/linux/arm64.zig+2
...@@ -302,6 +302,8 @@ pub const SYS_fsmount = 432;...@@ -302,6 +302,8 @@ pub const SYS_fsmount = 432;
302pub const SYS_fspick = 433;302pub const SYS_fspick = 433;
303pub const SYS_pidfd_open = 434;303pub const SYS_pidfd_open = 434;
304pub const SYS_clone3 = 435;304pub const SYS_clone3 = 435;
305pub const SYS_openat2 = 437;
306pub const SYS_pidfd_getfd = 438;
305307
306pub const O_CREAT = 0o100;308pub const O_CREAT = 0o100;
307pub const O_EXCL = 0o200;309pub const O_EXCL = 0o200;
lib/std/os/bits/linux/i386.zig+2
...@@ -434,6 +434,8 @@ pub const SYS_fsopen = 430;...@@ -434,6 +434,8 @@ pub const SYS_fsopen = 430;
434pub const SYS_fsconfig = 431;434pub const SYS_fsconfig = 431;
435pub const SYS_fsmount = 432;435pub const SYS_fsmount = 432;
436pub const SYS_fspick = 433;436pub const SYS_fspick = 433;
437pub const SYS_openat2 = 437;
438pub const SYS_pidfd_getfd = 438;
437439
438pub const O_CREAT = 0o100;440pub const O_CREAT = 0o100;
439pub const O_EXCL = 0o200;441pub const O_EXCL = 0o200;
lib/std/os/bits/linux/mipsel.zig+2
...@@ -375,6 +375,8 @@ pub const SYS_pkey_free = (SYS_Linux + 365);...@@ -375,6 +375,8 @@ pub const SYS_pkey_free = (SYS_Linux + 365);
375pub const SYS_statx = (SYS_Linux + 366);375pub const SYS_statx = (SYS_Linux + 366);
376pub const SYS_rseq = (SYS_Linux + 367);376pub const SYS_rseq = (SYS_Linux + 367);
377pub const SYS_io_pgetevents = (SYS_Linux + 368);377pub const SYS_io_pgetevents = (SYS_Linux + 368);
378pub const SYS_openat2 = (SYS_Linux + 437);
379pub const SYS_pidfd_getfd = (SYS_Linux + 438);
378380
379pub const O_CREAT = 0o0400;381pub const O_CREAT = 0o0400;
380pub const O_EXCL = 0o02000;382pub const O_EXCL = 0o02000;
lib/std/os/bits/linux/riscv64.zig+2
...@@ -297,6 +297,8 @@ pub const SYS_fsmount = 432;...@@ -297,6 +297,8 @@ pub const SYS_fsmount = 432;
297pub const SYS_fspick = 433;297pub const SYS_fspick = 433;
298pub const SYS_pidfd_open = 434;298pub const SYS_pidfd_open = 434;
299pub const SYS_clone3 = 435;299pub const SYS_clone3 = 435;
300pub const SYS_openat2 = 437;
301pub const SYS_pidfd_getfd = 438;
300302
301pub const O_CREAT = 0o100;303pub const O_CREAT = 0o100;
302pub const O_EXCL = 0o200;304pub const O_EXCL = 0o200;
lib/std/os/bits/linux/x86_64.zig+2
...@@ -362,6 +362,8 @@ pub const SYS_fsmount = 432;...@@ -362,6 +362,8 @@ pub const SYS_fsmount = 432;
362pub const SYS_fspick = 433;362pub const SYS_fspick = 433;
363pub const SYS_pidfd_open = 434;363pub const SYS_pidfd_open = 434;
364pub const SYS_clone3 = 435;364pub const SYS_clone3 = 435;
365pub const SYS_openat2 = 437;
366pub const SYS_pidfd_getfd = 438;
365367
366pub const O_CREAT = 0o100;368pub const O_CREAT = 0o100;
367pub const O_EXCL = 0o200;369pub 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...@@ -1169,8 +1169,8 @@ pub fn io_uring_enter(fd: i32, to_submit: u32, min_complete: u32, flags: u32, si
1169 return syscall6(SYS_io_uring_enter, @bitCast(usize, @as(isize, fd)), to_submit, min_complete, flags, @ptrToInt(sig), NSIG / 8);1169 return syscall6(SYS_io_uring_enter, @bitCast(usize, @as(isize, fd)), to_submit, min_complete, flags, @ptrToInt(sig), NSIG / 8);
1170}1170}
11711171
1172pub fn io_uring_register(fd: i32, opcode: u32, arg: ?*const c_void, nr_args: u32) usize {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)), opcode, @ptrToInt(arg), nr_args);1173 return syscall4(SYS_io_uring_register, @bitCast(usize, @as(isize, fd)), @enumToInt(opcode), @ptrToInt(arg), nr_args);
1174}1174}
11751175
1176pub fn memfd_create(name: [*:0]const u8, flags: u32) usize {1176pub fn memfd_create(name: [*:0]const u8, flags: u32) usize {