aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Thread.zig
diff options
context:
space:
mode:
authorAl Hoang <3811822-hoanga@users.noreply.gitlab.com>2021-01-17 13:29:00 -0600
committerAndrew Kelley <andrew@ziglang.org>2021-02-25 16:41:42 -0700
commitc17396691ce116a949618cb03d740997c7e80788 (patch)
treea7d9f8fbf9cb4b765609af2ec842b17e6f0e7be5 /lib/std/Thread.zig
parent6b0372229da4fa4cf32f0ee1eb079f530554b094 (diff)
downloadzig-c17396691ce116a949618cb03d740997c7e80788.tar.gz
zig-c17396691ce116a949618cb03d740997c7e80788.zip
initial support for haiku sync update
* add cpu count * use haiku find_directory * add definitions and exports for building in haiku
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");
},