Skip to content

Commit 30a5ae1

Browse files
authored
Add support for armv7-sony-vita-newlibeabihf. (#882)
Add `target_os = "vita"` checks as needed for rustix to compile on armv7-sony-vita-newlibeabihf. This excludes support for `mm`, `termios`, and a few other things for now, where the libc bindings seem to be missing key types and constants. Fixes #881.
1 parent 702c54a commit 30a5ae1

47 files changed

Lines changed: 712 additions & 175 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ jobs:
214214
- run: cargo check -Z build-std --target=riscv32imc-esp-espidf --features=all-apis
215215
- run: cargo check -Z build-std --target=aarch64-unknown-nto-qnx710 --features=all-apis
216216
- run: cargo check -Z build-std --target=x86_64-pc-nto-qnx710 --features=all-apis
217+
- run: cargo check -Z build-std --target=armv7-sony-vita-newlibeabihf --features=all-apis
217218
# `std` doesn't appear to build on AIX yet, so test in `no_std` mode.
218219
- run: cargo check -Zbuild-std=core,alloc --target=powerpc64-ibm-aix --features=all-apis --no-default-features
219220
# Disable MIPS entirely for now as it fails with errors like

src/backend/libc/conv.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(super) fn c_str(c: &CStr) -> *const c::c_char {
1616
c.as_ptr()
1717
}
1818

19-
#[cfg(not(any(windows, target_os = "espidf", target_os = "wasi")))]
19+
#[cfg(not(any(windows, target_os = "espidf", target_os = "vita", target_os = "wasi")))]
2020
#[inline]
2121
pub(super) fn no_fd() -> LibcFd {
2222
-1
@@ -192,7 +192,13 @@ pub(super) fn msg_iov_len(len: usize) -> c::size_t {
192192

193193
/// Convert the value to the `msg_iovlen` field of a `msghdr` struct.
194194
#[cfg(all(
195-
not(any(windows, target_os = "espidf", target_os = "redox", target_os = "wasi")),
195+
not(any(
196+
windows,
197+
target_os = "espidf",
198+
target_os = "redox",
199+
target_os = "vita",
200+
target_os = "wasi"
201+
)),
196202
not(any(
197203
target_os = "android",
198204
all(target_os = "linux", not(target_env = "musl"))
@@ -232,6 +238,7 @@ pub(crate) fn msg_control_len(len: usize) -> c::socklen_t {
232238
target_os = "haiku",
233239
target_os = "nto",
234240
target_os = "redox",
241+
target_os = "vita",
235242
target_os = "wasi",
236243
)))]
237244
#[inline]

src/backend/libc/fs/dir.rs

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
1-
#[cfg(not(any(solarish, target_os = "haiku", target_os = "nto")))]
1+
#[cfg(not(any(solarish, target_os = "haiku", target_os = "nto", target_os = "vita")))]
22
use super::types::FileType;
33
use crate::backend::c;
44
use crate::backend::conv::owned_fd;
55
use crate::fd::{AsFd, BorrowedFd};
66
use crate::ffi::{CStr, CString};
7-
use crate::fs::{fcntl_getfl, fstat, openat, Mode, OFlags, Stat};
7+
use crate::fs::{fcntl_getfl, openat, Mode, OFlags};
8+
#[cfg(not(target_os = "vita"))]
9+
use crate::fs::{fstat, Stat};
810
#[cfg(not(any(
911
solarish,
1012
target_os = "haiku",
1113
target_os = "netbsd",
1214
target_os = "nto",
1315
target_os = "redox",
16+
target_os = "vita",
1417
target_os = "wasi",
1518
)))]
1619
use crate::fs::{fstatfs, StatFs};
17-
#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
20+
#[cfg(not(any(
21+
solarish,
22+
target_os = "haiku",
23+
target_os = "redox",
24+
target_os = "vita",
25+
target_os = "wasi"
26+
)))]
1827
use crate::fs::{fstatvfs, StatVfs};
1928
use crate::io;
20-
#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))]
29+
#[cfg(not(any(target_os = "fuchsia", target_os = "vita", target_os = "wasi")))]
2130
#[cfg(feature = "process")]
2231
use crate::process::fchdir;
2332
use alloc::borrow::ToOwned;
@@ -128,11 +137,12 @@ impl Dir {
128137
solarish,
129138
target_os = "aix",
130139
target_os = "haiku",
131-
target_os = "nto"
140+
target_os = "nto",
141+
target_os = "vita"
132142
)))]
133143
d_type: dirent.d_type,
134144

