Skip to content

Commit 75710d9

Browse files
committed
glibc: Initial setup of source reorganization
Establish the basic source reorganization for glibc, and seed it with a `net/route.h` definition. Glibc has the same headers in various locations, then copies or (I believe) combines them in the install location based on the target platform. To mirror this, our source primarily mirrors the glibc source tree, then reexports things in `src/new/glibc.rs` in the same way that glibc does when it creates an install.
1 parent 9cf1a1c commit 75710d9

File tree

7 files changed

+71
-22
lines changed

7 files changed

+71
-22
lines changed

src/new/glibc/mod.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,25 @@
22
//!
33
//! * Headers: <https://sourceware.org/git/?p=glibc.git> (official)
44
//! * Headers: <https://github.com/bminor/glibc> (mirror)
5+
//!
6+
//! This module structure is modeled after glibc's source tree. Its build system selects headers
7+
//! from different locations based on the platform, which we mimic here with reexports.
8+
9+
/// Source directory: `posix/`
10+
///
11+
/// <https://github.com/bminor/glibc/tree/master/posix>
12+
mod posix {
13+
pub(crate) mod unistd;
14+
}
15+
16+
/// Source directory: `sysdeps/`
17+
///
18+
/// <https://github.com/bminor/glibc/tree/master/sysdeps>
19+
mod sysdeps {
20+
#[cfg(target_family = "unix")]
21+
pub(crate) mod unix;
22+
}
523

6-
pub(crate) mod unistd;
24+
pub(crate) use posix::*;
25+
#[cfg(target_os = "linux")]
26+
pub(crate) use sysdeps::unix::linux::*;

src/new/glibc/unistd.rs renamed to src/new/glibc/posix/unistd.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//! Header: `unistd.h`
2+
//!
3+
//! <https://github.com/bminor/glibc/blob/master/posix/unistd.h>
24
35
pub use crate::new::common::posix::unistd::{
46
STDERR_FILENO,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//! Source directory: `sysdeps/unix/sysv/linux` (the `sysv` is flattened).
2+
//!
3+
//! <https://github.com/bminor/glibc/tree/master/sysdeps/unix/sysv/linux>
4+
5+
/// Directory: `net/`
6+
///
7+
/// Source directory: `sysdeps/unix/sysv/linux/net`
8+
pub(crate) mod net {
9+
pub(crate) mod route;
10+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//! Header: `net/route.h`
2+
//!
3+
//! Source header: `sysdeps/unix/sysv/linux/net/route.h`
4+
//! <https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/net/route.h>
5+
6+
use crate::prelude::*;
7+
8+
s! {
9+
pub struct rtentry {
10+
pub rt_pad1: c_ulong,
11+
pub rt_dst: crate::sockaddr,
12+
pub rt_gateway: crate::sockaddr,
13+
pub rt_genmask: crate::sockaddr,
14+
pub rt_flags: c_ushort,
15+
pub rt_pad2: c_short,
16+
pub rt_pad3: c_ulong,
17+
pub rt_tos: c_uchar,
18+
pub rt_class: c_uchar,
19+
// FIXME(1.0): private padding fields
20+
#[cfg(target_pointer_width = "64")]
21+
pub rt_pad4: [c_short; 3usize],
22+
#[cfg(not(target_pointer_width = "64"))]
23+
pub rt_pad4: c_short,
24+
pub rt_metric: c_short,
25+
pub rt_dev: *mut c_char,
26+
pub rt_mtu: c_ulong,
27+
pub rt_window: c_ulong,
28+
pub rt_irtt: c_ushort,
29+
}
30+
}

src/new/glibc/sysdeps/unix/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//! Source directory: `sysdeps/unix/`
2+
//!
3+
//! <https://github.com/bminor/glibc/tree/master/sysdeps/unix>
4+
5+
#[cfg(target_os = "linux")]
6+
pub(crate) mod linux;

src/new/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ cfg_if! {
177177
pub use linux::can::raw::*;
178178
pub use linux::can::*;
179179
pub use linux::keyctl::*;
180+
#[cfg(target_env = "gnu")]
181+
pub use net::route::*;
180182
} else if #[cfg(target_vendor = "apple")] {
181183
pub use signal::*;
182184
}

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,27 +131,6 @@ s! {
131131
pub nm_gid: u32,
132132
}
133133

134-
pub struct rtentry {
135-
pub rt_pad1: c_ulong,
136-
pub rt_dst: crate::sockaddr,
137-
pub rt_gateway: crate::sockaddr,
138-
pub rt_genmask: crate::sockaddr,
139-
pub rt_flags: c_ushort,
140-
pub rt_pad2: c_short,
141-
pub rt_pad3: c_ulong,
142-
pub rt_tos: c_uchar,
143-
pub rt_class: c_uchar,
144-
#[cfg(target_pointer_width = "64")]
145-
pub rt_pad4: [c_short; 3usize],
146-
#[cfg(not(target_pointer_width = "64"))]
147-
pub rt_pad4: c_short,
148-
pub rt_metric: c_short,
149-
pub rt_dev: *mut c_char,
150-
pub rt_mtu: c_ulong,
151-
pub rt_window: c_ulong,
152-
pub rt_irtt: c_ushort,
153-
}
154-
155134
pub struct ntptimeval {
156135
pub time: crate::timeval,
157136
pub maxerror: c_long,

0 commit comments

Comments
 (0)