diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/macros.rs | 13 | ||||
-rw-r--r-- | src/sys/socket/addr.rs | 1 | ||||
-rw-r--r-- | src/sys/socket/mod.rs | 1 | ||||
-rw-r--r-- | src/unistd.rs | 8 |
4 files changed, 6 insertions, 17 deletions
diff --git a/src/macros.rs b/src/macros.rs index feb02ea7..7d6ac8df 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -203,16 +203,3 @@ macro_rules! libc_enum { } }; } - -/// A Rust version of the familiar C `offset_of` macro. It returns the byte -/// offset of `field` within struct `ty` -#[cfg(not(target_os = "redox"))] -macro_rules! offset_of { - ($ty:ty, $field:ident) => {{ - // Safe because we don't actually read from the dereferenced pointer - #[allow(unused_unsafe)] // for when the macro is used in an unsafe block - unsafe { - &(*(ptr::null() as *const $ty)).$field as *const _ as usize - } - }} -} diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index 1f7f4ec6..71b2c973 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -1,6 +1,7 @@ use super::sa_family_t; use crate::{Error, Result, NixPath}; use crate::errno::Errno; +use memoffset::offset_of; use std::{fmt, mem, net, ptr, slice}; use std::ffi::OsStr; use std::hash::{Hash, Hasher}; diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 76bfa761..726ff8e1 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -5,6 +5,7 @@ use cfg_if::cfg_if; use crate::{Error, Result, errno::Errno}; use libc::{self, c_void, c_int, iovec, socklen_t, size_t, CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_LEN}; +use memoffset::offset_of; use std::{mem, ptr, slice}; use std::os::unix::io::RawFd; use crate::sys::time::TimeVal; diff --git a/src/unistd.rs b/src/unistd.rs index f93c2192..d3afeac6 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -2641,10 +2641,10 @@ impl User { libc::size_t, *mut *mut libc::passwd) -> libc::c_int { - let buflimit = 16384; + let buflimit = 1048576; let bufsize = match sysconf(SysconfVar::GETPW_R_SIZE_MAX) { Ok(Some(n)) => n as usize, - Ok(None) | Err(_) => buflimit as usize, + Ok(None) | Err(_) => 16384, }; let mut cbuf = Vec::with_capacity(bufsize); @@ -2762,10 +2762,10 @@ impl Group { libc::size_t, *mut *mut libc::group) -> libc::c_int { - let buflimit = 16384; + let buflimit = 1048576; let bufsize = match sysconf(SysconfVar::GETGR_R_SIZE_MAX) { Ok(Some(n)) => n as usize, - Ok(None) | Err(_) => buflimit as usize, + Ok(None) | Err(_) => 16384, }; let mut cbuf = Vec::with_capacity(bufsize); |