| author | |
| committer | |
| log | 11c8c38332ada0585a8690e84c8de3affb34c935 |
| tree | dc8aa3968f27bd928111bc9aa52f8fefed5f0d76 |
| parent | 77d0a9c07e8880bdb222d87ece66a7d822a76748 |
std.c should reflect the CRT, not std.posix's bizarre view of the world.
Also:
* Audit some incorrect std.c types and function signatures
* Remove ws2_32 from std.c (dubious quality, and ws2_32 isn't libc)
* Remove remnants of Windows support in std.posix
closes https://codeberg.org/ziglang/zig/issues/3738213 files changed, 234 insertions(+), 205 deletions(-)
lib/std/Io/Dir.zig+1-1| ... | @@ -12,7 +12,7 @@ const Allocator = std.mem.Allocator; | ... | @@ -12,7 +12,7 @@ const Allocator = std.mem.Allocator; |
| 12 | 12 | ||
| 13 | handle: Handle, | 13 | handle: Handle, |
| 14 | 14 | ||
| 15 | pub const Handle = std.posix.fd_t; | 15 | pub const Handle = File.Handle; |
| 16 | 16 | ||
| 17 | pub const path = std.fs.path; | 17 | pub const path = std.fs.path; |
| 18 | 18 |
lib/std/Io/File.zig+5-5| ... | @@ -23,7 +23,7 @@ pub const Flags = struct { | ... | @@ -23,7 +23,7 @@ pub const Flags = struct { |
| 23 | nonblocking: bool, | 23 | nonblocking: bool, |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | pub const Handle = std.posix.fd_t; | 26 | pub const Handle = if (native_os == .windows) std.os.windows.HANDLE else std.posix.fd_t; |
| 27 | 27 | ||
| 28 | pub const Reader = @import("File/Reader.zig"); | 28 | pub const Reader = @import("File/Reader.zig"); |
| 29 | pub const Writer = @import("File/Writer.zig"); | 29 | pub const Writer = @import("File/Writer.zig"); |
| ... | @@ -34,10 +34,10 @@ pub const MemoryMap = @import("File/MemoryMap.zig"); | ... | @@ -34,10 +34,10 @@ pub const MemoryMap = @import("File/MemoryMap.zig"); |
| 34 | /// deadlocking. | 34 | /// deadlocking. |
| 35 | pub const MultiReader = @import("File/MultiReader.zig"); | 35 | pub const MultiReader = @import("File/MultiReader.zig"); |
| 36 | 36 | ||
| 37 | pub const INode = std.posix.ino_t; | 37 | pub const INode = if (native_os == .windows) std.os.windows.LARGE_INTEGER else std.posix.ino_t; |
| 38 | pub const NLink = std.posix.nlink_t; | 38 | pub const NLink = if (native_os == .windows) std.os.windows.ULONG else std.posix.nlink_t; |
| 39 | pub const Uid = std.posix.uid_t; | 39 | pub const Uid = if (native_os == .windows) void else std.posix.uid_t; |
| 40 | pub const Gid = std.posix.gid_t; | 40 | pub const Gid = if (native_os == .windows) void else std.posix.gid_t; |
| 41 | pub const BlockSize = u32; | 41 | pub const BlockSize = u32; |
| 42 | 42 | ||
| 43 | pub const Kind = enum { | 43 | pub const Kind = enum { |
lib/std/Io/Threaded.zig+74-65| ... | @@ -1614,7 +1614,7 @@ pub const default_PATH = "/usr/local/bin:/bin:/usr/bin"; | ... | @@ -1614,7 +1614,7 @@ pub const default_PATH = "/usr/local/bin:/bin:/usr/bin"; |
| 1614 | const max_windows_kernel_bug_retries = 13; | 1614 | const max_windows_kernel_bug_retries = 13; |
| 1615 | 1615 | ||
| 1616 | comptime { | 1616 | comptime { |
| 1617 | if (@TypeOf(posix.IOV_MAX) != void) assert(max_iovecs_len <= posix.IOV_MAX); | 1617 | if (!is_windows and @TypeOf(posix.IOV_MAX) != void) assert(max_iovecs_len <= posix.IOV_MAX); |
| 1618 | } | 1618 | } |
| 1619 | 1619 | ||
| 1620 | pub const InitOptions = struct { | 1620 | pub const InitOptions = struct { |
| ... | @@ -1696,7 +1696,7 @@ pub fn init( | ... | @@ -1696,7 +1696,7 @@ pub fn init( |
| 1696 | .disable_memory_mapping = options.disable_memory_mapping, | 1696 | .disable_memory_mapping = options.disable_memory_mapping, |
| 1697 | }; | 1697 | }; |
| 1698 | 1698 | ||
| 1699 | if (posix.Sigaction != void) { | 1699 | if (!is_windows and posix.Sigaction != void) { |
| 1700 | // This causes sending `posix.SIG.IO` to thread to interrupt blocking | 1700 | // This causes sending `posix.SIG.IO` to thread to interrupt blocking |
| 1701 | // syscalls, returning `posix.E.INTR`. | 1701 | // syscalls, returning `posix.E.INTR`. |
| 1702 | const act: posix.Sigaction = .{ | 1702 | const act: posix.Sigaction = .{ |
| ... | @@ -1758,7 +1758,7 @@ pub fn setAsyncLimit(t: *Threaded, new_limit: Io.Limit) void { | ... | @@ -1758,7 +1758,7 @@ pub fn setAsyncLimit(t: *Threaded, new_limit: Io.Limit) void { |
| 1758 | 1758 | ||
| 1759 | pub fn deinit(t: *Threaded) void { | 1759 | pub fn deinit(t: *Threaded) void { |
| 1760 | t.join(); | 1760 | t.join(); |
| 1761 | if (posix.Sigaction != void and t.have_signal_handler) { | 1761 | if (!is_windows and posix.Sigaction != void and t.have_signal_handler) { |
| 1762 | if (have_sig_io) posix.sigaction(.IO, &t.old_sig_io, null); | 1762 | if (have_sig_io) posix.sigaction(.IO, &t.old_sig_io, null); |
| 1763 | if (have_sig_pipe) posix.sigaction(.PIPE, &t.old_sig_pipe, null); | 1763 | if (have_sig_pipe) posix.sigaction(.PIPE, &t.old_sig_pipe, null); |
| 1764 | } | 1764 | } |
| ... | @@ -2009,8 +2009,8 @@ const have_preadv = switch (native_os) { | ... | @@ -2009,8 +2009,8 @@ const have_preadv = switch (native_os) { |
| 2009 | .windows, .haiku => false, | 2009 | .windows, .haiku => false, |
| 2010 | else => true, | 2010 | else => true, |
| 2011 | }; | 2011 | }; |
| 2012 | const have_sig_io = posix.SIG != void and @hasField(posix.SIG, "IO"); | 2012 | const have_sig_io = !is_windows and posix.SIG != void and @hasField(posix.SIG, "IO"); |
| 2013 | const have_sig_pipe = posix.SIG != void and @hasField(posix.SIG, "PIPE"); | 2013 | const have_sig_pipe = !is_windows and posix.SIG != void and @hasField(posix.SIG, "PIPE"); |
| 2014 | const have_sendfile = if (builtin.link_libc) @TypeOf(std.c.sendfile) != void else native_os == .linux; | 2014 | const have_sendfile = if (builtin.link_libc) @TypeOf(std.c.sendfile) != void else native_os == .linux; |
| 2015 | const have_copy_file_range = switch (native_os) { | 2015 | const have_copy_file_range = switch (native_os) { |
| 2016 | .linux, .freebsd => true, | 2016 | .linux, .freebsd => true, |
| ... | @@ -7283,6 +7283,8 @@ fn fileHardLink( | ... | @@ -7283,6 +7283,8 @@ fn fileHardLink( |
| 7283 | const t: *Threaded = @ptrCast(@alignCast(userdata)); | 7283 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 7284 | _ = t; | 7284 | _ = t; |
| 7285 | 7285 | ||
| 7286 | if (is_windows) return error.OperationUnsupported; | ||
| 7287 | |||
| 7286 | var new_path_buffer: [posix.PATH_MAX]u8 = undefined; | 7288 | var new_path_buffer: [posix.PATH_MAX]u8 = undefined; |
| 7287 | const new_sub_path_posix = try pathToPosix(new_sub_path, &new_path_buffer); | 7289 | const new_sub_path_posix = try pathToPosix(new_sub_path, &new_path_buffer); |
| 7288 | 7290 | ||
| ... | @@ -12229,7 +12231,7 @@ fn netListenUnixPosix( | ... | @@ -12229,7 +12231,7 @@ fn netListenUnixPosix( |
| 12229 | if (!net.has_unix_sockets) return error.AddressFamilyUnsupported; | 12231 | if (!net.has_unix_sockets) return error.AddressFamilyUnsupported; |
| 12230 | const t: *Threaded = @ptrCast(@alignCast(userdata)); | 12232 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 12231 | _ = t; | 12233 | _ = t; |
| 12232 | const socket_fd = openSocketPosix(posix.AF.UNIX, .{ .mode = .stream }) catch |err| switch (err) { | 12234 | const socket_fd = openSocketPosix(AF.UNIX, .{ .mode = .stream }) catch |err| switch (err) { |
| 12233 | error.ProtocolUnsupportedBySystem => return error.AddressFamilyUnsupported, | 12235 | error.ProtocolUnsupportedBySystem => return error.AddressFamilyUnsupported, |
| 12234 | error.ProtocolUnsupportedByAddressFamily => return error.AddressFamilyUnsupported, | 12236 | error.ProtocolUnsupportedByAddressFamily => return error.AddressFamilyUnsupported, |
| 12235 | error.SocketModeUnsupported => return error.AddressFamilyUnsupported, | 12237 | error.SocketModeUnsupported => return error.AddressFamilyUnsupported, |
| ... | @@ -12308,8 +12310,8 @@ fn netListenUnixWindows( | ... | @@ -12308,8 +12310,8 @@ fn netListenUnixWindows( |
| 12308 | 12310 | ||
| 12309 | fn posixBindUnix( | 12311 | fn posixBindUnix( |
| 12310 | fd: posix.socket_t, | 12312 | fd: posix.socket_t, |
| 12311 | addr: *const posix.sockaddr, | 12313 | addr: *const sockaddr, |
| 12312 | addr_len: posix.socklen_t, | 12314 | addr_len: socklen_t, |
| 12313 | ) !void { | 12315 | ) !void { |
| 12314 | const syscall: Syscall = try .start(); | 12316 | const syscall: Syscall = try .start(); |
| 12315 | while (true) { | 12317 | while (true) { |
| ... | @@ -12351,8 +12353,8 @@ fn posixBindUnix( | ... | @@ -12351,8 +12353,8 @@ fn posixBindUnix( |
| 12351 | 12353 | ||
| 12352 | fn posixBind( | 12354 | fn posixBind( |
| 12353 | socket_fd: posix.socket_t, | 12355 | socket_fd: posix.socket_t, |
| 12354 | addr: *const posix.sockaddr, | 12356 | addr: *const sockaddr, |
| 12355 | addr_len: posix.socklen_t, | 12357 | addr_len: socklen_t, |
| 12356 | ) !void { | 12358 | ) !void { |
| 12357 | const syscall: Syscall = try .start(); | 12359 | const syscall: Syscall = try .start(); |
| 12358 | while (true) { | 12360 | while (true) { |
| ... | @@ -12386,8 +12388,8 @@ fn posixBind( | ... | @@ -12386,8 +12388,8 @@ fn posixBind( |
| 12386 | 12388 | ||
| 12387 | fn posixConnect( | 12389 | fn posixConnect( |
| 12388 | socket_fd: posix.socket_t, | 12390 | socket_fd: posix.socket_t, |
| 12389 | addr: *const posix.sockaddr, | 12391 | addr: *const sockaddr, |
| 12390 | addr_len: posix.socklen_t, | 12392 | addr_len: socklen_t, |
| 12391 | ) !void { | 12393 | ) !void { |
| 12392 | const syscall: Syscall = try .start(); | 12394 | const syscall: Syscall = try .start(); |
| 12393 | while (true) switch (posix.errno(posix.system.connect(socket_fd, addr, addr_len))) { | 12395 | while (true) switch (posix.errno(posix.system.connect(socket_fd, addr, addr_len))) { |
| ... | @@ -12424,8 +12426,8 @@ fn posixConnect( | ... | @@ -12424,8 +12426,8 @@ fn posixConnect( |
| 12424 | 12426 | ||
| 12425 | fn posixConnectUnix( | 12427 | fn posixConnectUnix( |
| 12426 | fd: posix.socket_t, | 12428 | fd: posix.socket_t, |
| 12427 | addr: *const posix.sockaddr, | 12429 | addr: *const sockaddr, |
| 12428 | addr_len: posix.socklen_t, | 12430 | addr_len: socklen_t, |
| 12429 | ) !void { | 12431 | ) !void { |
| 12430 | const syscall: Syscall = try .start(); | 12432 | const syscall: Syscall = try .start(); |
| 12431 | while (true) { | 12433 | while (true) { |
| ... | @@ -12468,8 +12470,8 @@ fn posixConnectUnix( | ... | @@ -12468,8 +12470,8 @@ fn posixConnectUnix( |
| 12468 | 12470 | ||
| 12469 | fn posixGetSockName( | 12471 | fn posixGetSockName( |
| 12470 | socket_fd: posix.fd_t, | 12472 | socket_fd: posix.fd_t, |
| 12471 | addr: *posix.sockaddr, | 12473 | addr: *sockaddr, |
| 12472 | addr_len: *posix.socklen_t, | 12474 | addr_len: *socklen_t, |
| 12473 | ) !void { | 12475 | ) !void { |
| 12474 | const syscall: Syscall = try .start(); | 12476 | const syscall: Syscall = try .start(); |
| 12475 | while (true) { | 12477 | while (true) { |
| ... | @@ -12610,7 +12612,7 @@ fn netConnectUnixPosix( | ... | @@ -12610,7 +12612,7 @@ fn netConnectUnixPosix( |
| 12610 | if (!net.has_unix_sockets) return error.AddressFamilyUnsupported; | 12612 | if (!net.has_unix_sockets) return error.AddressFamilyUnsupported; |
| 12611 | const t: *Threaded = @ptrCast(@alignCast(userdata)); | 12613 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 12612 | _ = t; | 12614 | _ = t; |
| 12613 | const socket_fd = openSocketPosix(posix.AF.UNIX, .{ .mode = .stream }) catch |err| switch (err) { | 12615 | const socket_fd = openSocketPosix(AF.UNIX, .{ .mode = .stream }) catch |err| switch (err) { |
| 12614 | error.ProtocolUnsupportedByAddressFamily => return error.AddressFamilyUnsupported, | 12616 | error.ProtocolUnsupportedByAddressFamily => return error.AddressFamilyUnsupported, |
| 12615 | error.OptionUnsupported => return error.Unexpected, | 12617 | error.OptionUnsupported => return error.Unexpected, |
| 12616 | else => |e| return e, | 12618 | else => |e| return e, |
| ... | @@ -12705,7 +12707,7 @@ fn netBindIpWindows( | ... | @@ -12705,7 +12707,7 @@ fn netBindIpWindows( |
| 12705 | } | 12707 | } |
| 12706 | 12708 | ||
| 12707 | fn openSocketPosix( | 12709 | fn openSocketPosix( |
| 12708 | family: posix.sa_family_t, | 12710 | family: sa_family_t, |
| 12709 | options: IpAddress.BindOptions, | 12711 | options: IpAddress.BindOptions, |
| 12710 | ) error{ | 12712 | ) error{ |
| 12711 | AddressFamilyUnsupported, | 12713 | AddressFamilyUnsupported, |
| ... | @@ -12720,7 +12722,7 @@ fn openSocketPosix( | ... | @@ -12720,7 +12722,7 @@ fn openSocketPosix( |
| 12720 | Canceled, | 12722 | Canceled, |
| 12721 | }!posix.socket_t { | 12723 | }!posix.socket_t { |
| 12722 | const mode, const protocol = try posixSocketModeProtocol(family, options.mode, options.protocol); | 12724 | const mode, const protocol = try posixSocketModeProtocol(family, options.mode, options.protocol); |
| 12723 | const flags: u32 = mode | if (socket_flags_unsupported) 0 else posix.SOCK.CLOEXEC; | 12725 | const flags: u32 = mode | if (socket_flags_unsupported) 0 else SOCK.CLOEXEC; |
| 12724 | const syscall: Syscall = try .start(); | 12726 | const syscall: Syscall = try .start(); |
| 12725 | const socket_fd = while (true) { | 12727 | const socket_fd = while (true) { |
| 12726 | const rc = posix.system.socket(family, flags, protocol); | 12728 | const rc = posix.system.socket(family, flags, protocol); |
| ... | @@ -12751,7 +12753,7 @@ fn openSocketPosix( | ... | @@ -12751,7 +12753,7 @@ fn openSocketPosix( |
| 12751 | 12753 | ||
| 12752 | if (options.ip6_only) |ip6_only| { | 12754 | if (options.ip6_only) |ip6_only| { |
| 12753 | if (posix.IPV6 == void) return error.OptionUnsupported; | 12755 | if (posix.IPV6 == void) return error.OptionUnsupported; |
| 12754 | try setSocketOptionPosix(socket_fd, posix.IPPROTO.IPV6, posix.IPV6.V6ONLY, @intFromBool(ip6_only)); | 12756 | try setSocketOptionPosix(socket_fd, IPPROTO.IPV6, posix.IPV6.V6ONLY, @intFromBool(ip6_only)); |
| 12755 | } | 12757 | } |
| 12756 | 12758 | ||
| 12757 | return socket_fd; | 12759 | return socket_fd; |
| ... | @@ -12776,15 +12778,15 @@ fn netSocketCreatePair( | ... | @@ -12776,15 +12778,15 @@ fn netSocketCreatePair( |
| 12776 | const t: *Threaded = @ptrCast(@alignCast(userdata)); | 12778 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 12777 | _ = t; | 12779 | _ = t; |
| 12778 | if (!have_networking) return error.OperationUnsupported; | 12780 | if (!have_networking) return error.OperationUnsupported; |
| 12779 | if (@TypeOf(posix.system.socketpair) == void) return error.OperationUnsupported; | 12781 | if (is_windows or @TypeOf(posix.system.socketpair) == void) return error.OperationUnsupported; |
| 12780 | if (native_os == .haiku) @panic("TODO"); | 12782 | if (native_os == .haiku) @panic("TODO"); |
| 12781 | 12783 | ||
| 12782 | const family: posix.sa_family_t = switch (options.family) { | 12784 | const family: sa_family_t = switch (options.family) { |
| 12783 | .ip4 => posix.AF.INET, | 12785 | .ip4 => AF.INET, |
| 12784 | .ip6 => posix.AF.INET6, | 12786 | .ip6 => AF.INET6, |
| 12785 | }; | 12787 | }; |
| 12786 | const mode, const protocol = try posixSocketModeProtocol(family, options.mode, options.protocol); | 12788 | const mode, const protocol = try posixSocketModeProtocol(family, options.mode, options.protocol); |
| 12787 | const flags: u32 = mode | if (socket_flags_unsupported) 0 else posix.SOCK.CLOEXEC; | 12789 | const flags: u32 = mode | if (socket_flags_unsupported) 0 else SOCK.CLOEXEC; |
| 12788 | 12790 | ||
| 12789 | var sockets: [2]posix.socket_t = undefined; | 12791 | var sockets: [2]posix.socket_t = undefined; |
| 12790 | const syscall: Syscall = try .start(); | 12792 | const syscall: Syscall = try .start(); |
| ... | @@ -12800,7 +12802,7 @@ fn netSocketCreatePair( | ... | @@ -12800,7 +12802,7 @@ fn netSocketCreatePair( |
| 12800 | try setCloexec(sockets[1]); | 12802 | try setCloexec(sockets[1]); |
| 12801 | } | 12803 | } |
| 12802 | var storages: [2]PosixAddress = undefined; | 12804 | var storages: [2]PosixAddress = undefined; |
| 12803 | var addr_lens: [2]posix.socklen_t = .{ @sizeOf(PosixAddress), @sizeOf(PosixAddress) }; | 12805 | var addr_lens: [2]socklen_t = .{ @sizeOf(PosixAddress), @sizeOf(PosixAddress) }; |
| 12804 | try posixGetSockName(sockets[0], &storages[0].any, &addr_lens[0]); | 12806 | try posixGetSockName(sockets[0], &storages[0].any, &addr_lens[0]); |
| 12805 | try posixGetSockName(sockets[1], &storages[1].any, &addr_lens[1]); | 12807 | try posixGetSockName(sockets[1], &storages[1].any, &addr_lens[1]); |
| 12806 | return .{ | 12808 | return .{ |
| ... | @@ -12926,11 +12928,11 @@ fn netAccept(t: *Threaded, listen_fd: net.Socket.Handle, options: net.Server.Acc | ... | @@ -12926,11 +12928,11 @@ fn netAccept(t: *Threaded, listen_fd: net.Socket.Handle, options: net.Server.Acc |
| 12926 | 12928 | ||
| 12927 | fn netAcceptPosix(listen_fd: net.Socket.Handle) net.Server.AcceptError!net.Socket { | 12929 | fn netAcceptPosix(listen_fd: net.Socket.Handle) net.Server.AcceptError!net.Socket { |
| 12928 | var storage: PosixAddress = undefined; | 12930 | var storage: PosixAddress = undefined; |
| 12929 | var addr_len: posix.socklen_t = @sizeOf(PosixAddress); | 12931 | var addr_len: socklen_t = @sizeOf(PosixAddress); |
| 12930 | const syscall: Syscall = try .start(); | 12932 | const syscall: Syscall = try .start(); |
| 12931 | const fd = while (true) { | 12933 | const fd = while (true) { |
| 12932 | const rc = if (have_accept4) | 12934 | const rc = if (have_accept4) |
| 12933 | posix.system.accept4(listen_fd, &storage.any, &addr_len, posix.SOCK.CLOEXEC) | 12935 | posix.system.accept4(listen_fd, &storage.any, &addr_len, SOCK.CLOEXEC) |
| 12934 | else | 12936 | else |
| 12935 | posix.system.accept(listen_fd, &storage.any, &addr_len); | 12937 | posix.system.accept(listen_fd, &storage.any, &addr_len); |
| 12936 | switch (posix.errno(rc)) { | 12938 | switch (posix.errno(rc)) { |
| ... | @@ -13788,7 +13790,7 @@ fn netInterfaceNameResolve( | ... | @@ -13788,7 +13790,7 @@ fn netInterfaceNameResolve( |
| 13788 | const t: *Threaded = @ptrCast(@alignCast(userdata)); | 13790 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 13789 | 13791 | ||
| 13790 | if (native_os == .linux) { | 13792 | if (native_os == .linux) { |
| 13791 | const sock_fd = openSocketPosix(posix.AF.UNIX, .{ .mode = .dgram }) catch |err| switch (err) { | 13793 | const sock_fd = openSocketPosix(AF.UNIX, .{ .mode = .dgram }) catch |err| switch (err) { |
| 13792 | error.ProcessFdQuotaExceeded => return error.SystemResources, | 13794 | error.ProcessFdQuotaExceeded => return error.SystemResources, |
| 13793 | error.SystemFdQuotaExceeded => return error.SystemResources, | 13795 | error.SystemFdQuotaExceeded => return error.SystemResources, |
| 13794 | error.AddressFamilyUnsupported => return error.Unexpected, | 13796 | error.AddressFamilyUnsupported => return error.Unexpected, |
| ... | @@ -13950,7 +13952,7 @@ fn netInterfaceName(userdata: ?*anyopaque, interface: net.Interface) net.Interfa | ... | @@ -13950,7 +13952,7 @@ fn netInterfaceName(userdata: ?*anyopaque, interface: net.Interface) net.Interfa |
| 13950 | else => |err| return windows.unexpectedError(err), | 13952 | else => |err| return windows.unexpectedError(err), |
| 13951 | } | 13953 | } |
| 13952 | var name_w: [net.Interface.Name.max_len:0]windows.WCHAR = undefined; | 13954 | var name_w: [net.Interface.Name.max_len:0]windows.WCHAR = undefined; |
| 13953 | switch (ConvertInterfaceLuidToNameW.?(&luid, &name_w, name_w.len)) { | 13955 | switch (ConvertInterfaceLuidToNameW.?(&luid, &name_w, name_w.len + 1)) { |
| 13954 | .SUCCESS => {}, | 13956 | .SUCCESS => {}, |
| 13955 | .INVALID_PARAMETER => unreachable, | 13957 | .INVALID_PARAMETER => unreachable, |
| 13956 | .NOT_ENOUGH_MEMORY => return error.NameTooLong, | 13958 | .NOT_ENOUGH_MEMORY => return error.NameTooLong, |
| ... | @@ -14227,15 +14229,15 @@ fn netLookupFallible( | ... | @@ -14227,15 +14229,15 @@ fn netLookupFallible( |
| 14227 | const port_c = std.mem.printSentinel(&port_buffer, "{d}", .{options.port}, 0) catch unreachable; | 14229 | const port_c = std.mem.printSentinel(&port_buffer, "{d}", .{options.port}, 0) catch unreachable; |
| 14228 | 14230 | ||
| 14229 | const family: i32 = if (options.family) |f| switch (f) { | 14231 | const family: i32 = if (options.family) |f| switch (f) { |
| 14230 | .ip4 => posix.AF.INET, | 14232 | .ip4 => AF.INET, |
| 14231 | .ip6 => posix.AF.INET6, | 14233 | .ip6 => AF.INET6, |
| 14232 | } else posix.AF.UNSPEC; | 14234 | } else AF.UNSPEC; |
| 14233 | 14235 | ||
| 14234 | const hints: posix.addrinfo = .{ | 14236 | const hints: posix.addrinfo = .{ |
| 14235 | .flags = .{ .CANONNAME = options.canonical_name_buffer != null, .NUMERICSERV = true }, | 14237 | .flags = .{ .CANONNAME = options.canonical_name_buffer != null, .NUMERICSERV = true }, |
| 14236 | .family = family, | 14238 | .family = family, |
| 14237 | .socktype = posix.SOCK.STREAM, | 14239 | .socktype = SOCK.STREAM, |
| 14238 | .protocol = posix.IPPROTO.TCP, | 14240 | .protocol = IPPROTO.TCP, |
| 14239 | .canonname = null, | 14241 | .canonname = null, |
| 14240 | .addr = null, | 14242 | .addr = null, |
| 14241 | .addrlen = 0, | 14243 | .addrlen = 0, |
| ... | @@ -14489,47 +14491,54 @@ fn processSetCurrentPath(userdata: ?*anyopaque, path: []const u8) process.SetCur | ... | @@ -14489,47 +14491,54 @@ fn processSetCurrentPath(userdata: ?*anyopaque, path: []const u8) process.SetCur |
| 14489 | return chdir(path); | 14491 | return chdir(path); |
| 14490 | } | 14492 | } |
| 14491 | 14493 | ||
| 14494 | const sockaddr = if (is_windows) ws2_32.sockaddr else posix.sockaddr; | ||
| 14495 | const sa_family_t = if (is_windows) ws2_32.ADDRESS_FAMILY else posix.sa_family_t; | ||
| 14496 | const socklen_t = if (is_windows) ws2_32.socklen_t else posix.socklen_t; | ||
| 14497 | const AF = if (is_windows) ws2_32.AF else posix.AF; | ||
| 14498 | const SOCK = if (is_windows) ws2_32.SOCK else posix.SOCK; | ||
| 14499 | const IPPROTO = if (is_windows) ws2_32.IPPROTO else posix.IPPROTO; | ||
| 14500 | |||
| 14492 | pub const PosixAddress = extern union { | 14501 | pub const PosixAddress = extern union { |
| 14493 | any: posix.sockaddr, | 14502 | any: sockaddr, |
| 14494 | in: posix.sockaddr.in, | 14503 | in: sockaddr.in, |
| 14495 | in6: posix.sockaddr.in6, | 14504 | in6: sockaddr.in6, |
| 14496 | }; | 14505 | }; |
| 14497 | 14506 | ||
| 14498 | const UnixAddress = extern union { | 14507 | const UnixAddress = extern union { |
| 14499 | any: posix.sockaddr, | 14508 | any: sockaddr, |
| 14500 | un: posix.sockaddr.un, | 14509 | un: sockaddr.un, |
| 14501 | }; | 14510 | }; |
| 14502 | 14511 | ||
| 14503 | pub fn posixAddressFamily(a: *const IpAddress) posix.sa_family_t { | 14512 | pub fn posixAddressFamily(a: *const IpAddress) sa_family_t { |
| 14504 | return switch (a.*) { | 14513 | return switch (a.*) { |
| 14505 | .ip4 => posix.AF.INET, | 14514 | .ip4 => AF.INET, |
| 14506 | .ip6 => posix.AF.INET6, | 14515 | .ip6 => AF.INET6, |
| 14507 | }; | 14516 | }; |
| 14508 | } | 14517 | } |
| 14509 | 14518 | ||
| 14510 | pub fn addressFromPosix(posix_address: *const PosixAddress) IpAddress { | 14519 | pub fn addressFromPosix(posix_address: *const PosixAddress) IpAddress { |
| 14511 | return switch (posix_address.any.family) { | 14520 | return switch (posix_address.any.family) { |
| 14512 | posix.AF.INET => .{ .ip4 = address4FromPosix(&posix_address.in) }, | 14521 | AF.INET => .{ .ip4 = address4FromPosix(&posix_address.in) }, |
| 14513 | posix.AF.INET6 => .{ .ip6 = address6FromPosix(&posix_address.in6) }, | 14522 | AF.INET6 => .{ .ip6 = address6FromPosix(&posix_address.in6) }, |
| 14514 | else => .{ .ip4 = .loopback(0) }, | 14523 | else => .{ .ip4 = .loopback(0) }, |
| 14515 | }; | 14524 | }; |
| 14516 | } | 14525 | } |
| 14517 | 14526 | ||
| 14518 | pub fn addressToPosix(a: *const IpAddress, storage: *PosixAddress) posix.socklen_t { | 14527 | pub fn addressToPosix(a: *const IpAddress, storage: *PosixAddress) socklen_t { |
| 14519 | return switch (a.*) { | 14528 | return switch (a.*) { |
| 14520 | .ip4 => |ip4| { | 14529 | .ip4 => |ip4| { |
| 14521 | storage.in = address4ToPosix(ip4); | 14530 | storage.in = address4ToPosix(ip4); |
| 14522 | return @sizeOf(posix.sockaddr.in); | 14531 | return @sizeOf(sockaddr.in); |
| 14523 | }, | 14532 | }, |
| 14524 | .ip6 => |*ip6| { | 14533 | .ip6 => |*ip6| { |
| 14525 | storage.in6 = address6ToPosix(ip6); | 14534 | storage.in6 = address6ToPosix(ip6); |
| 14526 | return @sizeOf(posix.sockaddr.in6); | 14535 | return @sizeOf(sockaddr.in6); |
| 14527 | }, | 14536 | }, |
| 14528 | }; | 14537 | }; |
| 14529 | } | 14538 | } |
| 14530 | 14539 | ||
| 14531 | fn addressUnixToPosix(a: *const net.UnixAddress, storage: *UnixAddress) posix.socklen_t { | 14540 | fn addressUnixToPosix(a: *const net.UnixAddress, storage: *UnixAddress) socklen_t { |
| 14532 | storage.un.family = posix.AF.UNIX; | 14541 | storage.un.family = AF.UNIX; |
| 14533 | var path_len = switch (native_os) { | 14542 | var path_len = switch (native_os) { |
| 14534 | .windows => @min(a.path.len, storage.un.path.len), | 14543 | .windows => @min(a.path.len, storage.un.path.len), |
| 14535 | else => a.path.len, | 14544 | else => a.path.len, |
| ... | @@ -14545,13 +14554,13 @@ fn addressUnixToPosix(a: *const net.UnixAddress, storage: *UnixAddress) posix.so | ... | @@ -14545,13 +14554,13 @@ fn addressUnixToPosix(a: *const net.UnixAddress, storage: *UnixAddress) posix.so |
| 14545 | switch (native_os) { | 14554 | switch (native_os) { |
| 14546 | .windows => { | 14555 | .windows => { |
| 14547 | if (storage.un.path[0] == 0) @memset(storage.un.path[path_len..], 0); | 14556 | if (storage.un.path[0] == 0) @memset(storage.un.path[path_len..], 0); |
| 14548 | return @sizeOf(posix.sockaddr.un); | 14557 | return @sizeOf(sockaddr.un); |
| 14549 | }, | 14558 | }, |
| 14550 | else => return @intCast(@offsetOf(posix.sockaddr.un, "path") + path_len), | 14559 | else => return @intCast(@offsetOf(sockaddr.un, "path") + path_len), |
| 14551 | } | 14560 | } |
| 14552 | } | 14561 | } |
| 14553 | 14562 | ||
| 14554 | fn address4FromPosix(in: *const posix.sockaddr.in) net.Ip4Address { | 14563 | fn address4FromPosix(in: *const sockaddr.in) net.Ip4Address { |
| 14555 | // The network byte order address in `in.addr` is already the byte order we want. | 14564 | // The network byte order address in `in.addr` is already the byte order we want. |
| 14556 | const addr_bytes: *const [4]u8 = @ptrCast(&in.addr); | 14565 | const addr_bytes: *const [4]u8 = @ptrCast(&in.addr); |
| 14557 | return .{ | 14566 | return .{ |
| ... | @@ -14560,7 +14569,7 @@ fn address4FromPosix(in: *const posix.sockaddr.in) net.Ip4Address { | ... | @@ -14560,7 +14569,7 @@ fn address4FromPosix(in: *const posix.sockaddr.in) net.Ip4Address { |
| 14560 | }; | 14569 | }; |
| 14561 | } | 14570 | } |
| 14562 | 14571 | ||
| 14563 | fn address6FromPosix(in6: *const posix.sockaddr.in6) net.Ip6Address { | 14572 | fn address6FromPosix(in6: *const sockaddr.in6) net.Ip6Address { |
| 14564 | return .{ | 14573 | return .{ |
| 14565 | .port = std.mem.bigToNative(u16, in6.port), | 14574 | .port = std.mem.bigToNative(u16, in6.port), |
| 14566 | .bytes = in6.addr, | 14575 | .bytes = in6.addr, |
| ... | @@ -14569,7 +14578,7 @@ fn address6FromPosix(in6: *const posix.sockaddr.in6) net.Ip6Address { | ... | @@ -14569,7 +14578,7 @@ fn address6FromPosix(in6: *const posix.sockaddr.in6) net.Ip6Address { |
| 14569 | }; | 14578 | }; |
| 14570 | } | 14579 | } |
| 14571 | 14580 | ||
| 14572 | fn address4ToPosix(a: net.Ip4Address) posix.sockaddr.in { | 14581 | fn address4ToPosix(a: net.Ip4Address) sockaddr.in { |
| 14573 | // The byte order of `a.bytes` is already equivalent to a network byte order address. | 14582 | // The byte order of `a.bytes` is already equivalent to a network byte order address. |
| 14574 | const addr_raw: *align(1) const u32 = @ptrCast(&a.bytes); | 14583 | const addr_raw: *align(1) const u32 = @ptrCast(&a.bytes); |
| 14575 | return .{ | 14584 | return .{ |
| ... | @@ -14578,7 +14587,7 @@ fn address4ToPosix(a: net.Ip4Address) posix.sockaddr.in { | ... | @@ -14578,7 +14587,7 @@ fn address4ToPosix(a: net.Ip4Address) posix.sockaddr.in { |
| 14578 | }; | 14587 | }; |
| 14579 | } | 14588 | } |
| 14580 | 14589 | ||
| 14581 | fn address6ToPosix(a: *const net.Ip6Address) posix.sockaddr.in6 { | 14590 | fn address6ToPosix(a: *const net.Ip6Address) sockaddr.in6 { |
| 14582 | return .{ | 14591 | return .{ |
| 14583 | .port = std.mem.nativeToBig(u16, a.port), | 14592 | .port = std.mem.nativeToBig(u16, a.port), |
| 14584 | .flowinfo = a.flow, | 14593 | .flowinfo = a.flow, |
| ... | @@ -14592,21 +14601,21 @@ pub fn errnoBug(err: posix.E) Io.UnexpectedError { | ... | @@ -14592,21 +14601,21 @@ pub fn errnoBug(err: posix.E) Io.UnexpectedError { |
| 14592 | return error.Unexpected; | 14601 | return error.Unexpected; |
| 14593 | } | 14602 | } |
| 14594 | 14603 | ||
| 14595 | pub fn posixSocketModeProtocol(family: posix.sa_family_t, mode: net.Socket.Mode, protocol: ?net.Protocol) !struct { u32, u32 } { | 14604 | pub fn posixSocketModeProtocol(family: sa_family_t, mode: net.Socket.Mode, protocol: ?net.Protocol) !struct { u32, u32 } { |
| 14596 | return .{ | 14605 | return .{ |
| 14597 | switch (mode) { | 14606 | switch (mode) { |
| 14598 | .stream => posix.SOCK.STREAM, | 14607 | .stream => SOCK.STREAM, |
| 14599 | .dgram => posix.SOCK.DGRAM, | 14608 | .dgram => SOCK.DGRAM, |
| 14600 | .seqpacket => posix.SOCK.SEQPACKET, | 14609 | .seqpacket => SOCK.SEQPACKET, |
| 14601 | .raw => posix.SOCK.RAW, | 14610 | .raw => SOCK.RAW, |
| 14602 | .rdm => if (@hasDecl(posix.SOCK, "RDM")) posix.SOCK.RDM else return error.OptionUnsupported, | 14611 | .rdm => if (@hasDecl(SOCK, "RDM")) SOCK.RDM else return error.OptionUnsupported, |
| 14603 | }, | 14612 | }, |
| 14604 | if (protocol) |p| @backingInt(p) else if (is_windows) switch (family) { | 14613 | if (protocol) |p| @backingInt(p) else if (is_windows) switch (family) { |
| 14605 | posix.AF.UNIX => switch (mode) { | 14614 | AF.UNIX => switch (mode) { |
| 14606 | .stream => 0, | 14615 | .stream => 0, |
| 14607 | else => return error.ProtocolUnsupportedByAddressFamily, | 14616 | else => return error.ProtocolUnsupportedByAddressFamily, |
| 14608 | }, | 14617 | }, |
| 14609 | posix.AF.INET, posix.AF.INET6 => @backingInt(@as(net.Protocol, switch (mode) { | 14618 | AF.INET, AF.INET6 => @backingInt(@as(net.Protocol, switch (mode) { |
| 14610 | .stream => .tcp, | 14619 | .stream => .tcp, |
| 14611 | .dgram => .udp, | 14620 | .dgram => .udp, |
| 14612 | else => return error.ProtocolUnsupportedByAddressFamily, | 14621 | else => return error.ProtocolUnsupportedByAddressFamily, |
| ... | @@ -17992,7 +18001,7 @@ fn progressParentFile(userdata: ?*anyopaque) std.Progress.ParentFileError!File { | ... | @@ -17992,7 +18001,7 @@ fn progressParentFile(userdata: ?*anyopaque) std.Progress.ParentFileError!File { |
| 17992 | return t.environ.zig_progress_file; | 18001 | return t.environ.zig_progress_file; |
| 17993 | } | 18002 | } |
| 17994 | 18003 | ||
| 17995 | fn inheritParentHandle(handle: posix.fd_t) Io.InheritParentHandleError!void { | 18004 | fn inheritParentHandle(handle: File.Handle) Io.InheritParentHandleError!void { |
| 17996 | switch (native_os) { | 18005 | switch (native_os) { |
| 17997 | .linux, | 18006 | .linux, |
| 17998 | .dragonfly, | 18007 | .dragonfly, |
lib/std/Io/net.zig+8-3| ... | @@ -1016,7 +1016,12 @@ pub const Interface = struct { | ... | @@ -1016,7 +1016,12 @@ pub const Interface = struct { |
| 1016 | pub const Name = struct { | 1016 | pub const Name = struct { |
| 1017 | bytes: [max_len:0]u8, | 1017 | bytes: [max_len:0]u8, |
| 1018 | 1018 | ||
| 1019 | pub const max_len = if (@TypeOf(std.posix.IFNAMESIZE) == void) 0 else std.posix.IFNAMESIZE - 1; | 1019 | pub const max_len = if (native_os == .windows) |
| 1020 | std.os.windows.IF.MAX_STRING_SIZE | ||
| 1021 | else if (@TypeOf(std.posix.IFNAMESIZE) == void) | ||
| 1022 | 0 | ||
| 1023 | else | ||
| 1024 | std.posix.IFNAMESIZE - 1; | ||
| 1020 | 1025 | ||
| 1021 | pub fn toSlice(n: *const Name) []const u8 { | 1026 | pub fn toSlice(n: *const Name) []const u8 { |
| 1022 | return std.mem.sliceTo(&n.bytes, 0); | 1027 | return std.mem.sliceTo(&n.bytes, 0); |
| ... | @@ -1094,7 +1099,7 @@ pub const Socket = struct { | ... | @@ -1094,7 +1099,7 @@ pub const Socket = struct { |
| 1094 | 1099 | ||
| 1095 | /// Underlying platform-defined type which may or may not be | 1100 | /// Underlying platform-defined type which may or may not be |
| 1096 | /// interchangeable with a file system file descriptor. | 1101 | /// interchangeable with a file system file descriptor. |
| 1097 | pub const Handle = std.posix.fd_t; | 1102 | pub const Handle = if (native_os == .windows) std.os.windows.HANDLE else std.posix.fd_t; |
| 1098 | 1103 | ||
| 1099 | /// Leaves `address` in a valid state. | 1104 | /// Leaves `address` in a valid state. |
| 1100 | pub fn close(s: *const Socket, io: Io) void { | 1105 | pub fn close(s: *const Socket, io: Io) void { |
| ... | @@ -1517,7 +1522,7 @@ pub const Stream = struct { | ... | @@ -1517,7 +1522,7 @@ pub const Stream = struct { |
| 1517 | } | 1522 | } |
| 1518 | }; | 1523 | }; |
| 1519 | 1524 | ||
| 1520 | pub const cmsg_align = if (@TypeOf(std.posix.cmsg_align) == void) 1 else std.posix.cmsg_align; | 1525 | pub const cmsg_align = if (native_os == .windows or @TypeOf(std.posix.cmsg_align) == void) 1 else std.posix.cmsg_align; |
| 1521 | /// Utility Functions for interacting with POSIX socket control messages. | 1526 | /// Utility Functions for interacting with POSIX socket control messages. |
| 1522 | /// See also https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html | 1527 | /// See also https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html |
| 1523 | pub const cmsg = struct { | 1528 | pub const cmsg = struct { |
lib/std/c.zig+74-46| ... | @@ -12,7 +12,6 @@ const page_size = std.heap.page_size_min; | ... | @@ -12,7 +12,6 @@ const page_size = std.heap.page_size_min; |
| 12 | const linux = std.os.linux; | 12 | const linux = std.os.linux; |
| 13 | const emscripten = std.os.emscripten; | 13 | const emscripten = std.os.emscripten; |
| 14 | const windows = std.os.windows; | 14 | const windows = std.os.windows; |
| 15 | const ws2_32 = std.os.windows.ws2_32; | ||
| 16 | const darwin = @import("c/darwin.zig"); | 15 | const darwin = @import("c/darwin.zig"); |
| 17 | const freebsd = @import("c/freebsd.zig"); | 16 | const freebsd = @import("c/freebsd.zig"); |
| 18 | const illumos = @import("c/illumos.zig"); | 17 | const illumos = @import("c/illumos.zig"); |
| ... | @@ -79,7 +78,7 @@ pub fn errno(rc: anytype) E { | ... | @@ -79,7 +78,7 @@ pub fn errno(rc: anytype) E { |
| 79 | pub const ino_t = switch (native_os) { | 78 | pub const ino_t = switch (native_os) { |
| 80 | .linux => linux.ino_t, | 79 | .linux => linux.ino_t, |
| 81 | .emscripten => emscripten.ino_t, | 80 | .emscripten => emscripten.ino_t, |
| 82 | .windows => windows.LARGE_INTEGER, | 81 | .windows => c_ushort, |
| 83 | .haiku => i64, | 82 | .haiku => i64, |
| 84 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L38 | 83 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L38 |
| 85 | else => u64, | 84 | else => u64, |
| ... | @@ -138,9 +137,10 @@ pub const dev_t = switch (native_os) { | ... | @@ -138,9 +137,10 @@ pub const dev_t = switch (native_os) { |
| 138 | pub const mode_t = switch (native_os) { | 137 | pub const mode_t = switch (native_os) { |
| 139 | .linux => linux.mode_t, | 138 | .linux => linux.mode_t, |
| 140 | .emscripten => emscripten.mode_t, | 139 | .emscripten => emscripten.mode_t, |
| 141 | .openbsd, .haiku, .netbsd, .illumos, .windows => u32, | 140 | .openbsd, .haiku, .netbsd, .illumos => u32, |
| 142 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L44 | 141 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L44 |
| 143 | .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .dragonfly, .serenity => u16, | 142 | .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .dragonfly, .serenity => u16, |
| 143 | .windows => c_ushort, | ||
| 144 | else => u0, | 144 | else => u0, |
| 145 | }; | 145 | }; |
| 146 | 146 | ||
| ... | @@ -149,7 +149,7 @@ pub const nlink_t = switch (native_os) { | ... | @@ -149,7 +149,7 @@ pub const nlink_t = switch (native_os) { |
| 149 | .emscripten => emscripten.nlink_t, | 149 | .emscripten => emscripten.nlink_t, |
| 150 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L45 | 150 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L45 |
| 151 | .freebsd, .serenity => u64, | 151 | .freebsd, .serenity => u64, |
| 152 | .openbsd, .netbsd, .dragonfly, .illumos, .windows => u32, | 152 | .openbsd, .netbsd, .dragonfly, .illumos => u32, |
| 153 | .haiku => i32, | 153 | .haiku => i32, |
| 154 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u16, | 154 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u16, |
| 155 | else => u0, | 155 | else => u0, |
| ... | @@ -237,9 +237,7 @@ pub const blkcnt_t = switch (native_os) { | ... | @@ -237,9 +237,7 @@ pub const blkcnt_t = switch (native_os) { |
| 237 | 237 | ||
| 238 | pub const fd_t = switch (native_os) { | 238 | pub const fd_t = switch (native_os) { |
| 239 | .linux => linux.fd_t, | 239 | .linux => linux.fd_t, |
| 240 | .windows => windows.HANDLE, | 240 | else => c_int, |
| 241 | .serenity => c_int, | ||
| 242 | else => i32, | ||
| 243 | }; | 241 | }; |
| 244 | 242 | ||
| 245 | pub const ARCH = switch (native_os) { | 243 | pub const ARCH = switch (native_os) { |
| ... | @@ -445,7 +443,6 @@ pub const E = switch (native_os) { | ... | @@ -445,7 +443,6 @@ pub const E = switch (native_os) { |
| 445 | TIMEDOUT = 138, | 443 | TIMEDOUT = 138, |
| 446 | TXTBSY = 139, | 444 | TXTBSY = 139, |
| 447 | WOULDBLOCK = 140, | 445 | WOULDBLOCK = 140, |
| 448 | DQUOT = 10069, | ||
| 449 | _, | 446 | _, |
| 450 | }, | 447 | }, |
| 451 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.E, | 448 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.E, |
| ... | @@ -1827,7 +1824,6 @@ pub const PATH_MAX = switch (native_os) { | ... | @@ -1827,7 +1824,6 @@ pub const PATH_MAX = switch (native_os) { |
| 1827 | pub const POLL = switch (native_os) { | 1824 | pub const POLL = switch (native_os) { |
| 1828 | .linux => linux.POLL, | 1825 | .linux => linux.POLL, |
| 1829 | .emscripten => emscripten.POLL, | 1826 | .emscripten => emscripten.POLL, |
| 1830 | .windows => ws2_32.POLL, | ||
| 1831 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { | 1827 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 1832 | pub const IN = 0x001; | 1828 | pub const IN = 0x001; |
| 1833 | pub const PRI = 0x002; | 1829 | pub const PRI = 0x002; |
| ... | @@ -1965,7 +1961,7 @@ pub const PROT = switch (native_os) { | ... | @@ -1965,7 +1961,7 @@ pub const PROT = switch (native_os) { |
| 1965 | .linux => linux.PROT, | 1961 | .linux => linux.PROT, |
| 1966 | .emscripten => emscripten.PROT, | 1962 | .emscripten => emscripten.PROT, |
| 1967 | // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L28-L31 | 1963 | // https://github.com/SerenityOS/serenity/blob/6d59d4d3d9e76e39112842ec487840828f1c9bfe/Kernel/API/POSIX/sys/mman.h#L28-L31 |
| 1968 | .openbsd, .haiku, .dragonfly, .netbsd, .illumos, .freebsd, .windows, .serenity => packed struct(u32) { | 1964 | .openbsd, .haiku, .dragonfly, .netbsd, .illumos, .freebsd, .serenity => packed struct(u32) { |
| 1969 | READ: bool = false, | 1965 | READ: bool = false, |
| 1970 | WRITE: bool = false, | 1966 | WRITE: bool = false, |
| 1971 | EXEC: bool = false, | 1967 | EXEC: bool = false, |
| ... | @@ -3796,7 +3792,6 @@ pub const T = switch (native_os) { | ... | @@ -3796,7 +3792,6 @@ pub const T = switch (native_os) { |
| 3796 | else => void, | 3792 | else => void, |
| 3797 | }; | 3793 | }; |
| 3798 | pub const IOCPARM_MASK = switch (native_os) { | 3794 | pub const IOCPARM_MASK = switch (native_os) { |
| 3799 | .windows => ws2_32.IOCPARM_MASK, | ||
| 3800 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 0x1fff, | 3795 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 0x1fff, |
| 3801 | else => void, | 3796 | else => void, |
| 3802 | }; | 3797 | }; |
| ... | @@ -4448,7 +4443,6 @@ pub const nfds_t = switch (native_os) { | ... | @@ -4448,7 +4443,6 @@ pub const nfds_t = switch (native_os) { |
| 4448 | .linux => linux.nfds_t, | 4443 | .linux => linux.nfds_t, |
| 4449 | .emscripten => emscripten.nfds_t, | 4444 | .emscripten => emscripten.nfds_t, |
| 4450 | .haiku, .illumos => usize, | 4445 | .haiku, .illumos => usize, |
| 4451 | .windows => c_ulong, | ||
| 4452 | .openbsd, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u32, | 4446 | .openbsd, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u32, |
| 4453 | // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L32 | 4447 | // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L32 |
| 4454 | .serenity => c_uint, | 4448 | .serenity => c_uint, |
| ... | @@ -4461,15 +4455,13 @@ pub const perf_event_attr = switch (native_os) { | ... | @@ -4461,15 +4455,13 @@ pub const perf_event_attr = switch (native_os) { |
| 4461 | pub const pid_t = switch (native_os) { | 4455 | pub const pid_t = switch (native_os) { |
| 4462 | .linux => linux.pid_t, | 4456 | .linux => linux.pid_t, |
| 4463 | .emscripten => emscripten.pid_t, | 4457 | .emscripten => emscripten.pid_t, |
| 4464 | .windows => windows.HANDLE, | ||
| 4465 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L31-L32 | 4458 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L31-L32 |
| 4466 | .serenity => c_int, | 4459 | else => c_int, |
| 4467 | else => i32, | ||
| 4468 | }; | 4460 | }; |
| 4469 | pub const pollfd = switch (native_os) { | 4461 | pub const pollfd = switch (native_os) { |
| 4470 | .linux => linux.pollfd, | 4462 | .linux => linux.pollfd, |
| 4471 | .emscripten => emscripten.pollfd, | 4463 | .emscripten => emscripten.pollfd, |
| 4472 | .windows => ws2_32.pollfd, | 4464 | .windows => void, |
| 4473 | // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L26-L30 | 4465 | // https://github.com/SerenityOS/serenity/blob/265764ff2fec038855193296588a887fc322d76a/Kernel/API/POSIX/poll.h#L26-L30 |
| 4474 | .serenity => extern struct { | 4466 | .serenity => extern struct { |
| 4475 | fd: fd_t, | 4467 | fd: fd_t, |
| ... | @@ -4942,7 +4934,6 @@ pub const addrinfo = if (builtin.abi.isAndroid()) extern struct { | ... | @@ -4942,7 +4934,6 @@ pub const addrinfo = if (builtin.abi.isAndroid()) extern struct { |
| 4942 | next: ?*addrinfo, | 4934 | next: ?*addrinfo, |
| 4943 | } else switch (native_os) { | 4935 | } else switch (native_os) { |
| 4944 | .linux, .emscripten => linux.addrinfo, | 4936 | .linux, .emscripten => linux.addrinfo, |
| 4945 | .windows => ws2_32.addrinfo, | ||
| 4946 | .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { | 4937 | .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 4947 | flags: AI, | 4938 | flags: AI, |
| 4948 | family: i32, | 4939 | family: i32, |
| ... | @@ -5008,7 +4999,6 @@ pub const addrinfo = if (builtin.abi.isAndroid()) extern struct { | ... | @@ -5008,7 +4999,6 @@ pub const addrinfo = if (builtin.abi.isAndroid()) extern struct { |
| 5008 | }; | 4999 | }; |
| 5009 | pub const sockaddr = switch (native_os) { | 5000 | pub const sockaddr = switch (native_os) { |
| 5010 | .linux, .emscripten => linux.sockaddr, | 5001 | .linux, .emscripten => linux.sockaddr, |
| 5011 | .windows => ws2_32.sockaddr, | ||
| 5012 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { | 5002 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 5013 | len: u8, | 5003 | len: u8, |
| 5014 | family: sa_family_t, | 5004 | family: sa_family_t, |
| ... | @@ -5343,14 +5333,13 @@ pub const sockaddr = switch (native_os) { | ... | @@ -5343,14 +5333,13 @@ pub const sockaddr = switch (native_os) { |
| 5343 | }; | 5333 | }; |
| 5344 | pub const socklen_t = switch (native_os) { | 5334 | pub const socklen_t = switch (native_os) { |
| 5345 | .linux, .emscripten => linux.socklen_t, | 5335 | .linux, .emscripten => linux.socklen_t, |
| 5346 | .windows => ws2_32.socklen_t, | 5336 | .windows => void, |
| 5347 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L57 | 5337 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L57 |
| 5348 | else => u32, | 5338 | else => u32, |
| 5349 | }; | 5339 | }; |
| 5350 | pub const in_port_t = u16; | 5340 | pub const in_port_t = u16; |
| 5351 | pub const sa_family_t = switch (native_os) { | 5341 | pub const sa_family_t = switch (native_os) { |
| 5352 | .linux, .emscripten => linux.sa_family_t, | 5342 | .linux, .emscripten => linux.sa_family_t, |
| 5353 | .windows => ws2_32.ADDRESS_FAMILY, | ||
| 5354 | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u8, | 5343 | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => u8, |
| 5355 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L66 | 5344 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L66 |
| 5356 | .illumos, .serenity => u16, | 5345 | .illumos, .serenity => u16, |
| ... | @@ -5403,7 +5392,6 @@ pub const AF = if (builtin.abi.isAndroid()) struct { | ... | @@ -5403,7 +5392,6 @@ pub const AF = if (builtin.abi.isAndroid()) struct { |
| 5403 | pub const MAX = 43; | 5392 | pub const MAX = 43; |
| 5404 | } else switch (native_os) { | 5393 | } else switch (native_os) { |
| 5405 | .linux, .emscripten => linux.AF, | 5394 | .linux, .emscripten => linux.AF, |
| 5406 | .windows => ws2_32.AF, | ||
| 5407 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { | 5395 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 5408 | pub const UNSPEC = 0; | 5396 | pub const UNSPEC = 0; |
| 5409 | pub const LOCAL = 1; | 5397 | pub const LOCAL = 1; |
| ... | @@ -5952,7 +5940,6 @@ pub const DT = switch (native_os) { | ... | @@ -5952,7 +5940,6 @@ pub const DT = switch (native_os) { |
| 5952 | pub const MSG = switch (native_os) { | 5940 | pub const MSG = switch (native_os) { |
| 5953 | .linux => linux.MSG, | 5941 | .linux => linux.MSG, |
| 5954 | .emscripten => emscripten.MSG, | 5942 | .emscripten => emscripten.MSG, |
| 5955 | .windows => ws2_32.MSG, | ||
| 5956 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.MSG, | 5943 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.MSG, |
| 5957 | .haiku => struct { | 5944 | .haiku => struct { |
| 5958 | pub const OOB = 0x0001; | 5945 | pub const OOB = 0x0001; |
| ... | @@ -6069,7 +6056,6 @@ pub const MSG = switch (native_os) { | ... | @@ -6069,7 +6056,6 @@ pub const MSG = switch (native_os) { |
| 6069 | pub const SOCK = switch (native_os) { | 6056 | pub const SOCK = switch (native_os) { |
| 6070 | .linux => linux.SOCK, | 6057 | .linux => linux.SOCK, |
| 6071 | .emscripten => emscripten.SOCK, | 6058 | .emscripten => emscripten.SOCK, |
| 6072 | .windows => ws2_32.SOCK, | ||
| 6073 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { | 6059 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 6074 | pub const STREAM = 1; | 6060 | pub const STREAM = 1; |
| 6075 | pub const DGRAM = 2; | 6061 | pub const DGRAM = 2; |
| ... | @@ -6178,7 +6164,6 @@ pub const TCP = switch (native_os) { | ... | @@ -6178,7 +6164,6 @@ pub const TCP = switch (native_os) { |
| 6178 | .openbsd => openbsd.TCP, | 6164 | .openbsd => openbsd.TCP, |
| 6179 | .dragonfly => dragonfly.TCP, | 6165 | .dragonfly => dragonfly.TCP, |
| 6180 | .emscripten => emscripten.TCP, | 6166 | .emscripten => emscripten.TCP, |
| 6181 | .windows => ws2_32.TCP, | ||
| 6182 | .illumos => illumos.TCP, | 6167 | .illumos => illumos.TCP, |
| 6183 | .haiku => haiku.TCP, | 6168 | .haiku => haiku.TCP, |
| 6184 | // https://github.com/SerenityOS/serenity/blob/61ac554a3403838f79ca746bd1c65ded6f97d124/Kernel/API/POSIX/netinet/tcp.h#L13-L14 | 6169 | // https://github.com/SerenityOS/serenity/blob/61ac554a3403838f79ca746bd1c65ded6f97d124/Kernel/API/POSIX/netinet/tcp.h#L13-L14 |
| ... | @@ -6190,7 +6175,6 @@ pub const TCP = switch (native_os) { | ... | @@ -6190,7 +6175,6 @@ pub const TCP = switch (native_os) { |
| 6190 | }; | 6175 | }; |
| 6191 | pub const IPPROTO = switch (native_os) { | 6176 | pub const IPPROTO = switch (native_os) { |
| 6192 | .linux, .emscripten => linux.IPPROTO, | 6177 | .linux, .emscripten => linux.IPPROTO, |
| 6193 | .windows => ws2_32.IPPROTO, | ||
| 6194 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { | 6178 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 6195 | pub const ICMP = 1; | 6179 | pub const ICMP = 1; |
| 6196 | pub const ICMPV6 = 58; | 6180 | pub const ICMPV6 = 58; |
| ... | @@ -6826,7 +6810,6 @@ pub const IPTOS = switch (native_os) { | ... | @@ -6826,7 +6810,6 @@ pub const IPTOS = switch (native_os) { |
| 6826 | pub const SOL = switch (native_os) { | 6810 | pub const SOL = switch (native_os) { |
| 6827 | .linux => linux.SOL, | 6811 | .linux => linux.SOL, |
| 6828 | .emscripten => emscripten.SOL, | 6812 | .emscripten => emscripten.SOL, |
| 6829 | .windows => ws2_32.SOL, | ||
| 6830 | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { | 6813 | .openbsd, .haiku, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 6831 | pub const SOCKET = 0xffff; | 6814 | pub const SOCKET = 0xffff; |
| 6832 | }, | 6815 | }, |
| ... | @@ -6845,7 +6828,6 @@ pub const SOL = switch (native_os) { | ... | @@ -6845,7 +6828,6 @@ pub const SOL = switch (native_os) { |
| 6845 | pub const SO = switch (native_os) { | 6828 | pub const SO = switch (native_os) { |
| 6846 | .linux => linux.SO, | 6829 | .linux => linux.SO, |
| 6847 | .emscripten => emscripten.SO, | 6830 | .emscripten => emscripten.SO, |
| 6848 | .windows => ws2_32.SO, | ||
| 6849 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { | 6831 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 6850 | pub const DEBUG = 0x0001; | 6832 | pub const DEBUG = 0x0001; |
| 6851 | pub const ACCEPTCONN = 0x0002; | 6833 | pub const ACCEPTCONN = 0x0002; |
| ... | @@ -7084,7 +7066,6 @@ pub const SO = switch (native_os) { | ... | @@ -7084,7 +7066,6 @@ pub const SO = switch (native_os) { |
| 7084 | }; | 7066 | }; |
| 7085 | pub const SOMAXCONN = switch (native_os) { | 7067 | pub const SOMAXCONN = switch (native_os) { |
| 7086 | .linux => linux.SOMAXCONN, | 7068 | .linux => linux.SOMAXCONN, |
| 7087 | .windows => ws2_32.SOMAXCONN, | ||
| 7088 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L128 | 7069 | // https://github.com/SerenityOS/serenity/blob/ac44ec5ebc707f9dd0c3d4759a1e17e91db5d74f/Kernel/API/POSIX/sys/socket.h#L128 |
| 7089 | .illumos, .serenity => 128, | 7070 | .illumos, .serenity => 128, |
| 7090 | // https://github.com/freebsd/freebsd-src/blob/9ab31f821ad1c6bad474510447387c50bef2c24c/sys/sys/socket.h#L434 | 7071 | // https://github.com/freebsd/freebsd-src/blob/9ab31f821ad1c6bad474510447387c50bef2c24c/sys/sys/socket.h#L434 |
| ... | @@ -7153,7 +7134,6 @@ pub const SCM = switch (native_os) { | ... | @@ -7153,7 +7134,6 @@ pub const SCM = switch (native_os) { |
| 7153 | pub const IFNAMESIZE = switch (native_os) { | 7134 | pub const IFNAMESIZE = switch (native_os) { |
| 7154 | .linux => linux.IFNAMESIZE, | 7135 | .linux => linux.IFNAMESIZE, |
| 7155 | .emscripten => emscripten.IFNAMESIZE, | 7136 | .emscripten => emscripten.IFNAMESIZE, |
| 7156 | .windows => 30, | ||
| 7157 | // https://github.com/SerenityOS/serenity/blob/9882848e0bf783dfc8e8a6d887a848d70d9c58f4/Kernel/API/POSIX/net/if.h#L50 | 7137 | // https://github.com/SerenityOS/serenity/blob/9882848e0bf783dfc8e8a6d887a848d70d9c58f4/Kernel/API/POSIX/net/if.h#L50 |
| 7158 | .openbsd, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => 16, | 7138 | .openbsd, .dragonfly, .netbsd, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .serenity => 16, |
| 7159 | .illumos => 32, | 7139 | .illumos => 32, |
| ... | @@ -7532,7 +7512,6 @@ pub const AI = if (builtin.abi.isAndroid()) packed struct(u32) { | ... | @@ -7532,7 +7512,6 @@ pub const AI = if (builtin.abi.isAndroid()) packed struct(u32) { |
| 7532 | NUMERICSERV: bool = false, | 7512 | NUMERICSERV: bool = false, |
| 7533 | _: u19 = 0, | 7513 | _: u19 = 0, |
| 7534 | }, | 7514 | }, |
| 7535 | .windows => ws2_32.AI, | ||
| 7536 | // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L90-L96 | 7515 | // https://github.com/SerenityOS/serenity/blob/d510d2aeb2facbd8f6c383d70fd1b033e1fee5dd/Userland/Libraries/LibC/netdb.h#L90-L96 |
| 7537 | .serenity => packed struct(c_int) { | 7516 | .serenity => packed struct(c_int) { |
| 7538 | PASSIVE: bool = false, | 7517 | PASSIVE: bool = false, |
| ... | @@ -8379,10 +8358,6 @@ pub const port_event = switch (native_os) { | ... | @@ -8379,10 +8358,6 @@ pub const port_event = switch (native_os) { |
| 8379 | 8358 | ||
| 8380 | pub const AT = switch (native_os) { | 8359 | pub const AT = switch (native_os) { |
| 8381 | .linux => linux.AT, | 8360 | .linux => linux.AT, |
| 8382 | .windows => struct { | ||
| 8383 | /// Remove directory instead of unlinking file | ||
| 8384 | pub const REMOVEDIR = 0x200; | ||
| 8385 | }, | ||
| 8386 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { | 8361 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { |
| 8387 | pub const FDCWD = -2; | 8362 | pub const FDCWD = -2; |
| 8388 | /// Use effective ids in access check | 8363 | /// Use effective ids in access check |
| ... | @@ -10436,6 +10411,7 @@ pub extern "c" fn alarm(seconds: c_uint) c_uint; | ... | @@ -10436,6 +10411,7 @@ pub extern "c" fn alarm(seconds: c_uint) c_uint; |
| 10436 | 10411 | ||
| 10437 | pub const close = switch (native_os) { | 10412 | pub const close = switch (native_os) { |
| 10438 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.@"close$NOCANCEL", | 10413 | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => darwin.@"close$NOCANCEL", |
| 10414 | .windows => private._close, | ||
| 10439 | else => private.close, | 10415 | else => private.close, |
| 10440 | }; | 10416 | }; |
| 10441 | 10417 | ||
| ... | @@ -10922,19 +10898,31 @@ pub extern "c" fn abort() noreturn; | ... | @@ -10922,19 +10898,31 @@ pub extern "c" fn abort() noreturn; |
| 10922 | pub extern "c" fn exit(code: c_int) noreturn; | 10898 | pub extern "c" fn exit(code: c_int) noreturn; |
| 10923 | pub extern "c" fn _Exit(code: c_int) noreturn; | 10899 | pub extern "c" fn _Exit(code: c_int) noreturn; |
| 10924 | pub extern "c" fn _exit(code: c_int) noreturn; | 10900 | pub extern "c" fn _exit(code: c_int) noreturn; |
| 10925 | pub extern "c" fn isatty(fd: fd_t) c_int; | 10901 | pub const isatty = switch (native_os) { |
| 10926 | pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: whence_t) off_t; | 10902 | .windows => private._isatty, |
| 10903 | else => private.isatty, | ||
| 10904 | }; | ||
| 10905 | pub const lseek = switch (native_os) { | ||
| 10906 | .windows => private._lseeki64, | ||
| 10907 | else => private.lseek, | ||
| 10908 | }; | ||
| 10927 | pub extern "c" fn open(path: [*:0]const u8, oflag: O, ...) c_int; | 10909 | pub extern "c" fn open(path: [*:0]const u8, oflag: O, ...) c_int; |
| 10928 | pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: O, ...) c_int; | 10910 | pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: O, ...) c_int; |
| 10929 | pub extern "c" fn ftruncate(fd: c_int, length: off_t) c_int; | 10911 | pub extern "c" fn ftruncate(fd: c_int, length: off_t) c_int; |
| 10930 | pub extern "c" fn raise(sig: SIG) c_int; | 10912 | pub extern "c" fn raise(sig: SIG) c_int; |
| 10931 | pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize; | 10913 | pub const read = switch (native_os) { |
| 10914 | .windows => private._read, | ||
| 10915 | else => private.read, | ||
| 10916 | }; | ||
| 10932 | pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize; | 10917 | pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize; |
| 10933 | pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: off_t) isize; | 10918 | pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: off_t) isize; |
| 10934 | pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: off_t) isize; | 10919 | pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: off_t) isize; |
| 10935 | pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize; | 10920 | pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize; |
| 10936 | pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: off_t) isize; | 10921 | pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: off_t) isize; |
| 10937 | pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize; | 10922 | pub const write = switch (native_os) { |
| 10923 | .windows => private._write, | ||
| 10924 | else => private.write, | ||
| 10925 | }; | ||
| 10938 | pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: off_t) isize; | 10926 | pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: off_t) isize; |
| 10939 | pub extern "c" fn mmap(addr: ?*align(page_size) anyopaque, len: usize, prot: PROT, flags: MAP, fd: fd_t, offset: off_t) *anyopaque; | 10927 | pub extern "c" fn mmap(addr: ?*align(page_size) anyopaque, len: usize, prot: PROT, flags: MAP, fd: fd_t, offset: off_t) *anyopaque; |
| 10940 | pub extern "c" fn munmap(addr: *align(page_size) const anyopaque, len: usize) c_int; | 10928 | pub extern "c" fn munmap(addr: *align(page_size) const anyopaque, len: usize) c_int; |
| ... | @@ -10977,7 +10965,10 @@ pub const fork = switch (native_os) { | ... | @@ -10977,7 +10965,10 @@ pub const fork = switch (native_os) { |
| 10977 | pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int; | 10965 | pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int; |
| 10978 | pub extern "c" fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int; | 10966 | pub extern "c" fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int; |
| 10979 | pub extern "c" fn pipe(fds: *[2]fd_t) c_int; | 10967 | pub extern "c" fn pipe(fds: *[2]fd_t) c_int; |
| 10980 | pub extern "c" fn mkdir(path: [*:0]const u8, mode: mode_t) c_int; | 10968 | pub const mkdir = switch (native_os) { |
| 10969 | .windows => private._mkdir, | ||
| 10970 | else => private.mkdir, | ||
| 10971 | }; | ||
| 10981 | pub extern "c" fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: mode_t) c_int; | 10972 | pub extern "c" fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: mode_t) c_int; |
| 10982 | pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int; | 10973 | pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int; |
| 10983 | pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: fd_t, newpath: [*:0]const u8) c_int; | 10974 | pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: fd_t, newpath: [*:0]const u8) c_int; |
| ... | @@ -10991,17 +10982,29 @@ pub const fexecve = switch (native_os) { | ... | @@ -10991,17 +10982,29 @@ pub const fexecve = switch (native_os) { |
| 10991 | }; | 10982 | }; |
| 10992 | pub extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int; | 10983 | pub extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int; |
| 10993 | pub extern "c" fn execveat(dirfd: fd_t, path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8, flags: EXECVEAT) c_int; | 10984 | pub extern "c" fn execveat(dirfd: fd_t, path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8, flags: EXECVEAT) c_int; |
| 10994 | pub extern "c" fn dup(fd: fd_t) c_int; | 10985 | pub const dup = switch (native_os) { |
| 10995 | pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int; | 10986 | .windows => private._dup, |
| 10987 | else => private.dup, | ||
| 10988 | }; | ||
| 10989 | pub const dup2 = switch (native_os) { | ||
| 10990 | .windows => private._dup2, | ||
| 10991 | else => private.dup2, | ||
| 10992 | }; | ||
| 10996 | pub extern "c" fn dup3(old: c_int, new: c_int, flags: c_uint) c_int; | 10993 | pub extern "c" fn dup3(old: c_int, new: c_int, flags: c_uint) c_int; |
| 10997 | pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; | 10994 | pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; |
| 10998 | pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; | 10995 | pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize; |
| 10999 | pub extern "c" fn chmod(path: [*:0]const u8, mode: mode_t) c_int; | 10996 | pub const chmod = switch (native_os) { |
| 10997 | .windows => private._chmod, | ||
| 10998 | else => private.chmod, | ||
| 10999 | }; | ||
| 11000 | pub extern "c" fn fchmod(fd: fd_t, mode: mode_t) c_int; | 11000 | pub extern "c" fn fchmod(fd: fd_t, mode: mode_t) c_int; |
| 11001 | pub extern "c" fn fchmodat(fd: fd_t, path: [*:0]const u8, mode: mode_t, flags: c_uint) c_int; | 11001 | pub extern "c" fn fchmodat(fd: fd_t, path: [*:0]const u8, mode: mode_t, flags: c_uint) c_int; |
| 11002 | pub extern "c" fn fchown(fd: fd_t, owner: uid_t, group: gid_t) c_int; | 11002 | pub extern "c" fn fchown(fd: fd_t, owner: uid_t, group: gid_t) c_int; |
| 11003 | pub extern "c" fn fchownat(fd: fd_t, path: [*:0]const u8, owner: uid_t, group: gid_t, flags: c_uint) c_int; | 11003 | pub extern "c" fn fchownat(fd: fd_t, path: [*:0]const u8, owner: uid_t, group: gid_t, flags: c_uint) c_int; |
| 11004 | pub extern "c" fn umask(mode: mode_t) mode_t; | 11004 | pub const umask = switch (native_os) { |
| 11005 | .windows => private._umask, | ||
| 11006 | else => private.umask, | ||
| 11007 | }; | ||
| 11005 | 11008 | ||
| 11006 | pub extern "c" fn rmdir(path: [*:0]const u8) c_int; | 11009 | pub extern "c" fn rmdir(path: [*:0]const u8) c_int; |
| 11007 | pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8; | 11010 | pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8; |
| ... | @@ -11044,7 +11047,7 @@ pub extern "c" fn recv( | ... | @@ -11044,7 +11047,7 @@ pub extern "c" fn recv( |
| 11044 | arg1: ?*anyopaque, | 11047 | arg1: ?*anyopaque, |
| 11045 | arg2: usize, | 11048 | arg2: usize, |
| 11046 | arg3: c_int, | 11049 | arg3: c_int, |
| 11047 | ) if (native_os == .windows) c_int else isize; | 11050 | ) isize; |
| 11048 | pub extern "c" fn recvfrom( | 11051 | pub extern "c" fn recvfrom( |
| 11049 | sockfd: fd_t, | 11052 | sockfd: fd_t, |
| 11050 | noalias buf: *anyopaque, | 11053 | noalias buf: *anyopaque, |
| ... | @@ -11052,7 +11055,7 @@ pub extern "c" fn recvfrom( | ... | @@ -11052,7 +11055,7 @@ pub extern "c" fn recvfrom( |
| 11052 | flags: u32, | 11055 | flags: u32, |
| 11053 | noalias src_addr: ?*sockaddr, | 11056 | noalias src_addr: ?*sockaddr, |
| 11054 | noalias addrlen: ?*socklen_t, | 11057 | noalias addrlen: ?*socklen_t, |
| 11055 | ) if (native_os == .windows) c_int else isize; | 11058 | ) isize; |
| 11056 | 11059 | ||
| 11057 | pub const recvmsg = switch (native_os) { | 11060 | pub const recvmsg = switch (native_os) { |
| 11058 | .windows => {}, | 11061 | .windows => {}, |
| ... | @@ -11319,7 +11322,10 @@ pub extern "c" fn setlogmask(maskpri: c_int) c_int; | ... | @@ -11319,7 +11322,10 @@ pub extern "c" fn setlogmask(maskpri: c_int) c_int; |
| 11319 | 11322 | ||
| 11320 | pub extern "c" fn if_nametoindex([*:0]const u8) c_int; | 11323 | pub extern "c" fn if_nametoindex([*:0]const u8) c_int; |
| 11321 | 11324 | ||
| 11322 | pub extern "c" fn getpid() pid_t; | 11325 | pub const getpid = switch (native_os) { |
| 11326 | .windows => private._getpid, | ||
| 11327 | else => private.getpid, | ||
| 11328 | }; | ||
| 11323 | pub extern "c" fn getppid() pid_t; | 11329 | pub extern "c" fn getppid() pid_t; |
| 11324 | pub extern "c" fn setsid() pid_t; | 11330 | pub extern "c" fn setsid() pid_t; |
| 11325 | 11331 | ||
| ... | @@ -11882,11 +11888,14 @@ const private = struct { | ... | @@ -11882,11 +11888,14 @@ const private = struct { |
| 11882 | extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void; | 11888 | extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void; |
| 11883 | extern "c" fn _swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void; | 11889 | extern "c" fn _swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void; |
| 11884 | 11890 | ||
| 11891 | extern "c" fn chmod(path: [*:0]const u8, mode: mode_t) c_int; | ||
| 11885 | extern "c" fn clock_getres(clk_id: clockid_t, tp: *timespec) c_int; | 11892 | extern "c" fn clock_getres(clk_id: clockid_t, tp: *timespec) c_int; |
| 11886 | extern "c" fn clock_gettime(clk_id: clockid_t, tp: *timespec) c_int; | 11893 | extern "c" fn clock_gettime(clk_id: clockid_t, tp: *timespec) c_int; |
| 11887 | extern "c" fn clock_nanosleep(clockid: clockid_t, flags: TIMER, t: *const timespec, remain: ?*timespec) c_int; | 11894 | extern "c" fn clock_nanosleep(clockid: clockid_t, flags: TIMER, t: *const timespec, remain: ?*timespec) c_int; |
| 11888 | extern "c" fn close(fd: fd_t) c_int; | 11895 | extern "c" fn close(fd: fd_t) c_int; |
| 11889 | extern "c" fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: c_uint) isize; | 11896 | extern "c" fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: c_uint) isize; |
| 11897 | extern "c" fn dup(fd: fd_t) c_int; | ||
| 11898 | extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int; | ||
| 11890 | extern "c" fn fexecve(fd: fd_t, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int; | 11899 | extern "c" fn fexecve(fd: fd_t, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int; |
| 11891 | extern "c" fn flock(fd: fd_t, operation: c_int) c_int; | 11900 | extern "c" fn flock(fd: fd_t, operation: c_int) c_int; |
| 11892 | extern "c" fn fork() c_int; | 11901 | extern "c" fn fork() c_int; |
| ... | @@ -11898,13 +11907,18 @@ const private = struct { | ... | @@ -11898,13 +11907,18 @@ const private = struct { |
| 11898 | .freebsd => isize, | 11907 | .freebsd => isize, |
| 11899 | .illumos => usize, | 11908 | .illumos => usize, |
| 11900 | }; | 11909 | }; |
| 11910 | extern "c" fn getpid() pid_t; | ||
| 11901 | extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; | 11911 | extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; |
| 11902 | extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; | 11912 | extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; |
| 11903 | extern "c" fn ioctl(fd: fd_t, request: c_int, ...) c_int; | 11913 | extern "c" fn ioctl(fd: fd_t, request: c_int, ...) c_int; |
| 11914 | extern "c" fn isatty(fd: fd_t) c_int; | ||
| 11915 | extern "c" fn lseek(fd: fd_t, offset: off_t, whence: whence_t) off_t; | ||
| 11916 | extern "c" fn mkdir(path: [*:0]const u8, mode: mode_t) c_int; | ||
| 11904 | extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int; | 11917 | extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int; |
| 11905 | extern "c" fn mremap(addr: ?*align(page_size) const anyopaque, old_len: usize, new_len: usize, flags: MREMAP, ...) *anyopaque; | 11918 | extern "c" fn mremap(addr: ?*align(page_size) const anyopaque, old_len: usize, new_len: usize, flags: MREMAP, ...) *anyopaque; |
| 11906 | extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; | 11919 | extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; |
| 11907 | extern "c" fn pipe2(fds: *[2]fd_t, flags: O) c_int; | 11920 | extern "c" fn pipe2(fds: *[2]fd_t, flags: O) c_int; |
| 11921 | extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize; | ||
| 11908 | extern "c" fn readdir(dir: *DIR) ?*dirent; | 11922 | extern "c" fn readdir(dir: *DIR) ?*dirent; |
| 11909 | extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; | 11923 | extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; |
| 11910 | extern "c" fn recvmsg(sockfd: fd_t, msg: *msghdr, flags: u32) isize; | 11924 | extern "c" fn recvmsg(sockfd: fd_t, msg: *msghdr, flags: u32) isize; |
| ... | @@ -11932,7 +11946,21 @@ const private = struct { | ... | @@ -11932,7 +11946,21 @@ const private = struct { |
| 11932 | extern "c" fn sigaltstack(ss: ?*const stack_t, old_ss: ?*stack_t) c_int; | 11946 | extern "c" fn sigaltstack(ss: ?*const stack_t, old_ss: ?*stack_t) c_int; |
| 11933 | extern "c" fn sysconf(sc: c_int) c_long; | 11947 | extern "c" fn sysconf(sc: c_int) c_long; |
| 11934 | extern "c" fn shm_open(name: [*:0]const u8, flag: c_int, mode: mode_t) c_int; | 11948 | extern "c" fn shm_open(name: [*:0]const u8, flag: c_int, mode: mode_t) c_int; |
| 11949 | extern "c" fn umask(mode: mode_t) mode_t; | ||
| 11935 | extern "c" fn wait4(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t; | 11950 | extern "c" fn wait4(pid: pid_t, status: ?*c_int, options: c_int, ru: ?*rusage) pid_t; |
| 11951 | extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize; | ||
| 11952 | |||
| 11953 | extern "c" fn _chmod(filename: [*:0]const u8, pmode: c_int) c_int; | ||
| 11954 | extern "c" fn _close(fd: fd_t) c_int; | ||
| 11955 | extern "c" fn _dup(fd: fd_t) c_int; | ||
| 11956 | extern "c" fn _dup2(old_fd: fd_t, new_fd: fd_t) c_int; | ||
| 11957 | extern "c" fn _getpid() pid_t; | ||
| 11958 | extern "c" fn _isatty(fd: fd_t) c_int; | ||
| 11959 | extern "c" fn _lseeki64(fd: fd_t, offset: off_t, whence: whence_t) off_t; | ||
| 11960 | extern "c" fn _mkdir(dirname: [*:0]const u8) c_int; | ||
| 11961 | extern "c" fn _read(fd: fd_t, buf: [*]u8, nbyte: c_uint) c_int; | ||
| 11962 | extern "c" fn _umask(pmode: c_int) c_int; | ||
| 11963 | extern "c" fn _write(fd: fd_t, buf: [*]const u8, nbyte: c_uint) c_int; | ||
| 11936 | 11964 | ||
| 11937 | extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8) c_int; | 11965 | extern "c" fn pthread_setname_np(thread: pthread_t, name: [*:0]const u8) c_int; |
| 11938 | 11966 |
lib/std/crypto/Certificate/Bundle.zig+1-1| ... | @@ -144,7 +144,7 @@ fn rescanWithPath(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp, cert_f | ... | @@ -144,7 +144,7 @@ fn rescanWithPath(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp, cert_f |
| 144 | cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); | 144 | cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | const RescanWindowsError = Allocator.Error || ParseCertError || std.posix.UnexpectedError || error{FileNotFound}; | 147 | const RescanWindowsError = Allocator.Error || ParseCertError || std.Io.UnexpectedError || error{FileNotFound}; |
| 148 | 148 | ||
| 149 | fn rescanWindows(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp) RescanWindowsError!void { | 149 | fn rescanWindows(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp) RescanWindowsError!void { |
| 150 | cb.bytes.clearRetainingCapacity(); | 150 | cb.bytes.clearRetainingCapacity(); |
lib/std/os/windows.zig+5-1| ... | @@ -13,7 +13,7 @@ const mem = std.mem; | ... | @@ -13,7 +13,7 @@ const mem = std.mem; |
| 13 | const assert = std.debug.assert; | 13 | const assert = std.debug.assert; |
| 14 | const math = std.math; | 14 | const math = std.math; |
| 15 | const maxInt = std.math.maxInt; | 15 | const maxInt = std.math.maxInt; |
| 16 | const UnexpectedError = std.posix.UnexpectedError; | 16 | const UnexpectedError = std.Io.UnexpectedError; |
| 17 | 17 | ||
| 18 | pub const kernel32 = @import("windows/kernel32.zig"); | 18 | pub const kernel32 = @import("windows/kernel32.zig"); |
| 19 | pub const ntdll = @import("windows/ntdll.zig"); | 19 | pub const ntdll = @import("windows/ntdll.zig"); |
| ... | @@ -1492,6 +1492,10 @@ pub const TDI = struct { | ... | @@ -1492,6 +1492,10 @@ pub const TDI = struct { |
| 1492 | }; | 1492 | }; |
| 1493 | }; | 1493 | }; |
| 1494 | 1494 | ||
| 1495 | pub const IF = struct { | ||
| 1496 | pub const MAX_STRING_SIZE = 256; | ||
| 1497 | }; | ||
| 1498 | |||
| 1495 | pub const NET = struct { | 1499 | pub const NET = struct { |
| 1496 | pub const LUID = packed struct(ULONG64) { Reserved: u24 = 0, Index: u24, IfType: u16 }; | 1500 | pub const LUID = packed struct(ULONG64) { Reserved: u24 = 0, Index: u24, IfType: u16 }; |
| 1497 | pub const IFINDEX = enum(ULONG) { _ }; | 1501 | pub const IFINDEX = enum(ULONG) { _ }; |
lib/std/posix.zig+33-57| ... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
| 5 | //! `std.process`. | 5 | //! `std.process`. |
| 6 | //! | 6 | //! |
| 7 | //! These APIs are generally lowered to libc function calls if and only if libc | 7 | //! These APIs are generally lowered to libc function calls if and only if libc |
| 8 | //! is linked. Most operating systems other than Windows, Linux, and WASI | 8 | //! is linked. Most operating systems other than Linux and WASI |
| 9 | //! require always linking libc because they use it as the stable syscall ABI. | 9 | //! require always linking libc because they use it as the stable syscall ABI. |
| 10 | const builtin = @import("builtin"); | 10 | const builtin = @import("builtin"); |
| 11 | const native_os = builtin.os.tag; | 11 | const native_os = builtin.os.tag; |
| ... | @@ -19,21 +19,19 @@ const assert = std.debug.assert; | ... | @@ -19,21 +19,19 @@ const assert = std.debug.assert; |
| 19 | const page_size_min = std.heap.page_size_min; | 19 | const page_size_min = std.heap.page_size_min; |
| 20 | 20 | ||
| 21 | test { | 21 | test { |
| 22 | _ = @import("posix/test.zig"); | 22 | if (native_os != .windows) _ = @import("posix/test.zig"); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | /// Whether to use libc for the POSIX API layer. | 25 | /// Whether to use libc for the POSIX API layer. |
| 26 | const use_libc = builtin.link_libc or switch (native_os) { | 26 | const use_libc = builtin.link_libc; |
| 27 | .windows => true, | ||
| 28 | else => false, | ||
| 29 | }; | ||
| 30 | 27 | ||
| 31 | const linux = std.os.linux; | 28 | const linux = std.os.linux; |
| 32 | const windows = std.os.windows; | ||
| 33 | const wasi = std.os.wasi; | 29 | const wasi = std.os.wasi; |
| 34 | 30 | ||
| 35 | /// A libc-compatible API layer. | 31 | /// A libc-compatible API layer. |
| 36 | pub const system = if (use_libc) | 32 | pub const system = if (native_os == .windows) |
| 33 | @compileError("Windows does not support POSIX") | ||
| 34 | else if (use_libc) | ||
| 37 | std.c | 35 | std.c |
| 38 | else switch (native_os) { | 36 | else switch (native_os) { |
| 39 | .linux => linux, | 37 | .linux => linux, |
| ... | @@ -134,14 +132,11 @@ pub const STDIN_FILENO = system.STDIN_FILENO; | ... | @@ -134,14 +132,11 @@ pub const STDIN_FILENO = system.STDIN_FILENO; |
| 134 | pub const STDOUT_FILENO = system.STDOUT_FILENO; | 132 | pub const STDOUT_FILENO = system.STDOUT_FILENO; |
| 135 | pub const SYS = system.SYS; | 133 | pub const SYS = system.SYS; |
| 136 | pub const Sigaction = system.Sigaction; | 134 | pub const Sigaction = system.Sigaction; |
| 137 | /// Windows has no concept of `stat`. | ||
| 138 | /// | ||
| 139 | /// On Linux, the `stat` bits/wrappers are removed due to having to maintain | 135 | /// On Linux, the `stat` bits/wrappers are removed due to having to maintain |
| 140 | /// the different varying stat structs per target and libc, leading to runtime | 136 | /// the different varying stat structs per target and libc, leading to runtime |
| 141 | /// errors. Users targeting Linux should add a comptime check and use statx, | 137 | /// errors. Users targeting Linux should add a comptime check and use statx, |
| 142 | /// similar to how `Io.File.stat` does. | 138 | /// similar to how `Io.File.stat` does. |
| 143 | pub const Stat = switch (native_os) { | 139 | pub const Stat = switch (native_os) { |
| 144 | .windows => void, | ||
| 145 | .linux => void, | 140 | .linux => void, |
| 146 | else => system.Stat, | 141 | else => system.Stat, |
| 147 | }; | 142 | }; |
| ... | @@ -406,7 +401,6 @@ pub const ReadError = std.Io.File.Reader.Error; | ... | @@ -406,7 +401,6 @@ pub const ReadError = std.Io.File.Reader.Error; |
| 406 | /// The corresponding POSIX limit is `maxInt(isize)`. | 401 | /// The corresponding POSIX limit is `maxInt(isize)`. |
| 407 | pub fn read(fd: fd_t, buf: []u8) ReadError!usize { | 402 | pub fn read(fd: fd_t, buf: []u8) ReadError!usize { |
| 408 | if (buf.len == 0) return 0; | 403 | if (buf.len == 0) return 0; |
| 409 | if (native_os == .windows) @compileError("unsupported OS"); | ||
| 410 | if (native_os == .wasi) @compileError("unsupported OS"); | 404 | if (native_os == .wasi) @compileError("unsupported OS"); |
| 411 | 405 | ||
| 412 | // Prevents EINVAL. | 406 | // Prevents EINVAL. |
| ... | @@ -441,14 +435,11 @@ pub const OpenError = std.Io.File.OpenError || error{WouldBlock}; | ... | @@ -441,14 +435,11 @@ pub const OpenError = std.Io.File.OpenError || error{WouldBlock}; |
| 441 | 435 | ||
| 442 | /// Open and possibly create a file. Keeps trying if it gets interrupted. | 436 | /// Open and possibly create a file. Keeps trying if it gets interrupted. |
| 443 | /// `file_path` is relative to the open directory handle `dir_fd`. | 437 | /// `file_path` is relative to the open directory handle `dir_fd`. |
| 444 | /// On Windows, `file_path` should be encoded as [WTF-8](https://wtf-8.codeberg.page/). | ||
| 445 | /// On WASI, `file_path` should be encoded as valid UTF-8. | 438 | /// On WASI, `file_path` should be encoded as valid UTF-8. |
| 446 | /// On other platforms, `file_path` is an opaque sequence of bytes with no particular encoding. | 439 | /// On other platforms, `file_path` is an opaque sequence of bytes with no particular encoding. |
| 447 | /// See also `openatZ`. | 440 | /// See also `openatZ`. |
| 448 | pub fn openat(dir_fd: fd_t, file_path: []const u8, flags: O, mode: mode_t) OpenError!fd_t { | 441 | pub fn openat(dir_fd: fd_t, file_path: []const u8, flags: O, mode: mode_t) OpenError!fd_t { |
| 449 | if (native_os == .windows) { | 442 | if (native_os == .wasi) { |
| 450 | @compileError("Windows does not support POSIX; use Windows-specific API or cross-platform std.fs API"); | ||
| 451 | } else if (native_os == .wasi) { | ||
| 452 | @compileError("use std.Io instead"); | 443 | @compileError("use std.Io instead"); |
| 453 | } | 444 | } |
| 454 | const file_path_c = try toPosixPath(file_path); | 445 | const file_path_c = try toPosixPath(file_path); |
| ... | @@ -457,14 +448,11 @@ pub fn openat(dir_fd: fd_t, file_path: []const u8, flags: O, mode: mode_t) OpenE | ... | @@ -457,14 +448,11 @@ pub fn openat(dir_fd: fd_t, file_path: []const u8, flags: O, mode: mode_t) OpenE |
| 457 | 448 | ||
| 458 | /// Open and possibly create a file. Keeps trying if it gets interrupted. | 449 | /// Open and possibly create a file. Keeps trying if it gets interrupted. |
| 459 | /// `file_path` is relative to the open directory handle `dir_fd`. | 450 | /// `file_path` is relative to the open directory handle `dir_fd`. |
| 460 | /// On Windows, `file_path` should be encoded as [WTF-8](https://wtf-8.codeberg.page/). | ||
| 461 | /// On WASI, `file_path` should be encoded as valid UTF-8. | 451 | /// On WASI, `file_path` should be encoded as valid UTF-8. |
| 462 | /// On other platforms, `file_path` is an opaque sequence of bytes with no particular encoding. | 452 | /// On other platforms, `file_path` is an opaque sequence of bytes with no particular encoding. |
| 463 | /// See also `openat`. | 453 | /// See also `openat`. |
| 464 | pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: O, mode: mode_t) OpenError!fd_t { | 454 | pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: O, mode: mode_t) OpenError!fd_t { |
| 465 | if (native_os == .windows) { | 455 | if (native_os == .wasi) { |
| 466 | @compileError("Windows does not support POSIX; use Windows-specific API or cross-platform std.fs API"); | ||
| 467 | } else if (native_os == .wasi) { | ||
| 468 | return openat(dir_fd, mem.sliceTo(file_path, 0), flags, mode); | 456 | return openat(dir_fd, mem.sliceTo(file_path, 0), flags, mode); |
| 469 | } | 457 | } |
| 470 | 458 | ||
| ... | @@ -526,21 +514,17 @@ pub const GetSockNameError = error{ | ... | @@ -526,21 +514,17 @@ pub const GetSockNameError = error{ |
| 526 | } || UnexpectedError; | 514 | } || UnexpectedError; |
| 527 | 515 | ||
| 528 | pub fn getpeername(sock: socket_t, addr: *sockaddr, addrlen: *socklen_t) GetSockNameError!void { | 516 | pub fn getpeername(sock: socket_t, addr: *sockaddr, addrlen: *socklen_t) GetSockNameError!void { |
| 529 | if (native_os == .windows) { | 517 | const rc = system.getpeername(sock, addr, addrlen); |
| 530 | @compileError("use std.Io instead"); | 518 | switch (errno(rc)) { |
| 531 | } else { | 519 | .SUCCESS => return, |
| 532 | const rc = system.getpeername(sock, addr, addrlen); | 520 | else => |err| return unexpectedErrno(err), |
| 533 | switch (errno(rc)) { | ||
| 534 | .SUCCESS => return, | ||
| 535 | else => |err| return unexpectedErrno(err), | ||
| 536 | 521 | ||
| 537 | .BADF => unreachable, // always a race condition | 522 | .BADF => unreachable, // always a race condition |
| 538 | .FAULT => unreachable, | 523 | .FAULT => unreachable, |
| 539 | .INVAL => unreachable, // invalid parameters | 524 | .INVAL => unreachable, // invalid parameters |
| 540 | .NOTSOCK => return error.FileDescriptorNotASocket, | 525 | .NOTSOCK => return error.FileDescriptorNotASocket, |
| 541 | .NOBUFS => return error.SystemResources, | 526 | .NOBUFS => return error.SystemResources, |
| 542 | .NOTCONN => return error.SocketUnconnected, | 527 | .NOTCONN => return error.SocketUnconnected, |
| 543 | } | ||
| 544 | } | 528 | } |
| 545 | } | 529 | } |
| 546 | 530 | ||
| ... | @@ -1008,9 +992,6 @@ pub const PollError = error{ | ... | @@ -1008,9 +992,6 @@ pub const PollError = error{ |
| 1008 | } || UnexpectedError; | 992 | } || UnexpectedError; |
| 1009 | 993 | ||
| 1010 | pub fn poll(fds: []pollfd, timeout: i32) PollError!usize { | 994 | pub fn poll(fds: []pollfd, timeout: i32) PollError!usize { |
| 1011 | if (native_os == .windows) { | ||
| 1012 | @compileError("use std.Io instead"); | ||
| 1013 | } | ||
| 1014 | while (true) { | 995 | while (true) { |
| 1015 | const fds_count = cast(nfds_t, fds.len) orelse return error.SystemResources; | 996 | const fds_count = cast(nfds_t, fds.len) orelse return error.SystemResources; |
| 1016 | const rc = system.poll(fds.ptr, fds_count, timeout); | 997 | const rc = system.poll(fds.ptr, fds_count, timeout); |
| ... | @@ -1078,25 +1059,21 @@ pub const SetSockOptError = error{ | ... | @@ -1078,25 +1059,21 @@ pub const SetSockOptError = error{ |
| 1078 | 1059 | ||
| 1079 | /// Set a socket's options. | 1060 | /// Set a socket's options. |
| 1080 | pub fn setsockopt(fd: socket_t, level: i32, optname: u32, opt: []const u8) SetSockOptError!void { | 1061 | pub fn setsockopt(fd: socket_t, level: i32, optname: u32, opt: []const u8) SetSockOptError!void { |
| 1081 | if (native_os == .windows) { | 1062 | switch (errno(system.setsockopt(fd, level, optname, opt.ptr, @intCast(opt.len)))) { |
| 1082 | @compileError("use std.Io instead"); | 1063 | .SUCCESS => {}, |
| 1083 | } else { | 1064 | .BADF => unreachable, // always a race condition |
| 1084 | switch (errno(system.setsockopt(fd, level, optname, opt.ptr, @intCast(opt.len)))) { | 1065 | .NOTSOCK => unreachable, // always a race condition |
| 1085 | .SUCCESS => {}, | 1066 | .INVAL => unreachable, |
| 1086 | .BADF => unreachable, // always a race condition | 1067 | .FAULT => unreachable, |
| 1087 | .NOTSOCK => unreachable, // always a race condition | 1068 | .DOM => return error.TimeoutTooBig, |
| 1088 | .INVAL => unreachable, | 1069 | .ISCONN => return error.AlreadyConnected, |
| 1089 | .FAULT => unreachable, | 1070 | .NOPROTOOPT => return error.InvalidProtocolOption, |
| 1090 | .DOM => return error.TimeoutTooBig, | 1071 | .NOMEM => return error.SystemResources, |
| 1091 | .ISCONN => return error.AlreadyConnected, | 1072 | .NOBUFS => return error.SystemResources, |
| 1092 | .NOPROTOOPT => return error.InvalidProtocolOption, | 1073 | .PERM => return error.PermissionDenied, |
| 1093 | .NOMEM => return error.SystemResources, | 1074 | .NODEV => return error.NoDevice, |
| 1094 | .NOBUFS => return error.SystemResources, | 1075 | .OPNOTSUPP => return error.OperationUnsupported, |
| 1095 | .PERM => return error.PermissionDenied, | 1076 | else => |err| return unexpectedErrno(err), |
| 1096 | .NODEV => return error.NoDevice, | ||
| 1097 | .OPNOTSUPP => return error.OperationUnsupported, | ||
| 1098 | else => |err| return unexpectedErrno(err), | ||
| 1099 | } | ||
| 1100 | } | 1077 | } |
| 1101 | } | 1078 | } |
| 1102 | 1079 | ||
| ... | @@ -1527,7 +1504,6 @@ pub const PtraceError = error{ | ... | @@ -1527,7 +1504,6 @@ pub const PtraceError = error{ |
| 1527 | 1504 | ||
| 1528 | pub fn ptrace(request: u32, pid: pid_t, addr: usize, data: usize) PtraceError!void { | 1505 | pub fn ptrace(request: u32, pid: pid_t, addr: usize, data: usize) PtraceError!void { |
| 1529 | return switch (native_os) { | 1506 | return switch (native_os) { |
| 1530 | .windows, | ||
| 1531 | .wasi, | 1507 | .wasi, |
| 1532 | .emscripten, | 1508 | .emscripten, |
| 1533 | .haiku, | 1509 | .haiku, |
lib/std/posix/test.zig+11-14| ... | @@ -36,19 +36,19 @@ test "check WASI CWD" { | ... | @@ -36,19 +36,19 @@ test "check WASI CWD" { |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | test "getuid" { | 38 | test "getuid" { |
| 39 | if (native_os == .windows or native_os == .wasi) return error.SkipZigTest; | 39 | if (native_os == .wasi) return error.SkipZigTest; |
| 40 | _ = posix.system.getuid(); | 40 | _ = posix.system.getuid(); |
| 41 | _ = posix.system.geteuid(); | 41 | _ = posix.system.geteuid(); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | test "getgid" { | 44 | test "getgid" { |
| 45 | if (native_os == .windows or native_os == .wasi) return error.SkipZigTest; | 45 | if (native_os == .wasi) return error.SkipZigTest; |
| 46 | _ = posix.system.getgid(); | 46 | _ = posix.system.getgid(); |
| 47 | _ = posix.system.getegid(); | 47 | _ = posix.system.getegid(); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | test "sigaltstack" { | 50 | test "sigaltstack" { |
| 51 | if (native_os == .windows or native_os == .wasi) return error.SkipZigTest; | 51 | if (native_os == .wasi) return error.SkipZigTest; |
| 52 | 52 | ||
| 53 | var st: posix.stack_t = undefined; | 53 | var st: posix.stack_t = undefined; |
| 54 | try posix.sigaltstack(null, &st); | 54 | try posix.sigaltstack(null, &st); |
| ... | @@ -102,7 +102,7 @@ test "dl_iterate_phdr" { | ... | @@ -102,7 +102,7 @@ test "dl_iterate_phdr" { |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | test "gethostname" { | 104 | test "gethostname" { |
| 105 | if (native_os == .windows or native_os == .wasi) | 105 | if (native_os == .wasi) |
| 106 | return error.SkipZigTest; | 106 | return error.SkipZigTest; |
| 107 | 107 | ||
| 108 | var buf: [posix.HOST_NAME_MAX]u8 = undefined; | 108 | var buf: [posix.HOST_NAME_MAX]u8 = undefined; |
| ... | @@ -111,7 +111,7 @@ test "gethostname" { | ... | @@ -111,7 +111,7 @@ test "gethostname" { |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | test "pipe" { | 113 | test "pipe" { |
| 114 | if (native_os == .windows or native_os == .wasi) | 114 | if (native_os == .wasi) |
| 115 | return error.SkipZigTest; | 115 | return error.SkipZigTest; |
| 116 | 116 | ||
| 117 | const io = testing.io; | 117 | const io = testing.io; |
| ... | @@ -155,7 +155,7 @@ test "memfd_create" { | ... | @@ -155,7 +155,7 @@ test "memfd_create" { |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | test "mmap" { | 157 | test "mmap" { |
| 158 | if (native_os == .windows or native_os == .wasi) | 158 | if (native_os == .wasi) |
| 159 | return error.SkipZigTest; | 159 | return error.SkipZigTest; |
| 160 | 160 | ||
| 161 | const io = testing.io; | 161 | const io = testing.io; |
| ... | @@ -252,7 +252,7 @@ test "mmap" { | ... | @@ -252,7 +252,7 @@ test "mmap" { |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | test "fcntl" { | 254 | test "fcntl" { |
| 255 | if (native_os == .windows or native_os == .wasi) | 255 | if (native_os == .wasi) |
| 256 | return error.SkipZigTest; | 256 | return error.SkipZigTest; |
| 257 | 257 | ||
| 258 | const io = testing.io; | 258 | const io = testing.io; |
| ... | @@ -351,7 +351,7 @@ test "getrlimit and setrlimit" { | ... | @@ -351,7 +351,7 @@ test "getrlimit and setrlimit" { |
| 351 | 351 | ||
| 352 | test "sigrtmin/max" { | 352 | test "sigrtmin/max" { |
| 353 | if (native_os.isDarwin() or switch (native_os) { | 353 | if (native_os.isDarwin() or switch (native_os) { |
| 354 | .wasi, .windows, .openbsd, .dragonfly => true, | 354 | .wasi, .openbsd, .dragonfly => true, |
| 355 | else => false, | 355 | else => false, |
| 356 | }) return error.SkipZigTest; | 356 | }) return error.SkipZigTest; |
| 357 | 357 | ||
| ... | @@ -361,7 +361,7 @@ test "sigrtmin/max" { | ... | @@ -361,7 +361,7 @@ test "sigrtmin/max" { |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | test "sigset empty/full" { | 363 | test "sigset empty/full" { |
| 364 | if (native_os == .wasi or native_os == .windows) | 364 | if (native_os == .wasi) |
| 365 | return error.SkipZigTest; | 365 | return error.SkipZigTest; |
| 366 | 366 | ||
| 367 | var set: posix.sigset_t = posix.sigemptyset(); | 367 | var set: posix.sigset_t = posix.sigemptyset(); |
| ... | @@ -389,7 +389,7 @@ fn reserved_signo(i: usize) bool { | ... | @@ -389,7 +389,7 @@ fn reserved_signo(i: usize) bool { |
| 389 | } | 389 | } |
| 390 | 390 | ||
| 391 | test "sigset add/del" { | 391 | test "sigset add/del" { |
| 392 | if (native_os == .wasi or native_os == .windows) | 392 | if (native_os == .wasi) |
| 393 | return error.SkipZigTest; | 393 | return error.SkipZigTest; |
| 394 | 394 | ||
| 395 | var sigset: posix.sigset_t = posix.sigemptyset(); | 395 | var sigset: posix.sigset_t = posix.sigemptyset(); |
| ... | @@ -426,21 +426,18 @@ test "sigset add/del" { | ... | @@ -426,21 +426,18 @@ test "sigset add/del" { |
| 426 | 426 | ||
| 427 | test "getpid" { | 427 | test "getpid" { |
| 428 | if (native_os == .wasi) return error.SkipZigTest; | 428 | if (native_os == .wasi) return error.SkipZigTest; |
| 429 | if (native_os == .windows) return error.SkipZigTest; | ||
| 430 | 429 | ||
| 431 | try expect(posix.system.getpid() != 0); | 430 | try expect(posix.system.getpid() != 0); |
| 432 | } | 431 | } |
| 433 | 432 | ||
| 434 | test "getppid" { | 433 | test "getppid" { |
| 435 | if (native_os == .wasi) return error.SkipZigTest; | 434 | if (native_os == .wasi) return error.SkipZigTest; |
| 436 | if (native_os == .windows) return error.SkipZigTest; | ||
| 437 | if (native_os == .plan9 and !builtin.link_libc) return error.SkipZigTest; | 435 | if (native_os == .plan9 and !builtin.link_libc) return error.SkipZigTest; |
| 438 | 436 | ||
| 439 | try expect(posix.getppid() >= 0); | 437 | try expect(posix.getppid() >= 0); |
| 440 | } | 438 | } |
| 441 | 439 | ||
| 442 | test "rename smoke test" { | 440 | test "rename smoke test" { |
| 443 | if (native_os == .windows) return error.SkipZigTest; | ||
| 444 | if (!fstest.isRealPathSupported()) return error.SkipZigTest; | 441 | if (!fstest.isRealPathSupported()) return error.SkipZigTest; |
| 445 | 442 | ||
| 446 | const io = testing.io; | 443 | const io = testing.io; |
| ... | @@ -452,7 +449,7 @@ test "rename smoke test" { | ... | @@ -452,7 +449,7 @@ test "rename smoke test" { |
| 452 | const base_path = try tmp.dir.realPathFileAlloc(io, ".", gpa); | 449 | const base_path = try tmp.dir.realPathFileAlloc(io, ".", gpa); |
| 453 | defer gpa.free(base_path); | 450 | defer gpa.free(base_path); |
| 454 | 451 | ||
| 455 | const mode: posix.mode_t = if (native_os == .windows) 0 else 0o666; | 452 | const mode: posix.mode_t = 0o666; |
| 456 | 453 | ||
| 457 | { | 454 | { |
| 458 | // Create some file using `open`. | 455 | // Create some file using `open`. |
lib/std/process.zig+14-7| ... | @@ -415,12 +415,12 @@ pub const SpawnOptions = struct { | ... | @@ -415,12 +415,12 @@ pub const SpawnOptions = struct { |
| 415 | /// On Linux and Darwin, this obtains rusage statistics from wait4(). | 415 | /// On Linux and Darwin, this obtains rusage statistics from wait4(). |
| 416 | request_resource_usage_statistics: bool = false, | 416 | request_resource_usage_statistics: bool = false, |
| 417 | 417 | ||
| 418 | /// Set to change the user id when spawning the child process. | 418 | /// Set to change the user id when spawning the child process. Unsupported on Windows. |
| 419 | uid: ?posix.uid_t = null, | 419 | uid: ?File.Uid = null, |
| 420 | /// Set to change the group id when spawning the child process. | 420 | /// Set to change the group id when spawning the child process. Unsupported on Windows. |
| 421 | gid: ?posix.gid_t = null, | 421 | gid: ?File.Gid = null, |
| 422 | /// Set to change the process group id when spawning the child process. | 422 | /// Set to change the process group id when spawning the child process. Unsupported on Windows. |
| 423 | pgid: ?posix.pid_t = null, | 423 | pgid: ?Child.Id = null, |
| 424 | 424 | ||
| 425 | /// Start child process in suspended state. | 425 | /// Start child process in suspended state. |
| 426 | /// For Posix systems it's started as if SIGSTOP was sent. | 426 | /// For Posix systems it's started as if SIGSTOP was sent. |
| ... | @@ -656,7 +656,7 @@ pub fn cleanExit(io: Io) void { | ... | @@ -656,7 +656,7 @@ pub fn cleanExit(io: Io) void { |
| 656 | /// On some systems, this raises the limit before seeing ProcessFdQuotaExceeded | 656 | /// On some systems, this raises the limit before seeing ProcessFdQuotaExceeded |
| 657 | /// errors. On other systems, this does nothing. | 657 | /// errors. On other systems, this does nothing. |
| 658 | pub fn raiseFileDescriptorLimit() void { | 658 | pub fn raiseFileDescriptorLimit() void { |
| 659 | const have_rlimit = posix.rlimit_resource != void; | 659 | const have_rlimit = native_os != .windows and posix.rlimit_resource != void; |
| 660 | if (!have_rlimit) return; | 660 | if (!have_rlimit) return; |
| 661 | 661 | ||
| 662 | var lim = posix.getrlimit(.NOFILE) catch return; // Oh well; we tried. | 662 | var lim = posix.getrlimit(.NOFILE) catch return; // Oh well; we tried. |
| ... | @@ -964,6 +964,7 @@ pub const LockMemoryOptions = struct { | ... | @@ -964,6 +964,7 @@ pub const LockMemoryOptions = struct { |
| 964 | pub fn lockMemory(memory: []align(std.heap.page_size_min) const u8, options: LockMemoryOptions) LockMemoryError!void { | 964 | pub fn lockMemory(memory: []align(std.heap.page_size_min) const u8, options: LockMemoryOptions) LockMemoryError!void { |
| 965 | if (native_os == .windows) { | 965 | if (native_os == .windows) { |
| 966 | // TODO call VirtualLock | 966 | // TODO call VirtualLock |
| 967 | return; | ||
| 967 | } | 968 | } |
| 968 | if (!options.on_fault and @TypeOf(posix.system.mlock) != void) { | 969 | if (!options.on_fault and @TypeOf(posix.system.mlock) != void) { |
| 969 | switch (posix.errno(posix.system.mlock(memory.ptr, memory.len))) { | 970 | switch (posix.errno(posix.system.mlock(memory.ptr, memory.len))) { |
| ... | @@ -1002,6 +1003,10 @@ pub const UnlockMemoryError = error{ | ... | @@ -1002,6 +1003,10 @@ pub const UnlockMemoryError = error{ |
| 1002 | /// See also: | 1003 | /// See also: |
| 1003 | /// * `lockMemory` | 1004 | /// * `lockMemory` |
| 1004 | pub fn unlockMemory(memory: []align(std.heap.page_size_min) const u8) UnlockMemoryError!void { | 1005 | pub fn unlockMemory(memory: []align(std.heap.page_size_min) const u8) UnlockMemoryError!void { |
| 1006 | if (native_os == .windows) { | ||
| 1007 | // TODO call VirtualUnlock | ||
| 1008 | return; | ||
| 1009 | } | ||
| 1005 | if (@TypeOf(posix.system.munlock) == void) return; | 1010 | if (@TypeOf(posix.system.munlock) == void) return; |
| 1006 | switch (posix.errno(posix.system.munlock(memory.ptr, memory.len))) { | 1011 | switch (posix.errno(posix.system.munlock(memory.ptr, memory.len))) { |
| 1007 | .SUCCESS => return, | 1012 | .SUCCESS => return, |
| ... | @@ -1021,6 +1026,7 @@ pub const LockMemoryAllOptions = struct { | ... | @@ -1021,6 +1026,7 @@ pub const LockMemoryAllOptions = struct { |
| 1021 | }; | 1026 | }; |
| 1022 | 1027 | ||
| 1023 | pub fn lockMemoryAll(options: LockMemoryAllOptions) LockMemoryError!void { | 1028 | pub fn lockMemoryAll(options: LockMemoryAllOptions) LockMemoryError!void { |
| 1029 | if (native_os == .windows) return; | ||
| 1024 | if (@TypeOf(posix.system.mlockall) == void) return error.UnsupportedOperation; | 1030 | if (@TypeOf(posix.system.mlockall) == void) return error.UnsupportedOperation; |
| 1025 | var flags: posix.MCL = .{ | 1031 | var flags: posix.MCL = .{ |
| 1026 | .CURRENT = options.current, | 1032 | .CURRENT = options.current, |
| ... | @@ -1045,6 +1051,7 @@ pub fn lockMemoryAll(options: LockMemoryAllOptions) LockMemoryError!void { | ... | @@ -1045,6 +1051,7 @@ pub fn lockMemoryAll(options: LockMemoryAllOptions) LockMemoryError!void { |
| 1045 | } | 1051 | } |
| 1046 | 1052 | ||
| 1047 | pub fn unlockMemoryAll() UnlockMemoryError!void { | 1053 | pub fn unlockMemoryAll() UnlockMemoryError!void { |
| 1054 | if (native_os == .windows) return; | ||
| 1048 | if (@TypeOf(posix.system.munlockall) == void) return; | 1055 | if (@TypeOf(posix.system.munlockall) == void) return; |
| 1049 | switch (posix.errno(posix.system.munlockall())) { | 1056 | switch (posix.errno(posix.system.munlockall())) { |
| 1050 | .SUCCESS => return, | 1057 | .SUCCESS => return, |
lib/std/process/Args.zig+1-1| ... | @@ -372,7 +372,7 @@ pub const Iterator = struct { | ... | @@ -372,7 +372,7 @@ pub const Iterator = struct { |
| 372 | index: usize, | 372 | index: usize, |
| 373 | args: [][:0]u8, | 373 | args: [][:0]u8, |
| 374 | 374 | ||
| 375 | pub const InitError = error{OutOfMemory} || std.posix.UnexpectedError; | 375 | pub const InitError = error{OutOfMemory} || std.Io.UnexpectedError; |
| 376 | 376 | ||
| 377 | /// You must call deinit to free the internal buffer of the | 377 | /// You must call deinit to free the internal buffer of the |
| 378 | /// iterator after you are done. | 378 | /// iterator after you are done. |
lib/std/process/Child.zig+5-2| ... | @@ -93,10 +93,13 @@ pub const ResourceUsageStatistics = struct { | ... | @@ -93,10 +93,13 @@ pub const ResourceUsageStatistics = struct { |
| 93 | 93 | ||
| 94 | pub const Term = union(enum) { | 94 | pub const Term = union(enum) { |
| 95 | exited: u8, | 95 | exited: u8, |
| 96 | signal: std.posix.SIG, | 96 | signal: Signal, |
| 97 | stopped: std.posix.SIG, | 97 | stopped: Signal, |
| 98 | unknown: u32, | 98 | unknown: u32, |
| 99 | 99 | ||
| 100 | // This probably needs some more thought for Windows. | ||
| 101 | const Signal = if (native_os == .windows) std.c.SIG else std.posix.SIG; | ||
| 102 | |||
| 100 | pub fn success(t: Term) bool { | 103 | pub fn success(t: Term) bool { |
| 101 | return switch (t) { | 104 | return switch (t) { |
| 102 | .exited => |code| code == 0, | 105 | .exited => |code| code == 0, |
src/link/MachO.zig+2-2| ... | @@ -4438,7 +4438,7 @@ pub const MachError = error{ | ... | @@ -4438,7 +4438,7 @@ pub const MachError = error{ |
| 4438 | /// Not enough permissions held to perform the requested kernel | 4438 | /// Not enough permissions held to perform the requested kernel |
| 4439 | /// call. | 4439 | /// call. |
| 4440 | PermissionDenied, | 4440 | PermissionDenied, |
| 4441 | } || std.posix.UnexpectedError; | 4441 | } || std.Io.UnexpectedError; |
| 4442 | 4442 | ||
| 4443 | pub const MachTask = extern struct { | 4443 | pub const MachTask = extern struct { |
| 4444 | port: std.c.mach_port_name_t, | 4444 | port: std.c.mach_port_name_t, |
| ... | @@ -4906,7 +4906,7 @@ pub fn getKernError(err: std.c.kern_return_t) KernE { | ... | @@ -4906,7 +4906,7 @@ pub fn getKernError(err: std.c.kern_return_t) KernE { |
| 4906 | return @as(KernE, @fromBackingInt(@intCast(@as(u32, @truncate(@as(usize, @intCast(err))))))); | 4906 | return @as(KernE, @fromBackingInt(@intCast(@as(u32, @truncate(@as(usize, @intCast(err))))))); |
| 4907 | } | 4907 | } |
| 4908 | 4908 | ||
| 4909 | pub fn unexpectedKernError(err: KernE) std.posix.UnexpectedError { | 4909 | pub fn unexpectedKernError(err: KernE) std.Io.UnexpectedError { |
| 4910 | if (std.options.unexpected_error_tracing) { | 4910 | if (std.options.unexpected_error_tracing) { |
| 4911 | std.debug.print("unexpected error: {d}\n", .{@backingInt(err)}); | 4911 | std.debug.print("unexpected error: {d}\n", .{@backingInt(err)}); |
| 4912 | std.debug.dumpCurrentStackTrace(.{}); | 4912 | std.debug.dumpCurrentStackTrace(.{}); |