Skip to content

Commit 4034872

Browse files
authored
Add support for vita target
1 parent 8eb4010 commit 4034872

File tree

12 files changed

+89
-38
lines changed

12 files changed

+89
-38
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,22 @@ jobs:
145145
run: cargo install --debug cargo-hack
146146
- name: Check all targets
147147
run: make check_all_targets
148+
CheckTier3Targets:
149+
name: Check
150+
runs-on: ubuntu-latest
151+
timeout-minutes: 10
152+
strategy:
153+
fail-fast: false
154+
matrix:
155+
target: ["armv7-sony-vita-newlibeabihf"]
156+
steps:
157+
- uses: actions/checkout@v3
158+
- uses: dtolnay/rust-toolchain@nightly
159+
with:
160+
components: rust-src
161+
- uses: taiki-e/install-action@cargo-hack
162+
- name: Run check
163+
run: cargo hack check -Z build-std=std,panic_abort --feature-powerset --target ${{ matrix.target }}
148164
Sanitizer:
149165
runs-on: ubuntu-latest
150166
timeout-minutes: 10
@@ -172,5 +188,6 @@ jobs:
172188
- Docs
173189
- Rustfmt
174190
- CheckTargets
191+
- CheckTier3Targets
175192
steps:
176193
- run: exit 0

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ net = []
4646
log = { version = "0.4.8", optional = true }
4747

4848
[target.'cfg(unix)'.dependencies]
49-
libc = "0.2.121"
49+
libc = "0.2.149"
5050

5151
[target.'cfg(windows)'.dependencies.windows-sys]
5252
version = "0.48"
@@ -60,7 +60,7 @@ features = [
6060

6161
[target.'cfg(target_os = "wasi")'.dependencies]
6262
wasi = "0.11.0"
63-
libc = "0.2.121"
63+
libc = "0.2.149"
6464

6565
[dev-dependencies]
6666
env_logger = { version = "0.9.3", default-features = false }

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ This uses the Windows AFD system to access socket readiness events.
162162

163163
## Unsupported flags
164164

165-
Mio uses different implementations to support the same functionality dependening
165+
Mio uses different implementations to support the same functionality depending
166166
on the platform. Mio generally uses the "best" implementation possible, where
167167
"best" usually means most efficient for Mio's use case. However this means that
168168
the implementation is often specific to a limited number of platforms, meaning
169-
we often have multiple implemetations for the same functionality. In some cases
169+
we often have multiple implementations for the same functionality. In some cases
170170
it might be required to not use the "best" implementation, but another
171171
implementation Mio supports (on other platforms). **Mio does not officially
172172
support secondary implementations on platforms**, however we do have various cfg

src/poll.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(all(unix, not(mio_unsupported_force_poll_poll)))]
1+
#[cfg(all(unix, not(mio_unsupported_force_poll_poll), not(target_os = "vita")))]
22
use std::os::unix::io::{AsRawFd, RawFd};
33
#[cfg(all(debug_assertions, not(target_os = "wasi")))]
44
use std::sync::atomic::{AtomicBool, Ordering};
@@ -423,7 +423,7 @@ impl Poll {
423423
}
424424
}
425425

