Skip to content

Commit 0c92066

Browse files
committed
Reorganize some newlib definitions into a "generic" module
1 parent b61fe73 commit 0c92066

File tree

7 files changed

+55
-52
lines changed

7 files changed

+55
-52
lines changed

src/unix/newlib/aarch64/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pub use crate::unix::newlib::generic::{sigset_t, stat};
2+
13
pub type clock_t = ::c_long;
24
pub type c_char = u8;
35
pub type wchar_t = u32;

src/unix/newlib/arm/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pub use crate::unix::newlib::generic::{sigset_t, stat};
2+
13
pub type clock_t = ::c_long;
24
pub type c_char = u8;
35
pub type wchar_t = u32;

src/unix/newlib/espidf/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pub use crate::unix::newlib::generic::{sigset_t, stat};
2+
13
pub type clock_t = ::c_ulong;
24
pub type c_char = i8;
35
pub type wchar_t = u32;

src/unix/newlib/generic.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! Common types used by most newlib platforms
2+
3+
s! {
4+
pub struct sigset_t {
5+
__val: [::c_ulong; 16],
6+
}
7+
8+
pub struct stat {
9+
pub st_dev: ::dev_t,
10+
pub st_ino: ::ino_t,
11+
pub st_mode: ::mode_t,
12+
pub st_nlink: ::nlink_t,
13+
pub st_uid: ::uid_t,
14+
pub st_gid: ::gid_t,
15+
pub st_rdev: ::dev_t,
16+
pub st_size: ::off_t,
17+
pub st_atime: ::time_t,
18+
pub st_spare1: ::c_long,
19+
pub st_mtime: ::time_t,
20+
pub st_spare2: ::c_long,
21+
pub st_ctime: ::time_t,
22+
pub st_spare3: ::c_long,
23+
pub st_blksize: ::blksize_t,
24+
pub st_blocks: ::blkcnt_t,
25+
pub st_spare4: [::c_long; 2usize],
26+
}
27+
}

src/unix/newlib/horizon/mod.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ pub type clock_t = c_ulong;
1818
pub type daddr_t = c_long;
1919
pub type caddr_t = *mut c_char;
2020
pub type sbintime_t = ::c_longlong;
21+
pub type sigset_t = ::c_ulong;
2122

22-
// External implementations are needed to use networking and threading.
2323
s! {
2424
pub struct sockaddr {
2525
pub sa_family: ::sa_family_t,
@@ -55,6 +55,23 @@ s! {
5555
pub struct sched_param {
5656
pub sched_priority: ::c_int,
5757
}
58+
59+
pub struct stat {
60+
pub st_dev: ::dev_t,
61+
pub st_ino: ::ino_t,
62+
pub st_mode: ::mode_t,
63+
pub st_nlink: ::nlink_t,
64+
pub st_uid: ::uid_t,
65+
pub st_gid: ::gid_t,
66+
pub st_rdev: ::dev_t,
67+
pub st_size: ::off_t,
68+
pub st_atim: ::timespec,
69+
pub st_mtim: ::timespec,
70+
pub st_ctim: ::timespec,
71+
pub st_blksize: ::blksize_t,
72+
pub st_blocks: ::blkcnt_t,
73+
pub st_spare4: [::c_long; 2usize],
74+
}
5875
}
5976

6077
pub const SIGEV_NONE: ::c_int = 1;

src/unix/newlib/mod.rs

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -229,57 +229,6 @@ s! {
229229
}
230230
}
231231

232-
cfg_if! {
233-
if #[cfg(target_os = "horizon")] {
234-
pub type sigset_t = ::c_ulong;
235-
236-
s! {
237-
pub struct stat {
238-
pub st_dev: ::dev_t,
239-
pub st_ino: ::ino_t,
240-
pub st_mode: ::mode_t,
241-
pub st_nlink: ::nlink_t,
242-
pub st_uid: ::uid_t,
243-
pub st_gid: ::gid_t,
244-
pub st_rdev: dev_t,
245-
pub st_size: off_t,
246-
pub st_atim: ::timespec,
247-
pub st_mtim: ::timespec,
248-
pub st_ctim: ::timespec,
249-
pub st_blksize: blksize_t,
250-
pub st_blocks: blkcnt_t,
251-
pub st_spare4: [::c_long; 2usize],
252-
}
253-
}
254-
} else {
255-
s! {
256-
pub struct sigset_t {
257-
__val: [::c_ulong; 16],
258-
}
259-
260-
pub struct stat {
261-
pub st_dev: ::dev_t,
262-
pub st_ino: ::ino_t,
263-
pub st_mode: ::mode_t,
264-
pub st_nlink: ::nlink_t,
265-
pub st_uid: ::uid_t,
266-
pub st_gid: ::gid_t,
267-
pub st_rdev: dev_t,
268-
pub st_size: off_t,
269-
pub st_atime: time_t,
270-
pub st_spare1: ::c_long,
271-
pub st_mtime: time_t,
272-
pub st_spare2: ::c_long,
273-
pub st_ctime: time_t,
274-
pub st_spare3: ::c_long,
275-
pub st_blksize: blksize_t,
276-
pub st_blocks: blkcnt_t,
277-
pub st_spare4: [::c_long; 2usize],
278-
}
279-
}
280-
}
281-
}
282-
283232
// unverified constants
284233
align_const! {
285234
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
@@ -774,6 +723,8 @@ extern "C" {
774723
pub fn uname(buf: *mut ::utsname) -> ::c_int;
775724
}
776725

726+
mod generic;
727+
777728
cfg_if! {
778729
if #[cfg(target_os = "espidf")] {
779730
mod espidf;

src/unix/newlib/powerpc/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pub use crate::unix::newlib::generic::{sigset_t, stat};
2+
13
pub type clock_t = ::c_ulong;
24
pub type c_char = u8;
35
pub type wchar_t = ::c_int;

0 commit comments

Comments
 (0)