| author | |
| committer | |
| log | 6f418c11e1ad1150fbdb002cfe1be92bda4e93cb |
| tree | 0fee66a95543b4d13f8a98fad3622deeb4e1eea4 |
| parent | cceadf52baff2590c1b38c469b1177918183dfe8 |
2 files changed, 32 insertions(+), 0 deletions(-)
lib/std/c/linux.zig+16| ... | @@ -371,3 +371,19 @@ pub const dirent64 = struct { | ... | @@ -371,3 +371,19 @@ pub const dirent64 = struct { |
| 371 | d_type: u8, | 371 | d_type: u8, |
| 372 | d_name: [256]u8, | 372 | d_name: [256]u8, |
| 373 | }; | 373 | }; |
| 374 | |||
| 375 | pub const MPOL = struct { | ||
| 376 | pub const F_NODE = 1 << 0; | ||
| 377 | pub const F_ADDR = 1 << 1; | ||
| 378 | pub const F_MEMS_ALLOWED = 1 << 2; | ||
| 379 | /// flags for SYS_mbind | ||
| 380 | pub const MF_STRICT = 1 << 0; | ||
| 381 | pub const MF_MOVE = 1 << 1; | ||
| 382 | pub const MF_MOVE_ALL = 1 << 2; | ||
| 383 | pub const MF_LAZY = 1 << 3; | ||
| 384 | pub const MF_INTERNAL = 1 << 4; | ||
| 385 | pub const MF_VALID = MPOL.MF_STRICT | MPOL.MF_MOVE | MPOL.MOVE_ALL; | ||
| 386 | }; | ||
| 387 | |||
| 388 | pub extern "c" fn getcpu(cpu: *c_uint, node: *c_uint) c_int; | ||
| 389 | pub extern "c" fn sched_getcpu() c_int; |
lib/std/os/linux.zig+16| ... | @@ -1519,6 +1519,22 @@ pub fn sched_getaffinity(pid: pid_t, size: usize, set: *cpu_set_t) usize { | ... | @@ -1519,6 +1519,22 @@ pub fn sched_getaffinity(pid: pid_t, size: usize, set: *cpu_set_t) usize { |
| 1519 | return 0; | 1519 | return 0; |
| 1520 | } | 1520 | } |
| 1521 | 1521 | ||
| 1522 | pub fn getcpu(cpu: *u32, node: *u32) usize { | ||
| 1523 | return syscall3(.getcpu, cpu, node, null); | ||
| 1524 | } | ||
| 1525 | |||
| 1526 | pub fn sched_getcpu() usize { | ||
| 1527 | var cpu: u32 = undefined; | ||
| 1528 | const rc = syscall3(.getcpu, &cpu, null, null); | ||
| 1529 | if (@bitCast(isize, rc) < 0) return rc; | ||
| 1530 | return @intCast(usize, cpu); | ||
| 1531 | } | ||
| 1532 | |||
| 1533 | /// libc has no wrapper for this syscall | ||
| 1534 | pub fn mbind(addr: ?*anyopaque, len: u32, mode: i32, nodemask: *const u32, maxnode: u32, flags: u32) usize { | ||
| 1535 | return syscall6(.mbind, addr, len, mode, nodemask, maxnode, flags); | ||
| 1536 | } | ||
| 1537 | |||
| 1522 | pub fn epoll_create() usize { | 1538 | pub fn epoll_create() usize { |
| 1523 | return epoll_create1(0); | 1539 | return epoll_create1(0); |
| 1524 | } | 1540 | } |