135-
#[cfg(not(any(freebsdlike, netbsdlike)))]
145+
#[cfg(not(any(freebsdlike, netbsdlike, target_os = "vita")))]
136146
d_ino: dirent.d_ino,
137147

138148
#[cfg(any(freebsdlike, netbsdlike))]
@@ -147,6 +157,7 @@ impl Dir {
147157
}
148158

149159
/// `fstat(self)`
160+
#[cfg(not(target_os = "vita"))]
150161
#[inline]
151162
pub fn stat(&self) -> io::Result<Stat> {
152163
fstat(unsafe { BorrowedFd::borrow_raw(c::dirfd(self.libc_dir.as_ptr())) })
@@ -159,6 +170,7 @@ impl Dir {
159170
target_os = "netbsd",
160171
target_os = "nto",
161172
target_os = "redox",
173+
target_os = "vita",
162174
target_os = "wasi",
163175
)))]
164176
#[inline]
@@ -167,15 +179,21 @@ impl Dir {
167179
}
168180

169181
/// `fstatvfs(self)`
170-
#[cfg(not(any(solarish, target_os = "haiku", target_os = "redox", target_os = "wasi")))]
182+
#[cfg(not(any(
183+
solarish,
184+
target_os = "haiku",
185+
target_os = "redox",
186+
target_os = "vita",
187+
target_os = "wasi"
188+
)))]
171189
#[inline]
172190
pub fn statvfs(&self) -> io::Result<StatVfs> {
173191
fstatvfs(unsafe { BorrowedFd::borrow_raw(c::dirfd(self.libc_dir.as_ptr())) })
174192
}
175193

176194
/// `fchdir(self)`
177195
#[cfg(feature = "process")]
178-
#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))]
196+
#[cfg(not(any(target_os = "fuchsia", target_os = "vita", target_os = "wasi")))]
179197
#[cfg_attr(doc_cfg, doc(cfg(feature = "process")))]
180198
#[inline]
181199
pub fn chdir(&self) -> io::Result<()> {
@@ -207,19 +225,26 @@ impl Iterator for Dir {
207225

208226
impl fmt::Debug for Dir {
209227
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
210-
f.debug_struct("Dir")
211-
.field("fd", unsafe { &c::dirfd(self.libc_dir.as_ptr()) })
212-
.finish()
228+
let mut s = f.debug_struct("Dir");
229+
#[cfg(not(target_os = "vita"))]
230+
s.field("fd", unsafe { &c::dirfd(self.libc_dir.as_ptr()) });
231+
s.finish()
213232
}
214233
}
215234

216235
/// `struct dirent`
217236
#[derive(Debug)]
218237
pub struct DirEntry {
219-
#[cfg(not(any(solarish, target_os = "aix", target_os = "haiku", target_os = "nto")))]
238+
#[cfg(not(any(
239+
solarish,
240+
target_os = "aix",
241+
target_os = "haiku",
242+
target_os = "nto",
243+
target_os = "vita"
244+
)))]
220245
d_type: u8,
221246

222-
#[cfg(not(any(freebsdlike, netbsdlike)))]
247+
#[cfg(not(any(freebsdlike, netbsdlike, target_os = "vita")))]
223248
d_ino: c::ino_t,
224249

225250
#[cfg(any(freebsdlike, netbsdlike))]
@@ -236,14 +261,20 @@ impl DirEntry {
236261
}
237262

238263
/// Returns the type of this directory entry.
239-
#[cfg(not(any(solarish, target_os = "aix", target_os = "haiku", target_os = "nto")))]
264+
#[cfg(not(any(
265+
solarish,
266+
target_os = "aix",
267+
target_os = "haiku",
268+
target_os = "nto",
269+
target_os = "vita"
270+
)))]
240271
#[inline]
241272
pub fn file_type(&self) -> FileType {
242273
FileType::from_dirent_d_type(self.d_type)
243274
}
244275

245276
/// Return the inode number of this directory entry.
246-
#[cfg(not(any(freebsdlike, netbsdlike)))]
277+
#[cfg(not(any(freebsdlike, netbsdlike, target_os = "vita")))]
247278
#[inline]
248279
pub fn ino(&self) -> u64 {
249280
self.d_ino as u64

src/backend/libc/fs/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub mod inotify;
66
target_os = "espidf",
77
target_os = "haiku",
88
target_os = "redox",
9+
target_os = "vita",
910
target_os = "wasi"
1011
)))]
1112
pub(crate) mod makedev;