426-
#[cfg(all(unix, not(mio_unsupported_force_poll_poll)))]
426+
#[cfg(all(unix, not(mio_unsupported_force_poll_poll), not(target_os = "vita")))]
427427
impl AsRawFd for Poll {
428428
fn as_raw_fd(&self) -> RawFd {
429429
self.registry.as_raw_fd()
@@ -710,7 +710,7 @@ impl fmt::Debug for Registry {
710710
}
711711
}
712712

713-
#[cfg(all(unix, not(mio_unsupported_force_poll_poll)))]
713+
#[cfg(all(unix, not(mio_unsupported_force_poll_poll), not(target_os = "vita")))]
714714
impl AsRawFd for Registry {
715715
fn as_raw_fd(&self) -> RawFd {
716716
self.selector.as_raw_fd()
@@ -720,7 +720,8 @@ impl AsRawFd for Registry {
720720
cfg_os_poll! {
721721
#[cfg(all(
722722
unix,
723-
not(mio_unsupported_force_poll_poll)
723+
not(mio_unsupported_force_poll_poll),
724+
not(target_os = "vita"),
724725
))]
725726
#[test]
726727
pub fn as_raw_fd() {

src/sys/unix/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ cfg_os_poll! {
3434

3535
cfg_io_source! {
3636
// Both `kqueue` and `epoll` don't need to hold any user space state.
37-
#[cfg(not(mio_unsupported_force_poll_poll))]
37+
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "vita")))]
3838
mod stateless_io_source {
3939
use std::io;
4040
use std::os::unix::io::RawFd;
@@ -87,10 +87,10 @@ cfg_os_poll! {
8787
}
8888
}
8989

90-
#[cfg(not(mio_unsupported_force_poll_poll))]
90+
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "vita")))]
9191
pub(crate) use self::stateless_io_source::IoSourceState;
9292

93-
#[cfg(mio_unsupported_force_poll_poll)]
93+
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "vita"))]
9494
pub(crate) use self::selector::IoSourceState;
9595
}
9696

@@ -105,6 +105,7 @@ cfg_os_poll! {
105105
target_os = "netbsd",
106106
target_os = "openbsd",
107107
target_os = "redox",
108+
target_os = "vita",
108109
))]
109110
pub(crate) mod pipe;
110111
}

src/sys/unix/net.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R
5151
target_os = "tvos",
5252
target_os = "watchos",
5353
target_os = "espidf",
54+
target_os = "vita",
5455
))]
5556
{
5657
if let Err(err) = syscall!(fcntl(socket, libc::F_SETFL, libc::O_NONBLOCK)) {
5758
let _ = syscall!(close(socket));
5859
return Err(err);
5960
}
60-
#[cfg(not(target_os = "espidf"))]
61+
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
6162
if let Err(err) = syscall!(fcntl(socket, libc::F_SETFD, libc::FD_CLOEXEC)) {
6263
let _ = syscall!(close(socket));
6364
return Err(err);
@@ -97,7 +98,10 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
9798
sin_family: libc::AF_INET as libc::sa_family_t,
9899
sin_port: addr.port().to_be(),
99100
sin_addr,
101+
#[cfg(not(target_os = "vita"))]
100102
sin_zero: [0; 8],
103+
#[cfg(target_os = "vita")]
104+
sin_zero: [0; 6],
101105
#[cfg(any(
102106
target_os = "aix",
103107
target_os = "dragonfly",
@@ -109,8 +113,11 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
109113
target_os = "tvos",
110114
target_os = "watchos",
111115
target_os = "espidf",
116+
target_os = "vita",
112117
))]
113118
sin_len: 0,
119+
#[cfg(target_os = "vita")]
120+
sin_vport: addr.port().to_be(),
114121
};
115122

116123
let sockaddr = SocketAddrCRepr { v4: sockaddr_in };
@@ -137,8 +144,11 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
137144
target_os = "tvos",
138145
target_os = "watchos",
139146
target_os = "espidf",
147+
target_os = "vita",
140148
))]
141149
sin6_len: 0,
150+
#[cfg(target_os = "vita")]
151+
sin6_vport: addr.port().to_be(),
142152
#[cfg(target_os = "illumos")]
143153
__sin6_src_id: 0,
144154
};

src/sys/unix/pipe.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> {
1717
target_os = "openbsd",
1818
target_os = "illumos",
1919
target_os = "redox",
20+
target_os = "vita",
2021
))]
2122
unsafe {
2223
if libc::pipe2(fds.as_mut_ptr(), libc::O_CLOEXEC | libc::O_NONBLOCK) != 0 {
@@ -67,6 +68,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> {
6768
target_os = "tvos",
6869
target_os = "watchos",
6970
target_os = "espidf",
71+
target_os = "vita",
7072
)))]
7173
compile_error!("unsupported target for `mio::unix::pipe`");
7274

