diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 60da0e5291..e9a973f2fd 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -500,25 +500,25 @@ pub const Os = struct { .dragonfly => .{ .semver = .{ - .min = .{ .major = 5, .minor = 8, .patch = 0 }, + .min = .{ .major = 6, .minor = 0, .patch = 0 }, .max = .{ .major = 6, .minor = 4, .patch = 0 }, }, }, .freebsd => .{ .semver = .{ - .min = .{ .major = 12, .minor = 0, .patch = 0 }, + .min = .{ .major = 13, .minor = 4, .patch = 0 }, .max = .{ .major = 14, .minor = 2, .patch = 0 }, }, }, .netbsd => .{ .semver = .{ - .min = .{ .major = 8, .minor = 0, .patch = 0 }, + .min = .{ .major = 9, .minor = 4, .patch = 0 }, .max = .{ .major = 10, .minor = 1, .patch = 0 }, }, }, .openbsd => .{ .semver = .{ - .min = .{ .major = 7, .minor = 3, .patch = 0 }, + .min = .{ .major = 7, .minor = 5, .patch = 0 }, .max = .{ .major = 7, .minor = 6, .patch = 0 }, }, }, diff --git a/lib/std/os.zig b/lib/std/os.zig index 3e9ec49e6e..f71180b5ee 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -158,57 +158,18 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix. return target; }, .freebsd => { - if (builtin.os.isAtLeast(.freebsd, .{ .major = 13, .minor = 0, .patch = 0 }) orelse false) { - var kfile: std.c.kinfo_file = undefined; - kfile.structsize = std.c.KINFO_FILE_SIZE; - switch (posix.errno(std.c.fcntl(fd, std.c.F.KINFO, @intFromPtr(&kfile)))) { - .SUCCESS => {}, - .BADF => return error.FileNotFound, - else => |err| return posix.unexpectedErrno(err), - } - const len = mem.indexOfScalar(u8, &kfile.path, 0) orelse max_path_bytes; - if (len == 0) return error.NameTooLong; - const result = out_buffer[0..len]; - @memcpy(result, kfile.path[0..len]); - return result; - } else { - // This fallback implementation reimplements libutil's `kinfo_getfile()`. - // The motivation is to avoid linking -lutil when building zig or general - // user executables. - var mib = [4]c_int{ posix.CTL.KERN, posix.KERN.PROC, posix.KERN.PROC_FILEDESC, std.c.getpid() }; - var len: usize = undefined; - posix.sysctl(&mib, null, &len, null, 0) catch |err| switch (err) { - error.PermissionDenied => unreachable, - error.SystemResources => return error.SystemResources, - error.NameTooLong => unreachable, - error.UnknownName => unreachable, - else => return error.Unexpected, - }; - len = len * 4 / 3; - const buf = std.heap.c_allocator.alloc(u8, len) catch return error.SystemResources; - defer std.heap.c_allocator.free(buf); - len = buf.len; - posix.sysctl(&mib, &buf[0], &len, null, 0) catch |err| switch (err) { - error.PermissionDenied => unreachable, - error.SystemResources => return error.SystemResources, - error.NameTooLong => unreachable, - error.UnknownName => unreachable, - else => return error.Unexpected, - }; - var i: usize = 0; - while (i < len) { - const kf: *align(1) std.c.kinfo_file = @ptrCast(&buf[i]); - if (kf.fd == fd) { - len = mem.indexOfScalar(u8, &kf.path, 0) orelse max_path_bytes; - if (len == 0) return error.NameTooLong; - const result = out_buffer[0..len]; - @memcpy(result, kf.path[0..len]); - return result; - } - i += @intCast(kf.structsize); - } - return error.FileNotFound; + var kfile: std.c.kinfo_file = undefined; + kfile.structsize = std.c.KINFO_FILE_SIZE; + switch (posix.errno(std.c.fcntl(fd, std.c.F.KINFO, @intFromPtr(&kfile)))) { + .SUCCESS => {}, + .BADF => return error.FileNotFound, + else => |err| return posix.unexpectedErrno(err), } + const len = mem.indexOfScalar(u8, &kfile.path, 0) orelse max_path_bytes; + if (len == 0) return error.NameTooLong; + const result = out_buffer[0..len]; + @memcpy(result, kfile.path[0..len]); + return result; }, .dragonfly => { @memset(out_buffer[0..max_path_bytes], 0); diff --git a/lib/std/posix.zig b/lib/std/posix.zig index c693393ae2..65c8769775 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -6590,7 +6590,7 @@ pub const CopyFileRangeError = error{ /// /// Maximum offsets on Linux and FreeBSD are `maxInt(i64)`. pub fn copy_file_range(fd_in: fd_t, off_in: u64, fd_out: fd_t, off_out: u64, len: usize, flags: u32) CopyFileRangeError!usize { - if ((comptime builtin.os.isAtLeast(.freebsd, .{ .major = 13, .minor = 0, .patch = 0 }) orelse false) or + if (builtin.os.tag == .freebsd or (comptime builtin.os.tag == .linux and std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 }))) { var off_in_copy: i64 = @bitCast(off_in); diff --git a/test/llvm_targets.zig b/test/llvm_targets.zig index 2271d1471b..8e9a070d93 100644 --- a/test/llvm_targets.zig +++ b/test/llvm_targets.zig @@ -71,8 +71,6 @@ const targets = [_]std.Target.Query{ // .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabi }, // .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabihf }, - .{ .cpu_arch = .armeb, .os_tag = .freebsd, .abi = .eabi }, - .{ .cpu_arch = .armeb, .os_tag = .freebsd, .abi = .eabihf }, .{ .cpu_arch = .armeb, .os_tag = .freestanding, .abi = .eabi }, .{ .cpu_arch = .armeb, .os_tag = .freestanding, .abi = .eabihf }, .{ .cpu_arch = .armeb, .os_tag = .linux, .abi = .eabi }, @@ -257,7 +255,6 @@ const targets = [_]std.Target.Query{ // .{ .cpu_arch = .sparc, .os_tag = .rtems, .abi = .none }, // .{ .cpu_arch = .sparc, .os_tag = .solaris, .abi = .none }, - .{ .cpu_arch = .sparc64, .os_tag = .freebsd, .abi = .none }, .{ .cpu_arch = .sparc64, .os_tag = .freestanding, .abi = .none }, .{ .cpu_arch = .sparc64, .os_tag = .haiku, .abi = .none }, .{ .cpu_arch = .sparc64, .os_tag = .illumos, .abi = .none },