src/backend/libc/fs/syscalls.rs

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ use crate::fd::{BorrowedFd, OwnedFd};
1313
use crate::ffi::CStr;
1414
#[cfg(apple)]
1515
use crate::ffi::CString;
16+
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
17+
use crate::fs::Access;
1618
#[cfg(not(any(
1719
apple,
1820
netbsdlike,
@@ -21,6 +23,7 @@ use crate::ffi::CString;
2123
target_os = "espidf",
2224
target_os = "haiku",
2325
target_os = "redox",
26+
target_os = "vita",
2427
)))]
2528
use crate::fs::Advice;
2629
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
@@ -33,9 +36,10 @@ use crate::fs::AtFlags;
3336
target_os = "espidf",
3437
target_os = "nto",
3538
target_os = "redox",
39+
target_os = "vita",
3640
)))]
3741
use crate::fs::FallocateFlags;
38-
#[cfg(not(any(target_os = "espidf", target_os = "wasi")))]
42+
#[cfg(not(any(target_os = "espidf", target_os = "vita", target_os = "wasi")))]
3943
use crate::fs::FlockOperation;
4044
#[cfg(any(linux_kernel, target_os = "freebsd"))]
4145
use crate::fs::MemfdFlags;
@@ -48,12 +52,19 @@ use crate::fs::SealFlags;
4852
target_os = "netbsd",
4953
target_os = "nto",
5054
target_os = "redox",
55+
target_os = "vita",
5156
target_os = "wasi",
5257
)))]
5358
use crate::fs::StatFs;
54-
#[cfg(not(target_os = "espidf"))]
55-
use crate::fs::{Access, Timestamps};
56-
#[cfg(not(any(apple, target_os = "espidf", target_os = "redox", target_os = "wasi")))]
59+
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
60+
use crate::fs::Timestamps;
61+
#[cfg(not(any(
62+
apple,
63+
target_os = "espidf",
64+
target_os = "redox",
65+
target_os = "vita",
66+
target_os = "wasi"
67+
)))]
5768
use crate::fs::{Dev, FileType};
5869
use crate::fs::{Mode, OFlags, SeekFrom, Stat};
5970
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
@@ -232,6 +243,7 @@ pub(crate) fn openat(
232243
target_os = "netbsd",
233244
target_os = "nto",
234245
target_os = "redox",
246+
target_os = "vita",
235247
target_os = "wasi",
236248
)))]
237249
#[inline]
@@ -688,12 +700,17 @@ fn statat_old(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<
688700
}
689701
}
690702

691-
#[cfg(not(any(target_os = "espidf", target_os = "emscripten")))]
703+
#[cfg(not(any(target_os = "espidf", target_os = "emscripten", target_os = "vita")))]
692704
pub(crate) fn access(path: &CStr, access: Access) -> io::Result<()> {
693705
unsafe { ret(c::access(c_str(path), access.bits())) }
694706
}
695707

696-
#[cfg(not(any(target_os = "emscripten", target_os = "espidf", target_os = "redox")))]
708+
#[cfg(not(any(
709+
target_os = "emscripten",
710+
target_os = "espidf",
711+
target_os = "redox",
712+
target_os = "vita"
713+
)))]
697714
pub(crate) fn accessat(
698715
dirfd: BorrowedFd<'_>,
699716
path: &CStr,
@@ -759,7 +776,7 @@ pub(crate) fn accessat(
759776
Ok(())
760777
}
761778

762-
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
779+
#[cfg(not(any(target_os = "espidf", target_os = "redox", target_os = "vita")))]
763780
pub(crate) fn utimensat(
764781
dirfd: BorrowedFd<'_>,
765782
path: &CStr,
@@ -1070,7 +1087,13 @@ pub(crate) fn chownat(
10701087
}
10711088
}
10721089

1073-
#[cfg(not(any(apple, target_os = "espidf", target_os = "redox", target_os = "wasi")))]
1090+
#[cfg(not(any(
1091+
apple,
1092+
target_os = "espidf",
1093+
target_os = "redox",
1094+
target_os = "vita",
1095+
target_os = "wasi"
1096+
)))]
10741097
pub(crate) fn mknodat(
10751098
dirfd: BorrowedFd<'_>,
10761099
path: &CStr,
@@ -1149,6 +1172,7 @@ pub(crate) fn copy_file_range(
11491172
target_os = "espidf",
11501173
target_os = "haiku",
11511174
target_os = "redox",
1175+
target_os = "vita",
11521176
)))]
11531177
pub(crate) fn fadvise(fd: BorrowedFd<'_>, offset: u64, len: u64, advice: Advice) -> io::Result<()> {
11541178
let offset = offset as i64;
@@ -1205,6 +1229,7 @@ pub(crate) fn fcntl_add_seals(fd: BorrowedFd<'_>, seals: SealFlags) -> io::Resul
12051229
target_os = "espidf",
12061230
target_os = "fuchsia",
12071231
target_os = "redox",
1232+
target_os = "vita",
12081233
target_os = "wasi"
12091234
)))]
12101235
#[inline]
@@ -1250,8 +1275,8 @@ pub(crate) fn seek(fd: BorrowedFd<'_>, pos: SeekFrom) -> io::Result<u64> {
12501275
SeekFrom::Hole(offset) => (c::SEEK_HOLE, offset),
12511276
};
12521277

