| ... | ... | @@ -57,7 +57,7 @@ const Closure = struct { |
| 57 | 57 | fn requestCancel(closure: *Closure) void { |
| 58 | 58 | switch (@atomicRmw(std.Thread.Id, &closure.cancel_tid, .Xchg, canceling_tid, .acq_rel)) { |
| 59 | 59 | 0, canceling_tid => {}, |
| 60 | | else => |tid| switch (builtin.os.tag) { |
| 60 | else => |tid| switch (native_os) { |
| 61 | 61 | .linux => _ = std.os.linux.tgkill(std.os.linux.getpid(), @bitCast(tid), posix.SIG.IO), |
| 62 | 62 | else => {}, |
| 63 | 63 | }, |
| ... | ... | @@ -168,49 +168,49 @@ pub fn io(t: *Threaded) Io { |
| 168 | 168 | .conditionWaitUncancelable = conditionWaitUncancelable, |
| 169 | 169 | .conditionWake = conditionWake, |
| 170 | 170 | |
| 171 | | .dirMake = switch (builtin.os.tag) { |
| 171 | .dirMake = switch (native_os) { |
| 172 | 172 | .windows => dirMakeWindows, |
| 173 | 173 | .wasi => dirMakeWasi, |
| 174 | 174 | else => dirMakePosix, |
| 175 | 175 | }, |
| 176 | | .dirMakePath = switch (builtin.os.tag) { |
| 176 | .dirMakePath = switch (native_os) { |
| 177 | 177 | .windows => dirMakePathWindows, |
| 178 | 178 | else => dirMakePathPosix, |
| 179 | 179 | }, |
| 180 | | .dirMakeOpenPath = switch (builtin.os.tag) { |
| 180 | .dirMakeOpenPath = switch (native_os) { |
| 181 | 181 | .windows => dirMakeOpenPathWindows, |
| 182 | 182 | .wasi => dirMakeOpenPathWasi, |
| 183 | 183 | else => dirMakeOpenPathPosix, |
| 184 | 184 | }, |
| 185 | 185 | .dirStat = dirStat, |
| 186 | | .dirStatPath = switch (builtin.os.tag) { |
| 186 | .dirStatPath = switch (native_os) { |
| 187 | 187 | .linux => dirStatPathLinux, |
| 188 | 188 | .windows => dirStatPathWindows, |
| 189 | 189 | .wasi => dirStatPathWasi, |
| 190 | 190 | else => dirStatPathPosix, |
| 191 | 191 | }, |
| 192 | | .fileStat = switch (builtin.os.tag) { |
| 192 | .fileStat = switch (native_os) { |
| 193 | 193 | .linux => fileStatLinux, |
| 194 | 194 | .windows => fileStatWindows, |
| 195 | 195 | .wasi => fileStatWasi, |
| 196 | 196 | else => fileStatPosix, |
| 197 | 197 | }, |
| 198 | | .dirAccess = switch (builtin.os.tag) { |
| 198 | .dirAccess = switch (native_os) { |
| 199 | 199 | .windows => dirAccessWindows, |
| 200 | 200 | .wasi => dirAccessWasi, |
| 201 | 201 | else => dirAccessPosix, |
| 202 | 202 | }, |
| 203 | | .dirCreateFile = switch (builtin.os.tag) { |
| 203 | .dirCreateFile = switch (native_os) { |
| 204 | 204 | .windows => dirCreateFileWindows, |
| 205 | 205 | .wasi => dirCreateFileWasi, |
| 206 | 206 | else => dirCreateFilePosix, |
| 207 | 207 | }, |
| 208 | | .dirOpenFile = switch (builtin.os.tag) { |
| 208 | .dirOpenFile = switch (native_os) { |
| 209 | 209 | .windows => dirOpenFileWindows, |
| 210 | 210 | .wasi => dirOpenFileWasi, |
| 211 | 211 | else => dirOpenFilePosix, |
| 212 | 212 | }, |
| 213 | | .dirOpenDir = switch (builtin.os.tag) { |
| 213 | .dirOpenDir = switch (native_os) { |
| 214 | 214 | .wasi => dirOpenDirWasi, |
| 215 | 215 | .haiku => dirOpenDirHaiku, |
| 216 | 216 | else => dirOpenDirPosix, |
| ... | ... | @@ -219,11 +219,11 @@ pub fn io(t: *Threaded) Io { |
| 219 | 219 | .fileClose = fileClose, |
| 220 | 220 | .fileWriteStreaming = fileWriteStreaming, |
| 221 | 221 | .fileWritePositional = fileWritePositional, |
| 222 | | .fileReadStreaming = switch (builtin.os.tag) { |
| 222 | .fileReadStreaming = switch (native_os) { |
| 223 | 223 | .windows => fileReadStreamingWindows, |
| 224 | 224 | else => fileReadStreamingPosix, |
| 225 | 225 | }, |
| 226 | | .fileReadPositional = switch (builtin.os.tag) { |
| 226 | .fileReadPositional = switch (native_os) { |
| 227 | 227 | .windows => fileReadPositionalWindows, |
| 228 | 228 | else => fileReadPositionalPosix, |
| 229 | 229 | }, |
| ... | ... | @@ -231,53 +231,56 @@ pub fn io(t: *Threaded) Io { |
| 231 | 231 | .fileSeekTo = fileSeekTo, |
| 232 | 232 | .openSelfExe = openSelfExe, |
| 233 | 233 | |
| 234 | | .now = switch (builtin.os.tag) { |
| 234 | .now = switch (native_os) { |
| 235 | 235 | .windows => nowWindows, |
| 236 | 236 | .wasi => nowWasi, |
| 237 | 237 | else => nowPosix, |
| 238 | 238 | }, |
| 239 | | .sleep = switch (builtin.os.tag) { |
| 239 | .sleep = switch (native_os) { |
| 240 | 240 | .windows => sleepWindows, |
| 241 | 241 | .wasi => sleepWasi, |
| 242 | 242 | .linux => sleepLinux, |
| 243 | 243 | else => sleepPosix, |
| 244 | 244 | }, |
| 245 | 245 | |
| 246 | | .netListenIp = switch (builtin.os.tag) { |
| 246 | .netListenIp = switch (native_os) { |
| 247 | 247 | .windows => netListenIpWindows, |
| 248 | 248 | else => netListenIpPosix, |
| 249 | 249 | }, |
| 250 | | .netListenUnix = switch (builtin.os.tag) { |
| 250 | .netListenUnix = switch (native_os) { |
| 251 | 251 | .windows => netListenUnixWindows, |
| 252 | 252 | else => netListenUnixPosix, |
| 253 | 253 | }, |
| 254 | | .netAccept = switch (builtin.os.tag) { |
| 254 | .netAccept = switch (native_os) { |
| 255 | 255 | .windows => netAcceptWindows, |
| 256 | 256 | else => netAcceptPosix, |
| 257 | 257 | }, |
| 258 | | .netBindIp = switch (builtin.os.tag) { |
| 258 | .netBindIp = switch (native_os) { |
| 259 | 259 | .windows => netBindIpWindows, |
| 260 | 260 | else => netBindIpPosix, |
| 261 | 261 | }, |
| 262 | | .netConnectIp = switch (builtin.os.tag) { |
| 262 | .netConnectIp = switch (native_os) { |
| 263 | 263 | .windows => netConnectIpWindows, |
| 264 | 264 | else => netConnectIpPosix, |
| 265 | 265 | }, |
| 266 | | .netConnectUnix = netConnectUnix, |
| 266 | .netConnectUnix = switch (native_os) { |
| 267 | .windows => netConnectUnixWindows, |
| 268 | else => netConnectUnixPosix, |
| 269 | }, |
| 267 | 270 | .netClose = netClose, |
| 268 | | .netRead = switch (builtin.os.tag) { |
| 271 | .netRead = switch (native_os) { |
| 269 | 272 | .windows => netReadWindows, |
| 270 | 273 | else => netReadPosix, |
| 271 | 274 | }, |
| 272 | | .netWrite = switch (builtin.os.tag) { |
| 275 | .netWrite = switch (native_os) { |
| 273 | 276 | .windows => netWriteWindows, |
| 274 | 277 | else => netWritePosix, |
| 275 | 278 | }, |
| 276 | | .netSend = switch (builtin.os.tag) { |
| 279 | .netSend = switch (native_os) { |
| 277 | 280 | .windows => netSendWindows, |
| 278 | 281 | else => netSendPosix, |
| 279 | 282 | }, |
| 280 | | .netReceive = switch (builtin.os.tag) { |
| 283 | .netReceive = switch (native_os) { |
| 281 | 284 | .windows => netReceiveWindows, |
| 282 | 285 | else => netReceivePosix, |
| 283 | 286 | }, |
| ... | ... | @@ -288,12 +291,12 @@ pub fn io(t: *Threaded) Io { |
| 288 | 291 | }; |
| 289 | 292 | } |
| 290 | 293 | |
| 291 | | pub const socket_flags_unsupported = builtin.os.tag.isDarwin() or native_os == .haiku; // 💩💩 |
| 294 | pub const socket_flags_unsupported = native_os.isDarwin() or native_os == .haiku; // 💩💩 |
| 292 | 295 | const have_accept4 = !socket_flags_unsupported; |
| 293 | 296 | const have_flock_open_flags = @hasField(posix.O, "EXLOCK"); |
| 294 | | const have_networking = builtin.os.tag != .wasi; |
| 297 | const have_networking = native_os != .wasi; |
| 295 | 298 | const have_flock = @TypeOf(posix.system.flock) != void; |
| 296 | | const have_sendmmsg = builtin.os.tag == .linux; |
| 299 | const have_sendmmsg = native_os == .linux; |
| 297 | 300 | const have_futex = switch (builtin.cpu.arch) { |
| 298 | 301 | .wasm32, .wasm64 => builtin.cpu.has(.wasm, .atomics), |
| 299 | 302 | else => true, |
| ... | ... | @@ -2916,7 +2919,7 @@ fn netListenUnixWindows( |
| 2916 | 2919 | ) net.UnixAddress.ListenError!net.Socket.Handle { |
| 2917 | 2920 | if (!net.has_unix_sockets) return error.AddressFamilyUnsupported; |
| 2918 | 2921 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2919 | | _ = t; |
| 2922 | try t.checkCancel(); |
| 2920 | 2923 | _ = address; |
| 2921 | 2924 | _ = options; |
| 2922 | 2925 | @panic("TODO"); |
| ... | ... | @@ -3192,7 +3195,7 @@ fn netConnectIpWindows( |
| 3192 | 3195 | } }; |
| 3193 | 3196 | } |
| 3194 | 3197 | |
| 3195 | | fn netConnectUnix( |
| 3198 | fn netConnectUnixPosix( |
| 3196 | 3199 | userdata: ?*anyopaque, |
| 3197 | 3200 | address: *const net.UnixAddress, |
| 3198 | 3201 | ) net.UnixAddress.ConnectError!net.Socket.Handle { |
| ... | ... | @@ -3209,6 +3212,17 @@ fn netConnectUnix( |
| 3209 | 3212 | return socket_fd; |
| 3210 | 3213 | } |
| 3211 | 3214 | |
| 3215 | fn 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 | |
| 3212 | 3226 | fn netBindIpPosix( |
| 3213 | 3227 | userdata: ?*anyopaque, |
| 3214 | 3228 | address: *const IpAddress, |
| ... | ... | @@ -4456,11 +4470,11 @@ fn recoverableOsBugDetected() void { |
| 4456 | 4470 | fn clockToPosix(clock: Io.Clock) posix.clockid_t { |
| 4457 | 4471 | return switch (clock) { |
| 4458 | 4472 | .real => posix.CLOCK.REALTIME, |
| 4459 | | .awake => switch (builtin.os.tag) { |
| 4473 | .awake => switch (native_os) { |
| 4460 | 4474 | .macos, .ios, .watchos, .tvos => posix.CLOCK.UPTIME_RAW, |
| 4461 | 4475 | else => posix.CLOCK.MONOTONIC, |
| 4462 | 4476 | }, |
| 4463 | | .boot => switch (builtin.os.tag) { |
| 4477 | .boot => switch (native_os) { |
| 4464 | 4478 | .macos, .ios, .watchos, .tvos => posix.CLOCK.MONOTONIC_RAW, |
| 4465 | 4479 | else => posix.CLOCK.BOOTTIME, |
| 4466 | 4480 | }, |
| ... | ... | @@ -4523,7 +4537,7 @@ fn statFromPosix(st: *const std.posix.Stat) Io.File.Stat { |
| 4523 | 4537 | std.posix.S.IFSOCK => break :k .unix_domain_socket, |
| 4524 | 4538 | else => {}, |
| 4525 | 4539 | } |
| 4526 | | if (builtin.os.tag == .illumos) switch (m) { |
| 4540 | if (native_os == .illumos) switch (m) { |
| 4527 | 4541 | std.posix.S.IFDOOR => break :k .door, |
| 4528 | 4542 | std.posix.S.IFPORT => break :k .event_port, |
| 4529 | 4543 | else => {}, |