Skip to content

Commit 2000494

Browse files
committed
Cfg out constants that are not available in FreeBSD10
1 parent 8512e07 commit 2000494

File tree

2 files changed

+45
-29
lines changed

2 files changed

+45
-29
lines changed

libc-test/build.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,9 +1647,17 @@ fn test_freebsd(target: &str) {
16471647
});
16481648

16491649
cfg.skip_field(move |struct_, field| {
1650-
// FIXME: `sa_sigaction` has type `sighandler_t` but that type is
1651-
// incorrect, see: https://github.com/rust-lang/libc/issues/1359
1652-
(struct_ == "sigaction" && field == "sa_sigaction")
1650+
match (struct_, field) {
1651+
// FIXME: `sa_sigaction` has type `sighandler_t` but that type is
1652+
// incorrect, see: https://github.com/rust-lang/libc/issues/1359
1653+
("sigaction", "sa_sigaction") => true,
1654+
1655+
// FIXME: in FreeBSD10 this field has type `char*` instead of
1656+
// `void*`:
1657+
("stack_t", "ss_sp") if Some(10) == freebsd_ver => true,
1658+
1659+
_ => false,
1660+
}
16531661
});
16541662

16551663
cfg.skip_roundtrip(move |s| match s {

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

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,32 @@ cfg_if! {
310310
}
311311
}
312312

313+
cfg_if! {
314+
if #[cfg(not(freebsd10))] {
315+
// These constants are not available in FreeBSD10
316+
// This prevents them from being used from libstd:
317+
pub const SF_USER_READAHEAD: ::c_int = 0x00000008;
318+
pub const SF_NOCACHE: ::c_int = 0x00000010;
319+
pub const RLIMIT_KQUEUES: ::c_int = 13;
320+
pub const RLIMIT_UMTXP: ::c_int = 14;
321+
pub const EVFILT_PROCDESC: i16 = -8;
322+
pub const EVFILT_SENDFILE: i16 = -12;
323+
pub const EVFILT_EMPTY: i16 = -13;
324+
pub const SO_REUSEPORT_LB: ::c_int = 0x10000;
325+
pub const TCP_CCALGOOPT: ::c_int = 65;
326+
pub const TCP_PCAP_OUT: ::c_int = 2048;
327+
pub const TCP_PCAP_IN: ::c_int = 4096;
328+
pub const IP_BINDMULTI: ::c_int = 25;
329+
pub const IP_ORIGDSTADDR : ::c_int = 27;
330+
pub const IP_RECVORIGDSTADDR : ::c_int = IP_ORIGDSTADDR;
331+
pub const IPV6_ORIGDSTADDR: ::c_int = 72;
332+
pub const IPV6_RECVORIGDSTADDR: ::c_int = IPV6_ORIGDSTADDR;
333+
pub const PD_CLOEXEC: ::c_int = 0x00000002;
334+
pub const PD_ALLOWED_AT_FORK: ::c_int = PD_DAEMON | PD_CLOEXEC;
335+
pub const IP_RSS_LISTEN_BUCKET: ::c_int = 26;
336+
}
337+
}
338+
313339
pub const SIGEV_THREAD_ID: ::c_int = 4;
314340

315341
pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0;
@@ -323,8 +349,6 @@ pub const SIGSTKSZ: ::size_t = 34816;
323349
pub const SF_NODISKIO: ::c_int = 0x00000001;
324350
pub const SF_MNOWAIT: ::c_int = 0x00000002;
325351
pub const SF_SYNC: ::c_int = 0x00000004;
326-
pub const SF_USER_READAHEAD: ::c_int = 0x00000008;
327-
pub const SF_NOCACHE: ::c_int = 0x00000010;
328352
pub const O_CLOEXEC: ::c_int = 0x00100000;
329353
pub const O_DIRECTORY: ::c_int = 0x00020000;
330354
pub const O_EXEC: ::c_int = 0x00040000;
@@ -338,8 +362,6 @@ pub const ENOTRECOVERABLE: ::c_int = 95;
338362
pub const EOWNERDEAD: ::c_int = 96;
339363
pub const RLIMIT_NPTS: ::c_int = 11;
340364
pub const RLIMIT_SWAP: ::c_int = 12;
341-
pub const RLIMIT_KQUEUES: ::c_int = 13;
342-
pub const RLIMIT_UMTXP: ::c_int = 14;
343365
pub const RLIM_NLIMITS: ::rlim_t = 15;
344366

345367
pub const Q_GETQUOTA: ::c_int = 0x700;
@@ -361,12 +383,9 @@ pub const EVFILT_VNODE: i16 = -4;
361383
pub const EVFILT_PROC: i16 = -5;
362384
pub const EVFILT_SIGNAL: i16 = -6;
363385
pub const EVFILT_TIMER: i16 = -7;
364-
pub const EVFILT_PROCDESC: i16 = -8;
365386
pub const EVFILT_FS: i16 = -9;
366387
pub const EVFILT_LIO: i16 = -10;
367388
pub const EVFILT_USER: i16 = -11;
368-
pub const EVFILT_SENDFILE: i16 = -12;
369-
pub const EVFILT_EMPTY: i16 = -13;
370389

