mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
Merge pull request #10073 from hoanga/haiku-support-build2
more haiku support
This commit is contained in:
commit
36c8adf589
@ -577,11 +577,12 @@ const PosixThreadImpl = struct {
|
||||
};
|
||||
},
|
||||
.haiku => {
|
||||
var count: u32 = undefined;
|
||||
var system_info: os.system_info = undefined;
|
||||
_ = os.system.get_system_info(&system_info); // always returns B_OK
|
||||
count = system_info.cpu_count;
|
||||
return @intCast(usize, count);
|
||||
var system_info: os.system.system_info = undefined;
|
||||
const rc = os.system.get_system_info(&system_info); // always returns B_OK
|
||||
return switch (os.errno(rc)) {
|
||||
.SUCCESS => @intCast(usize, system_info.cpu_count),
|
||||
else => |err| os.unexpectedErrno(err),
|
||||
};
|
||||
},
|
||||
else => {
|
||||
var count: c_int = undefined;
|
||||
|
||||
1023
lib/std/c/haiku.zig
1023
lib/std/c/haiku.zig
File diff suppressed because it is too large
Load Diff
@ -40,6 +40,7 @@ const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{
|
||||
.major = 4,
|
||||
.minor = 14,
|
||||
}) orelse true;
|
||||
const is_haiku = builtin.os.tag == .haiku;
|
||||
|
||||
const Context = struct {
|
||||
init_state: enum(u8) { uninitialized = 0, initialized, failed },
|
||||
@ -72,7 +73,7 @@ fn tlsCsprngFill(_: *c_void, buffer: []u8) void {
|
||||
|
||||
if (wipe_mem.len == 0) {
|
||||
// Not initialized yet.
|
||||
if (want_fork_safety and maybe_have_wipe_on_fork) {
|
||||
if (want_fork_safety and maybe_have_wipe_on_fork or is_haiku) {
|
||||
// Allocate a per-process page, madvise operates with page
|
||||
// granularity.
|
||||
wipe_mem = os.mmap(
|
||||
|
||||
@ -527,13 +527,23 @@ pub const Dir = struct {
|
||||
}
|
||||
|
||||
var stat_info: os.Stat = undefined;
|
||||
_ = os.system._kern_read_stat(
|
||||
const rc = os.system._kern_read_stat(
|
||||
self.dir.fd,
|
||||
&haiku_entry.d_name,
|
||||
false,
|
||||
&stat_info,
|
||||
0,
|
||||
);
|
||||
if (rc != 0) {
|
||||
switch (os.errno(rc)) {
|
||||
.SUCCESS => {},
|
||||
.BADF => unreachable, // Dir is invalid or was opened without iteration ability
|
||||
.FAULT => unreachable,
|
||||
.NOTDIR => unreachable,
|
||||
.INVAL => unreachable,
|
||||
else => |err| return os.unexpectedErrno(err),
|
||||
}
|
||||
}
|
||||
const statmode = stat_info.mode & os.S.IFMT;
|
||||
|
||||
const entry_kind = switch (statmode) {
|
||||
|
||||
@ -3885,6 +3885,15 @@ fn detectLibCFromLibCInstallation(arena: *Allocator, target: Target, lci: *const
|
||||
list.appendAssumeCapacity(shared_dir);
|
||||
}
|
||||
}
|
||||
if (target.os.tag == .haiku) {
|
||||
const include_dir_path = lci.include_dir orelse return error.LibCInstallationNotAvailable;
|
||||
const os_dir = try std.fs.path.join(arena, &[_][]const u8{ include_dir_path, "os" });
|
||||
list.appendAssumeCapacity(os_dir);
|
||||
|
||||
const config_dir = try std.fs.path.join(arena, &[_][]const u8{ include_dir_path, "config" });
|
||||
list.appendAssumeCapacity(config_dir);
|
||||
}
|
||||
|
||||
return LibCDirs{
|
||||
.libc_include_dir_list = list.items,
|
||||
.libc_installation = lci,
|
||||
|
||||
@ -321,7 +321,7 @@ pub const LibCInstallation = struct {
|
||||
const sys_include_dir_example_file = if (is_windows)
|
||||
"sys\\types.h"
|
||||
else if (is_haiku)
|
||||
"posix/errno.h"
|
||||
"errno.h"
|
||||
else
|
||||
"sys/errno.h";
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user