Skip to content

Commit f0917cc

Browse files
committed
Define eventfd on NetBSD
Like FreeBSD, NetBSD supports eventfd, see https://man.netbsd.org/eventfd.2. OpenBSD does not AFAICT. Also, format imports with rustfmt 1.8.0-stable (ed61e7d7e2 2025-11-07).
1 parent 7b336ae commit f0917cc

File tree

1 file changed

+11
-6
lines changed
  • src/unix/bsd/netbsdlike/netbsd

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
use crate::prelude::*;
2-
use crate::{
3-
cmsghdr,
4-
cpuid_t,
5-
lwpid_t,
6-
off_t,
7-
};
2+
use crate::{cmsghdr, cpuid_t, lwpid_t, off_t};
83

94
pub type blksize_t = i32;
5+
pub type eventfd_t = u64;
106
pub type fsblkcnt_t = u64;
117
pub type fsfilcnt_t = u64;
128
pub type idtype_t = c_int;
@@ -1742,6 +1738,11 @@ pub const RTA_TAG: c_int = 0x100;
17421738
pub const RTAX_TAG: c_int = 8;
17431739
pub const RTAX_MAX: c_int = 9;
17441740

1741+
// For eventfd
1742+
pub const EFD_SEMAPHORE: c_int = crate::O_RDWR;
1743+
pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK;
1744+
pub const EFD_CLOEXEC: c_int = crate::O_CLOEXEC;
1745+
17451746
// sys/timerfd.h
17461747
pub const TFD_CLOEXEC: i32 = crate::O_CLOEXEC;
17471748
pub const TFD_NONBLOCK: i32 = crate::O_NONBLOCK;
@@ -2197,6 +2198,10 @@ extern "C" {
21972198
pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int;
21982199
pub fn getvfsstat(buf: *mut crate::statvfs, bufsize: size_t, flags: c_int) -> c_int;
21992200

2201+
pub fn eventfd(init: c_uint, flags: c_int) -> c_int;
2202+
pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int;
2203+
pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int;
2204+
22002205
// Added in `NetBSD` 10.0
22012206
pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int;
22022207
pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int;

0 commit comments

Comments
 (0)