Skip to content

Commit a7a709a

Browse files
binarycraft007andrewrk
authored andcommitted
Fixes #13893 - some standard library networking tests are failing on Windows
1 parent e41bc64 commit a7a709a

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/std/os/windows.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,7 @@ pub fn loadWinsockExtensionFunction(comptime T: type, sock: ws2_32.SOCKET, guid:
20682068
ws2_32.SIO_GET_EXTENSION_FUNCTION_POINTER,
20692069
@ptrCast(*const anyopaque, &guid),
20702070
@sizeOf(GUID),
2071-
@intToPtr(?*anyopaque, @ptrToInt(function)),
2071+
@intToPtr(?*anyopaque, @ptrToInt(&function)),
20722072
@sizeOf(T),
20732073
&num_bytes,
20742074
null,

lib/std/os/windows/test.zig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,28 @@ test "removeDotDirs" {
6363
try testRemoveDotDirs("a\\b\\..\\", "a\\");
6464
try testRemoveDotDirs("a\\b\\..\\c", "a\\c");
6565
}
66+
67+
test "loadWinsockExtensionFunction" {
68+
_ = try windows.WSAStartup(2, 2);
69+
defer windows.WSACleanup() catch unreachable;
70+
71+
const LPFN_CONNECTEX = *const fn (
72+
Socket: windows.ws2_32.SOCKET,
73+
SockAddr: *const windows.ws2_32.sockaddr,
74+
SockLen: std.os.socklen_t,
75+
SendBuf: ?*const anyopaque,
76+
SendBufLen: windows.DWORD,
77+
BytesSent: *windows.DWORD,
78+
Overlapped: *windows.OVERLAPPED,
79+
) callconv(windows.WINAPI) windows.BOOL;
80+
81+
_ = windows.loadWinsockExtensionFunction(
82+
LPFN_CONNECTEX,
83+
try std.os.socket(std.os.AF.INET, std.os.SOCK.DGRAM, 0),
84+
windows.ws2_32.WSAID_CONNECTEX,
85+
) catch |err| switch (err) {
86+
error.OperationNotSupported => unreachable,
87+
error.ShortRead => unreachable,
88+
else => |e| return e,
89+
};
90+
}

0 commit comments

Comments
 (0)