authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-23 08:02:03-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-29 06:20:51-07:00
log5d7672f2adc8f1058aa1f49f80055b8816a06371
tree47da8d1ae830506f254f4fa659705c721eb63fa1
parent89bb58e5a3c663b139e55e943ce32331baa24c61

std.Io.Threaded: stub netConnectUnix for Windows


1 files changed, 46 insertions(+), 32 deletions(-)

lib/std/Io/Threaded.zig+46-32
......@@ -57,7 +57,7 @@ const Closure = struct {
5757 fn requestCancel(closure: *Closure) void {
5858 switch (@atomicRmw(std.Thread.Id, &closure.cancel_tid, .Xchg, canceling_tid, .acq_rel)) {
5959 0, canceling_tid => {},
60 else => |tid| switch (builtin.os.tag) {
60 else => |tid| switch (native_os) {
6161 .linux => _ = std.os.linux.tgkill(std.os.linux.getpid(), @bitCast(tid), posix.SIG.IO),
6262 else => {},
6363 },
......@@ -168,49 +168,49 @@ pub fn io(t: *Threaded) Io {
168168 .conditionWaitUncancelable = conditionWaitUncancelable,
169169 .conditionWake = conditionWake,
170170
171 .dirMake = switch (builtin.os.tag) {
171 .dirMake = switch (native_os) {
172172 .windows => dirMakeWindows,
173173 .wasi => dirMakeWasi,
174174 else => dirMakePosix,
175175 },
176 .dirMakePath = switch (builtin.os.tag) {
176 .dirMakePath = switch (native_os) {
177177 .windows => dirMakePathWindows,
178178 else => dirMakePathPosix,
179179 },
180 .dirMakeOpenPath = switch (builtin.os.tag) {
180 .dirMakeOpenPath = switch (native_os) {
181181 .windows => dirMakeOpenPathWindows,
182182 .wasi => dirMakeOpenPathWasi,
183183 else => dirMakeOpenPathPosix,
184184 },
185185 .dirStat = dirStat,
186 .dirStatPath = switch (builtin.os.tag) {
186 .dirStatPath = switch (native_os) {
187187 .linux => dirStatPathLinux,
188188 .windows => dirStatPathWindows,
189189 .wasi => dirStatPathWasi,
190190 else => dirStatPathPosix,
191191 },
192 .fileStat = switch (builtin.os.tag) {
192 .fileStat = switch (native_os) {
193193 .linux => fileStatLinux,
194194 .windows => fileStatWindows,
195195 .wasi => fileStatWasi,
196196 else => fileStatPosix,
197197 },
198 .dirAccess = switch (builtin.os.tag) {
198 .dirAccess = switch (native_os) {
199199 .windows => dirAccessWindows,
200200 .wasi => dirAccessWasi,
201201 else => dirAccessPosix,
202202 },
203 .dirCreateFile = switch (builtin.os.tag) {
203 .dirCreateFile = switch (native_os) {
204204 .windows => dirCreateFileWindows,
205205 .wasi => dirCreateFileWasi,
206206 else => dirCreateFilePosix,
207207 },
208 .dirOpenFile = switch (builtin.os.tag) {
208 .dirOpenFile = switch (native_os) {
209209 .windows => dirOpenFileWindows,
210210 .wasi => dirOpenFileWasi,
211211 else => dirOpenFilePosix,
212212 },
213 .dirOpenDir = switch (builtin.os.tag) {
213 .dirOpenDir = switch (native_os) {
214214 .wasi => dirOpenDirWasi,
215215 .haiku => dirOpenDirHaiku,
216216 else => dirOpenDirPosix,
......@@ -219,11 +219,11 @@ pub fn io(t: *Threaded) Io {
219219 .fileClose = fileClose,
220220 .fileWriteStreaming = fileWriteStreaming,
221221 .fileWritePositional = fileWritePositional,
222 .fileReadStreaming = switch (builtin.os.tag) {
222 .fileReadStreaming = switch (native_os) {
223223 .windows => fileReadStreamingWindows,
224224 else => fileReadStreamingPosix,
225225 },
226 .fileReadPositional = switch (builtin.os.tag) {
226 .fileReadPositional = switch (native_os) {
227227 .windows => fileReadPositionalWindows,
228228 else => fileReadPositionalPosix,
229229 },
......@@ -231,53 +231,56 @@ pub fn io(t: *Threaded) Io {
231231 .fileSeekTo = fileSeekTo,
232232 .openSelfExe = openSelfExe,
233233
234 .now = switch (builtin.os.tag) {
234 .now = switch (native_os) {
235235 .windows => nowWindows,
236236 .wasi => nowWasi,
237237 else => nowPosix,
238238 },
239 .sleep = switch (builtin.os.tag) {
239 .sleep = switch (native_os) {
240240 .windows => sleepWindows,
241241 .wasi => sleepWasi,
242242 .linux => sleepLinux,
243243 else => sleepPosix,
244244 },
245245
246 .netListenIp = switch (builtin.os.tag) {
246 .netListenIp = switch (native_os) {
247247 .windows => netListenIpWindows,
248248 else => netListenIpPosix,
249249 },
250 .netListenUnix = switch (builtin.os.tag) {
250 .netListenUnix = switch (native_os) {
251251 .windows => netListenUnixWindows,
252252 else => netListenUnixPosix,
253253 },
254 .netAccept = switch (builtin.os.tag) {
254 .netAccept = switch (native_os) {
255255 .windows => netAcceptWindows,
256256 else => netAcceptPosix,
257257 },
258 .netBindIp = switch (builtin.os.tag) {
258 .netBindIp = switch (native_os) {
259259 .windows => netBindIpWindows,
260260 else => netBindIpPosix,
261261 },
262 .netConnectIp = switch (builtin.os.tag) {
262 .netConnectIp = switch (native_os) {
263263 .windows => netConnectIpWindows,
264264 else => netConnectIpPosix,
265265 },
266 .netConnectUnix = netConnectUnix,
266 .netConnectUnix = switch (native_os) {
267 .windows => netConnectUnixWindows,
268 else => netConnectUnixPosix,
269 },
267270 .netClose = netClose,
268 .netRead = switch (builtin.os.tag) {
271 .netRead = switch (native_os) {
269272 .windows => netReadWindows,
270273 else => netReadPosix,
271274 },
272 .netWrite = switch (builtin.os.tag) {
275 .netWrite = switch (native_os) {
273276 .windows => netWriteWindows,
274277 else => netWritePosix,
275278 },
276 .netSend = switch (builtin.os.tag) {
279 .netSend = switch (native_os) {
277280 .windows => netSendWindows,
278281 else => netSendPosix,
279282 },
280 .netReceive = switch (builtin.os.tag) {
283 .netReceive = switch (native_os) {
281284 .windows => netReceiveWindows,
282285 else => netReceivePosix,
283286 },
......@@ -288,12 +291,12 @@ pub fn io(t: *Threaded) Io {
288291 };
289292}
290293
291pub const socket_flags_unsupported = builtin.os.tag.isDarwin() or native_os == .haiku; // 💩💩
294pub const socket_flags_unsupported = native_os.isDarwin() or native_os == .haiku; // 💩💩
292295const have_accept4 = !socket_flags_unsupported;
293296const have_flock_open_flags = @hasField(posix.O, "EXLOCK");
294const have_networking = builtin.os.tag != .wasi;
297const have_networking = native_os != .wasi;
295298const have_flock = @TypeOf(posix.system.flock) != void;
296const have_sendmmsg = builtin.os.tag == .linux;
299const have_sendmmsg = native_os == .linux;
297300const have_futex = switch (builtin.cpu.arch) {
298301 .wasm32, .wasm64 => builtin.cpu.has(.wasm, .atomics),
299302 else => true,
......@@ -2916,7 +2919,7 @@ fn netListenUnixWindows(
29162919) net.UnixAddress.ListenError!net.Socket.Handle {
29172920 if (!net.has_unix_sockets) return error.AddressFamilyUnsupported;
29182921 const t: *Threaded = @ptrCast(@alignCast(userdata));
2919 _ = t;
2922 try t.checkCancel();
29202923 _ = address;
29212924 _ = options;
29222925 @panic("TODO");
......@@ -3192,7 +3195,7 @@ fn netConnectIpWindows(
31923195 } };
31933196}
31943197
3195fn netConnectUnix(
3198fn netConnectUnixPosix(
31963199 userdata: ?*anyopaque,
31973200 address: *const net.UnixAddress,
31983201) net.UnixAddress.ConnectError!net.Socket.Handle {
......@@ -3209,6 +3212,17 @@ fn netConnectUnix(
32093212 return socket_fd;
32103213}
32113214
3215fn netConnectUnixWindows(
3216 userdata: ?*anyopaque,
3217 address: *const net.UnixAddress,
3218) net.UnixAddress.ConnectError!net.Socket.Handle {
3219 if (!net.has_unix_sockets) return error.AddressFamilyUnsupported;
3220 const t: *Threaded = @ptrCast(@alignCast(userdata));
3221 try t.checkCancel();
3222 _ = address;
3223 @panic("TODO");
3224}
3225
32123226fn netBindIpPosix(
32133227 userdata: ?*anyopaque,
32143228 address: *const IpAddress,
......@@ -4456,11 +4470,11 @@ fn recoverableOsBugDetected() void {
44564470fn clockToPosix(clock: Io.Clock) posix.clockid_t {
44574471 return switch (clock) {
44584472 .real => posix.CLOCK.REALTIME,
4459 .awake => switch (builtin.os.tag) {
4473 .awake => switch (native_os) {
44604474 .macos, .ios, .watchos, .tvos => posix.CLOCK.UPTIME_RAW,
44614475 else => posix.CLOCK.MONOTONIC,
44624476 },
4463 .boot => switch (builtin.os.tag) {
4477 .boot => switch (native_os) {
44644478 .macos, .ios, .watchos, .tvos => posix.CLOCK.MONOTONIC_RAW,
44654479 else => posix.CLOCK.BOOTTIME,
44664480 },
......@@ -4523,7 +4537,7 @@ fn statFromPosix(st: *const std.posix.Stat) Io.File.Stat {
45234537 std.posix.S.IFSOCK => break :k .unix_domain_socket,
45244538 else => {},
45254539 }
4526 if (builtin.os.tag == .illumos) switch (m) {
4540 if (native_os == .illumos) switch (m) {
45274541 std.posix.S.IFDOOR => break :k .door,
45284542 std.posix.S.IFPORT => break :k .event_port,
45294543 else => {},