| author | |
| committer | |
| log | 80625990d5ce82b781de54c4587b489cbd2cd55f |
| tree | 76f7583b67d1e817efb0d2f401836d9a229aaf83 |
| parent | 85ed81bb94ca59da49a128cb6ee5065b130ba06c |
On Windows, it is sometimes problematic to depend on ws2_32.dll. Before,
users of std.Io.Threaded would have to call ioBasic() rather than io()
in order to avoid unnecessary dependencies on ws2_32.dll. Now, the
application can disable networking with std.Options.
This change is necessary due to moving networking functionality to
be based on Io.Operation, which is a tagged union.40 files changed, 122 insertions(+), 230 deletions(-)
lib/compiler/test_runner.zig+1-1| ... | ... | @@ -17,7 +17,7 @@ var fba: std.heap.FixedBufferAllocator = .init(&fba_buffer); |
| 17 | 17 | var fba_buffer: [8192]u8 = undefined; |
| 18 | 18 | var stdin_buffer: [4096]u8 = undefined; |
| 19 | 19 | var stdout_buffer: [4096]u8 = undefined; |
| 20 | const runner_threaded_io: Io = Io.Threaded.global_single_threaded.ioBasic(); | |
| 20 | const runner_threaded_io: Io = Io.Threaded.global_single_threaded.io(); | |
| 21 | 21 | |
| 22 | 22 | /// Keep in sync with logic in `std.Build.addRunArtifact` which decides whether |
| 23 | 23 | /// the test runner will communicate with the build runner via `std.zig.Server`. |
lib/compiler_rt.zig+1-1| ... | ... | @@ -17,7 +17,7 @@ else |
| 17 | 17 | null; |
| 18 | 18 | |
| 19 | 19 | pub const std_options_debug_io: std.Io = if (builtin.is_test) |
| 20 | std.Io.Threaded.global_single_threaded.ioBasic() | |
| 20 | std.Io.Threaded.global_single_threaded.io() | |
| 21 | 21 | else |
| 22 | 22 | unreachable; |
| 23 | 23 |
lib/fuzzer.zig+1-1| ... | ... | @@ -13,7 +13,7 @@ pub const std_options = std.Options{ |
| 13 | 13 | .logFn = logOverride, |
| 14 | 14 | }; |
| 15 | 15 | |
| 16 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 16 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 17 | 17 | |
| 18 | 18 | fn logOverride( |
| 19 | 19 | comptime level: std.log.Level, |
lib/std/Io/Threaded.zig+19-147| ... | ... | @@ -1908,142 +1908,10 @@ pub fn io(t: *Threaded) Io { |
| 1908 | 1908 | }; |
| 1909 | 1909 | } |
| 1910 | 1910 | |
| 1911 | /// Same as `io` but disables all networking functionality, which has | |
| 1912 | /// an additional dependency on Windows (ws2_32). | |
| 1913 | pub fn ioBasic(t: *Threaded) Io { | |
| 1914 | return .{ | |
| 1915 | .userdata = t, | |
| 1916 | .vtable = &.{ | |
| 1917 | .crashHandler = crashHandler, | |
| 1918 | ||
| 1919 | .async = async, | |
| 1920 | .concurrent = concurrent, | |
| 1921 | .await = await, | |
| 1922 | .cancel = cancel, | |
| 1923 | ||
| 1924 | .groupAsync = groupAsync, | |
| 1925 | .groupConcurrent = groupConcurrent, | |
| 1926 | .groupAwait = groupAwait, | |
| 1927 | .groupCancel = groupCancel, | |
| 1928 | ||
| 1929 | .recancel = recancel, | |
| 1930 | .swapCancelProtection = swapCancelProtection, | |
| 1931 | .checkCancel = checkCancel, | |
| 1932 | ||
| 1933 | .futexWait = futexWait, | |
| 1934 | .futexWaitUncancelable = futexWaitUncancelable, | |
| 1935 | .futexWake = futexWake, | |
| 1936 | ||
| 1937 | .operate = operate, | |
| 1938 | .batchAwaitAsync = batchAwaitAsync, | |
| 1939 | .batchAwaitConcurrent = batchAwaitConcurrent, | |
| 1940 | .batchCancel = batchCancel, | |
| 1941 | ||
| 1942 | .dirCreateDir = dirCreateDir, | |
| 1943 | .dirCreateDirPath = dirCreateDirPath, | |
| 1944 | .dirCreateDirPathOpen = dirCreateDirPathOpen, | |
| 1945 | .dirStat = dirStat, | |
| 1946 | .dirStatFile = dirStatFile, | |
| 1947 | .dirAccess = dirAccess, | |
| 1948 | .dirCreateFile = dirCreateFile, | |
| 1949 | .dirCreateFileAtomic = dirCreateFileAtomic, | |
| 1950 | .dirOpenFile = dirOpenFile, | |
| 1951 | .dirOpenDir = dirOpenDir, | |
| 1952 | .dirClose = dirClose, | |
| 1953 | .dirRead = dirRead, | |
| 1954 | .dirRealPath = dirRealPath, | |
| 1955 | .dirRealPathFile = dirRealPathFile, | |
| 1956 | .dirDeleteFile = dirDeleteFile, | |
| 1957 | .dirDeleteDir = dirDeleteDir, | |
| 1958 | .dirRename = dirRename, | |
| 1959 | .dirRenamePreserve = dirRenamePreserve, | |
| 1960 | .dirSymLink = dirSymLink, | |
| 1961 | .dirReadLink = dirReadLink, | |
| 1962 | .dirSetOwner = dirSetOwner, | |
| 1963 | .dirSetFileOwner = dirSetFileOwner, | |
| 1964 | .dirSetPermissions = dirSetPermissions, | |
| 1965 | .dirSetFilePermissions = dirSetFilePermissions, | |
| 1966 | .dirSetTimestamps = dirSetTimestamps, | |
| 1967 | .dirHardLink = dirHardLink, | |
| 1968 | ||
| 1969 | .fileStat = fileStat, | |
| 1970 | .fileLength = fileLength, | |
| 1971 | .fileClose = fileClose, | |
| 1972 | .fileWritePositional = fileWritePositional, | |
| 1973 | .fileWriteFileStreaming = fileWriteFileStreaming, | |
| 1974 | .fileWriteFilePositional = fileWriteFilePositional, | |
| 1975 | .fileReadPositional = fileReadPositional, | |
| 1976 | .fileSeekBy = fileSeekBy, | |
| 1977 | .fileSeekTo = fileSeekTo, | |
| 1978 | .fileSync = fileSync, | |
| 1979 | .fileIsTty = fileIsTty, | |
| 1980 | .fileEnableAnsiEscapeCodes = fileEnableAnsiEscapeCodes, | |
| 1981 | .fileSupportsAnsiEscapeCodes = fileSupportsAnsiEscapeCodes, | |
| 1982 | .fileSetLength = fileSetLength, | |
| 1983 | .fileSetOwner = fileSetOwner, | |
| 1984 | .fileSetPermissions = fileSetPermissions, | |
| 1985 | .fileSetTimestamps = fileSetTimestamps, | |
| 1986 | .fileLock = fileLock, | |
| 1987 | .fileTryLock = fileTryLock, | |
| 1988 | .fileUnlock = fileUnlock, | |
| 1989 | .fileDowngradeLock = fileDowngradeLock, | |
| 1990 | .fileRealPath = fileRealPath, | |
| 1991 | .fileHardLink = fileHardLink, | |
| 1992 | ||
| 1993 | .fileMemoryMapCreate = fileMemoryMapCreate, | |
| 1994 | .fileMemoryMapDestroy = fileMemoryMapDestroy, | |
| 1995 | .fileMemoryMapSetLength = fileMemoryMapSetLength, | |
| 1996 | .fileMemoryMapRead = fileMemoryMapRead, | |
| 1997 | .fileMemoryMapWrite = fileMemoryMapWrite, | |
| 1998 | ||
| 1999 | .processExecutableOpen = processExecutableOpen, | |
| 2000 | .processExecutablePath = processExecutablePath, | |
| 2001 | .lockStderr = lockStderr, | |
| 2002 | .tryLockStderr = tryLockStderr, | |
| 2003 | .unlockStderr = unlockStderr, | |
| 2004 | .processCurrentPath = processCurrentPath, | |
| 2005 | .processSetCurrentDir = processSetCurrentDir, | |
| 2006 | .processSetCurrentPath = processSetCurrentPath, | |
| 2007 | .processReplace = processReplace, | |
| 2008 | .processReplacePath = processReplacePath, | |
| 2009 | .processSpawn = processSpawn, | |
| 2010 | .processSpawnPath = processSpawnPath, | |
| 2011 | .childWait = childWait, | |
| 2012 | .childKill = childKill, | |
| 2013 | ||
| 2014 | .progressParentFile = progressParentFile, | |
| 2015 | ||
| 2016 | .now = now, | |
| 2017 | .clockResolution = clockResolution, | |
| 2018 | .sleep = sleep, | |
| 2019 | ||
| 2020 | .random = random, | |
| 2021 | .randomSecure = randomSecure, | |
| 2022 | ||
| 2023 | .netListenIp = netListenIpUnavailable, | |
| 2024 | .netListenUnix = netListenUnixUnavailable, | |
| 2025 | .netAccept = netAcceptUnavailable, | |
| 2026 | .netBindIp = netBindIpUnavailable, | |
| 2027 | .netConnectIp = netConnectIpUnavailable, | |
| 2028 | .netSocketCreatePair = netSocketCreatePairUnavailable, | |
| 2029 | .netConnectUnix = netConnectUnixUnavailable, | |
| 2030 | .netClose = netCloseUnavailable, | |
| 2031 | .netShutdown = netShutdownUnavailable, | |
| 2032 | .netRead = netReadUnavailable, | |
| 2033 | .netWrite = netWriteUnavailable, | |
| 2034 | .netWriteFile = netWriteFileUnavailable, | |
| 2035 | .netSend = netSendUnavailable, | |
| 2036 | .netInterfaceNameResolve = netInterfaceNameResolveUnavailable, | |
| 2037 | .netInterfaceName = netInterfaceNameUnavailable, | |
| 2038 | .netLookup = netLookupUnavailable, | |
| 2039 | }, | |
| 2040 | }; | |
| 2041 | } | |
| 2042 | ||
| 2043 | 1911 | pub const socket_flags_unsupported = is_darwin or native_os == .haiku; |
| 2044 | 1912 | const have_accept4 = !socket_flags_unsupported; |
| 2045 | 1913 | const have_flock_open_flags = @hasField(posix.O, "EXLOCK"); |
| 2046 | const have_networking = native_os != .wasi; | |
| 1914 | const have_networking = std.options.networking and native_os != .wasi; | |
| 2047 | 1915 | const have_flock = @TypeOf(posix.system.flock) != void; |
| 2048 | 1916 | const have_sendmmsg = native_os == .linux; |
| 2049 | 1917 | const have_futex = switch (builtin.cpu.arch) { |
| ... | ... | @@ -2595,7 +2463,7 @@ fn futexWait(userdata: ?*anyopaque, ptr: *const u32, expected: u32, timeout: Io. |
| 2595 | 2463 | return; |
| 2596 | 2464 | } |
| 2597 | 2465 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2598 | const t_io = ioBasic(t); | |
| 2466 | const t_io = io(t); | |
| 2599 | 2467 | const timeout_ns: ?u64 = ns: { |
| 2600 | 2468 | const d = timeout.toDurationFromNow(t_io) orelse break :ns null; |
| 2601 | 2469 | break :ns std.math.lossyCast(u64, d.raw.toNanoseconds()); |
| ... | ... | @@ -2788,7 +2656,7 @@ fn batchAwaitAsync(userdata: ?*anyopaque, b: *Io.Batch) Io.Cancelable!void { |
| 2788 | 2656 | fn batchAwaitConcurrent(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.AwaitConcurrentError!void { |
| 2789 | 2657 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2790 | 2658 | if (is_windows) { |
| 2791 | const deadline: ?Io.Clock.Timestamp = timeout.toTimestamp(ioBasic(t)); | |
| 2659 | const deadline: ?Io.Clock.Timestamp = timeout.toTimestamp(io(t)); | |
| 2792 | 2660 | try batchDrainSubmittedWindows(t, b, true); |
| 2793 | 2661 | while (b.pending.head != .none and b.completed.head == .none) { |
| 2794 | 2662 | var delay_interval: windows.LARGE_INTEGER = interval: { |
| ... | ... | @@ -2898,7 +2766,7 @@ fn batchAwaitConcurrent(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout |
| 2898 | 2766 | }, |
| 2899 | 2767 | else => {}, |
| 2900 | 2768 | } |
| 2901 | const t_io = ioBasic(t); | |
| 2769 | const t_io = io(t); | |
| 2902 | 2770 | const deadline = timeout.toTimestamp(t_io); |
| 2903 | 2771 | while (true) { |
| 2904 | 2772 | const timeout_ms: i32 = t: { |
| ... | ... | @@ -3536,7 +3404,7 @@ fn dirCreateDirPathOpenPosix( |
| 3536 | 3404 | options: Dir.OpenOptions, |
| 3537 | 3405 | ) Dir.CreateDirPathOpenError!Dir { |
| 3538 | 3406 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 3539 | const t_io = ioBasic(t); | |
| 3407 | const t_io = io(t); | |
| 3540 | 3408 | return dirOpenDirPosix(t, dir, sub_path, options) catch |err| switch (err) { |
| 3541 | 3409 | error.FileNotFound => { |
| 3542 | 3410 | _ = try dir.createDirPathStatus(t_io, sub_path, permissions); |
| ... | ... | @@ -3657,7 +3525,7 @@ fn dirCreateDirPathOpenWasi( |
| 3657 | 3525 | options: Dir.OpenOptions, |
| 3658 | 3526 | ) Dir.CreateDirPathOpenError!Dir { |
| 3659 | 3527 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 3660 | const t_io = ioBasic(t); | |
| 3528 | const t_io = io(t); | |
| 3661 | 3529 | return dirOpenDirWasi(t, dir, sub_path, options) catch |err| switch (err) { |
| 3662 | 3530 | error.FileNotFound => { |
| 3663 | 3531 | _ = try dir.createDirPathStatus(t_io, sub_path, permissions); |
| ... | ... | @@ -4698,7 +4566,7 @@ fn dirCreateFileAtomic( |
| 4698 | 4566 | options: Dir.CreateFileAtomicOptions, |
| 4699 | 4567 | ) Dir.CreateFileAtomicError!File.Atomic { |
| 4700 | 4568 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4701 | const t_io = ioBasic(t); | |
| 4569 | const t_io = io(t); | |
| 4702 | 4570 | |
| 4703 | 4571 | // Linux has O_TMPFILE, but linkat() does not support AT_REPLACE, so it's |
| 4704 | 4572 | // useless when we have to make up a bogus path name to do the rename() |
| ... | ... | @@ -10326,19 +10194,19 @@ fn processExecutablePath(userdata: ?*anyopaque, out_buffer: []u8) process.Execut |
| 10326 | 10194 | const rc = std.c._NSGetExecutablePath(&symlink_path_buf, &n); |
| 10327 | 10195 | if (rc != 0) return error.NameTooLong; |
| 10328 | 10196 | const symlink_path = std.mem.sliceTo(&symlink_path_buf, 0); |
| 10329 | return Io.Dir.realPathFileAbsolute(ioBasic(t), symlink_path, out_buffer) catch |err| switch (err) { | |
| 10197 | return Io.Dir.realPathFileAbsolute(io(t), symlink_path, out_buffer) catch |err| switch (err) { | |
| 10330 | 10198 | error.NetworkNotFound => unreachable, // Windows-only |
| 10331 | 10199 | error.FileBusy => unreachable, // Windows-only |
| 10332 | 10200 | else => |e| return e, |
| 10333 | 10201 | }; |
| 10334 | 10202 | }, |
| 10335 | .linux, .serenity => return Io.Dir.readLinkAbsolute(ioBasic(t), "/proc/self/exe", out_buffer) catch |err| switch (err) { | |
| 10203 | .linux, .serenity => return Io.Dir.readLinkAbsolute(io(t), "/proc/self/exe", out_buffer) catch |err| switch (err) { | |
| 10336 | 10204 | error.UnsupportedReparsePointType => unreachable, // Windows-only |
| 10337 | 10205 | error.NetworkNotFound => unreachable, // Windows-only |
| 10338 | 10206 | error.FileBusy => unreachable, // Windows-only |
| 10339 | 10207 | else => |e| return e, |
| 10340 | 10208 | }, |
| 10341 | .illumos => return Io.Dir.readLinkAbsolute(ioBasic(t), "/proc/self/path/a.out", out_buffer) catch |err| switch (err) { | |
| 10209 | .illumos => return Io.Dir.readLinkAbsolute(io(t), "/proc/self/path/a.out", out_buffer) catch |err| switch (err) { | |
| 10342 | 10210 | error.UnsupportedReparsePointType => unreachable, // Windows-only |
| 10343 | 10211 | error.NetworkNotFound => unreachable, // Windows-only |
| 10344 | 10212 | error.FileBusy => unreachable, // Windows-only |
| ... | ... | @@ -11700,7 +11568,7 @@ fn sleepPosix(timeout: Io.Timeout) Io.Cancelable!void { |
| 11700 | 11568 | } |
| 11701 | 11569 | |
| 11702 | 11570 | fn sleepWasi(t: *Threaded, timeout: Io.Timeout) Io.Cancelable!void { |
| 11703 | const t_io = ioBasic(t); | |
| 11571 | const t_io = io(t); | |
| 11704 | 11572 | const w = std.os.wasi; |
| 11705 | 11573 | |
| 11706 | 11574 | const clock: w.subscription_clock_t = if (timeout.toDurationFromNow(t_io)) |d| .{ |
| ... | ... | @@ -11729,7 +11597,7 @@ fn sleepWasi(t: *Threaded, timeout: Io.Timeout) Io.Cancelable!void { |
| 11729 | 11597 | } |
| 11730 | 11598 | |
| 11731 | 11599 | fn sleepNanosleep(t: *Threaded, timeout: Io.Timeout) Io.Cancelable!void { |
| 11732 | const t_io = ioBasic(t); | |
| 11600 | const t_io = io(t); | |
| 11733 | 11601 | const sec_type = @typeInfo(posix.timespec).@"struct".fields[0].type; |
| 11734 | 11602 | const nsec_type = @typeInfo(posix.timespec).@"struct".fields[1].type; |
| 11735 | 11603 | |
| ... | ... | @@ -11961,6 +11829,7 @@ fn netListenUnixWindows( |
| 11961 | 11829 | options: net.UnixAddress.ListenOptions, |
| 11962 | 11830 | ) net.UnixAddress.ListenError!net.Socket.Handle { |
| 11963 | 11831 | if (!net.has_unix_sockets) return error.AddressFamilyUnsupported; |
| 11832 | if (!have_networking) return error.NetworkDown; | |
| 11964 | 11833 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 11965 | 11834 | |
| 11966 | 11835 | const socket_handle = openSocketWsa(t, posix.AF.UNIX, .{ .mode = .stream }) catch |err| switch (err) { |
| ... | ... | @@ -12457,6 +12326,7 @@ fn netConnectUnixWindows( |
| 12457 | 12326 | address: *const net.UnixAddress, |
| 12458 | 12327 | ) net.UnixAddress.ConnectError!net.Socket.Handle { |
| 12459 | 12328 | if (!net.has_unix_sockets) return error.AddressFamilyUnsupported; |
| 12329 | if (!have_networking) return error.NetworkDown; | |
| 12460 | 12330 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 12461 | 12331 | |
| 12462 | 12332 | const socket_handle = try openSocketWsa(t, posix.AF.UNIX, .{ .mode = .stream }); |
| ... | ... | @@ -13426,7 +13296,7 @@ fn netReceiveWindowsOne( |
| 13426 | 13296 | data_buffer: []u8, |
| 13427 | 13297 | flags: net.ReceiveFlags, |
| 13428 | 13298 | ) net.Socket.ReceiveError!void { |
| 13429 | comptime assert(have_networking); | |
| 13299 | if (!have_networking) return error.NetworkDown; | |
| 13430 | 13300 | |
| 13431 | 13301 | var windows_flags: u32 = |
| 13432 | 13302 | @as(u32, if (flags.oob) ws2_32.MSG.OOB else 0) | |
| ... | ... | @@ -13601,6 +13471,7 @@ fn netWriteWindows( |
| 13601 | 13471 | data: []const []const u8, |
| 13602 | 13472 | splat: usize, |
| 13603 | 13473 | ) net.Stream.Writer.Error!usize { |
| 13474 | if (!have_networking) return error.NetworkDown; | |
| 13604 | 13475 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 13605 | 13476 | comptime assert(is_windows); |
| 13606 | 13477 | |
| ... | ... | @@ -13723,6 +13594,7 @@ fn addBuf(v: []posix.iovec_const, i: *iovlen_t, bytes: []const u8) void { |
| 13723 | 13594 | } |
| 13724 | 13595 | |
| 13725 | 13596 | fn netClose(userdata: ?*anyopaque, handles: []const net.Socket.Handle) void { |
| 13597 | if (!have_networking) unreachable; | |
| 13726 | 13598 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 13727 | 13599 | _ = t; |
| 13728 | 13600 | switch (native_os) { |
| ... | ... | @@ -13931,7 +13803,7 @@ fn netLookupUnavailable( |
| 13931 | 13803 | _ = host_name; |
| 13932 | 13804 | _ = options; |
| 13933 | 13805 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 13934 | resolved.close(ioBasic(t)); | |
| 13806 | resolved.close(io(t)); | |
| 13935 | 13807 | return error.NetworkDown; |
| 13936 | 13808 | } |
| 13937 | 13809 | |
| ... | ... | @@ -14214,7 +14086,7 @@ fn tryLockStderr(userdata: ?*anyopaque, terminal_mode: ?Io.Terminal.Mode) Io.Can |
| 14214 | 14086 | |
| 14215 | 14087 | fn initLockedStderr(t: *Threaded, terminal_mode: ?Io.Terminal.Mode) Io.Cancelable!Io.LockedStderr { |
| 14216 | 14088 | if (!t.stderr_writer_initialized) { |
| 14217 | const io_t = ioBasic(t); | |
| 14089 | const io_t = io(t); | |
| 14218 | 14090 | if (is_windows) t.stderr_writer.file = .stderr(); |
| 14219 | 14091 | t.stderr_writer.io = io_t; |
| 14220 | 14092 | t.stderr_writer_initialized = true; |
lib/std/std.zig+4-1| ... | ... | @@ -174,6 +174,9 @@ pub const Options = struct { |
| 174 | 174 | /// stack traces will just print an error to the relevant `Io.Writer` and return. |
| 175 | 175 | allow_stack_tracing: bool = !@import("builtin").strip_debug_info, |
| 176 | 176 | |
| 177 | /// Allows disabling networking in std.Io implementations. | |
| 178 | networking: bool = true, | |
| 179 | ||
| 177 | 180 | /// TODO This is a separate decl instead of a field as a workaround around |
| 178 | 181 | /// compilation errors due to zig not being lazy enough. |
| 179 | 182 | pub const logTerminalMode: fn () Io.Terminal.Mode = log.defaultTerminalMode; |
| ... | ... | @@ -202,7 +205,7 @@ pub const Options = struct { |
| 202 | 205 | /// implementation based on coroutines, one likely wants `std.debug.print` |
| 203 | 206 | /// to directly write to stderr without trying to interact with the code |
| 204 | 207 | /// being debugged. |
| 205 | pub const debug_io: Io = if (@hasDecl(root, "std_options_debug_io")) root.std_options_debug_io else debug_threaded_io.?.ioBasic(); | |
| 208 | pub const debug_io: Io = if (@hasDecl(root, "std_options_debug_io")) root.std_options_debug_io else debug_threaded_io.?.io(); | |
| 206 | 209 | |
| 207 | 210 | /// Overrides `std.Io.File.Permissions`. |
| 208 | 211 | pub const FilePermissions: ?type = if (@hasDecl(root, "std_options_FilePermissions")) root.std_options_FilePermissions else null; |
lib/ubsan_rt.zig+4| ... | ... | @@ -3,6 +3,10 @@ const builtin = @import("builtin"); |
| 3 | 3 | const assert = std.debug.assert; |
| 4 | 4 | const panic = std.debug.panicExtra; |
| 5 | 5 | |
| 6 | pub const std_options: std.Options = .{ | |
| 7 | .networking = false, | |
| 8 | }; | |
| 9 | ||
| 6 | 10 | const SourceLocation = extern struct { |
| 7 | 11 | file_name: ?[*:0]const u8, |
| 8 | 12 | line: u32, |
test/incremental/add_decl+6-6| ... | ... | @@ -10,7 +10,7 @@ pub fn main() !void { |
| 10 | 10 | try std.Io.File.stdout().writeStreamingAll(io, foo); |
| 11 | 11 | } |
| 12 | 12 | const foo = "good morning\n"; |
| 13 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 13 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 14 | 14 | #expect_stdout="good morning\n" |
| 15 | 15 | |
| 16 | 16 | #update=add new declaration |
| ... | ... | @@ -21,7 +21,7 @@ pub fn main() !void { |
| 21 | 21 | } |
| 22 | 22 | const foo = "good morning\n"; |
| 23 | 23 | const bar = "good evening\n"; |
| 24 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 24 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 25 | 25 | #expect_stdout="good morning\n" |
| 26 | 26 | |
| 27 | 27 | #update=reference new declaration |
| ... | ... | @@ -32,7 +32,7 @@ pub fn main() !void { |
| 32 | 32 | } |
| 33 | 33 | const foo = "good morning\n"; |
| 34 | 34 | const bar = "good evening\n"; |
| 35 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 35 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 36 | 36 | #expect_stdout="good evening\n" |
| 37 | 37 | |
| 38 | 38 | #update=reference missing declaration |
| ... | ... | @@ -43,7 +43,7 @@ pub fn main() !void { |
| 43 | 43 | } |
| 44 | 44 | const foo = "good morning\n"; |
| 45 | 45 | const bar = "good evening\n"; |
| 46 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 46 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 47 | 47 | #expect_error=main.zig:3:52: error: use of undeclared identifier 'qux' |
| 48 | 48 | |
| 49 | 49 | #update=add missing declaration |
| ... | ... | @@ -55,7 +55,7 @@ pub fn main() !void { |
| 55 | 55 | const foo = "good morning\n"; |
| 56 | 56 | const bar = "good evening\n"; |
| 57 | 57 | const qux = "good night\n"; |
| 58 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 58 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 59 | 59 | #expect_stdout="good night\n" |
| 60 | 60 | |
| 61 | 61 | #update=remove unused declarations |
| ... | ... | @@ -65,5 +65,5 @@ pub fn main() !void { |
| 65 | 65 | try std.Io.File.stdout().writeStreamingAll(io, qux); |
| 66 | 66 | } |
| 67 | 67 | const qux = "good night\n"; |
| 68 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 68 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 69 | 69 | #expect_stdout="good night\n" |
test/incremental/add_decl_namespaced+6-6| ... | ... | @@ -10,7 +10,7 @@ pub fn main() !void { |
| 10 | 10 | try std.Io.File.stdout().writeStreamingAll(io, @This().foo); |
| 11 | 11 | } |
| 12 | 12 | const foo = "good morning\n"; |
| 13 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 13 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 14 | 14 | #expect_stdout="good morning\n" |
| 15 | 15 | |
| 16 | 16 | #update=add new declaration |
| ... | ... | @@ -21,7 +21,7 @@ pub fn main() !void { |
| 21 | 21 | } |
| 22 | 22 | const foo = "good morning\n"; |
| 23 | 23 | const bar = "good evening\n"; |
| 24 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 24 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 25 | 25 | #expect_stdout="good morning\n" |
| 26 | 26 | |
| 27 | 27 | #update=reference new declaration |
| ... | ... | @@ -32,7 +32,7 @@ pub fn main() !void { |
| 32 | 32 | } |
| 33 | 33 | const foo = "good morning\n"; |
| 34 | 34 | const bar = "good evening\n"; |
| 35 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 35 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 36 | 36 | #expect_stdout="good evening\n" |
| 37 | 37 | |
| 38 | 38 | #update=reference missing declaration |
| ... | ... | @@ -43,7 +43,7 @@ pub fn main() !void { |
| 43 | 43 | } |
| 44 | 44 | const foo = "good morning\n"; |
| 45 | 45 | const bar = "good evening\n"; |
| 46 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 46 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 47 | 47 | #expect_error=main.zig:3:59: error: root source file struct 'main' has no member named 'qux' |
| 48 | 48 | #expect_error=main.zig:1:1: note: struct declared here |
| 49 | 49 | |
| ... | ... | @@ -56,7 +56,7 @@ pub fn main() !void { |
| 56 | 56 | const foo = "good morning\n"; |
| 57 | 57 | const bar = "good evening\n"; |
| 58 | 58 | const qux = "good night\n"; |
| 59 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 59 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 60 | 60 | #expect_stdout="good night\n" |
| 61 | 61 | |
| 62 | 62 | #update=remove unused declarations |
| ... | ... | @@ -66,5 +66,5 @@ pub fn main() !void { |
| 66 | 66 | try std.Io.File.stdout().writeStreamingAll(io, @This().qux); |
| 67 | 67 | } |
| 68 | 68 | const qux = "good night\n"; |
| 69 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 69 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 70 | 70 | #expect_stdout="good night\n" |
test/incremental/bad_import+2-2| ... | ... | @@ -11,7 +11,7 @@ pub fn main() !void { |
| 11 | 11 | try std.Io.File.stdout().writeStreamingAll(io, "success\n"); |
| 12 | 12 | } |
| 13 | 13 | const std = @import("std"); |
| 14 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 14 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 15 | 15 | #file=foo.zig |
| 16 | 16 | comptime { |
| 17 | 17 | _ = @import("bad.zig"); |
| ... | ... | @@ -34,5 +34,5 @@ pub fn main() !void { |
| 34 | 34 | try std.Io.File.stdout().writeStreamingAll(io, "success\n"); |
| 35 | 35 | } |
| 36 | 36 | const std = @import("std"); |
| 37 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 37 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 38 | 38 | #expect_stdout="success\n" |
test/incremental/change_embed_file+3-3| ... | ... | @@ -10,7 +10,7 @@ const string = @embedFile("string.txt"); |
| 10 | 10 | pub fn main() !void { |
| 11 | 11 | try std.Io.File.stdout().writeStreamingAll(io, string); |
| 12 | 12 | } |
| 13 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 13 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 14 | 14 | #file=string.txt |
| 15 | 15 | Hello, World! |
| 16 | 16 | #expect_stdout="Hello, World!\n" |
| ... | ... | @@ -31,7 +31,7 @@ const string = @embedFile("string.txt"); |
| 31 | 31 | pub fn main() !void { |
| 32 | 32 | try std.Io.File.stdout().writeStreamingAll(io, "a hardcoded string\n"); |
| 33 | 33 | } |
| 34 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 34 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 35 | 35 | #expect_stdout="a hardcoded string\n" |
| 36 | 36 | |
| 37 | 37 | #update=re-introduce reference to file |
| ... | ... | @@ -41,7 +41,7 @@ const string = @embedFile("string.txt"); |
| 41 | 41 | pub fn main() !void { |
| 42 | 42 | try std.Io.File.stdout().writeStreamingAll(io, string); |
| 43 | 43 | } |
| 44 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 44 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 45 | 45 | #expect_error=main.zig:2:27: error: unable to open 'string.txt': FileNotFound |
| 46 | 46 | |
| 47 | 47 | #update=recreate file |
test/incremental/change_enum_tag_type+3-3| ... | ... | @@ -19,7 +19,7 @@ pub fn main() !void { |
| 19 | 19 | try stdout_writer.interface.print("{s}\n", .{@tagName(val)}); |
| 20 | 20 | } |
| 21 | 21 | const std = @import("std"); |
| 22 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 22 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 23 | 23 | #expect_stdout="a\n" |
| 24 | 24 | #update=too many enum fields |
| 25 | 25 | #file=main.zig |
| ... | ... | @@ -43,7 +43,7 @@ comptime { |
| 43 | 43 | std.debug.assert(@TypeOf(@intFromEnum(Foo.e)) == Tag); |
| 44 | 44 | } |
| 45 | 45 | const std = @import("std"); |
| 46 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 46 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 47 | 47 | #expect_error=main.zig:7:5: error: enumeration value '4' too large for type 'u2' |
| 48 | 48 | #update=increase tag size |
| 49 | 49 | #file=main.zig |
| ... | ... | @@ -62,5 +62,5 @@ pub fn main() !void { |
| 62 | 62 | try stdout_writer.interface.print("{s}\n", .{@tagName(val)}); |
| 63 | 63 | } |
| 64 | 64 | const std = @import("std"); |
| 65 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 65 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 66 | 66 | #expect_stdout="a\n" |
test/incremental/change_exports+6-6| ... | ... | @@ -21,7 +21,7 @@ pub fn main() !void { |
| 21 | 21 | try stdout_writer.interface.print("{}\n", .{S.bar}); |
| 22 | 22 | } |
| 23 | 23 | const std = @import("std"); |
| 24 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 24 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 25 | 25 | #expect_stdout="123\n" |
| 26 | 26 | |
| 27 | 27 | #update=add conflict |
| ... | ... | @@ -44,7 +44,7 @@ pub fn main() !void { |
| 44 | 44 | try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other }); |
| 45 | 45 | } |
| 46 | 46 | const std = @import("std"); |
| 47 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 47 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 48 | 48 | #expect_error=main.zig:6:5: error: exported symbol collision: foo |
| 49 | 49 | #expect_error=main.zig:1:1: note: other symbol here |
| 50 | 50 | |
| ... | ... | @@ -68,7 +68,7 @@ pub fn main() !void { |
| 68 | 68 | try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other }); |
| 69 | 69 | } |
| 70 | 70 | const std = @import("std"); |
| 71 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 71 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 72 | 72 | #expect_stdout="123 456\n" |
| 73 | 73 | |
| 74 | 74 | #update=put exports in decl |
| ... | ... | @@ -94,7 +94,7 @@ pub fn main() !void { |
| 94 | 94 | try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other }); |
| 95 | 95 | } |
| 96 | 96 | const std = @import("std"); |
| 97 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 97 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 98 | 98 | #expect_stdout="123 456\n" |
| 99 | 99 | |
| 100 | 100 | #update=remove reference to exporting decl |
| ... | ... | @@ -141,7 +141,7 @@ pub fn main() !void { |
| 141 | 141 | try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other }); |
| 142 | 142 | } |
| 143 | 143 | const std = @import("std"); |
| 144 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 144 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 145 | 145 | #expect_stdout="123 456\n" |
| 146 | 146 | |
| 147 | 147 | #update=reintroduce reference to exporting decl, introducing conflict |
| ... | ... | @@ -167,7 +167,7 @@ pub fn main() !void { |
| 167 | 167 | try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other }); |
| 168 | 168 | } |
| 169 | 169 | const std = @import("std"); |
| 170 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 170 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 171 | 171 | #expect_error=main.zig:5:5: error: exported symbol collision: bar |
| 172 | 172 | #expect_error=main.zig:2:1: note: other symbol here |
| 173 | 173 | #expect_error=main.zig:6:5: error: exported symbol collision: other |
test/incremental/change_fn_type+3-3| ... | ... | @@ -12,7 +12,7 @@ fn foo(x: u8) !void { |
| 12 | 12 | return stdout_writer.interface.print("{d}\n", .{x}); |
| 13 | 13 | } |
| 14 | 14 | const std = @import("std"); |
| 15 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 15 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 16 | 16 | #expect_stdout="123\n" |
| 17 | 17 | |
| 18 | 18 | #update=change function type |
| ... | ... | @@ -25,7 +25,7 @@ fn foo(x: i64) !void { |
| 25 | 25 | return stdout_writer.interface.print("{d}\n", .{x}); |
| 26 | 26 | } |
| 27 | 27 | const std = @import("std"); |
| 28 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 28 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 29 | 29 | #expect_stdout="123\n" |
| 30 | 30 | |
| 31 | 31 | #update=change function argument |
| ... | ... | @@ -38,5 +38,5 @@ fn foo(x: i64) !void { |
| 38 | 38 | return stdout_writer.interface.print("{d}\n", .{x}); |
| 39 | 39 | } |
| 40 | 40 | const std = @import("std"); |
| 41 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 41 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 42 | 42 | #expect_stdout="-42\n" |
test/incremental/change_generic_line_number+2-2| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | #update=initial version |
| 5 | 5 | #file=main.zig |
| 6 | 6 | const std = @import("std"); |
| 7 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 7 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 8 | 8 | fn Printer(message: []const u8) type { |
| 9 | 9 | return struct { |
| 10 | 10 | fn print() !void { |
| ... | ... | @@ -20,7 +20,7 @@ pub fn main() !void { |
| 20 | 20 | #update=change line number |
| 21 | 21 | #file=main.zig |
| 22 | 22 | const std = @import("std"); |
| 23 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 23 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 24 | 24 | |
| 25 | 25 | fn Printer(message: []const u8) type { |
| 26 | 26 | return struct { |
test/incremental/change_line_number+2-2| ... | ... | @@ -7,7 +7,7 @@ const std = @import("std"); |
| 7 | 7 | pub fn main() !void { |
| 8 | 8 | try std.Io.File.stdout().writeStreamingAll(io, "foo\n"); |
| 9 | 9 | } |
| 10 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 10 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 11 | 11 | #expect_stdout="foo\n" |
| 12 | 12 | #update=change line number |
| 13 | 13 | #file=main.zig |
| ... | ... | @@ -16,5 +16,5 @@ const std = @import("std"); |
| 16 | 16 | pub fn main() !void { |
| 17 | 17 | try std.Io.File.stdout().writeStreamingAll(io, "foo\n"); |
| 18 | 18 | } |
| 19 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 19 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 20 | 20 | #expect_stdout="foo\n" |
test/incremental/change_panic_handler+3-3| ... | ... | @@ -17,7 +17,7 @@ fn myPanic(msg: []const u8, _: ?usize) noreturn { |
| 17 | 17 | std.process.exit(0); |
| 18 | 18 | } |
| 19 | 19 | const std = @import("std"); |
| 20 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 20 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 21 | 21 | #expect_stdout="panic message: integer overflow\n" |
| 22 | 22 | |
| 23 | 23 | #update=change the panic handler body |
| ... | ... | @@ -35,7 +35,7 @@ fn myPanic(msg: []const u8, _: ?usize) noreturn { |
| 35 | 35 | std.process.exit(0); |
| 36 | 36 | } |
| 37 | 37 | const std = @import("std"); |
| 38 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 38 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 39 | 39 | #expect_stdout="new panic message: integer overflow\n" |
| 40 | 40 | |
| 41 | 41 | #update=change the panic handler function value |
| ... | ... | @@ -53,5 +53,5 @@ fn myPanicNew(msg: []const u8, _: ?usize) noreturn { |
| 53 | 53 | std.process.exit(0); |
| 54 | 54 | } |
| 55 | 55 | const std = @import("std"); |
| 56 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 56 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 57 | 57 | #expect_stdout="third panic message: integer overflow\n" |
test/incremental/change_panic_handler_explicit+3-3| ... | ... | @@ -47,7 +47,7 @@ fn myPanic(msg: []const u8, _: ?usize) noreturn { |
| 47 | 47 | std.process.exit(0); |
| 48 | 48 | } |
| 49 | 49 | const std = @import("std"); |
| 50 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 50 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 51 | 51 | #expect_stdout="panic message: integer overflow\n" |
| 52 | 52 | |
| 53 | 53 | #update=change the panic handler body |
| ... | ... | @@ -95,7 +95,7 @@ fn myPanic(msg: []const u8, _: ?usize) noreturn { |
| 95 | 95 | std.process.exit(0); |
| 96 | 96 | } |
| 97 | 97 | const std = @import("std"); |
| 98 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 98 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 99 | 99 | #expect_stdout="new panic message: integer overflow\n" |
| 100 | 100 | |
| 101 | 101 | #update=change the panic handler function value |
| ... | ... | @@ -143,5 +143,5 @@ fn myPanicNew(msg: []const u8, _: ?usize) noreturn { |
| 143 | 143 | std.process.exit(0); |
| 144 | 144 | } |
| 145 | 145 | const std = @import("std"); |
| 146 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 146 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 147 | 147 | #expect_stdout="third panic message: integer overflow\n" |
test/incremental/change_shift_op+2-2| ... | ... | @@ -13,7 +13,7 @@ fn foo(x: u16) !void { |
| 13 | 13 | try stdout_writer.interface.print("0x{x}\n", .{x << 4}); |
| 14 | 14 | } |
| 15 | 15 | const std = @import("std"); |
| 16 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 16 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 17 | 17 | #expect_stdout="0x3000\n" |
| 18 | 18 | #update=change to right shift |
| 19 | 19 | #file=main.zig |
| ... | ... | @@ -25,5 +25,5 @@ fn foo(x: u16) !void { |
| 25 | 25 | try stdout_writer.interface.print("0x{x}\n", .{x >> 4}); |
| 26 | 26 | } |
| 27 | 27 | const std = @import("std"); |
| 28 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 28 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 29 | 29 | #expect_stdout="0x130\n" |
test/incremental/change_struct_same_fields+3-3| ... | ... | @@ -18,7 +18,7 @@ fn foo(val: *const S) !void { |
| 18 | 18 | ); |
| 19 | 19 | } |
| 20 | 20 | const std = @import("std"); |
| 21 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 21 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 22 | 22 | #expect_stdout="100 200\n" |
| 23 | 23 | |
| 24 | 24 | #update=change struct layout |
| ... | ... | @@ -36,7 +36,7 @@ fn foo(val: *const S) !void { |
| 36 | 36 | ); |
| 37 | 37 | } |
| 38 | 38 | const std = @import("std"); |
| 39 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 39 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 40 | 40 | #expect_stdout="100 200\n" |
| 41 | 41 | |
| 42 | 42 | #update=change values |
| ... | ... | @@ -54,5 +54,5 @@ fn foo(val: *const S) !void { |
| 54 | 54 | ); |
| 55 | 55 | } |
| 56 | 56 | const std = @import("std"); |
| 57 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 57 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 58 | 58 | #expect_stdout="1234 5678\n" |
test/incremental/change_zon_file+3-3| ... | ... | @@ -10,7 +10,7 @@ const message: []const u8 = @import("message.zon"); |
| 10 | 10 | pub fn main() !void { |
| 11 | 11 | try std.Io.File.stdout().writeStreamingAll(io, message); |
| 12 | 12 | } |
| 13 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 13 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 14 | 14 | #file=message.zon |
| 15 | 15 | "Hello, World!\n" |
| 16 | 16 | #expect_stdout="Hello, World!\n" |
| ... | ... | @@ -32,7 +32,7 @@ const message: []const u8 = @import("message.zon"); |
| 32 | 32 | pub fn main() !void { |
| 33 | 33 | try std.Io.File.stdout().writeStreamingAll(io, "a hardcoded string\n"); |
| 34 | 34 | } |
| 35 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 35 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 36 | 36 | #expect_error=message.zon:1:1: error: unable to load 'message.zon': FileNotFound |
| 37 | 37 | #expect_error=main.zig:2:37: note: file imported here |
| 38 | 38 | |
| ... | ... | @@ -48,5 +48,5 @@ const message: []const u8 = @import("message.zon"); |
| 48 | 48 | pub fn main() !void { |
| 49 | 49 | try std.Io.File.stdout().writeStreamingAll(io, message); |
| 50 | 50 | } |
| 51 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 51 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 52 | 52 | #expect_stdout="We're back, World!\n" |
test/incremental/change_zon_file_no_result_type+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | #update=initial version |
| 7 | 7 | #file=main.zig |
| 8 | 8 | const std = @import("std"); |
| 9 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 9 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 10 | 10 | pub fn main() !void { |
| 11 | 11 | try std.Io.File.stdout().writeStreamingAll(io, @import("foo.zon").message); |
| 12 | 12 | } |
test/incremental/compile_log+3-3| ... | ... | @@ -10,7 +10,7 @@ const std = @import("std"); |
| 10 | 10 | pub fn main() !void { |
| 11 | 11 | try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n"); |
| 12 | 12 | } |
| 13 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 13 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 14 | 14 | #expect_stdout="Hello, World!\n" |
| 15 | 15 | |
| 16 | 16 | #update=add compile log |
| ... | ... | @@ -20,7 +20,7 @@ pub fn main() !void { |
| 20 | 20 | try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n"); |
| 21 | 21 | @compileLog("this is a log"); |
| 22 | 22 | } |
| 23 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 23 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 24 | 24 | #expect_error=main.zig:4:5: error: found compile log statement |
| 25 | 25 | #expect_compile_log=@as(*const [13:0]u8, "this is a log") |
| 26 | 26 | |
| ... | ... | @@ -30,5 +30,5 @@ const std = @import("std"); |
| 30 | 30 | pub fn main() !void { |
| 31 | 31 | try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n"); |
| 32 | 32 | } |
| 33 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 33 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 34 | 34 | #expect_stdout="Hello, World!\n" |
test/incremental/fix_astgen_failure+3-3| ... | ... | @@ -19,7 +19,7 @@ const std = @import("std"); |
| 19 | 19 | pub fn hello() !void { |
| 20 | 20 | try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n"); |
| 21 | 21 | } |
| 22 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 22 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 23 | 23 | #expect_stdout="Hello, World!\n" |
| 24 | 24 | #update=add new error |
| 25 | 25 | #file=foo.zig |
| ... | ... | @@ -27,7 +27,7 @@ const std = @import("std"); |
| 27 | 27 | pub fn hello() !void { |
| 28 | 28 | try std.Io.File.stdout().writeStreamingAll(io, hello_str); |
| 29 | 29 | } |
| 30 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 30 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 31 | 31 | #expect_error=foo.zig:3:52: error: use of undeclared identifier 'hello_str' |
| 32 | 32 | #update=fix the new error |
| 33 | 33 | #file=foo.zig |
| ... | ... | @@ -36,5 +36,5 @@ const hello_str = "Hello, World! Again!\n"; |
| 36 | 36 | pub fn hello() !void { |
| 37 | 37 | try std.Io.File.stdout().writeStreamingAll(io, hello_str); |
| 38 | 38 | } |
| 39 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 39 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 40 | 40 | #expect_stdout="Hello, World! Again!\n" |
test/incremental/function_becomes_inline+3-3| ... | ... | @@ -11,7 +11,7 @@ fn foo() !void { |
| 11 | 11 | try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n"); |
| 12 | 12 | } |
| 13 | 13 | const std = @import("std"); |
| 14 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 14 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 15 | 15 | #expect_stdout="Hello, World!\n" |
| 16 | 16 | |
| 17 | 17 | #update=make function inline |
| ... | ... | @@ -23,7 +23,7 @@ inline fn foo() !void { |
| 23 | 23 | try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n"); |
| 24 | 24 | } |
| 25 | 25 | const std = @import("std"); |
| 26 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 26 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 27 | 27 | #expect_stdout="Hello, World!\n" |
| 28 | 28 | |
| 29 | 29 | #update=change string |
| ... | ... | @@ -35,5 +35,5 @@ inline fn foo() !void { |
| 35 | 35 | try std.Io.File.stdout().writeStreamingAll(io, "Hello, `inline` World!\n"); |
| 36 | 36 | } |
| 37 | 37 | const std = @import("std"); |
| 38 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 38 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 39 | 39 | #expect_stdout="Hello, `inline` World!\n" |
test/incremental/hello+2-2| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | #update=initial version |
| 7 | 7 | #file=main.zig |
| 8 | 8 | const std = @import("std"); |
| 9 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 9 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 10 | 10 | pub fn main() !void { |
| 11 | 11 | try std.Io.File.stdout().writeStreamingAll(io, "good morning\n"); |
| 12 | 12 | } |
| ... | ... | @@ -14,7 +14,7 @@ pub fn main() !void { |
| 14 | 14 | #update=change the string |
| 15 | 15 | #file=main.zig |
| 16 | 16 | const std = @import("std"); |
| 17 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 17 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 18 | 18 | pub fn main() !void { |
| 19 | 19 | try std.Io.File.stdout().writeStreamingAll(io, "おはようございます\n"); |
| 20 | 20 | } |
test/incremental/make_decl_pub+2-2| ... | ... | @@ -14,7 +14,7 @@ const std = @import("std"); |
| 14 | 14 | fn hello() !void { |
| 15 | 15 | try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n"); |
| 16 | 16 | } |
| 17 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 17 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 18 | 18 | #expect_error=main.zig:3:12: error: 'hello' is not marked 'pub' |
| 19 | 19 | #expect_error=foo.zig:2:1: note: declared here |
| 20 | 20 | |
| ... | ... | @@ -24,5 +24,5 @@ const std = @import("std"); |
| 24 | 24 | pub fn hello() !void { |
| 25 | 25 | try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n"); |
| 26 | 26 | } |
| 27 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 27 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 28 | 28 | #expect_stdout="Hello, World!\n" |
test/incremental/modify_inline_fn+2-2| ... | ... | @@ -13,7 +13,7 @@ pub fn main() !void { |
| 13 | 13 | inline fn getStr() []const u8 { |
| 14 | 14 | return "foo\n"; |
| 15 | 15 | } |
| 16 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 16 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 17 | 17 | #expect_stdout="foo\n" |
| 18 | 18 | #update=change the string |
| 19 | 19 | #file=main.zig |
| ... | ... | @@ -25,5 +25,5 @@ pub fn main() !void { |
| 25 | 25 | inline fn getStr() []const u8 { |
| 26 | 26 | return "bar\n"; |
| 27 | 27 | } |
| 28 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 28 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 29 | 29 | #expect_stdout="bar\n" |
test/incremental/move_src+2-2| ... | ... | @@ -16,7 +16,7 @@ fn foo() u32 { |
| 16 | 16 | fn bar() u32 { |
| 17 | 17 | return 123; |
| 18 | 18 | } |
| 19 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 19 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 20 | 20 | #expect_stdout="7 123\n" |
| 21 | 21 | |
| 22 | 22 | #update=add newline |
| ... | ... | @@ -33,5 +33,5 @@ fn foo() u32 { |
| 33 | 33 | fn bar() u32 { |
| 34 | 34 | return 123; |
| 35 | 35 | } |
| 36 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 36 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 37 | 37 | #expect_stdout="8 123\n" |
test/incremental/no_change_preserves_tag_names+2-2| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | #file=main.zig |
| 8 | 8 | const std = @import("std"); |
| 9 | 9 | var some_enum: enum { first, second } = .first; |
| 10 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 10 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 11 | 11 | pub fn main() !void { |
| 12 | 12 | try std.Io.File.stdout().writeStreamingAll(io, @tagName(some_enum)); |
| 13 | 13 | } |
| ... | ... | @@ -16,7 +16,7 @@ pub fn main() !void { |
| 16 | 16 | #file=main.zig |
| 17 | 17 | const std = @import("std"); |
| 18 | 18 | var some_enum: enum { first, second } = .first; |
| 19 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 19 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 20 | 20 | pub fn main() !void { |
| 21 | 21 | try std.Io.File.stdout().writeStreamingAll(io, @tagName(some_enum)); |
| 22 | 22 | } |
test/incremental/recursive_function_becomes_non_recursive+2-2| ... | ... | @@ -14,7 +14,7 @@ fn foo(recurse: bool) !void { |
| 14 | 14 | try stdout.writeStreamingAll(io, "non-recursive path\n"); |
| 15 | 15 | } |
| 16 | 16 | const std = @import("std"); |
| 17 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 17 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 18 | 18 | #expect_stdout="non-recursive path\n" |
| 19 | 19 | |
| 20 | 20 | #update=eliminate recursion and change argument |
| ... | ... | @@ -28,5 +28,5 @@ fn foo(recurse: bool) !void { |
| 28 | 28 | try stdout.writeStreamingAll(io, "non-recursive path\n"); |
| 29 | 29 | } |
| 30 | 30 | const std = @import("std"); |
| 31 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 31 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 32 | 32 | #expect_stdout="x==1\n" |
test/incremental/remove_enum_field+2-2| ... | ... | @@ -14,7 +14,7 @@ pub fn main() !void { |
| 14 | 14 | try stdout_writer.interface.print("{}\n", .{@intFromEnum(MyEnum.foo)}); |
| 15 | 15 | } |
| 16 | 16 | const std = @import("std"); |
| 17 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 17 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 18 | 18 | #expect_stdout="1\n" |
| 19 | 19 | #update=remove enum field |
| 20 | 20 | #file=main.zig |
| ... | ... | @@ -27,6 +27,6 @@ pub fn main() !void { |
| 27 | 27 | try stdout_writer.interface.print("{}\n", .{@intFromEnum(MyEnum.foo)}); |
| 28 | 28 | } |
| 29 | 29 | const std = @import("std"); |
| 30 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 30 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 31 | 31 | #expect_error=main.zig:7:69: error: enum 'main.MyEnum' has no member named 'foo' |
| 32 | 32 | #expect_error=main.zig:1:16: note: enum declared here |
test/incremental/unreferenced_error+4-4| ... | ... | @@ -10,7 +10,7 @@ pub fn main() !void { |
| 10 | 10 | try std.Io.File.stdout().writeStreamingAll(io, a); |
| 11 | 11 | } |
| 12 | 12 | const a = "Hello, World!\n"; |
| 13 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 13 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 14 | 14 | #expect_stdout="Hello, World!\n" |
| 15 | 15 | |
| 16 | 16 | #update=introduce compile error |
| ... | ... | @@ -20,7 +20,7 @@ pub fn main() !void { |
| 20 | 20 | try std.Io.File.stdout().writeStreamingAll(io, a); |
| 21 | 21 | } |
| 22 | 22 | const a = @compileError("bad a"); |
| 23 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 23 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 24 | 24 | #expect_error=main.zig:5:11: error: bad a |
| 25 | 25 | |
| 26 | 26 | #update=remove error reference |
| ... | ... | @@ -31,7 +31,7 @@ pub fn main() !void { |
| 31 | 31 | } |
| 32 | 32 | const a = @compileError("bad a"); |
| 33 | 33 | const b = "Hi there!\n"; |
| 34 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 34 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 35 | 35 | #expect_stdout="Hi there!\n" |
| 36 | 36 | |
| 37 | 37 | #update=introduce and remove reference to error |
| ... | ... | @@ -42,5 +42,5 @@ pub fn main() !void { |
| 42 | 42 | } |
| 43 | 43 | const a = "Back to a\n"; |
| 44 | 44 | const b = @compileError("bad b"); |
| 45 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 45 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 46 | 46 | #expect_stdout="Back to a\n" |
test/standalone/coff_dwarf/build.zig+3| ... | ... | @@ -46,6 +46,9 @@ pub fn build(b: *std.Build) void { |
| 46 | 46 | lib.root_module.addCSourceFile(.{ .file = b.path("shared_lib.c"), .flags = &.{"-gdwarf"} }); |
| 47 | 47 | exe.root_module.linkLibrary(lib); |
| 48 | 48 | |
| 49 | if (target.result.os.tag == .windows) | |
| 50 | exe.root_module.linkSystemLibrary("ws2_32", .{}); | |
| 51 | ||
| 49 | 52 | const run = b.addRunArtifact(exe); |
| 50 | 53 | run.expectExitCode(0); |
| 51 | 54 | run.skip_foreign_checks = true; |
test/standalone/dirname/exists_in.zig+1-1| ... | ... | @@ -26,7 +26,7 @@ pub fn main(init: std.process.Init) !void { |
| 26 | 26 | return error.BadUsage; |
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 29 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 30 | 30 | |
| 31 | 31 | var dir = try std.Io.Dir.cwd().openDir(io, dir_path, .{}); |
| 32 | 32 | defer dir.close(io); |
test/standalone/dirname/touch.zig+1-1| ... | ... | @@ -21,7 +21,7 @@ pub fn main(init: std.process.Init) !void { |
| 21 | 21 | const dir_path = std.Io.Dir.path.dirname(path) orelse unreachable; |
| 22 | 22 | const basename = std.Io.Dir.path.basename(path); |
| 23 | 23 | |
| 24 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 24 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 25 | 25 | |
| 26 | 26 | var dir = try std.Io.Dir.cwd().openDir(io, dir_path, .{}); |
| 27 | 27 | defer dir.close(io); |
test/standalone/issue_5825/build.zig+1| ... | ... | @@ -34,6 +34,7 @@ pub fn build(b: *std.Build) void { |
| 34 | 34 | exe.subsystem = .console; |
| 35 | 35 | exe.root_module.linkSystemLibrary("kernel32", .{}); |
| 36 | 36 | exe.root_module.linkSystemLibrary("ntdll", .{}); |
| 37 | exe.root_module.linkSystemLibrary("ws2_32", .{}); | |
| 37 | 38 | exe.root_module.addObject(obj); |
| 38 | 39 | |
| 39 | 40 | // TODO: actually check the output |
test/standalone/mix_o_files/build.zig+3| ... | ... | @@ -16,6 +16,9 @@ pub fn build(b: *std.Build) void { |
| 16 | 16 | }), |
| 17 | 17 | }); |
| 18 | 18 | |
| 19 | if (target.result.os.tag == .windows) | |
| 20 | obj.root_module.linkSystemLibrary("ws2_32", .{}); | |
| 21 | ||
| 19 | 22 | const exe = b.addExecutable(.{ |
| 20 | 23 | .name = "test", |
| 21 | 24 | .root_module = b.createModule(.{ |
test/standalone/run_cwd/check_file_exists.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ pub fn main(init: std.process.Init) !void { |
| 5 | 5 | if (args.len != 2) return error.BadUsage; |
| 6 | 6 | const path = args[1]; |
| 7 | 7 | |
| 8 | const io = std.Io.Threaded.global_single_threaded.ioBasic(); | |
| 8 | const io = std.Io.Threaded.global_single_threaded.io(); | |
| 9 | 9 | |
| 10 | 10 | std.Io.Dir.cwd().access(io, path, .{}) catch return error.AccessFailed; |
| 11 | 11 | } |
test/standalone/shared_library/build.zig+4-1| ... | ... | @@ -5,7 +5,7 @@ pub fn build(b: *std.Build) void { |
| 5 | 5 | b.default_step = test_step; |
| 6 | 6 | |
| 7 | 7 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 8 | const target = b.graph.host; | |
| 8 | const target = b.standardTargetOptions(.{}); | |
| 9 | 9 | |
| 10 | 10 | const exe_names: []const []const u8 = &.{ "test", "test-dync" }; |
| 11 | 11 | const lib_names: []const []const u8 = &.{ "mathtest", "mathtest-dync" }; |
| ... | ... | @@ -24,6 +24,9 @@ pub fn build(b: *std.Build) void { |
| 24 | 24 | }), |
| 25 | 25 | }); |
| 26 | 26 | |
| 27 | if (target.result.os.tag == .windows) | |
| 28 | lib.root_module.linkSystemLibrary("ws2_32", .{}); | |
| 29 | ||
| 27 | 30 | const exe = b.addExecutable(.{ |
| 28 | 31 | .name = exe_name, |
| 29 | 32 | .root_module = b.createModule(.{ |
test/standalone/windows_argv/build.zig+3| ... | ... | @@ -20,6 +20,8 @@ pub fn build(b: *std.Build) !void { |
| 20 | 20 | .optimize = optimize, |
| 21 | 21 | }), |
| 22 | 22 | }); |
| 23 | lib_gnu.root_module.linkSystemLibrary("ws2_32", .{}); | |
| 24 | ||
| 23 | 25 | const verify_gnu = b.addExecutable(.{ |
| 24 | 26 | .name = "verify-gnu", |
| 25 | 27 | .root_module = b.createModule(.{ |
| ... | ... | @@ -101,6 +103,7 @@ pub fn build(b: *std.Build) !void { |
| 101 | 103 | .flags = &.{ "-DUNICODE", "-D_UNICODE" }, |
| 102 | 104 | }); |
| 103 | 105 | verify_msvc.root_module.linkLibrary(lib_msvc); |
| 106 | verify_msvc.root_module.linkSystemLibrary("ws2_32", .{}); | |
| 104 | 107 | verify_msvc.root_module.link_libc = true; |
| 105 | 108 | |
| 106 | 109 | const run_msvc = b.addRunArtifact(fuzz); |