authorgravatar for elliot.huang.signed@gmail.comBinary Craft <elliot.huang.signed@gmail.com> 2023-02-24 11:03:27+08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-01 02:54:43-05:00
loga7a709aaa974c394c001f6d7d9be138cc44fd22d
treebd3d67dd5cfbfaadd701a2cfe6efb173d37a54a9
parente41bc640c6c4277385236d3dd90b4db566550509

Fixes #13893 - some standard library networking tests are failing on Windows


2 files changed, 26 insertions(+), 1 deletions(-)

lib/std/os/windows.zig+1-1
......@@ -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+25
......@@ -63,3 +63,28 @@ test "removeDotDirs" {
6363 try testRemoveDotDirs("a\\b\\..\\", "a\\");
6464 try testRemoveDotDirs("a\\b\\..\\c", "a\\c");
6565}
66
67test "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}