| author | |
| committer | |
| log | 5888d84ea362a81a313450d988425abba29dd728 |
| tree | 232e1be13e56305b64400e0077a95907559a5f36 |
| parent | 62bebda270d44a163a69393c9e189c2b1811f023 |
| parent | fee9318b1756054ff7050bae72c87a1b63a6f968 |
| signature |
closes #38544 files changed, 40 insertions(+), 0 deletions(-)
lib/std/c.zig+1| ... | @@ -109,6 +109,7 @@ pub extern "c" fn setreuid(ruid: c_uint, euid: c_uint) c_int; | ... | @@ -109,6 +109,7 @@ pub extern "c" fn setreuid(ruid: c_uint, euid: c_uint) c_int; |
| 109 | pub extern "c" fn setregid(rgid: c_uint, egid: c_uint) c_int; | 109 | pub extern "c" fn setregid(rgid: c_uint, egid: c_uint) c_int; |
| 110 | pub extern "c" fn rmdir(path: [*:0]const u8) c_int; | 110 | pub extern "c" fn rmdir(path: [*:0]const u8) c_int; |
| 111 | pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8; | 111 | pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8; |
| 112 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; | ||
| 112 | pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; | 113 | pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; |
| 113 | pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; | 114 | pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; |
| 114 | pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; | 115 | pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; |
lib/std/os.zig+11| ... | @@ -3325,3 +3325,14 @@ pub fn memfd_create(name: []const u8, flags: u32) !fd_t { | ... | @@ -3325,3 +3325,14 @@ pub fn memfd_create(name: []const u8, flags: u32) !fd_t { |
| 3325 | const name_t = try toMemFdPath(name); | 3325 | const name_t = try toMemFdPath(name); |
| 3326 | return memfd_createC(&name_t, flags); | 3326 | return memfd_createC(&name_t, flags); |
| 3327 | } | 3327 | } |
| 3328 | |||
| 3329 | pub fn getrusage(who: i32) rusage { | ||
| 3330 | var result: rusage = undefined; | ||
| 3331 | const rc = system.getrusage(who, &result); | ||
| 3332 | switch (errno(rc)) { | ||
| 3333 | 0 => return result, | ||
| 3334 | EINVAL => unreachable, | ||
| 3335 | EFAULT => unreachable, | ||
| 3336 | else => unreachable, | ||
| 3337 | } | ||
| 3338 | } |
lib/std/os/bits/linux.zig+24| ... | @@ -1453,3 +1453,27 @@ pub const MFD_HUGE_512MB = HUGETLB_FLAG_ENCODE_512MB; | ... | @@ -1453,3 +1453,27 @@ pub const MFD_HUGE_512MB = HUGETLB_FLAG_ENCODE_512MB; |
| 1453 | pub const MFD_HUGE_1GB = HUGETLB_FLAG_ENCODE_1GB; | 1453 | pub const MFD_HUGE_1GB = HUGETLB_FLAG_ENCODE_1GB; |
| 1454 | pub const MFD_HUGE_2GB = HUGETLB_FLAG_ENCODE_2GB; | 1454 | pub const MFD_HUGE_2GB = HUGETLB_FLAG_ENCODE_2GB; |
| 1455 | pub const MFD_HUGE_16GB = HUGETLB_FLAG_ENCODE_16GB; | 1455 | pub const MFD_HUGE_16GB = HUGETLB_FLAG_ENCODE_16GB; |
| 1456 | |||
| 1457 | pub const RUSAGE_SELF = 0; | ||
| 1458 | pub const RUSAGE_CHILDREN = -1; | ||
| 1459 | pub const RUSAGE_THREAD = 1; | ||
| 1460 | |||
| 1461 | pub const rusage = extern struct { | ||
| 1462 | utime: timeval, | ||
| 1463 | stime: timeval, | ||
| 1464 | maxrss: isize, | ||
| 1465 | ix_rss: isize, | ||
| 1466 | idrss: isize, | ||
| 1467 | isrss: isize, | ||
| 1468 | minflt: isize, | ||
| 1469 | majflt: isize, | ||
| 1470 | nswap: isize, | ||
| 1471 | inblock: isize, | ||
| 1472 | oublock: isize, | ||
| 1473 | msgsnd: isize, | ||
| 1474 | msgrcv: isize, | ||
| 1475 | nsignals: isize, | ||
| 1476 | nvcsw: isize, | ||
| 1477 | nivcsw: isize, | ||
| 1478 | __reserved: [16]isize = [1]isize{0} ** 16, | ||
| 1479 | }; |
lib/std/os/linux.zig+4| ... | @@ -1114,6 +1114,10 @@ pub fn memfd_create(name: [*:0]const u8, flags: u32) usize { | ... | @@ -1114,6 +1114,10 @@ pub fn memfd_create(name: [*:0]const u8, flags: u32) usize { |
| 1114 | return syscall2(SYS_memfd_create, @ptrToInt(name), flags); | 1114 | return syscall2(SYS_memfd_create, @ptrToInt(name), flags); |
| 1115 | } | 1115 | } |
| 1116 | 1116 | ||
| 1117 | pub fn getrusage(who: i32, usage: *rusage) usize { | ||
| 1118 | return syscall2(SYS_getrusage, @bitCast(usize, @as(isize, who)), @ptrToInt(usage)); | ||
| 1119 | } | ||
| 1120 | |||
| 1117 | test "" { | 1121 | test "" { |
| 1118 | if (builtin.os == .linux) { | 1122 | if (builtin.os == .linux) { |
| 1119 | _ = @import("linux/test.zig"); | 1123 | _ = @import("linux/test.zig"); |