Skip to content

Commit 2bf5e32

Browse files
committed
Define eventfd on NetBSD
Like FreeBSD, NetBSD supports eventfd, see https://man.netbsd.org/eventfd.2. OpenBSD does not AFAICT. While at, it make the already define eventfd* argument names match the respective OSs man pages (or header files).
1 parent 7b336ae commit 2bf5e32

File tree

6 files changed

+15
-5
lines changed

6 files changed

+15
-5
lines changed

src/fuchsia/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3918,7 +3918,7 @@ extern "C" {
39183918
len: size_t,
39193919
flags: c_uint,
39203920
) -> ssize_t;
3921-
pub fn eventfd(init: c_uint, flags: c_int) -> c_int;
3921+
pub fn eventfd(initval: c_uint, flags: c_int) -> c_int;
39223922
pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int;
39233923
pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int;
39243924
pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4700,7 +4700,7 @@ extern "C" {
47004700
pub fn memfd_create(name: *const c_char, flags: c_uint) -> c_int;
47014701
pub fn setaudit(auditinfo: *const auditinfo_t) -> c_int;
47024702

4703-
pub fn eventfd(init: c_uint, flags: c_int) -> c_int;
4703+
pub fn eventfd(initval: c_uint, flags: c_int) -> c_int;
47044704
pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int;
47054705
pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int;
47064706

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::{
77
};
88

99
pub type blksize_t = i32;
10+
pub type eventfd_t = u64;
1011
pub type fsblkcnt_t = u64;
1112
pub type fsfilcnt_t = u64;
1213
pub type idtype_t = c_int;
@@ -1742,6 +1743,11 @@ pub const RTA_TAG: c_int = 0x100;
17421743
pub const RTAX_TAG: c_int = 8;
17431744
pub const RTAX_MAX: c_int = 9;
17441745

1746+
// For eventfd
1747+
pub const EFD_SEMAPHORE: c_int = crate::O_RDWR;
1748+
pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK;
1749+
pub const EFD_CLOEXEC: c_int = crate::O_CLOEXEC;
1750+
17451751
// sys/timerfd.h
17461752
pub const TFD_CLOEXEC: i32 = crate::O_CLOEXEC;
17471753
pub const TFD_NONBLOCK: i32 = crate::O_NONBLOCK;
@@ -2197,6 +2203,10 @@ extern "C" {
21972203
pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int;
21982204
pub fn getvfsstat(buf: *mut crate::statvfs, bufsize: size_t, flags: c_int) -> c_int;
21992205

2206+
pub fn eventfd(val: c_uint, flags: c_int) -> c_int;
2207+
pub fn eventfd_read(efd: c_int, valp: *mut eventfd_t) -> c_int;
2208+
pub fn eventfd_write(efd: c_int, val: eventfd_t) -> c_int;
2209+
22002210
// Added in `NetBSD` 10.0
22012211
pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int;
22022212
pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int;

src/unix/linux_like/android/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3526,7 +3526,7 @@ extern "C" {
35263526
len: size_t,
35273527
flags: c_uint,
35283528
) -> ssize_t;
3529-
pub fn eventfd(init: c_uint, flags: c_int) -> c_int;
3529+
pub fn eventfd(initval: c_uint, flags: c_int) -> c_int;
35303530
pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int;
35313531
pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int;
35323532
pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int;

src/unix/linux_like/linux/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6088,7 +6088,7 @@ extern "C" {
60886088
len: size_t,
60896089
flags: c_uint,
60906090
) -> ssize_t;
6091-
pub fn eventfd(init: c_uint, flags: c_int) -> c_int;
6091+
pub fn eventfd(initval: c_uint, flags: c_int) -> c_int;
60926092
pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int;
60936093
pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int;
60946094

src/unix/solarish/illumos.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub const TFD_TIMER_ABSTIME: i32 = 1 << 0;
212212
pub const TFD_TIMER_CANCEL_ON_SET: i32 = 1 << 1;
213213

214214
extern "C" {
215-
pub fn eventfd(init: c_uint, flags: c_int) -> c_int;
215+
pub fn eventfd(initval: c_uint, flags: c_int) -> c_int;
216216

217217
pub fn epoll_pwait(
218218
epfd: c_int,

0 commit comments

Comments
 (0)