Skip to content

Commit edc180a

Browse files
committed
Add Haiku support
Uses the poll(2) implementation for Poll and the pipe(2) based implementation for Waker. Perhaps we can do better, but I can't find any proper manuals for the OS outside of a reference to the Posix standard. Hence I only uses APIs available in said standard. Closes #1472 Updates #1702
1 parent beee1d1 commit edc180a

File tree

11 files changed

+30
-6
lines changed

11 files changed

+30
-6
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ jobs:
162162
- x86_64-pc-windows-msvc
163163
- x86_64-unknown-dragonfly
164164
- x86_64-unknown-freebsd
165+
- x86_64-unknown-haiku
165166
- x86_64-unknown-hermit
166167
- x86_64-unknown-illumos
167168
- x86_64-unknown-linux-gnu

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,9 @@ This uses the Windows AFD system to access socket readiness events.
152152

153153
### Unsupported
154154

155-
* Haiku, see [issue #1472]
156155
* Solaris, see [issue #1152]
157156
* Wine, see [issue #1444]
158157

159-
[issue #1472]: https://github.com/tokio-rs/mio/issues/1472
160158
[issue #1152]: https://github.com/tokio-rs/mio/issues/1152
161159
[issue #1444]: https://github.com/tokio-rs/mio/issues/1444
162160

src/poll.rs

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
not(mio_unsupported_force_poll_poll),
44
not(any(
55
target_os = "espidf",
6+
target_os = "haiku",
67
target_os = "hermit",
78
target_os = "nto",
89
target_os = "solaris",
@@ -438,6 +439,7 @@ impl Poll {
438439
not(mio_unsupported_force_poll_poll),
439440
not(any(
440441
target_os = "espidf",
442+
target_os = "haiku",
441443
target_os = "hermit",
442444
target_os = "nto",
443445
target_os = "solaris",
@@ -735,6 +737,7 @@ impl fmt::Debug for Registry {
735737
not(mio_unsupported_force_poll_poll),
736738
not(any(
737739
target_os = "espidf",
740+
target_os = "haiku",
738741
target_os = "hermit",
739742
target_os = "nto",
740743
target_os = "solaris",

src/sys/unix/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ cfg_os_poll! {
3636

3737
cfg_io_source! {
3838
// Both `kqueue` and `epoll` don't need to hold any user space state.
39-
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "hermit", target_os = "nto", target_os = "solaris", target_os = "vita")))]
39+
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "haiku", target_os = "hermit", target_os = "nto", target_os = "solaris", target_os = "vita")))]
4040
mod stateless_io_source {
4141
use std::io;
4242
use std::os::fd::RawFd;
@@ -88,10 +88,10 @@ cfg_os_poll! {
8888
}
8989
}
9090

91-
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "hermit", target_os = "nto", target_os = "solaris", target_os = "vita")))]
91+
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "haiku", target_os = "hermit", target_os = "nto", target_os = "solaris", target_os = "vita")))]
9292
pub(crate) use self::stateless_io_source::IoSourceState;
9393

94-
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "hermit", target_os = "nto", target_os = "solaris", target_os = "vita"))]
94+
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "haiku", target_os = "hermit", target_os = "nto", target_os = "solaris", target_os = "vita"))]
9595
pub(crate) use self::selector::IoSourceState;
9696
}
9797

