Skip to content

Add poll API #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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(...))]
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down