Skip to content

Correct solaris libc definitions: #516

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 2 commits into from
Feb 10, 2017
Merged
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
24 changes: 19 additions & 5 deletions src/unix/solaris/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use dox::mem;

pub type c_char = i8;
pub type c_long = i64;
pub type c_ulong = u64;
Expand Down Expand Up @@ -27,7 +29,7 @@ pub type off_t = i64;
pub type useconds_t = ::c_uint;
pub type socklen_t = u32;
pub type sa_family_t = u8;
pub type pthread_t = ::uintptr_t;
pub type pthread_t = ::c_uint;
pub type pthread_key_t = ::c_uint;
pub type blksize_t = u32;
pub type fflags_t = u32;
Expand Down Expand Up @@ -123,6 +125,9 @@ s! {
}

pub struct fd_set {
#[cfg(target_pointer_width = "64")]
fds_bits: [i64; FD_SETSIZE / 64],
#[cfg(target_pointer_width = "32")]
fds_bits: [i32; FD_SETSIZE / 32],
}

Expand Down Expand Up @@ -448,7 +453,13 @@ pub const SIG_SETMASK: ::c_int = 3;
pub const IPV6_MULTICAST_LOOP: ::c_int = 0x8;
pub const IPV6_V6ONLY: ::c_int = 0x27;

pub const FD_SETSIZE: usize = 1024;
cfg_if! {
if #[cfg(target_pointer_width = "64")] {
pub const FD_SETSIZE: usize = 65536;
} else {
pub const FD_SETSIZE: usize = 1024;
}
}

pub const ST_RDONLY: ::c_ulong = 1;
pub const ST_NOSUID: ::c_ulong = 2;
Expand Down Expand Up @@ -946,19 +957,22 @@ pub const RTLD_CONFGEN: ::c_int = 0x10000;

f! {
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
let fd = fd as usize;
(*set).fds_bits[fd / 32] &= !(1 << (fd % 32));
(*set).fds_bits[fd / bits] &= !(1 << (fd % bits));
return
}

pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
let fd = fd as usize;
return ((*set).fds_bits[fd / 32] & (1 << (fd % 32))) != 0
return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
}

pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
let fd = fd as usize;
(*set).fds_bits[fd / 32] |= 1 << (fd % 32);
(*set).fds_bits[fd / bits] |= 1 << (fd % bits);
return
}

Expand Down