@@ -556,7 +558,7 @@ impl IntoRawFd for Receiver {
556558
}
557559
}
558560

559-
#[cfg(not(target_os = "illumos"))]
561+
#[cfg(not(any(target_os = "illumos", target_os = "vita")))]
560562
fn set_nonblocking(fd: RawFd, nonblocking: bool) -> io::Result<()> {
561563
let value = nonblocking as libc::c_int;
562564
if unsafe { libc::ioctl(fd, libc::FIONBIO, &value) } == -1 {
@@ -566,7 +568,7 @@ fn set_nonblocking(fd: RawFd, nonblocking: bool) -> io::Result<()> {
566568
}
567569
}
568570

569-
#[cfg(target_os = "illumos")]
571+
#[cfg(any(target_os = "illumos", target_os = "vita"))]
570572
fn set_nonblocking(fd: RawFd, nonblocking: bool) -> io::Result<()> {
571573
let flags = unsafe { libc::fcntl(fd, libc::F_GETFL) };
572574
if flags < 0 {

src/sys/unix/selector/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ mod epoll;
2020
))]
2121
pub(crate) use self::epoll::{event, Event, Events, Selector};
2222

23-
#[cfg(mio_unsupported_force_poll_poll)]
23+
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "vita"))]
2424
mod poll;
2525

26-
#[cfg(mio_unsupported_force_poll_poll)]
26+
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "vita"))]
2727
pub(crate) use self::poll::{event, Event, Events, IoSourceState, Selector};
2828

2929
#[cfg(all(

src/sys/unix/tcp.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream,
8989
target_os = "tvos",
9090
target_os = "watchos",
9191
target_os = "espidf",
92+
target_os = "vita",
9293
all(target_arch = "x86", target_os = "android"),
9394
))]
9495
let stream = {
@@ -99,11 +100,15 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream,
99100
))
100101
.map(|socket| unsafe { net::TcpStream::from_raw_fd(socket) })
101102
.and_then(|s| {
102-
#[cfg(not(target_os = "espidf"))]
103+
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
103104
syscall!(fcntl(s.as_raw_fd(), libc::F_SETFD, libc::FD_CLOEXEC))?;
104105

105106
// See https://github.com/tokio-rs/mio/issues/1450
106-
#[cfg(any(all(target_arch = "x86", target_os = "android"), target_os = "espidf",))]
107+
#[cfg(any(
108+
all(target_arch = "x86", target_os = "android"),
109+
target_os = "espidf",
110+
target_os = "vita",
111+
))]
107112
syscall!(fcntl(s.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK))?;
108113

109114
Ok(s)

src/sys/unix/uds/listener.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So
5252
target_os = "tvos",
5353
target_os = "watchos",
5454
target_os = "espidf",
55+
target_os = "vita",
5556
// Android x86's seccomp profile forbids calls to `accept4(2)`
5657
// See https://github.com/tokio-rs/mio/issues/1445 for details
5758
all(target_arch = "x86", target_os = "android"),
@@ -76,6 +77,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So
7677
target_os = "tvos",
7778
target_os = "watchos",
7879
target_os = "espidf",
80+
target_os = "vita",
7981
all(target_arch = "x86", target_os = "android")
8082
))]
8183
let socket = syscall!(accept(
@@ -87,11 +89,15 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So
8789
// Ensure the socket is closed if either of the `fcntl` calls
8890
// error below.
8991
let s = unsafe { net::UnixStream::from_raw_fd(socket) };
90-
#[cfg(not(target_os = "espidf"))]
92+
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
9193
syscall!(fcntl(socket, libc::F_SETFD, libc::FD_CLOEXEC))?;
9294

9395
// See https://github.com/tokio-rs/mio/issues/1450
94-
#[cfg(any(all(target_arch = "x86", target_os = "android"), target_os = "espidf",))]
96+
#[cfg(any(
97+
all(target_arch = "x86", target_os = "android"),
98+
target_os = "espidf",
99+
target_os = "vita",
100+
))]
95101
syscall!(fcntl(socket, libc::F_SETFL, libc::O_NONBLOCK))?;
96102

