summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg V <greg@unrelenting.technology>2021-10-20 14:43:20 +0300
committerGreg V <greg@unrelenting.technology>2021-11-07 03:16:22 +0300
commit57492ef9939f8d99f577f64bf85f10834eea0607 (patch)
treea39b7f43ebd5073ddda2364270a7f53a6d6d69f7
parent16c69c07341ccfc674fdb6e092fa76747198414a (diff)
downloadrust-libc-57492ef9939f8d99f577f64bf85f10834eea0607.tar.gz
FreeBSD: add eventfd (since 13)
-rw-r--r--libc-test/build.rs17
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs2
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/mod.rs5
3 files changed, 20 insertions, 4 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 2bf2387610..3cb21492a9 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -1764,8 +1764,13 @@ fn test_freebsd(target: &str) {
_ => cfg.define("_WANT_FREEBSD11_STAT", None),
};
- let freebsdlast = match freebsd_ver {
- Some(12) | Some(13) => true,
+ let freebsd12 = match freebsd_ver {
+ Some(n) if n >= 12 => true,
+ _ => false,
+ };
+
+ let freebsd13 = match freebsd_ver {
+ Some(n) if n >= 13 => true,
_ => false,
};
@@ -1818,10 +1823,11 @@ fn test_freebsd(target: &str) {
"stdlib.h",
"string.h",
"sys/capsicum.h",
- [freebsdlast]:"sys/auxv.h",
+ [freebsd12]:"sys/auxv.h",
"sys/cpuset.h",
- [freebsdlast]:"sys/domainset.h",
+ [freebsd12]:"sys/domainset.h",
"sys/event.h",
+ [freebsd13]:"sys/eventfd.h",
"sys/extattr.h",
"sys/file.h",
"sys/ioctl.h",
@@ -1914,6 +1920,9 @@ fn test_freebsd(target: &str) {
true
}
+ // These constants were introduced in FreeBSD 13:
+ "EFD_CLOEXEC" | "EFD_NONBLOCK" | "EFD_SEMAPHORE" if Some(13) > freebsd_ver => true,
+
// These constants were introduced in FreeBSD 12:
"SF_USER_READAHEAD"
| "EVFILT_EMPTY"
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
index 722ca697f3..e8c4a4af2c 100644
--- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
@@ -265,6 +265,8 @@ extern "C" {
rmtp: *mut ::timespec,
) -> ::c_int;
+ pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
+
pub fn fdatasync(fd: ::c_int) -> ::c_int;
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 0f23d2c383..ca9ad8a190 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -1717,6 +1717,11 @@ pub const RFLINUXTHPN: ::c_int = 65536;
pub const RFTSIGZMB: ::c_int = 524288;
pub const RFSPAWN: ::c_int = 2147483648;
+// For eventfd
+pub const EFD_SEMAPHORE: ::c_int = 0x1;
+pub const EFD_NONBLOCK: ::c_int = 0x4;
+pub const EFD_CLOEXEC: ::c_int = 0x100000;
+
pub const MALLOCX_ZERO: ::c_int = 0x40;
/// size of returned wchan message