mirror of
https://github.com/ziglang/zig.git
synced 2026-01-03 03:53:20 +00:00
std.Io.Threaded: stub netConnectUnix for Windows
This commit is contained in:
parent
89bb58e5a3
commit
5d7672f2ad
@ -57,7 +57,7 @@ const Closure = struct {
|
|||||||
fn requestCancel(closure: *Closure) void {
|
fn requestCancel(closure: *Closure) void {
|
||||||
switch (@atomicRmw(std.Thread.Id, &closure.cancel_tid, .Xchg, canceling_tid, .acq_rel)) {
|
switch (@atomicRmw(std.Thread.Id, &closure.cancel_tid, .Xchg, canceling_tid, .acq_rel)) {
|
||||||
0, canceling_tid => {},
|
0, canceling_tid => {},
|
||||||
else => |tid| switch (builtin.os.tag) {
|
else => |tid| switch (native_os) {
|
||||||
.linux => _ = std.os.linux.tgkill(std.os.linux.getpid(), @bitCast(tid), posix.SIG.IO),
|
.linux => _ = std.os.linux.tgkill(std.os.linux.getpid(), @bitCast(tid), posix.SIG.IO),
|
||||||
else => {},
|
else => {},
|
||||||
},
|
},
|
||||||
@ -168,49 +168,49 @@ pub fn io(t: *Threaded) Io {
|
|||||||
.conditionWaitUncancelable = conditionWaitUncancelable,
|
.conditionWaitUncancelable = conditionWaitUncancelable,
|
||||||
.conditionWake = conditionWake,
|
.conditionWake = conditionWake,
|
||||||
|
|
||||||
.dirMake = switch (builtin.os.tag) {
|
.dirMake = switch (native_os) {
|
||||||
.windows => dirMakeWindows,
|
.windows => dirMakeWindows,
|
||||||
.wasi => dirMakeWasi,
|
.wasi => dirMakeWasi,
|
||||||
else => dirMakePosix,
|
else => dirMakePosix,
|
||||||
},
|
},
|
||||||
.dirMakePath = switch (builtin.os.tag) {
|
.dirMakePath = switch (native_os) {
|
||||||
.windows => dirMakePathWindows,
|
.windows => dirMakePathWindows,
|
||||||
else => dirMakePathPosix,
|
else => dirMakePathPosix,
|
||||||
},
|
},
|
||||||
.dirMakeOpenPath = switch (builtin.os.tag) {
|
.dirMakeOpenPath = switch (native_os) {
|
||||||
.windows => dirMakeOpenPathWindows,
|
.windows => dirMakeOpenPathWindows,
|
||||||
.wasi => dirMakeOpenPathWasi,
|
.wasi => dirMakeOpenPathWasi,
|
||||||
else => dirMakeOpenPathPosix,
|
else => dirMakeOpenPathPosix,
|
||||||
},
|
},
|
||||||
.dirStat = dirStat,
|
.dirStat = dirStat,
|
||||||
.dirStatPath = switch (builtin.os.tag) {
|
.dirStatPath = switch (native_os) {
|
||||||
.linux => dirStatPathLinux,
|
.linux => dirStatPathLinux,
|
||||||
.windows => dirStatPathWindows,
|
.windows => dirStatPathWindows,
|
||||||
.wasi => dirStatPathWasi,
|
.wasi => dirStatPathWasi,
|
||||||
else => dirStatPathPosix,
|
else => dirStatPathPosix,
|
||||||
},
|
},
|
||||||
.fileStat = switch (builtin.os.tag) {
|
.fileStat = switch (native_os) {
|
||||||
.linux => fileStatLinux,
|
.linux => fileStatLinux,
|
||||||
.windows => fileStatWindows,
|
.windows => fileStatWindows,
|
||||||
.wasi => fileStatWasi,
|
.wasi => fileStatWasi,
|
||||||
else => fileStatPosix,
|
else => fileStatPosix,
|
||||||
},
|
},
|
||||||
.dirAccess = switch (builtin.os.tag) {
|
.dirAccess = switch (native_os) {
|
||||||
.windows => dirAccessWindows,
|
.windows => dirAccessWindows,
|
||||||
.wasi => dirAccessWasi,
|
.wasi => dirAccessWasi,
|
||||||
else => dirAccessPosix,
|
else => dirAccessPosix,
|
||||||
},
|
},
|
||||||
.dirCreateFile = switch (builtin.os.tag) {
|
.dirCreateFile = switch (native_os) {
|
||||||
.windows => dirCreateFileWindows,
|
.windows => dirCreateFileWindows,
|
||||||
.wasi => dirCreateFileWasi,
|
.wasi => dirCreateFileWasi,
|
||||||
else => dirCreateFilePosix,
|
else => dirCreateFilePosix,
|
||||||
},
|
},
|
||||||
.dirOpenFile = switch (builtin.os.tag) {
|
.dirOpenFile = switch (native_os) {
|
||||||
.windows => dirOpenFileWindows,
|
.windows => dirOpenFileWindows,
|
||||||
.wasi => dirOpenFileWasi,
|
.wasi => dirOpenFileWasi,
|
||||||
else => dirOpenFilePosix,
|
else => dirOpenFilePosix,
|
||||||
},
|
},
|
||||||
.dirOpenDir = switch (builtin.os.tag) {
|
.dirOpenDir = switch (native_os) {
|
||||||
.wasi => dirOpenDirWasi,
|
.wasi => dirOpenDirWasi,
|
||||||
.haiku => dirOpenDirHaiku,
|
.haiku => dirOpenDirHaiku,
|
||||||
else => dirOpenDirPosix,
|
else => dirOpenDirPosix,
|
||||||
@ -219,11 +219,11 @@ pub fn io(t: *Threaded) Io {
|
|||||||
.fileClose = fileClose,
|
.fileClose = fileClose,
|
||||||
.fileWriteStreaming = fileWriteStreaming,
|
.fileWriteStreaming = fileWriteStreaming,
|
||||||
.fileWritePositional = fileWritePositional,
|
.fileWritePositional = fileWritePositional,
|
||||||
.fileReadStreaming = switch (builtin.os.tag) {
|
.fileReadStreaming = switch (native_os) {
|
||||||
.windows => fileReadStreamingWindows,
|
.windows => fileReadStreamingWindows,
|
||||||
else => fileReadStreamingPosix,
|
else => fileReadStreamingPosix,
|
||||||
},
|
},
|
||||||
.fileReadPositional = switch (builtin.os.tag) {
|
.fileReadPositional = switch (native_os) {
|
||||||
.windows => fileReadPositionalWindows,
|
.windows => fileReadPositionalWindows,
|
||||||
else => fileReadPositionalPosix,
|
else => fileReadPositionalPosix,
|
||||||
},
|
},
|
||||||
@ -231,53 +231,56 @@ pub fn io(t: *Threaded) Io {
|
|||||||
.fileSeekTo = fileSeekTo,
|
.fileSeekTo = fileSeekTo,
|
||||||
.openSelfExe = openSelfExe,
|
.openSelfExe = openSelfExe,
|
||||||
|
|
||||||
.now = switch (builtin.os.tag) {
|
.now = switch (native_os) {
|
||||||
.windows => nowWindows,
|
.windows => nowWindows,
|
||||||
.wasi => nowWasi,
|
.wasi => nowWasi,
|
||||||
else => nowPosix,
|
else => nowPosix,
|
||||||
},
|
},
|
||||||
.sleep = switch (builtin.os.tag) {
|
.sleep = switch (native_os) {
|
||||||
.windows => sleepWindows,
|
.windows => sleepWindows,
|
||||||
.wasi => sleepWasi,
|
.wasi => sleepWasi,
|
||||||
.linux => sleepLinux,
|
.linux => sleepLinux,
|
||||||
else => sleepPosix,
|
else => sleepPosix,
|
||||||
},
|
},
|
||||||
|
|
||||||
.netListenIp = switch (builtin.os.tag) {
|
.netListenIp = switch (native_os) {
|
||||||
.windows => netListenIpWindows,
|
.windows => netListenIpWindows,
|
||||||
else => netListenIpPosix,
|
else => netListenIpPosix,
|
||||||
},
|
},
|
||||||
.netListenUnix = switch (builtin.os.tag) {
|
.netListenUnix = switch (native_os) {
|
||||||
.windows => netListenUnixWindows,
|
.windows => netListenUnixWindows,
|
||||||
else => netListenUnixPosix,
|
else => netListenUnixPosix,
|
||||||
},
|
},
|
||||||
.netAccept = switch (builtin.os.tag) {
|
.netAccept = switch (native_os) {
|
||||||
.windows => netAcceptWindows,
|
.windows => netAcceptWindows,
|
||||||
else => netAcceptPosix,
|
else => netAcceptPosix,
|
||||||
},
|
},
|
||||||
.netBindIp = switch (builtin.os.tag) {
|
.netBindIp = switch (native_os) {
|
||||||
.windows => netBindIpWindows,
|
.windows => netBindIpWindows,
|
||||||
else => netBindIpPosix,
|
else => netBindIpPosix,
|
||||||
},
|
},
|
||||||
.netConnectIp = switch (builtin.os.tag) {
|
.netConnectIp = switch (native_os) {
|
||||||
.windows => netConnectIpWindows,
|
.windows => netConnectIpWindows,
|
||||||
else => netConnectIpPosix,
|
else => netConnectIpPosix,
|
||||||
},
|
},
|
||||||
.netConnectUnix = netConnectUnix,
|
.netConnectUnix = switch (native_os) {
|
||||||
|
.windows => netConnectUnixWindows,
|
||||||
|
else => netConnectUnixPosix,
|
||||||
|
},
|
||||||
.netClose = netClose,
|
.netClose = netClose,
|
||||||
.netRead = switch (builtin.os.tag) {
|
.netRead = switch (native_os) {
|
||||||
.windows => netReadWindows,
|
.windows => netReadWindows,
|
||||||
else => netReadPosix,
|
else => netReadPosix,
|
||||||
},
|
},
|
||||||
.netWrite = switch (builtin.os.tag) {
|
.netWrite = switch (native_os) {
|
||||||
.windows => netWriteWindows,
|
.windows => netWriteWindows,
|
||||||
else => netWritePosix,
|
else => netWritePosix,
|
||||||
},
|
},
|
||||||
.netSend = switch (builtin.os.tag) {
|
.netSend = switch (native_os) {
|
||||||
.windows => netSendWindows,
|
.windows => netSendWindows,
|
||||||
else => netSendPosix,
|
else => netSendPosix,
|
||||||
},
|
},
|
||||||
.netReceive = switch (builtin.os.tag) {
|
.netReceive = switch (native_os) {
|
||||||
.windows => netReceiveWindows,
|
.windows => netReceiveWindows,
|
||||||
else => netReceivePosix,
|
else => netReceivePosix,
|
||||||
},
|
},
|
||||||
@ -288,12 +291,12 @@ pub fn io(t: *Threaded) Io {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const socket_flags_unsupported = builtin.os.tag.isDarwin() or native_os == .haiku; // 💩💩
|
pub const socket_flags_unsupported = native_os.isDarwin() or native_os == .haiku; // 💩💩
|
||||||
const have_accept4 = !socket_flags_unsupported;
|
const have_accept4 = !socket_flags_unsupported;
|
||||||
const have_flock_open_flags = @hasField(posix.O, "EXLOCK");
|
const have_flock_open_flags = @hasField(posix.O, "EXLOCK");
|
||||||
const have_networking = builtin.os.tag != .wasi;
|
const have_networking = native_os != .wasi;
|
||||||
const have_flock = @TypeOf(posix.system.flock) != void;
|
const have_flock = @TypeOf(posix.system.flock) != void;
|
||||||
const have_sendmmsg = builtin.os.tag == .linux;
|
const have_sendmmsg = native_os == .linux;
|
||||||
const have_futex = switch (builtin.cpu.arch) {
|
const have_futex = switch (builtin.cpu.arch) {
|
||||||
.wasm32, .wasm64 => builtin.cpu.has(.wasm, .atomics),
|
.wasm32, .wasm64 => builtin.cpu.has(.wasm, .atomics),
|
||||||
else => true,
|
else => true,
|
||||||
@ -2916,7 +2919,7 @@ fn netListenUnixWindows(
|
|||||||
) net.UnixAddress.ListenError!net.Socket.Handle {
|
) net.UnixAddress.ListenError!net.Socket.Handle {
|
||||||
if (!net.has_unix_sockets) return error.AddressFamilyUnsupported;
|
if (!net.has_unix_sockets) return error.AddressFamilyUnsupported;
|
||||||
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
||||||
_ = t;
|
try t.checkCancel();
|
||||||
_ = address;
|
_ = address;
|
||||||
_ = options;
|
_ = options;
|
||||||
@panic("TODO");
|
@panic("TODO");
|
||||||
@ -3192,7 +3195,7 @@ fn netConnectIpWindows(
|
|||||||
} };
|
} };
|
||||||
}
|
}
|
||||||
|
|
||||||
fn netConnectUnix(
|
fn netConnectUnixPosix(
|
||||||
userdata: ?*anyopaque,
|
userdata: ?*anyopaque,
|
||||||
address: *const net.UnixAddress,
|
address: *const net.UnixAddress,
|
||||||
) net.UnixAddress.ConnectError!net.Socket.Handle {
|
) net.UnixAddress.ConnectError!net.Socket.Handle {
|
||||||
@ -3209,6 +3212,17 @@ fn netConnectUnix(
|
|||||||
return socket_fd;
|
return socket_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn netConnectUnixWindows(
|
||||||
|
userdata: ?*anyopaque,
|
||||||
|
address: *const net.UnixAddress,
|
||||||
|
) net.UnixAddress.ConnectError!net.Socket.Handle {
|
||||||
|
if (!net.has_unix_sockets) return error.AddressFamilyUnsupported;
|
||||||
|
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
||||||
|
try t.checkCancel();
|
||||||
|
_ = address;
|
||||||
|
@panic("TODO");
|
||||||
|
}
|
||||||
|
|
||||||
fn netBindIpPosix(
|
fn netBindIpPosix(
|
||||||
userdata: ?*anyopaque,
|
userdata: ?*anyopaque,
|
||||||
address: *const IpAddress,
|
address: *const IpAddress,
|
||||||
@ -4456,11 +4470,11 @@ fn recoverableOsBugDetected() void {
|
|||||||
fn clockToPosix(clock: Io.Clock) posix.clockid_t {
|
fn clockToPosix(clock: Io.Clock) posix.clockid_t {
|
||||||
return switch (clock) {
|
return switch (clock) {
|
||||||
.real => posix.CLOCK.REALTIME,
|
.real => posix.CLOCK.REALTIME,
|
||||||
.awake => switch (builtin.os.tag) {
|
.awake => switch (native_os) {
|
||||||
.macos, .ios, .watchos, .tvos => posix.CLOCK.UPTIME_RAW,
|
.macos, .ios, .watchos, .tvos => posix.CLOCK.UPTIME_RAW,
|
||||||
else => posix.CLOCK.MONOTONIC,
|
else => posix.CLOCK.MONOTONIC,
|
||||||
},
|
},
|
||||||
.boot => switch (builtin.os.tag) {
|
.boot => switch (native_os) {
|
||||||
.macos, .ios, .watchos, .tvos => posix.CLOCK.MONOTONIC_RAW,
|
.macos, .ios, .watchos, .tvos => posix.CLOCK.MONOTONIC_RAW,
|
||||||
else => posix.CLOCK.BOOTTIME,
|
else => posix.CLOCK.BOOTTIME,
|
||||||
},
|
},
|
||||||
@ -4523,7 +4537,7 @@ fn statFromPosix(st: *const std.posix.Stat) Io.File.Stat {
|
|||||||
std.posix.S.IFSOCK => break :k .unix_domain_socket,
|
std.posix.S.IFSOCK => break :k .unix_domain_socket,
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
if (builtin.os.tag == .illumos) switch (m) {
|
if (native_os == .illumos) switch (m) {
|
||||||
std.posix.S.IFDOOR => break :k .door,
|
std.posix.S.IFDOOR => break :k .door,
|
||||||
std.posix.S.IFPORT => break :k .event_port,
|
std.posix.S.IFPORT => break :k .event_port,
|
||||||
else => {},
|
else => {},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user