Skip to content

Commit 245b0f8

Browse files
committed
Auto merge of #1440 - pizzamig:invert-freebsd12, r=gnzlbg
Add support for FreeBSD CURRENT (aka freebsd13) Using the last FreeBSD-CURRENT (development snapshot) the libc build, but tests fail. This patch detects and supports FreeBSD CURRENT as freebsd13, and reworks the conditional compilation to use the `freebsd11` attribute instead of `not(freebsd12)` For now, freebsd13 is reusing all freebsd12 definitions, except for `ELAST` While here, add a new `errno`introduced in freebsd13
2 parents 692dc54 + 154e58d commit 245b0f8

File tree

8 files changed

+40
-17
lines changed

8 files changed

+40
-17
lines changed

build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ fn main() {
1616
}
1717

1818
if env::var("LIBC_CI").is_ok() {
19+
if let Some(11) = which_freebsd() {
20+
println!("cargo:rustc-cfg=freebsd11");
21+
}
1922
if let Some(12) = which_freebsd() {
2023
println!("cargo:rustc-cfg=freebsd12");
2124
}
25+
if let Some(13) = which_freebsd() {
26+
println!("cargo:rustc-cfg=freebsd13");
27+
}
2228
}
2329

2430
// Rust >= 1.15 supports private module use:
@@ -100,6 +106,7 @@ fn which_freebsd() -> Option<i32> {
100106
match &stdout {
101107
s if s.starts_with("11") => Some(11),
102108
s if s.starts_with("12") => Some(12),
109+
s if s.starts_with("13") => Some(13),
103110
_ => None,
104111
}
105112
}

libc-test/build.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,10 +1455,12 @@ fn test_freebsd(target: &str) {
14551455

14561456
let freebsd_ver = which_freebsd();
14571457

1458-
if let Some(12) = freebsd_ver {
1459-
// If the host is FreeBSD 12, run FreeBSD 12 tests
1460-
cfg.cfg("freebsd12", None);
1461-
}
1458+
match freebsd_ver {
1459+
Some(11) => cfg.cfg("freebsd11", None),
1460+
Some(12) => cfg.cfg("freebsd12", None),
1461+
Some(13) => cfg.cfg("freebsd13", None),
1462+
_ => &mut cfg,
1463+
};
14621464

14631465
// Required for `getline`:
14641466
cfg.define("_WITH_GETLINE", None);
@@ -1586,7 +1588,7 @@ fn test_freebsd(target: &str) {
15861588
| "IP_RECVORIGDSTADDR"
15871589
| "IPV6_ORIGDSTADDR"
15881590
| "IPV6_RECVORIGDSTADDR"
1589-
if Some(12) != freebsd_ver =>
1591+
if Some(11) == freebsd_ver =>
15901592
{
15911593
true
15921594
}
@@ -2472,6 +2474,7 @@ fn which_freebsd() -> Option<i32> {
24722474
match &stdout {
24732475
s if s.starts_with("11") => Some(11),
24742476
s if s.starts_with("12") => Some(12),
2477+
s if s.starts_with("13") => Some(13),
24752478
_ => None,
24762479
}
24772480
}

src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ cfg_if! {
189189
}
190190
}
191191

192+
pub const ELAST: ::c_int = 96;
193+
192194
extern {
193195
// Return type ::c_int was removed in FreeBSD 12
194196
pub fn setgrent() -> ::c_int;

src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ cfg_if! {
190190
}
191191
}
192192

193+
cfg_if! {
194+
if #[cfg(not(freebsd13))] {
195+
pub const ELAST: ::c_int = 96;
196+
} else {
197+
pub const EINTEGRITY: ::c_int = 97;
198+
pub const ELAST: ::c_int = 97;
199+
}
200+
}
201+
193202
extern {
194203
pub fn setgrent();
195204
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ pub const ENOTCAPABLE: ::c_int = 93;
333333
pub const ECAPMODE: ::c_int = 94;
334334
pub const ENOTRECOVERABLE: ::c_int = 95;
335335
pub const EOWNERDEAD: ::c_int = 96;
336-
pub const ELAST: ::c_int = 96;
337336
pub const RLIMIT_NPTS: ::c_int = 11;
338337
pub const RLIMIT_SWAP: ::c_int = 12;
339338
pub const RLIMIT_KQUEUES: ::c_int = 13;
@@ -1332,6 +1331,9 @@ cfg_if! {
13321331
if #[cfg(freebsd12)] {
13331332
mod freebsd12;
13341333
pub use self::freebsd12::*;
1334+
} else if #[cfg(freebsd13)] {
1335+
mod freebsd12;
1336+
pub use self::freebsd12::*;
13351337
} else {
13361338
mod freebsd11;
13371339
pub use self::freebsd11::*;

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ extern {
11521152
pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
11531153
pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int;
11541154
#[cfg_attr(
1155-
all(target_os = "freebsd", not(freebsd12)),
1155+
all(target_os = "freebsd", freebsd11),
11561156
link_name = "kevent@FBSD_1.0"
11571157
)]
11581158
pub fn kevent(kq: ::c_int,
@@ -1171,7 +1171,7 @@ extern {
11711171
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
11721172
mode: ::mode_t) -> ::c_int;
11731173
#[cfg_attr(
1174-
all(target_os = "freebsd", not(freebsd12)),
1174+
all(target_os = "freebsd", freebsd11),
11751175
link_name = "mknodat@FBSD_1.1"
11761176
)]
11771177
pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char,

