diff --git a/src/unix/newlib/aarch64/mod.rs b/src/unix/newlib/aarch64/mod.rs deleted file mode 100644 index 56c268fc5f2bb..0000000000000 --- a/src/unix/newlib/aarch64/mod.rs +++ /dev/null @@ -1,56 +0,0 @@ -use crate::prelude::*; - -pub type clock_t = c_long; -pub type wchar_t = u32; - -s! { - pub struct sockaddr { - pub sa_len: u8, - pub sa_family: crate::sa_family_t, - pub sa_data: [c_char; 14], - } - - pub struct sockaddr_in6 { - pub sin6_len: u8, - pub sin6_family: crate::sa_family_t, - pub sin6_port: crate::in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: crate::in6_addr, - pub sin6_scope_id: u32, - } - - pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: crate::sa_family_t, - pub sin_port: crate::in_port_t, - pub sin_addr: crate::in_addr, - pub sin_zero: [c_char; 8], - } -} - -pub const AF_INET6: c_int = 23; - -pub const FIONBIO: c_ulong = 1; - -pub const POLLIN: c_short = 0x1; -pub const POLLPRI: c_short = 0x2; -pub const POLLOUT: c_short = 0x4; -pub const POLLERR: c_short = 0x8; -pub const POLLHUP: c_short = 0x10; -pub const POLLNVAL: c_short = 0x20; - -pub const SOL_SOCKET: c_int = 65535; - -pub const MSG_OOB: c_int = 1; -pub const MSG_PEEK: c_int = 2; -pub const MSG_DONTWAIT: c_int = 4; -pub const MSG_DONTROUTE: c_int = 0; -pub const MSG_WAITALL: c_int = 0; -pub const MSG_MORE: c_int = 0; -pub const MSG_NOSIGNAL: c_int = 0; - -pub use crate::unix::newlib::generic::{ - dirent, - sigset_t, - stat, -}; diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs index 9b5978fc538c3..a559cf4da59fd 100644 --- a/src/unix/newlib/arm/mod.rs +++ b/src/unix/newlib/arm/mod.rs @@ -50,9 +50,3 @@ pub const MSG_DONTROUTE: c_int = 0; pub const MSG_WAITALL: c_int = 0; pub const MSG_MORE: c_int = 0; pub const MSG_NOSIGNAL: c_int = 0; - -pub use crate::unix::newlib::generic::{ - dirent, - sigset_t, - stat, -}; diff --git a/src/unix/newlib/generic.rs b/src/unix/newlib/generic.rs deleted file mode 100644 index c020e8e7702d4..0000000000000 --- a/src/unix/newlib/generic.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! Common types used by most newlib platforms -use crate::off_t; -#[allow(unused_imports)] // needed for platforms that don't use the prelude here -use crate::prelude::*; - -s! { - #[cfg(all(not(target_os = "vita"), not(target_os = "horizon")))] - pub struct sigset_t { - __val: u32, - } - - pub struct stat { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub st_size: off_t, - pub st_atim: crate::timespec, - pub st_mtim: crate::timespec, - pub st_ctim: crate::timespec, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt_t, - pub st_spare4: [c_long; 2usize], - } - - #[cfg(not(target_os = "vita"))] - pub struct dirent { - pub d_ino: crate::ino_t, - pub d_type: c_uchar, - pub d_name: [c_char; 256usize], - } -} diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index ee6abccedfb6a..0c7af12c7ff1e 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -6,18 +6,16 @@ pub type blksize_t = i32; pub type clockid_t = c_ulong; cfg_if! { - if #[cfg(any(target_os = "espidf"))] { + if #[cfg(any(target_os = "espidf", target_os = "vita"))] { pub type dev_t = c_short; pub type ino_t = c_ushort; pub type off_t = c_long; - } else if #[cfg(any(target_os = "vita"))] { - pub type dev_t = c_short; - pub type ino_t = c_ushort; - pub type off_t = c_int; - } else { + } else if #[cfg(any(target_arch = "arm", target_arch = "powerpc"))] { pub type dev_t = u32; pub type ino_t = u32; pub type off_t = i64; + } else { + core::compile_error!("unsupported target"); } } @@ -55,12 +53,12 @@ pub type useconds_t = u32; cfg_if! { if #[cfg(any( - target_os = "horizon", - all(target_os = "espidf", not(espidf_time32)) + all(target_os = "espidf", espidf_time32), + target_os = "vita" ))] { - pub type time_t = c_longlong; + pub type time_t = c_long; } else { - pub type time_t = i32; + pub type time_t = i64; } } @@ -325,6 +323,35 @@ s! { // Unverified size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], } + + #[cfg(all(not(target_os = "vita"), not(target_os = "horizon")))] + pub struct sigset_t { + __val: u32, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_spare4: [c_long; 2usize], + } + + #[cfg(not(target_os = "vita"))] + pub struct dirent { + pub d_ino: crate::ino_t, + pub d_type: c_uchar, + pub d_name: [c_char; 256usize], + } } pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { @@ -935,8 +962,6 @@ extern "C" { pub fn uname(buf: *mut crate::utsname) -> c_int; } -mod generic; - cfg_if! { if #[cfg(target_os = "espidf")] { mod espidf; @@ -950,22 +975,10 @@ cfg_if! { } else if #[cfg(target_arch = "arm")] { mod arm; pub use self::arm::*; - } else if #[cfg(target_arch = "aarch64")] { - mod aarch64; - pub use self::aarch64::*; - } else if #[cfg(target_arch = "powerpc")] { - mod powerpc; - pub use self::powerpc::*; - } else { - // Only tested on ARM so far. Other platforms might have different - // definitions for types and constants. - pub use target_arch_not_implemented; - } -} - -cfg_if! { - if #[cfg(target_os = "rtems")] { + } else if #[cfg(target_os = "rtems")] { mod rtems; pub use self::rtems::*; + } else { + core::compile_error!("unsupported target"); } } diff --git a/src/unix/newlib/powerpc/mod.rs b/src/unix/newlib/powerpc/mod.rs deleted file mode 100644 index f51a1b2cbe602..0000000000000 --- a/src/unix/newlib/powerpc/mod.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::prelude::*; - -pub type clock_t = c_ulong; -pub type wchar_t = c_int; - -pub use crate::unix::newlib::generic::{ - dirent, - sigset_t, - stat, -}; - -// the newlib shipped with devkitPPC does not support the following components: -// - sockaddr -// - AF_INET6 -// - FIONBIO -// - POLL* -// - SOL_SOCKET -// - MSG_*