diff --git a/build.rs b/build.rs index 76ca0961e4782..f355447a672c6 100644 --- a/build.rs +++ b/build.rs @@ -16,9 +16,15 @@ 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"); } + if let Some(13) = which_freebsd() { + println!("cargo:rustc-cfg=freebsd13"); + } } // Rust >= 1.15 supports private module use: @@ -100,6 +106,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 7eafc086c694d..146beb073442b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1455,10 +1455,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); - } + 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); @@ -1586,7 +1588,7 @@ fn test_freebsd(target: &str) { | "IP_RECVORIGDSTADDR" | "IPV6_ORIGDSTADDR" | "IPV6_RECVORIGDSTADDR" - if Some(12) != freebsd_ver => + if Some(11) == freebsd_ver => { true } @@ -2472,6 +2474,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..464744d140da4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -190,6 +190,15 @@ cfg_if! { } } +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(); 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