Merge pull request #10073 from hoanga/haiku-support-build2

more haiku support
This commit is contained in:
Andrew Kelley 2021-11-24 18:42:30 -08:00 committed by GitHub
commit 36c8adf589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 346 additions and 714 deletions

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -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(

View File

@ -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) {

View File

@ -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,

View File

@ -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";