From 96ea9c99521180bc4fd4eb07d5d7b699a784fb96 Mon Sep 17 00:00:00 2001 From: Luca Pizzamiglio Date: Sun, 21 Jul 2019 17:49:08 +0200 Subject: [PATCH 1/6] Add support for FreeBSD CURRENT (aka freebsd13) Currently, libc supports and detects freebsd11 and freebsd13 Unknown versions, like freebsd13, is treated as freebsd11. This patch solve the issues, detecting freebsd13 and treating it like freebsd12. Inverting the logic not(freebsd12) -> freebsd11 where possible --- build.rs | 4 ++++ libc-test/build.rs | 8 +++++++- src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs | 2 ++ src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs | 5 +++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 4 +++- src/unix/bsd/freebsdlike/mod.rs | 4 ++-- src/unix/bsd/mod.rs | 4 ++-- src/unix/mod.rs | 14 +++++++------- 8 files changed, 32 insertions(+), 13 deletions(-) diff --git a/build.rs b/build.rs index 76ca0961e4782..c43cca36d2586 100644 --- a/build.rs +++ b/build.rs @@ -19,6 +19,9 @@ fn main() { if let Some(12) = which_freebsd() { println!("cargo:rustc-cfg=freebsd12"); } + if let Some(13) = which_freebsd() { + println!("cargo:rustc-cfg=freebsd13"); + } } // Rust >= 1.15 supports private module use: @@ -100,6 +103,7 @@ fn which_freebsd() -> Option { match &stdout { s if s.starts_with("11") => Some(11), s if s.starts_with("12") => Some(12), + s if s.starts_with("13") => Some(13), _ => None, } } diff --git a/libc-test/build.rs b/libc-test/build.rs index 6edbd0f2ff506..8dffc6819b03d 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1455,6 +1455,11 @@ fn test_freebsd(target: &str) { cfg.cfg("freebsd12", None); } + if let Some(13) = freebsd_ver { + // If the host is FreeBSD 12, run FreeBSD 12 tests + cfg.cfg("freebsd13", None); + } + // Required for `getline`: cfg.define("_WITH_GETLINE", None); // Required for making freebsd11_stat available in the headers @@ -1581,7 +1586,7 @@ fn test_freebsd(target: &str) { | "IP_RECVORIGDSTADDR" | "IPV6_ORIGDSTADDR" | "IPV6_RECVORIGDSTADDR" - if Some(12) != freebsd_ver => + if Some(11) == freebsd_ver => { true } @@ -2468,6 +2473,7 @@ fn which_freebsd() -> Option { match &stdout { s if s.starts_with("11") => Some(11), s if s.starts_with("12") => Some(12), + s if s.starts_with("13") => Some(13), _ => None, } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 7d7dc2c1d4902..b71b284e42554 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -189,6 +189,8 @@ cfg_if! { } } +pub const ELAST: ::c_int = 96; + extern { // Return type ::c_int was removed in FreeBSD 12 pub fn setgrent() -> ::c_int; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index ab1b8d98357b3..c01916955fd97 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -190,6 +190,11 @@ cfg_if! { } } +#[cfg(not(freebsd13))] +pub const ELAST: ::c_int = 96; +#[cfg(freebsd13)] +pub const ELAST: ::c_int = 97; + extern { pub fn setgrent(); pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 9f11c202bb4ea..c178b91b9408e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -333,7 +333,6 @@ pub const ENOTCAPABLE: ::c_int = 93; pub const ECAPMODE: ::c_int = 94; pub const ENOTRECOVERABLE: ::c_int = 95; pub const EOWNERDEAD: ::c_int = 96; -pub const ELAST: ::c_int = 96; pub const RLIMIT_NPTS: ::c_int = 11; pub const RLIMIT_SWAP: ::c_int = 12; pub const RLIMIT_KQUEUES: ::c_int = 13; @@ -1332,6 +1331,9 @@ cfg_if! { if #[cfg(freebsd12)] { mod freebsd12; pub use self::freebsd12::*; + } else if #[cfg(freebsd13)] { + mod freebsd12; + pub use self::freebsd12::*; } else { mod freebsd11; pub use self::freebsd11::*; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index ce5452062ce3d..f937d772a9a44 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1152,7 +1152,7 @@ extern { pub fn getutxline(ut: *const utmpx) -> *mut utmpx; pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int; #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "kevent@FBSD_1.0" )] pub fn kevent(kq: ::c_int, @@ -1171,7 +1171,7 @@ extern { pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int; #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "mknodat@FBSD_1.1" )] pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 77f82b182bb57..ee644114a4867 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -536,7 +536,7 @@ extern { #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "glob@FBSD_1.0" )] pub fn glob(pattern: *const ::c_char, @@ -546,7 +546,7 @@ extern { pglob: *mut ::glob_t) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "globfree@FBSD_1.0" )] pub fn globfree(pglob: *mut ::glob_t); diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 8295dfc020c9c..ab803cbcd41ca 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -567,7 +567,7 @@ extern { #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "fstat@FBSD_1.0" )] pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; @@ -577,7 +577,7 @@ extern { #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__stat50")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "stat@FBSD_1.0" )] pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; @@ -614,14 +614,14 @@ extern { #[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "readdir@FBSD_1.0" )] pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent; #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "readdir_r@FBSD_1.0" )] /// The 64-bit libc on Solaris and illumos only has readdir_r. If a @@ -653,7 +653,7 @@ extern { flags: ::c_int) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "fstatat@FBSD_1.1" )] pub fn fstatat(dirfd: ::c_int, pathname: *const ::c_char, @@ -815,7 +815,7 @@ extern { #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "lstat@FBSD_1.0" )] pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int; @@ -992,7 +992,7 @@ extern { #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "mknod@FBSD_1.0" )] pub fn mknod(pathname: *const ::c_char, mode: ::mode_t, From c2c62cc8a4c275c59eb972da9bbe8270849e0b24 Mon Sep 17 00:00:00 2001 From: Luca Pizzamiglio Date: Sun, 21 Jul 2019 17:55:11 +0200 Subject: [PATCH 2/6] Add EINTEGRITY errno and fix style --- src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index c01916955fd97..464744d140da4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -190,10 +190,14 @@ cfg_if! { } } -#[cfg(not(freebsd13))] -pub const ELAST: ::c_int = 96; -#[cfg(freebsd13)] -pub const ELAST: ::c_int = 97; +cfg_if! { + if #[cfg(not(freebsd13))] { + pub const ELAST: ::c_int = 96; + } else { + pub const EINTEGRITY: ::c_int = 97; + pub const ELAST: ::c_int = 97; + } +} extern { pub fn setgrent(); From 72aa2262ca3e8e7889e8872b7508b81d56d70e6a Mon Sep 17 00:00:00 2001 From: Luca Pizzamiglio Date: Sun, 21 Jul 2019 18:10:40 +0200 Subject: [PATCH 3/6] Properly define freebsd11 attribute --- build.rs | 3 +++ libc-test/build.rs | 15 ++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build.rs b/build.rs index c43cca36d2586..f355447a672c6 100644 --- a/build.rs +++ b/build.rs @@ -16,6 +16,9 @@ fn main() { } if env::var("LIBC_CI").is_ok() { + if let Some(11) = which_freebsd() { + println!("cargo:rustc-cfg=freebsd11"); + } if let Some(12) = which_freebsd() { println!("cargo:rustc-cfg=freebsd12"); } diff --git a/libc-test/build.rs b/libc-test/build.rs index 8dffc6819b03d..02e769ea80181 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1450,15 +1450,12 @@ fn test_freebsd(target: &str) { let freebsd_ver = which_freebsd(); - if let Some(12) = freebsd_ver { - // If the host is FreeBSD 12, run FreeBSD 12 tests - cfg.cfg("freebsd12", None); - } - - if let Some(13) = freebsd_ver { - // If the host is FreeBSD 12, run FreeBSD 12 tests - cfg.cfg("freebsd13", None); - } + match freebsd_ver { + Some(11) => cfg.cfg("freebsd11", None), + Some(12) => cfg.cfg("freebsd12", None), + Some(13) => cfg.cfg("freebsd13", None), + _ => &mut cfg + }; // Required for `getline`: cfg.define("_WITH_GETLINE", None); From 4a74f1e0df84257aac462b725f14b080da703037 Mon Sep 17 00:00:00 2001 From: Luca Pizzamiglio Date: Sun, 21 Jul 2019 17:49:08 +0200 Subject: [PATCH 4/6] Add support for FreeBSD CURRENT (aka freebsd13) Currently, libc supports and detects freebsd11 and freebsd13 Unknown versions, like freebsd13, is treated as freebsd11. This patch solve the issues, detecting freebsd13 and treating it like freebsd12. Inverting the logic not(freebsd12) -> freebsd11 where possible --- build.rs | 4 ++++ libc-test/build.rs | 8 +++++++- src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs | 2 ++ src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs | 5 +++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 4 +++- src/unix/bsd/freebsdlike/mod.rs | 4 ++-- src/unix/bsd/mod.rs | 4 ++-- src/unix/mod.rs | 14 +++++++------- 8 files changed, 32 insertions(+), 13 deletions(-) diff --git a/build.rs b/build.rs index 76ca0961e4782..c43cca36d2586 100644 --- a/build.rs +++ b/build.rs @@ -19,6 +19,9 @@ fn main() { if let Some(12) = which_freebsd() { println!("cargo:rustc-cfg=freebsd12"); } + if let Some(13) = which_freebsd() { + println!("cargo:rustc-cfg=freebsd13"); + } } // Rust >= 1.15 supports private module use: @@ -100,6 +103,7 @@ fn which_freebsd() -> Option { match &stdout { s if s.starts_with("11") => Some(11), s if s.starts_with("12") => Some(12), + s if s.starts_with("13") => Some(13), _ => None, } } diff --git a/libc-test/build.rs b/libc-test/build.rs index 6edbd0f2ff506..8dffc6819b03d 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1455,6 +1455,11 @@ fn test_freebsd(target: &str) { cfg.cfg("freebsd12", None); } + if let Some(13) = freebsd_ver { + // If the host is FreeBSD 12, run FreeBSD 12 tests + cfg.cfg("freebsd13", None); + } + // Required for `getline`: cfg.define("_WITH_GETLINE", None); // Required for making freebsd11_stat available in the headers @@ -1581,7 +1586,7 @@ fn test_freebsd(target: &str) { | "IP_RECVORIGDSTADDR" | "IPV6_ORIGDSTADDR" | "IPV6_RECVORIGDSTADDR" - if Some(12) != freebsd_ver => + if Some(11) == freebsd_ver => { true } @@ -2468,6 +2473,7 @@ fn which_freebsd() -> Option { match &stdout { s if s.starts_with("11") => Some(11), s if s.starts_with("12") => Some(12), + s if s.starts_with("13") => Some(13), _ => None, } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 7d7dc2c1d4902..b71b284e42554 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -189,6 +189,8 @@ cfg_if! { } } +pub const ELAST: ::c_int = 96; + extern { // Return type ::c_int was removed in FreeBSD 12 pub fn setgrent() -> ::c_int; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index ab1b8d98357b3..c01916955fd97 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -190,6 +190,11 @@ cfg_if! { } } +#[cfg(not(freebsd13))] +pub const ELAST: ::c_int = 96; +#[cfg(freebsd13)] +pub const ELAST: ::c_int = 97; + extern { pub fn setgrent(); pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 9f11c202bb4ea..c178b91b9408e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -333,7 +333,6 @@ pub const ENOTCAPABLE: ::c_int = 93; pub const ECAPMODE: ::c_int = 94; pub const ENOTRECOVERABLE: ::c_int = 95; pub const EOWNERDEAD: ::c_int = 96; -pub const ELAST: ::c_int = 96; pub const RLIMIT_NPTS: ::c_int = 11; pub const RLIMIT_SWAP: ::c_int = 12; pub const RLIMIT_KQUEUES: ::c_int = 13; @@ -1332,6 +1331,9 @@ cfg_if! { if #[cfg(freebsd12)] { mod freebsd12; pub use self::freebsd12::*; + } else if #[cfg(freebsd13)] { + mod freebsd12; + pub use self::freebsd12::*; } else { mod freebsd11; pub use self::freebsd11::*; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index ce5452062ce3d..f937d772a9a44 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1152,7 +1152,7 @@ extern { pub fn getutxline(ut: *const utmpx) -> *mut utmpx; pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int; #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "kevent@FBSD_1.0" )] pub fn kevent(kq: ::c_int, @@ -1171,7 +1171,7 @@ extern { pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int; #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "mknodat@FBSD_1.1" )] pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 77f82b182bb57..ee644114a4867 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -536,7 +536,7 @@ extern { #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "glob@FBSD_1.0" )] pub fn glob(pattern: *const ::c_char, @@ -546,7 +546,7 @@ extern { pglob: *mut ::glob_t) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "globfree@FBSD_1.0" )] pub fn globfree(pglob: *mut ::glob_t); diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 65cf7ecf5c05d..721d241164a1d 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -567,7 +567,7 @@ extern { #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "fstat@FBSD_1.0" )] pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; @@ -577,7 +577,7 @@ extern { #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__stat50")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "stat@FBSD_1.0" )] pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; @@ -608,7 +608,7 @@ extern { #[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "readdir@FBSD_1.0" )] pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent; @@ -631,7 +631,7 @@ extern { flags: ::c_int) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "fstatat@FBSD_1.1" )] pub fn fstatat(dirfd: ::c_int, pathname: *const ::c_char, @@ -786,7 +786,7 @@ extern { #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "lstat@FBSD_1.0" )] pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int; @@ -962,7 +962,7 @@ extern { #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "mknod@FBSD_1.0" )] pub fn mknod(pathname: *const ::c_char, mode: ::mode_t, @@ -1126,7 +1126,7 @@ cfg_if! { #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] #[cfg_attr( - all(target_os = "freebsd", not(freebsd12)), + all(target_os = "freebsd", freebsd11), link_name = "readdir_r@FBSD_1.0" )] /// The 64-bit libc on Solaris and illumos only has readdir_r. If a From bde8b842a48aee64b7a2f1746aebce1013474cf5 Mon Sep 17 00:00:00 2001 From: Luca Pizzamiglio Date: Sun, 21 Jul 2019 17:55:11 +0200 Subject: [PATCH 5/6] Add EINTEGRITY errno and fix style --- src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index c01916955fd97..464744d140da4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -190,10 +190,14 @@ cfg_if! { } } -#[cfg(not(freebsd13))] -pub const ELAST: ::c_int = 96; -#[cfg(freebsd13)] -pub const ELAST: ::c_int = 97; +cfg_if! { + if #[cfg(not(freebsd13))] { + pub const ELAST: ::c_int = 96; + } else { + pub const EINTEGRITY: ::c_int = 97; + pub const ELAST: ::c_int = 97; + } +} extern { pub fn setgrent(); From 64bc745405116ff5eaa0358fb46bc2233e0756a7 Mon Sep 17 00:00:00 2001 From: Luca Pizzamiglio Date: Sun, 21 Jul 2019 18:10:40 +0200 Subject: [PATCH 6/6] Properly define freebsd11 attribute --- build.rs | 3 +++ libc-test/build.rs | 15 ++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build.rs b/build.rs index c43cca36d2586..f355447a672c6 100644 --- a/build.rs +++ b/build.rs @@ -16,6 +16,9 @@ fn main() { } if env::var("LIBC_CI").is_ok() { + if let Some(11) = which_freebsd() { + println!("cargo:rustc-cfg=freebsd11"); + } if let Some(12) = which_freebsd() { println!("cargo:rustc-cfg=freebsd12"); } diff --git a/libc-test/build.rs b/libc-test/build.rs index 8dffc6819b03d..02e769ea80181 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1450,15 +1450,12 @@ fn test_freebsd(target: &str) { let freebsd_ver = which_freebsd(); - if let Some(12) = freebsd_ver { - // If the host is FreeBSD 12, run FreeBSD 12 tests - cfg.cfg("freebsd12", None); - } - - if let Some(13) = freebsd_ver { - // If the host is FreeBSD 12, run FreeBSD 12 tests - cfg.cfg("freebsd13", None); - } + match freebsd_ver { + Some(11) => cfg.cfg("freebsd11", None), + Some(12) => cfg.cfg("freebsd12", None), + Some(13) => cfg.cfg("freebsd13", None), + _ => &mut cfg + }; // Required for `getline`: cfg.define("_WITH_GETLINE", None);