diff options
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/event.rs | 14 | ||||
-rw-r--r-- | src/sys/socket/consts.rs | 69 | ||||
-rw-r--r-- | src/sys/socket/sockopt.rs | 6 | ||||
-rw-r--r-- | src/sys/syscall.rs | 10 | ||||
-rw-r--r-- | src/sys/termios.rs | 24 |
5 files changed, 71 insertions, 52 deletions
diff --git a/src/sys/event.rs b/src/sys/event.rs index 3e2a6d43..494c12dd 100644 --- a/src/sys/event.rs +++ b/src/sys/event.rs @@ -22,8 +22,14 @@ pub struct KEvent { target_os = "dragonfly", target_os = "macos", target_os = "ios"))] type type_of_udata = *mut ::c_void; +#[cfg(any(target_os = "openbsd", target_os = "freebsd", + target_os = "dragonfly", target_os = "macos", + target_os = "ios"))] +type type_of_data = libc::intptr_t; #[cfg(any(target_os = "netbsd"))] type type_of_udata = intptr_t; +#[cfg(any(target_os = "netbsd"))] +type type_of_data = libc::int64_t; #[cfg(not(target_os = "netbsd"))] type type_of_event_filter = i16; @@ -58,9 +64,9 @@ pub enum EventFilter { } #[cfg(target_os = "netbsd")] -type type_of_event_filter = i32; +type type_of_event_filter = libc::uint32_t; #[cfg(target_os = "netbsd")] -#[repr(u32)] +#[repr(i32)] #[derive(Clone, Copy, Debug, PartialEq)] pub enum EventFilter { EVFILT_READ = libc::EVFILT_READ, @@ -216,7 +222,7 @@ impl KEvent { filter: filter as type_of_event_filter, flags: flags.bits(), fflags: fflags.bits(), - data: data, + data: data as type_of_data, udata: udata as type_of_udata } } } @@ -238,7 +244,7 @@ impl KEvent { } pub fn data(&self) -> intptr_t { - self.kevent.data + self.kevent.data as intptr_t } pub fn udata(&self) -> intptr_t { diff --git a/src/sys/socket/consts.rs b/src/sys/socket/consts.rs index 9a1861fa..54213ef1 100644 --- a/src/sys/socket/consts.rs +++ b/src/sys/socket/consts.rs @@ -11,14 +11,14 @@ mod os { pub const AF_NETLINK: c_int = 16; pub const AF_PACKET: c_int = 17; - pub const SOCK_STREAM: c_int = 1; - pub const SOCK_DGRAM: c_int = 2; - pub const SOCK_SEQPACKET: c_int = 5; - pub const SOCK_RAW: c_int = 3; + pub const SOCK_STREAM: c_int = libc::SOCK_STREAM; + pub const SOCK_DGRAM: c_int = libc::SOCK_DGRAM; + pub const SOCK_SEQPACKET: c_int = libc::SOCK_SEQPACKET; + pub const SOCK_RAW: c_int = libc::SOCK_RAW; pub const SOCK_RDM: c_int = 4; pub const SOL_IP: c_int = 0; - pub const SOL_SOCKET: c_int = 1; + pub const SOL_SOCKET: c_int = libc::SOL_SOCKET; pub const SOL_TCP: c_int = 6; pub const SOL_UDP: c_int = 17; pub const SOL_IPV6: c_int = 41; @@ -28,36 +28,39 @@ mod os { pub const IPPROTO_TCP: c_int = SOL_TCP; pub const IPPROTO_UDP: c_int = SOL_UDP; - pub const SO_ACCEPTCONN: c_int = 30; + pub const SO_ACCEPTCONN: c_int = libc::SO_ACCEPTCONN; pub const SO_BINDTODEVICE: c_int = 25; - pub const SO_BROADCAST: c_int = 6; + pub const SO_BROADCAST: c_int = libc::SO_BROADCAST; pub const SO_BSDCOMPAT: c_int = 14; pub const SO_DEBUG: c_int = 1; pub const SO_DOMAIN: c_int = 39; - pub const SO_ERROR: c_int = 4; - pub const SO_DONTROUTE: c_int = 5; - pub const SO_KEEPALIVE: c_int = 9; - pub const SO_LINGER: c_int = 13; + pub const SO_ERROR: c_int = libc::SO_ERROR; + pub const SO_DONTROUTE: c_int = libc::SO_DONTROUTE; + pub const SO_KEEPALIVE: c_int = libc::SO_KEEPALIVE; + pub const SO_LINGER: c_int = libc::SO_LINGER; pub const SO_MARK: c_int = 36; - pub const SO_OOBINLINE: c_int = 10; - pub const SO_PASSCRED: c_int = 16; + pub const SO_OOBINLINE: c_int = libc::SO_OOBINLINE; + #[cfg(not(target_arch="arm"))] + pub const SO_PASSCRED: c_int = libc::SO_PASSCRED; pub const SO_PEEK_OFF: c_int = 42; - pub const SO_PEERCRED: c_int = 17; + #[cfg(not(target_arch="arm"))] + pub const SO_PEERCRED: c_int = libc::SO_PEERCRED; pub const SO_PRIORITY: c_int = 12; pub const SO_PROTOCOL: c_int = 38; - pub const SO_RCVBUF: c_int = 8; + pub const SO_RCVBUF: c_int = libc::SO_RCVBUF; pub const SO_RCVBUFFORCE: c_int = 33; - pub const SO_RCVLOWAT: c_int = 18; - pub const SO_SNDLOWAT: c_int = 19; - pub const SO_RCVTIMEO: c_int = 20; - pub const SO_SNDTIMEO: c_int = 21; - pub const SO_REUSEADDR: c_int = 2; - pub const SO_REUSEPORT: c_int = 15; + pub const SO_RCVLOWAT: c_int = libc::SO_RCVLOWAT; + pub const SO_SNDLOWAT: c_int = libc::SO_SNDLOWAT; + pub const SO_RCVTIMEO: c_int = libc::SO_RCVTIMEO; + pub const SO_SNDTIMEO: c_int = libc::SO_SNDTIMEO; + pub const SO_REUSEADDR: c_int = libc::SO_REUSEADDR; + pub const SO_REUSEPORT: c_int = libc::SO_REUSEPORT; pub const SO_RXQ_OVFL: c_int = 40; - pub const SO_SNDBUF: c_int = 7; - pub const SO_SNDBUFFORCE: c_int = 32; + pub const SO_SNDBUF: c_int = libc::SO_SNDBUF; + #[cfg(not(target_arch="arm"))] + pub const SO_SNDBUFFORCE: c_int = libc::SO_SNDBUFFORCE; pub const SO_TIMESTAMP: c_int = 29; - pub const SO_TYPE: c_int = 3; + pub const SO_TYPE: c_int = libc::SO_TYPE; pub const SO_BUSY_POLL: c_int = 46; #[cfg(target_os = "linux")] pub const SO_ORIGINAL_DST: c_int = 80; @@ -152,7 +155,7 @@ mod os { #[cfg(any(target_os = "macos", target_os = "ios"))] pub const SYSPROTO_CONTROL: c_int = 2; - pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_ACCEPTCONN: c_int = libc::SO_ACCEPTCONN; pub const SO_BROADCAST: c_int = 0x0020; pub const SO_DEBUG: c_int = 0x0001; #[cfg(not(target_os = "netbsd"))] @@ -417,7 +420,7 @@ mod test { #[cfg(target_os = "linux")] #[test] - pub fn test_linux_consts() { + pub fn test_general_linux_consts() { // TODO Figure out how to test new constants check_const!( SOL_IP, @@ -431,13 +434,21 @@ mod test { TCP_CORK, // SO_BUSY_POLL, // SO_RXQ_OVFL, - SO_PASSCRED, SO_PRIORITY, // SO_PROTOCOL, SO_RCVBUFFORCE, // SO_PEEK_OFF, - SO_PEERCRED, - SO_SNDBUFFORCE, MSG_ERRQUEUE); } + + #[cfg(all(target_os = "linux", not(target_arch="arm")))] + #[test] + pub fn test_linux_not_arm_consts() { + // TODO Figure out how to test new constants + check_const!( + SO_PASSCRED, + SO_PEERCRED, + SO_SNDBUFFORCE); + } + } diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index bf17347c..61d85ec3 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -152,7 +152,7 @@ sockopt_impl!(Both, Broadcast, consts::SOL_SOCKET, consts::SO_BROADCAST, bool); sockopt_impl!(Both, OobInline, consts::SOL_SOCKET, consts::SO_OOBINLINE, bool); sockopt_impl!(GetOnly, SocketError, consts::SOL_SOCKET, consts::SO_ERROR, i32); sockopt_impl!(Both, KeepAlive, consts::SOL_SOCKET, consts::SO_KEEPALIVE, bool); -#[cfg(target_os = "linux")] +#[cfg(all(target_os = "linux", not(target_arch="arm")))] sockopt_impl!(GetOnly, PeerCredentials, consts::SOL_SOCKET, consts::SO_PEERCRED, super::ucred); #[cfg(any(target_os = "macos", target_os = "ios"))] @@ -167,7 +167,7 @@ sockopt_impl!(Both, RcvBuf, consts::SOL_SOCKET, consts::SO_RCVBUF, usize); sockopt_impl!(Both, SndBuf, consts::SOL_SOCKET, consts::SO_SNDBUF, usize); #[cfg(target_os = "linux")] sockopt_impl!(SetOnly, RcvBufForce, consts::SOL_SOCKET, consts::SO_RCVBUFFORCE, usize); -#[cfg(target_os = "linux")] +#[cfg(all(target_os = "linux", not(target_arch="arm")))] sockopt_impl!(SetOnly, SndBufForce, consts::SOL_SOCKET, consts::SO_SNDBUFFORCE, usize); sockopt_impl!(GetOnly, SockType, consts::SOL_SOCKET, consts::SO_TYPE, super::SockType); #[cfg(any(target_os = "freebsd", @@ -378,7 +378,7 @@ impl<'a> Set<'a, usize> for SetUsize { #[cfg(test)] mod test { - #[cfg(target_os = "linux")] + #[cfg(all(target_os = "linux", not(target_arch = "arm")))] #[test] fn can_get_peercred_on_unix_socket() { use super::super::*; diff --git a/src/sys/syscall.rs b/src/sys/syscall.rs index c2d9e51c..692b4cef 100644 --- a/src/sys/syscall.rs +++ b/src/sys/syscall.rs @@ -54,6 +54,16 @@ mod arch { pub static MEMFD_CREATE: Syscall = 354; } +#[cfg(target_arch = "powerpc")] +mod arch { + use libc::c_long; + + pub type Syscall = c_long; + + pub static SYSPIVOTROOT: Syscall = 203; + pub static MEMFD_CREATE: Syscall = 360; +} + extern { pub fn syscall(num: Syscall, ...) -> c_int; } diff --git a/src/sys/termios.rs b/src/sys/termios.rs index e8df1ed9..126d149c 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs @@ -96,22 +96,14 @@ mod ffi { #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd"))] pub mod consts { - #[cfg(not(any(target_os = "dragonfly", target_os = "netbsd")))] - use libc::{c_int, c_ulong, c_uchar}; - #[cfg(any(target_os = "dragonfly", target_os = "netbsd"))] - use libc::{c_int, c_uint, c_uchar}; - #[cfg(not(any(target_os = "dragonfly", target_os = "netbsd")))] - pub type tcflag_t = c_ulong; - #[cfg(any(target_os = "dragonfly", target_os = "netbsd"))] - pub type tcflag_t = c_uint; + use libc; - pub type cc_t = c_uchar; + use libc::c_int; - #[cfg(not(any(target_os = "dragonfly", target_os = "netbsd")))] - pub type speed_t = c_ulong; - #[cfg(any(target_os = "dragonfly", target_os = "netbsd"))] - pub type speed_t = c_uint; + pub type tcflag_t = libc::tcflag_t; + pub type cc_t = libc::cc_t; + pub type speed_t = libc::speed_t; #[repr(C)] #[derive(Clone, Copy)] @@ -166,7 +158,7 @@ mod ffi { B7200, B14400, B28800, B57600, B76800, B115200, B230400}; - #[cfg(any(target_os = "netbsd", target_os = "freebsd"))] + #[cfg(target_os = "freebsd")] use libc::{B460800, B921600}; match s { @@ -193,9 +185,9 @@ mod ffi { B76800 => BaudRate::B76800, B115200 => BaudRate::B115200, B230400 => BaudRate::B230400, - #[cfg(any(target_os = "netbsd", target_os = "freebsd"))] + #[cfg(target_os = "freebsd")] B460800 => BaudRate::B460800, - #[cfg(any(target_os = "netbsd", target_os = "freebsd"))] + #[cfg(target_os = "freebsd")] B921600 => BaudRate::B921600, b @ _ => unreachable!("Invalid baud constant: {}", b), } |