97103
Ok(s)

src/sys/unix/uds/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ cfg_os_poll! {
8181
target_os = "tvos",
8282
target_os = "watchos",
8383
target_os = "espidf",
84+
target_os = "vita",
8485
)))]
8586
let flags = flags | libc::SOCK_NONBLOCK | libc::SOCK_CLOEXEC;
8687

@@ -101,15 +102,17 @@ cfg_os_poll! {
101102
target_os = "tvos",
102103
target_os = "watchos",
103104
target_os = "espidf",
105+
target_os = "vita",
104106
))]
105107
{
106108
syscall!(fcntl(fds[0], libc::F_SETFL, libc::O_NONBLOCK))?;
107-
#[cfg(not(target_os = "espidf"))]
109+
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
108110
syscall!(fcntl(fds[0], libc::F_SETFD, libc::FD_CLOEXEC))?;
109111
syscall!(fcntl(fds[1], libc::F_SETFL, libc::O_NONBLOCK))?;
110-
#[cfg(not(target_os = "espidf"))]
112+
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
111113
syscall!(fcntl(fds[1], libc::F_SETFD, libc::FD_CLOEXEC))?;
112114
}
115+
113116
Ok(pair)
114117
}
115118

src/sys/unix/waker.rs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
target_os = "tvos",
1010
target_os = "watchos",
1111
)
12-
))
12+
)),
13+
not(target_os = "vita"),
1314
))]
1415
mod fdbased {
1516
#[cfg(all(
@@ -61,7 +62,8 @@ mod fdbased {
6162
target_os = "tvos",
6263
target_os = "watchos",
6364
)
64-
))
65+
)),
66+
not(target_os = "vita"),
6567
))]
6668
pub use self::fdbased::Waker;
6769

@@ -205,6 +207,7 @@ pub use self::kqueue::Waker;
205207
target_os = "netbsd",
206208
target_os = "openbsd",
207209
target_os = "redox",
210+
target_os = "vita",
208211
))]
209212
mod pipe {
210213
use crate::sys::unix::pipe;
@@ -250,7 +253,7 @@ mod pipe {
250253
}
251254
}
252255

253-
#[cfg(mio_unsupported_force_poll_poll)]
256+
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "vita"))]
254257
pub fn ack_and_reset(&self) {
255258
self.empty();
256259
}
@@ -275,21 +278,24 @@ mod pipe {
275278
}
276279
}
277280

278-
#[cfg(all(
279-
mio_unsupported_force_poll_poll,
280-
any(
281-
mio_unsupported_force_waker_pipe,
282-
target_os = "aix",
283-
target_os = "dragonfly",
284-
target_os = "illumos",
285-
target_os = "netbsd",
286-
target_os = "openbsd",
287-
target_os = "redox",
288-
)
281+
#[cfg(any(
282+
all(
283+
mio_unsupported_force_poll_poll,
284+
any(
285+
mio_unsupported_force_waker_pipe,
286+
target_os = "aix",
287+
target_os = "dragonfly",
288+
target_os = "illumos",
289+
target_os = "netbsd",
290+
target_os = "openbsd",
291+
target_os = "redox",
292+
)
293+
),
294+
target_os = "vita",
289295
))]
290296
pub(crate) use self::pipe::WakerInternal;
291297

292-
#[cfg(mio_unsupported_force_poll_poll)]
298+
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "vita"))]
293299
mod poll {
294300
use crate::sys::Selector;
295301
use crate::Token;
@@ -315,5 +321,5 @@ mod poll {
315321
}
316322
}
317323

318-
#[cfg(mio_unsupported_force_poll_poll)]
324+
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "vita"))]
319325
pub use self::poll::Waker;

0 commit comments

Comments
 (0)