diff --git a/src/unix/newlib/aarch64/mod.rs b/src/unix/newlib/aarch64/mod.rs index 71aa894922bbe..6454756bf1c16 100644 --- a/src/unix/newlib/aarch64/mod.rs +++ b/src/unix/newlib/aarch64/mod.rs @@ -1,3 +1,5 @@ +pub use crate::unix::newlib::generic::{sigset_t, stat}; + pub type clock_t = ::c_long; pub type c_char = u8; pub type wchar_t = u32; diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs index 78bea276533d5..835455357eb7d 100644 --- a/src/unix/newlib/arm/mod.rs +++ b/src/unix/newlib/arm/mod.rs @@ -1,3 +1,5 @@ +pub use crate::unix::newlib::generic::{sigset_t, stat}; + pub type clock_t = ::c_long; pub type c_char = u8; pub type wchar_t = u32; diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index d3e1059465f7f..7188571a27c76 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -1,3 +1,5 @@ +pub use crate::unix::newlib::generic::{sigset_t, stat}; + pub type clock_t = ::c_ulong; pub type c_char = i8; pub type wchar_t = u32; diff --git a/src/unix/newlib/generic.rs b/src/unix/newlib/generic.rs new file mode 100644 index 0000000000000..db7797f17c297 --- /dev/null +++ b/src/unix/newlib/generic.rs @@ -0,0 +1,27 @@ +//! Common types used by most newlib platforms + +s! { + pub struct sigset_t { + __val: [::c_ulong; 16], + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_atime: ::time_t, + pub st_spare1: ::c_long, + pub st_mtime: ::time_t, + pub st_spare2: ::c_long, + pub st_ctime: ::time_t, + pub st_spare3: ::c_long, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_spare4: [::c_long; 2usize], + } +} diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs index 84dd9c43edb40..7d3e6d02db8ef 100644 --- a/src/unix/newlib/horizon/mod.rs +++ b/src/unix/newlib/horizon/mod.rs @@ -18,8 +18,8 @@ pub type clock_t = c_ulong; pub type daddr_t = c_long; pub type caddr_t = *mut c_char; pub type sbintime_t = ::c_longlong; +pub type sigset_t = ::c_ulong; -// External implementations are needed to use networking and threading. s! { pub struct sockaddr { pub sa_family: ::sa_family_t, @@ -55,6 +55,23 @@ s! { pub struct sched_param { pub sched_priority: ::c_int, } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_atim: ::timespec, + pub st_mtim: ::timespec, + pub st_ctim: ::timespec, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_spare4: [::c_long; 2usize], + } } pub const SIGEV_NONE: ::c_int = 1; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index f4473c543c335..149ade445180a 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -229,57 +229,6 @@ s! { } } -cfg_if! { - if #[cfg(target_os = "horizon")] { - pub type sigset_t = ::c_ulong; - - s! { - pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: dev_t, - pub st_size: off_t, - pub st_atim: ::timespec, - pub st_mtim: ::timespec, - pub st_ctim: ::timespec, - pub st_blksize: blksize_t, - pub st_blocks: blkcnt_t, - pub st_spare4: [::c_long; 2usize], - } - } - } else { - s! { - pub struct sigset_t { - __val: [::c_ulong; 16], - } - - pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: dev_t, - pub st_size: off_t, - pub st_atime: time_t, - pub st_spare1: ::c_long, - pub st_mtime: time_t, - pub st_spare2: ::c_long, - pub st_ctime: time_t, - pub st_spare3: ::c_long, - pub st_blksize: blksize_t, - pub st_blocks: blkcnt_t, - pub st_spare4: [::c_long; 2usize], - } - } - } -} - // unverified constants align_const! { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { @@ -774,6 +723,8 @@ extern "C" { pub fn uname(buf: *mut ::utsname) -> ::c_int; } +mod generic; + cfg_if! { if #[cfg(target_os = "espidf")] { mod espidf; diff --git a/src/unix/newlib/powerpc/mod.rs b/src/unix/newlib/powerpc/mod.rs index 4289658cd6623..d046d202bd020 100644 --- a/src/unix/newlib/powerpc/mod.rs +++ b/src/unix/newlib/powerpc/mod.rs @@ -1,3 +1,5 @@ +pub use crate::unix::newlib::generic::{sigset_t, stat}; + pub type clock_t = ::c_ulong; pub type c_char = u8; pub type wchar_t = ::c_int;