Skip to content

Commit 4df84a1

Browse files
authored
Rollup merge of #110638 - nikarh:vita, r=Mark-Simulacrum
STD support for PSVita This PR adds std support for `armv7-sony-vita-newlibeabihf` target. The work here is fairly similar to #95897, just for a different target platform. This depends on the following pull requests: rust-lang/backtrace-rs#523 rust-lang/libc#3209
2 parents c9b4c63 + 3ba3df3 commit 4df84a1

File tree

20 files changed

+322
-41
lines changed

20 files changed

+322
-41
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1938,9 +1938,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
19381938

19391939
[[package]]
19401940
name = "libc"
1941-
version = "0.2.142"
1941+
version = "0.2.143"
19421942
source = "registry+https://github.com/rust-lang/crates.io-index"
1943-
checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317"
1943+
checksum = "edc207893e85c5d6be840e969b496b53d94cec8be2d501b214f50daa97fa8024"
19441944
dependencies = [
19451945
"rustc-std-workspace-core",
19461946
]

compiler/rustc_target/src/spec/armv7_sony_vita_newlibeabihf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub fn target() -> Target {
99
let pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,-q"]);
1010

1111
Target {
12-
llvm_target: "armv7a-vita-newlibeabihf".into(),
12+
llvm_target: "armv7a-vita-eabihf".into(),
1313
pointer_width: 32,
1414
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
1515
arch: "arm".into(),

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1515
panic_unwind = { path = "../panic_unwind", optional = true }
1616
panic_abort = { path = "../panic_abort" }
1717
core = { path = "../core" }
18-
libc = { version = "0.2.142", default-features = false, features = ['rustc-dep-of-std'] }
18+
libc = { version = "0.2.143", default-features = false, features = ['rustc-dep-of-std'] }
1919
compiler_builtins = { version = "0.1.91" }
2020
profiler_builtins = { path = "../profiler_builtins", optional = true }
2121
unwind = { path = "../unwind" }

library/std/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ fn main() {
3434
|| target.contains("espidf")
3535
|| target.contains("solid")
3636
|| target.contains("nintendo-3ds")
37+
|| target.contains("vita")
3738
|| target.contains("nto")
3839
{
3940
// These platforms don't have any special requirements.

library/std/src/os/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ pub mod redox;
137137
pub mod solaris;
138138
#[cfg(target_os = "solid_asp3")]
139139
pub mod solid;
140+
#[cfg(target_os = "vita")]
141+
pub mod vita;
140142
#[cfg(target_os = "vxworks")]
141143
pub mod vxworks;
142144
#[cfg(target_os = "watchos")]

library/std/src/os/unix/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ mod platform {
7373
pub use crate::os::redox::*;
7474
#[cfg(target_os = "solaris")]
7575
pub use crate::os::solaris::*;
76+
#[cfg(target_os = "vita")]
77+
pub use crate::os::vita::*;
7678
#[cfg(target_os = "vxworks")]
7779
pub use crate::os::vxworks::*;
7880
#[cfg(target_os = "watchos")]

library/std/src/os/vita/fs.rs

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#![stable(feature = "metadata_ext", since = "1.1.0")]
2+
3+
use crate::fs::Metadata;
4+
use crate::sys_common::AsInner;
5+
6+
/// OS-specific extensions to [`fs::Metadata`].
7+
///
8+
/// [`fs::Metadata`]: crate::fs::Metadata
9+
#[stable(feature = "metadata_ext", since = "1.1.0")]
10+
pub trait MetadataExt {
11+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
12+
fn st_dev(&self) -> u64;
13+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
14+
fn st_ino(&self) -> u64;
15+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
16+
fn st_mode(&self) -> u32;
17+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
18+
fn st_nlink(&self) -> u64;
19+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
20+
fn st_uid(&self) -> u32;
21+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
22+
fn st_gid(&self) -> u32;
23+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
24+
fn st_rdev(&self) -> u64;
25+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
26+
fn st_size(&self) -> u64;
27+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
28+
fn st_atime(&self) -> i64;
29+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
30+
fn st_atime_nsec(&self) -> i64;
31+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
32+
fn st_mtime(&self) -> i64;
33+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
34+
fn st_mtime_nsec(&self) -> i64;
35+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
36+
fn st_ctime(&self) -> i64;
37+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
38+
fn st_ctime_nsec(&self) -> i64;
39+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
40+
fn st_blksize(&self) -> u64;
41+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
42+
fn st_blocks(&self) -> u64;
43+
}
44+
45+
#[stable(feature = "metadata_ext", since = "1.1.0")]
46+
impl MetadataExt for Metadata {
47+
fn st_dev(&self) -> u64 {
48+
self.as_inner().as_inner().st_dev as u64
49+
}
50+
fn st_ino(&self) -> u64 {
51+
self.as_inner().as_inner().st_ino as u64
52+
}
53+
fn st_mode(&self) -> u32 {
54+
self.as_inner().as_inner().st_mode as u32
55+
}
56+
fn st_nlink(&self) -> u64 {
57+
self.as_inner().as_inner().st_nlink as u64
58+
}
59+
fn st_uid(&self) -> u32 {
60+
self.as_inner().as_inner().st_uid as u32
61+
}
62+
fn st_gid(&self) -> u32 {
63+
self.as_inner().as_inner().st_gid as u32
64+
}
65+
fn st_rdev(&self) -> u64 {
66+
self.as_inner().as_inner().st_rdev as u64
67+
}
68+
fn st_size(&self) -> u64 {
69+
self.as_inner().as_inner().st_size as u64
70+
}
71+
fn st_atime(&self) -> i64 {
72+
self.as_inner().as_inner().st_atime as i64
73+
}
74+
fn st_atime_nsec(&self) -> i64 {
75+
0
76+
}
77+
fn st_mtime(&self) -> i64 {
78+
self.as_inner().as_inner().st_mtime as i64
79+
}
80+
fn st_mtime_nsec(&self) -> i64 {
81+
0
82+
}
83+
fn st_ctime(&self) -> i64 {
84+
self.as_inner().as_inner().st_ctime as i64
85+
}
86+
fn st_ctime_nsec(&self) -> i64 {
87+
0
88+
}
89+
fn st_blksize(&self) -> u64 {
90+
self.as_inner().as_inner().st_blksize as u64
91+
}
92+
fn st_blocks(&self) -> u64 {
93+
self.as_inner().as_inner().st_blocks as u64
94+
}
95+
}

library/std/src/os/vita/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//! Definitions for vita
2+
3+
#![stable(feature = "raw_ext", since = "1.1.0")]
4+
5+
pub mod fs;
6+
pub(crate) mod raw;

library/std/src/os/vita/raw.rs

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//! vita raw type definitions
2+
3+
#![stable(feature = "raw_ext", since = "1.1.0")]
4+
#![deprecated(
5+
since = "1.8.0",
6+
note = "these type aliases are no longer supported by \
7+
the standard library, the `libc` crate on \
8+
crates.io should be used instead for the correct \
9+
definitions"
10+
)]
11+
#![allow(deprecated)]
12+
13+
use crate::os::raw::c_long;
14+
use crate::os::unix::raw::{gid_t, uid_t};
15+
16+
#[stable(feature = "pthread_t", since = "1.8.0")]
17+
pub type pthread_t = libc::pthread_t;
18+
19+
#[stable(feature = "raw_ext", since = "1.1.0")]
20+
pub type blkcnt_t = libc::blkcnt_t;
21+
22+
#[stable(feature = "raw_ext", since = "1.1.0")]
23+
pub type blksize_t = libc::blksize_t;
24+
#[stable(feature = "raw_ext", since = "1.1.0")]
25+
pub type dev_t = libc::dev_t;
26+
#[stable(feature = "raw_ext", since = "1.1.0")]
27+
pub type ino_t = libc::ino_t;
28+
#[stable(feature = "raw_ext", since = "1.1.0")]
29+
pub type mode_t = libc::mode_t;
30+
#[stable(feature = "raw_ext", since = "1.1.0")]
31+
pub type nlink_t = libc::nlink_t;
32+
#[stable(feature = "raw_ext", since = "1.1.0")]
33+
pub type off_t = libc::off_t;
34+
35+
#[stable(feature = "raw_ext", since = "1.1.0")]
36+
pub type time_t = libc::time_t;
37+
38+
#[repr(C)]
39+
#[derive(Clone)]
40+
#[stable(feature = "raw_ext", since = "1.1.0")]
41+
pub struct stat {
42+
#[stable(feature = "raw_ext", since = "1.1.0")]
43+
pub st_dev: dev_t,
44+
#[stable(feature = "raw_ext", since = "1.1.0")]
45+
pub st_ino: ino_t,
46+
#[stable(feature = "raw_ext", since = "1.1.0")]
47+
pub st_mode: mode_t,
48+
#[stable(feature = "raw_ext", since = "1.1.0")]
49+
pub st_nlink: nlink_t,
50+
#[stable(feature = "raw_ext", since = "1.1.0")]
51+
pub st_uid: uid_t,
52+
#[stable(feature = "raw_ext", since = "1.1.0")]
53+
pub st_gid: gid_t,
54+
#[stable(feature = "raw_ext", since = "1.1.0")]
55+
pub st_rdev: dev_t,
56+
#[stable(feature = "raw_ext", since = "1.1.0")]
57+
pub st_size: off_t,
58+
#[stable(feature = "raw_ext", since = "1.1.0")]
59+
pub st_atime: time_t,
60+
#[stable(feature = "raw_ext", since = "1.1.0")]
61+
pub st_mtime: time_t,
62+
#[stable(feature = "raw_ext", since = "1.1.0")]
63+
pub st_ctime: time_t,
64+
#[stable(feature = "raw_ext", since = "1.1.0")]
65+
pub st_blksize: blksize_t,
66+
#[stable(feature = "raw_ext", since = "1.1.0")]
67+
pub st_blocks: blkcnt_t,
68+
#[stable(feature = "raw_ext", since = "1.1.0")]
69+
pub st_spare4: [c_long; 2usize],
70+
}

library/std/src/sys/unix/alloc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ cfg_if::cfg_if! {
5959
target_os = "redox",
6060
target_os = "solaris",
6161
target_os = "espidf",
62-
target_os = "horizon"
62+
target_os = "horizon",
63+
target_os = "vita",
6364
))] {
6465
#[inline]
6566
unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {

library/std/src/sys/unix/args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ mod imp {
265265
}
266266
}
267267

268-
#[cfg(target_os = "espidf")]
268+
#[cfg(any(target_os = "espidf", target_os = "vita"))]
269269
mod imp {
270270
use super::Args;
271271

library/std/src/sys/unix/env.rs

+11
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ pub mod os {
141141
pub const EXE_EXTENSION: &str = "elf";
142142
}
143143

144+
#[cfg(target_os = "vita")]
145+
pub mod os {
146+
pub const FAMILY: &str = "unix";
147+
pub const OS: &str = "vita";
148+
pub const DLL_PREFIX: &str = "lib";
149+
pub const DLL_SUFFIX: &str = ".so";
150+
pub const DLL_EXTENSION: &str = "so";
151+
pub const EXE_SUFFIX: &str = ".elf";
152+
pub const EXE_EXTENSION: &str = "elf";
153+
}
154+
144155
#[cfg(all(target_os = "emscripten", target_arch = "asmjs"))]
145156
pub mod os {
146157
pub const FAMILY: &str = "unix";

library/std/src/sys/unix/fd.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const fn max_iov() -> usize {
7575
target_os = "nto",
7676
target_os = "openbsd",
7777
target_os = "horizon",
78+
target_os = "vita",
7879
target_os = "watchos",
7980
)))]
8081
const fn max_iov() -> usize {
@@ -93,7 +94,7 @@ impl FileDesc {
9394
Ok(ret as usize)
9495
}
9596

96-
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
97+
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
9798
pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
9899
let ret = cvt(unsafe {
99100
libc::readv(
@@ -105,14 +106,14 @@ impl FileDesc {
105106
Ok(ret as usize)
106107
}
107108

108-
#[cfg(any(target_os = "espidf", target_os = "horizon"))]
109+
#[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))]
109110
pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
110111
io::default_read_vectored(|b| self.read(b), bufs)
111112
}
112113

113114
#[inline]
114115
pub fn is_read_vectored(&self) -> bool {
115-
cfg!(not(any(target_os = "espidf", target_os = "horizon")))
116+
cfg!(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))
116117
}
117118

118119
pub fn read_to_end(&self, buf: &mut Vec<u8>) -> io::Result<usize> {
@@ -253,7 +254,7 @@ impl FileDesc {
253254
Ok(ret as usize)
254255
}
255256

256-
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
257+
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
257258
pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
258259
let ret = cvt(unsafe {
259260
libc::writev(
@@ -265,14 +266,14 @@ impl FileDesc {
265266
Ok(ret as usize)
266267
}
267268

268-
#[cfg(any(target_os = "espidf", target_os = "horizon"))]
269+
#[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))]
269270
pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
270271
io::default_write_vectored(|b| self.write(b), bufs)
271272
}
272273

273274
#[inline]
274275
pub fn is_write_vectored(&self) -> bool {
275-
cfg!(not(any(target_os = "espidf", target_os = "horizon")))
276+
cfg!(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))
276277
}
277278

278279
pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {

library/std/src/sys/unix/fs.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,12 @@ impl FileAttr {
447447

448448
#[cfg(not(any(target_os = "netbsd", target_os = "nto")))]
449449
impl FileAttr {
450-
#[cfg(not(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon")))]
450+
#[cfg(not(any(
451+
target_os = "vxworks",
452+
target_os = "espidf",
453+
target_os = "horizon",
454+
target_os = "vita"
455+
)))]
451456
pub fn modified(&self) -> io::Result<SystemTime> {
452457
#[cfg(target_pointer_width = "32")]
453458
cfg_has_statx! {
@@ -459,7 +464,7 @@ impl FileAttr {
459464
Ok(SystemTime::new(self.stat.st_mtime as i64, self.stat.st_mtime_nsec as i64))
460465
}
461466

462-
#[cfg(any(target_os = "vxworks", target_os = "espidf"))]
467+
#[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "vita"))]
463468
pub fn modified(&self) -> io::Result<SystemTime> {
464469
Ok(SystemTime::new(self.stat.st_mtime as i64, 0))
465470
}
@@ -469,7 +474,12 @@ impl FileAttr {
469474
Ok(SystemTime::from(self.stat.st_mtim))
470475
}
471476

472-
#[cfg(not(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon")))]
477+
#[cfg(not(any(
478+
target_os = "vxworks",
479+
target_os = "espidf",
480+
target_os = "horizon",
481+
target_os = "vita"
482+
)))]
473483
pub fn accessed(&self) -> io::Result<SystemTime> {
474484
#[cfg(target_pointer_width = "32")]
475485
cfg_has_statx! {
@@ -481,7 +491,7 @@ impl FileAttr {
481491
Ok(SystemTime::new(self.stat.st_atime as i64, self.stat.st_atime_nsec as i64))
482492
}
483493

484-
#[cfg(any(target_os = "vxworks", target_os = "espidf"))]
494+
#[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "vita"))]
485495
pub fn accessed(&self) -> io::Result<SystemTime> {
486496
Ok(SystemTime::new(self.stat.st_atime as i64, 0))
487497
}
@@ -866,6 +876,7 @@ impl DirEntry {
866876
target_os = "vxworks",
867877
target_os = "espidf",
868878
target_os = "horizon",
879+
target_os = "vita",
869880
target_os = "nto",
870881
))]
871882
pub fn ino(&self) -> u64 {

0 commit comments

Comments
 (0)