1
- use std:: { mem , ptr:: null_mut} ;
1
+ use std:: ptr:: null_mut;
2
2
3
- pub use i32 as c_int;
4
3
use windows_sys:: Win32 :: Networking :: WinSock :: { CMSGHDR , WSABUF , WSAMSG } ;
5
4
6
5
// Macros from https://github.com/microsoft/win32metadata/blob/main/generation/WinSDK/RecompiledIdlHeaders/shared/ws2def.h
7
6
#[ inline]
8
7
const fn wsa_cmsghdr_align ( length : usize ) -> usize {
9
- ( length + mem:: align_of :: < CMSGHDR > ( ) - 1 ) & !( mem:: align_of :: < CMSGHDR > ( ) - 1 )
8
+ ( length + std :: mem:: align_of :: < CMSGHDR > ( ) - 1 ) & !( std :: mem:: align_of :: < CMSGHDR > ( ) - 1 )
10
9
}
11
10
12
11
// WSA_CMSGDATA_ALIGN(sizeof(CMSGHDR))
13
12
const WSA_CMSGDATA_OFFSET : usize =
14
- ( mem:: size_of :: < CMSGHDR > ( ) + mem:: align_of :: < usize > ( ) - 1 ) & !( mem:: align_of :: < usize > ( ) - 1 ) ;
13
+ ( std :: mem:: size_of :: < CMSGHDR > ( ) + std :: mem:: align_of :: < usize > ( ) - 1 ) & !( std :: mem:: align_of :: < usize > ( ) - 1 ) ;
15
14
16
15
#[ inline]
17
16
unsafe fn wsa_cmsg_firsthdr ( msg : * const WSAMSG ) -> * mut CMSGHDR {
18
- if ( * msg) . Control . len as usize >= mem:: size_of :: < CMSGHDR > ( ) {
17
+ if ( * msg) . Control . len as usize >= std :: mem:: size_of :: < CMSGHDR > ( ) {
19
18
( * msg) . Control . buf as _
20
19
} else {
21
20
null_mut ( )
@@ -28,7 +27,7 @@ unsafe fn wsa_cmsg_nxthdr(msg: *const WSAMSG, cmsg: *const CMSGHDR) -> *mut CMSG
28
27
wsa_cmsg_firsthdr ( msg)
29
28
} else {
30
29
let next = cmsg as usize + wsa_cmsghdr_align ( ( * cmsg) . cmsg_len ) ;
31
- if next + mem:: size_of :: < CMSGHDR > ( )
30
+ if next + std :: mem:: size_of :: < CMSGHDR > ( )
32
31
> ( * msg) . Control . buf as usize + ( * msg) . Control . len as usize
33
32
{
34
33
null_mut ( )
@@ -97,7 +96,7 @@ impl<'a> CMsgMut<'a> {
97
96
}
98
97
99
98
pub ( crate ) unsafe fn set_data < T > ( & mut self , data : T ) {
100
- self . 0 . cmsg_len = wsa_cmsg_len ( mem:: size_of :: < T > ( ) as _ ) as _ ;
99
+ self . 0 . cmsg_len = wsa_cmsg_len ( std :: mem:: size_of :: < T > ( ) as _ ) as _ ;
101
100
let data_ptr = wsa_cmsg_data ( self . 0 ) ;
102
101
std:: ptr:: write ( data_ptr. cast :: < T > ( ) , data) ;
103
102
}
@@ -113,7 +112,7 @@ impl CMsgIter {
113
112
assert ! ( len >= wsa_cmsg_space( 0 ) as _, "buffer too short" ) ;
114
113
assert ! ( ptr. cast:: <CMSGHDR >( ) . is_aligned( ) , "misaligned buffer" ) ;
115
114
116
- let mut msg: WSAMSG = unsafe { mem:: zeroed ( ) } ;
115
+ let mut msg: WSAMSG = unsafe { std :: mem:: zeroed ( ) } ;
117
116
msg. Control = WSABUF {
118
117
len : len as _ ,
119
118
buf : ptr as _ ,
@@ -143,7 +142,7 @@ impl CMsgIter {
143
142
144
143
pub ( crate ) fn is_space_enough < T > ( & self ) -> bool {
145
144
if !self . cmsg . is_null ( ) {
146
- let space = wsa_cmsg_space ( mem:: size_of :: < T > ( ) as _ ) ;
145
+ let space = wsa_cmsg_space ( std :: mem:: size_of :: < T > ( ) as _ ) ;
147
146
let max = self . msg . Control . buf as usize + self . msg . Control . len as usize ;
148
147
self . cmsg as usize + space <= max
149
148
} else {
@@ -153,5 +152,5 @@ impl CMsgIter {
153
152
}
154
153
155
154
pub ( crate ) fn space_of < T > ( ) -> usize {
156
- wsa_cmsg_space ( mem:: size_of :: < T > ( ) as _ )
155
+ wsa_cmsg_space ( std :: mem:: size_of :: < T > ( ) as _ )
157
156
}
0 commit comments