@@ -102,6 +102,7 @@ cfg_os_poll! {
102102
mio_unsupported_force_waker_pipe,
103103
target_os = "aix",
104104
target_os = "dragonfly",
105+
target_os = "haiku",
105106
target_os = "illumos",
106107
target_os = "netbsd",
107108
target_os = "nto",

src/sys/unix/net.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,17 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
105105
sin_family: libc::AF_INET as libc::sa_family_t,
106106
sin_port: addr.port().to_be(),
107107
sin_addr,
108-
#[cfg(not(target_os = "vita"))]
108+
#[cfg(not(any(target_os = "haiku", target_os = "vita")))]
109109
sin_zero: [0; 8],
110+
#[cfg(target_os = "haiku")]
111+
sin_zero: [0; 24],
110112
#[cfg(target_os = "vita")]
111113
sin_zero: [0; 6],
112114
#[cfg(any(
113115
target_os = "aix",
114116
target_os = "dragonfly",
115117
target_os = "freebsd",
118+
target_os = "haiku",
116119
target_os = "ios",
117120
target_os = "macos",
118121
target_os = "netbsd",
@@ -147,6 +150,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
147150
target_os = "aix",
148151
target_os = "dragonfly",
149152
target_os = "freebsd",
153+
target_os = "haiku",
150154
target_os = "ios",
151155
target_os = "macos",
152156
target_os = "netbsd",

src/sys/unix/pipe.rs

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> {
2828

2929
#[cfg(any(
3030
target_os = "aix",
31+
target_os = "haiku",
3132
target_os = "ios",
3233
target_os = "macos",
3334
target_os = "tvos",
@@ -61,6 +62,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> {
6162
target_os = "android",
6263
target_os = "dragonfly",
6364
target_os = "freebsd",
65+
target_os = "haiku",
6466
target_os = "illumos",
6567
target_os = "ios",
6668
target_os = "linux",

src/sys/unix/selector/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub(crate) use self::epoll::{event, Event, Events, Selector};
2323
#[cfg(any(
2424
mio_unsupported_force_poll_poll,
2525
target_os = "espidf",
26+
target_os = "haiku",
2627
target_os = "hermit",
2728
target_os = "nto",
2829
target_os = "solaris",
@@ -33,6 +34,7 @@ mod poll;
3334
#[cfg(any(
3435
mio_unsupported_force_poll_poll,
3536
target_os = "espidf",
37+
target_os = "haiku",
3638
target_os = "hermit",
3739
target_os = "nto",
3840
target_os = "solaris",
@@ -44,6 +46,7 @@ cfg_io_source! {
4446
#[cfg(any(
4547
mio_unsupported_force_poll_poll,
4648
target_os = "espidf",
49+
target_os = "haiku",
4750
target_os = "hermit",
4851
target_os = "nto",
4952
target_os = "solaris",

src/sys/unix/tcp.rs

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream,
8989
// set `CLOEXEC`.
9090
#[cfg(any(
9191
target_os = "aix",
92+
target_os = "haiku",
9293
target_os = "ios",
9394
target_os = "macos",
9495
target_os = "redox",

src/sys/unix/uds/listener.rs

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So
3535

3636
#[cfg(not(any(
3737
target_os = "aix",
38+
target_os = "haiku",
3839
target_os = "ios",
3940
target_os = "macos",
4041
target_os = "netbsd",
@@ -62,6 +63,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So
6263

6364
#[cfg(any(
6465
target_os = "aix",
66+
target_os = "haiku",
6567
target_os = "ios",
6668
target_os = "macos",
6769
target_os = "netbsd",

src/sys/unix/uds/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ where
8787
{
8888
#[cfg(not(any(
8989
target_os = "aix",
90+
target_os = "haiku",
9091
target_os = "ios",
9192
target_os = "macos",
9293
target_os = "nto",
@@ -110,6 +111,7 @@ where
110111
// there is an error, the file descriptors are closed.
111112
#[cfg(any(
112113
target_os = "aix",
114+
target_os = "haiku",
113115
target_os = "ios",
114116
target_os = "macos",
115117
target_os = "nto",

src/sys/unix/waker.rs

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
)),
1414
not(any(
1515
target_os = "espidf",
16+
target_os = "haiku",
1617
target_os = "hermit",
1718
target_os = "nto",
1819
target_os = "solaris",
@@ -74,6 +75,7 @@ mod fdbased {
7475
)),
7576
not(any(
7677
target_os = "espidf",
78+
target_os = "haiku",
7779
target_os = "hermit",
7880
target_os = "nto",
7981
target_os = "solaris",
@@ -239,6 +241,7 @@ pub use self::kqueue::Waker;
239241
mio_unsupported_force_waker_pipe,
240242
target_os = "aix",
241243
target_os = "dragonfly",
244+
target_os = "haiku",
242245
target_os = "illumos",
243246
target_os = "netbsd",
244247
target_os = "nto",
@@ -294,6 +297,7 @@ mod pipe {
294297
#[cfg(any(
295298
mio_unsupported_force_poll_poll,
296299
target_os = "espidf",
300+
target_os = "haiku",
297301
target_os = "nto",
298302
target_os = "solaris",
299303
target_os = "vita",
@@ -335,6 +339,7 @@ mod pipe {
335339
target_os = "redox",
336340
)
337341
),
342+
target_os = "haiku",
338343
target_os = "nto",
339344
target_os = "solaris",
340345
target_os = "vita",
@@ -344,6 +349,7 @@ pub(crate) use self::pipe::WakerInternal;
344349
#[cfg(any(
345350
mio_unsupported_force_poll_poll,
346351
target_os = "espidf",
352+
target_os = "haiku",
347353
target_os = "hermit",
348354
target_os = "nto",
349355
target_os = "solaris",
@@ -377,6 +383,7 @@ mod poll {
377383
#[cfg(any(
378384
mio_unsupported_force_poll_poll,
379385
target_os = "espidf",
386+
target_os = "haiku",
380387
target_os = "hermit",
381388
target_os = "nto",
382389
target_os = "solaris",

0 commit comments

Comments
 (0)