Skip to content

Commit a6c6688

Browse files
committed
Add poll API
Signed-off-by: David Henningsson <[email protected]>
1 parent fb83189 commit a6c6688

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ fn main() {
8888
cfg.header("sys/uio.h");
8989
cfg.header("sched.h");
9090
cfg.header("termios.h");
91+
cfg.header("poll.h");
9192
}
9293

9394
if android {

src/unix/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub type in_addr_t = u32;
1010
pub type in_port_t = u16;
1111
pub type sighandler_t = ::size_t;
1212
pub type cc_t = ::c_uchar;
13+
pub type nfds_t = ::c_ulong;
1314

1415
pub enum DIR {}
1516

@@ -91,6 +92,12 @@ s! {
9192
pub iov_base: *mut ::c_void,
9293
pub iov_len: ::size_t,
9394
}
95+
96+
pub struct pollfd {
97+
pub fd: ::c_int,
98+
pub events: ::c_short,
99+
pub revents: ::c_short,
100+
}
94101
}
95102

96103
pub const WNOHANG: ::c_int = 1;
@@ -117,6 +124,13 @@ pub const S_ISUID: ::c_int = 0x800;
117124
pub const S_ISGID: ::c_int = 0x400;
118125
pub const S_ISVTX: ::c_int = 0x200;
119126

127+
pub const POLLIN: ::c_short = 0x1;
128+
pub const POLLPRI: ::c_short = 0x2;
129+
pub const POLLOUT: ::c_short = 0x4;
130+
pub const POLLERR: ::c_short = 0x8;
131+
pub const POLLHUP: ::c_short = 0x10;
132+
pub const POLLNVAL: ::c_short = 0x20;
133+
120134
cfg_if! {
121135
if #[cfg(feature = "default")] {
122136
// cargo build, don't pull in anything extra as the libstd dep
@@ -548,6 +562,7 @@ extern {
548562
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
549563
link_name = "recvmsg$UNIX2003")]
550564
pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t;
565+
pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
551566
}
552567

553568
// TODO: get rid of this #[cfg(not(...))]

0 commit comments

Comments
 (0)