aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorSardorbek Imomaliev <3041675+imomaliev@users.noreply.github.com>2025-08-21 11:36:57 +0100
committerGitHub <noreply@github.com>2025-08-21 12:36:57 +0200
commit01b5023868a2881d69e2947c0fd7d9bcf51a1698 (patch)
tree2a2aef147fa22c9ce106cc3549acfd7030b802ee /lib/std
parentcab6d752e8f6f6d3f538075840acc108238feda3 (diff)
downloadzig-01b5023868a2881d69e2947c0fd7d9bcf51a1698.tar.gz
zig-01b5023868a2881d69e2947c0fd7d9bcf51a1698.zip
drop NameTooLong from sysctlbynameZ error set (#24909)
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/Thread.zig2
-rw-r--r--lib/std/posix.zig8
-rw-r--r--lib/std/process.zig2
-rw-r--r--lib/std/zig/system.zig1
-rw-r--r--lib/std/zig/system/darwin/macos.zig1
5 files changed, 9 insertions, 5 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
index 63af3796b7..e6d1c79d01 100644
--- a/lib/std/Thread.zig
+++ b/lib/std/Thread.zig
@@ -761,7 +761,7 @@ const PosixThreadImpl = struct {
var count_len: usize = @sizeOf(c_int);
const name = if (comptime target.os.tag.isDarwin()) "hw.logicalcpu" else "hw.ncpu";
posix.sysctlbynameZ(name, &count, &count_len, null, 0) catch |err| switch (err) {
- error.NameTooLong, error.UnknownName => unreachable,
+ error.UnknownName => unreachable,
else => |e| return e,
};
return @as(usize, @intCast(count));
diff --git a/lib/std/posix.zig b/lib/std/posix.zig
index 256ed036c5..31ac2fcb85 100644
--- a/lib/std/posix.zig
+++ b/lib/std/posix.zig
@@ -5291,13 +5291,19 @@ pub fn sysctl(
}
}
+pub const SysCtlByNameError = error{
+ PermissionDenied,
+ SystemResources,
+ UnknownName,
+} || UnexpectedError;
+
pub fn sysctlbynameZ(
name: [*:0]const u8,
oldp: ?*anyopaque,
oldlenp: ?*usize,
newp: ?*anyopaque,
newlen: usize,
-) SysCtlError!void {
+) SysCtlByNameError!void {
if (native_os == .wasi) {
@compileError("sysctl not supported on WASI");
}
diff --git a/lib/std/process.zig b/lib/std/process.zig
index 2e9cb1fe85..360c3f6af0 100644
--- a/lib/std/process.zig
+++ b/lib/std/process.zig
@@ -1759,7 +1759,7 @@ pub fn totalSystemMemory() TotalSystemMemoryError!u64 {
var physmem: c_ulong = undefined;
var len: usize = @sizeOf(c_ulong);
posix.sysctlbynameZ("hw.physmem", &physmem, &len, null, 0) catch |err| switch (err) {
- error.NameTooLong, error.UnknownName => unreachable,
+ error.UnknownName => unreachable,
else => return error.UnknownTotalSystemMemory,
};
return @as(usize, @intCast(physmem));
diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig
index ba43543ee2..41d2aef3f9 100644
--- a/lib/std/zig/system.zig
+++ b/lib/std/zig/system.zig
@@ -228,7 +228,6 @@ pub fn resolveTargetQuery(query: Target.Query) DetectError!Target {
var len: usize = @sizeOf(@TypeOf(value));
posix.sysctlbynameZ(key, &value, &len, null, 0) catch |err| switch (err) {
- error.NameTooLong => unreachable, // constant, known good value
error.PermissionDenied => unreachable, // only when setting values,
error.SystemResources => unreachable, // memory already on the stack
error.UnknownName => unreachable, // constant, known good value
diff --git a/lib/std/zig/system/darwin/macos.zig b/lib/std/zig/system/darwin/macos.zig
index eba837fb49..eecb857465 100644
--- a/lib/std/zig/system/darwin/macos.zig
+++ b/lib/std/zig/system/darwin/macos.zig
@@ -397,7 +397,6 @@ pub fn detectNativeCpuAndFeatures() ?Target.Cpu {
var cpu_family: std.c.CPUFAMILY = undefined;
var len: usize = @sizeOf(std.c.CPUFAMILY);
std.posix.sysctlbynameZ("hw.cpufamily", &cpu_family, &len, null, 0) catch |err| switch (err) {
- error.NameTooLong => unreachable, // constant, known good value
error.PermissionDenied => unreachable, // only when setting values,
error.SystemResources => unreachable, // memory already on the stack
error.UnknownName => unreachable, // constant, known good value