From fee9318b1756054ff7050bae72c87a1b63a6f968 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 5 Jan 2020 16:57:14 -0500 Subject: [PATCH] std.os.getrusage: add C extern fn and reserved field * add reserved field to match musl struct definition so that it will work with musl libc. * add libc getrusage so that it will work with libc what's not done in this branch is: * test coverage. See #1629, which should also aim to provide general test coverage for the std lib. * rusage struct bits for non-linux operating systems --- lib/std/c.zig | 1 + lib/std/os/bits/linux.zig | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/std/c.zig b/lib/std/c.zig index 684758286..45d0b4db0 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -109,6 +109,7 @@ pub extern "c" fn setreuid(ruid: c_uint, euid: c_uint) c_int; pub extern "c" fn setregid(rgid: c_uint, egid: c_uint) c_int; pub extern "c" fn rmdir(path: [*:0]const u8) c_int; pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8; +pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig index 6fa8bc1f3..678868a2c 100644 --- a/lib/std/os/bits/linux.zig +++ b/lib/std/os/bits/linux.zig @@ -1475,4 +1475,5 @@ pub const rusage = extern struct { nsignals: isize, nvcsw: isize, nivcsw: isize, + __reserved: [16]isize = [1]isize{0} ** 16, };