diff --git a/libc-test/build.rs b/libc-test/build.rs index f94f7051faf295dbef51b8ce1d8fa16359f89360..0e6e550c95336463cf59047a156f4861240c808b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -88,6 +88,7 @@ fn main() { cfg.header("sys/uio.h"); cfg.header("sched.h"); cfg.header("termios.h"); + cfg.header("poll.h"); } if android { diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 144240d42397c4825512b03b1f5d469d249ebe14..69208862ea55e3409e40649036a2caa40dec1741 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -6,6 +6,7 @@ pub type blkcnt_t = i64; pub type socklen_t = u32; pub type sa_family_t = u8; pub type pthread_t = ::uintptr_t; +pub type nfds_t = ::c_uint; s! { pub struct sockaddr { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 4060b4eebfb70f64530b6be604b0f1a10ad82a9d..6a05d82d268d085659e0623fa34e446258b5a213 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -91,6 +91,12 @@ s! { pub iov_base: *mut ::c_void, pub iov_len: ::size_t, } + + pub struct pollfd { + pub fd: ::c_int, + pub events: ::c_short, + pub revents: ::c_short, + } } pub const WNOHANG: ::c_int = 1; @@ -117,6 +123,13 @@ pub const S_ISUID: ::c_int = 0x800; pub const S_ISGID: ::c_int = 0x400; pub const S_ISVTX: ::c_int = 0x200; +pub const POLLIN: ::c_short = 0x1; +pub const POLLPRI: ::c_short = 0x2; +pub const POLLOUT: ::c_short = 0x4; +pub const POLLERR: ::c_short = 0x8; +pub const POLLHUP: ::c_short = 0x10; +pub const POLLNVAL: ::c_short = 0x20; + cfg_if! { if #[cfg(feature = "default")] { // cargo build, don't pull in anything extra as the libstd dep @@ -548,6 +561,9 @@ extern { #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "recvmsg$UNIX2003")] pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "poll$UNIX2003")] + pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int; } // TODO: get rid of this #[cfg(not(...))] diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index f00cebd05c34e83484321b32795d39f252e2ae18..032d3de3a71cfbc1f51f5eba867af9c38144d350 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -22,6 +22,7 @@ pub type sigset_t = c_ulong; pub type time64_t = i64; pub type fsfilcnt_t = ::c_ulong; pub type fsblkcnt_t = ::c_ulong; +pub type nfds_t = ::c_uint; s! { pub struct stat { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 512d5adc3879a6fd0f1b3a89df72219a988a3416..b7de02b991bb68a7d2ed23eb6242bfc8a1e8bbc9 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -14,6 +14,7 @@ pub type fsfilcnt_t = ::c_ulong; pub type key_t = ::c_int; pub type shmatt_t = ::c_ulong; pub type mqd_t = ::c_int; +pub type nfds_t = ::c_ulong; pub enum fpos64_t {} // TODO: fill this out with a struct