aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Thread.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/Thread.zig')
-rw-r--r--lib/std/Thread.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
index 80de19fe19..52f625edf4 100644
--- a/lib/std/Thread.zig
+++ b/lib/std/Thread.zig
@@ -504,6 +504,13 @@ pub fn cpuCount() CpuCountError!usize {
};
return @intCast(usize, count);
}
+ if (std.Target.current.os.tag == .haiku) {
+ var count: u32 = undefined;
+ var system_info: os.system_info = undefined;
+ const rc = os.system.get_system_info(&system_info);
+ count = system_info.cpu_count;
+ return @intCast(usize, count);
+ }
var count: c_int = undefined;
var count_len: usize = @sizeOf(c_int);
const name = if (comptime std.Target.current.isDarwin()) "hw.logicalcpu" else "hw.ncpu";
@@ -538,6 +545,9 @@ pub fn getCurrentThreadId() u64 {
.openbsd => {
return @bitCast(u32, c.getthrid());
},
+ .haiku => {
+ return @bitCast(u32, c.find_thread(null));
+ },
else => {
@compileError("getCurrentThreadId not implemented for this platform");
},