diff --git a/backtrace b/backtrace index 8ad84ca5a..4245978ca 160000 --- a/backtrace +++ b/backtrace @@ -1 +1 @@ -Subproject commit 8ad84ca5ad88ade697637387e7cb4d7c3cf4bde8 +Subproject commit 4245978ca8169c40c088ff733825e4527f7b914c diff --git a/std/Cargo.toml b/std/Cargo.toml index 0441f7e6c..1454b0025 100644 --- a/std/Cargo.toml +++ b/std/Cargo.toml @@ -15,7 +15,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] } panic_unwind = { path = "../panic_unwind", optional = true } panic_abort = { path = "../panic_abort" } core = { path = "../core" } -libc = { version = "0.2.142", default-features = false, features = ['rustc-dep-of-std'] } +libc = { version = "0.2.143", default-features = false, features = ['rustc-dep-of-std'] } compiler_builtins = { version = "0.1.91" } profiler_builtins = { path = "../profiler_builtins", optional = true } unwind = { path = "../unwind" } diff --git a/std/build.rs b/std/build.rs index cf708db6f..0fb03c8e8 100644 --- a/std/build.rs +++ b/std/build.rs @@ -34,6 +34,7 @@ fn main() { || target.contains("espidf") || target.contains("solid") || target.contains("nintendo-3ds") + || target.contains("vita") || target.contains("nto") { // These platforms don't have any special requirements. diff --git a/std/src/os/mod.rs b/std/src/os/mod.rs index b148d8a00..5b54cc5f2 100644 --- a/std/src/os/mod.rs +++ b/std/src/os/mod.rs @@ -137,6 +137,8 @@ pub mod redox; pub mod solaris; #[cfg(target_os = "solid_asp3")] pub mod solid; +#[cfg(target_os = "vita")] +pub mod vita; #[cfg(target_os = "vxworks")] pub mod vxworks; #[cfg(target_os = "watchos")] diff --git a/std/src/os/unix/mod.rs b/std/src/os/unix/mod.rs index eb2d7ce11..6fe111118 100644 --- a/std/src/os/unix/mod.rs +++ b/std/src/os/unix/mod.rs @@ -73,6 +73,8 @@ mod platform { pub use crate::os::redox::*; #[cfg(target_os = "solaris")] pub use crate::os::solaris::*; + #[cfg(target_os = "vita")] + pub use crate::os::vita::*; #[cfg(target_os = "vxworks")] pub use crate::os::vxworks::*; #[cfg(target_os = "watchos")] diff --git a/std/src/os/vita/fs.rs b/std/src/os/vita/fs.rs new file mode 100644 index 000000000..a5a06764a --- /dev/null +++ b/std/src/os/vita/fs.rs @@ -0,0 +1,95 @@ +#![stable(feature = "metadata_ext", since = "1.1.0")] + +use crate::fs::Metadata; +use crate::sys_common::AsInner; + +/// OS-specific extensions to [`fs::Metadata`]. +/// +/// [`fs::Metadata`]: crate::fs::Metadata +#[stable(feature = "metadata_ext", since = "1.1.0")] +pub trait MetadataExt { + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_dev(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_ino(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_mode(&self) -> u32; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_nlink(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_uid(&self) -> u32; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_gid(&self) -> u32; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_rdev(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_size(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_atime(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_atime_nsec(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_mtime(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_mtime_nsec(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_ctime(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_ctime_nsec(&self) -> i64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_blksize(&self) -> u64; + #[stable(feature = "metadata_ext2", since = "1.8.0")] + fn st_blocks(&self) -> u64; +} + +#[stable(feature = "metadata_ext", since = "1.1.0")] +impl MetadataExt for Metadata { + fn st_dev(&self) -> u64 { + self.as_inner().as_inner().st_dev as u64 + } + fn st_ino(&self) -> u64 { + self.as_inner().as_inner().st_ino as u64 + } + fn st_mode(&self) -> u32 { + self.as_inner().as_inner().st_mode as u32 + } + fn st_nlink(&self) -> u64 { + self.as_inner().as_inner().st_nlink as u64 + } + fn st_uid(&self) -> u32 { + self.as_inner().as_inner().st_uid as u32 + } + fn st_gid(&self) -> u32 { + self.as_inner().as_inner().st_gid as u32 + } + fn st_rdev(&self) -> u64 { + self.as_inner().as_inner().st_rdev as u64 + } + fn st_size(&self) -> u64 { + self.as_inner().as_inner().st_size as u64 + } + fn st_atime(&self) -> i64 { + self.as_inner().as_inner().st_atime as i64 + } + fn st_atime_nsec(&self) -> i64 { + 0 + } + fn st_mtime(&self) -> i64 { + self.as_inner().as_inner().st_mtime as i64 + } + fn st_mtime_nsec(&self) -> i64 { + 0 + } + fn st_ctime(&self) -> i64 { + self.as_inner().as_inner().st_ctime as i64 + } + fn st_ctime_nsec(&self) -> i64 { + 0 + } + fn st_blksize(&self) -> u64 { + self.as_inner().as_inner().st_blksize as u64 + } + fn st_blocks(&self) -> u64 { + self.as_inner().as_inner().st_blocks as u64 + } +} diff --git a/std/src/os/vita/mod.rs b/std/src/os/vita/mod.rs new file mode 100644 index 000000000..da9edd12f --- /dev/null +++ b/std/src/os/vita/mod.rs @@ -0,0 +1,6 @@ +//! Definitions for vita + +#![stable(feature = "raw_ext", since = "1.1.0")] + +pub mod fs; +pub(crate) mod raw; diff --git a/std/src/os/vita/raw.rs b/std/src/os/vita/raw.rs new file mode 100644 index 000000000..74cae4d41 --- /dev/null +++ b/std/src/os/vita/raw.rs @@ -0,0 +1,70 @@ +//! vita raw type definitions + +#![stable(feature = "raw_ext", since = "1.1.0")] +#![deprecated( + since = "1.8.0", + note = "these type aliases are no longer supported by \ + the standard library, the `libc` crate on \ + crates.io should be used instead for the correct \ + definitions" +)] +#![allow(deprecated)] + +use crate::os::raw::c_long; +use crate::os::unix::raw::{gid_t, uid_t}; + +#[stable(feature = "pthread_t", since = "1.8.0")] +pub type pthread_t = libc::pthread_t; + +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type blkcnt_t = libc::blkcnt_t; + +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type blksize_t = libc::blksize_t; +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type dev_t = libc::dev_t; +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type ino_t = libc::ino_t; +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type mode_t = libc::mode_t; +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type nlink_t = libc::nlink_t; +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type off_t = libc::off_t; + +#[stable(feature = "raw_ext", since = "1.1.0")] +pub type time_t = libc::time_t; + +#[repr(C)] +#[derive(Clone)] +#[stable(feature = "raw_ext", since = "1.1.0")] +pub struct stat { + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_dev: dev_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ino: ino_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mode: mode_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_nlink: nlink_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_uid: uid_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_gid: gid_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_rdev: dev_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_size: off_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime: time_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime: time_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime: time_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blksize: blksize_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blocks: blkcnt_t, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_spare4: [c_long; 2usize], +} diff --git a/std/src/sys/unix/alloc.rs b/std/src/sys/unix/alloc.rs index 9d6567c9f..8604b5398 100644 --- a/std/src/sys/unix/alloc.rs +++ b/std/src/sys/unix/alloc.rs @@ -59,7 +59,8 @@ cfg_if::cfg_if! { target_os = "redox", target_os = "solaris", target_os = "espidf", - target_os = "horizon" + target_os = "horizon", + target_os = "vita", ))] { #[inline] unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 { diff --git a/std/src/sys/unix/args.rs b/std/src/sys/unix/args.rs index 3d79058b3..9ed4d9c1e 100644 --- a/std/src/sys/unix/args.rs +++ b/std/src/sys/unix/args.rs @@ -265,7 +265,7 @@ mod imp { } } -#[cfg(target_os = "espidf")] +#[cfg(any(target_os = "espidf", target_os = "vita"))] mod imp { use super::Args; diff --git a/std/src/sys/unix/env.rs b/std/src/sys/unix/env.rs index 1a9276f11..8c3ef88d8 100644 --- a/std/src/sys/unix/env.rs +++ b/std/src/sys/unix/env.rs @@ -141,6 +141,17 @@ pub mod os { pub const EXE_EXTENSION: &str = "elf"; } +#[cfg(target_os = "vita")] +pub mod os { + pub const FAMILY: &str = "unix"; + pub const OS: &str = "vita"; + pub const DLL_PREFIX: &str = "lib"; + pub const DLL_SUFFIX: &str = ".so"; + pub const DLL_EXTENSION: &str = "so"; + pub const EXE_SUFFIX: &str = ".elf"; + pub const EXE_EXTENSION: &str = "elf"; +} + #[cfg(all(target_os = "emscripten", target_arch = "asmjs"))] pub mod os { pub const FAMILY: &str = "unix"; diff --git a/std/src/sys/unix/fd.rs b/std/src/sys/unix/fd.rs index 45f96478f..cb630eede 100644 --- a/std/src/sys/unix/fd.rs +++ b/std/src/sys/unix/fd.rs @@ -75,6 +75,7 @@ const fn max_iov() -> usize { target_os = "nto", target_os = "openbsd", target_os = "horizon", + target_os = "vita", target_os = "watchos", )))] const fn max_iov() -> usize { @@ -93,7 +94,7 @@ impl FileDesc { Ok(ret as usize) } - #[cfg(not(any(target_os = "espidf", target_os = "horizon")))] + #[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))] pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result { let ret = cvt(unsafe { libc::readv( @@ -105,14 +106,14 @@ impl FileDesc { Ok(ret as usize) } - #[cfg(any(target_os = "espidf", target_os = "horizon"))] + #[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))] pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result { io::default_read_vectored(|b| self.read(b), bufs) } #[inline] pub fn is_read_vectored(&self) -> bool { - cfg!(not(any(target_os = "espidf", target_os = "horizon"))) + cfg!(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))) } pub fn read_to_end(&self, buf: &mut Vec) -> io::Result { @@ -253,7 +254,7 @@ impl FileDesc { Ok(ret as usize) } - #[cfg(not(any(target_os = "espidf", target_os = "horizon")))] + #[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))] pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result { let ret = cvt(unsafe { libc::writev( @@ -265,14 +266,14 @@ impl FileDesc { Ok(ret as usize) } - #[cfg(any(target_os = "espidf", target_os = "horizon"))] + #[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))] pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result { io::default_write_vectored(|b| self.write(b), bufs) } #[inline] pub fn is_write_vectored(&self) -> bool { - cfg!(not(any(target_os = "espidf", target_os = "horizon"))) + cfg!(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))) } pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { diff --git a/std/src/sys/unix/fs.rs b/std/src/sys/unix/fs.rs index b398fd5eb..22d2ae397 100644 --- a/std/src/sys/unix/fs.rs +++ b/std/src/sys/unix/fs.rs @@ -447,7 +447,12 @@ impl FileAttr { #[cfg(not(any(target_os = "netbsd", target_os = "nto")))] impl FileAttr { - #[cfg(not(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon")))] + #[cfg(not(any( + target_os = "vxworks", + target_os = "espidf", + target_os = "horizon", + target_os = "vita" + )))] pub fn modified(&self) -> io::Result { #[cfg(target_pointer_width = "32")] cfg_has_statx! { @@ -459,7 +464,7 @@ impl FileAttr { Ok(SystemTime::new(self.stat.st_mtime as i64, self.stat.st_mtime_nsec as i64)) } - #[cfg(any(target_os = "vxworks", target_os = "espidf"))] + #[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "vita"))] pub fn modified(&self) -> io::Result { Ok(SystemTime::new(self.stat.st_mtime as i64, 0)) } @@ -469,7 +474,12 @@ impl FileAttr { Ok(SystemTime::from(self.stat.st_mtim)) } - #[cfg(not(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon")))] + #[cfg(not(any( + target_os = "vxworks", + target_os = "espidf", + target_os = "horizon", + target_os = "vita" + )))] pub fn accessed(&self) -> io::Result { #[cfg(target_pointer_width = "32")] cfg_has_statx! { @@ -481,7 +491,7 @@ impl FileAttr { Ok(SystemTime::new(self.stat.st_atime as i64, self.stat.st_atime_nsec as i64)) } - #[cfg(any(target_os = "vxworks", target_os = "espidf"))] + #[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "vita"))] pub fn accessed(&self) -> io::Result { Ok(SystemTime::new(self.stat.st_atime as i64, 0)) } @@ -866,6 +876,7 @@ impl DirEntry { target_os = "vxworks", target_os = "espidf", target_os = "horizon", + target_os = "vita", target_os = "nto", ))] pub fn ino(&self) -> u64 { diff --git a/std/src/sys/unix/mod.rs b/std/src/sys/unix/mod.rs index 68c9520cc..bb9e65e68 100644 --- a/std/src/sys/unix/mod.rs +++ b/std/src/sys/unix/mod.rs @@ -92,6 +92,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { target_os = "redox", target_os = "l4re", target_os = "horizon", + target_os = "vita", )))] 'poll: { use crate::sys::os::errno; @@ -140,6 +141,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { target_os = "vxworks", target_os = "l4re", target_os = "horizon", + target_os = "vita", )))] { use crate::sys::os::errno; @@ -162,7 +164,12 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { } unsafe fn reset_sigpipe(#[allow(unused_variables)] sigpipe: u8) { - #[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "horizon")))] + #[cfg(not(any( + target_os = "emscripten", + target_os = "fuchsia", + target_os = "horizon", + target_os = "vita" + )))] { // We don't want to add this as a public type to std, nor do we // want to `include!` a file from the compiler (which would break @@ -199,7 +206,8 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { target_os = "espidf", target_os = "emscripten", target_os = "fuchsia", - target_os = "horizon" + target_os = "horizon", + target_os = "vita" )))] static UNIX_SIGPIPE_ATTR_SPECIFIED: crate::sync::atomic::AtomicBool = crate::sync::atomic::AtomicBool::new(false); @@ -208,7 +216,8 @@ static UNIX_SIGPIPE_ATTR_SPECIFIED: crate::sync::atomic::AtomicBool = target_os = "espidf", target_os = "emscripten", target_os = "fuchsia", - target_os = "horizon" + target_os = "horizon", + target_os = "vita", )))] pub(crate) fn unix_sigpipe_attr_specified() -> bool { UNIX_SIGPIPE_ATTR_SPECIFIED.load(crate::sync::atomic::Ordering::Relaxed) @@ -402,7 +411,7 @@ cfg_if::cfg_if! { } } -#[cfg(any(target_os = "espidf", target_os = "horizon"))] +#[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))] mod unsupported { use crate::io; diff --git a/std/src/sys/unix/os.rs b/std/src/sys/unix/os.rs index a345af76f..8edfd3313 100644 --- a/std/src/sys/unix/os.rs +++ b/std/src/sys/unix/os.rs @@ -460,7 +460,7 @@ pub fn current_exe() -> io::Result { path.canonicalize() } -#[cfg(any(target_os = "espidf", target_os = "horizon"))] +#[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))] pub fn current_exe() -> io::Result { super::unsupported::unsupported() } @@ -614,7 +614,8 @@ pub fn home_dir() -> Option { target_os = "redox", target_os = "vxworks", target_os = "espidf", - target_os = "horizon" + target_os = "horizon", + target_os = "vita", ))] unsafe fn fallback() -> Option { None @@ -627,7 +628,8 @@ pub fn home_dir() -> Option { target_os = "redox", target_os = "vxworks", target_os = "espidf", - target_os = "horizon" + target_os = "horizon", + target_os = "vita", )))] unsafe fn fallback() -> Option { let amt = match libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX) { diff --git a/std/src/sys/unix/process/mod.rs b/std/src/sys/unix/process/mod.rs index 3701510f3..0cf163d9f 100644 --- a/std/src/sys/unix/process/mod.rs +++ b/std/src/sys/unix/process/mod.rs @@ -14,7 +14,7 @@ cfg_if::cfg_if! { } else if #[cfg(target_os = "vxworks")] { #[path = "process_vxworks.rs"] mod process_inner; - } else if #[cfg(any(target_os = "espidf", target_os = "horizon"))] { + } else if #[cfg(any(target_os = "espidf", target_os = "horizon", target_os = "vita"))] { #[path = "process_unsupported.rs"] mod process_inner; } else { diff --git a/std/src/sys/unix/rand.rs b/std/src/sys/unix/rand.rs index 0f347ffab..d8b63546b 100644 --- a/std/src/sys/unix/rand.rs +++ b/std/src/sys/unix/rand.rs @@ -21,7 +21,8 @@ pub fn hashmap_random_keys() -> (u64, u64) { not(target_os = "fuchsia"), not(target_os = "redox"), not(target_os = "vxworks"), - not(target_os = "emscripten") + not(target_os = "emscripten"), + not(target_os = "vita"), ))] mod imp { use crate::fs::File; @@ -175,7 +176,7 @@ mod imp { } } -#[cfg(any(target_os = "openbsd", target_os = "emscripten"))] +#[cfg(any(target_os = "openbsd", target_os = "emscripten", target_os = "vita"))] mod imp { use crate::sys::os::errno;