Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haiku: fix poll definitions #19436

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 34 additions & 25 deletions lib/std/c/haiku.zig
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,6 @@ pub const socklen_t = u32;
// Modes and flags for dlopen()
// include/dlfcn.h

pub const POLL = struct {
/// input available
pub const IN = 70;
/// output available
pub const OUT = 71;
/// input message available
pub const MSG = 72;
/// I/O error
pub const ERR = 73;
/// high priority input available
pub const PRI = 74;
/// device disconnected
pub const HUP = 75;
};

pub const RTLD = struct {
/// relocations are performed as needed
pub const LAZY = 0;
Expand Down Expand Up @@ -177,14 +162,6 @@ pub const msghdr = extern struct {
pub const off_t = i64;
pub const ino_t = u64;

pub const nfds_t = u32;

pub const pollfd = extern struct {
fd: i32,
events: i16,
revents: i16,
};

pub const Stat = extern struct {
dev: i32,
ino: u64,
Expand Down Expand Up @@ -427,7 +404,39 @@ pub const W = struct {
}
};

// posix/signal.h
// /system/develop/headers/posix/poll.h

pub const nfds_t = usize;

pub const pollfd = extern struct {
fd: i32,
events: i16,
revents: i16,
};

pub const POLL = struct {
/// any readable data available
pub const IN = 0x0001;
/// file descriptor is writeable
pub const OUT = 0x0002;
pub const RDNORM = IN;
pub const WRNORM = OUT;
/// priority readable data
pub const RDBAND = 0x0008;
/// priority data can be written
pub const WRBAND = 0x0010;
/// high priority readable data
pub const PRI = 0x0020;

/// errors pending
pub const ERR = 0x0004;
/// disconnected
pub const HUP = 0x0080;
/// invalid file descriptor
pub const NVAL = 0x1000;
};

// /system/develop/headers/posix/signal.h

pub const sigset_t = u64;
pub const empty_sigset: sigset_t = 0;
Expand Down Expand Up @@ -548,7 +557,7 @@ pub const ucontext_t = extern struct {
mcontext: mcontext_t,
};

// arch/*/signal.h
// /system/develop/headers/posix/arch/*/signal.h

pub const vregs = switch (builtin.cpu.arch) {
.arm, .thumb => extern struct {
Expand Down
5 changes: 1 addition & 4 deletions lib/std/io.zig
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,7 @@ pub fn Poller(comptime StreamEnum: type) type {
// allocate grows exponentially.
const bump_amt = 512;

const err_mask = switch (builtin.target.os.tag) {
.haiku => posix.POLL.ERR | posix.POLL.HUP,
else => posix.POLL.ERR | posix.POLL.NVAL | posix.POLL.HUP,
};
const err_mask = posix.POLL.ERR | posix.POLL.NVAL | posix.POLL.HUP;

const events_len = try posix.poll(&self.poll_fds, if (nanoseconds) |ns|
std.math.cast(i32, ns / std.time.ns_per_ms) orelse std.math.maxInt(i32)
Expand Down
14 changes: 7 additions & 7 deletions lib/std/zig/LibCInstallation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,42 +67,42 @@ pub fn parse(
}
inline for (fields, 0..) |field, i| {
if (!found_keys[i].found) {
log.err("missing field: {s}\n", .{field.name});
log.err("missing field: {s}", .{field.name});
return error.ParseError;
}
}
if (self.include_dir == null) {
log.err("include_dir may not be empty\n", .{});
log.err("include_dir may not be empty", .{});
return error.ParseError;
}
if (self.sys_include_dir == null) {
log.err("sys_include_dir may not be empty\n", .{});
log.err("sys_include_dir may not be empty", .{});
return error.ParseError;
}

const os_tag = target.os.tag;
if (self.crt_dir == null and !target.isDarwin()) {
log.err("crt_dir may not be empty for {s}\n", .{@tagName(os_tag)});
log.err("crt_dir may not be empty for {s}", .{@tagName(os_tag)});
return error.ParseError;
}

if (self.msvc_lib_dir == null and os_tag == .windows and target.abi == .msvc) {
log.err("msvc_lib_dir may not be empty for {s}-{s}\n", .{
log.err("msvc_lib_dir may not be empty for {s}-{s}", .{
@tagName(os_tag),
@tagName(target.abi),
});
return error.ParseError;
}
if (self.kernel32_lib_dir == null and os_tag == .windows and target.abi == .msvc) {
log.err("kernel32_lib_dir may not be empty for {s}-{s}\n", .{
log.err("kernel32_lib_dir may not be empty for {s}-{s}", .{
@tagName(os_tag),
@tagName(target.abi),
});
return error.ParseError;
}

if (self.gcc_dir == null and os_tag == .haiku) {
log.err("gcc_dir may not be empty for {s}\n", .{@tagName(os_tag)});
log.err("gcc_dir may not be empty for {s}", .{@tagName(os_tag)});
return error.ParseError;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/std/zig/system.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ fn detectAbiAndDynamicLinker(
error.FileTooBig,
error.Unexpected,
=> |e| {
std.log.warn("Encountered error: {s}, falling back to default ABI and dynamic linker.\n", .{@errorName(e)});
std.log.warn("Encountered error: {s}, falling back to default ABI and dynamic linker.", .{@errorName(e)});
return defaultAbiAndDynamicLinker(cpu, os, query);
},

Expand Down Expand Up @@ -1065,7 +1065,7 @@ fn detectAbiAndDynamicLinker(
error.NameTooLong,
// Finally, we fall back on the standard path.
=> |e| {
std.log.warn("Encountered error: {s}, falling back to default ABI and dynamic linker.\n", .{@errorName(e)});
std.log.warn("Encountered error: {s}, falling back to default ABI and dynamic linker.", .{@errorName(e)});
return defaultAbiAndDynamicLinker(cpu, os, query);
},
};
Expand Down