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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 95 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 70 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)