blob: baaaa89ddd52ead1378fc7e0400a9b4c4796997d [file] [log] [blame]
Andrew Walbran12f61402020-10-14 11:10:53 +01001use libc;
2use std::os::unix::io::RawFd;
3use crate::Result;
4use crate::errno::Errno;
5
6libc_bitflags! {
7 pub struct EfdFlags: libc::c_int {
8 EFD_CLOEXEC; // Since Linux 2.6.27
9 EFD_NONBLOCK; // Since Linux 2.6.27
10 EFD_SEMAPHORE; // Since Linux 2.6.30
11 }
12}
13
14pub fn eventfd(initval: libc::c_uint, flags: EfdFlags) -> Result<RawFd> {
15 let res = unsafe { libc::eventfd(initval, flags.bits()) };
16
17 Errno::result(res).map(|r| r as RawFd)
18}