Skip to content

Commit 38c16a9

Browse files
committed
Auto merge of #2468 - unrelentingtech:fbsd-efd, r=JohnTitor
FreeBSD: add eventfd (since 13) This already exposes constants in the non-versioned code like #2465 so this should wait on #2465
2 parents 25ea72c + 57492ef commit 38c16a9

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

libc-test/build.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -1764,8 +1764,13 @@ fn test_freebsd(target: &str) {
17641764
_ => cfg.define("_WANT_FREEBSD11_STAT", None),
17651765
};
17661766

1767-
let freebsdlast = match freebsd_ver {
1768-
Some(12) | Some(13) => true,
1767+
let freebsd12 = match freebsd_ver {
1768+
Some(n) if n >= 12 => true,
1769+
_ => false,
1770+
};
1771+
1772+
let freebsd13 = match freebsd_ver {
1773+
Some(n) if n >= 13 => true,
17691774
_ => false,
17701775
};
17711776

@@ -1818,10 +1823,11 @@ fn test_freebsd(target: &str) {
18181823
"stdlib.h",
18191824
"string.h",
18201825
"sys/capsicum.h",
1821-
[freebsdlast]:"sys/auxv.h",
1826+
[freebsd12]:"sys/auxv.h",
18221827
"sys/cpuset.h",
1823-
[freebsdlast]:"sys/domainset.h",
1828+
[freebsd12]:"sys/domainset.h",
18241829
"sys/event.h",
1830+
[freebsd13]:"sys/eventfd.h",
18251831
"sys/extattr.h",
18261832
"sys/file.h",
18271833
"sys/ioctl.h",
@@ -1914,6 +1920,9 @@ fn test_freebsd(target: &str) {
19141920
true
19151921
}
19161922

1923+
// These constants were introduced in FreeBSD 13:
1924+
"EFD_CLOEXEC" | "EFD_NONBLOCK" | "EFD_SEMAPHORE" if Some(13) > freebsd_ver => true,
1925+
19171926
// These constants were introduced in FreeBSD 12:
19181927
"SF_USER_READAHEAD"
19191928
| "EVFILT_EMPTY"

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

+2
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ extern "C" {
265265
rmtp: *mut ::timespec,
266266
) -> ::c_int;
267267

268+
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
269+
268270
pub fn fdatasync(fd: ::c_int) -> ::c_int;
269271

270272
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;

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

+5
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,11 @@ pub const RFLINUXTHPN: ::c_int = 65536;
17171717
pub const RFTSIGZMB: ::c_int = 524288;
17181718
pub const RFSPAWN: ::c_int = 2147483648;
17191719

1720+
// For eventfd
1721+
pub const EFD_SEMAPHORE: ::c_int = 0x1;
1722+
pub const EFD_NONBLOCK: ::c_int = 0x4;
1723+
pub const EFD_CLOEXEC: ::c_int = 0x100000;
1724+
17201725
pub const MALLOCX_ZERO: ::c_int = 0x40;
17211726

17221727
/// size of returned wchan message

0 commit comments

Comments
 (0)