Skip to content

Commit f2aad75

Browse files
committed
Allow cmsg_space! to be used in unit tests
1 parent 2d36e3a commit f2aad75

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/sys/socket/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,11 @@ impl Ipv6MembershipRequest {
401401
macro_rules! cmsg_space {
402402
( $( $x:ty ),* ) => {
403403
{
404-
use nix::sys::socket::{c_uint, CMSG_SPACE};
405-
use std::mem;
406404
let mut space = 0;
407405
$(
408406
// CMSG_SPACE is always safe
409407
space += unsafe {
410-
CMSG_SPACE(mem::size_of::<$x>() as c_uint)
408+
$crate::sys::socket::CMSG_SPACE(::std::mem::size_of::<$x>() as $crate::sys::socket::c_uint)
411409
} as usize;
412410
)*
413411
Vec::<u8>::with_capacity(space)
@@ -1775,3 +1773,11 @@ pub fn shutdown(df: RawFd, how: Shutdown) -> Result<()> {
17751773
Errno::result(shutdown(df, how)).map(drop)
17761774
}
17771775
}
1776+
1777+
#[cfg(test)]
1778+
mod tests {
1779+
#[test]
1780+
fn can_use_cmsg_space() {
1781+
let _ = cmsg_space!(u8);
1782+
}
1783+
}

0 commit comments

Comments
 (0)