| ... | @@ -491,6 +491,16 @@ pub const Thread = struct { | ... | @@ -491,6 +491,16 @@ pub const Thread = struct { |
| 491 | if (std.Target.current.os.tag == .windows) { | 491 | if (std.Target.current.os.tag == .windows) { |
| 492 | return os.windows.peb().NumberOfProcessors; | 492 | return os.windows.peb().NumberOfProcessors; |
| 493 | } | 493 | } |
| | 494 | if (std.Target.current.os.tag == .openbsd) { |
| | 495 | var count: c_int = undefined; |
| | 496 | var count_size: usize = @sizeOf(c_int); |
| | 497 | const mib = [_]c_int{ os.CTL_HW, os.HW_NCPUONLINE }; |
| | 498 | os.sysctl(&mib, &count, &count_size, null, 0) catch |err| switch (err) { |
| | 499 | error.NameTooLong, error.UnknownName => unreachable, |
| | 500 | else => |e| return e, |
| | 501 | }; |
| | 502 | return @intCast(usize, count); |
| | 503 | } |
| 494 | var count: c_int = undefined; | 504 | var count: c_int = undefined; |
| 495 | var count_len: usize = @sizeOf(c_int); | 505 | var count_len: usize = @sizeOf(c_int); |
| 496 | const name = if (comptime std.Target.current.isDarwin()) "hw.logicalcpu" else "hw.ncpu"; | 506 | const name = if (comptime std.Target.current.isDarwin()) "hw.logicalcpu" else "hw.ncpu"; |