Skip to content

Commit

Permalink
Auto merge of #2215 - JohnTitor:arphrd-can, r=Amanieu
Browse files Browse the repository at this point in the history
Declare `ARPHRD_CAN` on the linux_like module

Supersedes #2077, closes #2077
  • Loading branch information
bors committed Jun 3, 2021
2 parents 2865077 + f77d49b commit 1d51906
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
5 changes: 5 additions & 0 deletions libc-test/Cargo.toml
Expand Up @@ -36,6 +36,11 @@ name = "linux-fcntl"
path = "test/linux_fcntl.rs"
harness = false

[[test]]
name = "linux-if-arp"
path = "test/linux_if_arp.rs"
harness = false

[[test]]
name = "linux-ipv6"
path = "test/linux_ipv6.rs"
Expand Down
19 changes: 18 additions & 1 deletion libc-test/build.rs
Expand Up @@ -2703,6 +2703,9 @@ fn test_linux(target: &str) {
| "F_SEAL_SHRINK"
| "F_SEAL_GROW"
| "F_SEAL_WRITE" => true,
// The `ARPHRD_CAN` is tested in the `linux_if_arp.rs` tests
// because including `linux/if_arp.h` causes some conflicts:
"ARPHRD_CAN" => true,

// Require Linux kernel 5.1:
"F_SEAL_FUTURE_WRITE" => true,
Expand Down Expand Up @@ -3064,7 +3067,6 @@ fn test_linux_like_apis(target: &str) {
cfg.header("elf.h");
cfg.skip_fn(|_| true)
.skip_static(|_| true)
.skip_fn(|_| true)
.skip_const(|_| true)
.type_name(move |ty, _is_struct, _is_union| ty.to_string())
.skip_struct(move |ty| match ty {
Expand All @@ -3077,6 +3079,21 @@ fn test_linux_like_apis(target: &str) {
});
cfg.generate("../src/lib.rs", "linux_elf.rs");
}

if linux || android {
// Test `ARPHRD_CAN`.
let mut cfg = ctest_cfg();
cfg.header("linux/if_arp.h");
cfg.skip_fn(|_| true)
.skip_static(|_| true)
.skip_const(move |name| match name {
"ARPHRD_CAN" => false,
_ => true,
})
.skip_struct(|_| true)
.skip_type(|_| true);
cfg.generate("../src/lib.rs", "linux_if_arp.rs");
}
}

fn which_freebsd() -> Option<i32> {
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/android.txt
Expand Up @@ -69,6 +69,7 @@ ARPHRD_ASH
ARPHRD_ATM
ARPHRD_AX25
ARPHRD_BIF
ARPHRD_CAN
ARPHRD_CHAOS
ARPHRD_CISCO
ARPHRD_CSLIP
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/linux.txt
Expand Up @@ -92,6 +92,7 @@ ARPHRD_ASH
ARPHRD_ATM
ARPHRD_AX25
ARPHRD_BIF
ARPHRD_CAN
ARPHRD_CHAOS
ARPHRD_CISCO
ARPHRD_CSLIP
Expand Down
12 changes: 12 additions & 0 deletions libc-test/test/linux_if_arp.rs
@@ -0,0 +1,12 @@
#![allow(bad_style, improper_ctypes, unused, deprecated)]

extern crate libc;
use libc::*;

#[cfg(any(target_os = "linux", target_os = "android"))]
include!(concat!(env!("OUT_DIR"), "/linux_if_arp.rs"));

#[cfg(not(any(target_os = "linux", target_os = "android")))]
fn main() {
println!("PASSED 0 tests");
}
1 change: 1 addition & 0 deletions src/unix/linux_like/mod.rs
Expand Up @@ -1306,6 +1306,7 @@ pub const ARPHRD_ADAPT: u16 = 264;
pub const ARPHRD_ROSE: u16 = 270;
pub const ARPHRD_X25: u16 = 271;
pub const ARPHRD_HWX25: u16 = 272;
pub const ARPHRD_CAN: u16 = 280;
pub const ARPHRD_PPP: u16 = 512;
pub const ARPHRD_CISCO: u16 = 513;
pub const ARPHRD_HDLC: u16 = ARPHRD_CISCO;
Expand Down

0 comments on commit 1d51906

Please sign in to comment.