Skip to content

Commit

Permalink
Skip items not available in FreeBSD10 in the libc-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzlbg committed Aug 25, 2019
1 parent efaabd8 commit 6db91d8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 41 deletions.
41 changes: 41 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,15 @@ fn test_freebsd(target: &str) {
}
});

cfg.skip_type(move |ty| {
match ty {
// `mmsghdr` is not available in FreeBSD 10
"mmsghdr" if Some(10) == freebsd_ver => true,

_ => false,
}
});

cfg.skip_const(move |name| {
match name {
// These constants were introduced in FreeBSD 12:
Expand All @@ -1598,6 +1607,31 @@ fn test_freebsd(target: &str) {
true
}

// These constants were introduced in FreeBSD 11:
"SF_USER_READAHEAD"
| "SF_NOCACHE"
| "RLIMIT_KQUEUES"
| "RLIMIT_UMTXP"
| "EVFILT_PROCDESC"
| "EVFILT_SENDFILE"
| "EVFILT_EMPTY"
| "SO_REUSEPORT_LB"
| "TCP_CCALGOOPT"
| "TCP_PCAP_OUT"
| "TCP_PCAP_IN"
| "IP_BINDMULTI"
| "IP_ORIGDSTADDR "
| "IP_RECVORIGDSTADDR "
| "IPV6_ORIGDSTADDR"
| "IPV6_RECVORIGDSTADDR"
| "PD_CLOEXEC"
| "PD_ALLOWED_AT_FORK"
| "IP_RSS_LISTEN_BUCKET"
if Some(10) == freebsd_ver =>
{
true
}

// FIXME: This constant has a different value in FreeBSD 10:
"RLIM_NLIMITS" if Some(10) == freebsd_ver => true,

Expand All @@ -1622,6 +1656,13 @@ fn test_freebsd(target: &str) {
// FIXME: https://github.com/rust-lang/libc/issues/1272
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true,

// These functions were added in FreeBSD 11:
"fdatasync" | "aio_waitcomplete" | "mq_getfd_np"
if Some(10) == freebsd_ver =>
{
true
}

// The `uname` function in the `utsname.h` FreeBSD header is a C
// inline function (has no symbol) that calls the `__xuname` symbol.
// Therefore the function pointer comparison does not make sense for it.
Expand Down
60 changes: 19 additions & 41 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,7 @@ s! {
pub ss_size: ::size_t,
pub ss_flags: ::c_int,
}
}

// FIXME: FreeBSD10 is only defined when building libstd
// These types are not available in FreeBSD10 and
// cfg'ing them out prevents them from being used from
// libstd by accident.
#[cfg(not(freebsd10))]
s! {
pub struct mmsghdr {
pub msg_hdr: ::msghdr,
pub msg_len: ::ssize_t,
Expand Down Expand Up @@ -314,33 +307,25 @@ cfg_if! {
}
}

// FIXME: FreeBSD10 is only defined when building libstd
// These constants are not available in FreeBSD10 and
// cfg'ing them out prevents them from being used from
// libstd by accident.
cfg_if! {
if #[cfg(not(freebsd10))] {
pub const SF_USER_READAHEAD: ::c_int = 0x00000008;
pub const SF_NOCACHE: ::c_int = 0x00000010;
pub const RLIMIT_KQUEUES: ::c_int = 13;
pub const RLIMIT_UMTXP: ::c_int = 14;
pub const EVFILT_PROCDESC: i16 = -8;
pub const EVFILT_SENDFILE: i16 = -12;
pub const EVFILT_EMPTY: i16 = -13;
pub const SO_REUSEPORT_LB: ::c_int = 0x10000;
pub const TCP_CCALGOOPT: ::c_int = 65;
pub const TCP_PCAP_OUT: ::c_int = 2048;
pub const TCP_PCAP_IN: ::c_int = 4096;
pub const IP_BINDMULTI: ::c_int = 25;
pub const IP_ORIGDSTADDR : ::c_int = 27;
pub const IP_RECVORIGDSTADDR : ::c_int = IP_ORIGDSTADDR;
pub const IPV6_ORIGDSTADDR: ::c_int = 72;
pub const IPV6_RECVORIGDSTADDR: ::c_int = IPV6_ORIGDSTADDR;
pub const PD_CLOEXEC: ::c_int = 0x00000002;
pub const PD_ALLOWED_AT_FORK: ::c_int = PD_DAEMON | PD_CLOEXEC;
pub const IP_RSS_LISTEN_BUCKET: ::c_int = 26;
}
}
pub const SF_USER_READAHEAD: ::c_int = 0x00000008;
pub const SF_NOCACHE: ::c_int = 0x00000010;
pub const RLIMIT_KQUEUES: ::c_int = 13;
pub const RLIMIT_UMTXP: ::c_int = 14;
pub const EVFILT_PROCDESC: i16 = -8;
pub const EVFILT_SENDFILE: i16 = -12;
pub const EVFILT_EMPTY: i16 = -13;
pub const SO_REUSEPORT_LB: ::c_int = 0x10000;
pub const TCP_CCALGOOPT: ::c_int = 65;
pub const TCP_PCAP_OUT: ::c_int = 2048;
pub const TCP_PCAP_IN: ::c_int = 4096;
pub const IP_BINDMULTI: ::c_int = 25;
pub const IP_ORIGDSTADDR : ::c_int = 27;
pub const IP_RECVORIGDSTADDR : ::c_int = IP_ORIGDSTADDR;
pub const IPV6_ORIGDSTADDR: ::c_int = 72;
pub const IPV6_RECVORIGDSTADDR: ::c_int = IPV6_ORIGDSTADDR;
pub const PD_CLOEXEC: ::c_int = 0x00000002;
pub const PD_ALLOWED_AT_FORK: ::c_int = PD_DAEMON | PD_CLOEXEC;
pub const IP_RSS_LISTEN_BUCKET: ::c_int = 26;

pub const SIGEV_THREAD_ID: ::c_int = 4;

Expand Down Expand Up @@ -1149,19 +1134,12 @@ f! {
}
}

// FIXME: FreeBSD10 is only defined when building libstd
// These functions are not available in FreeBSD10 and
// cfg'ing them out prevents them from being used from
// libstd by accident.
#[cfg(not(freebsd10))]
extern {
pub fn fdatasync(fd: ::c_int) -> ::c_int;
pub fn aio_waitcomplete(iocbp: *mut *mut aiocb,
timeout: *mut ::timespec) -> ::ssize_t;
pub fn mq_getfd_np(mqd: ::mqd_t) -> ::c_int;
}

extern {
pub fn __error() -> *mut ::c_int;

pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
Expand Down

0 comments on commit 6db91d8

Please sign in to comment.