1253-
// ESP-IDF doesn't support 64-bit offsets.
1254-
#[cfg(target_os = "espidf")]
1278+
// ESP-IDF and Vita don't support 64-bit offsets.
1279+
#[cfg(any(target_os = "espidf", target_os = "vita"))]
12551280
let offset: i32 = offset.try_into().map_err(|_| io::Errno::OVERFLOW)?;
12561281

12571282
let offset = unsafe { ret_off_t(c::lseek(borrowed_fd(fd), offset, whence))? };
@@ -1318,7 +1343,12 @@ pub(crate) fn fchown(fd: BorrowedFd<'_>, owner: Option<Uid>, group: Option<Gid>)
13181343
}
13191344
}
13201345

1321-
#[cfg(not(any(target_os = "espidf", target_os = "solaris", target_os = "wasi")))]
1346+
#[cfg(not(any(
1347+
target_os = "espidf",
1348+
target_os = "solaris",
1349+
target_os = "vita",
1350+
target_os = "wasi"
1351+
)))]
13221352
pub(crate) fn flock(fd: BorrowedFd<'_>, operation: FlockOperation) -> io::Result<()> {
13231353
unsafe { ret(c::flock(borrowed_fd(fd), operation as c::c_int)) }
13241354
}
@@ -1340,7 +1370,12 @@ pub(crate) fn syncfs(fd: BorrowedFd<'_>) -> io::Result<()> {
13401370
unsafe { ret(syncfs(borrowed_fd(fd))) }
13411371
}
13421372

1343-
#[cfg(not(any(target_os = "espidf", target_os = "redox", target_os = "wasi")))]
1373+
#[cfg(not(any(
1374+
target_os = "espidf",
1375+
target_os = "redox",
1376+
target_os = "vita",
1377+
target_os = "wasi"
1378+
)))]
13441379
pub(crate) fn sync() {
13451380
unsafe { c::sync() }
13461381
}
@@ -1408,6 +1443,7 @@ fn fstat_old(fd: BorrowedFd<'_>) -> io::Result<Stat> {
14081443
target_os = "netbsd",
14091444
target_os = "nto",
14101445
target_os = "redox",
1446+
target_os = "vita",
14111447
target_os = "wasi",
14121448
)))]
14131449
pub(crate) fn fstatfs(fd: BorrowedFd<'_>) -> io::Result<StatFs> {
@@ -1447,7 +1483,7 @@ fn libc_statvfs_to_statvfs(from: c::statvfs) -> StatVfs {
14471483
}
14481484
}
14491485

1450-
#[cfg(not(target_os = "espidf"))]
1486+
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
14511487
pub(crate) fn futimens(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()> {
14521488
// Old 32-bit version: libc has `futimens` but it is not y2038 safe by
14531489
// default. But there may be a `__futimens64` we can use.
@@ -1555,6 +1591,7 @@ fn futimens_old(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()> {
15551591
target_os = "espidf",
15561592
target_os = "nto",
15571593
target_os = "redox",
1594+
target_os = "vita",
15581595
)))]
15591596
pub(crate) fn fallocate(
15601597
fd: BorrowedFd<'_>,
@@ -1632,6 +1669,7 @@ pub(crate) fn fsync(fd: BorrowedFd<'_>) -> io::Result<()> {
16321669
target_os = "espidf",
16331670
target_os = "haiku",
16341671
target_os = "redox",
1672+
target_os = "vita",
16351673
)))]
16361674
pub(crate) fn fdatasync(fd: BorrowedFd<'_>) -> io::Result<()> {
16371675
unsafe { ret(c::fdatasync(borrowed_fd(fd))) }

0 commit comments

Comments
 (0)