From c17396691ce116a949618cb03d740997c7e80788 Mon Sep 17 00:00:00 2001 From: Al Hoang <3811822-hoanga@users.noreply.gitlab.com> Date: Sun, 17 Jan 2021 13:29:00 -0600 Subject: initial support for haiku sync update * add cpu count * use haiku find_directory * add definitions and exports for building in haiku --- lib/std/Thread.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/std/Thread.zig') 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"); }, -- cgit v1.2.3