summaryrefslogtreecommitdiff
path: root/src/sys/socket/mod.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-23 02:58:48 +0000
committerGitHub <noreply@github.com>2021-03-23 02:58:48 +0000
commit3f8a66dc69ba3ae4df6a0f3eb879dc30020965bc (patch)
treec26fa0de33f327c18a8711bc179397ccc8db6785 /src/sys/socket/mod.rs
parent5e491c81dcced811ed6ddce7872e255a62a61606 (diff)
parentf7ce988c290f7acfcc71d7c963b6e8a2e6052058 (diff)
downloadnix-3f8a66dc69ba3ae4df6a0f3eb879dc30020965bc.zip
Merge #1406
1406: Allow cmsg_space! to be used in unit tests r=asomers a=WiSaGaN Fixes https://github.com/nix-rust/nix/issues/1405 Co-authored-by: Lu, Wangshan <wisagan@gmail.com>
Diffstat (limited to 'src/sys/socket/mod.rs')
-rw-r--r--src/sys/socket/mod.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index 74a26834..2725e57c 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -415,13 +415,11 @@ impl Ipv6MembershipRequest {
macro_rules! cmsg_space {
( $( $x:ty ),* ) => {
{
- use nix::sys::socket::{c_uint, CMSG_SPACE};
- use std::mem;
let mut space = 0;
$(
// CMSG_SPACE is always safe
space += unsafe {
- CMSG_SPACE(mem::size_of::<$x>() as c_uint)
+ $crate::sys::socket::CMSG_SPACE(::std::mem::size_of::<$x>() as $crate::sys::socket::c_uint)
} as usize;
)*
Vec::<u8>::with_capacity(space)
@@ -1789,3 +1787,11 @@ pub fn shutdown(df: RawFd, how: Shutdown) -> Result<()> {
Errno::result(shutdown(df, how)).map(drop)
}
}
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn can_use_cmsg_space() {
+ let _ = cmsg_space!(u8);
+ }
+}