diff --git a/libc-test/build.rs b/libc-test/build.rs index 4716febb83f44..4095fca6f83f6 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1278,6 +1278,7 @@ fn test_netbsd(target: &str) { "mqueue.h", "netinet/dccp.h", "sys/event.h", + (!netbsd9, "sys/eventfd.h"), "sys/quota.h", "sys/reboot.h", "sys/shm.h", @@ -1323,6 +1324,7 @@ fn test_netbsd(target: &str) { "sighandler_t" => true, // Incomplete type in C "cpuset_t" => true, + "eventfd_t" if netbsd9 => true, _ => false, } }); @@ -1382,6 +1384,8 @@ fn test_netbsd(target: &str) { // FIXME(netbsd): Look into setting `_POSIX_C_SOURCE` to enable this "qsort_r" => true, + "eventfd" | "eventfd_read" | "eventfd_write" if netbsd9 => true, + _ => false, } }); diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 1b99f98f021a2..49e1430f1cc4a 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3918,7 +3918,7 @@ extern "C" { len: size_t, flags: c_uint, ) -> ssize_t; - pub fn eventfd(init: c_uint, flags: c_int) -> c_int; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index bc25a19e23cfb..6827ab069bf5d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4700,7 +4700,7 @@ extern "C" { pub fn memfd_create(name: *const c_char, flags: c_uint) -> c_int; pub fn setaudit(auditinfo: *const auditinfo_t) -> c_int; - pub fn eventfd(init: c_uint, flags: c_int) -> c_int; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int; pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 2c30a585b7fd6..c8fb9c582a57e 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -7,6 +7,7 @@ use crate::{ }; pub type blksize_t = i32; +pub type eventfd_t = u64; pub type fsblkcnt_t = u64; pub type fsfilcnt_t = u64; pub type idtype_t = c_int; @@ -1742,6 +1743,11 @@ pub const RTA_TAG: c_int = 0x100; pub const RTAX_TAG: c_int = 8; pub const RTAX_MAX: c_int = 9; +// For eventfd +pub const EFD_SEMAPHORE: c_int = crate::O_RDWR; +pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK; +pub const EFD_CLOEXEC: c_int = crate::O_CLOEXEC; + // sys/timerfd.h pub const TFD_CLOEXEC: i32 = crate::O_CLOEXEC; pub const TFD_NONBLOCK: i32 = crate::O_NONBLOCK; @@ -2197,6 +2203,10 @@ extern "C" { pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int; pub fn getvfsstat(buf: *mut crate::statvfs, bufsize: size_t, flags: c_int) -> c_int; + pub fn eventfd(val: c_uint, flags: c_int) -> c_int; + pub fn eventfd_read(efd: c_int, valp: *mut eventfd_t) -> c_int; + pub fn eventfd_write(efd: c_int, val: eventfd_t) -> c_int; + // Added in `NetBSD` 10.0 pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int; pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 5625704682e3d..4fb647235c982 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3521,7 +3521,7 @@ extern "C" { len: size_t, flags: c_uint, ) -> ssize_t; - pub fn eventfd(init: c_uint, flags: c_int) -> c_int; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int; pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index d0ea99e28b034..652c780d103fd 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -6057,7 +6057,7 @@ extern "C" { len: size_t, flags: c_uint, ) -> ssize_t; - pub fn eventfd(init: c_uint, flags: c_int) -> c_int; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int; pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index d83a24075e0b4..c0a17823bb9a7 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -212,7 +212,7 @@ pub const TFD_TIMER_ABSTIME: i32 = 1 << 0; pub const TFD_TIMER_CANCEL_ON_SET: i32 = 1 << 1; extern "C" { - pub fn eventfd(init: c_uint, flags: c_int) -> c_int; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; pub fn epoll_pwait( epfd: c_int,