@@ -9,7 +9,6 @@ use crate::marker::PhantomData;
9
9
use crate :: mem;
10
10
use crate :: mem:: forget;
11
11
use crate :: sys;
12
- use crate :: sys:: c;
13
12
#[ cfg( not( target_vendor = "uwp" ) ) ]
14
13
use crate :: sys:: cvt;
15
14
@@ -76,7 +75,7 @@ impl BorrowedSocket<'_> {
76
75
#[ rustc_const_stable( feature = "io_safety" , since = "1.63.0" ) ]
77
76
#[ stable( feature = "io_safety" , since = "1.63.0" ) ]
78
77
pub const unsafe fn borrow_raw ( socket : RawSocket ) -> Self {
79
- assert ! ( socket != c:: INVALID_SOCKET as RawSocket ) ;
78
+ assert ! ( socket != sys :: c:: INVALID_SOCKET as RawSocket ) ;
80
79
Self { socket, _phantom : PhantomData }
81
80
}
82
81
}
@@ -94,7 +93,11 @@ impl OwnedSocket {
94
93
#[ cfg( not( target_vendor = "uwp" ) ) ]
95
94
pub ( crate ) fn set_no_inherit ( & self ) -> io:: Result < ( ) > {
96
95
cvt ( unsafe {
97
- c:: SetHandleInformation ( self . as_raw_socket ( ) as c:: HANDLE , c:: HANDLE_FLAG_INHERIT , 0 )
96
+ sys:: c:: SetHandleInformation (
97
+ self . as_raw_socket ( ) as sys:: c:: HANDLE ,
98
+ sys:: c:: HANDLE_FLAG_INHERIT ,
99
+ 0 ,
100
+ )
98
101
} )
99
102
. map ( drop)
100
103
}
@@ -110,43 +113,47 @@ impl BorrowedSocket<'_> {
110
113
/// object as the existing `BorrowedSocket` instance.
111
114
#[ stable( feature = "io_safety" , since = "1.63.0" ) ]
112
115
pub fn try_clone_to_owned ( & self ) -> io:: Result < OwnedSocket > {
113
- let mut info = unsafe { mem:: zeroed :: < c:: WSAPROTOCOL_INFOW > ( ) } ;
116
+ let mut info = unsafe { mem:: zeroed :: < sys :: c:: WSAPROTOCOL_INFOW > ( ) } ;
114
117
let result = unsafe {
115
- c:: WSADuplicateSocketW ( self . as_raw_socket ( ) , c:: GetCurrentProcessId ( ) , & mut info)
118
+ sys:: c:: WSADuplicateSocketW (
119
+ self . as_raw_socket ( ) ,
120
+ sys:: c:: GetCurrentProcessId ( ) ,
121
+ & mut info,
122
+ )
116
123
} ;
117
124
sys:: net:: cvt ( result) ?;
118
125
let socket = unsafe {
119
- c:: WSASocketW (
126
+ sys :: c:: WSASocketW (
120
127
info. iAddressFamily ,
121
128
info. iSocketType ,
122
129
info. iProtocol ,
123
130
& mut info,
124
131
0 ,
125
- c:: WSA_FLAG_OVERLAPPED | c:: WSA_FLAG_NO_HANDLE_INHERIT ,
132
+ sys :: c:: WSA_FLAG_OVERLAPPED | sys :: c:: WSA_FLAG_NO_HANDLE_INHERIT ,
126
133
)
127
134
} ;
128
135
129
- if socket != c:: INVALID_SOCKET {
136
+ if socket != sys :: c:: INVALID_SOCKET {
130
137
unsafe { Ok ( OwnedSocket :: from_raw_socket ( socket) ) }
131
138
} else {
132
- let error = unsafe { c:: WSAGetLastError ( ) } ;
139
+ let error = unsafe { sys :: c:: WSAGetLastError ( ) } ;
133
140
134
- if error != c:: WSAEPROTOTYPE && error != c:: WSAEINVAL {
141
+ if error != sys :: c:: WSAEPROTOTYPE && error != sys :: c:: WSAEINVAL {
135
142
return Err ( io:: Error :: from_raw_os_error ( error) ) ;
136
143
}
137
144
138
145
let socket = unsafe {
139
- c:: WSASocketW (
146
+ sys :: c:: WSASocketW (
140
147
info. iAddressFamily ,
141
148
info. iSocketType ,
142
149
info. iProtocol ,
143
150
& mut info,
144
151
0 ,
145
- c:: WSA_FLAG_OVERLAPPED ,
152
+ sys :: c:: WSA_FLAG_OVERLAPPED ,
146
153
)
147
154
} ;
148
155
149
- if socket == c:: INVALID_SOCKET {
156
+ if socket == sys :: c:: INVALID_SOCKET {
150
157
return Err ( last_error ( ) ) ;
151
158
}
152
159
@@ -161,7 +168,7 @@ impl BorrowedSocket<'_> {
161
168
162
169
/// Returns the last error from the Windows socket interface.
163
170
fn last_error ( ) -> io:: Error {
164
- io:: Error :: from_raw_os_error ( unsafe { c:: WSAGetLastError ( ) } )
171
+ io:: Error :: from_raw_os_error ( unsafe { sys :: c:: WSAGetLastError ( ) } )
165
172
}
166
173
167
174
#[ stable( feature = "io_safety" , since = "1.63.0" ) ]
@@ -194,7 +201,7 @@ impl IntoRawSocket for OwnedSocket {
194
201
impl FromRawSocket for OwnedSocket {
195
202
#[ inline]
196
203
unsafe fn from_raw_socket ( socket : RawSocket ) -> Self {
197
- debug_assert_ne ! ( socket, c:: INVALID_SOCKET as RawSocket ) ;
204
+ debug_assert_ne ! ( socket, sys :: c:: INVALID_SOCKET as RawSocket ) ;
198
205
Self { socket }
199
206
}
200
207
}
@@ -204,7 +211,7 @@ impl Drop for OwnedSocket {
204
211
#[ inline]
205
212
fn drop ( & mut self ) {
206
213
unsafe {
207
- let _ = c:: closesocket ( self . socket ) ;
214
+ let _ = sys :: c:: closesocket ( self . socket ) ;
208
215
}
209
216
}
210
217
}
0 commit comments