| author | |
| committer | |
| log | 9bbac4288697f056f0cdb0c6ac597e9b1b18ea12 |
| tree | 68a2e77e2fccf07774d8cc0fd51150fdd5ae1d2b |
| parent | 2d33cc2e42d40ce0ee798d4d56c2d7da93ead44a |
| parent | c8631ec523bb9ae9ff04f00401cb7e0fe0ae3bf4 |
| signature |
`std.Target`: Bump some minimum OS versions for BSDs4 files changed, 16 insertions(+), 58 deletions(-)
lib/std/Target.zig+4-4| ... | ... | @@ -500,25 +500,25 @@ pub const Os = struct { |
| 500 | 500 | |
| 501 | 501 | .dragonfly => .{ |
| 502 | 502 | .semver = .{ |
| 503 | .min = .{ .major = 5, .minor = 8, .patch = 0 }, | |
| 503 | .min = .{ .major = 6, .minor = 0, .patch = 0 }, | |
| 504 | 504 | .max = .{ .major = 6, .minor = 4, .patch = 0 }, |
| 505 | 505 | }, |
| 506 | 506 | }, |
| 507 | 507 | .freebsd => .{ |
| 508 | 508 | .semver = .{ |
| 509 | .min = .{ .major = 12, .minor = 0, .patch = 0 }, | |
| 509 | .min = .{ .major = 13, .minor = 4, .patch = 0 }, | |
| 510 | 510 | .max = .{ .major = 14, .minor = 2, .patch = 0 }, |
| 511 | 511 | }, |
| 512 | 512 | }, |
| 513 | 513 | .netbsd => .{ |
| 514 | 514 | .semver = .{ |
| 515 | .min = .{ .major = 8, .minor = 0, .patch = 0 }, | |
| 515 | .min = .{ .major = 9, .minor = 4, .patch = 0 }, | |
| 516 | 516 | .max = .{ .major = 10, .minor = 1, .patch = 0 }, |
| 517 | 517 | }, |
| 518 | 518 | }, |
| 519 | 519 | .openbsd => .{ |
| 520 | 520 | .semver = .{ |
| 521 | .min = .{ .major = 7, .minor = 3, .patch = 0 }, | |
| 521 | .min = .{ .major = 7, .minor = 5, .patch = 0 }, | |
| 522 | 522 | .max = .{ .major = 7, .minor = 6, .patch = 0 }, |
| 523 | 523 | }, |
| 524 | 524 | }, |
lib/std/os.zig+11-50| ... | ... | @@ -158,57 +158,18 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix. |
| 158 | 158 | return target; |
| 159 | 159 | }, |
| 160 | 160 | .freebsd => { |
| 161 | if (builtin.os.isAtLeast(.freebsd, .{ .major = 13, .minor = 0, .patch = 0 }) orelse false) { | |
| 162 | var kfile: std.c.kinfo_file = undefined; | |
| 163 | kfile.structsize = std.c.KINFO_FILE_SIZE; | |
| 164 | switch (posix.errno(std.c.fcntl(fd, std.c.F.KINFO, @intFromPtr(&kfile)))) { | |
| 165 | .SUCCESS => {}, | |
| 166 | .BADF => return error.FileNotFound, | |
| 167 | else => |err| return posix.unexpectedErrno(err), | |
| 168 | } | |
| 169 | const len = mem.indexOfScalar(u8, &kfile.path, 0) orelse max_path_bytes; | |
| 170 | if (len == 0) return error.NameTooLong; | |
| 171 | const result = out_buffer[0..len]; | |
| 172 | @memcpy(result, kfile.path[0..len]); | |
| 173 | return result; | |
| 174 | } else { | |
| 175 | // This fallback implementation reimplements libutil's `kinfo_getfile()`. | |
| 176 | // The motivation is to avoid linking -lutil when building zig or general | |
| 177 | // user executables. | |
| 178 | var mib = [4]c_int{ posix.CTL.KERN, posix.KERN.PROC, posix.KERN.PROC_FILEDESC, std.c.getpid() }; | |
| 179 | var len: usize = undefined; | |
| 180 | posix.sysctl(&mib, null, &len, null, 0) catch |err| switch (err) { | |
| 181 | error.PermissionDenied => unreachable, | |
| 182 | error.SystemResources => return error.SystemResources, | |
| 183 | error.NameTooLong => unreachable, | |
| 184 | error.UnknownName => unreachable, | |
| 185 | else => return error.Unexpected, | |
| 186 | }; | |
| 187 | len = len * 4 / 3; | |
| 188 | const buf = std.heap.c_allocator.alloc(u8, len) catch return error.SystemResources; | |
| 189 | defer std.heap.c_allocator.free(buf); | |
| 190 | len = buf.len; | |
| 191 | posix.sysctl(&mib, &buf[0], &len, null, 0) catch |err| switch (err) { | |
| 192 | error.PermissionDenied => unreachable, | |
| 193 | error.SystemResources => return error.SystemResources, | |
| 194 | error.NameTooLong => unreachable, | |
| 195 | error.UnknownName => unreachable, | |
| 196 | else => return error.Unexpected, | |
| 197 | }; | |
| 198 | var i: usize = 0; | |
| 199 | while (i < len) { | |
| 200 | const kf: *align(1) std.c.kinfo_file = @ptrCast(&buf[i]); | |
| 201 | if (kf.fd == fd) { | |
| 202 | len = mem.indexOfScalar(u8, &kf.path, 0) orelse max_path_bytes; | |
| 203 | if (len == 0) return error.NameTooLong; | |
| 204 | const result = out_buffer[0..len]; | |
| 205 | @memcpy(result, kf.path[0..len]); | |
| 206 | return result; | |
| 207 | } | |
| 208 | i += @intCast(kf.structsize); | |
| 209 | } | |
| 210 | return error.FileNotFound; | |
| 161 | var kfile: std.c.kinfo_file = undefined; | |
| 162 | kfile.structsize = std.c.KINFO_FILE_SIZE; | |
| 163 | switch (posix.errno(std.c.fcntl(fd, std.c.F.KINFO, @intFromPtr(&kfile)))) { | |
| 164 | .SUCCESS => {}, | |
| 165 | .BADF => return error.FileNotFound, | |
| 166 | else => |err| return posix.unexpectedErrno(err), | |
| 211 | 167 | } |
| 168 | const len = mem.indexOfScalar(u8, &kfile.path, 0) orelse max_path_bytes; | |
| 169 | if (len == 0) return error.NameTooLong; | |
| 170 | const result = out_buffer[0..len]; | |
| 171 | @memcpy(result, kfile.path[0..len]); | |
| 172 | return result; | |
| 212 | 173 | }, |
| 213 | 174 | .dragonfly => { |
| 214 | 175 | @memset(out_buffer[0..max_path_bytes], 0); |
lib/std/posix.zig+1-1| ... | ... | @@ -6590,7 +6590,7 @@ pub const CopyFileRangeError = error{ |
| 6590 | 6590 | /// |
| 6591 | 6591 | /// Maximum offsets on Linux and FreeBSD are `maxInt(i64)`. |
| 6592 | 6592 | 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 { |
| 6593 | if ((comptime builtin.os.isAtLeast(.freebsd, .{ .major = 13, .minor = 0, .patch = 0 }) orelse false) or | |
| 6593 | if (builtin.os.tag == .freebsd or | |
| 6594 | 6594 | (comptime builtin.os.tag == .linux and std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 }))) |
| 6595 | 6595 | { |
| 6596 | 6596 | var off_in_copy: i64 = @bitCast(off_in); |
test/llvm_targets.zig-3| ... | ... | @@ -71,8 +71,6 @@ const targets = [_]std.Target.Query{ |
| 71 | 71 | // .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabi }, |
| 72 | 72 | // .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabihf }, |
| 73 | 73 | |
| 74 | .{ .cpu_arch = .armeb, .os_tag = .freebsd, .abi = .eabi }, | |
| 75 | .{ .cpu_arch = .armeb, .os_tag = .freebsd, .abi = .eabihf }, | |
| 76 | 74 | .{ .cpu_arch = .armeb, .os_tag = .freestanding, .abi = .eabi }, |
| 77 | 75 | .{ .cpu_arch = .armeb, .os_tag = .freestanding, .abi = .eabihf }, |
| 78 | 76 | .{ .cpu_arch = .armeb, .os_tag = .linux, .abi = .eabi }, |
| ... | ... | @@ -257,7 +255,6 @@ const targets = [_]std.Target.Query{ |
| 257 | 255 | // .{ .cpu_arch = .sparc, .os_tag = .rtems, .abi = .none }, |
| 258 | 256 | // .{ .cpu_arch = .sparc, .os_tag = .solaris, .abi = .none }, |
| 259 | 257 | |
| 260 | .{ .cpu_arch = .sparc64, .os_tag = .freebsd, .abi = .none }, | |
| 261 | 258 | .{ .cpu_arch = .sparc64, .os_tag = .freestanding, .abi = .none }, |
| 262 | 259 | .{ .cpu_arch = .sparc64, .os_tag = .haiku, .abi = .none }, |
| 263 | 260 | .{ .cpu_arch = .sparc64, .os_tag = .illumos, .abi = .none }, |