| author | |
| committer | |
| log | 3640303ce1585f266f94e2c815287cb590478e0d |
| tree | 02289065efbdca8241f78cb195eeddb20b59a2aa |
| parent | af4b8eb6c087618729c821269e9f6d662d5f193c |
| signature |
4 files changed, 11 insertions(+), 3 deletions(-)
std/c.zig+1-1| ... | @@ -72,7 +72,7 @@ pub extern "c" fn setreuid(ruid: c_uint, euid: c_uint) c_int; | ... | @@ -72,7 +72,7 @@ pub extern "c" fn setreuid(ruid: c_uint, euid: c_uint) c_int; |
| 72 | pub extern "c" fn setregid(rgid: c_uint, egid: c_uint) c_int; | 72 | pub extern "c" fn setregid(rgid: c_uint, egid: c_uint) c_int; |
| 73 | pub extern "c" fn rmdir(path: [*]const u8) c_int; | 73 | pub extern "c" fn rmdir(path: [*]const u8) c_int; |
| 74 | pub extern "c" fn getenv(name: [*]const u8) ?[*]u8; | 74 | pub extern "c" fn getenv(name: [*]const u8) ?[*]u8; |
| 75 | pub extern "c" fn sysctl(name: [*]c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; | 75 | pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; |
| 76 | pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; | 76 | pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; |
| 77 | pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; | 77 | pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; |
| 78 | 78 |
std/os.zig+3-1| ... | @@ -2071,6 +2071,7 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t { | ... | @@ -2071,6 +2071,7 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t { |
| 2071 | pub const SysCtlError = error{ | 2071 | pub const SysCtlError = error{ |
| 2072 | PermissionDenied, | 2072 | PermissionDenied, |
| 2073 | SystemResources, | 2073 | SystemResources, |
| 2074 | NameTooLong, | ||
| 2074 | Unexpected, | 2075 | Unexpected, |
| 2075 | }; | 2076 | }; |
| 2076 | 2077 | ||
| ... | @@ -2081,7 +2082,8 @@ pub fn sysctl( | ... | @@ -2081,7 +2082,8 @@ pub fn sysctl( |
| 2081 | newp: ?*c_void, | 2082 | newp: ?*c_void, |
| 2082 | newlen: usize, | 2083 | newlen: usize, |
| 2083 | ) SysCtlError!void { | 2084 | ) SysCtlError!void { |
| 2084 | switch (errno(system.sysctl(name.ptr, name.len, oldp, oldlenp, newp, newlen))) { | 2085 | const name_len = math.cast(c_uint, name.len) catch return error.NameTooLong; |
| 2086 | switch (errno(system.sysctl(name.ptr, name_len, oldp, oldlenp, newp, newlen))) { | ||
| 2085 | 0 => return, | 2087 | 0 => return, |
| 2086 | EFAULT => unreachable, | 2088 | EFAULT => unreachable, |
| 2087 | EPERM => return error.PermissionDenied, | 2089 | EPERM => return error.PermissionDenied, |
std/os/bits/freebsd.zig+3| ... | @@ -1,3 +1,6 @@ | ... | @@ -1,3 +1,6 @@ |
| 1 | const std = @import("../../std.zig"); | ||
| 2 | const maxInt = std.math.maxInt; | ||
| 3 | |||
| 1 | pub const fd_t = c_int; | 4 | pub const fd_t = c_int; |
| 2 | pub const pid_t = c_int; | 5 | pub const pid_t = c_int; |
| 3 | 6 |
std/thread.zig+4-1| ... | @@ -340,7 +340,10 @@ pub const Thread = struct { | ... | @@ -340,7 +340,10 @@ pub const Thread = struct { |
| 340 | var count: c_int = undefined; | 340 | var count: c_int = undefined; |
| 341 | var count_len: usize = @sizeOf(c_int); | 341 | var count_len: usize = @sizeOf(c_int); |
| 342 | const name = if (os.darwin.is_the_target) c"hw.logicalcpu" else c"hw.ncpu"; | 342 | const name = if (os.darwin.is_the_target) c"hw.logicalcpu" else c"hw.ncpu"; |
| 343 | try os.sysctlbynameC(name, @ptrCast(*c_void, &count), &count_len, null, 0); | 343 | os.sysctlbynameC(name, &count, &count_len, null, 0) catch |err| switch (err) { |
| 344 | error.NameTooLong => unreachable, | ||
| 345 | else => |e| return e, | ||
| 346 | }; | ||
| 344 | return @intCast(usize, count); | 347 | return @intCast(usize, count); |
| 345 | } | 348 | } |
| 346 | }; | 349 | }; |