authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-03-26 03:23:05+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-03-27 01:55:42-04:00
log77ff6bc656e497c81a0320cb1e99be0e5e596894
tree3d9e848c53fd30467bdc7998b5e209ff73937a6c
parent7684423c0846acb553d8287d0edc8fe6b1f8ca57

haiku: fix poll definitions


2 files changed, 35 insertions(+), 29 deletions(-)

lib/std/c/haiku.zig+34-25
...@@ -110,21 +110,6 @@ pub const socklen_t = u32;...@@ -110,21 +110,6 @@ pub const socklen_t = u32;
110// Modes and flags for dlopen()110// Modes and flags for dlopen()
111// include/dlfcn.h111// include/dlfcn.h
112112
113pub const POLL = struct {
114 /// input available
115 pub const IN = 70;
116 /// output available
117 pub const OUT = 71;
118 /// input message available
119 pub const MSG = 72;
120 /// I/O error
121 pub const ERR = 73;
122 /// high priority input available
123 pub const PRI = 74;
124 /// device disconnected
125 pub const HUP = 75;
126};
127
128pub const RTLD = struct {113pub const RTLD = struct {
129 /// relocations are performed as needed114 /// relocations are performed as needed
130 pub const LAZY = 0;115 pub const LAZY = 0;
...@@ -177,14 +162,6 @@ pub const msghdr = extern struct {...@@ -177,14 +162,6 @@ pub const msghdr = extern struct {
177pub const off_t = i64;162pub const off_t = i64;
178pub const ino_t = u64;163pub const ino_t = u64;
179164
180pub const nfds_t = u32;
181
182pub const pollfd = extern struct {
183 fd: i32,
184 events: i16,
185 revents: i16,
186};
187
188pub const Stat = extern struct {165pub const Stat = extern struct {
189 dev: i32,166 dev: i32,
190 ino: u64,167 ino: u64,
...@@ -427,7 +404,39 @@ pub const W = struct {...@@ -427,7 +404,39 @@ pub const W = struct {
427 }404 }
428};405};
429406
430// posix/signal.h407// /system/develop/headers/posix/poll.h
408
409pub const nfds_t = usize;
410
411pub const pollfd = extern struct {
412 fd: i32,
413 events: i16,
414 revents: i16,
415};
416
417pub const POLL = struct {
418 /// any readable data available
419 pub const IN = 0x0001;
420 /// file descriptor is writeable
421 pub const OUT = 0x0002;
422 pub const RDNORM = IN;
423 pub const WRNORM = OUT;
424 /// priority readable data
425 pub const RDBAND = 0x0008;
426 /// priority data can be written
427 pub const WRBAND = 0x0010;
428 /// high priority readable data
429 pub const PRI = 0x0020;
430
431 /// errors pending
432 pub const ERR = 0x0004;
433 /// disconnected
434 pub const HUP = 0x0080;
435 /// invalid file descriptor
436 pub const NVAL = 0x1000;
437};
438
439// /system/develop/headers/posix/signal.h
431440
432pub const sigset_t = u64;441pub const sigset_t = u64;
433pub const empty_sigset: sigset_t = 0;442pub const empty_sigset: sigset_t = 0;
...@@ -548,7 +557,7 @@ pub const ucontext_t = extern struct {...@@ -548,7 +557,7 @@ pub const ucontext_t = extern struct {
548 mcontext: mcontext_t,557 mcontext: mcontext_t,
549};558};
550559
551// arch/*/signal.h560// /system/develop/headers/posix/arch/*/signal.h
552561
553pub const vregs = switch (builtin.cpu.arch) {562pub const vregs = switch (builtin.cpu.arch) {
554 .arm, .thumb => extern struct {563 .arm, .thumb => extern struct {
lib/std/io.zig+1-4
...@@ -610,10 +610,7 @@ pub fn Poller(comptime StreamEnum: type) type {...@@ -610,10 +610,7 @@ pub fn Poller(comptime StreamEnum: type) type {
610 // allocate grows exponentially.610 // allocate grows exponentially.
611 const bump_amt = 512;611 const bump_amt = 512;
612612
613 const err_mask = switch (builtin.target.os.tag) {613 const err_mask = posix.POLL.ERR | posix.POLL.NVAL | posix.POLL.HUP;
614 .haiku => posix.POLL.ERR | posix.POLL.HUP,
615 else => posix.POLL.ERR | posix.POLL.NVAL | posix.POLL.HUP,
616 };
617614
618 const events_len = try posix.poll(&self.poll_fds, if (nanoseconds) |ns|615 const events_len = try posix.poll(&self.poll_fds, if (nanoseconds) |ns|
619 std.math.cast(i32, ns / std.time.ns_per_ms) orelse std.math.maxInt(i32)616 std.math.cast(i32, ns / std.time.ns_per_ms) orelse std.math.maxInt(i32)