Skip to content

Commit

Permalink
FreeBSD: add eventfd (since 13)
Browse files Browse the repository at this point in the history
  • Loading branch information
valpackett committed Nov 7, 2021
1 parent 16c69c0 commit 57492ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
17 changes: 13 additions & 4 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 57492ef

Please sign in to comment.