Skip to content

Commit e9d81a7

Browse files
committed
Convert winsock calls to WSA...A
1 parent 3773091 commit e9d81a7

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

library/std/src/fs/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ fn windows_unix_socket_exists() {
17621762
// std doesn't currently support Unix sockets on Windows so manually create one here.
17631763
net::init();
17641764
unsafe {
1765-
let socket = c::WSASocketW(
1765+
let socket = c::WSASocketA(
17661766
c::AF_UNIX as i32,
17671767
c::SOCK_STREAM,
17681768
0,

library/std/src/os/windows/io/socket.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,17 @@ impl BorrowedSocket<'_> {
113113
/// object as the existing `BorrowedSocket` instance.
114114
#[stable(feature = "io_safety", since = "1.63.0")]
115115
pub fn try_clone_to_owned(&self) -> io::Result<OwnedSocket> {
116-
let mut info = unsafe { mem::zeroed::<sys::c::WSAPROTOCOL_INFOW>() };
116+
let mut info = unsafe { mem::zeroed::<sys::c::WSAPROTOCOL_INFOA>() };
117117
let result = unsafe {
118-
sys::c::WSADuplicateSocketW(
118+
sys::c::WSADuplicateSocketA(
119119
self.as_raw_socket() as sys::c::SOCKET,
120120
sys::c::GetCurrentProcessId(),
121121
&mut info,
122122
)
123123
};
124124
sys::net::cvt(result)?;
125125
let socket = unsafe {
126-
sys::c::WSASocketW(
126+
sys::c::WSASocketA(
127127
info.iAddressFamily,
128128
info.iSocketType,
129129
info.iProtocol,
@@ -143,7 +143,7 @@ impl BorrowedSocket<'_> {
143143
}
144144

145145
let socket = unsafe {
146-
sys::c::WSASocketW(
146+
sys::c::WSASocketA(
147147
info.iAddressFamily,
148148
info.iSocketType,
149149
info.iProtocol,

library/std/src/sys/windows/c/windows_sys.lst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,6 @@ Windows.Win32.Networking.WinSock.WSABASEERR
21132113
Windows.Win32.Networking.WinSock.WSABUF
21142114
Windows.Win32.Networking.WinSock.WSACleanup
21152115
Windows.Win32.Networking.WinSock.WSADATA
2116-
Windows.Win32.Networking.WinSock.WSADuplicateSocketW
21172116
Windows.Win32.Networking.WinSock.WSAEACCES
21182117
Windows.Win32.Networking.WinSock.WSAEADDRINUSE
21192118
Windows.Win32.Networking.WinSock.WSAEADDRNOTAVAIL
@@ -2169,12 +2168,10 @@ Windows.Win32.Networking.WinSock.WSAHOST_NOT_FOUND
21692168
Windows.Win32.Networking.WinSock.WSANO_DATA
21702169
Windows.Win32.Networking.WinSock.WSANO_RECOVERY
21712170
Windows.Win32.Networking.WinSock.WSANOTINITIALISED
2172-
Windows.Win32.Networking.WinSock.WSAPROTOCOL_INFOW
21732171
Windows.Win32.Networking.WinSock.WSAPROTOCOLCHAIN
21742172
Windows.Win32.Networking.WinSock.WSARecv
21752173
Windows.Win32.Networking.WinSock.WSASend
21762174
Windows.Win32.Networking.WinSock.WSASERVICE_NOT_FOUND
2177-
Windows.Win32.Networking.WinSock.WSASocketW
21782175
Windows.Win32.Networking.WinSock.WSASYSCALLFAILURE
21792176
Windows.Win32.Networking.WinSock.WSASYSNOTREADY
21802177
Windows.Win32.Networking.WinSock.WSATRY_AGAIN
@@ -2621,3 +2618,8 @@ Windows.Win32.Storage.FileSystem.INVALID_SET_FILE_POINTER
26212618
// hashmap crypt fallback
26222619
Windows.Win32.System.SystemInformation.GetTickCount
26232620
Windows.Win32.System.Threading.GetCurrentThreadId
2621+
2622+
// WinSock fallbacks
2623+
Windows.Win32.Networking.WinSock.WSAPROTOCOL_INFOA
2624+
Windows.Win32.Networking.WinSock.WSASocketA
2625+
Windows.Win32.Networking.WinSock.WSADuplicateSocketA

library/std/src/sys/windows/c/windows_sys.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -779,10 +779,10 @@ extern "system" {
779779
}
780780
#[link(name = "ws2_32")]
781781
extern "system" {
782-
pub fn WSADuplicateSocketW(
782+
pub fn WSADuplicateSocketA(
783783
s: SOCKET,
784784
dwprocessid: u32,
785-
lpprotocolinfo: *mut WSAPROTOCOL_INFOW,
785+
lpprotocolinfo: *mut WSAPROTOCOL_INFOA,
786786
) -> i32;
787787
}
788788
#[link(name = "ws2_32")]
@@ -815,11 +815,11 @@ extern "system" {
815815
}
816816
#[link(name = "ws2_32")]
817817
extern "system" {
818-
pub fn WSASocketW(
818+
pub fn WSASocketA(
819819
af: i32,
820820
r#type: i32,
821821
protocol: i32,
822-
lpprotocolinfo: *const WSAPROTOCOL_INFOW,
822+
lpprotocolinfo: *const WSAPROTOCOL_INFOA,
823823
g: u32,
824824
dwflags: u32,
825825
) -> SOCKET;
@@ -4356,7 +4356,7 @@ impl ::core::clone::Clone for WSAPROTOCOLCHAIN {
43564356
}
43574357
}
43584358
#[repr(C)]
4359-
pub struct WSAPROTOCOL_INFOW {
4359+
pub struct WSAPROTOCOL_INFOA {
43604360
pub dwServiceFlags1: u32,
43614361
pub dwServiceFlags2: u32,
43624362
pub dwServiceFlags3: u32,
@@ -4376,10 +4376,10 @@ pub struct WSAPROTOCOL_INFOW {
43764376
pub iSecurityScheme: i32,
43774377
pub dwMessageSize: u32,
43784378
pub dwProviderReserved: u32,
4379-
pub szProtocol: [u16; 256],
4379+
pub szProtocol: [u8; 256],
43804380
}
4381-
impl ::core::marker::Copy for WSAPROTOCOL_INFOW {}
4382-
impl ::core::clone::Clone for WSAPROTOCOL_INFOW {
4381+
impl ::core::marker::Copy for WSAPROTOCOL_INFOA {}
4382+
impl ::core::clone::Clone for WSAPROTOCOL_INFOA {
43834383
fn clone(&self) -> Self {
43844384
*self
43854385
}

library/std/src/sys/windows/net.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl Socket {
106106
SocketAddr::V6(..) => c::AF_INET6,
107107
};
108108
let socket = unsafe {
109-
c::WSASocketW(
109+
c::WSASocketA(
110110
family,
111111
ty,
112112
0,
@@ -126,7 +126,7 @@ impl Socket {
126126
}
127127

128128
let socket =
129-
unsafe { c::WSASocketW(family, ty, 0, ptr::null_mut(), 0, c::WSA_FLAG_OVERLAPPED) };
129+
unsafe { c::WSASocketA(family, ty, 0, ptr::null_mut(), 0, c::WSA_FLAG_OVERLAPPED) };
130130

131131
if socket == c::INVALID_SOCKET {
132132
return Err(last_error());

0 commit comments

Comments
 (0)