| author | |
| committer | |
| log | 96acc204b2c6080f0169ca3721c3b95a433c185b |
| tree | a7dfe641c7ffcf9932d8b749b6d55c0b3a40ae37 |
| parent | d41111d7ef531f6f55a19c56205d6d2f1134c224 |
| parent | 4054d001445098cdb72a02243e13180f1fba6d79 |
| signature |
fix bad return types for BSDs getdents and debitrot openbsd7 files changed, 57 insertions(+), 30 deletions(-)
lib/std/Thread.zig+1-1| ... | ... | @@ -624,7 +624,7 @@ const PosixThreadImpl = struct { |
| 624 | 624 | .openbsd => { |
| 625 | 625 | var count: c_int = undefined; |
| 626 | 626 | var count_size: usize = @sizeOf(c_int); |
| 627 | const mib = [_]c_int{ os.CTL.HW, os.system.HW_NCPUONLINE }; | |
| 627 | const mib = [_]c_int{ os.CTL.HW, os.system.HW.NCPUONLINE }; | |
| 628 | 628 | os.sysctl(&mib, &count, &count_size, null, 0) catch |err| switch (err) { |
| 629 | 629 | error.NameTooLong, error.UnknownName => unreachable, |
| 630 | 630 | else => |e| return e, |
lib/std/c/dragonfly.zig+1-1| ... | ... | @@ -9,7 +9,7 @@ pub fn _errno() *c_int { |
| 9 | 9 | return &errno; |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; | |
| 12 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int; | |
| 13 | 13 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; |
| 14 | 14 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; |
| 15 | 15 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; |
lib/std/c/freebsd.zig+1-1| ... | ... | @@ -75,7 +75,7 @@ pub const _errno = __error; |
| 75 | 75 | |
| 76 | 76 | pub extern "c" var malloc_options: [*:0]const u8; |
| 77 | 77 | |
| 78 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; | |
| 78 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) isize; | |
| 79 | 79 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; |
| 80 | 80 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; |
| 81 | 81 | pub extern "c" fn getentropy(buf_ptr: [*]u8, buf_len: usize) c_int; |
lib/std/c/openbsd.zig+29-26| ... | ... | @@ -16,7 +16,7 @@ pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; |
| 16 | 16 | pub extern "c" fn getthrid() pid_t; |
| 17 | 17 | pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; |
| 18 | 18 | |
| 19 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; | |
| 19 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int; | |
| 20 | 20 | pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; |
| 21 | 21 | |
| 22 | 22 | pub const pthread_mutex_t = extern struct { |
| ... | ... | @@ -1606,31 +1606,34 @@ pub const KERN = struct { |
| 1606 | 1606 | pub const PROC_NENV = 4; |
| 1607 | 1607 | }; |
| 1608 | 1608 | |
| 1609 | pub const HW_MACHINE = 1; | |
| 1610 | pub const HW_MODEL = 2; | |
| 1611 | pub const HW_NCPU = 3; | |
| 1612 | pub const HW_BYTEORDER = 4; | |
| 1613 | pub const HW_PHYSMEM = 5; | |
| 1614 | pub const HW_USERMEM = 6; | |
| 1615 | pub const HW_PAGESIZE = 7; | |
| 1616 | pub const HW_DISKNAMES = 8; | |
| 1617 | pub const HW_DISKSTATS = 9; | |
| 1618 | pub const HW_DISKCOUNT = 10; | |
| 1619 | pub const HW_SENSORS = 11; | |
| 1620 | pub const HW_CPUSPEED = 12; | |
| 1621 | pub const HW_SETPERF = 13; | |
| 1622 | pub const HW_VENDOR = 14; | |
| 1623 | pub const HW_PRODUCT = 15; | |
| 1624 | pub const HW_VERSION = 16; | |
| 1625 | pub const HW_SERIALNO = 17; | |
| 1626 | pub const HW_UUID = 18; | |
| 1627 | pub const HW_PHYSMEM64 = 19; | |
| 1628 | pub const HW_USERMEM64 = 20; | |
| 1629 | pub const HW_NCPUFOUND = 21; | |
| 1630 | pub const HW_ALLOWPOWERDOWN = 22; | |
| 1631 | pub const HW_PERFPOLICY = 23; | |
| 1632 | pub const HW_SMT = 24; | |
| 1633 | pub const HW_NCPUONLINE = 25; | |
| 1609 | pub const HW = struct { | |
| 1610 | pub const MACHINE = 1; | |
| 1611 | pub const MODEL = 2; | |
| 1612 | pub const NCPU = 3; | |
| 1613 | pub const BYTEORDER = 4; | |
| 1614 | pub const PHYSMEM = 5; | |
| 1615 | pub const USERMEM = 6; | |
| 1616 | pub const PAGESIZE = 7; | |
| 1617 | pub const DISKNAMES = 8; | |
| 1618 | pub const DISKSTATS = 9; | |
| 1619 | pub const DISKCOUNT = 10; | |
| 1620 | pub const SENSORS = 11; | |
| 1621 | pub const CPUSPEED = 12; | |
| 1622 | pub const SETPERF = 13; | |
| 1623 | pub const VENDOR = 14; | |
| 1624 | pub const PRODUCT = 15; | |
| 1625 | pub const VERSION = 16; | |
| 1626 | pub const SERIALNO = 17; | |
| 1627 | pub const UUID = 18; | |
| 1628 | pub const PHYSMEM64 = 19; | |
| 1629 | pub const USERMEM64 = 20; | |
| 1630 | pub const NCPUFOUND = 21; | |
| 1631 | pub const ALLOWPOWERDOWN = 22; | |
| 1632 | pub const PERFPOLICY = 23; | |
| 1633 | pub const SMT = 24; | |
| 1634 | pub const NCPUONLINE = 25; | |
| 1635 | pub const POWER = 26; | |
| 1636 | }; | |
| 1634 | 1637 | |
| 1635 | 1638 | /// TODO refines if necessary |
| 1636 | 1639 | pub const PTHREAD_STACK_MIN = switch (builtin.cpu.arch) { |
lib/std/fs.zig+3| ... | ... | @@ -478,6 +478,9 @@ pub const IterableDir = struct { |
| 478 | 478 | .FAULT => unreachable, |
| 479 | 479 | .NOTDIR => unreachable, |
| 480 | 480 | .INVAL => unreachable, |
| 481 | // Introduced in freebsd 13.2: directory unlinked but still open. | |
| 482 | // To be consistent, iteration ends if the directory being iterated is deleted during iteration. | |
| 483 | .NOENT => return null, | |
| 481 | 484 | else => |err| return os.unexpectedErrno(err), |
| 482 | 485 | } |
| 483 | 486 | if (rc == 0) return null; |
lib/std/os.zig+4| ... | ... | @@ -88,6 +88,10 @@ pub const F = system.F; |
| 88 | 88 | pub const FD_CLOEXEC = system.FD_CLOEXEC; |
| 89 | 89 | pub const Flock = system.Flock; |
| 90 | 90 | pub const HOST_NAME_MAX = system.HOST_NAME_MAX; |
| 91 | pub const HW = switch (builtin.os.tag) { | |
| 92 | .openbsd => system.HW, | |
| 93 | else => .{}, | |
| 94 | }; | |
| 91 | 95 | pub const IFNAMESIZE = system.IFNAMESIZE; |
| 92 | 96 | pub const IOV_MAX = system.IOV_MAX; |
| 93 | 97 | pub const IPPROTO = system.IPPROTO; |
lib/std/process.zig+18-1| ... | ... | @@ -1163,7 +1163,7 @@ pub fn totalSystemMemory() TotalSystemMemoryError!usize { |
| 1163 | 1163 | .linux => { |
| 1164 | 1164 | return totalSystemMemoryLinux() catch return error.UnknownTotalSystemMemory; |
| 1165 | 1165 | }, |
| 1166 | .freebsd, .netbsd, .openbsd, .dragonfly, .macos => { | |
| 1166 | .freebsd, .netbsd, .dragonfly, .macos => { | |
| 1167 | 1167 | var physmem: c_ulong = undefined; |
| 1168 | 1168 | var len: usize = @sizeOf(c_ulong); |
| 1169 | 1169 | const name = switch (builtin.os.tag) { |
| ... | ... | @@ -1177,6 +1177,23 @@ pub fn totalSystemMemory() TotalSystemMemoryError!usize { |
| 1177 | 1177 | }; |
| 1178 | 1178 | return @intCast(usize, physmem); |
| 1179 | 1179 | }, |
| 1180 | .openbsd => { | |
| 1181 | const mib: [2]c_int = [_]c_int{ | |
| 1182 | std.os.CTL.HW, | |
| 1183 | std.os.HW.PHYSMEM64, | |
| 1184 | }; | |
| 1185 | var physmem: i64 = undefined; | |
| 1186 | var len: usize = @sizeOf(@TypeOf(physmem)); | |
| 1187 | std.os.sysctl(&mib, &physmem, &len, null, 0) catch |err| switch (err) { | |
| 1188 | error.NameTooLong => unreachable, // constant, known good value | |
| 1189 | error.PermissionDenied => unreachable, // only when setting values, | |
| 1190 | error.SystemResources => unreachable, // memory already on the stack | |
| 1191 | error.UnknownName => unreachable, // constant, known good value | |
| 1192 | else => return error.UnknownTotalSystemMemory, | |
| 1193 | }; | |
| 1194 | assert(physmem >= 0); | |
| 1195 | return @bitCast(usize, physmem); | |
| 1196 | }, | |
| 1180 | 1197 | .windows => { |
| 1181 | 1198 | var sbi: std.os.windows.SYSTEM_BASIC_INFORMATION = undefined; |
| 1182 | 1199 | const rc = std.os.windows.ntdll.NtQuerySystemInformation( |