Skip to content

Commit b328398

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. (backport <#4540>) (cherry picked from commit 0399c4e)
1 parent 2d2ed69 commit b328398

File tree

7 files changed

+70
-22
lines changed

7 files changed

+70
-22
lines changed

src/new/glibc/mod.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,24 @@
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+
pub(crate) mod unix;
21+
}
522

6-
pub(crate) mod unistd;
23+
pub(crate) use posix::*;
24+
#[cfg(target_os = "linux")]
25+
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
@@ -153,27 +153,6 @@ s! {
153153
pub nm_gid: u32,
154154
}
155155

156-
pub struct rtentry {
157-
pub rt_pad1: c_ulong,
158-
pub rt_dst: crate::sockaddr,
159-
pub rt_gateway: crate::sockaddr,
160-
pub rt_genmask: crate::sockaddr,
161-
pub rt_flags: c_ushort,
162-
pub rt_pad2: c_short,
163-
pub rt_pad3: c_ulong,
164-
pub rt_tos: c_uchar,
165-
pub rt_class: c_uchar,
166-
#[cfg(target_pointer_width = "64")]
167-
pub rt_pad4: [c_short; 3usize],
168-
#[cfg(not(target_pointer_width = "64"))]
169-
pub rt_pad4: c_short,
170-
pub rt_metric: c_short,
171-
pub rt_dev: *mut c_char,
172-
pub rt_mtu: c_ulong,
173-
pub rt_window: c_ulong,
174-
pub rt_irtt: c_ushort,
175-
}
176-
177156
pub struct ntptimeval {
178157
pub time: crate::timeval,
179158
pub maxerror: c_long,

0 commit comments

Comments
 (0)