summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Drobnak <mark.drobnak@gmail.com>2022-03-13 17:39:24 -0700
committerMark Drobnak <mark.drobnak@gmail.com>2022-03-13 17:44:08 -0700
commit0c92066e212219feef8472a8c66621e09eabd209 (patch)
tree89ddd1471eb7a4d9ca8b450e59c87e51d41f95eb
parentb61fe73f3fbf820bafa06e841dda1b803cb7b5dd (diff)
downloadrust-libc-0c92066e212219feef8472a8c66621e09eabd209.tar.gz
Reorganize some newlib definitions into a "generic" module
-rw-r--r--src/unix/newlib/aarch64/mod.rs2
-rw-r--r--src/unix/newlib/arm/mod.rs2
-rw-r--r--src/unix/newlib/espidf/mod.rs2
-rw-r--r--src/unix/newlib/generic.rs27
-rw-r--r--src/unix/newlib/horizon/mod.rs19
-rw-r--r--src/unix/newlib/mod.rs53
-rw-r--r--src/unix/newlib/powerpc/mod.rs2
7 files changed, 55 insertions, 52 deletions
diff --git a/src/unix/newlib/aarch64/mod.rs b/src/unix/newlib/aarch64/mod.rs
index 71aa894922..6454756bf1 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 78bea27653..835455357e 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 d3e1059465..7188571a27 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 0000000000..db7797f17c
--- /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 84dd9c43ed..7d3e6d02db 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 f4473c543c..149ade4451 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 4289658cd6..d046d202bd 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;