src/unix/bsd/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ extern {
536536
#[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
537537
#[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
538538
#[cfg_attr(
539-
all(target_os = "freebsd", not(freebsd12)),
539+
all(target_os = "freebsd", freebsd11),
540540
link_name = "glob@FBSD_1.0"
541541
)]
542542
pub fn glob(pattern: *const ::c_char,
@@ -546,7 +546,7 @@ extern {
546546
pglob: *mut ::glob_t) -> ::c_int;
547547
#[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
548548
#[cfg_attr(
549-
all(target_os = "freebsd", not(freebsd12)),
549+
all(target_os = "freebsd", freebsd11),
550550
link_name = "globfree@FBSD_1.0"
551551
)]
552552
pub fn globfree(pglob: *mut ::glob_t);

src/unix/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ extern {
567567
#[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")]
568568
#[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
569569
#[cfg_attr(
570-
all(target_os = "freebsd", not(freebsd12)),
570+
all(target_os = "freebsd", freebsd11),
571571
link_name = "fstat@FBSD_1.0"
572572
)]
573573
pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
@@ -577,7 +577,7 @@ extern {
577577
#[cfg_attr(target_os = "macos", link_name = "stat$INODE64")]
578578
#[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
579579
#[cfg_attr(
580-
all(target_os = "freebsd", not(freebsd12)),
580+
all(target_os = "freebsd", freebsd11),
581581
link_name = "stat@FBSD_1.0"
582582
)]
583583
pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
@@ -608,7 +608,7 @@ extern {
608608
#[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")]
609609
#[cfg_attr(target_os = "netbsd", link_name = "__readdir30")]
610610
#[cfg_attr(
611-
all(target_os = "freebsd", not(freebsd12)),
611+
all(target_os = "freebsd", freebsd11),
612612
link_name = "readdir@FBSD_1.0"
613613
)]
614614
pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
@@ -631,7 +631,7 @@ extern {
631631
flags: ::c_int) -> ::c_int;
632632
#[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")]
633633
#[cfg_attr(
634-
all(target_os = "freebsd", not(freebsd12)),
634+
all(target_os = "freebsd", freebsd11),
635635
link_name = "fstatat@FBSD_1.1"
636636
)]
637637
pub fn fstatat(dirfd: ::c_int, pathname: *const ::c_char,
@@ -786,7 +786,7 @@ extern {
786786
#[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")]
787787
#[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
788788
#[cfg_attr(
789-
all(target_os = "freebsd", not(freebsd12)),
789+
all(target_os = "freebsd", freebsd11),
790790
link_name = "lstat@FBSD_1.0"
791791
)]
792792
pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
@@ -962,7 +962,7 @@ extern {
962962

963963
#[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
964964
#[cfg_attr(
965-
all(target_os = "freebsd", not(freebsd12)),
965+
all(target_os = "freebsd", freebsd11),
966966
link_name = "mknod@FBSD_1.0"
967967
)]
968968
pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
@@ -1126,7 +1126,7 @@ cfg_if! {
11261126
#[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
11271127
#[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
11281128
#[cfg_attr(
1129-
all(target_os = "freebsd", not(freebsd12)),
1129+
all(target_os = "freebsd", freebsd11),
11301130
link_name = "readdir_r@FBSD_1.0"
11311131
)]
11321132
/// The 64-bit libc on Solaris and illumos only has readdir_r. If a

0 commit comments

Comments
 (0)