authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-27 14:12:50-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-27 14:12:50-04:00
log06435535d3e40e4676e98009fad136f98fffbf2e
treea72055c4cce2869fa81f12d621560d6bec436f62
parentf1610f6c1ddbb5c2b42d2ecac433b8eff11d5a3a
signature Commit is signed but in an unrecognized format.

fixes for darwin


7 files changed, 46 insertions(+), 55 deletions(-)

std/child_process.zig+2-2
...@@ -47,7 +47,7 @@ pub const ChildProcess = struct {...@@ -47,7 +47,7 @@ pub const ChildProcess = struct {
47 /// Set to change the current working directory when spawning the child process.47 /// Set to change the current working directory when spawning the child process.
48 pub cwd: ?[]const u8,48 pub cwd: ?[]const u8,
4949
50 err_pipe: if (os.windows.is_the_target) void else [2]i32,50 err_pipe: if (os.windows.is_the_target) void else [2]os.fd_t,
51 llnode: if (os.windows.is_the_target) void else LinkedList(*ChildProcess).Node,51 llnode: if (os.windows.is_the_target) void else LinkedList(*ChildProcess).Node,
5252
53 pub const SpawnError = error{OutOfMemory} || os.ExecveError || os.SetIdError ||53 pub const SpawnError = error{OutOfMemory} || os.ExecveError || os.SetIdError ||
...@@ -701,7 +701,7 @@ fn windowsMakePipeOut(rd: *?windows.HANDLE, wr: *?windows.HANDLE, sattr: *const...@@ -701,7 +701,7 @@ fn windowsMakePipeOut(rd: *?windows.HANDLE, wr: *?windows.HANDLE, sattr: *const
701 wr.* = wr_h;701 wr.* = wr_h;
702}702}
703703
704fn destroyPipe(pipe: [2]i32) void {704fn destroyPipe(pipe: [2]os.fd_t) void {
705 os.close(pipe[0]);705 os.close(pipe[0]);
706 os.close(pipe[1]);706 os.close(pipe[1]);
707}707}
std/event/loop.zig+12-12
...@@ -222,10 +222,10 @@ pub const Loop = struct {...@@ -222,10 +222,10 @@ pub const Loop = struct {
222 }222 }
223 },223 },
224 .macosx, .freebsd, .netbsd => {224 .macosx, .freebsd, .netbsd => {
225 self.os_data.kqfd = try os.bsdKQueue();225 self.os_data.kqfd = try os.kqueue();
226 errdefer os.close(self.os_data.kqfd);226 errdefer os.close(self.os_data.kqfd);
227227
228 self.os_data.fs_kqfd = try os.bsdKQueue();228 self.os_data.fs_kqfd = try os.kqueue();
229 errdefer os.close(self.os_data.fs_kqfd);229 errdefer os.close(self.os_data.fs_kqfd);
230230
231 self.os_data.fs_queue = std.atomic.Queue(fs.Request).init();231 self.os_data.fs_queue = std.atomic.Queue(fs.Request).init();
...@@ -264,7 +264,7 @@ pub const Loop = struct {...@@ -264,7 +264,7 @@ pub const Loop = struct {
264 };264 };
265 self.available_eventfd_resume_nodes.push(eventfd_node);265 self.available_eventfd_resume_nodes.push(eventfd_node);
266 const kevent_array = (*const [1]os.Kevent)(&eventfd_node.data.kevent);266 const kevent_array = (*const [1]os.Kevent)(&eventfd_node.data.kevent);
267 _ = try os.bsdKEvent(self.os_data.kqfd, kevent_array, empty_kevs, null);267 _ = try os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null);
268 eventfd_node.data.kevent.flags = os.EV_CLEAR | os.EV_ENABLE;268 eventfd_node.data.kevent.flags = os.EV_CLEAR | os.EV_ENABLE;
269 eventfd_node.data.kevent.fflags = os.NOTE_TRIGGER;269 eventfd_node.data.kevent.fflags = os.NOTE_TRIGGER;
270 }270 }
...@@ -280,7 +280,7 @@ pub const Loop = struct {...@@ -280,7 +280,7 @@ pub const Loop = struct {
280 .udata = @ptrToInt(&self.final_resume_node),280 .udata = @ptrToInt(&self.final_resume_node),
281 };281 };
282 const final_kev_arr = (*const [1]os.Kevent)(&self.os_data.final_kevent);282 const final_kev_arr = (*const [1]os.Kevent)(&self.os_data.final_kevent);
283 _ = try os.bsdKEvent(self.os_data.kqfd, final_kev_arr, empty_kevs, null);283 _ = try os.kevent(self.os_data.kqfd, final_kev_arr, empty_kevs, null);
284 self.os_data.final_kevent.flags = os.EV_ENABLE;284 self.os_data.final_kevent.flags = os.EV_ENABLE;
285 self.os_data.final_kevent.fflags = os.NOTE_TRIGGER;285 self.os_data.final_kevent.fflags = os.NOTE_TRIGGER;
286286
...@@ -315,7 +315,7 @@ pub const Loop = struct {...@@ -315,7 +315,7 @@ pub const Loop = struct {
315315
316 var extra_thread_index: usize = 0;316 var extra_thread_index: usize = 0;
317 errdefer {317 errdefer {
318 _ = os.bsdKEvent(self.os_data.kqfd, final_kev_arr, empty_kevs, null) catch unreachable;318 _ = os.kevent(self.os_data.kqfd, final_kev_arr, empty_kevs, null) catch unreachable;
319 while (extra_thread_index != 0) {319 while (extra_thread_index != 0) {
320 extra_thread_index -= 1;320 extra_thread_index -= 1;
321 self.extra_threads[extra_thread_index].wait();321 self.extra_threads[extra_thread_index].wait();
...@@ -474,7 +474,7 @@ pub const Loop = struct {...@@ -474,7 +474,7 @@ pub const Loop = struct {
474 };474 };
475 const kevent_array = (*const [1]os.Kevent)(&kev);475 const kevent_array = (*const [1]os.Kevent)(&kev);
476 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];476 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];
477 _ = try os.bsdKEvent(self.os_data.kqfd, kevent_array, empty_kevs, null);477 _ = try os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null);
478 }478 }
479479
480 pub fn bsdRemoveKev(self: *Loop, ident: usize, filter: i16) void {480 pub fn bsdRemoveKev(self: *Loop, ident: usize, filter: i16) void {
...@@ -488,7 +488,7 @@ pub const Loop = struct {...@@ -488,7 +488,7 @@ pub const Loop = struct {
488 };488 };
489 const kevent_array = (*const [1]os.Kevent)(&kev);489 const kevent_array = (*const [1]os.Kevent)(&kev);
490 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];490 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];
491 _ = os.bsdKEvent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch undefined;491 _ = os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch undefined;
492 self.finishOneEvent();492 self.finishOneEvent();
493 }493 }
494494
...@@ -504,7 +504,7 @@ pub const Loop = struct {...@@ -504,7 +504,7 @@ pub const Loop = struct {
504 .macosx, .freebsd, .netbsd => {504 .macosx, .freebsd, .netbsd => {
505 const kevent_array = (*const [1]os.Kevent)(&eventfd_node.kevent);505 const kevent_array = (*const [1]os.Kevent)(&eventfd_node.kevent);
506 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];506 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];
507 _ = os.bsdKEvent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch {507 _ = os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch {
508 self.next_tick_queue.unget(next_tick_node);508 self.next_tick_queue.unget(next_tick_node);
509 self.available_eventfd_resume_nodes.push(resume_stack_node);509 self.available_eventfd_resume_nodes.push(resume_stack_node);
510 return;510 return;
...@@ -634,7 +634,7 @@ pub const Loop = struct {...@@ -634,7 +634,7 @@ pub const Loop = struct {
634 const final_kevent = (*const [1]os.Kevent)(&self.os_data.final_kevent);634 const final_kevent = (*const [1]os.Kevent)(&self.os_data.final_kevent);
635 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];635 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];
636 // cannot fail because we already added it and this just enables it636 // cannot fail because we already added it and this just enables it
637 _ = os.bsdKEvent(self.os_data.kqfd, final_kevent, empty_kevs, null) catch unreachable;637 _ = os.kevent(self.os_data.kqfd, final_kevent, empty_kevs, null) catch unreachable;
638 return;638 return;
639 },639 },
640 .windows => {640 .windows => {
...@@ -690,7 +690,7 @@ pub const Loop = struct {...@@ -690,7 +690,7 @@ pub const Loop = struct {
690 .macosx, .freebsd, .netbsd => {690 .macosx, .freebsd, .netbsd => {
691 var eventlist: [1]os.Kevent = undefined;691 var eventlist: [1]os.Kevent = undefined;
692 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];692 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];
693 const count = os.bsdKEvent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable;693 const count = os.kevent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable;
694 for (eventlist[0..count]) |ev| {694 for (eventlist[0..count]) |ev| {
695 const resume_node = @intToPtr(*ResumeNode, ev.udata);695 const resume_node = @intToPtr(*ResumeNode, ev.udata);
696 const handle = resume_node.handle;696 const handle = resume_node.handle;
...@@ -753,7 +753,7 @@ pub const Loop = struct {...@@ -753,7 +753,7 @@ pub const Loop = struct {
753 builtin.Os.macosx, builtin.Os.freebsd, builtin.Os.netbsd => {753 builtin.Os.macosx, builtin.Os.freebsd, builtin.Os.netbsd => {
754 const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wake);754 const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wake);
755 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];755 const empty_kevs = ([*]os.Kevent)(undefined)[0..0];
756 _ = os.bsdKEvent(self.os_data.fs_kqfd, fs_kevs, empty_kevs, null) catch unreachable;756 _ = os.kevent(self.os_data.fs_kqfd, fs_kevs, empty_kevs, null) catch unreachable;
757 },757 },
758 builtin.Os.linux => {758 builtin.Os.linux => {
759 _ = @atomicRmw(i32, &self.os_data.fs_queue_item, AtomicRmwOp.Xchg, 1, AtomicOrder.SeqCst);759 _ = @atomicRmw(i32, &self.os_data.fs_queue_item, AtomicRmwOp.Xchg, 1, AtomicOrder.SeqCst);
...@@ -823,7 +823,7 @@ pub const Loop = struct {...@@ -823,7 +823,7 @@ pub const Loop = struct {
823 builtin.Os.macosx, builtin.Os.freebsd, builtin.Os.netbsd => {823 builtin.Os.macosx, builtin.Os.freebsd, builtin.Os.netbsd => {
824 const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wait);824 const fs_kevs = (*const [1]os.Kevent)(&self.os_data.fs_kevent_wait);
825 var out_kevs: [1]os.Kevent = undefined;825 var out_kevs: [1]os.Kevent = undefined;
826 _ = os.bsdKEvent(self.os_data.fs_kqfd, fs_kevs, out_kevs[0..], null) catch unreachable;826 _ = os.kevent(self.os_data.fs_kqfd, fs_kevs, out_kevs[0..], null) catch unreachable;
827 },827 },
828 else => @compileError("Unsupported OS"),828 else => @compileError("Unsupported OS"),
829 }829 }
std/fs.zig+6-6
...@@ -509,7 +509,7 @@ pub const Dir = struct {...@@ -509,7 +509,7 @@ pub const Dir = struct {
509 }509 }
510 }510 }
511 self.handle.index = 0;511 self.handle.index = 0;
512 self.handle.end_index = @intCast(usize, result);512 self.handle.end_index = @intCast(usize, rc);
513 break;513 break;
514 }514 }
515 }515 }
...@@ -694,7 +694,7 @@ pub fn readLinkC(pathname: [*]const u8, buffer: *[os.PATH_MAX]u8) ![]u8 {...@@ -694,7 +694,7 @@ pub fn readLinkC(pathname: [*]const u8, buffer: *[os.PATH_MAX]u8) ![]u8 {
694 return os.readlinkC(pathname, buffer);694 return os.readlinkC(pathname, buffer);
695}695}
696696
697pub const OpenSelfExeError = os.OpenError || os.windows.CreateFileError;697pub const OpenSelfExeError = os.OpenError || os.windows.CreateFileError || SelfExePathError;
698698
699pub fn openSelfExe() OpenSelfExeError!File {699pub fn openSelfExe() OpenSelfExeError!File {
700 if (os.linux.is_the_target) {700 if (os.linux.is_the_target) {
...@@ -730,10 +730,10 @@ pub const SelfExePathError = os.ReadLinkError || os.SysCtlError;...@@ -730,10 +730,10 @@ pub const SelfExePathError = os.ReadLinkError || os.SysCtlError;
730/// On Linux, depends on procfs being mounted. If the currently executing binary has730/// On Linux, depends on procfs being mounted. If the currently executing binary has
731/// been deleted, the file path looks something like `/a/b/c/exe (deleted)`.731/// been deleted, the file path looks something like `/a/b/c/exe (deleted)`.
732/// TODO make the return type of this a null terminated pointer732/// TODO make the return type of this a null terminated pointer
733pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) ![]u8 {733pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) SelfExePathError![]u8 {
734 if (os.darwin.is_the_target) {734 if (os.darwin.is_the_target) {
735 var u32_len: u32 = out_buffer.len;735 var u32_len: u32 = out_buffer.len;
736 const rc = c._NSGetExecutablePath(out_buffer, &u32_len);736 const rc = std.c._NSGetExecutablePath(out_buffer, &u32_len);
737 if (rc != 0) return error.NameTooLong;737 if (rc != 0) return error.NameTooLong;
738 return mem.toSlice(u8, out_buffer);738 return mem.toSlice(u8, out_buffer);
739 }739 }
...@@ -765,13 +765,13 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) ![]u8 {...@@ -765,13 +765,13 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) ![]u8 {
765}765}
766766
767/// Same as `selfExePath` except the result is UTF16LE-encoded.767/// Same as `selfExePath` except the result is UTF16LE-encoded.
768pub fn selfExePathW(out_buffer: *[os.windows.PATH_MAX_WIDE]u16) ![]u16 {768pub fn selfExePathW(out_buffer: *[os.windows.PATH_MAX_WIDE]u16) SelfExePathError![]u16 {
769 return os.windows.GetModuleFileNameW(null, out_buffer, out_buffer.len);769 return os.windows.GetModuleFileNameW(null, out_buffer, out_buffer.len);
770}770}
771771
772/// `selfExeDirPath` except allocates the result on the heap.772/// `selfExeDirPath` except allocates the result on the heap.
773/// Caller owns returned memory.773/// Caller owns returned memory.
774pub fn selfExeDirPathAlloc(allocator: *Allocator) ![]u8 {774pub fn selfExeDirPathAlloc(allocator: *Allocator) SelfExePathError![]u8 {
775 var buf: [MAX_PATH_BYTES]u8 = undefined;775 var buf: [MAX_PATH_BYTES]u8 = undefined;
776 return mem.dupe(allocator, u8, try selfExeDirPath(&buf));776 return mem.dupe(allocator, u8, try selfExeDirPath(&buf));
777}777}
std/os.zig+23-10
...@@ -297,8 +297,9 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) ReadError!usize {...@@ -297,8 +297,9 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) ReadError!usize {
297 const err = darwin.getErrno(rc);297 const err = darwin.getErrno(rc);
298 switch (err) {298 switch (err) {
299 0 => {299 0 => {
300 off += rc;300 const amt_read = @bitCast(usize, rc);
301 inner_off += rc;301 off += amt_read;
302 inner_off += amt_read;
302 if (inner_off == v.iov_len) {303 if (inner_off == v.iov_len) {
303 iov_i += 1;304 iov_i += 1;
304 inner_off = 0;305 inner_off = 0;
...@@ -421,8 +422,9 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) WriteError!void...@@ -421,8 +422,9 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) WriteError!void
421 const err = darwin.getErrno(rc);422 const err = darwin.getErrno(rc);
422 switch (err) {423 switch (err) {
423 0 => {424 0 => {
424 off += rc;425 const amt_written = @bitCast(usize, rc);
425 inner_off += rc;426 off += amt_written;
427 inner_off += amt_written;
426 if (inner_off == v.iov_len) {428 if (inner_off == v.iov_len) {
427 iov_i += 1;429 iov_i += 1;
428 inner_off = 0;430 inner_off = 0;
...@@ -1205,8 +1207,8 @@ pub fn isatty(handle: fd_t) bool {...@@ -1205,8 +1207,8 @@ pub fn isatty(handle: fd_t) bool {
1205 @compileError("TODO implement std.os.isatty for WASI");1207 @compileError("TODO implement std.os.isatty for WASI");
1206 }1208 }
1207 if (linux.is_the_target) {1209 if (linux.is_the_target) {
1208 var wsz: system.winsize = undefined;1210 var wsz: linux.winsize = undefined;
1209 return system.syscall3(system.SYS_ioctl, @bitCast(usize, isize(handle)), TIOCGWINSZ, @ptrToInt(&wsz)) == 0;1211 return linux.syscall3(linux.SYS_ioctl, @bitCast(usize, isize(handle)), linux.TIOCGWINSZ, @ptrToInt(&wsz)) == 0;
1210 }1212 }
1211 unreachable;1213 unreachable;
1212}1214}
...@@ -1778,6 +1780,10 @@ pub const KEventError = error{...@@ -1778,6 +1780,10 @@ pub const KEventError = error{
17781780
1779 /// The specified process to attach to does not exist.1781 /// The specified process to attach to does not exist.
1780 ProcessNotFound,1782 ProcessNotFound,
1783
1784 /// changelist or eventlist had too many items on it.
1785 /// TODO remove this possibility
1786 Overflow,
1781};1787};
17821788
1783pub fn kevent(1789pub fn kevent(
...@@ -1787,9 +1793,16 @@ pub fn kevent(...@@ -1787,9 +1793,16 @@ pub fn kevent(
1787 timeout: ?*const timespec,1793 timeout: ?*const timespec,
1788) KEventError!usize {1794) KEventError!usize {
1789 while (true) {1795 while (true) {
1790 const rc = system.kevent(kq, changelist, eventlist, timeout);1796 const rc = system.kevent(
1797 kq,
1798 changelist.ptr,
1799 try math.cast(c_int, changelist.len),
1800 eventlist.ptr,
1801 try math.cast(c_int, eventlist.len),
1802 timeout,
1803 );
1791 switch (errno(rc)) {1804 switch (errno(rc)) {
1792 0 => return rc,1805 0 => return @intCast(usize, rc),
1793 EACCES => return error.AccessDenied,1806 EACCES => return error.AccessDenied,
1794 EFAULT => unreachable,1807 EFAULT => unreachable,
1795 EBADF => unreachable, // Always a race condition.1808 EBADF => unreachable, // Always a race condition.
...@@ -2028,7 +2041,7 @@ pub const PipeError = error{...@@ -2028,7 +2041,7 @@ pub const PipeError = error{
20282041
2029/// Creates a unidirectional data channel that can be used for interprocess communication.2042/// Creates a unidirectional data channel that can be used for interprocess communication.
2030pub fn pipe() PipeError![2]fd_t {2043pub fn pipe() PipeError![2]fd_t {
2031 var fds: [2]i32 = undefined;2044 var fds: [2]fd_t = undefined;
2032 switch (errno(system.pipe(&fds))) {2045 switch (errno(system.pipe(&fds))) {
2033 0 => return fds,2046 0 => return fds,
2034 EINVAL => unreachable, // Invalid parameters to pipe()2047 EINVAL => unreachable, // Invalid parameters to pipe()
...@@ -2040,7 +2053,7 @@ pub fn pipe() PipeError![2]fd_t {...@@ -2040,7 +2053,7 @@ pub fn pipe() PipeError![2]fd_t {
2040}2053}
20412054
2042pub fn pipe2(flags: u32) PipeError![2]fd_t {2055pub fn pipe2(flags: u32) PipeError![2]fd_t {
2043 var fds: [2]i32 = undefined;2056 var fds: [2]fd_t = undefined;
2044 switch (errno(system.pipe2(&fds, flags))) {2057 switch (errno(system.pipe2(&fds, flags))) {
2045 0 => return fds,2058 0 => return fds,
2046 EINVAL => unreachable, // Invalid flags2059 EINVAL => unreachable, // Invalid flags
std/os/bits/darwin.zig+1-23
...@@ -1,32 +1,10 @@...@@ -1,32 +1,10 @@
1const std = @import("../../std.zig");1const std = @import("../../std.zig");
2const assert = std.debug.assert;2const assert = std.debug.assert;
3const maxInt = std.math.maxInt;
34
4pub const fd_t = c_int;5pub const fd_t = c_int;
5pub const pid_t = c_int;6pub const pid_t = c_int;
67
7pub fn sigaction(sig: u5, noalias act: *const Sigaction, noalias oact: ?*Sigaction) usize {
8 assert(sig != SIGKILL);
9 assert(sig != SIGSTOP);
10 var cact = c.Sigaction{
11 .handler = @ptrCast(extern fn (c_int) void, act.handler),
12 .sa_flags = @bitCast(c_int, act.flags),
13 .sa_mask = act.mask,
14 };
15 var coact: c.Sigaction = undefined;
16 const result = errnoWrap(c.sigaction(sig, &cact, &coact));
17 if (result != 0) {
18 return result;
19 }
20 if (oact) |old| {
21 old.* = Sigaction{
22 .handler = @ptrCast(extern fn (i32) void, coact.handler),
23 .flags = @bitCast(u32, coact.sa_flags),
24 .mask = coact.sa_mask,
25 };
26 }
27 return result;
28}
29
30pub const in_port_t = u16;8pub const in_port_t = u16;
31pub const sa_family_t = u8;9pub const sa_family_t = u8;
32pub const socklen_t = u32;10pub const socklen_t = u32;
std/os/bits/windows.zig-1
...@@ -159,5 +159,4 @@ pub const EWOULDBLOCK = 140;...@@ -159,5 +159,4 @@ pub const EWOULDBLOCK = 140;
159// for if branches that aren't taken.159// for if branches that aren't taken.
160pub const SIGKILL = @compileError("Windows libc does not have this");160pub const SIGKILL = @compileError("Windows libc does not have this");
161pub const EDQUOT = @compileError("Windows libc does not have this");161pub const EDQUOT = @compileError("Windows libc does not have this");
162pub const TIOCGWINSZ = @compileError("Windows libc does not have this");
163pub const F_OK = 0;162pub const F_OK = 0;
std/thread.zig+2-1
...@@ -323,6 +323,7 @@ pub const Thread = struct {...@@ -323,6 +323,7 @@ pub const Thread = struct {
323 pub const CpuCountError = error{323 pub const CpuCountError = error{
324 OutOfMemory,324 OutOfMemory,
325 PermissionDenied,325 PermissionDenied,
326 SystemResources,
326 Unexpected,327 Unexpected,
327 };328 };
328329
...@@ -339,7 +340,7 @@ pub const Thread = struct {...@@ -339,7 +340,7 @@ pub const Thread = struct {
339 var count: c_int = undefined;340 var count: c_int = undefined;
340 var count_len: usize = @sizeOf(c_int);341 var count_len: usize = @sizeOf(c_int);
341 const name = if (os.darwin.is_the_target) c"hw.logicalcpu" else c"hw.ncpu";342 const name = if (os.darwin.is_the_target) c"hw.logicalcpu" else c"hw.ncpu";
342 try os.sysctlbyname(name, @ptrCast(*c_void, &count), &count_len, null, 0);343 try os.sysctlbynameC(name, @ptrCast(*c_void, &count), &count_len, null, 0);
343 return @intCast(usize, count);344 return @intCast(usize, count);
344 }345 }
345};346};