Skip to content

Commit c66151a

Browse files
devnexenVexu
authored andcommitted
std.os: sysctl* wrappers, better warning at compile time
1 parent 2dbcc03 commit c66151a

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

lib/std/os.zig

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4722,11 +4722,8 @@ pub fn sysctl(
47224722
newp: ?*anyopaque,
47234723
newlen: usize,
47244724
) SysCtlError!void {
4725-
if (builtin.os.tag == .wasi) {
4726-
@panic("unsupported"); // TODO should be compile error, not panic
4727-
}
4728-
if (builtin.os.tag == .haiku) {
4729-
@panic("unsupported"); // TODO should be compile error, not panic
4725+
if (builtin.os.tag == .wasi or builtin.os.tag == .haiku) {
4726+
@compileError("unsupported OS");
47304727
}
47314728

47324729
const name_len = math.cast(c_uint, name.len) orelse return error.NameTooLong;
@@ -4747,11 +4744,8 @@ pub fn sysctlbynameZ(
47474744
newp: ?*anyopaque,
47484745
newlen: usize,
47494746
) SysCtlError!void {
4750-
if (builtin.os.tag == .wasi) {
4751-
@panic("unsupported"); // TODO should be compile error, not panic
4752-
}
4753-
if (builtin.os.tag == .haiku) {
4754-
@panic("unsupported"); // TODO should be compile error, not panic
4747+
if (builtin.os.tag == .wasi or builtin.os.tag == .haiku) {
4748+
@compileError("unsupported OS");
47554749
}
47564750

47574751
switch (errno(system.sysctlbyname(name, oldp, oldlenp, newp, newlen))) {

0 commit comments

Comments
 (0)