Skip to content
This repository has been archived by the owner on Nov 28, 2020. It is now read-only.

WIP: Fix compilation for windows #128

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions libzmq-sys/src/errno.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// taken from github.com/erickt/rust-zmq/blob/master/zmq-sys/src/errno.rs

#[cfg(windows)]
use super::windows::errno;
#[cfg(unix)]
use libc as errno;
#[cfg(windows)]
use windows::errno;

const ZMQ_HAUSNUMERO: i32 = 156_384_712;

Expand Down
2 changes: 2 additions & 0 deletions libzmq-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

mod bindings;
pub mod errno;
#[cfg(windows)]
pub(crate) mod windows;

pub use bindings::*;

Expand Down
32 changes: 32 additions & 0 deletions libzmq-sys/src/windows.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Taken from https://github.com/erickt/rust-zmq/blob/master/zmq-sys/src/windows.rs
pub mod errno {
use libc::c_int;

// Use constants as defined in the windows header errno.h
// libzmq should be compiled with VS2010 SDK headers or newer
pub const EACCES: c_int = 13;
pub const EADDRINUSE: c_int = 100;
pub const EADDRNOTAVAIL: c_int = 101;
pub const EAGAIN: c_int = 11;
pub const EBADF: c_int = 9;
pub const EBUSY: c_int = 16;
pub const ECONNREFUSED: c_int = 107;
pub const EFAULT: c_int = 14;
pub const EINTR: c_int = 4;
pub const EHOSTUNREACH: c_int = 110;
pub const EINPROGRESS: c_int = 112;
pub const EINVAL: c_int = 22;
pub const EMFILE: c_int = 24;
pub const EMSGSIZE: c_int = 115;
pub const ENAMETOOLONG: c_int = 38;
pub const ENETDOWN: c_int = 116;
pub const ENOBUFS: c_int = 119;
pub const ENODEV: c_int = 19;
pub const ENOENT: c_int = 2;
pub const ENOMEM: c_int = 12;
pub const ENOTCONN: c_int = 126;
pub const ENOTSOCK: c_int = 128;
pub const ENOTSUP: c_int = 129;
pub const EPROTO: c_int = 134;
pub const EPROTONOSUPPORT: c_int = 135;
}
10 changes: 6 additions & 4 deletions libzmq/src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ use sys::errno;

use bitflags::bitflags;

use std::os::{
raw::{c_short, c_void},
unix::io::{AsRawFd, RawFd},
};
use std::os::raw::{c_short, c_void};

#[cfg(unix)]
use std::os::unix::io::{AsRawFd, RawFd};
#[cfg(windows)]
use std::os::windows::io::{AsRawSocket as AsRawFd, RawSocket as RawFd};

bitflags! {
/// A bitflag used to specifies the condition for triggering an [`Event`] in the
Expand Down