371390
pub const EV_ADD: u16 = 0x1;
372391
pub const EV_DELETE: u16 = 0x2;
@@ -593,7 +612,6 @@ pub const JAIL_SYS_INHERIT: ::c_int = 2;
593612
pub const SO_BINTIME: ::c_int = 0x2000;
594613
pub const SO_NO_OFFLOAD: ::c_int = 0x4000;
595614
pub const SO_NO_DDP: ::c_int = 0x8000;
596-
pub const SO_REUSEPORT_LB: ::c_int = 0x10000;
597615
pub const SO_LABEL: ::c_int = 0x1009;
598616
pub const SO_PEERLABEL: ::c_int = 0x1010;
599617
pub const SO_LISTENQLIMIT: ::c_int = 0x1011;
@@ -932,23 +950,12 @@ pub const IPPROTO_SEND: ::c_int = 259;
932950
pub const TCP_MD5SIG: ::c_int = 16;
933951
pub const TCP_INFO: ::c_int = 32;
934952
pub const TCP_CONGESTION: ::c_int = 64;
935-
pub const TCP_CCALGOOPT: ::c_int = 65;
936953
pub const TCP_KEEPINIT: ::c_int = 128;
937954
pub const TCP_FASTOPEN: ::c_int = 1025;
938-
pub const TCP_PCAP_OUT: ::c_int = 2048;
939-
pub const TCP_PCAP_IN: ::c_int = 4096;
940955

941956
pub const IP_BINDANY: ::c_int = 24;
942-
pub const IP_BINDMULTI: ::c_int = 25;
943-
pub const IP_RSS_LISTEN_BUCKET: ::c_int = 26;
944-
pub const IP_ORIGDSTADDR : ::c_int = 27;
945-
pub const IP_RECVORIGDSTADDR : ::c_int = IP_ORIGDSTADDR;
946-
947957
pub const IP_RECVTOS: ::c_int = 68;
948958

949-
pub const IPV6_ORIGDSTADDR: ::c_int = 72;
950-
pub const IPV6_RECVORIGDSTADDR: ::c_int = IPV6_ORIGDSTADDR;
951-
952959
pub const PF_SLOW: ::c_int = AF_SLOW;
953960
pub const PF_SCLUSTER: ::c_int = AF_SCLUSTER;
954961
pub const PF_ARP: ::c_int = AF_ARP;
@@ -1071,8 +1078,6 @@ pub const XUCRED_VERSION: ::c_uint = 0;
10711078

10721079
// Flags which can be passed to pdfork(2)
10731080
pub const PD_DAEMON: ::c_int = 0x00000001;
1074-
pub const PD_CLOEXEC: ::c_int = 0x00000002;
1075-
pub const PD_ALLOWED_AT_FORK: ::c_int = PD_DAEMON | PD_CLOEXEC;
10761081

10771082
// Values for struct rtprio (type_ field)
10781083
pub const RTP_PRIO_REALTIME: ::c_ushort = 2;
@@ -1138,6 +1143,14 @@ f! {
11381143
}
11391144
}
11401145

1146+
#[cfg(not(freebsd10))]
1147+
extern {
1148+
pub fn fdatasync(fd: ::c_int) -> ::c_int;
1149+
pub fn aio_waitcomplete(iocbp: *mut *mut aiocb,
1150+
timeout: *mut ::timespec) -> ::ssize_t;
1151+
pub fn mq_getfd_np(mqd: ::mqd_t) -> ::c_int;
1152+
}
1153+
11411154
extern {
11421155
pub fn __error() -> *mut ::c_int;
11431156

@@ -1205,7 +1218,6 @@ extern {
12051218
pub fn jail_set(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int)
12061219
-> ::c_int;
12071220

1208-
pub fn fdatasync(fd: ::c_int) -> ::c_int;
12091221
pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
12101222
len: ::off_t) -> ::c_int;
12111223
pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
@@ -1218,10 +1230,6 @@ extern {
12181230
pub fn getutxuser(user: *const ::c_char) -> *mut utmpx;
12191231
pub fn setutxdb(_type: ::c_int, file: *const ::c_char) -> ::c_int;
12201232

1221-
pub fn aio_waitcomplete(iocbp: *mut *mut aiocb,
1222-
timeout: *mut ::timespec) -> ::ssize_t;
1223-
pub fn mq_getfd_np(mqd: ::mqd_t) -> ::c_int;
1224-
12251233
pub fn waitid(idtype: idtype_t, id: ::id_t, infop: *mut ::siginfo_t,
12261234
options: ::c_int) -> ::c_int;
12271235

0 commit comments

Comments
 (0)